Search in sources :

Example 31 with UsernamePasswordAuthenticationInfo

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

the class TestCompare method testIfc2x3tc1Guid.

@Test
public void testIfc2x3tc1Guid() {
    try {
        // Create a new BimServerClient with authentication
        BimServerClientInterface bimServerClient = getFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
        // Create a new project
        SProject newProject1 = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
        SProject newProject2 = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
        // Get the appropriate deserializer
        SDeserializerPluginConfiguration deserializer = bimServerClient.getServiceInterface().getSuggestedDeserializerForExtension("ifc", newProject1.getOid());
        SSerializerPluginConfiguration serializer = bimServerClient.getServiceInterface().getSerializerByName("Ifc2x3tc1");
        // Checkin the file
        bimServerClient.checkin(newProject1.getOid(), "test", deserializer.getOid(), false, Flow.SYNC, new URL("https://github.com/opensourceBIM/TestFiles/raw/master/TestData/data/compare_by_guid_rev_1.ifc"));
        bimServerClient.checkin(newProject2.getOid(), "test", deserializer.getOid(), false, Flow.SYNC, new URL("https://github.com/opensourceBIM/TestFiles/raw/master/TestData/data/compare_by_guid_rev_2.ifc"));
        newProject1 = bimServerClient.getServiceInterface().getProjectByPoid(newProject1.getOid());
        newProject2 = bimServerClient.getServiceInterface().getProjectByPoid(newProject2.getOid());
        SModelComparePluginConfiguration defaultModelCompare = bimServerClient.getPluginInterface().getModelCompareByName("GUID based");
        bimServerClient.getServiceInterface().compare(newProject1.getLastRevisionId(), newProject2.getLastRevisionId(), SCompareType.ALL, defaultModelCompare.getOid());
        Long topicId = bimServerClient.getServiceInterface().downloadCompareResults(serializer.getOid(), newProject1.getLastRevisionId(), newProject2.getLastRevisionId(), defaultModelCompare.getOid(), SCompareType.ALL, true);
        bimServerClient.saveDownloadData(topicId, Paths.get("tmptestdata/ifc2x3tc1guidcompare.ifc"));
    } catch (Throwable e) {
        e.printStackTrace();
        if (e instanceof AssertionError) {
            throw (AssertionError) e;
        }
        fail(e.getMessage());
    }
}
Also used : SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) SModelComparePluginConfiguration(org.bimserver.interfaces.objects.SModelComparePluginConfiguration) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) SSerializerPluginConfiguration(org.bimserver.interfaces.objects.SSerializerPluginConfiguration) SProject(org.bimserver.interfaces.objects.SProject) URL(java.net.URL) Test(org.junit.Test)

Example 32 with UsernamePasswordAuthenticationInfo

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

the class UpdateProject method test.

@Test
public void test() {
    try {
        // Create a new BimServerClient with authentication
        BimServerClientInterface bimServerClient = getFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
        // Create a new project
        String originalName = "test " + Math.random();
        String newName = "test " + Math.random();
        SProject newProject = bimServerClient.getServiceInterface().addProject(originalName, "ifc2x3tc1");
        newProject.setName(newName);
        bimServerClient.getServiceInterface().updateProject(newProject);
        newProject = bimServerClient.getServiceInterface().getProjectByPoid(newProject.getOid());
        if (newProject.getName().equals(originalName)) {
            fail("Project name not updated");
        } else if (!newProject.getName().equals(newName)) {
            fail("Project name not updated to new name");
        }
    } catch (Throwable e) {
        e.printStackTrace();
        if (e instanceof AssertionError) {
            throw (AssertionError) e;
        }
        fail(e.getMessage());
    }
}
Also used : UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) SProject(org.bimserver.interfaces.objects.SProject) Test(org.junit.Test)

Example 33 with UsernamePasswordAuthenticationInfo

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

the class TestAddReferenceWithOppositeExisting 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);
        Long ifcBuildingOid2 = lowLevelInterface.createObject(tid, "IfcBuilding", true);
        lowLevelInterface.addReference(tid, ifcBuildingOid1, "ContainsElements", ifcRelContainedInSpatialStructureOid);
        lowLevelInterface.commitTransaction(tid, "Initial");
        tid = lowLevelInterface.startTransaction(newProject.getOid());
        lowLevelInterface.addReference(tid, ifcBuildingOid2, "ContainsElements", ifcRelContainedInSpatialStructureOid);
        try {
            lowLevelInterface.commitTransaction(tid, "2");
        } catch (UserException e) {
            if (e.getErrorCode() != ErrorCode.SET_REFERENCE_FAILED_OPPOSITE_ALREADY_SET) {
                fail("Didn't get the right errormessage");
            }
        }
    } catch (Exception e) {
        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 34 with UsernamePasswordAuthenticationInfo

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

the class TestCreateGuid 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 furnishingOid = lowLevelInterface.createObject(tid, "IfcFurnishingElement", true);
        lowLevelInterface.setStringAttribute(tid, furnishingOid, "GlobalId", "0uyjn9Jan3nRq36Uj6gwws");
        // Commit the transaction
        lowLevelInterface.commitTransaction(tid, "test");
        tid = lowLevelInterface.startTransaction(newProject.getOid());
        assertTrue(lowLevelInterface.getStringAttribute(tid, furnishingOid, "GlobalId").equals("0uyjn9Jan3nRq36Uj6gwws"));
    } 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 35 with UsernamePasswordAuthenticationInfo

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

the class TestCreateReferenceListsAndClear 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 ifcShapeRepresentationOid = lowLevelInterface.createObject(tid, "IfcShapeRepresentation", false);
        long ifcRepresentationItem1 = lowLevelInterface.createObject(tid, "IfcStyledItem", false);
        long ifcRepresentationItem2 = lowLevelInterface.createObject(tid, "IfcMappedItem", false);
        long ifcRepresentationItem3 = lowLevelInterface.createObject(tid, "IfcGeometricRepresentationItem", false);
        lowLevelInterface.addReference(tid, ifcShapeRepresentationOid, "Items", ifcRepresentationItem1);
        lowLevelInterface.addReference(tid, ifcShapeRepresentationOid, "Items", ifcRepresentationItem2);
        lowLevelInterface.addReference(tid, ifcShapeRepresentationOid, "Items", ifcRepresentationItem3);
        // Commit the transaction
        lowLevelInterface.commitTransaction(tid, "test");
        tid = lowLevelInterface.startTransaction(newProject.getOid());
        List<Long> itemOids = lowLevelInterface.getReferences(tid, ifcShapeRepresentationOid, "Items");
        assertTrue(itemOids.get(0) == ifcRepresentationItem1 && itemOids.get(1) == ifcRepresentationItem2 && itemOids.get(2) == ifcRepresentationItem3);
        lowLevelInterface.removeAllReferences(tid, ifcShapeRepresentationOid, "Items");
        lowLevelInterface.commitTransaction(tid, "removed all references");
        tid = lowLevelInterface.startTransaction(newProject.getOid());
        itemOids = lowLevelInterface.getReferences(tid, ifcShapeRepresentationOid, "Items");
        assertTrue(itemOids.size() == 0);
    } 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