Search in sources :

Example 21 with BimServerClient

use of org.bimserver.client.BimServerClient in project BIMserver by opensourceBIM.

the class TestGetProperties 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/AC9R1-Haus-G-H-Ver2-2x3.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);
            for (IfcWall wall : model.getAllWithSubTypes(IfcWall.class)) {
                String layerName = IfcUtils.getStringProperty(wall, "Layername");
                Assert.assertNotNull(layerName);
                Assert.assertFalse(layerName.isEmpty());
            }
        }
    }
    Thread.sleep(1000);
}
Also used : Path(java.nio.file.Path) IfcWall(org.bimserver.models.ifc2x3tc1.IfcWall) 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) CheckinProgressHandler(org.bimserver.plugins.services.CheckinProgressHandler) Test(org.junit.Test)

Example 22 with BimServerClient

use of org.bimserver.client.BimServerClient in project BIMserver by opensourceBIM.

the class TestIfc4TwoDimensional3 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), "ifc4");
            SDeserializerPluginConfiguration deserializer = client.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
            Path path = Paths.get("../../TestFiles/TestData/data/ifc4add2tc1/slab-standard-case.ifc");
            SLongCheckinActionState actionState = client.checkinSync(project.getOid(), "test", deserializer.getOid(), path, (title, progress) -> System.out.println(title + ": " + progress));
            ClientIfcModel model = client.getModel(project, actionState.getRoid(), true, false);
            List<IfcIndexedPolyCurve> polyCurves = model.getAll(IfcIndexedPolyCurve.class);
            Assert.assertEquals(1, polyCurves.size());
            for (IfcIndexedPolyCurve ifcIndexedPolyCurve : polyCurves) {
                EList<IfcSegmentIndexSelect> segments = ifcIndexedPolyCurve.getSegments();
                Assert.assertEquals(4, segments.size());
                for (IfcSegmentIndexSelect ifcSegmentIndexSelect : segments) {
                    if (ifcSegmentIndexSelect instanceof IfcLineIndex) {
                        Assert.assertEquals(2, ((IfcLineIndex) ifcSegmentIndexSelect).getWrappedValue().size());
                    } else if (ifcSegmentIndexSelect instanceof IfcArcIndex) {
                        Assert.assertEquals(3, ((IfcArcIndex) ifcSegmentIndexSelect).getWrappedValue().size());
                    }
                }
            }
        }
        Thread.sleep(500);
    }
}
Also used : Path(java.nio.file.Path) IfcLineIndex(org.bimserver.models.ifc4.IfcLineIndex) 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) IfcIndexedPolyCurve(org.bimserver.models.ifc4.IfcIndexedPolyCurve) SProject(org.bimserver.interfaces.objects.SProject) IfcArcIndex(org.bimserver.models.ifc4.IfcArcIndex) BimServerClient(org.bimserver.client.BimServerClient) IfcSegmentIndexSelect(org.bimserver.models.ifc4.IfcSegmentIndexSelect) Test(org.junit.Test)

Example 23 with BimServerClient

use of org.bimserver.client.BimServerClient in project BIMserver by opensourceBIM.

the class TestCopy 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, (title, progress) -> System.out.println(title + ": " + progress));
            long roid = actionState.getRoid();
            client.getServiceInterface().clone(roid, "Clone-" + RandomStringUtils.randomAlphabetic(10), "Cloned", true);
        }
    }
    Thread.sleep(1000);
}
Also used : Path(java.nio.file.Path) 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) Test(org.junit.Test)

Example 24 with BimServerClient

use of org.bimserver.client.BimServerClient in project BIMserver by opensourceBIM.

the class TestDeserializerErrorCode2 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");
            Path path = Paths.get("../../TestFiles/TestData/data/ADT-FZK-Haus-2005-2006.ifc");
            SDeserializerPluginConfiguration deserializer = client.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
            SLongCheckinActionState checkinSync = client.checkinSync(project.getOid(), "test", deserializer.getOid(), path, new CheckinProgressHandler() {

                @Override
                public void progress(String title, int progress) {
                    System.out.println(title + ": " + progress);
                }
            });
            Assert.assertEquals(DeserializerErrorCode.IFC_SCHEMA_NOT_SUPPORTED_BY_DESERIALIZER, ErrorCode.fromCode(checkinSync.getDeserializeErrorCode()));
        }
    }
}
Also used : Path(java.nio.file.Path) 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) CheckinProgressHandler(org.bimserver.plugins.services.CheckinProgressHandler) BimServerClient(org.bimserver.client.BimServerClient) Test(org.junit.Test)

Example 25 with BimServerClient

use of org.bimserver.client.BimServerClient in project BIMserver by opensourceBIM.

the class TestIfc4TwoDimensional2 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), "ifc4");
            SDeserializerPluginConfiguration deserializer = client.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
            Path path = Paths.get("../../TestFiles/TestData/data/ifc4add2tc1/basin-advanced-brep.ifc");
            SLongCheckinActionState actionState = client.checkinSync(project.getOid(), "test", deserializer.getOid(), path, (title, progress) -> System.out.println(title + ": " + progress));
            ClientIfcModel model = client.getModel(project, actionState.getRoid(), true, false);
            List<IfcBSplineCurveWithKnots> bSplineCurves = model.getAll(IfcBSplineCurveWithKnots.class);
            Assert.assertEquals(4, bSplineCurves.size());
            for (IfcBSplineCurveWithKnots bSplineCurve : bSplineCurves) {
                Assert.assertEquals(7, bSplineCurve.getControlPointsList().size());
                for (org.bimserver.models.ifc4.IfcCartesianPoint point : bSplineCurve.getControlPointsList()) {
                    Assert.assertNotNull(point);
                    Assert.assertTrue(point.getCoordinates().size() == 2 || point.getCoordinates().size() == 3);
                }
            }
            List<IfcBSplineSurfaceWithKnots> bSplineSurfaces = model.getAll(IfcBSplineSurfaceWithKnots.class);
            Assert.assertEquals(2, bSplineSurfaces.size());
            for (IfcBSplineSurfaceWithKnots bSplineSurface : bSplineSurfaces) {
                Assert.assertEquals(4, bSplineSurface.getControlPointsList().size());
                for (ListOfIfcCartesianPoint pointList : bSplineSurface.getControlPointsList()) {
                    // This assertion fails, error seems to be in client.
                    // 1st pointlist is of size 1, 2nd of size 2 and so on
                    // with duplication of the first point's coordinates
                    Assert.assertEquals(7, pointList.getList().size());
                    for (IfcCartesianPoint point : pointList.getList()) {
                        Assert.assertNotNull(point);
                        Assert.assertEquals(3, point.getCoordinates().size());
                    }
                }
            }
        }
        Thread.sleep(500);
    }
}
Also used : Path(java.nio.file.Path) ClientIfcModel(org.bimserver.client.ClientIfcModel) SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) IfcBSplineSurfaceWithKnots(org.bimserver.models.ifc4.IfcBSplineSurfaceWithKnots) UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) JsonBimServerClientFactory(org.bimserver.client.json.JsonBimServerClientFactory) SLongCheckinActionState(org.bimserver.interfaces.objects.SLongCheckinActionState) IfcCartesianPoint(org.bimserver.models.ifc4.IfcCartesianPoint) SProject(org.bimserver.interfaces.objects.SProject) BimServerClient(org.bimserver.client.BimServerClient) ListOfIfcCartesianPoint(org.bimserver.models.ifc4.ListOfIfcCartesianPoint) IfcCartesianPoint(org.bimserver.models.ifc4.IfcCartesianPoint) ListOfIfcCartesianPoint(org.bimserver.models.ifc4.ListOfIfcCartesianPoint) IfcBSplineCurveWithKnots(org.bimserver.models.ifc4.IfcBSplineCurveWithKnots) Test(org.junit.Test)

Aggregations

BimServerClient (org.bimserver.client.BimServerClient)27 JsonBimServerClientFactory (org.bimserver.client.json.JsonBimServerClientFactory)23 UsernamePasswordAuthenticationInfo (org.bimserver.shared.UsernamePasswordAuthenticationInfo)23 SProject (org.bimserver.interfaces.objects.SProject)20 SDeserializerPluginConfiguration (org.bimserver.interfaces.objects.SDeserializerPluginConfiguration)15 Test (org.junit.Test)15 Path (java.nio.file.Path)14 ClientIfcModel (org.bimserver.client.ClientIfcModel)11 SLongCheckinActionState (org.bimserver.interfaces.objects.SLongCheckinActionState)9 BimServerClientException (org.bimserver.shared.exceptions.BimServerClientException)6 CheckinProgressHandler (org.bimserver.plugins.services.CheckinProgressHandler)5 GeometryInfo (org.bimserver.models.geometry.GeometryInfo)3 IfcWall (org.bimserver.models.ifc2x3tc1.IfcWall)3 PublicInterfaceNotFoundException (org.bimserver.shared.exceptions.PublicInterfaceNotFoundException)3 DateFormat (java.text.DateFormat)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Date (java.util.Date)2 Query (org.bimserver.database.queries.om.Query)2 QueryPart (org.bimserver.database.queries.om.QueryPart)2 PackageMetaData (org.bimserver.emf.PackageMetaData)2