Search in sources :

Example 41 with UsernamePasswordAuthenticationInfo

use of org.bimserver.shared.UsernamePasswordAuthenticationInfo 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 42 with UsernamePasswordAuthenticationInfo

use of org.bimserver.shared.UsernamePasswordAuthenticationInfo 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 43 with UsernamePasswordAuthenticationInfo

use of org.bimserver.shared.UsernamePasswordAuthenticationInfo 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 44 with UsernamePasswordAuthenticationInfo

use of org.bimserver.shared.UsernamePasswordAuthenticationInfo 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 45 with UsernamePasswordAuthenticationInfo

use of org.bimserver.shared.UsernamePasswordAuthenticationInfo 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

UsernamePasswordAuthenticationInfo (org.bimserver.shared.UsernamePasswordAuthenticationInfo)55 BimServerClientInterface (org.bimserver.plugins.services.BimServerClientInterface)46 SProject (org.bimserver.interfaces.objects.SProject)45 Test (org.junit.Test)41 SDeserializerPluginConfiguration (org.bimserver.interfaces.objects.SDeserializerPluginConfiguration)27 URL (java.net.URL)20 LowLevelInterface (org.bimserver.shared.interfaces.LowLevelInterface)19 IfcModelInterface (org.bimserver.emf.IfcModelInterface)17 SSerializerPluginConfiguration (org.bimserver.interfaces.objects.SSerializerPluginConfiguration)15 JsonBimServerClientFactory (org.bimserver.client.json.JsonBimServerClientFactory)11 Path (java.nio.file.Path)10 IOException (java.io.IOException)9 ChannelConnectionException (org.bimserver.shared.ChannelConnectionException)9 BimServerClientException (org.bimserver.shared.exceptions.BimServerClientException)9 ServiceException (org.bimserver.shared.exceptions.ServiceException)9 PublicInterfaceNotFoundException (org.bimserver.shared.exceptions.PublicInterfaceNotFoundException)8 BimServerClientFactory (org.bimserver.shared.BimServerClientFactory)7 UserException (org.bimserver.shared.exceptions.UserException)6 IfcPropertySingleValue (org.bimserver.models.ifc2x3tc1.IfcPropertySingleValue)5 File (java.io.File)4