Exemplo n.º 1
0
 /*
  * Serializers, deserializers, renderengines etc... all have counterparts as
  * objects in the database for configuration purposes, this methods syncs
  * both versions
  */
 private void createDatabaseObjects(DatabaseSession session)
     throws BimserverLockConflictException, BimserverDatabaseException, PluginException,
         BimserverConcurrentModificationDatabaseException {
   IfcModelInterface allOfType =
       session.getAllOfType(StorePackage.eINSTANCE.getUser(), Query.getDefault());
   for (User user : allOfType.getAll(User.class)) {
     updateUserSettings(session, user);
   }
 }
Exemplo n.º 2
0
 private void step1() {
   List<IfcDistributionPort> ports = model.getAll(IfcDistributionPort.class);
   for (IfcDistributionPort port : ports) {
     if (port.getConnectedTo().size() == 0 && port.getConnectedFrom().size() == 0) {
       LOGGER.info("Step 1: DistributionPort = " + port.getName());
       step2(port);
     }
   }
 }
Exemplo n.º 3
0
  public static void writeResources(COBIEType cType, IfcModelInterface model) {
    LogHandler loggerHandler = new LogHandler(sheetName, LOGGER);
    loggerHandler.sheetWriteBegin();
    COBIEType.Resources resources;
    String name;
    IfcOwnerHistory oh;
    String createdBy;
    Calendar createdOn;
    String category;
    String extSystem;
    String extObject;
    String extIdentifier;
    String description;
    try {
      resources = cType.getResources();
      if (resources == null) {
        resources = cType.addNewResources();
      }
    } catch (Exception ex) {
      resources = cType.addNewResources();
    }

    for (IfcConstructionEquipmentResource equipmentResource :
        model.getAll(IfcConstructionEquipmentResource.class)) {
      try {

        name = IfcToResource.nameFromConstructionEquipmentResource(equipmentResource);
        oh = equipmentResource.getOwnerHistory();
        createdBy = COBieUtility.getEmailFromOwnerHistory(oh);
        createdOn = IfcToContact.getCreatedOn(oh.getCreationDate());
        category = IfcToResource.categoryFromConstructionEquipmentResource(equipmentResource);
        extSystem = COBieUtility.getApplicationName(oh);
        extObject = COBieUtility.extObjectFromObjectDef(equipmentResource);
        extIdentifier = COBieUtility.extIdFromRoot(equipmentResource);
        description = IfcToResource.descriptionFromConstructionEquipmentResource(equipmentResource);

        ResourceType resource = resources.addNewResource();
        resource.setName(name);
        resource.setCreatedBy(createdBy);
        resource.setCreatedOn(createdOn);
        resource.setCategory(category);
        resource.setExtSystem(extSystem);
        resource.setExtObject(extObject);
        resource.setExtIdentifier(extIdentifier);
        resource.setDescription(description);
        loggerHandler.rowWritten();
      } catch (Exception ex) {
        loggerHandler.error(ex);
      }
    }
    loggerHandler.sheetWritten();
  }
Exemplo n.º 4
0
  @Override
  public void run() {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    running = true;
    while (running) {
      try {
        String line = reader.readLine();
        if (line == null) {
          try {
            Thread.sleep(50);
          } catch (InterruptedException e) {
            LOGGER.error("", e);
          }
          continue;
        }
        if (line.equalsIgnoreCase("exit")) {
          bimServer.stop();
          return;
        } else if (line.startsWith("dumpmodel")) {
          try {
            long roid = Long.parseLong(line.substring(9).trim());
            DatabaseSession databaseSession = bimServer.getDatabase().createSession();
            try {
              DownloadDatabaseAction downloadDatabaseAction =
                  new DownloadDatabaseAction(
                      bimServer,
                      databaseSession,
                      AccessMethod.INTERNAL,
                      roid,
                      -1,
                      -1,
                      new SystemAuthorization(1, TimeUnit.HOURS),
                      null,
                      new Reporter() {
                        @Override
                        public void error(String error) {}

                        @Override
                        public void info(String info) {}

                        @Override
                        public void warning(String warning) {}
                      });
              IfcModelInterface model = downloadDatabaseAction.execute();
              LOGGER.info("Model size: " + model.size());

              List<IfcWall> walls = model.getAll(IfcWall.class);
              List<IfcProject> projects = model.getAll(IfcProject.class);
              List<IfcSlab> slabs = model.getAll(IfcSlab.class);
              List<IfcWindow> windows = model.getAll(IfcWindow.class);

              LOGGER.info("Walls: " + walls.size());
              LOGGER.info("Windows: " + windows.size());
              LOGGER.info("Projects: " + projects.size());
              LOGGER.info("Slabs: " + slabs.size());
            } catch (UserException e) {
              LOGGER.error("", e);
            } catch (BimserverLockConflictException e) {
              LOGGER.error("", e);
            } catch (BimserverDatabaseException e) {
              LOGGER.error("", e);
            } finally {
              databaseSession.close();
            }
          } catch (Exception e) {
            LOGGER.error("", e);
          }
        } else if (line.equalsIgnoreCase("dump")) {
          LOGGER.info("Dumping all thread's track traces...");
          LOGGER.info("");
          Map<Thread, StackTraceElement[]> allStackTraces = Thread.getAllStackTraces();
          for (Thread t : allStackTraces.keySet()) {
            LOGGER.info(t.getName());
            StackTraceElement[] stackTraceElements = allStackTraces.get(t);
            for (StackTraceElement stackTraceElement : stackTraceElements) {
              LOGGER.info(
                  "\t"
                      + stackTraceElement.getClassName()
                      + ":"
                      + stackTraceElement.getLineNumber()
                      + "."
                      + stackTraceElement.getMethodName());
            }
            LOGGER.info("");
          }
          LOGGER.info("Done printing stack traces");
          LOGGER.info("");
          try {
            Thread.sleep(10000);
          } catch (InterruptedException e) {
            LOGGER.error("", e);
          }
        } else if (line.equals("migrate")) {
          try {
            bimServer.getDatabase().getMigrator().migrate();
            bimServer.getServerInfoManager().update();
          } catch (MigrationException e) {
            LOGGER.error("", e);
          } catch (InconsistentModelsException e) {
            LOGGER.error("", e);
          }
        } else if (line.equals("clearendpoints")) {
          bimServer.getEndPointManager().clear();
        } else if (line.startsWith("showall")) {
          KeyValueStore keyValueStore = ((Database) bimServer.getDatabase()).getKeyValueStore();
          Set<String> allTableNames = keyValueStore.getAllTableNames();
          long total = 0;
          for (String tableName : allTableNames) {
            long size = keyValueStore.count(tableName);
            total += size;
            if (size != 0) {
              LOGGER.info(tableName + " " + size);
            }
          }
          LOGGER.info("total: " + total);
        } else {
          LOGGER.info("Unknown command");
        }
      } catch (IOException e) {
        LOGGER.error("", e);
      }
    }
  }
Exemplo n.º 5
0
  public static void main(String[] args) {
    try {
      PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(new File("home"));
      DeserializerPlugin deserializerPlugin =
          pluginManager.getFirstDeserializer("ifc", Schema.IFC2X3TC1, true);

      Deserializer deserializer = deserializerPlugin.createDeserializer(null);
      deserializer.init(pluginManager.getMetaDataManager().getPackageMetaData("ifc2x3tc1"));

      IfcModelInterface model =
          deserializer.read(new File("../TestData/data/AC9R1-Haus-G-H-Ver2-2x3.ifc"));

      deserializer = deserializerPlugin.createDeserializer(null);
      deserializer.init(pluginManager.getMetaDataManager().getPackageMetaData("ifc2x3tc1"));
      IfcModelInterface furnishingModel = deserializer.read(new File("test.ifc"));

      model.fixOids(new IncrementingOidProvider());
      long oid = model.getHighestOid();
      IncrementingOidProvider oidProvider = new IncrementingOidProvider(oid + 1);

      IfcFurnishingElement picknick =
          (IfcFurnishingElement)
              furnishingModel.getByName(
                  Ifc2x3tc1Package.eINSTANCE.getIfcFurnishingElement(), "Picknik Bank");

      ModelHelper modelHelper =
          new ModelHelper(
              pluginManager.getMetaDataManager(),
              new HideAllInversesObjectIDM(
                  CollectionUtils.singleSet(Ifc2x3tc1Package.eINSTANCE),
                  pluginManager.requireSchemaDefinition("ifc2x3tc1")),
              model);

      IfcProductDefinitionShape representation =
          (IfcProductDefinitionShape) picknick.getRepresentation();
      IfcRepresentation surfaceModel = null;
      IfcRepresentation boundingBox = null;
      for (IfcRepresentation ifcRepresentation : representation.getRepresentations()) {
        IfcShapeRepresentation ifcShapeRepresentation = (IfcShapeRepresentation) ifcRepresentation;
        if (ifcShapeRepresentation.getRepresentationType().equals("SurfaceModel")) {
          surfaceModel = (IfcRepresentation) modelHelper.copy(ifcShapeRepresentation, false);
        } else if (ifcShapeRepresentation.getRepresentationType().equals("BoundingBox")) {
          boundingBox = (IfcRepresentation) modelHelper.copy(ifcShapeRepresentation, false);
        }
      }

      IfcOwnerHistory ownerHistory = null;
      List<IfcOwnerHistory> all = model.getAll(IfcOwnerHistory.class);
      if (all.size() > 0) {
        ownerHistory = all.get(0);
      }

      for (IfcBuildingStorey ifcBuildingStorey : model.getAll(IfcBuildingStorey.class)) {
        for (IfcRelDecomposes ifcRelDecomposes : ifcBuildingStorey.getIsDecomposedBy()) {
          for (IfcObjectDefinition ifcObjectDefinition : ifcRelDecomposes.getRelatedObjects()) {
            if (ifcObjectDefinition instanceof IfcSpace) {
              IfcSpace ifcSpace = (IfcSpace) ifcObjectDefinition;
              //							IfcProductDefinitionShape slabRepr = (IfcProductDefinitionShape)
              // ifcSpace.getRepresentation();
              //							IfcBoundingBox box = null;
              //							for (IfcRepresentation representation2 : slabRepr.getRepresentations()) {
              //								IfcShapeRepresentation shapeRepresentation =
              // (IfcShapeRepresentation)representation2;
              //								if (shapeRepresentation.getRepresentationType().equals("BoundingBox")) {
              //									for (IfcRepresentationItem i2 : shapeRepresentation.getItems()) {
              //										box = (IfcBoundingBox)i2;
              //									}
              //								}
              //							}

              IfcFurnishingElement newFurnishing =
                  model.create(IfcFurnishingElement.class, oidProvider);

              IfcRelContainedInSpatialStructure containedInSpatialStructure2 =
                  model.create(IfcRelContainedInSpatialStructure.class, oidProvider);
              containedInSpatialStructure2.setRelatingStructure(ifcBuildingStorey);
              containedInSpatialStructure2.getRelatedElements().add(newFurnishing);

              newFurnishing.setName("Generated");
              newFurnishing.setGlobalId("TEST");
              newFurnishing.setOwnerHistory(ownerHistory);
              IfcProductDefinitionShape definitionShape =
                  model.create(IfcProductDefinitionShape.class, oidProvider);
              newFurnishing.setRepresentation(definitionShape);

              definitionShape.getRepresentations().add(boundingBox);
              definitionShape.getRepresentations().add(surfaceModel);

              IfcLocalPlacement localPlacement = model.create(IfcLocalPlacement.class, oidProvider);
              localPlacement.setPlacementRelTo(ifcSpace.getObjectPlacement());
              IfcAxis2Placement3D axis2Placement3D =
                  model.create(IfcAxis2Placement3D.class, oidProvider);
              localPlacement.setRelativePlacement(axis2Placement3D);

              IfcCartesianPoint pos = model.create(IfcCartesianPoint.class, oidProvider);
              pos.getCoordinates().add(-3d);
              pos.getCoordinates().add(+0.5d);
              pos.getCoordinates().add(0d);
              axis2Placement3D.setLocation(pos);

              newFurnishing.setObjectPlacement(localPlacement);
            }
          }
        }
      }

      model.resetExpressIds();

      SerializerPlugin serializerPlugin =
          pluginManager.getSerializerPlugin(
              "org.bimserver.ifc.step.serializer.IfcStepSerializerPlugin", true);
      Serializer serializer = serializerPlugin.createSerializer(null);
      serializer.init(model, null, pluginManager, null, null, true);
      serializer.writeToFile(new File("withfurn.ifc"), null);
    } catch (PluginException e) {
      e.printStackTrace();
    } catch (DeserializeException e) {
      e.printStackTrace();
    } catch (IfcModelInterfaceException e) {
      e.printStackTrace();
    } catch (SerializerException e) {
      e.printStackTrace();
    }
  }
Exemplo n.º 6
0
  private static void exportTypeInformation(
      IfcModelInterface model,
      LogHandler loggerHandler,
      ArrayList<String> typeNames,
      ArrayList<String> documentNames,
      COBIEType.Documents documents) {
    String name;
    String createdBy;
    Calendar createdOn;
    String category;
    String approvalBy;
    String stage;
    String sheetName;
    String rowName;
    String directory;
    String file;
    String extSystem;
    String extObject;
    String extIdentifier;
    String description;
    String reference;
    IfcOwnerHistory oh;
    DocumentType tempDocument;
    if (documentNames.size() == 0) {
      for (IfcRelDefinesByType defByType : model.getAll(IfcRelDefinesByType.class)) {
        try {
          IfcTypeObject type = defByType.getRelatingType();
          if (type != null) {
            name = IfcToDocument.nameFromTypeObject(type);
            if (!typeNames.contains(name)) {

              oh = COBieIfcUtility.firstOwnerHistoryFromModel(model);
              createdBy = COBieIfcUtility.getEmailFromOwnerHistory(oh);
              createdOn = IfcToContact.getCreatedOn(oh.getCreationDate());
              category = IfcToDocument.categoryFromTypeObject(type);
              approvalBy = IfcToDocument.ApprovalBy;
              stage = IfcToDocument.Stage;
              sheetName = IfcToDocument.TypeSheetName;
              rowName = IfcToType.nameFromTypeObject(type);
              directory = IfcToDocument.Directory;
              file = IfcToDocument.File;
              extSystem = COBieIfcUtility.getApplicationName(oh);
              extObject = IfcToType.extObjectFromTypeObject(type);
              extIdentifier = COBieIfcUtility.extIdFromRoot(type);
              description = IfcToDocument.descriptionFromTypeObject(type);
              reference = IfcToDocument.Reference;

              tempDocument = documents.addNewDocument();
              typeNames.add(name);
              tempDocument.setName(name);
              tempDocument.setCreatedBy(createdBy);
              tempDocument.setCreatedOn(createdOn);
              tempDocument.setCategory(category);
              tempDocument.setApprovalBy(approvalBy);
              tempDocument.setStage(stage);
              tempDocument.setSheetName(sheetName);
              tempDocument.setRowName(rowName);
              tempDocument.setDirectory(directory);
              tempDocument.setFile(file);
              tempDocument.setExtSystem(extSystem);
              tempDocument.setExtObject(extObject);
              tempDocument.setExtIdentifier(extIdentifier);
              tempDocument.setDescription(description);
              tempDocument.setReference(reference);
              loggerHandler.rowWritten();
            }
          }
        } catch (Exception ex) {
          loggerHandler.error(ex);
        }
      }
    }
  }
Exemplo n.º 7
0
  private static void exportDocumentInformationObjects(
      IfcModelInterface model,
      LogHandler loggerHandler,
      ArrayList<String> documentNames,
      COBIEType.Documents documents) {
    String name;
    String createdBy;
    Calendar createdOn;
    String category;
    String approvalBy;
    String stage;
    String sheetName;
    String rowName;
    String directory;
    String file;
    String extSystem;
    String extObject;
    String extIdentifier;
    String description;
    String reference;
    IfcOwnerHistory oh;
    DocumentType tempDocument;
    for (IfcRelAssociatesDocument relAssociatesDocument :
        model.getAll(IfcRelAssociatesDocument.class)) {
      IfcDocumentSelect docInfoSelect = relAssociatesDocument.getRelatingDocument();
      if (docInfoSelect instanceof IfcDocumentInformation) {
        IfcDocumentInformation docInfo = (IfcDocumentInformation) docInfoSelect;
        try {

          name = IfcToDocument.nameFromDocumentInformation(docInfo);
          oh = relAssociatesDocument.getOwnerHistory();
          createdBy = COBieIfcUtility.getEmailFromOwnerHistory(oh);
          createdOn = IfcToContact.getCreatedOn(oh.getCreationDate());
          category = IfcToDocument.categoryFromDocumentInformation(docInfo);
          approvalBy = IfcToDocument.approvalByFromDocumentInformation(docInfo);
          stage = IfcToDocument.stageFromDocumentInformation(docInfo);
          sheetName = IfcToDocument.sheetNameFromRelAssociatesDocument(relAssociatesDocument);
          rowName = IfcToDocument.rowNameFromRelAssociatesDocument(relAssociatesDocument);
          directory = IfcToDocument.directoryFromDocumentInformation(docInfo);
          file = IfcToDocument.fileFromDocumentInformation(docInfo);
          extSystem = COBieIfcUtility.getApplicationName(oh);
          extObject = IfcToDocument.extObjectFromRelAssociatesDocument(relAssociatesDocument);
          extIdentifier = IfcToDocument.extIdFromRelAssociatesDocument(relAssociatesDocument);
          description = IfcToDocument.descriptionFromDocumentInformation(docInfo);
          reference = IfcToDocument.referenceFromDocumentInformation(docInfo);

          tempDocument = documents.addNewDocument();
          tempDocument.setName(name);
          tempDocument.setCreatedBy(createdBy);
          tempDocument.setCreatedOn(createdOn);
          tempDocument.setCategory(category);
          tempDocument.setApprovalBy(approvalBy);
          tempDocument.setStage(stage);
          tempDocument.setSheetName(sheetName);
          tempDocument.setRowName(rowName);
          tempDocument.setDirectory(directory);
          tempDocument.setFile(file);
          tempDocument.setExtSystem(extSystem);
          tempDocument.setExtIdentifier(extIdentifier);
          tempDocument.setExtObject(extObject);
          tempDocument.setDescription(description);
          tempDocument.setReference(reference);
          documentNames.add(name);
          loggerHandler.rowWritten();
        } catch (Exception ex) {
          loggerHandler.error(ex);
        }
      }
    }
  }