use of org.bimserver.interfaces.objects.SSerializerPluginConfiguration in project BIMserver by opensourceBIM.
the class TestSetWrappedIntegerGeometry method test.
@Test
public void test() {
try {
BimServerClientInterface bimServerClient = getFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
bimServerClient.getSettingsInterface().setCacheOutputFiles(false);
LowLevelInterface lowLevelInterface = bimServerClient.getLowLevelInterface();
SProject newProject = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
SDeserializerPluginConfiguration suggestedDeserializerForExtension = bimServerClient.getServiceInterface().getSuggestedDeserializerForExtension("ifc", newProject.getOid());
bimServerClient.checkin(newProject.getOid(), "initial", suggestedDeserializerForExtension.getOid(), false, Flow.SYNC, new URL("https://github.com/opensourceBIM/TestFiles/raw/master/TestData/data/revit_quantities.ifc"));
newProject = bimServerClient.getServiceInterface().getProjectByPoid(newProject.getOid());
SSerializerPluginConfiguration serializer = bimServerClient.getServiceInterface().getSerializerByName("Ifc2x3tc1 (Streaming)");
bimServerClient.download(newProject.getLastRevisionId(), serializer.getOid(), Paths.get("test1.ifc"));
IfcModelInterface model = bimServerClient.getModel(newProject, newProject.getLastRevisionId(), false, false);
long tid = lowLevelInterface.startTransaction(newProject.getOid());
IfcPropertySingleValue ifcPropertySingleValue = model.getAll(IfcPropertySingleValue.class).iterator().next();
bimServerClient.getLowLevelInterface().setWrappedLongAttribute(tid, ifcPropertySingleValue.getOid(), "NominalValue", "IfcInteger", 12345L);
long roid = lowLevelInterface.commitTransaction(tid, "v2");
IfcModelInterface newModel = bimServerClient.getModel(newProject, roid, true, false, true);
SVector3f minBounds = newModel.getModelMetaData().getMinBounds();
SVector3f maxBounds = newModel.getModelMetaData().getMaxBounds();
org.junit.Assert.assertNotNull(minBounds);
org.junit.Assert.assertNotNull(maxBounds);
bimServerClient.download(newProject.getLastRevisionId(), serializer.getOid(), Paths.get("test2.ifc"));
bimServerClient.download(roid, serializer.getOid(), Paths.get("test3.ifc"));
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.bimserver.interfaces.objects.SSerializerPluginConfiguration in project BIMserver by opensourceBIM.
the class MultiCheckinAndDownload 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();
for (int i = 0; i < 3; i++) {
// Create a new project
SProject newProject = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
// This is the file we will be checking in
File ifcFile = new File("../TestData/data/AC11-FZK-Haus-IFC.ifc");
// Find a deserializer to use
SDeserializerPluginConfiguration deserializer = bimServerClient.getServiceInterface().getSuggestedDeserializerForExtension("ifc", newProject.getOid());
// Checkin
Long progressId = bimServerClient.getServiceInterface().checkin(newProject.getOid(), "test", deserializer.getOid(), ifcFile.length(), ifcFile.getName(), new DataHandler(new FileDataSource(ifcFile)), false, true);
// Get the status
SLongActionState longActionState = bimServerClient.getRegistry().getProgress(progressId);
if (longActionState.getState() == SActionState.FINISHED) {
// Find a serializer
SSerializerPluginConfiguration serializer = bimServerClient.getServiceInterface().getSerializerByContentType("application/ifc");
// Get the project details
newProject = bimServerClient.getServiceInterface().getProjectByPoid(newProject.getOid());
// Download the latest revision (the one we just checked in)
Long topicId = bimServerClient.getServiceInterface().download(Collections.singleton(newProject.getLastRevisionId()), DefaultQueries.allAsString(), serializer.getOid(), true);
SLongActionState downloadState = bimServerClient.getRegistry().getProgress(topicId);
if (downloadState.getState() == SActionState.FINISHED) {
// Success
System.out.println("Success");
}
}
}
long e = System.nanoTime();
System.out.println(((e - s) / 1000000) + " ms");
} catch (Exception e) {
fail(e.getMessage());
}
}
use of org.bimserver.interfaces.objects.SSerializerPluginConfiguration in project BIMserver by opensourceBIM.
the class SingleCheckinAndDownload method test.
@Test
public void test() {
try {
// Create a new BimServerClient with authentication
BimServerClientInterface bimServerClient = getFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
// When you use the channel for checkin/download calls, all data will have to be converted to the used channel's format, for example for JSON, binary data will be Base64 encoded, which will make things slower and larger
// The alternative is to use the Servlets, those will also use compression where possible
// Using the channel is slower
boolean useChannel = false;
// Create a new project
SProject newProject = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
// Find a deserializer to use
SDeserializerPluginConfiguration deserializer = bimServerClient.getServiceInterface().getSuggestedDeserializerForExtension("ifc", newProject.getOid());
// Checkin
Long progressId = -1L;
// if (useChannel) {
// progressId = bimServerClient.getServiceInterface().checkin(newProject.getOid(), "test", deserializer.getOid(), ifcFile.toFile().length(), ifcFile.getFileName().toString(), new DataHandler(new FileDataSource(ifcFile.toFile())), true, true);
// } else {
progressId = 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"));
// }
// Get the status
SLongActionState longActionState = bimServerClient.getRegistry().getProgress(progressId);
if (longActionState.getState() == SActionState.FINISHED) {
// Find a serializer
SSerializerPluginConfiguration serializer = bimServerClient.getServiceInterface().getSerializerByContentType("application/ifc");
// Get the project details
newProject = bimServerClient.getServiceInterface().getProjectByPoid(newProject.getOid());
// Download the latest revision (the one we just checked in)
if (useChannel) {
Long topicId = bimServerClient.getServiceInterface().download(Collections.singleton(newProject.getLastRevisionId()), DefaultQueries.allAsString(), serializer.getOid(), true);
SLongActionState downloadState = bimServerClient.getRegistry().getProgress(topicId);
if (downloadState.getState() == SActionState.FINISHED) {
InputStream inputStream = bimServerClient.getServiceInterface().getDownloadData(topicId).getFile().getInputStream();
IOUtils.copy(inputStream, new ByteArrayOutputStream());
System.out.println("Success");
}
} else {
// Note: sync: false
Long topicId = bimServerClient.getServiceInterface().download(Collections.singleton(newProject.getLastRevisionId()), DefaultQueries.allAsString(), serializer.getOid(), false);
InputStream downloadData = bimServerClient.getDownloadData(topicId);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
IOUtils.copy(downloadData, baos);
System.out.println(baos.size() + " bytes downloaded");
}
} else {
System.out.println(longActionState.getState());
}
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.bimserver.interfaces.objects.SSerializerPluginConfiguration in project BIMserver by opensourceBIM.
the class SingleCheckinAndDownloadSimplified 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");
// This is the file we will be checking in
Path ifcFile = Paths.get("../TestData/data/AC11-FZK-Haus-IFC.ifc");
// Find a deserializer to use
SDeserializerPluginConfiguration deserializer = bimServerClient.getServiceInterface().getSuggestedDeserializerForExtension("ifc", newProject.getOid());
// Checkin
bimServerClient.checkin(newProject.getOid(), "test", deserializer.getOid(), false, Flow.SYNC, ifcFile);
// Find a serializer
SSerializerPluginConfiguration colladaSerializer = bimServerClient.getServiceInterface().getSerializerByContentType("application/collada");
// Get the project details
newProject = bimServerClient.getServiceInterface().getProjectByPoid(newProject.getOid());
// Download the latest revision (the one we just checked in)
// Note: sync: false
Long topicIdId = bimServerClient.getServiceInterface().download(Collections.singleton(newProject.getLastRevisionId()), DefaultQueries.allAsString(), colladaSerializer.getOid(), false);
InputStream downloadData = bimServerClient.getDownloadData(topicIdId);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
IOUtils.copy(downloadData, baos);
System.out.println(baos.size() + " bytes downloaded");
} catch (Exception e) {
fail(e.getMessage());
}
}
use of org.bimserver.interfaces.objects.SSerializerPluginConfiguration in project BIMserver by opensourceBIM.
the class TestCompare method testIfc2x3tc1Name.
@Test
public void testIfc2x3tc1Name() {
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("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/ifc2x3tc1namecompare.ifc"));
} catch (Throwable e) {
e.printStackTrace();
if (e instanceof AssertionError) {
throw (AssertionError) e;
}
fail(e.getMessage());
}
}
Aggregations