public boolean createIndexTable(EClass eClass, EStructuralFeature eStructuralFeature, DatabaseSession databaseSession, boolean transactional) throws BimserverDatabaseException { return keyValueStore.createIndexTable(eClass.getEPackage().getName() + "_" + eClass.getName() + "_" + eStructuralFeature.getName(), databaseSession, transactional); }
public static String makeGetter(EStructuralFeature eStructuralFeature) { StringBuilder sb = new StringBuilder(); if (eStructuralFeature.getEType() == EcorePackage.eINSTANCE.getEBoolean()) { sb.append("is"); } else { sb.append("get"); } sb.append(firstLetterUpperCase(eStructuralFeature.getName())); if (eStructuralFeature instanceof EReference && !eStructuralFeature.isMany() && eStructuralFeature.getEAnnotation("embedsreference") == null) { sb.append("Id"); } return sb.toString(); }
public void addUseForSerialization(EStructuralFeature eStructuralFeature) { if (eStructuralFeature.getEContainingClass().isSuperTypeOf(eClass)) { useForSerializationFeatures.put(eStructuralFeature, true); } else { throw new IllegalArgumentException(eStructuralFeature.getName() + " does not exist in " + eClass.getName()); } }
private boolean useUnsetBit(EStructuralFeature feature) { // TODO non-unsettable boolean values can also be stored in these bits if (feature.isUnsettable()) { return true; } else { if (feature.isMany()) { return true; } if (feature.getDefaultValue() == null || (feature.getDefaultValue() != null && feature.getDefaultValue() == null)) { return true; } } return false; }
public static String makeSetter(EStructuralFeature eStructuralFeature) { StringBuilder sb = new StringBuilder(); sb.append("set" + firstLetterUpperCase(eStructuralFeature.getName())); if (eStructuralFeature instanceof EReference && !eStructuralFeature.isMany() && eStructuralFeature.getEAnnotation("embedsreference") == null) { sb.append("Id"); } return sb.toString(); }
if (eClassifier instanceof EClass) { EClass eClass = (EClass)eClassifier; for (EStructuralFeature eStructuralFeature : eClass.getEAllStructuralFeatures()) { if (eStructuralFeature.isMany()) { hasLists = true; break; if (eStructuralFeature.getEAnnotation("notinserviceinterface") == null) { if (eStructuralFeature instanceof EAttribute) { EAttribute eAttribute = (EAttribute)eStructuralFeature; stringBuffer.append(eStructuralFeature.getName()); stringBuffer.append((eStructuralFeature instanceof EReference && !eStructuralFeature.isMany() && eStructuralFeature.getEAnnotation("embedsreference") == null) ? "Id" : "" ); stringBuffer.append(TEXT_34); stringBuffer.append(eStructuralFeature.getEType() == EcorePackage.eINSTANCE.getEBoolean() ? "is" : "get"); stringBuffer.append(StringUtils.firstUpperCase(eStructuralFeature.getName())); stringBuffer.append((eStructuralFeature instanceof EReference && !eStructuralFeature.isMany() && eStructuralFeature.getEAnnotation("embedsreference") == null) ? "Id" : "" ); stringBuffer.append(TEXT_35); if (eStructuralFeature.getEType() == EcorePackage.eINSTANCE.getEDate()) { importManager.getImport("java.util.Date"); } else if (eStructuralFeature.getEType().getName().equals("DataHandler")) { importManager.getImport("javax.activation.DataHandler"); boolean useId = (eStructuralFeature instanceof EReference && !eStructuralFeature.isMany() && eStructuralFeature.getEAnnotation("embedsreference") == null); stringBuffer.append(eStructuralFeature.getName()); stringBuffer.append((eStructuralFeature instanceof EReference && !eStructuralFeature.isMany() && eStructuralFeature.getEAnnotation("embedsreference") == null) ? "Id" : "" ); stringBuffer.append(TEXT_40);
@SuppressWarnings({ "unchecked", "rawtypes" }) public static void fillDataObject(BiMap<? extends Long, ? extends EObject> mapResult, EObject eObject, DataObject dataObject) { for (EStructuralFeature eStructuralFeature : eObject.eClass().getEAllStructuralFeatures()) { Object eGet = eObject.eGet(eStructuralFeature); if (eStructuralFeature.getEAnnotation("hidden") == null && !eStructuralFeature.isDerived()) { if (eStructuralFeature instanceof EAttribute) { if (eStructuralFeature.isMany()) { ListDataValue listDataValue = StoreFactory.eINSTANCE.createListDataValue(); listDataValue.setFieldName(eStructuralFeature.getName()); dataObject.getValues().add(listDataValue); if (eStructuralFeature.getEType() == EcorePackage.eINSTANCE.getEDoubleObject() || eStructuralFeature.getEType() == EcorePackage.eINSTANCE.getEDouble()) { EStructuralFeature asStringFeature = eObject.eClass().getEStructuralFeature(eStructuralFeature.getName() + "AsString"); dataValue.setStringValue(null); dataValue.setFieldName(eStructuralFeature.getName()); if (eStructuralFeature.isMany()) { if (eStructuralFeature.getEType() == EcorePackage.eINSTANCE.getEDouble() || eStructuralFeature.getEType() == EcorePackage.eINSTANCE.getEDoubleObject()) { List list = (List)eObject.eGet(eObject.eClass().getEStructuralFeature(eStructuralFeature.getName() + "AsString")); ListDataValue dataValue = StoreFactory.eINSTANCE.createListDataValue(); dataValue.setFieldName(eStructuralFeature.getName()); dataValue.setFieldName(eStructuralFeature.getName()); e.setFieldName(eStructuralFeature.getName()); reference.setFieldName(eStructuralFeature.getName());
private void write(MinimalVirtualObject object) throws IOException { if (object.eClass().getEAnnotation("wrapped") != null) { EStructuralFeature wrappedFeature = object.eClass().getEStructuralFeature("wrappedValue"); print("{"); print("\"_t\":\"" + object.eClass().getName() + "\","); print("\"_v\":"); Object wrappedValue = object.eGet(wrappedFeature); if (eStructuralFeature instanceof EReference) { print("{"); print("\"_t\":\"" + eStructuralFeature.getEType().getName() + "\","); print("\"_r\":" + o.toString()); print("}"); print("\"_t\":\"" + object.eClass().getName() + "\","); for (EStructuralFeature eStructuralFeature : object.eClass().getEAllStructuralFeatures()) { print("\"" + eStructuralFeature.getName() + "\":"); if (eStructuralFeature.getEType() instanceof EDataType) { writePrimitive(eStructuralFeature, object.eGet(eStructuralFeature)); } else { write((MinimalVirtualObject) val); if (object.eClass().getEAllStructuralFeatures().get(object.eClass().getEAllStructuralFeatures().size()-1) != eStructuralFeature) { print(",");
protected void validate() { if (value != null && !eStructuralFeature.getEType().isInstance(value)) { String valueClass = value instanceof EObject ? ((EObject)value).eClass().getName() : value.getClass().getName(); throw new ClassCastException ("The feature '" + eStructuralFeature.getName() + "'s type '" + eStructuralFeature.getEType().getName() + "' does not permit a value of type '" + valueClass + "'"); } }
protected void supersetAdd(Object object) { if (supersetFeatureIDs != null) { Resource.Internal eInternalResource = owner.eInternalResource(); if (eInternalResource != null && eInternalResource.isLoading()) { return; } for (int i = 0; i < supersetFeatureIDs.length; i++) { EStructuralFeature supersetEStructuralFeature = owner.eClass() .getEStructuralFeature(supersetFeatureIDs[i]); if (supersetEStructuralFeature.isMany()) { @SuppressWarnings("unchecked") EList<Object> supersetEList = (EList<Object>) owner .eGet(supersetEStructuralFeature); if (!supersetEList.contains(object)) { supersetEList.add(object); } } } } }
return converted.get(original); EStructuralFeature targetFeature = newObject.eClass().getEStructuralFeature(eStructuralFeature.getName()); if (targetFeature == null) { continue; if (eStructuralFeature.getEType() instanceof EEnum) { EEnum targetEnum = (EEnum) targetFeature.getEType(); EEnumLiteral newLiteral = targetEnum.getEEnumLiteral(get.toString()); if (newLiteral != null) { if (get == null) { } else { if (eStructuralFeature.isMany()) { EList<EObject> list = (EList<EObject>) get; AbstractEList<EObject> toList = (AbstractEList<EObject>) newObject.eGet(targetFeature); for (Object o : list) { IdEObject ref = (IdEObject)o; if (targetFeature.getEType().isInstance(ref)) { if (converted.containsKey(o)) { toList.addUnique(converted.get(o)); if (targetFeature.isMany()) { LOGGER.info("Different multiplicity"); } else {
@SuppressWarnings("unchecked") private void writeTable(PrintWriter out, EObject eObject) { out.println("<h1>" + eObject.eClass().getName() + "</h1>"); out.println("<table>"); for (EStructuralFeature eStructuralFeature : eObject.eClass().getEAllStructuralFeatures()) { if (eStructuralFeature.getEAnnotation("hidden") == null) { out.println("<tr>"); out.println("<td>" + eStructuralFeature.getName() + "</td>"); Object eGet = eObject.eGet(eStructuralFeature); if (eStructuralFeature instanceof EAttribute) { if (eStructuralFeature.getUpperBound() == 1) { out.println("<td>" + eGet + "</td>"); } else { if (eStructuralFeature.getUpperBound() == 1) { if (eStructuralFeature.getEType().getEAnnotation("wrapped") != null) { EObject value = (EObject) eGet; if (value != null) { out.println("<td>" + value.eGet(value.eClass().getEStructuralFeature("wrappedValue")) + "</td>"); if (eStructuralFeature.getEType().getEAnnotation("wrapped") != null) { List<EObject> list = (List<EObject>) eGet; out.println("<td>");
private void processPossibleIndices(ByteBuffer keyBuffer, int pid, int rid, long oid, EClass eClass, ByteBuffer valueBuffer) throws BimserverLockConflictException, BimserverDatabaseException { boolean hasAtLeastOneIndex = false; for (EStructuralFeature eStructuralFeature : eClass.getEAllStructuralFeatures()) { if (eStructuralFeature.getEAnnotation("singleindex") != null) { hasAtLeastOneIndex = true; break; oldKeyBuffer.putLong(oid); oldKeyBuffer.putInt(-(rid - 1)); oldData = database.getKeyValueStore().get(eClass.getEPackage().getName() + "_" + eClass.getName(), oldKeyBuffer.array(), this); for (EStructuralFeature eStructuralFeature : eClass.getEAllStructuralFeatures()) { if (eStructuralFeature.getEAnnotation("singleindex") != null) { String indexTableName = eClass.getEPackage().getName() + "_" + eClass.getName() + "_" + eStructuralFeature.getName(); if (perRecordVersioning && oldData != null) { ByteBuffer oldValue = ByteBuffer.wrap(oldData);
private void writeEmbedded(IdEObject object) throws IOException { print("{"); print("\"_t\":\"" + object.eClass().getName() + "\","); for (EStructuralFeature eStructuralFeature : object.eClass().getEAllStructuralFeatures()) { print("\"" + eStructuralFeature.getName() + "\":"); writePrimitive(eStructuralFeature, object.eGet(eStructuralFeature)); if (object.eClass().getEAllStructuralFeatures().get(object.eClass().getEAllStructuralFeatures().size()-1) != eStructuralFeature) { print(","); } } print("}"); }
private void compareEClass(EClass eClass1, EClass eClass2) throws SchemaCompareException { if (eClass1.getEAllStructuralFeatures().size() != eClass2.getEAllStructuralFeatures().size()) { throw new SchemaCompareException("Not the same amount of features in " + eClass1.getName()); } Iterator<EStructuralFeature> iterator1 = eClass1.getEAllStructuralFeatures().iterator(); Iterator<EStructuralFeature> iterator2 = eClass2.getEAllStructuralFeatures().iterator(); while (iterator1.hasNext()) { EStructuralFeature structuralFeature1 = iterator1.next(); EStructuralFeature structuralFeature2 = iterator2.next(); if (!structuralFeature1.getName().equals(structuralFeature2.getName())) { throw new SchemaCompareException("Features not the same name"); } if (!structuralFeature1.getEType().getName().equals(structuralFeature2.getEType().getName())) { throw new SchemaCompareException("Features not of the same type"); } } }
@SuppressWarnings({ "rawtypes", "unchecked" }) private EObject from(JsonParser jp, EClass eClass) throws JsonParseException, IOException { EObject result = eClass.getEPackage().getEFactoryInstance().create(eClass); Map<String, EStructuralFeature> fieldFeatureMap = JsonMetadata.INSTANCE.getJsonFeatures(eClass); EDataType dataType = (EDataType) feature.getEType(); if (feature.isMany()) { if (nextToken == JsonToken.START_ARRAY) { EList values = new BasicEList(); while (jp.nextToken() != JsonToken.END_ARRAY) { values.add(parseValueForDataType(jp, dataType)); result.eSet(feature, values); result.eSet(feature, parseValueForDataType(jp, dataType)); if (!eRef.isContainment()) { continue; // Non-containment references are currently ignored if (feature.isMany() && nextToken == JsonToken.START_ARRAY) { EList values = new BasicEList(); while (jp.nextToken() != JsonToken.END_ARRAY) { values.add(from(jp, eRef.getEReferenceType())); result.eSet(feature, values); result.eSet(feature, from(jp, eRef.getEReferenceType()));
for (EStructuralFeature feature : eClass.getEAllStructuralFeatures()) { try { if (getPackageMetaData().useForDatabaseStorage(eClass, feature)) { boolean isUnsetted = (unsetted[fieldCounter / 8] & (1 << (fieldCounter % 8))) != 0; if (isUnsetted) { if (feature.isUnsettable()) { idEObject.eUnset(feature); } else if (feature.isMany()) { } else if (feature.getDefaultValue() != null) { idEObject.setAttribute(feature, feature.getDefaultValue()); if (feature.isMany()) { newValue = readList(idEObject, buffer, feature); } else { if (feature.getEType() instanceof EEnum) { int enumOrdinal = buffer.getInt(); if (enumOrdinal == -1) { newValue = null; } else { EClassifier eType = feature.getEType(); EEnumLiteral enumLiteral = ((EEnumImpl) eType).getEEnumLiteral(enumOrdinal); if (enumLiteral != null) { } else if (feature.getEType() instanceof EClass) { if (feature.getEAnnotation("dbembed") != null) { newValue = readEmbeddedValue(feature, buffer, referenceClass); } else {
throw new UserException("Only objects from the following schemas are allowed to be changed: Ifc2x3tc1 and IFC4, this object (" + eClass.getName() + ") is from the \"" + eClass.getEPackage().getName() + "\" package"); throw new UserException("No object of type \"" + eClass.getName() + "\" with oid " + oid + " found in project with pid " + transaction.getProject().getId()); EReference eReference = packageMetaData.getEReference(eClass.getName(), attributeName); throw new UserException("No reference with the name \"" + attributeName + "\" found in class \"" + eClass.getName() + "\""); if (value instanceof List && eReference.isMany()) { List sourceList = (List)value; if (!eReference.isMany()) { throw new UserException("Attribute is not of type 'many'"); if (eReference.getEType() == EcorePackage.eINSTANCE.getEDouble()) { List asStringList = (List)object.eGet(object.eClass().getEStructuralFeature(attributeName + "AsString")); asStringList.add(String.valueOf(o)); wrappedObject.set(wrappedObject.eClass().getEStructuralFeature("wrappedValue").getName(), value); object.set(eReference.getName(), wrappedObject); if (value instanceof Double) { wrappedObject.set(wrappedObject.eClass().getEStructuralFeature("wrappedValueAsString").getName(), String.valueOf((Double)value));
private void doRealDerivedAttributes() { for (EntityDefinition entityDefinition : schema.getEntities()) { for (DerivedAttribute2 attributeName : entityDefinition.getDerivedAttributes().values()) { EClass eClass = (EClass) schemaPack.getEClassifier(entityDefinition.getName()); EClassifier eType = schemaPack.getEClassifier(((DefinedType) attributeName.getType()).getName()); boolean found = false; for (EClass eSuperType : eClass.getEAllSuperTypes()) { if (eSuperType.getEStructuralFeature(attributeName.getName()) != null) { found = true; break; if (eType.getEAnnotation("wrapped") != null) { if (!found) { EAttribute eAttribute = eFactory.createEAttribute(); eAttribute.setUnique(false); EClassifier type = ((EClass) eType).getEStructuralFeature("wrappedValue").getEType(); eAttribute.setEType(type); eAttribute.setUnsettable(true); // TODO find out if (!found) { EReference eReference = eFactory.createEReference(); eReference.setName(attributeName.getName()); eReference.setDerived(true); eReference.setUnsettable(true);
private void addToList(EStructuralFeature eStructuralFeature, int index, AbstractEList list, EObject referencedObject) throws DeserializeException { EClass referenceEClass = referencedObject.eClass(); if (((EClass) eStructuralFeature.getEType()).isSuperTypeOf(referenceEClass)) { while (list.size() <= index) { list.addUnique(referencedObject); } } else { throw new DeserializeException(-1, referenceEClass.getName() + " cannot be stored in " + eStructuralFeature.getName()); } }