use of org.bimserver.plugins.services.BimServerClientInterface 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());
}
}
use of org.bimserver.plugins.services.BimServerClientInterface 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());
}
}
use of org.bimserver.plugins.services.BimServerClientInterface 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());
}
}
use of org.bimserver.plugins.services.BimServerClientInterface 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());
}
}
use of org.bimserver.plugins.services.BimServerClientInterface 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());
}
}
Aggregations