Search in sources :

Example 1 with CheckinProgressHandler

use of org.bimserver.plugins.services.CheckinProgressHandler in project BIMserver by opensourceBIM.

the class TestGetGeometry2 method test.

@Test
public void test() throws Exception {
    try (JsonBimServerClientFactory factory = new JsonBimServerClientFactory("http://localhost:8080")) {
        try (BimServerClient client = factory.create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"))) {
            SProject project = client.getServiceInterface().addProject(RandomStringUtils.randomAlphanumeric(10), "ifc2x3tc1");
            SDeserializerPluginConfiguration deserializer = client.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
            Path path = Paths.get("../../TestFiles/TestData/data/export1.ifc");
            SLongCheckinActionState actionState = client.checkinSync(project.getOid(), "test", deserializer.getOid(), path, new CheckinProgressHandler() {

                @Override
                public void progress(String title, int progress) {
                    System.out.println(title + ": " + progress);
                }
            });
            ClientIfcModel model = client.getModel(project, actionState.getRoid(), false, false, true);
            for (IfcProduct product : model.getAllWithSubTypes(IfcProduct.class)) {
                GeometryInfo geometry = product.getGeometry();
                if (geometry != null) {
                    System.out.println(product.getGeometry().getData().getNrVertices());
                    System.out.println(product.getGeometry().getData().getVertices().getData().length);
                }
            }
        }
    }
    Thread.sleep(1000);
}
Also used : Path(java.nio.file.Path) ClientIfcModel(org.bimserver.client.ClientIfcModel) SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) JsonBimServerClientFactory(org.bimserver.client.json.JsonBimServerClientFactory) SLongCheckinActionState(org.bimserver.interfaces.objects.SLongCheckinActionState) SProject(org.bimserver.interfaces.objects.SProject) BimServerClient(org.bimserver.client.BimServerClient) GeometryInfo(org.bimserver.models.geometry.GeometryInfo) IfcProduct(org.bimserver.models.ifc2x3tc1.IfcProduct) CheckinProgressHandler(org.bimserver.plugins.services.CheckinProgressHandler) Test(org.junit.Test)

Example 2 with CheckinProgressHandler

use of org.bimserver.plugins.services.CheckinProgressHandler in project BIMserver by opensourceBIM.

the class TestGetUuid method test.

@Test
public void test() throws Exception {
    try (JsonBimServerClientFactory factory = new JsonBimServerClientFactory("http://localhost:8080")) {
        try (BimServerClient client = factory.create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"))) {
            SServerInfo serverInfo = client.getAdminInterface().getServerInfo();
            System.out.println(serverInfo.getServerState());
            System.out.println(serverInfo.getUuid());
            SProject project = client.getServiceInterface().addProject(RandomStringUtils.randomAlphanumeric(10), "ifc2x3tc1");
            SDeserializerPluginConfiguration deserializer = client.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
            Path path = Paths.get("../../TestFiles/TestData/data/AC11-Institute-Var-2-IFC.ifc");
            client.checkinSync(project.getOid(), "test", deserializer.getOid(), path, new CheckinProgressHandler() {

                @Override
                public void progress(String title, int progress) {
                    System.out.println(title + ": " + progress);
                }
            });
            project = client.getServiceInterface().getProjectByPoid(project.getOid());
            ClientIfcModel model = client.getModel(project, project.getLastRevisionId(), true, true);
            for (IfcBuildingStorey ifcBuildingStorey : model.getAll(IfcBuildingStorey.class)) {
                System.out.println(ifcBuildingStorey.getUuid() + ":" + ifcBuildingStorey.getRid());
            }
            System.out.println("Length unit: " + IfcUtils.getLengthUnitPrefix(model));
            IfcProject ifcProject = model.getAll(IfcProject.class).iterator().next();
            ifcProject.setName(ifcProject.getName() + " updated");
            long newRoid = model.commit("commit message");
            model = client.getModel(project, newRoid, true, true);
            ifcProject = model.getAll(IfcProject.class).iterator().next();
            System.out.println(ifcProject.getName());
        }
    }
    Thread.sleep(1000);
}
Also used : Path(java.nio.file.Path) IfcProject(org.bimserver.models.ifc2x3tc1.IfcProject) ClientIfcModel(org.bimserver.client.ClientIfcModel) SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) JsonBimServerClientFactory(org.bimserver.client.json.JsonBimServerClientFactory) SProject(org.bimserver.interfaces.objects.SProject) BimServerClient(org.bimserver.client.BimServerClient) SServerInfo(org.bimserver.interfaces.objects.SServerInfo) CheckinProgressHandler(org.bimserver.plugins.services.CheckinProgressHandler) IfcBuildingStorey(org.bimserver.models.ifc2x3tc1.IfcBuildingStorey) Test(org.junit.Test)

Example 3 with CheckinProgressHandler

use of org.bimserver.plugins.services.CheckinProgressHandler in project BIMserver by opensourceBIM.

the class TestServerRestart method checkin.

private void checkin(BimServerClient client) throws ServerException, UserException {
    SProject project = client.getServiceInterface().addProject(RandomStringUtils.randomAlphanumeric(10), "ifc2x3tc1");
    SDeserializerPluginConfiguration deserializer = client.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
    Path path = Paths.get("../../TestFiles/TestData/data/export1.ifc");
    client.checkinSync(project.getOid(), "test", deserializer.getOid(), path, new CheckinProgressHandler() {

        @Override
        public void progress(String title, int progress) {
            System.out.println(title + ": " + progress);
        }
    });
}
Also used : Path(java.nio.file.Path) SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) SProject(org.bimserver.interfaces.objects.SProject) CheckinProgressHandler(org.bimserver.plugins.services.CheckinProgressHandler)

Example 4 with CheckinProgressHandler

use of org.bimserver.plugins.services.CheckinProgressHandler in project BIMserver by opensourceBIM.

the class BimServerClient method checkin.

public SLongCheckinActionState checkin(long poid, String comment, long deserializerOid, long fileSize, String filename, InputStream inputStream, CheckinProgressHandler progressHandler) throws ServerException, UserException, PublicInterfaceNotFoundException {
    long topicId = getServiceInterface().initiateCheckin(poid, deserializerOid);
    ProgressHandler progressHandlerWrapper = new ProgressHandler() {

        @Override
        public void progress(SLongActionState state) {
            progressHandler.progress(state.getTitle(), state.getProgress());
        }
    };
    getNotificationsManager().registerProgressHandler(topicId, progressHandlerWrapper);
    return channel.checkinSync(baseAddress, token, poid, comment, deserializerOid, false, fileSize, filename, inputStream, topicId);
}
Also used : ProgressHandler(org.bimserver.plugins.services.ProgressHandler) CheckinProgressHandler(org.bimserver.plugins.services.CheckinProgressHandler) SLongActionState(org.bimserver.interfaces.objects.SLongActionState)

Example 5 with CheckinProgressHandler

use of org.bimserver.plugins.services.CheckinProgressHandler in project BIMserver by opensourceBIM.

the class BimServerClient method checkin.

public SLongCheckinActionState checkin(long poid, String comment, long deserializerOid, URL url, CheckinProgressHandler progressHandler) throws ServerException, UserException, PublicInterfaceNotFoundException {
    long topicId = getServiceInterface().initiateCheckin(poid, deserializerOid);
    ProgressHandler progressHandlerWrapper = new ProgressHandler() {

        @Override
        public void progress(SLongActionState state) {
            progressHandler.progress(state.getTitle(), state.getProgress());
        }
    };
    getNotificationsManager().registerProgressHandler(topicId, progressHandlerWrapper);
    try {
        InputStream openStream = url.openStream();
        try {
            channel.checkinAsync(baseAddress, token, poid, comment, deserializerOid, false, -1, url.toString(), openStream, topicId);
        } finally {
            openStream.close();
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    getNotificationsManager().unregisterProgressHandler(topicId, progressHandlerWrapper);
    return (SLongCheckinActionState) getRegistry().getProgress(topicId);
}
Also used : ProgressHandler(org.bimserver.plugins.services.ProgressHandler) CheckinProgressHandler(org.bimserver.plugins.services.CheckinProgressHandler) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) SLongCheckinActionState(org.bimserver.interfaces.objects.SLongCheckinActionState) SLongActionState(org.bimserver.interfaces.objects.SLongActionState) IOException(java.io.IOException)

Aggregations

CheckinProgressHandler (org.bimserver.plugins.services.CheckinProgressHandler)10 SDeserializerPluginConfiguration (org.bimserver.interfaces.objects.SDeserializerPluginConfiguration)7 SProject (org.bimserver.interfaces.objects.SProject)7 Path (java.nio.file.Path)6 SLongCheckinActionState (org.bimserver.interfaces.objects.SLongCheckinActionState)6 UsernamePasswordAuthenticationInfo (org.bimserver.shared.UsernamePasswordAuthenticationInfo)6 Test (org.junit.Test)6 BimServerClient (org.bimserver.client.BimServerClient)5 JsonBimServerClientFactory (org.bimserver.client.json.JsonBimServerClientFactory)5 SLongActionState (org.bimserver.interfaces.objects.SLongActionState)4 InputStream (java.io.InputStream)3 ClientIfcModel (org.bimserver.client.ClientIfcModel)3 ProgressHandler (org.bimserver.plugins.services.ProgressHandler)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 IOException (java.io.IOException)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 URL (java.net.URL)1 SSerializerPluginConfiguration (org.bimserver.interfaces.objects.SSerializerPluginConfiguration)1 SServerInfo (org.bimserver.interfaces.objects.SServerInfo)1 GeometryInfo (org.bimserver.models.geometry.GeometryInfo)1