Search in sources :

Example 36 with UsernamePasswordAuthenticationInfo

use of org.bimserver.shared.UsernamePasswordAuthenticationInfo in project BIMserver by opensourceBIM.

the class TestCreateUnknownType 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());
        // IfcCartesi(O)nPoint
        lowLevelInterface.createObject(tid, "IfcCartesionPoint", true);
        // Commit the transaction
        lowLevelInterface.commitTransaction(tid, "test");
    } catch (Exception e) {
        if (e instanceof UserException) {
        } else {
            e.printStackTrace();
            fail(e.getMessage());
        }
    }
}
Also used : UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) UserException(org.bimserver.shared.exceptions.UserException) SProject(org.bimserver.interfaces.objects.SProject) LowLevelInterface(org.bimserver.shared.interfaces.LowLevelInterface) UserException(org.bimserver.shared.exceptions.UserException) Test(org.junit.Test)

Example 37 with UsernamePasswordAuthenticationInfo

use of org.bimserver.shared.UsernamePasswordAuthenticationInfo in project BIMserver by opensourceBIM.

the class TestIfcMeasureWithUnit 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 low level interface
        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());
        // Create furnishing
        Long ifcMeasureWithUnitOid = lowLevelInterface.createObject(tid, "IfcMeasureWithUnit", false);
        lowLevelInterface.setWrappedDoubleAttribute(tid, ifcMeasureWithUnitOid, "ValueComponent", "IfcPlaneAngleMeasure", 0.12345);
        // Commit the transaction
        lowLevelInterface.commitTransaction(tid, "test");
        tid = lowLevelInterface.startTransaction(newProject.getOid());
        double v = lowLevelInterface.getDoubleAttribute(tid, ifcMeasureWithUnitOid, "ValueComponent");
        if (v != 0.12345) {
            fail("0.12345 expected, got " + v);
        }
    } 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 38 with UsernamePasswordAuthenticationInfo

use of org.bimserver.shared.UsernamePasswordAuthenticationInfo in project BIMserver by opensourceBIM.

the class TestRemoveObject2 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
        SSerializerPluginConfiguration serializer = bimServerClient.getServiceInterface().getSerializerByContentType("application/ifc");
        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);
        Long ifcWallOid = lowLevelInterface.createObject(tid, "IfcWall", true);
        lowLevelInterface.addReference(tid, ifcBuildingOid, "ContainsElements", ifcRelContainedInSpatialStructureOid);
        lowLevelInterface.addReference(tid, ifcRelContainedInSpatialStructureOid, "RelatedElements", ifcWallOid);
        Long newRoid = lowLevelInterface.commitTransaction(tid, "Initial");
        bimServerClient.download(newRoid, serializer.getOid(), Paths.get("test1.ifc"));
        tid = lowLevelInterface.startTransaction(newProject.getOid());
        lowLevelInterface.removeObject(tid, ifcWallOid);
        lowLevelInterface.removeObject(tid, ifcRelContainedInSpatialStructureOid);
        newRoid = lowLevelInterface.commitTransaction(tid, "removed");
        bimServerClient.download(newRoid, serializer.getOid(), Paths.get("test2.ifc"));
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) SSerializerPluginConfiguration(org.bimserver.interfaces.objects.SSerializerPluginConfiguration) SProject(org.bimserver.interfaces.objects.SProject) LowLevelInterface(org.bimserver.shared.interfaces.LowLevelInterface) Test(org.junit.Test)

Example 39 with UsernamePasswordAuthenticationInfo

use of org.bimserver.shared.UsernamePasswordAuthenticationInfo in project BIMserver by opensourceBIM.

the class TestRemoveReferenceWithOpposite 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 ifcBuildingOid1 = lowLevelInterface.createObject(tid, "IfcBuilding", true);
        lowLevelInterface.addReference(tid, ifcBuildingOid1, "ContainsElements", ifcRelContainedInSpatialStructureOid);
        lowLevelInterface.commitTransaction(tid, "Initial");
        tid = lowLevelInterface.startTransaction(newProject.getOid());
        lowLevelInterface.removeReference(tid, ifcBuildingOid1, "ContainsElements", 0);
        lowLevelInterface.commitTransaction(tid, "2");
        tid = lowLevelInterface.startTransaction(newProject.getOid());
        if (lowLevelInterface.getReference(tid, ifcRelContainedInSpatialStructureOid, "RelatingStructure") != -1) {
            fail("Reference should no be set");
        }
    } 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 40 with UsernamePasswordAuthenticationInfo

use of org.bimserver.shared.UsernamePasswordAuthenticationInfo in project BIMserver by opensourceBIM.

the class TestRemoveReferenceWithOpposite2 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 ifcRelAssignsToGroupOid = lowLevelInterface.createObject(tid, "IfcRelAssignsToGroup", true);
        Long ifcFurnishingElement1Oid = lowLevelInterface.createObject(tid, "IfcFurnishingElement", true);
        Long ifcFurnishingElement2Oid = lowLevelInterface.createObject(tid, "IfcFurnishingElement", true);
        lowLevelInterface.addReference(tid, ifcRelAssignsToGroupOid, "RelatedObjects", ifcFurnishingElement1Oid);
        lowLevelInterface.addReference(tid, ifcRelAssignsToGroupOid, "RelatedObjects", ifcFurnishingElement2Oid);
        lowLevelInterface.commitTransaction(tid, "Initial");
        tid = lowLevelInterface.startTransaction(newProject.getOid());
        List<Long> references = lowLevelInterface.getReferences(tid, ifcRelAssignsToGroupOid, "RelatedObjects");
        assertEquals("Number of references", 2, references.size());
        lowLevelInterface.removeReferenceByOid(tid, ifcRelAssignsToGroupOid, "RelatedObjects", ifcFurnishingElement1Oid);
        lowLevelInterface.commitTransaction(tid, "2");
        tid = lowLevelInterface.startTransaction(newProject.getOid());
        references = lowLevelInterface.getReferences(tid, ifcRelAssignsToGroupOid, "RelatedObjects");
        assertEquals("Number of references", 1, references.size());
    } 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)

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