Search in sources :

Example 46 with BimServerClientInterface

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

the class TestSetReferenceWithOpposite method test.

@Test
public void test() {
    try {
        // Create a new BimServerClient with authentication
        BimServerClientInterface bimServerClient = getFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
        LowLevelInterface lowLevelInterface = bimServerClient.getLowLevelInterface();
        // Create a new project
        SProject newProject = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
        // Start a transaction
        Long tid = lowLevelInterface.startTransaction(newProject.getOid());
        Long ifcRelContainedInSpatialStructureOid = lowLevelInterface.createObject(tid, "IfcRelContainedInSpatialStructure", true);
        Long ifcBuildingOid = lowLevelInterface.createObject(tid, "IfcBuilding", true);
        lowLevelInterface.setReference(tid, ifcRelContainedInSpatialStructureOid, "RelatingStructure", ifcBuildingOid);
        lowLevelInterface.commitTransaction(tid, "Initial");
        tid = lowLevelInterface.startTransaction(newProject.getOid());
        List<Long> references = lowLevelInterface.getReferences(tid, ifcBuildingOid, "ContainsElements");
        if (references.size() != 1) {
            fail("Should be 1");
        }
        if (!references.get(0).equals(ifcRelContainedInSpatialStructureOid)) {
            fail("Wrong " + references.get(0) + " / " + ifcRelContainedInSpatialStructureOid);
        }
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) SProject(org.bimserver.interfaces.objects.SProject) LowLevelInterface(org.bimserver.shared.interfaces.LowLevelInterface) Test(org.junit.Test)

Example 47 with BimServerClientInterface

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

the class TestSetString method test.

@Test
public void test() {
    try {
        BimServerClientInterface bimServerClient = getFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
        bimServerClient.getSettingsInterface().setCacheOutputFiles(false);
        LowLevelInterface lowLevelInterface = bimServerClient.getLowLevelInterface();
        SProject newProject = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
        SDeserializerPluginConfiguration suggestedDeserializerForExtension = bimServerClient.getServiceInterface().getSuggestedDeserializerForExtension("ifc", newProject.getOid());
        bimServerClient.checkin(newProject.getOid(), "initial", suggestedDeserializerForExtension.getOid(), false, Flow.SYNC, new URL("https://github.com/opensourceBIM/TestFiles/raw/master/TestData/data/WallOnly.ifc"));
        newProject = bimServerClient.getServiceInterface().getProjectByPoid(newProject.getOid());
        SSerializerPluginConfiguration serializer = bimServerClient.getServiceInterface().getSerializerByName("Ifc2x3tc1 (Streaming)");
        bimServerClient.download(newProject.getLastRevisionId(), serializer.getOid(), Paths.get("test1.ifc"));
        IfcModelInterface model = bimServerClient.getModel(newProject, newProject.getLastRevisionId(), true, false);
        long tid = lowLevelInterface.startTransaction(newProject.getOid());
        IfcRoot wall = (IfcRoot) model.getByGuid("3Ep4r0uuX5ywPYOUG2H2A4");
        bimServerClient.getLowLevelInterface().setStringAttribute(tid, wall.getOid(), "Name", "Test 12345");
        long roid = lowLevelInterface.commitTransaction(tid, "v2");
        bimServerClient.download(roid, serializer.getOid(), Paths.get("test3.ifc"));
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) IfcModelInterface(org.bimserver.emf.IfcModelInterface) IfcRoot(org.bimserver.models.ifc2x3tc1.IfcRoot) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) SSerializerPluginConfiguration(org.bimserver.interfaces.objects.SSerializerPluginConfiguration) SProject(org.bimserver.interfaces.objects.SProject) LowLevelInterface(org.bimserver.shared.interfaces.LowLevelInterface) URL(java.net.URL) Test(org.junit.Test)

Example 48 with BimServerClientInterface

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

the class TestSetWrappedBoolean method test.

@Test
public void test() {
    try {
        BimServerClientInterface bimServerClient = getFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
        bimServerClient.getSettingsInterface().setCacheOutputFiles(false);
        LowLevelInterface lowLevelInterface = bimServerClient.getLowLevelInterface();
        SProject newProject = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
        SDeserializerPluginConfiguration suggestedDeserializerForExtension = bimServerClient.getServiceInterface().getSuggestedDeserializerForExtension("ifc", newProject.getOid());
        bimServerClient.checkin(newProject.getOid(), "initial", suggestedDeserializerForExtension.getOid(), false, Flow.SYNC, new URL("https://github.com/opensourceBIM/TestFiles/raw/master/TestData/data/revit_quantities.ifc"));
        newProject = bimServerClient.getServiceInterface().getProjectByPoid(newProject.getOid());
        SSerializerPluginConfiguration serializer = bimServerClient.getServiceInterface().getSerializerByName("Ifc2x3tc1 (Streaming)");
        bimServerClient.download(newProject.getLastRevisionId(), serializer.getOid(), Paths.get("test1.ifc"));
        IfcModelInterface model = bimServerClient.getModel(newProject, newProject.getLastRevisionId(), false, false);
        long tid = lowLevelInterface.startTransaction(newProject.getOid());
        IfcPropertySingleValue ifcPropertySingleValue = model.getAll(IfcPropertySingleValue.class).iterator().next();
        bimServerClient.getLowLevelInterface().setWrappedBooleanAttribute(tid, ifcPropertySingleValue.getOid(), "NominalValue", "IfcBoolean", true);
        long roid = lowLevelInterface.commitTransaction(tid, "v2");
        bimServerClient.download(newProject.getLastRevisionId(), serializer.getOid(), Paths.get("test2.ifc"));
        bimServerClient.download(roid, serializer.getOid(), Paths.get("test3.ifc"));
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : IfcPropertySingleValue(org.bimserver.models.ifc2x3tc1.IfcPropertySingleValue) SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) IfcModelInterface(org.bimserver.emf.IfcModelInterface) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) SSerializerPluginConfiguration(org.bimserver.interfaces.objects.SSerializerPluginConfiguration) SProject(org.bimserver.interfaces.objects.SProject) LowLevelInterface(org.bimserver.shared.interfaces.LowLevelInterface) URL(java.net.URL) Test(org.junit.Test)

Example 49 with BimServerClientInterface

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

the class TestSetWrappedInteger method test.

@Test
public void test() {
    try {
        BimServerClientInterface bimServerClient = getFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
        bimServerClient.getSettingsInterface().setCacheOutputFiles(false);
        LowLevelInterface lowLevelInterface = bimServerClient.getLowLevelInterface();
        SProject newProject = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
        SDeserializerPluginConfiguration suggestedDeserializerForExtension = bimServerClient.getServiceInterface().getSuggestedDeserializerForExtension("ifc", newProject.getOid());
        bimServerClient.checkin(newProject.getOid(), "initial", suggestedDeserializerForExtension.getOid(), false, Flow.SYNC, new URL("https://github.com/opensourceBIM/TestFiles/raw/master/TestData/data/revit_quantities.ifc"));
        newProject = bimServerClient.getServiceInterface().getProjectByPoid(newProject.getOid());
        SSerializerPluginConfiguration serializer = bimServerClient.getServiceInterface().getSerializerByName("Ifc2x3");
        bimServerClient.download(newProject.getLastRevisionId(), serializer.getOid(), Paths.get("test1.ifc"));
        IfcModelInterface model = bimServerClient.getModel(newProject, newProject.getLastRevisionId(), false, false);
        long tid = lowLevelInterface.startTransaction(newProject.getOid());
        IfcPropertySingleValue ifcPropertySingleValue = model.getAll(IfcPropertySingleValue.class).iterator().next();
        bimServerClient.getLowLevelInterface().setWrappedIntegerAttribute(tid, ifcPropertySingleValue.getOid(), "NominalValue", "IfcInteger", 12345);
        long roid = lowLevelInterface.commitTransaction(tid, "v2");
        bimServerClient.download(newProject.getLastRevisionId(), serializer.getOid(), Paths.get("test2.ifc"));
        bimServerClient.download(roid, serializer.getOid(), Paths.get("test3.ifc"));
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : IfcPropertySingleValue(org.bimserver.models.ifc2x3tc1.IfcPropertySingleValue) SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) IfcModelInterface(org.bimserver.emf.IfcModelInterface) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) SSerializerPluginConfiguration(org.bimserver.interfaces.objects.SSerializerPluginConfiguration) SProject(org.bimserver.interfaces.objects.SProject) LowLevelInterface(org.bimserver.shared.interfaces.LowLevelInterface) URL(java.net.URL) Test(org.junit.Test)

Example 50 with BimServerClientInterface

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

the class TestUnsetReferenceWithOpposite method test.

@Test
public void test() {
    try {
        // Create a new BimServerClient with authentication
        BimServerClientInterface bimServerClient = getFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
        // Get the service interface
        // PluginInterface pluginInterface = bimServerClient.getPlugin();
        LowLevelInterface service = bimServerClient.getLowLevelInterface();
        Long projectId = bimServerClient.getServiceInterface().addProject("PG-unsetReferenceTest" + new Random().nextInt(), "ifc2x3tc1").getOid();
        Long transactionId = service.startTransaction(projectId);
        Long ifcRelContainedInSpatialStructureId = service.createObject(transactionId, "IfcRelContainedInSpatialStructure", true);
        Long ifcBuildingId = service.createObject(transactionId, "IfcBuilding", true);
        service.setReference(transactionId, ifcRelContainedInSpatialStructureId, "RelatingStructure", ifcBuildingId);
    // Long revisionId = service.commitTransaction(transactionId, "comment");
    // SSerializerPluginConfiguration serializerByPluginClassName = pluginInterface.getSerializerByPluginClassName("org.bimserver.ifc.step.serializer.IfcStepSerializerPlugin");
    // bimServerClient.download(revisionId, serializerByPluginClassName.getOid(), new File("1.ifc"));
    // transactionId = service.startTransaction(projectId);
    // service.unsetReference(transactionId, ifcRelContainedInSpatialStructureId, "RelatingStructure");
    // revisionId = service.commitTransaction(transactionId, "comment");
    // bimServerClient.download(revisionId, serializerByPluginClassName.getOid(), new File("2.ifc"));
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : Random(java.util.Random) UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) LowLevelInterface(org.bimserver.shared.interfaces.LowLevelInterface) Test(org.junit.Test)

Aggregations

BimServerClientInterface (org.bimserver.plugins.services.BimServerClientInterface)66 SProject (org.bimserver.interfaces.objects.SProject)57 UsernamePasswordAuthenticationInfo (org.bimserver.shared.UsernamePasswordAuthenticationInfo)46 Test (org.junit.Test)40 SDeserializerPluginConfiguration (org.bimserver.interfaces.objects.SDeserializerPluginConfiguration)31 SSerializerPluginConfiguration (org.bimserver.interfaces.objects.SSerializerPluginConfiguration)23 IfcModelInterface (org.bimserver.emf.IfcModelInterface)20 PublicInterfaceNotFoundException (org.bimserver.shared.exceptions.PublicInterfaceNotFoundException)20 URL (java.net.URL)19 LowLevelInterface (org.bimserver.shared.interfaces.LowLevelInterface)19 IOException (java.io.IOException)16 ServiceException (org.bimserver.shared.exceptions.ServiceException)15 UserException (org.bimserver.shared.exceptions.UserException)13 ServerException (org.bimserver.shared.exceptions.ServerException)11 BimServerClientException (org.bimserver.shared.exceptions.BimServerClientException)10 Path (java.nio.file.Path)8 JsonBimServerClientFactory (org.bimserver.client.json.JsonBimServerClientFactory)7 BimServerClientFactory (org.bimserver.shared.BimServerClientFactory)7 IfcPropertySingleValue (org.bimserver.models.ifc2x3tc1.IfcPropertySingleValue)6 File (java.io.File)4