@Override public T execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException { T result = super.execute(); if (result == null) { throw new UserException("No " + getClazz().getSimpleName() + " found where " + eAttribute.getName() + " = " + value); } 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 UnsupportedOperationException("Attribute " + attribute.getName() + " does not have the \"singleindex\" annotation"); } 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; }
@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 UnsupportedOperationException(attribute.getContainerClass().getName() + "." + attribute.getName() + " does not have a \"singleindex\"");
@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; }
System.out.println("#" + key + " " + object.eClass().getName()); for (EAttribute attribute : object.eClass().getEAllAttributes()) { System.out.println("\t" + attribute.getName() + "(" + attribute.getEType().getName() + "): " + object.eGet(attribute));
stringBuffer.append(StringUtils.firstUpperCase(eAttribute.getName())); stringBuffer.append(TEXT_36); stringBuffer.append(eAttribute.getEType().getName()); stringBuffer.append(TEXT_37); stringBuffer.append(StringUtils.firstUpperCase(eAttribute.getName())); stringBuffer.append(TEXT_38); stringBuffer.append(StringUtils.firstUpperCase(eAttribute.getName())); stringBuffer.append(TEXT_40); stringBuffer.append(eAttribute.getEType() == EcorePackage.eINSTANCE.getEBoolean() ? "is" : "get"); stringBuffer.append(StringUtils.firstUpperCase(eAttribute.getName())); stringBuffer.append(TEXT_41); stringBuffer.append(StringUtils.firstUpperCase(eAttribute.getName())); stringBuffer.append(TEXT_42); stringBuffer.append(eAttribute.getEType() == EcorePackage.eINSTANCE.getEBoolean() ? "is" : "get"); stringBuffer.append(StringUtils.firstUpperCase(eAttribute.getName())); stringBuffer.append(TEXT_41); stringBuffer.append(StringUtils.firstUpperCase(eAttribute.getName())); stringBuffer.append(TEXT_76); stringBuffer.append(eAttribute.getEType().getName()); stringBuffer.append(TEXT_37); stringBuffer.append(StringUtils.firstUpperCase(eAttribute.getName())); stringBuffer.append(TEXT_38); stringBuffer.append(StringUtils.firstUpperCase(eAttribute.getName())); stringBuffer.append(TEXT_40); stringBuffer.append(eAttribute.getEType() == EcorePackage.eINSTANCE.getEBoolean() ? "is" : "get");
@SuppressWarnings({ "rawtypes", "unchecked" }) private void setDoubleAsStringValues(IdEObject idEObject) { for (EAttribute eAttribute : idEObject.eClass().getEAllAttributes()) { if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEDouble()) { EStructuralFeature asStringFeature = idEObject.eClass().getEStructuralFeature(eAttribute.getName() + "AsString"); if (asStringFeature != null) { if (eAttribute.isMany()) { List list = (List) idEObject.eGet(eAttribute); List listAsString = (List) idEObject.eGet(asStringFeature); for (int i = 0; i < list.size(); i++) { listAsString.set(i, "" + list.get(i)); } } else { idEObject.eSet(asStringFeature, "" + idEObject.eGet(eAttribute)); } } } } }
stringBuffer.append(eAttribute.getEType().getName()); stringBuffer.append(TEXT_16); stringBuffer.append(eAttribute.getName()); stringBuffer.append(TEXT_17); stringBuffer.append(eAttribute.getEType().getInstanceClassName()); stringBuffer.append(TEXT_19); stringBuffer.append(eAttribute.getName()); stringBuffer.append(TEXT_20); stringBuffer.append(eAttribute.getEType().getInstanceClassName()); stringBuffer.append(eAttribute.getName()); stringBuffer.append(TEXT_17); stringBuffer.append(eAttribute.getEType().getInstanceClassName()); stringBuffer.append(TEXT_16); stringBuffer.append(eAttribute.getName()); stringBuffer.append(TEXT_17); stringBuffer.append(GenerateUtils.makeGetter(eAttribute)); stringBuffer.append(TEXT_46); stringBuffer.append(eAttribute.getName()); stringBuffer.append(TEXT_47); stringBuffer.append(GenerateUtils.makeSetter(eAttribute)); stringBuffer.append(eAttribute.getEType().getName()); stringBuffer.append(TEXT_16); stringBuffer.append(eAttribute.getName()); stringBuffer.append(TEXT_49);
if (val != null) { printIndention(indention + 1); System.out.println(eAttribute.getName() + ": " + val);
List list = (List)object.get(eAttribute.getName()); list.remove(index);
eAttribute.setUnsettable(expAttrib.isOptional()); eAttribute.setName(attrib.getName()); if (eAttribute.getName().equals("RefLatitude") || eAttribute.getName().equals("RefLongitude")) { eAttribute.setUpperBound(3); eAttribute.setUnique(false); EAttribute eAttribute = eFactory.createEAttribute(); eAttribute.setName(attrib.getName()); if (eAttribute.getName().equals("RefLatitude") || eAttribute.getName().equals("RefLongitude")) { eAttribute.setUpperBound(3); } else {
public UserPermission(IModel<User> registrant, PermissionSetting permission) { super(); this.registrant = registrant; this.permission = permission; this.comparator = new EObjectNameComparator<User>(UsersPackage.Literals.USER__DISPLAY_NAME.getName()); }
private TransformationModelElement createTransformationElement(EObject eobject) { TransformationModelElement element = new TransformationModelElement(); for (EAttribute attribute : eobject.eClass().getEAllAttributes()) { Object eGet = eobject.eGet(attribute); if (eGet != null && !attribute.getName().equals(TransformationModelElement.TYPE_ATTR)) { element.addAttribute(attribute.getName(), eobject.eGet(attribute).toString()); } } element.addAttribute(TransformationModelElement.TYPE_ATTR, eobject.eClass().getName()); elementMap.put(element, eobject); return element; }
protected EAttribute getNameEAttribute(final EObject target) { final Function1<EAttribute, Boolean> _function = (EAttribute it) -> { return Boolean.valueOf((Objects.equal(it.getName(), "name") && Objects.equal(it.getEType(), EcorePackage.Literals.ESTRING))); }; return IterableExtensions.<EAttribute>head(IterableExtensions.<EAttribute>filter(target.eClass().getEAllAttributes(), _function)); } }
@Override protected void unsetAttribute(PersistentEObject object, EAttribute attribute) { Vertex vertex = backend.getVertex(object.id()); String propertyName = attribute.getName(); if (attribute.isMany()) { propertyName += SEPARATOR + SIZE_LITERAL; Integer size = vertex.getProperty(propertyName); for (int i = 0; i < size; i++) { vertex.removeProperty(attribute.getName() + SEPARATOR + i); } } vertex.removeProperty(propertyName); }
@Override protected void initRenderingContext(MMenuItem element, IEclipseContext context) { super.initRenderingContext(element, context); context.set(MenuPackageImpl.Literals.ITEM__TYPE.getName(), element.getType()); }