コード例 #1
0
  private void applyIDMFilter(IfcModelInterface model) {
    try {
      ObjectIDM objectIDM = cobieToolkit.getObjectIDM();
      if (objectIDM != null) {
        ArrayList<IdEObject> removeTheseObjects = new ArrayList<IdEObject>();
        for (long key : model.getObjects().keySet()) {
          IdEObject candidateObject = model.get(key);
          boolean shouldIncludeObject =
              objectIDM.shouldIncludeClass(candidateObject.eClass(), candidateObject.eClass());
          for (EStructuralFeature feature : candidateObject.eClass().getEAllStructuralFeatures()) {
            boolean shouldFollowReference =
                objectIDM.shouldFollowReference(
                    candidateObject.eClass(), candidateObject.eClass(), feature);
            if (!shouldFollowReference) {
              candidateObject.eUnset(feature);
            }
          }
          if (!shouldIncludeObject) {
            removeTheseObjects.add(candidateObject);
          }
        }
        for (IdEObject ideObject : removeTheseObjects) {
          model.remove(ideObject);
        }
      }

    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
コード例 #2
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);
   }
 }
コード例 #3
0
 public void update() {
   try {
     serverInfo.setVersion(
         bimServer
             .getSConverter()
             .convertFromSObject(bimServer.getVersionChecker().getLocalVersion(), null));
   } catch (BimserverDatabaseException e) {
     LOGGER.error("", e);
   }
   if (bimServer.getDatabase().getMigrator().migrationRequired()) {
     setServerState(ServerState.MIGRATION_REQUIRED);
     if (bimServer.getConfig().isAutoMigrate()) {
       try {
         bimServer.getDatabase().getMigrator().migrate();
         setServerState(ServerState.RUNNING);
       } catch (MigrationException | InconsistentModelsException e) {
         LOGGER.error("", e);
       }
     }
   } else if (bimServer.getDatabase().getMigrator().migrationImpossible()) {
     setServerState(ServerState.MIGRATION_IMPOSSIBLE);
   } else {
     DatabaseSession session = bimServer.getDatabase().createSession();
     try {
       boolean adminFound = false;
       ServerSettings settings = bimServer.getServerSettingsCache().getServerSettings();
       IfcModelInterface users =
           session.getAllOfType(StorePackage.eINSTANCE.getUser(), Query.getDefault());
       for (IdEObject idEObject : users.getValues()) {
         if (idEObject instanceof User) {
           User user = (User) idEObject;
           if (user.getUserType() == UserType.ADMIN) {
             adminFound = true;
             break;
           }
         }
       }
       if (settings.getSiteAddress().isEmpty()
           || settings.getSmtpServer().isEmpty()
           || !adminFound) {
         setServerState(ServerState.NOT_SETUP);
       } else {
         setServerState(ServerState.RUNNING);
       }
     } catch (BimserverDatabaseException e) {
       LOGGER.error("", e);
     } finally {
       session.close();
     }
   }
 }
コード例 #4
0
  private void setClassificationInverseSlots(IfcModelInterface model) {

    for (IfcRelAssociatesClassification classificationAssociation :
        model.getAllWithSubTypes(IfcRelAssociatesClassification.class)) {
      for (IfcRoot relatedObject : classificationAssociation.getRelatedObjects()) {
        if (relatedObject instanceof IfcPropertySetDefinition) {
          try {
            IfcPropertySetDefinition propertySetDefinition =
                (IfcPropertySetDefinition) relatedObject;
            if (!propertySetDefinition.getHasAssociations().contains(classificationAssociation)) {
              propertySetDefinition.getHasAssociations().add(classificationAssociation);
            }
          } catch (Exception ex) {

          }
        } else if (relatedObject instanceof IfcObjectDefinition) {
          try {
            IfcObjectDefinition objectDefinition = (IfcObjectDefinition) relatedObject;
            if (!objectDefinition.getHasAssociations().contains(classificationAssociation)) {;
            }
            objectDefinition.getHasAssociations().add(classificationAssociation);
          } catch (Exception ex) {

          }
        }
      }
    }
  }
コード例 #5
0
 /*
  * This will list all projects, select the first project with at least one
  * revision and dump the names of all walls within the last revision of that
  * project
  */
 @Test
 public void testDump() {
   try {
     ServiceMap serviceMap = bimServer.getServiceFactory().get(AccessMethod.INTERNAL);
     ServiceInterface service = serviceMap.get(ServiceInterface.class);
     String token = serviceMap.get(AuthInterface.class).login(username, password);
     service =
         bimServer
             .getServiceFactory()
             .get(token, AccessMethod.INTERNAL)
             .get(ServiceInterface.class);
     BimDatabase database = bimServer.getDatabase();
     DatabaseSession session = database.createSession();
     SProject firstProjectWithRevisions = null;
     for (SProject project : serviceMap.getServiceInterface().getAllProjects(false, true)) {
       System.out.println(project.getName());
       if (!project.getRevisions().isEmpty() && firstProjectWithRevisions == null) {
         firstProjectWithRevisions = project;
       }
     }
     if (firstProjectWithRevisions != null) {
       long roid = firstProjectWithRevisions.getLastRevisionId();
       DownloadDatabaseAction downloadDatabaseAction =
           new DownloadDatabaseAction(
               bimServer,
               session,
               AccessMethod.INTERNAL,
               roid,
               -1,
               -1,
               ((ServiceImpl) service).getAuthorization(),
               null);
       IfcModelInterface ifcModelInterface = downloadDatabaseAction.execute();
       for (IfcWall ifcWall : ifcModelInterface.getAllWithSubTypes(IfcWall.class)) {
         System.out.println(ifcWall.getName());
       }
     }
   } catch (ServiceException e) {
     e.printStackTrace();
   } catch (BimserverDatabaseException e) {
     e.printStackTrace();
   } catch (PublicInterfaceNotFoundException e) {
     e.printStackTrace();
   }
 }
コード例 #6
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);
     }
   }
 }
コード例 #7
0
 private void createProperty(
     IfcWindow window, IfcModelInterface model, String name, String description, Object value)
     throws IfcModelInterfaceException {
   IfcRelDefinesByProperties ifcRelDefinesByProperties =
       model.create(IfcRelDefinesByProperties.class);
   window.getIsDefinedBy().add(ifcRelDefinesByProperties);
   IfcPropertySet propertySet = model.create(IfcPropertySet.class);
   ifcRelDefinesByProperties.setRelatingPropertyDefinition(propertySet);
   IfcPropertySingleValue property = model.create(IfcPropertySingleValue.class);
   propertySet.getHasProperties().add(property);
   property.setName(name);
   property.setDescription(description);
   if (value instanceof Boolean) {
     IfcBoolean ifcValue = model.create(IfcBoolean.class);
     ifcValue.setWrappedValue(((Boolean) value) ? Tristate.TRUE : Tristate.FALSE);
     property.setNominalValue(ifcValue);
   } else {
     // Unimplemented
   }
 }
コード例 #8
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();
  }
コード例 #9
0
  @Test
  public void test() {
    ProtocolBuffersMetaData protocolBuffersMetaData = new ProtocolBuffersMetaData();
    protocolBuffersMetaData.load(
        bimServer.getServicesMap(), ProtocolBuffersBimServerClientFactory.class);
    BimServerClientFactory factory =
        new ProtocolBuffersBimServerClientFactory(
            "localhost", 8020, 8080, protocolBuffersMetaData, null);
    UsernamePasswordAuthenticationInfo usernamePasswordAuthenticationInfo =
        new UsernamePasswordAuthenticationInfo("*****@*****.**", "admin");
    try {
      bimServerClient = factory.create(usernamePasswordAuthenticationInfo);
    } catch (ChannelConnectionException e1) {
      e1.printStackTrace();
    } catch (ServerException e) {
      e.printStackTrace();
    } catch (UserException e) {
      e.printStackTrace();
    } catch (ServiceException e) {
      e.printStackTrace();
    }
    try {
      IfcModelInterface model = bimServerClient.newModel(createProject(), false);
      SProject project = createProject();
      CreateFromScratch createFromScratch = new CreateFromScratch();
      createFromScratch.createIfcProject(model);
      long roid = model.commit("tralala");

      dumpToFile(project, roid);

      createFromScratch.createWall(model);
      roid = model.commit("test");

      dumpToFile(project, roid);
    } catch (Exception e) {
      e.printStackTrace();
      fail(e.getMessage());
    }
  }
コード例 #10
0
 @Override
 public void execute(VirtualUser virtualUser)
     throws ServerException, UserException, PublicInterfaceNotFoundException {
   SRevision randomRevision = virtualUser.getRandomRevision();
   if (randomRevision != null) {
     IfcModelInterface model;
     try {
       SProject project =
           virtualUser
               .getBimServerClient()
               .getBimsie1ServiceInterface()
               .getProjectByPoid(randomRevision.getProjectId());
       model =
           virtualUser
               .getBimServerClient()
               .getModel(project, randomRevision.getOid(), true, false);
       PluginManager pluginManager = getTestFramework().getPluginManager();
       SerializerPlugin serializerPlugin =
           pluginManager.getSerializerPlugin(
               "org.bimserver.ifc.step.serializer.IfcStepSerializerPlugin", true);
       Serializer serializer = serializerPlugin.createSerializer(new PluginConfiguration());
       model.generateMinimalExpressIds();
       serializer.init(
           model, null, pluginManager, pluginManager.requireRenderEngine(), null, false);
       serializer.writeToFile(
           new File(getTestFramework().getTestConfiguration().getOutputFolder(), "test.ifc"),
           null);
     } catch (BimServerClientException e1) {
       e1.printStackTrace();
     } catch (RenderEngineException e) {
       e.printStackTrace();
     } catch (PluginException e) {
       e.printStackTrace();
     } catch (SerializerException e) {
       e.printStackTrace();
     }
   }
 }
コード例 #11
0
ファイル: IfcVisualiser.java プロジェクト: joojump/BIMserver
  private void createSceneGraph() throws PluginException, IfcModelInterfaceException {
    buildingTransformGroup = new TransformGroup();

    Set<Class<? extends IfcRoot>> classesToConvert = new HashSet<Class<? extends IfcRoot>>();
    classesToConvert.add(IfcWall.class);
    classesToConvert.add(IfcWallStandardCase.class);
    classesToConvert.add(IfcWindow.class);
    classesToConvert.add(IfcOpeningElement.class);
    classesToConvert.add(IfcSlab.class);
    classesToConvert.add(IfcRoof.class);
    classesToConvert.add(IfcColumn.class);
    classesToConvert.add(IfcSpace.class);
    classesToConvert.add(IfcDoor.class);
    classesToConvert.add(IfcRailing.class);
    classesToConvert.add(IfcFurnishingElement.class);
    classesToConvert.add(IfcStair.class);
    classesToConvert.add(IfcBeam.class);
    classesToConvert.add(IfcFlowTerminalType.class);
    classesToConvert.add(IfcDistributionFlowElement.class);
    classesToConvert.add(IfcSite.class);
    // classesToConvert.add(IfcProxy.class);

    for (IdEObject idEObject : model.getValues()) {
      if (classesToConvert.contains(idEObject.eClass().getInstanceClass())) {
        setGeometry((IfcRoot) idEObject);
      }
    }
    buildingBranchGroup = new BranchGroup();
    addLights(buildingBranchGroup);
    buildingBranchGroup.addChild(buildingTransformGroup);
    showLoader = false;
    sceneBranchGroup.removeChild(loaderBranchGroup);
    sharedGroup.addChild(buildingBranchGroup);

    // for (int x = 0; x < 5; x++) {
    // for (int y = 0; y < 5; y++) {
    Link link1 = new Link(sharedGroup);
    Transform3D t3d1 = new Transform3D();
    // t3d1.setTranslation(new Vector3f(x * 20, y * 20, 0f));
    BranchGroup x1 = new BranchGroup();
    TransformGroup t1 = new TransformGroup(t3d1);
    x1.addChild(t1);
    t1.addChild(link1);
    sceneBranchGroup.addChild(x1);
    // }
    // }

    reInitView();
  }
コード例 #12
0
 public CompareResult compare(
     IfcModelInterface model1, IfcModelInterface model2, CompareType compareType)
     throws ModelCompareException {
   CompareResult result = StoreFactory.eINSTANCE.createCompareResult();
   try {
     for (EClassifier eClassifier : Ifc2x3tc1Package.eINSTANCE.getEClassifiers()) {
       if (eClassifier instanceof EClass
           && Ifc2x3tc1Package.eINSTANCE.getIfcRoot().isSuperTypeOf((EClass) eClassifier)) {
         EClass eClass = (EClass) eClassifier;
         for (IdEObject i : model1.getValues()) {
           if (i instanceof IfcWindow) {
             IfcWindow window = (IfcWindow) i;
             for (EStructuralFeature feature : window.eClass().getEStructuralFeatures()) {
               window.eGet(feature);
             }
           }
         }
         for (String guid : model1.getGuids(eClass)) {
           IdEObject eObject1 = model1.getByGuid(guid);
           IdEObject eObject2 = model2.getByGuid(guid);
           if (eObject2 == null) {
             if (compareType == CompareType.ALL || compareType == CompareType.DELETE) {
               ObjectRemoved objectRemoved = StoreFactory.eINSTANCE.createObjectRemoved();
               objectRemoved.setDataObject(makeDataObject(eObject1));
               getCompareContainer(eObject1.eClass()).getItems().add(objectRemoved);
             }
           }
         }
         for (String guid : model2.getGuids(eClass)) {
           IdEObject eObject1 = model1.getByGuid(guid);
           IdEObject eObject2 = model2.getByGuid(guid);
           if (eObject1 == null) {
             if (compareType == CompareType.ALL || compareType == CompareType.ADD) {
               ObjectAdded objectAdded = StoreFactory.eINSTANCE.createObjectAdded();
               objectAdded.setDataObject(makeDataObject(eObject2));
               getCompareContainer(eObject2.eClass()).getItems().add(objectAdded);
             }
           } else {
             compareEObjects(eClass, eObject1, eObject2, result, compareType);
           }
         }
       }
     }
   } catch (Exception e) {
     throw new ModelCompareException(e);
   }
   for (CompareContainer compareContainer : getMap().values()) {
     result.getItems().add(compareContainer);
   }
   return result;
 }
コード例 #13
0
ファイル: MoveObject.java プロジェクト: signalsaeed/IFCParser
  @Test
  public void test() {
    try {
      // Create a new BimServerClient with authentication
      BimServerClientInterface bimServerClient =
          getFactory()
              .create(new UsernamePasswordAuthenticationInfo("*****@*****.**", "admin"));

      // Create a new project
      SProject newProject =
          bimServerClient
              .getBimsie1ServiceInterface()
              .addProject("test" + Math.random(), "ifc2x3tc1");

      // Get the appropriate deserializer
      SDeserializerPluginConfiguration deserializer =
          bimServerClient
              .getBimsie1ServiceInterface()
              .getSuggestedDeserializerForExtension("ifc", newProject.getOid());

      // Checkin the file
      bimServerClient.checkin(
          newProject.getOid(),
          "test",
          deserializer.getOid(),
          false,
          true,
          new File("../TestData/data/AC11-Institute-Var-2-IFC.ifc"));

      // Refresh project info
      newProject =
          bimServerClient.getBimsie1ServiceInterface().getProjectByPoid(newProject.getOid());

      IfcModelInterface model =
          bimServerClient.getModel(newProject, newProject.getLastRevisionId(), true, false);
      for (IfcFurnishingElement ifcFurnishingElement :
          model.getAllWithSubTypes(IfcFurnishingElement.class)) {
        IfcObjectPlacement objectPlacement = ifcFurnishingElement.getObjectPlacement();
        if (objectPlacement != null && objectPlacement instanceof IfcLocalPlacement) {
          IfcLocalPlacement localPlacement = (IfcLocalPlacement) objectPlacement;
          IfcAxis2Placement relativePlacement = localPlacement.getRelativePlacement();
          if (relativePlacement != null) {
            if (relativePlacement instanceof IfcAxis2Placement3D) {
              IfcAxis2Placement3D axis2Placement3D = (IfcAxis2Placement3D) relativePlacement;
              IfcCartesianPoint location = axis2Placement3D.getLocation();
              double newValue = location.getCoordinates().get(2) + 50;
              System.out.println(
                  "Changing z value of "
                      + ifcFurnishingElement.getName()
                      + " from "
                      + location.getCoordinates().get(2)
                      + " to "
                      + newValue);
              location.getCoordinates().set(2, newValue);
            }
          }
        }
      }
      long newRoid = model.commit("Moved all furniture 50 meters up");
      SSerializerPluginConfiguration ifcSerializer =
          bimServerClient
              .getBimsie1ServiceInterface()
              .getSerializerByContentType("application/ifc");
      bimServerClient.download(newRoid, ifcSerializer.getOid(), new File("movedf.ifc"));
    } catch (Throwable e) {
      e.printStackTrace();
      if (e instanceof AssertionError) {
        throw (AssertionError) e;
      }
      fail(e.getMessage());
    }
  }
コード例 #14
0
  private IfcModel realCheckout(
      Project project, Revision revision, DatabaseSession databaseSession, User user)
      throws BimserverLockConflictException, BimserverDatabaseException, UserException {
    SerializerPluginConfiguration serializerPluginConfiguration =
        getDatabaseSession()
            .get(
                StorePackage.eINSTANCE.getSerializerPluginConfiguration(),
                serializerOid,
                Query.getDefault());
    final long totalSize = revision.getSize();
    final AtomicLong total = new AtomicLong();

    IfcModelSet ifcModelSet = new IfcModelSet();
    for (ConcreteRevision subRevision : revision.getConcreteRevisions()) {
      IfcModel subModel = new IfcModel();
      int highestStopId = findHighestStopRid(project, subRevision);
      Query query =
          new Query(
              subRevision.getProject().getId(), subRevision.getId(), null, Deep.YES, highestStopId);
      subModel.addChangeListener(
          new IfcModelChangeListener() {
            @Override
            public void objectAdded() {
              total.incrementAndGet();
              if (totalSize == 0) {
                setProgress("Preparing checkout...", 0);
              } else {
                setProgress(
                    "Preparing checkout...", (int) Math.round(100.0 * total.get() / totalSize));
              }
            }
          });
      getDatabaseSession().getMap(subModel, query);
      try {
        checkGeometry(
            serializerPluginConfiguration,
            getBimServer().getPluginManager(),
            subModel,
            project,
            subRevision,
            revision);
      } catch (GeometryGeneratingException e) {
        throw new UserException(e);
      }
      subModel.getModelMetaData().setDate(subRevision.getDate());
      ifcModelSet.add(subModel);
    }

    IfcModelInterface ifcModel = new IfcModel();
    if (ifcModelSet.size() > 1) {
      try {
        ifcModel =
            getBimServer()
                .getMergerFactory()
                .createMerger(getDatabaseSession(), getAuthorization().getUoid())
                .merge(revision.getProject(), ifcModelSet, new ModelHelper(ifcModel));
      } catch (MergeException e) {
        throw new UserException(e);
      }
    } else {
      ifcModel = ifcModelSet.iterator().next();
    }

    ifcModel.getModelMetaData().setName(project.getName() + "." + revision.getId());
    ifcModel.getModelMetaData().setRevisionId(project.getRevisions().indexOf(revision) + 1);
    ifcModel.getModelMetaData().setAuthorizedUser(user.getName());
    ifcModel.getModelMetaData().setDate(new Date());
    return (IfcModel) ifcModel;
  }
コード例 #15
0
ファイル: CommandLine.java プロジェクト: RckMrkr/MDD2013
  @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);
      }
    }
  }
コード例 #16
0
  private static void exportBAMieClassificationReferences(
      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 extSystem;
    String extObject;
    String extIdentifier;
    String description;
    String reference;
    IfcOwnerHistory oh;
    DocumentType tempDocument;
    for (IfcDistributionElement element : model.getAllWithSubTypes(IfcDistributionElement.class)) {
      try {
        for (IfcRelAssociates relAssociates : element.getHasAssociations()) {
          if (relAssociates instanceof IfcRelAssociatesClassification) {
            category = COBieIfcUtility.getObjectClassificationCategoryString(element);
            if (ClassificationHandler.isBAMieRelAssociatesClassification(
                (IfcRelAssociatesClassification) relAssociates)) {
              name = COBieUtility.getCOBieString(element.getName());
              oh = element.getOwnerHistory();
              createdBy = COBieIfcUtility.getEmailFromOwnerHistory(oh);
              createdOn = IfcToContact.getCreatedOn(oh.getCreationDate());
              category = IfcToDocument.BAMIE_CATEGORY;
              approvalBy = IfcToDocument.ApprovalBy;
              stage = IfcToDocument.Stage;
              sheetName = COBieUtility.CobieSheetName.Component.name();
              rowName = IfcToDocument.bamieRowNameFromDistributionElement(element);
              extSystem = COBieIfcUtility.getApplicationName(oh);
              extObject = IfcToComponent.extObjectFromProduct(element);
              extIdentifier = COBieIfcUtility.extIdFromRoot(element);
              description = COBieUtility.getCOBieString(element.getName());
              reference = IfcToDocument.Reference;

              IfcClassificationReference classificationReference =
                  COBieIfcUtility.getObjectClassificationReference(element);
              directory = COBieUtility.getCOBieString(classificationReference.getLocation());

              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(COBieUtility.COBieNA);
              tempDocument.setExtSystem(extSystem);
              tempDocument.setExtObject(extObject);
              tempDocument.setExtIdentifier(extIdentifier);
              tempDocument.setDescription(description);
              tempDocument.setReference(reference);
              loggerHandler.rowWritten();
            }
          }
        }
      } catch (Exception ex) {

      }
    }
  }
コード例 #17
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);
        }
      }
    }
  }
コード例 #18
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);
        }
      }
    }
  }
コード例 #19
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();
    }
  }
コード例 #20
0
  @Test
  public void test() {
    try {
      // New client
      BimServerClientInterface bimServerClient =
          getFactory()
              .create(new UsernamePasswordAuthenticationInfo("*****@*****.**", "admin"));

      // Create a project
      SProject project =
          bimServerClient
              .getBimsie1ServiceInterface()
              .addProject("test" + Math.random(), "ifc2x3tc1");

      // Look for a deserializer
      SDeserializerPluginConfiguration deserializer =
          bimServerClient
              .getBimsie1ServiceInterface()
              .getSuggestedDeserializerForExtension("ifc", project.getOid());

      bimServerClient.checkin(
          project.getOid(),
          "test",
          deserializer.getOid(),
          false,
          true,
          new File("../TestData/data/AC11-Institute-Var-2-IFC.ifc"));

      // Refresh project
      project = bimServerClient.getBimsie1ServiceInterface().getProjectByPoid(project.getOid());

      // Load model without lazy loading (complete model at once)
      IfcModelInterface model =
          bimServerClient.getModel(project, project.getLastRevisionId(), true, false);

      String propertyName = "BooleanProperty";

      int nrWindowsFirst = 0;
      // Iterate over all projects, there should be 1
      for (IfcWindow window : model.getAllWithSubTypes(IfcWindow.class)) {
        nrWindowsFirst++;
        createProperty(window, model, propertyName, "Description of property", true);
      }

      model.commit("Added boolean properties to " + nrWindowsFirst + " windows");

      project = bimServerClient.getBimsie1ServiceInterface().getProjectByPoid(project.getOid());
      model = bimServerClient.getModel(project, project.getLastRevisionId(), true, false);
      int foundOke = 0;
      int nrWindowsSecond = 0;
      Set<Long> counted = new HashSet<Long>();
      for (IfcWindow window : model.getAllWithSubTypes(IfcWindow.class)) {
        nrWindowsSecond++;
        for (IfcRelDefines ifcRelDefines : window.getIsDefinedBy()) {
          if (ifcRelDefines instanceof IfcRelDefinesByProperties) {
            IfcRelDefinesByProperties ifcRelDefinesByProperties =
                (IfcRelDefinesByProperties) ifcRelDefines;
            IfcPropertySetDefinition relatingPropertyDefinition =
                ifcRelDefinesByProperties.getRelatingPropertyDefinition();
            if (relatingPropertyDefinition instanceof IfcPropertySet) {
              IfcPropertySet ifcPropertySet = (IfcPropertySet) relatingPropertyDefinition;
              for (IfcProperty ifcProperty : ifcPropertySet.getHasProperties()) {
                if (ifcProperty instanceof IfcPropertySingleValue) {
                  IfcPropertySingleValue ifcPropertySingleValue =
                      (IfcPropertySingleValue) ifcProperty;
                  if (ifcPropertySingleValue.getName().equals(propertyName)) {
                    IfcValue nominalValue = ifcPropertySingleValue.getNominalValue();
                    if (nominalValue instanceof IfcBoolean) {
                      if (((IfcBoolean) nominalValue).getWrappedValue() == Tristate.TRUE) {
                        if (!counted.contains(ifcPropertySingleValue.getOid())) {
                          foundOke++;
                          counted.add(ifcPropertySingleValue.getOid());
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
      LOGGER.info("Windows first: " + nrWindowsFirst);
      LOGGER.info("Windows second: " + nrWindowsSecond);
      LOGGER.info("Found Oke: " + foundOke);
      if (foundOke != nrWindowsFirst) {
        fail(foundOke + " / " + nrWindowsFirst);
      }
    } catch (Throwable e) {
      e.printStackTrace();
      fail(e.getMessage());
    }
  }
コード例 #21
0
  @Override
  public IfcModelInterface execute()
      throws UserException, BimserverLockConflictException, BimserverDatabaseException {
    User user = getUserByUoid(getAuthorization().getUoid());
    Set<String> foundNames = new HashSet<String>();
    IfcModelSet ifcModelSet = new IfcModelSet();
    Project project = null;
    long incrSize = 0L;

    SerializerPluginConfiguration serializerPluginConfiguration =
        getDatabaseSession()
            .get(
                StorePackage.eINSTANCE.getSerializerPluginConfiguration(),
                serializerOid,
                Query.getDefault());

    for (Long roid : roids) {
      Revision virtualRevision = getRevisionByRoid(roid);
      project = virtualRevision.getProject();
      if (!getAuthorization().hasRightsOnProjectOrSuperProjectsOrSubProjects(user, project)) {
        throw new UserException(
            "User has insufficient rights to download revisions from this project");
      }
      Map<ConcreteRevision, Set<Long>> map = new HashMap<ConcreteRevision, Set<Long>>();
      for (String name : names) {
        if (!foundNames.contains(name)) {
          for (ConcreteRevision concreteRevision : virtualRevision.getConcreteRevisions()) {
            for (ObjectIdentifier objectIdentifier :
                getDatabaseSession()
                    .getOidsOfName(
                        name, concreteRevision.getProject().getId(), concreteRevision.getId())) {
              foundNames.add(name);
              if (!map.containsKey(concreteRevision)) {
                map.put(concreteRevision, new HashSet<Long>());
                incrSize += concreteRevision.getSize();
              }
              map.get(concreteRevision).add(objectIdentifier.getOid());
            }
          }
        }
      }
      final long totalSize = incrSize;
      final AtomicLong total = new AtomicLong();

      for (ConcreteRevision concreteRevision : map.keySet()) {
        IfcModel subModel = new IfcModel();
        int highestStopId = findHighestStopRid(project, concreteRevision);
        Query query =
            new Query(
                concreteRevision.getProject().getId(),
                concreteRevision.getId(),
                objectIDM,
                deep,
                highestStopId);
        subModel.addChangeListener(
            new IfcModelChangeListener() {
              @Override
              public void objectAdded() {
                total.incrementAndGet();
                progress = (int) Math.round(100.0 * total.get() / totalSize);
              }
            });
        Set<Long> oids = map.get(concreteRevision);
        getDatabaseSession().getMapWithOids(subModel, oids, query);
        subModel.getModelMetaData().setDate(concreteRevision.getDate());

        try {
          checkGeometry(
              serializerPluginConfiguration,
              bimServer.getPluginManager(),
              subModel,
              project,
              concreteRevision,
              virtualRevision);
        } catch (GeometryGeneratingException e) {
          throw new UserException(e);
        }

        ifcModelSet.add(subModel);
      }
    }
    IfcModelInterface ifcModel = new IfcModel();
    try {
      ifcModel =
          bimServer
              .getMergerFactory()
              .createMerger(getDatabaseSession(), getAuthorization().getUoid())
              .merge(project, ifcModelSet, new ModelHelper(ifcModel));
      ifcModel.getModelMetaData().setName("query");
      for (String name : names) {
        if (!foundNames.contains(name)) {
          throw new UserException("Name " + name + " not found");
        }
      }
      ifcModel.getModelMetaData().setRevisionId(1);
      ifcModel
          .getModelMetaData()
          .setAuthorizedUser(getUserByUoid(getAuthorization().getUoid()).getName());
      ifcModel.getModelMetaData().setDate(new Date());
      return ifcModel;
    } catch (MergeException e) {
      throw new UserException(e);
    }
  }