Search in sources :

Example 1 with IfcWall

use of org.bimserver.models.ifc2x3tc1.IfcWall in project BIMserver by opensourceBIM.

the class CommandLine method run.

@Override
public void run() {
    reader = new BufferedReader(new InputStreamReader(System.in));
    running = true;
    try {
        while (running) {
            try {
                String line = reader.readLine();
                if (line == null) {
                    Thread.sleep(50);
                    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);
                            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("");
                    Thread.sleep(10000);
                } 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);
            }
        }
    } catch (InterruptedException e) {
    }
}
Also used : InconsistentModelsException(org.bimserver.database.migrations.InconsistentModelsException) Set(java.util.Set) DatabaseSession(org.bimserver.database.DatabaseSession) IfcModelInterface(org.bimserver.emf.IfcModelInterface) KeyValueStore(org.bimserver.database.KeyValueStore) SystemAuthorization(org.bimserver.webservices.authorization.SystemAuthorization) List(java.util.List) UserException(org.bimserver.shared.exceptions.UserException) DownloadDatabaseAction(org.bimserver.database.actions.DownloadDatabaseAction) IfcWall(org.bimserver.models.ifc2x3tc1.IfcWall) IfcProject(org.bimserver.models.ifc2x3tc1.IfcProject) IfcWindow(org.bimserver.models.ifc2x3tc1.IfcWindow) InputStreamReader(java.io.InputStreamReader) IOException(java.io.IOException) IOException(java.io.IOException) BimserverLockConflictException(org.bimserver.database.BimserverLockConflictException) MigrationException(org.bimserver.database.migrations.MigrationException) UserException(org.bimserver.shared.exceptions.UserException) InconsistentModelsException(org.bimserver.database.migrations.InconsistentModelsException) IfcSlab(org.bimserver.models.ifc2x3tc1.IfcSlab) MigrationException(org.bimserver.database.migrations.MigrationException) BufferedReader(java.io.BufferedReader) BimserverLockConflictException(org.bimserver.database.BimserverLockConflictException)

Example 2 with IfcWall

use of org.bimserver.models.ifc2x3tc1.IfcWall in project BIMserver by opensourceBIM.

the class TestDeleteObjects method test.

@Test
public void test() {
    try {
        // Create a new BimServerClient with authentication
        BimServerClientInterface bimServerClient = getFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
        // Create a new project
        SProject newProject = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
        IfcModelInterface model = bimServerClient.newModel(newProject, true);
        for (int i = 0; i < 10; i++) {
            IfcWall wall = model.create(Ifc2x3tc1Package.eINSTANCE.getIfcWall());
            wall.setName("Wall " + i);
            wall.setGlobalId("Wall " + i);
        }
        long roid = model.commit("Initial model");
        model = bimServerClient.getModel(newProject, roid, true, true);
        List<IfcWall> walls = model.getAllWithSubTypes(Ifc2x3tc1Package.eINSTANCE.getIfcWall());
        assertTrue(walls.size() == 10);
        IfcWall wall6 = (IfcWall) model.getByGuid("Wall 6");
        assertTrue(wall6 != null);
        wall6.remove();
        roid = model.commit("Removed wall 6");
        model = bimServerClient.getModel(newProject, roid, true, false);
        walls = model.getAllWithSubTypes(Ifc2x3tc1Package.eINSTANCE.getIfcWall());
        assertTrue(walls.size() == 9);
    } catch (Throwable e) {
        if (e instanceof AssertionError) {
            throw (AssertionError) e;
        }
        fail(e.getMessage());
    }
}
Also used : IfcWall(org.bimserver.models.ifc2x3tc1.IfcWall) UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) IfcModelInterface(org.bimserver.emf.IfcModelInterface) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) SProject(org.bimserver.interfaces.objects.SProject) Test(org.junit.Test)

Example 3 with IfcWall

use of org.bimserver.models.ifc2x3tc1.IfcWall in project BIMserver by opensourceBIM.

the class TestChangeGeometryError method test.

@Test
public void test() {
    try {
        // Create a new BimServerClient with authentication
        BimServerClientInterface bimServerClient = getFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
        // Create a new project
        SProject newProject = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
        // Look for a deserializer
        SDeserializerPluginConfiguration deserializer = bimServerClient.getServiceInterface().getSuggestedDeserializerForExtension("ifc", newProject.getOid());
        bimServerClient.checkin(newProject.getOid(), "test", deserializer.getOid(), false, Flow.SYNC, new URL("https://github.com/opensourceBIM/TestFiles/raw/master/TestData/data/AC11-Institute-Var-2-IFC.ifc"));
        newProject = bimServerClient.getServiceInterface().getProjectByPoid(newProject.getOid());
        IfcModelInterface model = bimServerClient.getModel(newProject, newProject.getLastRevisionId(), false, true, true);
        List<IfcWall> walls = model.getAllWithSubTypes(Ifc2x3tc1Package.eINSTANCE.getIfcWall());
        IfcWall firstWall = walls.get(0);
        firstWall.getGeometry().getData().setVertices(new byte[10]);
        model.commit("Tried to change geometry, which should not be possible");
        fail("This have thrown an error");
    } catch (Throwable e) {
        if (e instanceof AssertionError) {
            throw (AssertionError) e;
        }
        e.printStackTrace();
        assertEquals("Only objects from the following schemas are allowed to be changed: Ifc2x3tc1 and IFC4, this object (GeometryData) is from the \"geometry\" package", e.getMessage());
    }
}
Also used : IfcWall(org.bimserver.models.ifc2x3tc1.IfcWall) SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) IfcModelInterface(org.bimserver.emf.IfcModelInterface) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) SProject(org.bimserver.interfaces.objects.SProject) URL(java.net.URL) Test(org.junit.Test)

Example 4 with IfcWall

use of org.bimserver.models.ifc2x3tc1.IfcWall in project BIMserver by opensourceBIM.

the class TestChangeDescription method start.

private void start() {
    BimServerClientInterface client = LocalDevSetup.setupJson("http://localhost:8080");
    try {
        SProject project = client.getServiceInterface().getProjectsByName("dfgfgdf").get(0);
        IfcModelInterface model = client.getModel(project, project.getLastRevisionId(), false, true);
        for (IfcWall wall : model.getAllWithSubTypes(IfcWall.class)) {
            wall.setDescription(wall.getDescription() + " Changed");
        }
        model.commit("test");
    } catch (UserException e) {
        e.printStackTrace();
    } catch (ServerException e) {
        e.printStackTrace();
    } catch (PublicInterfaceNotFoundException e) {
        e.printStackTrace();
    } catch (BimServerClientException e) {
        e.printStackTrace();
    }
}
Also used : IfcWall(org.bimserver.models.ifc2x3tc1.IfcWall) ServerException(org.bimserver.shared.exceptions.ServerException) IfcModelInterface(org.bimserver.emf.IfcModelInterface) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) UserException(org.bimserver.shared.exceptions.UserException) SProject(org.bimserver.interfaces.objects.SProject) BimServerClientException(org.bimserver.shared.exceptions.BimServerClientException)

Example 5 with IfcWall

use of org.bimserver.models.ifc2x3tc1.IfcWall in project BIMserver by opensourceBIM.

the class TestNewQueryViaClient method start.

private void start() {
    try (JsonBimServerClientFactory factory = new JsonBimServerClientFactory("http://localhost:8080")) {
        BimServerClient client = factory.create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
        String projectName = "Test " + new Random().nextInt();
        SProject project = client.getServiceInterface().addProject(projectName, "ifc2x3tc1");
        SDeserializerPluginConfiguration deserializer = client.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
        client.checkin(project.getOid(), "Test Model", deserializer.getOid(), false, Flow.SYNC, Paths.get("C:/Git/TestFiles/TestData/data/AC11-FZK-Haus-IFC.ifc"));
        project = client.getServiceInterface().getProjectByPoid(project.getOid());
        System.out.println(project.getName());
        ClientIfcModel model = client.getModel(project, project.getLastRevisionId(), false, false);
        Query query = new Query(model.getPackageMetaData());
        QueryPart queryPart = query.createQueryPart();
        queryPart.addType(Ifc2x3tc1Package.eINSTANCE.getIfcWall(), true);
        for (IfcWall ifcWall : model.getAllWithSubTypes(IfcWall.class)) {
            System.out.println(ifcWall.getGlobalId());
        }
    } catch (ServiceException e) {
        e.printStackTrace();
    } catch (ChannelConnectionException e) {
        e.printStackTrace();
    } catch (PublicInterfaceNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (BimServerClientException e) {
        e.printStackTrace();
    } catch (Exception e1) {
        e1.printStackTrace();
    }
}
Also used : IfcWall(org.bimserver.models.ifc2x3tc1.IfcWall) ClientIfcModel(org.bimserver.client.ClientIfcModel) SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) Query(org.bimserver.database.queries.om.Query) ChannelConnectionException(org.bimserver.shared.ChannelConnectionException) UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) QueryPart(org.bimserver.database.queries.om.QueryPart) JsonBimServerClientFactory(org.bimserver.client.json.JsonBimServerClientFactory) IOException(java.io.IOException) SProject(org.bimserver.interfaces.objects.SProject) BimServerClientException(org.bimserver.shared.exceptions.BimServerClientException) BimServerClient(org.bimserver.client.BimServerClient) ChannelConnectionException(org.bimserver.shared.ChannelConnectionException) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException) BimServerClientException(org.bimserver.shared.exceptions.BimServerClientException) ServiceException(org.bimserver.shared.exceptions.ServiceException) IOException(java.io.IOException) Random(java.util.Random) ServiceException(org.bimserver.shared.exceptions.ServiceException) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException)

Aggregations

IfcWall (org.bimserver.models.ifc2x3tc1.IfcWall)5 IfcModelInterface (org.bimserver.emf.IfcModelInterface)4 SProject (org.bimserver.interfaces.objects.SProject)4 BimServerClientInterface (org.bimserver.plugins.services.BimServerClientInterface)3 UsernamePasswordAuthenticationInfo (org.bimserver.shared.UsernamePasswordAuthenticationInfo)3 IOException (java.io.IOException)2 SDeserializerPluginConfiguration (org.bimserver.interfaces.objects.SDeserializerPluginConfiguration)2 BimServerClientException (org.bimserver.shared.exceptions.BimServerClientException)2 PublicInterfaceNotFoundException (org.bimserver.shared.exceptions.PublicInterfaceNotFoundException)2 UserException (org.bimserver.shared.exceptions.UserException)2 Test (org.junit.Test)2 BufferedReader (java.io.BufferedReader)1 InputStreamReader (java.io.InputStreamReader)1 URL (java.net.URL)1 List (java.util.List)1 Random (java.util.Random)1 Set (java.util.Set)1 BimServerClient (org.bimserver.client.BimServerClient)1 ClientIfcModel (org.bimserver.client.ClientIfcModel)1 JsonBimServerClientFactory (org.bimserver.client.json.JsonBimServerClientFactory)1