use of org.bimserver.interfaces.objects.SProject 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.interfaces.objects.SProject 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.interfaces.objects.SProject 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.interfaces.objects.SProject 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());
}
}
use of org.bimserver.interfaces.objects.SProject 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());
}
}
}
Aggregations