コード例 #1
0
 private void doSubtypes(DerivedAttribute2 attribute) {
   for (EntityDefinition entityDefinition : subtypes) {
     entityDefinition.addDerived(
         new DerivedAttribute2(
             attribute.getName(),
             attribute.getType(),
             attribute.getExpressCode(),
             attribute.isCollection(),
             true),
         false);
     entityDefinition.doSubtypes(attribute);
   }
 }
コード例 #2
0
 public void addDerived(DerivedAttribute2 attribute, boolean firstOccurance) {
   if (!derivedAttributes.containsKey(attribute.getName())) {
     derivedAttributes.put(attribute.getName(), attribute);
   } else {
     if (firstOccurance) {
       derivedAttributes.put(attribute.getName(), attribute);
     }
   }
   for (EntityDefinition entityDefinition : supertypes) {
     if (entityDefinition.getAttributeBNWithSuper(attribute.getName()) != null) {
       derivedAttributesOverride.add(attribute.getName());
     }
   }
   doSubtypes(attribute);
 }
コード例 #3
0
 public SchemaFieldIgnoreMap(Set<? extends EPackage> packages, SchemaDefinition schema) {
   super(packages);
   ArrayList<EntityDefinition> entities = schema.getEntities();
   for (EntityDefinition entity : entities) {
     for (Attribute attribute : entity.getAttributes(true)) {
       if (attribute instanceof InverseAttribute) {
         if (attribute.getName().equals("HasOpenings")) {
           // || attribute.getName().equals("IsDecomposedBy") ||
           // attribute.getName().equals("ContainedInStructure") ||
           // attribute.getName().equals("FillsVoids") ||
           // attribute.getName().equals("VoidsElements")
           // Exception: http://code.google.com/p/bimserver/issues/detail?id=303
           // Addition: Leon says this should be done for all types
         } else {
           addToGeneralIgnoreSet(
               new StructuralFeatureIdentifier(entity.getName(), attribute.getName()));
         }
       }
     }
   }
 }
コード例 #4
0
 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);
         }
       }
     }
   }
 }
コード例 #5
0
 public boolean addSupertype(EntityDefinition parent) {
   supertypes.add(parent);
   supertypesBN.put(parent.getName(), parent);
   return true;
 }