private void setOrRemoveTransient(EClass eClass) {
   if (eClass.getEAnnotation("teneo.jpa") != null) {
     eClass.getEAnnotations().remove(eClass.getEAnnotation("teneo.jpa"));
   } else {
     final EAnnotation eAnnotation = EcoreFactory.eINSTANCE.createEAnnotation();
     eAnnotation.setSource("teneo.jpa");
     eAnnotation.getDetails().put("value", "@Transient");
     eClass.getEAnnotations().add(eAnnotation);
   }
 }
Example #2
0
 //
 // Create the ResultValidatableNode,ResultConstrainingNode cross-linkage for all
 // validateableObject,constraint pairs.
 //
 protected void createResults(@NonNull Set<Resource> resources) {
   for (Resource resource : resources) {
     System.out.println("createResults " + resource.getURI());
     System.out.println(resource);
     for (TreeIterator<EObject> tit = resource.getAllContents(); tit.hasNext(); ) {
       @SuppressWarnings("null")
       @NonNull
       EObject eObject = tit.next();
       EClass eClass = eObject.eClass();
       EAnnotation eAnnotation = eClass.getEAnnotation("http://www.eclipse.org/uml2/2.0.0/UML");
       if ((eAnnotation != null)
           && (eAnnotation.getReferences().size() > 0)) { // Stereotype application
         EObject umlClass = eAnnotation.getReferences().get(0);
         if (umlClass != null) {
           createResultNodes(eObject, getURI(umlClass));
           //						eClass = null;
         }
       } else if (eClass != null) {
         for (@SuppressWarnings("null") @NonNull URI aType : getTypeClosure(eClass)) {
           //				System.out.println("  ... " + getLabel(eObject) + " " + getLabel(aType));
           createResultNodes(eObject, aType);
         }
       }
     }
   }
 }
 private void write(PrintWriter out, IdEObject object) throws SerializerException {
   EClass eClass = object.eClass();
   if (eClass.getEAnnotation("hidden") != null) {
     return;
   }
   out.print(DASH);
   int convertedKey = getExpressId(object);
   if (convertedKey == -1) {
     throw new SerializerException(
         "Going to serialize an object with id -1 (" + object.eClass().getName() + ")");
   }
   out.print(String.valueOf(convertedKey));
   out.print("= ");
   String upperCase = upperCases.get(eClass);
   if (upperCase == null) {
     throw new SerializerException("Type not found: " + eClass.getName());
   }
   out.print(upperCase);
   out.print(OPEN_PAREN);
   boolean isFirst = true;
   for (EStructuralFeature feature : eClass.getEAllStructuralFeatures()) {
     if (!feature.isDerived() && feature.getEAnnotation("hidden") == null) {
       EClassifier type = feature.getEType();
       if (type instanceof EEnum) {
         if (!isFirst) {
           out.print(COMMA);
         }
         writeEnum(out, object, feature);
         isFirst = false;
       } else if (type instanceof EClass) {
         if (!isInverse(feature)) {
           if (!isFirst) {
             out.print(COMMA);
           }
           writeEClass(out, object, feature);
           isFirst = false;
         }
       } else if (type instanceof EDataType) {
         if (!isFirst) {
           out.print(COMMA);
         }
         writeEDataType(out, object, feature);
         isFirst = false;
       }
     }
   }
   out.println(PAREN_CLOSE_SEMICOLON);
 }
Example #4
0
 public boolean isInternal() {
   return eclass.getEAnnotation(EclDocConstants.INTERNAL_ANN) != null;
 }
 private void writeWrappedValue(
     PrintWriter out, EObject object, EStructuralFeature feature, EClass ec)
     throws SerializerException {
   Object get = object.eGet(feature);
   boolean isWrapped = ec.getEAnnotation("wrapped") != null;
   EStructuralFeature structuralFeature = ec.getEStructuralFeature(WRAPPED_VALUE);
   if (get instanceof EObject) {
     boolean isDefinedWrapped = feature.getEType().getEAnnotation("wrapped") != null;
     EObject betweenObject = (EObject) get;
     if (betweenObject != null) {
       if (isWrapped && isDefinedWrapped) {
         Object val = betweenObject.eGet(structuralFeature);
         String name = structuralFeature.getEType().getName();
         if ((name.equals(IFC_BOOLEAN) || name.equals(IFC_LOGICAL)) && val == null) {
           out.print(BOOLEAN_UNDEFINED);
         } else if (structuralFeature.getEType() == ECORE_PACKAGE_INSTANCE.getEDouble()) {
           Object stringVal =
               betweenObject.eGet(
                   betweenObject.eClass().getEStructuralFeature("wrappedValueAsString"));
           if (stringVal != null && model.isUseDoubleStrings()) {
             out.print(stringVal);
           } else {
             out.print(val);
           }
         } else {
           writePrimitive(out, val);
         }
       } else {
         writeEmbedded(out, betweenObject);
       }
     }
   } else if (get instanceof EList<?>) {
     EList<?> list = (EList<?>) get;
     if (list.isEmpty()) {
       if (!feature.isUnsettable()) {
         out.print(OPEN_CLOSE_PAREN);
       } else {
         out.print("$");
       }
     } else {
       out.print(OPEN_PAREN);
       boolean first = true;
       for (Object o : list) {
         if (!first) {
           out.print(COMMA);
         }
         EObject object2 = (EObject) o;
         Object val = object2.eGet(structuralFeature);
         if (structuralFeature.getEType() == ECORE_PACKAGE_INSTANCE.getEDouble()) {
           out.print(
               object2.eGet(
                   object2
                       .eClass()
                       .getEStructuralFeature("stringValue" + structuralFeature.getName())));
         } else {
           writePrimitive(out, val);
         }
         first = false;
       }
       out.print(CLOSE_PAREN);
     }
   } else {
     if (get == null) {
       EClassifier type = structuralFeature.getEType();
       if (type == IFC_PACKAGE_INSTANCE.getIfcBoolean()
           || type == IFC_PACKAGE_INSTANCE.getIfcLogical()
           || type == ECORE_PACKAGE_INSTANCE.getEBoolean()) {
         out.print(BOOLEAN_UNDEFINED);
       } else {
         SchemaDefinition schema;
         try {
           schema = getPluginManager().requireSchemaDefinition();
         } catch (PluginException e) {
           throw new SerializerException(e);
         }
         EntityDefinition entityBN = schema.getEntityBN(object.eClass().getName());
         if (entityBN != null && entityBN.isDerived(feature.getName())) {
           out.print("*");
         } else {
           out.print(DOLLAR);
         }
       }
     }
   }
 }