use of org.bimserver.plugins.services.BimServerClientInterface in project BIMserver by opensourceBIM.
the class TestMoveObject 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
SProject newProject = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
// Get the appropriate deserializer
SDeserializerPluginConfiguration deserializer = bimServerClient.getServiceInterface().getSuggestedDeserializerForExtension("ifc", newProject.getOid());
// Checkin the file
bimServerClient.checkin(newProject.getOid(), "test", deserializer.getOid(), false, Flow.SYNC, new URL("https://github.com/opensourceBIM/TestFiles/raw/master/TestData/data/AC11-Institute-Var-2-IFC.ifc"));
// Refresh project info
newProject = bimServerClient.getServiceInterface().getProjectByPoid(newProject.getOid());
IfcModelInterface model = bimServerClient.getModel(newProject, newProject.getLastRevisionId(), true, true);
for (IfcFurnishingElement ifcFurnishingElement : model.getAllWithSubTypes(IfcFurnishingElement.class)) {
IfcObjectPlacement objectPlacement = ifcFurnishingElement.getObjectPlacement();
if (objectPlacement != null && objectPlacement instanceof IfcLocalPlacement) {
IfcLocalPlacement localPlacement = (IfcLocalPlacement) objectPlacement;
IfcAxis2Placement relativePlacement = localPlacement.getRelativePlacement();
if (relativePlacement != null) {
if (relativePlacement instanceof IfcAxis2Placement3D) {
IfcAxis2Placement3D axis2Placement3D = (IfcAxis2Placement3D) relativePlacement;
IfcCartesianPoint location = axis2Placement3D.getLocation();
double newValue = location.getCoordinates().get(2) + 50;
System.out.println("Changing z value of " + ifcFurnishingElement.getName() + " from " + location.getCoordinates().get(2) + " to " + newValue);
location.getCoordinates().set(2, newValue);
}
}
}
}
long newRoid = model.commit("Moved all furniture 50 meters up");
SSerializerPluginConfiguration ifcSerializer = bimServerClient.getServiceInterface().getSerializerByContentType("application/ifc");
bimServerClient.download(newRoid, ifcSerializer.getOid(), Paths.get("movedf.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 TestAddReferenceWithOpposite 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.addReference(tid, ifcBuildingOid, "ContainsElements", ifcRelContainedInSpatialStructureOid);
lowLevelInterface.commitTransaction(tid, "Initial");
tid = lowLevelInterface.startTransaction(newProject.getOid());
if (!lowLevelInterface.getReference(tid, ifcRelContainedInSpatialStructureOid, "RelatingStructure").equals(ifcBuildingOid)) {
fail("Not the same");
}
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.bimserver.plugins.services.BimServerClientInterface in project BIMserver by opensourceBIM.
the class SubProjects method test.
@Test
public void test() {
try {
// Create a new BimServerClient with authentication
BimServerClientInterface bimServerClient = getFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
long s = System.nanoTime();
// Create a new project
SProject mainProject = bimServerClient.getServiceInterface().addProject("main" + Math.random(), "ifc2x3tc1");
SProject sub1 = bimServerClient.getServiceInterface().addProjectAsSubProject("Sub1" + Math.random(), mainProject.getOid(), "ifc2x3tc1");
SProject sub2 = bimServerClient.getServiceInterface().addProjectAsSubProject("Sub2" + Math.random(), mainProject.getOid(), "ifc2x3tc1");
SProject sub3 = bimServerClient.getServiceInterface().addProjectAsSubProject("Sub3" + Math.random(), mainProject.getOid(), "ifc2x3tc1");
// Find a deserializer to use
SDeserializerPluginConfiguration deserializer = bimServerClient.getServiceInterface().getSuggestedDeserializerForExtension("ifc", mainProject.getOid());
// Checkin
bimServerClient.checkin(sub1.getOid(), "test", deserializer.getOid(), false, Flow.SYNC, new URL("https://github.com/opensourceBIM/TestFiles/raw/master/TestData/data/AC11-Institute-Var-2-IFC.ifc"));
bimServerClient.checkin(sub2.getOid(), "test", deserializer.getOid(), false, Flow.SYNC, new URL("https://github.com/opensourceBIM/TestFiles/raw/master/TestData/data/AC90R1-niedriha-V2-2x3.ifc"));
bimServerClient.checkin(sub3.getOid(), "test", deserializer.getOid(), false, Flow.SYNC, new URL("https://github.com/opensourceBIM/TestFiles/raw/master/TestData/data/AC11-FZK-Haus-IFC.ifc"));
// Find a serializer
SSerializerPluginConfiguration serializer = bimServerClient.getServiceInterface().getSerializerByContentType("application/ifc");
// Get the project details
mainProject = bimServerClient.getServiceInterface().getProjectByPoid(mainProject.getOid());
// Download the latest revision (the one we just checked in)
// Long topicId = bimServerClient.getServiceInterface().downloadByTypes(Collections.singleton(mainProject.getLastRevisionId()),
// Collections.singleton("IfcWall"), serializer.getOid(), true, false, true, true);
Long topicId = bimServerClient.getServiceInterface().download(Collections.singleton(mainProject.getLastRevisionId()), DefaultQueries.allAsString(), serializer.getOid(), true);
IOUtils.copy(bimServerClient.getDownloadData(topicId), new FileOutputStream(new File("out.ifc")));
bimServerClient.getServiceInterface().cleanupLongAction(topicId);
long e = System.nanoTime();
System.out.println(((e - s) / 1000000) + " ms");
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.bimserver.plugins.services.BimServerClientInterface in project BIMserver by opensourceBIM.
the class TestCompare method testIfc4Guid.
@Test
public void testIfc4Guid() {
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(), "ifc4");
SProject newProject2 = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc4");
// Get the appropriate deserializer
SDeserializerPluginConfiguration deserializer = bimServerClient.getServiceInterface().getSuggestedDeserializerForExtension("ifc", newProject1.getOid());
SSerializerPluginConfiguration serializer = bimServerClient.getServiceInterface().getSerializerByName("Ifc4");
// 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_name_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_name_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/ifc4guidcompare.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 TestCompare method testIfc4Name.
@Test
public void testIfc4Name() {
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(), "ifc4");
SProject newProject2 = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc4");
// Get the appropriate deserializer
SDeserializerPluginConfiguration deserializer = bimServerClient.getServiceInterface().getSuggestedDeserializerForExtension("ifc", newProject1.getOid());
SSerializerPluginConfiguration serializer = bimServerClient.getServiceInterface().getSerializerByName("Ifc4");
// 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_name_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_name_rev_2.ifc"));
newProject1 = bimServerClient.getServiceInterface().getProjectByPoid(newProject1.getOid());
newProject2 = bimServerClient.getServiceInterface().getProjectByPoid(newProject2.getOid());
SModelComparePluginConfiguration defaultModelCompare = bimServerClient.getPluginInterface().getModelCompareByName("Name 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/ifc4namecompare.ifc"));
} catch (Throwable e) {
e.printStackTrace();
if (e instanceof AssertionError) {
throw (AssertionError) e;
}
fail(e.getMessage());
}
}
Aggregations