use of org.eclipse.emf.ecore.EEnum in project BIMserver by opensourceBIM.
the class HashMapVirtualObject method writeList.
@SuppressWarnings("rawtypes")
private void writeList(VirtualObject virtualObject, ByteBuffer buffer, PackageMetaData packageMetaData, EStructuralFeature feature) throws BimserverDatabaseException {
if (feature.getEType() instanceof EEnum) {
// Aggregate relations to enums never occur... at this
// moment
} else if (feature.getEType() instanceof EClass) {
List list = (List) virtualObject.eGet(feature);
buffer.putInt(list.size());
for (Object o : list) {
if (o == null) {
buffer.order(ByteOrder.LITTLE_ENDIAN);
buffer.putShort((short) -1);
buffer.order(ByteOrder.BIG_ENDIAN);
} else {
if (o instanceof VirtualObject) {
VirtualObject listObject = (VirtualObject) o;
if (feature.getEAnnotation("twodimensionalarray") != null) {
Short cid = getDatabaseInterface().getCidOfEClass((EClass) feature.getEType());
buffer.order(ByteOrder.LITTLE_ENDIAN);
buffer.putShort((short) -cid);
buffer.order(ByteOrder.BIG_ENDIAN);
EStructuralFeature lf = listObject.eClass().getEStructuralFeature("List");
writeList(listObject, buffer, packageMetaData, lf);
} else {
if (listObject.eClass().getEAnnotation("wrapped") != null || listObject.eClass().getEStructuralFeature("wrappedValue") != null) {
writeWrappedValue(getPid(), getRid(), listObject, buffer, packageMetaData);
}
}
} else if (o instanceof Long) {
long listObjectOid = (Long) o;
writeReference(listObjectOid, buffer, feature);
} else if (o instanceof HashMapWrappedVirtualObject) {
HashMapWrappedVirtualObject hashMapWrappedVirtualObject = (HashMapWrappedVirtualObject) o;
writeWrappedValue(-1, -1, hashMapWrappedVirtualObject, buffer, packageMetaData);
}
}
}
} else if (feature.getEType() instanceof EDataType) {
List list = (List) virtualObject.eGet(feature);
if (list == null) {
buffer.putInt(-1);
} else {
buffer.putInt(list.size());
for (Object o : list) {
writePrimitiveValue(feature, o, buffer);
}
}
}
}
use of org.eclipse.emf.ecore.EEnum in project BIMserver by opensourceBIM.
the class HashMapVirtualObject method write.
public ByteBuffer write() throws BimserverDatabaseException {
int bufferSize = getExactSize(this);
ByteBuffer buffer = ByteBuffer.allocate(bufferSize);
byte[] unsetted = new byte[getPackageMetaData().getUnsettedLength(eClass)];
int fieldCounter = 0;
for (EStructuralFeature feature : eClass().getEAllStructuralFeatures()) {
if (getPackageMetaData().useForDatabaseStorage(eClass, feature)) {
if (useUnsetBit(feature)) {
unsetted[fieldCounter / 8] |= (1 << (fieldCounter % 8));
}
fieldCounter++;
}
}
buffer.put(unsetted);
EClass eClass = getDatabaseInterface().getEClassForOid(getOid());
if (!eClass.isSuperTypeOf(eClass())) {
throw new BimserverDatabaseException("Object with oid " + getOid() + " is a " + eClass().getName() + " but it's cid-part says it's a " + eClass.getName());
}
buffer.putLong(getUuid().getMostSignificantBits());
buffer.putLong(getUuid().getLeastSignificantBits());
for (EStructuralFeature feature : eClass().getEAllStructuralFeatures()) {
if (getPackageMetaData().useForDatabaseStorage(eClass, feature)) {
if (!useUnsetBit(feature)) {
if (feature.isMany()) {
writeList(this, buffer, getPackageMetaData(), feature);
} else {
Object value = eGet(feature);
if (feature.getEType() instanceof EEnum) {
if (value == null) {
buffer.putInt(-1);
} else {
EEnum eEnum = (EEnum) feature.getEType();
EEnumLiteral eEnumLiteral = eEnum.getEEnumLiteralByLiteral(((Enum<?>) value).toString());
if (eEnumLiteral != null) {
buffer.putInt(eEnumLiteral.getValue());
} else {
LOGGER.error(((Enum<?>) value).toString() + " not found");
buffer.putInt(-1);
}
}
} else if (feature.getEType() instanceof EClass) {
if (value == null) {
buffer.order(ByteOrder.LITTLE_ENDIAN);
buffer.putShort((short) -1);
buffer.order(ByteOrder.BIG_ENDIAN);
} else if (value instanceof VirtualObject) {
writeWrappedValue(getPid(), getRid(), (VirtualObject) value, buffer, getPackageMetaData());
} else if (value instanceof WrappedVirtualObject) {
writeWrappedValue(getPid(), getRid(), (WrappedVirtualObject) value, buffer, getPackageMetaData());
} else {
long referencedOid = (Long) value;
writeReference(referencedOid, buffer, feature);
}
} else if (feature.getEType() instanceof EDataType) {
writePrimitiveValue(feature, value, buffer);
}
}
}
}
}
if (buffer.position() != bufferSize) {
throw new BimserverDatabaseException("Value buffer sizes do not match for " + eClass().getName() + " " + buffer.position() + "/" + bufferSize);
}
return buffer;
}
use of org.eclipse.emf.ecore.EEnum in project BIMserver by opensourceBIM.
the class ClientIfcModel method set.
@Override
public void set(IdEObject idEObject, EStructuralFeature eFeature, Object newValue) {
if (!recordChanges) {
return;
}
if (!eFeature.isMany()) {
if (getModelState() != ModelState.LOADING && ((IdEObjectImpl) idEObject).getLoadingState() != State.LOADING) {
try {
if (newValue != EStructuralFeature.Internal.DynamicValueHolder.NIL) {
LowLevelInterface lowLevelInterface = getBimServerClient().getLowLevelInterface();
if (eFeature.getName().equals("wrappedValue")) {
// Wrapped objects get the same oid as their
// "parent" object, so we know which object the
// client wants to update. That's why we can use
// idEObject.getOid() here
// We are making this crazy hack ever crazier, let's
// iterate over our parents features, and see if
// there is one matching our wrapped type...
// Seriously, when there are multiple fields of the
// same type, this fails miserably, a real fix
// should probably store the parent-oid + feature
// name in the wrapped object (requires two extra,
// volatile, fields),
// or we just don't support this (just create a new
// wrapped object too), we could even throw some
// sort of exception. Hack morally okay because it's
// client-side...
EReference foundReference = null;
if (contains(idEObject.getOid())) {
IdEObject parentObject = get(idEObject.getOid());
int found = 0;
foundReference = null;
for (EReference testReference : parentObject.eClass().getEAllReferences()) {
if (((EClass) testReference.getEType()).isSuperTypeOf(idEObject.eClass())) {
foundReference = testReference;
found++;
if (found > 1) {
throw new RuntimeException("Sorry, crazy hack could not resolve the right field, please let BIMserver developer know (debug info: " + parentObject.eClass().getName() + ", " + idEObject.eClass().getName() + ")");
}
}
}
if (eFeature.getEType() == EcorePackage.eINSTANCE.getEString()) {
lowLevelInterface.setWrappedStringAttribute(getTransactionId(), idEObject.getOid(), foundReference.getName(), idEObject.eClass().getName(), (String) newValue);
} else if (eFeature.getEType() == EcorePackage.eINSTANCE.getELong() || eFeature.getEType() == EcorePackage.eINSTANCE.getELongObject()) {
lowLevelInterface.setWrappedLongAttribute(getTransactionId(), idEObject.getOid(), foundReference.getName(), idEObject.eClass().getName(), (Long) newValue);
} else if (eFeature.getEType() == EcorePackage.eINSTANCE.getEDouble() || eFeature.getEType() == EcorePackage.eINSTANCE.getEDoubleObject()) {
lowLevelInterface.setWrappedDoubleAttribute(getTransactionId(), idEObject.getOid(), foundReference.getName(), idEObject.eClass().getName(), (Double) newValue);
} else if (eFeature.getEType() == EcorePackage.eINSTANCE.getEBoolean() || eFeature.getEType() == EcorePackage.eINSTANCE.getEBooleanObject()) {
lowLevelInterface.setWrappedBooleanAttribute(getTransactionId(), idEObject.getOid(), foundReference.getName(), idEObject.eClass().getName(), (Boolean) newValue);
} else if (eFeature.getEType() == EcorePackage.eINSTANCE.getEInt() || eFeature.getEType() == EcorePackage.eINSTANCE.getEIntegerObject()) {
lowLevelInterface.setWrappedIntegerAttribute(getTransactionId(), idEObject.getOid(), foundReference.getName(), idEObject.eClass().getName(), (Integer) newValue);
} else if (eFeature.getEType() == EcorePackage.eINSTANCE.getEByteArray()) {
throw new RuntimeException("Unimplemented " + eFeature.getEType().getName() + " " + newValue);
}
} else {
if (eFeature.getEType() == EcorePackage.eINSTANCE.getEString()) {
lowLevelInterface.setStringAttribute(getTransactionId(), idEObject.getOid(), eFeature.getName(), (String) newValue);
} else if (eFeature.getEType() == EcorePackage.eINSTANCE.getELong() || eFeature.getEType() == EcorePackage.eINSTANCE.getELongObject()) {
lowLevelInterface.setLongAttribute(getTransactionId(), idEObject.getOid(), eFeature.getName(), (Long) newValue);
} else if (eFeature.getEType() == EcorePackage.eINSTANCE.getEDouble() || eFeature.getEType() == EcorePackage.eINSTANCE.getEDoubleObject()) {
lowLevelInterface.setDoubleAttribute(getTransactionId(), idEObject.getOid(), eFeature.getName(), (Double) newValue);
} else if (eFeature.getEType() == EcorePackage.eINSTANCE.getEBoolean() || eFeature.getEType() == EcorePackage.eINSTANCE.getEBooleanObject()) {
lowLevelInterface.setBooleanAttribute(getTransactionId(), idEObject.getOid(), eFeature.getName(), (Boolean) newValue);
} else if (eFeature.getEType() == EcorePackage.eINSTANCE.getEInt() || eFeature.getEType() == EcorePackage.eINSTANCE.getEIntegerObject()) {
lowLevelInterface.setIntegerAttribute(getTransactionId(), idEObject.getOid(), eFeature.getName(), (Integer) newValue);
} else if (eFeature.getEType() == EcorePackage.eINSTANCE.getEByteArray()) {
lowLevelInterface.setByteArrayAttribute(getTransactionId(), idEObject.getOid(), eFeature.getName(), (Byte[]) newValue);
} else if (eFeature.getEType() instanceof EEnum) {
lowLevelInterface.setEnumAttribute(getTransactionId(), idEObject.getOid(), eFeature.getName(), ((Enum<?>) newValue).toString());
} else if (eFeature instanceof EReference) {
if (newValue == null) {
lowLevelInterface.setReference(getTransactionId(), idEObject.getOid(), eFeature.getName(), -1L);
} else {
lowLevelInterface.setReference(getTransactionId(), idEObject.getOid(), eFeature.getName(), ((IdEObject) newValue).getOid());
}
} else {
throw new RuntimeException("Unimplemented " + eFeature.getEType().getName() + " " + newValue);
}
}
} else {
if (eFeature.getEType() == EcorePackage.eINSTANCE.getEString()) {
lowLevelInterface.setStringAttribute(getTransactionId(), idEObject.getOid(), eFeature.getName(), (String) newValue);
} else if (eFeature.getEType() == EcorePackage.eINSTANCE.getELong() || eFeature.getEType() == EcorePackage.eINSTANCE.getELongObject()) {
lowLevelInterface.setLongAttribute(getTransactionId(), idEObject.getOid(), eFeature.getName(), (Long) newValue);
} else if (eFeature.getEType() == EcorePackage.eINSTANCE.getEDouble() || eFeature.getEType() == EcorePackage.eINSTANCE.getEDoubleObject()) {
lowLevelInterface.setDoubleAttribute(getTransactionId(), idEObject.getOid(), eFeature.getName(), (Double) newValue);
} else if (eFeature.getEType() == EcorePackage.eINSTANCE.getEBoolean() || eFeature.getEType() == EcorePackage.eINSTANCE.getEBooleanObject()) {
lowLevelInterface.setBooleanAttribute(getTransactionId(), idEObject.getOid(), eFeature.getName(), (Boolean) newValue);
} else if (eFeature.getEType() == EcorePackage.eINSTANCE.getEInt() || eFeature.getEType() == EcorePackage.eINSTANCE.getEIntegerObject()) {
lowLevelInterface.setIntegerAttribute(getTransactionId(), idEObject.getOid(), eFeature.getName(), (Integer) newValue);
} else if (eFeature.getEType() == EcorePackage.eINSTANCE.getEByteArray()) {
if (newValue instanceof byte[]) {
Byte[] n = new Byte[((byte[]) newValue).length];
for (int i = 0; i < n.length; i++) {
n[i] = ((byte[]) newValue)[i];
}
newValue = n;
}
lowLevelInterface.setByteArrayAttribute(getTransactionId(), idEObject.getOid(), eFeature.getName(), (Byte[]) newValue);
} else if (eFeature.getEType() instanceof EEnum) {
lowLevelInterface.setEnumAttribute(getTransactionId(), idEObject.getOid(), eFeature.getName(), ((Enum<?>) newValue).toString());
} else if (eFeature instanceof EReference) {
if (newValue == null) {
lowLevelInterface.setReference(getTransactionId(), idEObject.getOid(), eFeature.getName(), -1L);
} else {
lowLevelInterface.setReference(getTransactionId(), idEObject.getOid(), eFeature.getName(), ((IdEObject) newValue).getOid());
}
} else {
throw new RuntimeException("Unimplemented " + eFeature.getEType().getName() + " " + newValue);
}
}
}
} catch (ServiceException e) {
LOGGER.error("", e);
} catch (PublicInterfaceNotFoundException e) {
LOGGER.error("", e);
}
}
}
}
use of org.eclipse.emf.ecore.EEnum in project BIMserver by opensourceBIM.
the class Step0023 method migrate.
@Override
public void migrate(Schema schema, DatabaseSession databaseSession) {
EClass pluginBundleVersionClass = schema.createEClass("store", "PluginBundleVersion");
EEnum pluginBundleType = schema.createEEnum("store", "PluginBundleType");
schema.createEEnumLiteral(pluginBundleType, "MAVEN");
schema.createEEnumLiteral(pluginBundleType, "GITHUB");
schema.createEEnumLiteral(pluginBundleType, "LOCAL");
EEnum pluginType = schema.createEEnum("store", "PluginType");
schema.createEEnumLiteral(pluginType, "SERIALIZER");
schema.createEEnumLiteral(pluginType, "DESERIALIZER");
schema.createEEnumLiteral(pluginType, "RENDER_ENGINE");
schema.createEEnumLiteral(pluginType, "QUERY_ENGINE");
schema.createEEnumLiteral(pluginType, "OBJECT_IDM");
schema.createEEnumLiteral(pluginType, "WEB_MODULE");
schema.createEEnumLiteral(pluginType, "MODEL_MERGER");
schema.createEEnumLiteral(pluginType, "MODEL_COMPARE");
schema.createEEnumLiteral(pluginType, "MODEL_CHECKER");
schema.createEEnumLiteral(pluginType, "STILL_IMAGE_RENDER");
schema.createEEnumLiteral(pluginType, "SERVICE");
schema.createEAttribute(pluginBundleVersionClass, "version", EcorePackage.eINSTANCE.getEString());
schema.createEAttribute(pluginBundleVersionClass, "type", pluginBundleType);
schema.createEAttribute(pluginBundleVersionClass, "description", EcorePackage.eINSTANCE.getEString());
schema.createEAttribute(pluginBundleVersionClass, "mismatch", EcorePackage.eINSTANCE.getEBoolean());
schema.createEAttribute(pluginBundleVersionClass, "repository", EcorePackage.eINSTANCE.getEString());
schema.createEAttribute(pluginBundleVersionClass, "groupId", EcorePackage.eINSTANCE.getEString());
schema.createEAttribute(pluginBundleVersionClass, "artifactId", EcorePackage.eINSTANCE.getEString());
schema.createEAttribute(pluginBundleVersionClass, "icon", EcorePackage.eINSTANCE.getEByteArray());
schema.createEAttribute(pluginBundleVersionClass, "organization", EcorePackage.eINSTANCE.getEString());
schema.createEAttribute(pluginBundleVersionClass, "name", EcorePackage.eINSTANCE.getEString());
EClass pluginBundle = schema.createEClass("store", "PluginBundle");
schema.createEAttribute(pluginBundle, "organization", EcorePackage.eINSTANCE.getEString());
schema.createEAttribute(pluginBundle, "name", EcorePackage.eINSTANCE.getEString());
schema.createEReference(pluginBundle, "latestVersion", pluginBundleVersionClass, Multiplicity.SINGLE).getEAnnotations().add(createEmbedsReferenceAnnotation());
schema.createEReference(pluginBundle, "availableVersions", pluginBundleVersionClass, Multiplicity.MANY).getEAnnotations().add(createEmbedsReferenceAnnotation());
schema.createEReference(pluginBundle, "installedVersion", pluginBundleVersionClass, Multiplicity.SINGLE).getEAnnotations().add(createEmbedsReferenceAnnotation());
EClass pluginInformation = schema.createEClass("store", "PluginInformation");
schema.createEAttribute(pluginInformation, "name", EcorePackage.eINSTANCE.getEString());
schema.createEAttribute(pluginInformation, "type", pluginType);
schema.createEAttribute(pluginInformation, "description", EcorePackage.eINSTANCE.getEString());
schema.createEAttribute(pluginInformation, "enabled", EcorePackage.eINSTANCE.getEBoolean());
schema.createEAttribute(pluginInformation, "identifier", EcorePackage.eINSTANCE.getEString());
schema.createEAttribute(pluginInformation, "installForAllUsers", EcorePackage.eINSTANCE.getEBoolean());
schema.createEAttribute(pluginInformation, "installForNewUsers", EcorePackage.eINSTANCE.getEBoolean());
EClass pluginDescriptor = schema.getEClass("store", "PluginDescriptor");
schema.createEAttribute(pluginDescriptor, "installForNewUsers", EcorePackage.eINSTANCE.getEBoolean());
EClass serverSettingsClass = schema.getEClass("store", "ServerSettings");
schema.createEAttribute(serverSettingsClass, "pluginStrictVersionChecking", EcorePackage.eINSTANCE.getEBoolean());
schema.createEReference(pluginDescriptor, "pluginBundleVersion", pluginBundleVersionClass, Multiplicity.SINGLE);
}
use of org.eclipse.emf.ecore.EEnum in project BIMserver by opensourceBIM.
the class Step0004 method migrate.
@Override
public void migrate(Schema schema, DatabaseSession databaseSession) {
// Model checker results
EClass modelCheckerResultItem = schema.createEClass("store", "ModelCheckerResultItem");
EClass modelCheckerResultHeader = schema.createEClass("store", "ModelCheckerResultHeader", modelCheckerResultItem);
schema.createEAttribute(modelCheckerResultHeader, "text", EcorePackage.eINSTANCE.getEString());
EEnum modelCheckerResultType = schema.createEEnum("store", "ModelCheckerResultType");
schema.createEEnumLiteral(modelCheckerResultType, "ERROR");
schema.createEEnumLiteral(modelCheckerResultType, "SUCCESS");
EClass modelCheckerResultLine = schema.createEClass("store", "ModelCheckerResultLine", modelCheckerResultItem);
schema.createEAttribute(modelCheckerResultLine, "fieldOrClass", EcorePackage.eINSTANCE.getEString());
schema.createEAttribute(modelCheckerResultLine, "value", EcorePackage.eINSTANCE.getEString());
schema.createEAttribute(modelCheckerResultLine, "shouldBe", EcorePackage.eINSTANCE.getEString());
schema.createEAttribute(modelCheckerResultLine, "type", modelCheckerResultType);
schema.createEAttribute(modelCheckerResultLine, "objectId", EcorePackage.eINSTANCE.getELong());
EClass modelCheckerResult = schema.createEClass("store", "ModelCheckerResult");
schema.createEAttribute(modelCheckerResult, "valid", EcorePackage.eINSTANCE.getEBoolean());
schema.createEReference(modelCheckerResult, "items", modelCheckerResultItem, Multiplicity.MANY);
EClass modelCheckerInstance = schema.createEClass("store", "ModelCheckerInstance");
schema.createEAttribute(modelCheckerInstance, "name", EcorePackage.eINSTANCE.getEString());
schema.createEAttribute(modelCheckerInstance, "description", EcorePackage.eINSTANCE.getEString());
schema.createEAttribute(modelCheckerInstance, "code", EcorePackage.eINSTANCE.getEString());
schema.createEAttribute(modelCheckerInstance, "compiled", EcorePackage.eINSTANCE.getEByteArray());
schema.createEAttribute(modelCheckerInstance, "valid", EcorePackage.eINSTANCE.getEBoolean());
schema.createEAttribute(modelCheckerInstance, "modelCheckerPluginClassName", EcorePackage.eINSTANCE.getEString(), Multiplicity.SINGLE);
// References to plugin
EClass service = schema.getEClass("store", "Service");
schema.createEReference(service, "modelCheckers", modelCheckerInstance, Multiplicity.MANY);
EClass project = schema.getEClass("store", "Project");
schema.createEReference(project, "modelCheckers", modelCheckerInstance, Multiplicity.MANY);
EClass internalServicePluginConfiguration = schema.getEClass("store", "InternalServicePluginConfiguration");
schema.createEAttribute(internalServicePluginConfiguration, "publicProfile", EcorePackage.eINSTANCE.getEBoolean());
// EClass geometryInstance = schema.createEClass("ifc2x3tc1", "GeometryInstance");
// schema.createEReference(geometryInstance, "data", schema.getEClass("ifc2x3tc1", "GeometryData"), Multiplicity.SINGLE);
// schema.createEAttribute(geometryInstance, "transformation", EcorePackage.eINSTANCE.getEByteArray(), Multiplicity.SINGLE);
// geometryInstance.getEAnnotations().add(createHiddenAnnotation());
// schema.createEReference(schema.getEClass("ifc2x3tc1", "GeometryInfo"), "instance", geometryInstance, Multiplicity.SINGLE);
}
Aggregations