Search in sources :

Example 11 with JsonQueryObjectModelConverter

use of org.bimserver.database.queries.om.JsonQueryObjectModelConverter in project BIMserver by opensourceBIM.

the class BimServerClient method query.

public long query(Query query, long roid, long serializerOid) throws ServerException, UserException, PublicInterfaceNotFoundException {
    ObjectNode queryNode = new JsonQueryObjectModelConverter(query.getPackageMetaData()).toJson(query);
    Long topicId = getServiceInterface().download(Collections.singleton(roid), queryNode.toString(), serializerOid, false);
    return topicId;
}
Also used : JsonQueryObjectModelConverter(org.bimserver.database.queries.om.JsonQueryObjectModelConverter) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode)

Example 12 with JsonQueryObjectModelConverter

use of org.bimserver.database.queries.om.JsonQueryObjectModelConverter in project BIMserver by opensourceBIM.

the class ClientIfcModel method getAllWithSubTypes.

@Override
public <T extends IdEObject> List<T> getAllWithSubTypes(EClass eClass) {
    if (!loadedClasses.contains(eClass.getName()) && modelState != ModelState.FULLY_LOADED) {
        try {
            modelState = ModelState.LOADING;
            Query query = new Query(getPackageMetaData());
            QueryPart queryPart = query.createQueryPart();
            queryPart.addType(eClass, true);
            if (includeGeometry && getPackageMetaData().getEClass("IfcProduct").isSuperTypeOf(eClass)) {
                Include include = queryPart.createInclude();
                include.addType(eClass, true);
                include.addField("geometry");
            }
            JsonQueryObjectModelConverter converter = new JsonQueryObjectModelConverter(getPackageMetaData());
            long topicId = bimServerClient.getServiceInterface().download(Collections.singleton(roid), converter.toJson(query).toString(), getJsonSerializerOid(), false);
            waitForDonePreparing(topicId);
            processDownload(topicId);
            bimServerClient.getServiceInterface().cleanupLongAction(topicId);
            for (EClass subClass : bimServerClient.getMetaDataManager().getPackageMetaData(eClass.getEPackage().getName()).getAllSubClasses(eClass)) {
                loadedClasses.add(subClass.getName());
                rebuildIndexPerClass(eClass);
            }
            loadedClasses.add(eClass.getName());
            modelState = ModelState.NONE;
            loadGeometry();
        } catch (Exception e) {
            LOGGER.error("", e);
        }
    }
    return super.getAllWithSubTypes(eClass);
}
Also used : EClass(org.eclipse.emf.ecore.EClass) JsonQueryObjectModelConverter(org.bimserver.database.queries.om.JsonQueryObjectModelConverter) Query(org.bimserver.database.queries.om.Query) QueryPart(org.bimserver.database.queries.om.QueryPart) Include(org.bimserver.database.queries.om.Include) QueryException(org.bimserver.database.queries.om.QueryException) EOFException(java.io.EOFException) IfcModelInterfaceException(org.bimserver.emf.IfcModelInterfaceException) UserException(org.bimserver.shared.exceptions.UserException) ServiceException(org.bimserver.shared.exceptions.ServiceException) ObjectAlreadyExistsException(org.bimserver.plugins.ObjectAlreadyExistsException) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException) IOException(java.io.IOException) DeserializeException(org.bimserver.plugins.deserializers.DeserializeException) ServerException(org.bimserver.shared.exceptions.ServerException)

Example 13 with JsonQueryObjectModelConverter

use of org.bimserver.database.queries.om.JsonQueryObjectModelConverter in project BIMserver by opensourceBIM.

the class ClientIfcModel method loadDeep.

private void loadDeep() throws ServerException, UserException, PublicInterfaceNotFoundException, QueryException {
    if (modelState != ModelState.FULLY_LOADED && modelState != ModelState.LOADING) {
        modelState = ModelState.LOADING;
        Query query = new Query("test", getPackageMetaData());
        QueryPart queryPart = query.createQueryPart();
        queryPart.setIncludeAllFields(true);
        ObjectNode queryNode = new JsonQueryObjectModelConverter(query.getPackageMetaData()).toJson(query);
        Long topicId = bimServerClient.getServiceInterface().download(Collections.singleton(roid), queryNode.toString(), getJsonSerializerOid(), false);
        waitForDonePreparing(topicId);
        try {
            processDownload(topicId);
            bimServerClient.getServiceInterface().cleanupLongAction(topicId);
            modelState = ModelState.FULLY_LOADED;
            loadGeometry();
        } catch (IfcModelInterfaceException | IOException e) {
            LOGGER.error("", e);
        } catch (QueryException e) {
            LOGGER.error("", e);
        } catch (GeometryException e) {
            LOGGER.error("", e);
        }
    }
}
Also used : IfcModelInterfaceException(org.bimserver.emf.IfcModelInterfaceException) QueryException(org.bimserver.database.queries.om.QueryException) JsonQueryObjectModelConverter(org.bimserver.database.queries.om.JsonQueryObjectModelConverter) Query(org.bimserver.database.queries.om.Query) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) QueryPart(org.bimserver.database.queries.om.QueryPart) IOException(java.io.IOException)

Aggregations

JsonQueryObjectModelConverter (org.bimserver.database.queries.om.JsonQueryObjectModelConverter)13 IOException (java.io.IOException)10 Query (org.bimserver.database.queries.om.Query)9 QueryException (org.bimserver.database.queries.om.QueryException)9 UserException (org.bimserver.shared.exceptions.UserException)8 IfcModelInterfaceException (org.bimserver.emf.IfcModelInterfaceException)7 QueryPart (org.bimserver.database.queries.om.QueryPart)6 DeserializeException (org.bimserver.plugins.deserializers.DeserializeException)6 ServerException (org.bimserver.shared.exceptions.ServerException)6 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)5 EOFException (java.io.EOFException)5 ObjectAlreadyExistsException (org.bimserver.plugins.ObjectAlreadyExistsException)5 PublicInterfaceNotFoundException (org.bimserver.shared.exceptions.PublicInterfaceNotFoundException)5 ServiceException (org.bimserver.shared.exceptions.ServiceException)5 Include (org.bimserver.database.queries.om.Include)4 OldQuery (org.bimserver.database.OldQuery)3 QueryObjectProvider (org.bimserver.database.queries.QueryObjectProvider)3 Date (java.util.Date)2 HashMap (java.util.HashMap)2 List (java.util.List)2