@Override public void getEClassRequirements(Set<EClass> classRequirements) { EClass eClass = attribute.getEContainingClass(); classRequirements.add(eClass); for (EClassifier subClass : eClass.getEPackage().getEClassifiers()) { if (subClass instanceof EClass && eClass.isSuperTypeOf((EClass) subClass)) { classRequirements.add((EClass) subClass); } } }
@SuppressWarnings("unchecked") public <T extends IdEObject> List<T> query(EAttribute attribute, Object value) throws BimserverLockConflictException, BimserverDatabaseException { List<T> result = new ArrayList<>(); if (attribute.getEAnnotation("singleindex") != null) { String indexTableName = attribute.getEContainingClass().getEPackage().getName() + "_" + attribute.getEContainingClass().getName() + "_" + attribute.getName(); byte[] queryBytes = null; if (value instanceof String) { queryBytes = ((String)value).getBytes(Charsets.UTF_8); } else if (value instanceof Integer) { queryBytes = BinUtils.intToByteArray((Integer)value); } else { throw new BimserverDatabaseException("Unsupported type " + value); } List<byte[]> duplicates = database.getKeyValueStore().getDuplicates(indexTableName, queryBytes, this); for (byte[] indexValue : duplicates) { ByteBuffer buffer = ByteBuffer.wrap(indexValue); buffer.getInt(); // pid long oid = buffer.getLong(); result.add((T) get(oid, OldQuery.getDefault())); } } return result; }
public ObjectIdentifier getOid(EClass eClass, EAttribute attribute, Object value, DatabaseInterface databaseInterface, int pid, int rid) throws BimserverDatabaseException { if (attribute.getEAnnotation("singleindex") != null) { String indexTableName = attribute.getEContainingClass().getEPackage().getName() + "_" + eClass.getName() + "_" + attribute.getName(); byte[] queryBytes = null; if (value instanceof String) { queryBytes = ((String)value).getBytes(Charsets.UTF_8); } else if (value instanceof Integer) { queryBytes = BinUtils.intToByteArray((Integer)value); } else { throw new BimserverDatabaseException("Unsupported type " + value); } ByteBuffer valueBuffer = ByteBuffer.allocate(queryBytes.length + 8); valueBuffer.putInt(pid); valueBuffer.putInt(-rid); valueBuffer.put(queryBytes); byte[] firstDuplicate = databaseInterface.get(indexTableName, valueBuffer.array()); if (firstDuplicate != null) { ByteBuffer buffer = ByteBuffer.wrap(firstDuplicate); buffer.getInt(); // pid long oid = buffer.getLong(); return new ObjectIdentifier(oid, (short)oid); } } else { throw new UnsupportedOperationException(eClass.getName() + "." + attribute.getName() + " does not have a singleindex"); } return null; }
public ObjectIdentifier getOidOfGuidAlternative(EClass eClass, EAttribute attribute, Object value, DatabaseInterface databaseInterface, int pid, int rid) throws BimserverDatabaseException { if (attribute.getEAnnotation("singleindex") != null) { String indexTableName = attribute.getEContainingClass().getEPackage().getName() + "_" + eClass.getName() + "_" + attribute.getName(); byte[] queryBytes = null; if (value instanceof String) { queryBytes = ((String)value).getBytes(Charsets.UTF_8); } else if (value instanceof Integer) { queryBytes = BinUtils.intToByteArray((Integer)value); } else { throw new BimserverDatabaseException("Unsupported type " + value); } ByteBuffer valueBuffer = ByteBuffer.allocate(queryBytes.length + 8); valueBuffer.putInt(pid); valueBuffer.putInt(-rid); valueBuffer.put(queryBytes); byte[] firstDuplicate = databaseInterface.get(indexTableName, valueBuffer.array()); if (firstDuplicate != null) { ByteBuffer buffer = ByteBuffer.wrap(firstDuplicate); buffer.getInt(); // pid long oid = buffer.getLong(); return new ObjectIdentifier(oid, (short)oid); } } else { throw new BimserverDatabaseException("Name queries are not implemented yet"); } return null; }
public ObjectIdentifier getOidOfGuidAlternative(EClass eClass, EAttribute attribute, Object value, DatabaseInterface databaseInterface, int pid, int rid) throws BimserverDatabaseException { if (attribute.getEAnnotation("singleindex") != null) { String indexTableName = attribute.getEContainingClass().getEPackage().getName() + "_" + eClass.getName() + "_" + attribute.getName(); byte[] queryBytes = null; if (value instanceof String) { queryBytes = ((String)value).getBytes(Charsets.UTF_8); } else if (value instanceof Integer) { queryBytes = BinUtils.intToByteArray((Integer)value); } else { throw new BimserverDatabaseException("Unsupported type " + value); } ByteBuffer valueBuffer = ByteBuffer.allocate(queryBytes.length + 8); valueBuffer.putInt(pid); valueBuffer.putInt(-rid); valueBuffer.put(queryBytes); byte[] firstDuplicate = databaseInterface.get(indexTableName, valueBuffer.array()); if (firstDuplicate != null) { ByteBuffer buffer = ByteBuffer.wrap(firstDuplicate); buffer.getInt(); // pid long oid = buffer.getLong(); return new ObjectIdentifier(oid, (short)oid); } } else { throw new UnsupportedOperationException("Attribute " + attribute.getName() + " does not have the \"singleindex\" annotation"); } return null; }
@SuppressWarnings("unchecked") public <T extends IdEObject> T querySingle(EAttribute attribute, Object value, int pid, int rid) throws BimserverLockConflictException, BimserverDatabaseException { if (attribute.getEAnnotation("singleindex") != null) { String indexTableName = attribute.getEContainingClass().getEPackage().getName() + "_" + attribute.getEContainingClass().getName() + "_" + attribute.getName(); byte[] queryBytes = null; if (value instanceof String) { throw new BimserverDatabaseException("Unsupported type " + value); boolean perRecordVersioning = perRecordVersioning(attribute.getEContainingClass()); if (!perRecordVersioning) { ByteBuffer valueBuffer = ByteBuffer.allocate(queryBytes.length + 8);
@Override public void change(Database database, DatabaseSession databaseSession) throws NotImplementedException, BimserverDatabaseException { EClass eClass = eAttribute.getEContainingClass(); KeyValueStore keyValueStore = database.getKeyValueStore(); for (EClass subClass : schema.getSubClasses(eClass)) {
@Override public boolean matches(IdEObject object) { if (!attribute.getEContainingClass().isSuperTypeOf(object.eClass())) { return false; } else { if (object.eGet(attribute) == null && literal.getValue() == null) { return true; } if (object.eGet(attribute) == null && literal.getValue() != null) { return false; } if (object.eGet(attribute) != null && literal.getValue() == null) { return false; } return object.eGet(attribute).equals(literal.getValue()); } } }
@Override public String getEAttributeID(final EAttribute eAttribute) { checkNotNull(eAttribute, "Precondition violation - argument 'eAttribute' must not be NULL!"); String eAttributeID = this.eAttributeToID.get(eAttribute); if (eAttributeID != null) { // found the EAttribute ID via '==' comparison return eAttributeID; } // we did not find the EAttribute instance - try to find it via owning EClass EClass eClass = this.getRegisteredEClassforEClassViaEPackage(eAttribute.getEContainingClass()); if (eClass == null) { // we don't know the owning EClass, maybe the EPackage was not registered? return null; } EStructuralFeature feature = eClass.getEStructuralFeature(eAttribute.getName()); if (feature == null) { // in our version of the EClass, no such feature exists... return null; } if (feature instanceof EAttribute == false) { // in our version of the eClass, it's an EReference... return null; } EAttribute registeredEAttribute = (EAttribute) feature; return this.eAttributeToID.get(registeredEAttribute); }
private static Object convertSinglePersistableObjectToEAttributeValue(final EAttribute eAttribute, final Object value) { if (value == null) { // null is always null, conversions make no sense here return null; } if (eAttribute.getEAttributeType() instanceof EEnum) { // for EEnums, we store the 'literal' representation, so we have to convert back now EEnum eEnum = (EEnum) eAttribute.getEAttributeType(); if (value instanceof String == false) { throw new EObjectPersistenceException("Tried to deserialize value for EEnum-typed EAttribute '" + eAttribute.getEContainingClass().getName() + "#" + eAttribute.getName() + "', but the stored object (class: '" + value.getClass().getName() + "' is not a literal string: '" + value + "'!"); } EEnumLiteral enumLiteral = eEnum.getEEnumLiteralByLiteral((String) value); if (enumLiteral == null) { throw new EObjectPersistenceException("Tried to deserialize a value for EEnum-typed EAttribute '" + eAttribute.getEContainingClass().getName() + "#" + eAttribute.getName() + "', but the stored literal '" + value + "' has no representation in the EEnum '" + eEnum.getName() + "'!"); } return enumLiteral; } // anything else remains as-is return value; }
if (eAttribute.getEContainingClass() != null) attributeName = eAttribute.getEContainingClass().getName() + "." + attributeName;
if (eAttribute.getEContainingClass() != null) attributeName = eAttribute.getEContainingClass().getName() + "." + attributeName;
String[] splitValues = entry.split(ENTRY_DELIMITER, 2); EClass metaClass = attribute.getEContainingClass(); EStructuralFeature entryFeature = metaClass.getEStructuralFeature(splitValues[0]);
@Override public Object caseEAttribute(EAttribute eAttribute) { EClass eContainingClass = eAttribute.getEContainingClass(); if (eContainingClass != null) { Property property = UMLFactory.eINSTANCE.createProperty(); eModelElementToElementMap.put(eAttribute, property); Classifier classifier = (Classifier) doSwitch(eContainingClass); getOwnedAttributes(classifier).add(property); property.setName(eAttribute.getName()); property.setIsReadOnly(!eAttribute.isChangeable()); property.setIsDerived(eAttribute.isDerived()); property.setVisibility(VisibilityKind.PUBLIC_LITERAL); caseETypedElement(eAttribute); defaultCase(eAttribute); return property; } return super.caseEAttribute(eAttribute); }
when(featureMapAttribute.isMany()).thenReturn(true); when(featureMapAttribute.getEAttributeType()).thenReturn(eDataTypeFeatureMap); when(featureMapAttribute.getEContainingClass()).thenReturn(eContainingClass);