Search in sources :

Example 1 with HashMapWrappedVirtualObject

use of org.bimserver.shared.HashMapWrappedVirtualObject in project BIMserver by opensourceBIM.

the class SharedJsonStreamingSerializer method writeObject.

private void writeObject(HashMapVirtualObject object) throws IOException, BimserverDatabaseException {
    // if (((IdEObjectImpl) object).getLoadingState() != State.LOADED) {
    // print("{");
    // print("\"_i\":" + object.getOid() + ",");
    // print("\"_t\":\"" + object.eClass().getName() + "\",");
    // print("\"_s\":0");
    // print("}\n");
    // } else {
    print("{");
    print("\"_i\":" + object.getOid() + ",");
    print("\"_t\":\"" + object.eClass().getName() + "\",");
    print("\"_s\":1");
    for (EStructuralFeature eStructuralFeature : object.eClass().getEAllStructuralFeatures()) {
        if (eStructuralFeature.getEAnnotation("nolazyload") == null && (eStructuralFeature.getEAnnotation("hidden") == null || includeHidden)) {
            if (eStructuralFeature instanceof EReference) {
                Object value = object.eGet(eStructuralFeature);
                if (value != null) {
                    if (eStructuralFeature.isMany()) {
                        List<?> list = (List<?>) value;
                        if (SERIALIZE_EMPTY_LISTS || !list.isEmpty()) {
                            print(",");
                            int wrapped = 0;
                            int referred = 0;
                            for (Object o : list) {
                                if (o instanceof Long) {
                                    referred++;
                                } else if (o instanceof HashMapWrappedVirtualObject) {
                                    wrapped++;
                                }
                            }
                            if (wrapped == 0 && referred != 0) {
                                print("\"_r" + eStructuralFeature.getName() + "\":[");
                            } else if (wrapped != 0 && referred == 0) {
                                print("\"_e" + eStructuralFeature.getName() + "\":[");
                            } else if (wrapped == 0 && referred == 0) {
                                print("\"_e" + eStructuralFeature.getName() + "\":[");
                            // should not happen
                            } else {
                                // both, this can occur,
                                // for example
                                // IfcTrimmedCurve.Trim1
                                print("\"_e" + eStructuralFeature.getName() + "\":[");
                            }
                            boolean f = true;
                            for (Object o : list) {
                                if (o == null) {
                                    LOGGER.info("Unexpeced null in list " + object.eClass().getName() + ":" + object.getOid() + "." + eStructuralFeature.getName());
                                } else {
                                    if (!f) {
                                        print(",");
                                    } else {
                                        f = false;
                                    }
                                    if (o instanceof Long) {
                                        long ref = (Long) o;
                                        if (wrapped != 0 && referred != 0) {
                                            // Special
                                            // situation,
                                            // where we have
                                            // to construct
                                            // an object
                                            // around the
                                            // OID to make
                                            // it
                                            // distinguishable
                                            // from embedded
                                            // objects
                                            print("{");
                                            print("\"_i\":");
                                            print("" + ref + ",");
                                            print("\"_t\":");
                                            print("\"" + object.getReusable().getDatabaseInterface().getEClassForOid(ref).getName() + "\"");
                                            print("}");
                                        } else {
                                            print("{");
                                            print("\"_i\":");
                                            print("" + ref + ",");
                                            print("\"_t\":");
                                            print("\"" + object.getReusable().getDatabaseInterface().getEClassForOid(ref).getName() + "\"");
                                            print("}");
                                        }
                                    } else if (o instanceof HashMapWrappedVirtualObject) {
                                        write((HashMapWrappedVirtualObject) o);
                                    } else if (eStructuralFeature.getEAnnotation("twodimensionalarray") != null) {
                                        EClass type = (EClass) eStructuralFeature.getEType();
                                        EStructuralFeature listFeature = type.getEStructuralFeature("List");
                                        List<?> listX = (List<?>) (((HashMapVirtualObject) o).eGet(listFeature));
                                        print("[");
                                        boolean fq = true;
                                        for (Object k : listX) {
                                            if (!fq) {
                                                print(",");
                                            }
                                            fq = false;
                                            if (k instanceof HashMapWrappedVirtualObject) {
                                                write((HashMapWrappedVirtualObject) k);
                                            } else {
                                                print("\"" + k + "\"");
                                            }
                                        }
                                        print("]");
                                    } else {
                                        LOGGER.info("Unimplemented " + o);
                                    }
                                }
                            }
                            print("]");
                        }
                    } else {
                        print(",");
                        if (value instanceof Long) {
                            long ref = (Long) value;
                            print("\"_r" + eStructuralFeature.getName() + "\":{\"_i\":" + ref + ",\"_t\":\"" + object.getReusable().getDatabaseInterface().getEClassForOid(ref).getName() + "\"}");
                        } else if (value instanceof HashMapWrappedVirtualObject) {
                            print("\"_e" + eStructuralFeature.getName() + "\":");
                            HashMapWrappedVirtualObject hashMapWrappedVirtualObject = (HashMapWrappedVirtualObject) value;
                            write(hashMapWrappedVirtualObject);
                        } else {
                        // print("\"" + eStructuralFeature.getName() + "\":");
                        // writePrimitive(eStructuralFeature, ((IfcGloballyUniqueId) ref).getWrappedValue());
                        }
                    }
                }
            } else {
                Object value = object.eGet(eStructuralFeature);
                if (value != null) {
                    if (eStructuralFeature.isMany()) {
                        List<?> list = (List<?>) value;
                        if (SERIALIZE_EMPTY_LISTS || !list.isEmpty()) {
                            print(",");
                            print("\"" + eStructuralFeature.getName() + "\":[");
                            boolean f = true;
                            for (Object o : list) {
                                if (!f) {
                                    print(",");
                                } else {
                                    f = false;
                                }
                                writePrimitive(eStructuralFeature, o);
                            }
                            print("]");
                        }
                    } else {
                        print(",");
                        print("\"" + eStructuralFeature.getName() + "\":");
                        writePrimitive(eStructuralFeature, value);
                    }
                }
            }
        }
    }
    print("}\n");
// }
}
Also used : EClass(org.eclipse.emf.ecore.EClass) HashMapWrappedVirtualObject(org.bimserver.shared.HashMapWrappedVirtualObject) HashMapVirtualObject(org.bimserver.shared.HashMapVirtualObject) EStructuralFeature(org.eclipse.emf.ecore.EStructuralFeature) HashMapWrappedVirtualObject(org.bimserver.shared.HashMapWrappedVirtualObject) HashMapVirtualObject(org.bimserver.shared.HashMapVirtualObject) MinimalVirtualObject(org.bimserver.shared.MinimalVirtualObject) List(java.util.List) EReference(org.eclipse.emf.ecore.EReference)

Example 2 with HashMapWrappedVirtualObject

use of org.bimserver.shared.HashMapWrappedVirtualObject in project BIMserver by opensourceBIM.

the class SharedJsonStreamingSerializer method write.

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\":");
        writePrimitive(wrappedFeature, object.eGet(wrappedFeature));
        print("}");
    } else if (object instanceof HashMapVirtualObject) {
        print("" + ((HashMapVirtualObject) object).getOid());
    } else if (object instanceof HashMapWrappedVirtualObject) {
        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("}");
    }
}
Also used : HashMapVirtualObject(org.bimserver.shared.HashMapVirtualObject) HashMapWrappedVirtualObject(org.bimserver.shared.HashMapWrappedVirtualObject) EStructuralFeature(org.eclipse.emf.ecore.EStructuralFeature)

Example 3 with HashMapWrappedVirtualObject

use of org.bimserver.shared.HashMapWrappedVirtualObject in project BIMserver by opensourceBIM.

the class DownloadByNewJsonQueryDatabaseAction method execute.

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public IfcModelInterface execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
    List<String> projectNames = new ArrayList<>();
    setProgress("Querying database...", -1);
    for (long roid : roids) {
        Revision revision = getDatabaseSession().get(StorePackage.eINSTANCE.getRevision(), roid, OldQuery.getDefault());
        projectNames.add(revision.getProject().getName() + "." + revision.getId());
    }
    String name = Joiner.on("-").join(projectNames);
    PackageMetaData lastPackageMetaData = null;
    Project lastProject = null;
    IfcModelSet ifcModelSet = new IfcModelSet();
    Map<Integer, Long> pidRoidMap = new HashMap<>();
    for (long roid : roids) {
        Revision revision = getDatabaseSession().get(StorePackage.eINSTANCE.getRevision(), roid, OldQuery.getDefault());
        lastProject = revision.getProject();
        PackageMetaData packageMetaData = getBimServer().getMetaDataManager().getPackageMetaData(revision.getProject().getSchema());
        lastPackageMetaData = packageMetaData;
        JsonQueryObjectModelConverter converter = new JsonQueryObjectModelConverter(packageMetaData);
        ObjectNode queryObject;
        try {
            queryObject = OBJECT_MAPPER.readValue(json, ObjectNode.class);
            Query query = converter.parseJson("query", (ObjectNode) queryObject);
            pidRoidMap.put(revision.getProject().getId(), roid);
            IfcModelInterface ifcModel = new ServerIfcModel(packageMetaData, pidRoidMap, getDatabaseSession());
            ifcModelSet.add(ifcModel);
            QueryObjectProvider queryObjectProvider = new QueryObjectProvider(getDatabaseSession(), getBimServer(), query, Collections.singleton(roid), packageMetaData);
            HashMapVirtualObject next = queryObjectProvider.next();
            while (next != null) {
                IdEObject newObject = packageMetaData.create(next.eClass());
                IdEObjectImpl idEObjectImpl = (IdEObjectImpl) newObject;
                idEObjectImpl.setPid(revision.getProject().getId());
                idEObjectImpl.setOid(next.getOid());
                for (EAttribute eAttribute : newObject.eClass().getEAllAttributes()) {
                    Object value = next.eGet(eAttribute);
                    if (eAttribute.isMany()) {
                        List<?> list = (List<?>) value;
                        if (list != null) {
                            AbstractEList targetList = (AbstractEList) newObject.eGet(eAttribute);
                            for (Object item : list) {
                                targetList.addUnique(item);
                            }
                        }
                    } else {
                        if (value != null || eAttribute.isUnsettable()) {
                            newObject.eSet(eAttribute, value);
                        }
                    }
                }
                ifcModel.add(next.getOid(), newObject);
                next = queryObjectProvider.next();
            }
            queryObjectProvider = new QueryObjectProvider(getDatabaseSession(), getBimServer(), query, Collections.singleton(roid), packageMetaData);
            next = queryObjectProvider.next();
            while (next != null) {
                IdEObject idEObject = ifcModel.get(next.getOid());
                if (idEObject.eClass() != next.eClass()) {
                    // Something is wrong
                    throw new RuntimeException("Classes not the same");
                }
                for (EReference eReference : idEObject.eClass().getEAllReferences()) {
                    if (eReference.isMany()) {
                        List refOids = (List) next.eGet(eReference);
                        AbstractEList<IdEObject> list = (AbstractEList<IdEObject>) idEObject.eGet(eReference);
                        if (refOids != null) {
                            for (Object refOid : refOids) {
                                if (refOid instanceof Long) {
                                    IdEObject ref = ifcModel.get((long) refOid);
                                    if (ref != null) {
                                        if (eReference.isUnique()) {
                                            list.add(ref);
                                        } else {
                                            list.addUnique(ref);
                                        }
                                    }
                                } else if (refOid instanceof HashMapWrappedVirtualObject) {
                                // IdEObject ref = ifcModel.get(((HashMapWrappedVirtualObject) refOid).get);
                                // if (ref != null) {
                                // list.add(ref);
                                // }
                                } else if (refOid instanceof HashMapVirtualObject) {
                                    HashMapVirtualObject hashMapVirtualObject = (HashMapVirtualObject) refOid;
                                    IdEObject listObject = packageMetaData.create(hashMapVirtualObject.eClass());
                                    List subList = (List<?>) hashMapVirtualObject.get("List");
                                    List newList = (List<?>) listObject.eGet(listObject.eClass().getEStructuralFeature("List"));
                                    for (Object o : subList) {
                                        if (o instanceof HashMapWrappedVirtualObject) {
                                            newList.add(convertWrapped(revision, ifcModel, (HashMapWrappedVirtualObject) o));
                                        } else {
                                            newList.add(o);
                                        }
                                    }
                                    list.addUnique(listObject);
                                } else {
                                }
                            }
                        }
                    } else {
                        Object r = next.eGet(eReference);
                        if (r instanceof Long) {
                            long refOid = (Long) r;
                            idEObject.eSet(eReference, ifcModel.get(refOid));
                        } else if (r instanceof HashMapWrappedVirtualObject) {
                            idEObject.eSet(eReference, convertWrapped(revision, ifcModel, (HashMapWrappedVirtualObject) r));
                        } else if (r instanceof HashMapVirtualObject) {
                        } else {
                        }
                    }
                }
                next = queryObjectProvider.next();
            }
            ifcModel.getModelMetaData().setName(name);
            ifcModel.getModelMetaData().setRevisionId(1);
            if (getAuthorization().getUoid() != -1) {
                ifcModel.getModelMetaData().setAuthorizedUser(getUserByUoid(getAuthorization().getUoid()).getName());
            }
            ifcModel.getModelMetaData().setDate(new Date());
        } catch (IOException e1) {
            e1.printStackTrace();
        } catch (IfcModelInterfaceException e) {
            e.printStackTrace();
        } catch (QueryException e) {
            e.printStackTrace();
        }
    }
    IfcModelInterface ifcModel = new ServerIfcModel(lastPackageMetaData, pidRoidMap, 0, getDatabaseSession());
    if (ifcModelSet.size() > 1) {
        setProgress("Merging IFC data...", -1);
        try {
            ifcModel = getBimServer().getMergerFactory().createMerger(getDatabaseSession(), getAuthorization().getUoid()).merge(lastProject, ifcModelSet, new ModelHelper(getBimServer().getMetaDataManager(), ifcModel));
        } catch (MergeException e) {
            throw new UserException(e);
        }
    } else {
        ifcModel = ifcModelSet.iterator().next();
    }
    ifcModel.getModelMetaData().setName(name);
    // ifcModel.getModelMetaData().setRevisionId(project.getRevisions().indexOf(virtualRevision) + 1);
    if (getAuthorization().getUoid() != -1) {
        ifcModel.getModelMetaData().setAuthorizedUser(getUserByUoid(getAuthorization().getUoid()).getName());
    }
    ifcModel.getModelMetaData().setDate(new Date());
    return ifcModel;
// for (Long roid : roids) {
// Revision virtualRevision = getRevisionByRoid(roid);
// pidRoidMap.put(virtualRevision.getProject().getId(), virtualRevision.getOid());
// project = virtualRevision.getProject();
// name += project.getName() + "-" + virtualRevision.getId() + "-";
// try {
// getAuthorization().canDownload(roid);
// } catch (UserException e) {
// if (!getAuthorization().hasRightsOnProjectOrSuperProjectsOrSubProjects(user, project)) {
// throw new UserException("User has insufficient rights to download revisions from this project");
// }
// if (!getAuthorization().hasRightsOnProjectOrSuperProjectsOrSubProjects(user, project)) {
// throw new UserException("User has insufficient rights to download revisions from this project");
// }
// }
// int size = 0;
// 
// for (ConcreteRevision concreteRevision : virtualRevision.getConcreteRevisions()) {
// try {
// int highestStopId = findHighestStopRid(project, concreteRevision);
// 
// PackageMetaData packageMetaData = getBimServer().getMetaDataManager().getPackageMetaData(concreteRevision.getProject().getSchema());
// lastPackageMetaData = packageMetaData;
// IfcModelInterface subModel = new ServerIfcModel(packageMetaData, pidRoidMap, getDatabaseSession());
// 
// OldQuery databaseQuery = new OldQuery(packageMetaData, concreteRevision.getProject().getId(), concreteRevision.getId(), virtualRevision.getOid(), null, Deep.NO, highestStopId);
// databaseQuery.updateOidCounters(concreteRevision, getDatabaseSession());
// JsonObject queryObject = (JsonObject)query;
// JsonArray queries = queryObject.get("queries").getAsJsonArray();
// for (JsonElement queryElement : queries) {
// processQueryPart(packageMetaData, queryObject, (JsonObject) queryElement, subModel, databaseQuery);
// }
// 
// size += subModel.size();
// subModel.getModelMetaData().setDate(concreteRevision.getDate());
// subModel.fixInverseMismatches();
// checkGeometry(serializerPluginConfiguration, getBimServer().getPluginManager(), subModel, project, concreteRevision, virtualRevision);
// ifcModelSet.add(subModel);
// } catch (GeometryGeneratingException | IfcModelInterfaceException e) {
// throw new UserException(e);
// }
// }
// 
// }
// TODO check, double merging??
// IfcModelInterface ifcModel = new BasicIfcModel(lastPackageMetaData, pidRoidMap);
// if (ifcModelSet.size() > 1) {
// try {
// ifcModel = getBimServer().getMergerFactory().createMerger(getDatabaseSession(), getAuthorization().getUoid()).merge(project, ifcModelSet, new ModelHelper(getBimServer().getMetaDataManager(), ifcModel));
// } catch (MergeException e) {
// throw new UserException(e);
// }
// } else {
// ifcModel = ifcModelSet.iterator().next();
// }
// if (name.endsWith("-")) {
// name = name.substring(0, name.length()-1);
// }
}
Also used : IdEObjectImpl(org.bimserver.emf.IdEObjectImpl) AbstractEList(org.eclipse.emf.common.util.AbstractEList) JsonQueryObjectModelConverter(org.bimserver.database.queries.om.JsonQueryObjectModelConverter) ServerIfcModel(org.bimserver.ServerIfcModel) Query(org.bimserver.database.queries.om.Query) OldQuery(org.bimserver.database.OldQuery) HashMapWrappedVirtualObject(org.bimserver.shared.HashMapWrappedVirtualObject) HashMap(java.util.HashMap) IfcModelInterface(org.bimserver.emf.IfcModelInterface) ArrayList(java.util.ArrayList) IfcModelInterfaceException(org.bimserver.emf.IfcModelInterfaceException) EAttribute(org.eclipse.emf.ecore.EAttribute) MergeException(org.bimserver.plugins.modelmerger.MergeException) QueryObjectProvider(org.bimserver.database.queries.QueryObjectProvider) ArrayList(java.util.ArrayList) AbstractEList(org.eclipse.emf.common.util.AbstractEList) List(java.util.List) UserException(org.bimserver.shared.exceptions.UserException) EReference(org.eclipse.emf.ecore.EReference) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ModelHelper(org.bimserver.plugins.ModelHelper) IdEObject(org.bimserver.emf.IdEObject) PackageMetaData(org.bimserver.emf.PackageMetaData) IOException(java.io.IOException) Date(java.util.Date) Project(org.bimserver.models.store.Project) QueryException(org.bimserver.database.queries.om.QueryException) Revision(org.bimserver.models.store.Revision) HashMapVirtualObject(org.bimserver.shared.HashMapVirtualObject) IfcModelSet(org.bimserver.plugins.IfcModelSet) HashMapWrappedVirtualObject(org.bimserver.shared.HashMapWrappedVirtualObject) IdEObject(org.bimserver.emf.IdEObject) HashMapVirtualObject(org.bimserver.shared.HashMapVirtualObject)

Example 4 with HashMapWrappedVirtualObject

use of org.bimserver.shared.HashMapWrappedVirtualObject in project BIMserver by opensourceBIM.

the class SetWrappedAttributeChange method execute.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void execute(Transaction transaction) throws UserException, BimserverLockConflictException, BimserverDatabaseException, IOException, QueryException {
    PackageMetaData packageMetaData = transaction.getDatabaseSession().getMetaDataManager().getPackageMetaData(transaction.getProject().getSchema());
    Query query = new Query(packageMetaData);
    QueryPart queryPart = query.createQueryPart();
    queryPart.addOid(oid);
    HashMapVirtualObject object = transaction.get(oid);
    if (object == null) {
        QueryObjectProvider queryObjectProvider = new QueryObjectProvider(transaction.getDatabaseSession(), transaction.getBimServer(), query, Collections.singleton(transaction.getPreviousRevision().getOid()), packageMetaData);
        object = queryObjectProvider.next();
        transaction.updated(object);
    }
    EClass eClass = transaction.getDatabaseSession().getEClassForOid(oid);
    if (!ChangeHelper.canBeChanged(eClass)) {
        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");
    }
    if (object == null) {
        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);
    if (eReference == null) {
        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'");
        }
        List list = (List) object.eGet(eReference);
        for (Object o : sourceList) {
            if (eReference.getEType() == EcorePackage.eINSTANCE.getEDouble()) {
                List asStringList = (List) object.eGet(object.eClass().getEStructuralFeature(attributeName + "AsString"));
                asStringList.add(String.valueOf(o));
            }
            list.add(o);
        }
    } else {
        if (eReference.isMany()) {
            throw new UserException("Attribute is not of type 'single'");
        }
        if (eReference.getEType() instanceof EEnum) {
            EEnum eEnum = (EEnum) eReference.getEType();
            object.set(eReference.getName(), eEnum.getEEnumLiteral(((String) value).toUpperCase()).getInstance());
        } else {
            EClass typeEClass = (EClass) packageMetaData.getEClassifier(type);
            if (typeEClass.getEAnnotation("wrapped") == null) {
                throw new UserException("Not a wrapped type");
            }
            HashMapWrappedVirtualObject wrappedObject = new HashMapWrappedVirtualObject(typeEClass);
            if (typeEClass == Ifc2x3tc1Package.eINSTANCE.getIfcBoolean()) {
                if ((Boolean) value == true) {
                    value = Tristate.TRUE;
                } else {
                    value = Tristate.FALSE;
                }
            }
            wrappedObject.set(wrappedObject.eClass().getEStructuralFeature("wrappedValue").getName(), value);
            object.set(eReference.getName(), wrappedObject);
        }
    // if (value instanceof Double) {
    // idEObject.eSet(idEObject.eClass().getEStructuralFeature(attributeName + "AsString"), String.valueOf((Double)value));
    // }
    }
}
Also used : EClass(org.eclipse.emf.ecore.EClass) Query(org.bimserver.database.queries.om.Query) HashMapVirtualObject(org.bimserver.shared.HashMapVirtualObject) HashMapWrappedVirtualObject(org.bimserver.shared.HashMapWrappedVirtualObject) PackageMetaData(org.bimserver.emf.PackageMetaData) QueryPart(org.bimserver.database.queries.om.QueryPart) QueryObjectProvider(org.bimserver.database.queries.QueryObjectProvider) List(java.util.List) HashMapWrappedVirtualObject(org.bimserver.shared.HashMapWrappedVirtualObject) HashMapVirtualObject(org.bimserver.shared.HashMapVirtualObject) UserException(org.bimserver.shared.exceptions.UserException) EEnum(org.eclipse.emf.ecore.EEnum) EReference(org.eclipse.emf.ecore.EReference)

Example 5 with HashMapWrappedVirtualObject

use of org.bimserver.shared.HashMapWrappedVirtualObject in project BIMserver by opensourceBIM.

the class DatabaseReadingStackFrame method readEmbeddedValue.

private HashMapWrappedVirtualObject readEmbeddedValue(EStructuralFeature feature, ByteBuffer buffer, EClass eClass) throws BimserverDatabaseException {
    HashMapWrappedVirtualObject eObject = new HashMapWrappedVirtualObject(eClass);
    for (EStructuralFeature eStructuralFeature : eClass.getEAllStructuralFeatures()) {
        if (eStructuralFeature.isMany()) {
        } else {
            Object primitiveValue = readPrimitiveValue(eStructuralFeature.getEType(), buffer);
            eObject.setAttribute(eStructuralFeature, primitiveValue);
        }
    }
    return eObject;
}
Also used : HashMapWrappedVirtualObject(org.bimserver.shared.HashMapWrappedVirtualObject) EStructuralFeature(org.eclipse.emf.ecore.EStructuralFeature) HashMapWrappedVirtualObject(org.bimserver.shared.HashMapWrappedVirtualObject) HashMapVirtualObject(org.bimserver.shared.HashMapVirtualObject)

Aggregations

HashMapWrappedVirtualObject (org.bimserver.shared.HashMapWrappedVirtualObject)11 HashMapVirtualObject (org.bimserver.shared.HashMapVirtualObject)9 List (java.util.List)4 EStructuralFeature (org.eclipse.emf.ecore.EStructuralFeature)4 QueryObjectProvider (org.bimserver.database.queries.QueryObjectProvider)3 Query (org.bimserver.database.queries.om.Query)3 EClass (org.eclipse.emf.ecore.EClass)3 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 QueryPart (org.bimserver.database.queries.om.QueryPart)2 PackageMetaData (org.bimserver.emf.PackageMetaData)2 UserException (org.bimserver.shared.exceptions.UserException)2 EReference (org.eclipse.emf.ecore.EReference)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 InputStream (java.io.InputStream)1 ByteBuffer (java.nio.ByteBuffer)1 ArrayList (java.util.ArrayList)1