Search in sources :

Example 6 with Include

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

the class StreamingGeometryGenerator method processX.

private void processX(final DatabaseSession databaseSession, QueryContext queryContext, GenerateGeometryResult generateGeometryResult, final StreamingSerializerPlugin ifcSerializerPlugin, final RenderEngineSettings settings, final RenderEngineFilter renderEngineFilter, RenderEnginePool renderEnginePool, ThreadPoolExecutor executor, EClass eClass, Query query, QueryPart queryPart, boolean geometryReused, Map<Long, ProductDef> map, int nrObjects) throws QueryException, IOException {
    JsonQueryObjectModelConverter jsonQueryObjectModelConverter = new JsonQueryObjectModelConverter(packageMetaData);
    String queryNameSpace = "validifc";
    if (packageMetaData.getSchema() == Schema.IFC4) {
        queryNameSpace = "ifc4stdlib";
    }
    if (eClass.getName().equals("IfcAnnotation")) {
        // IfcAnnotation also has the field ContainedInStructure, but that is it's own field (looks like a hack on the IFC-spec side)
        queryPart.addInclude(jsonQueryObjectModelConverter.getDefineFromFile(queryNameSpace + ":IfcAnnotationContainedInStructure"));
    } else {
        queryPart.addInclude(jsonQueryObjectModelConverter.getDefineFromFile(queryNameSpace + ":ContainedInStructure"));
    }
    if (packageMetaData.getSchema() == Schema.IFC4) {
        queryPart.addInclude(jsonQueryObjectModelConverter.getDefineFromFile(queryNameSpace + ":IsTypedBy"));
    }
    queryPart.addInclude(jsonQueryObjectModelConverter.getDefineFromFile(queryNameSpace + ":Decomposes"));
    queryPart.addInclude(jsonQueryObjectModelConverter.getDefineFromFile(queryNameSpace + ":OwnerHistory"));
    Include representationInclude = jsonQueryObjectModelConverter.getDefineFromFile(queryNameSpace + ":Representation");
    queryPart.addInclude(representationInclude);
    Include objectPlacement = jsonQueryObjectModelConverter.getDefineFromFile(queryNameSpace + ":ObjectPlacement");
    queryPart.addInclude(objectPlacement);
    if (packageMetaData.getEClass("IfcElement").isSuperTypeOf(eClass)) {
        Include openingsInclude = queryPart.createInclude();
        openingsInclude.addType(packageMetaData.getEClass(eClass.getName()), false);
        openingsInclude.addField("HasOpenings");
        Include hasOpenings = openingsInclude.createInclude();
        hasOpenings.addType(packageMetaData.getEClass("IfcRelVoidsElement"), false);
        hasOpenings.addField("RelatedOpeningElement");
        hasOpenings.addInclude(representationInclude);
        hasOpenings.addInclude(objectPlacement);
    // Include relatedOpeningElement = hasOpenings.createInclude();
    // relatedOpeningElement.addType(packageMetaData.getEClass("IfcOpeningElement"), false);
    // relatedOpeningElement.addField("HasFillings");
    // Include hasFillings = relatedOpeningElement.createInclude();
    // hasFillings.addType(packageMetaData.getEClass("IfcRelFillsElement"), false);
    // hasFillings.addField("RelatedBuildingElement");
    }
    QueryObjectProvider queryObjectProvider = new QueryObjectProvider(databaseSession, bimServer, query, Collections.singleton(queryContext.getRoid()), packageMetaData);
    ReportJob job = report.newJob(eClass.getName(), nrObjects);
    GeometryRunner runner = new GeometryRunner(this, eClass, renderEnginePool, databaseSession, settings, queryObjectProvider, ifcSerializerPlugin, renderEngineFilter, generateGeometryResult, queryContext, query, geometryReused, map, job, reuseGeometry);
    executor.submit(runner);
    jobsTotal.incrementAndGet();
}
Also used : JsonQueryObjectModelConverter(org.bimserver.database.queries.om.JsonQueryObjectModelConverter) QueryObjectProvider(org.bimserver.database.queries.QueryObjectProvider) Include(org.bimserver.database.queries.om.Include)

Example 7 with Include

use of org.bimserver.database.queries.om.Include 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)

Aggregations

Include (org.bimserver.database.queries.om.Include)7 Query (org.bimserver.database.queries.om.Query)5 QueryPart (org.bimserver.database.queries.om.QueryPart)5 JsonQueryObjectModelConverter (org.bimserver.database.queries.om.JsonQueryObjectModelConverter)4 EClass (org.eclipse.emf.ecore.EClass)4 IOException (java.io.IOException)3 HashMap (java.util.HashMap)3 QueryObjectProvider (org.bimserver.database.queries.QueryObjectProvider)3 QueryException (org.bimserver.database.queries.om.QueryException)3 UserException (org.bimserver.shared.exceptions.UserException)3 EOFException (java.io.EOFException)2 HashSet (java.util.HashSet)2 List (java.util.List)2 AtomicLong (java.util.concurrent.atomic.AtomicLong)2 OldQuery (org.bimserver.database.OldQuery)2 IfcModelInterfaceException (org.bimserver.emf.IfcModelInterfaceException)2 ObjectAlreadyExistsException (org.bimserver.plugins.ObjectAlreadyExistsException)2 DeserializeException (org.bimserver.plugins.deserializers.DeserializeException)2 LittleEndianDataInputStream (com.google.common.io.LittleEndianDataInputStream)1 InputStream (java.io.InputStream)1