use of org.bimserver.plugins.services.CheckinProgressHandler in project BIMserver by opensourceBIM.
the class TestGetGeometry2 method test.
@Test
public void test() throws Exception {
try (JsonBimServerClientFactory factory = new JsonBimServerClientFactory("http://localhost:8080")) {
try (BimServerClient client = factory.create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"))) {
SProject project = client.getServiceInterface().addProject(RandomStringUtils.randomAlphanumeric(10), "ifc2x3tc1");
SDeserializerPluginConfiguration deserializer = client.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
Path path = Paths.get("../../TestFiles/TestData/data/export1.ifc");
SLongCheckinActionState actionState = client.checkinSync(project.getOid(), "test", deserializer.getOid(), path, new CheckinProgressHandler() {
@Override
public void progress(String title, int progress) {
System.out.println(title + ": " + progress);
}
});
ClientIfcModel model = client.getModel(project, actionState.getRoid(), false, false, true);
for (IfcProduct product : model.getAllWithSubTypes(IfcProduct.class)) {
GeometryInfo geometry = product.getGeometry();
if (geometry != null) {
System.out.println(product.getGeometry().getData().getNrVertices());
System.out.println(product.getGeometry().getData().getVertices().getData().length);
}
}
}
}
Thread.sleep(1000);
}
use of org.bimserver.plugins.services.CheckinProgressHandler in project BIMserver by opensourceBIM.
the class TestGetUuid method test.
@Test
public void test() throws Exception {
try (JsonBimServerClientFactory factory = new JsonBimServerClientFactory("http://localhost:8080")) {
try (BimServerClient client = factory.create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"))) {
SServerInfo serverInfo = client.getAdminInterface().getServerInfo();
System.out.println(serverInfo.getServerState());
System.out.println(serverInfo.getUuid());
SProject project = client.getServiceInterface().addProject(RandomStringUtils.randomAlphanumeric(10), "ifc2x3tc1");
SDeserializerPluginConfiguration deserializer = client.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
Path path = Paths.get("../../TestFiles/TestData/data/AC11-Institute-Var-2-IFC.ifc");
client.checkinSync(project.getOid(), "test", deserializer.getOid(), path, new CheckinProgressHandler() {
@Override
public void progress(String title, int progress) {
System.out.println(title + ": " + progress);
}
});
project = client.getServiceInterface().getProjectByPoid(project.getOid());
ClientIfcModel model = client.getModel(project, project.getLastRevisionId(), true, true);
for (IfcBuildingStorey ifcBuildingStorey : model.getAll(IfcBuildingStorey.class)) {
System.out.println(ifcBuildingStorey.getUuid() + ":" + ifcBuildingStorey.getRid());
}
System.out.println("Length unit: " + IfcUtils.getLengthUnitPrefix(model));
IfcProject ifcProject = model.getAll(IfcProject.class).iterator().next();
ifcProject.setName(ifcProject.getName() + " updated");
long newRoid = model.commit("commit message");
model = client.getModel(project, newRoid, true, true);
ifcProject = model.getAll(IfcProject.class).iterator().next();
System.out.println(ifcProject.getName());
}
}
Thread.sleep(1000);
}
use of org.bimserver.plugins.services.CheckinProgressHandler in project BIMserver by opensourceBIM.
the class TestServerRestart method checkin.
private void checkin(BimServerClient client) throws ServerException, UserException {
SProject project = client.getServiceInterface().addProject(RandomStringUtils.randomAlphanumeric(10), "ifc2x3tc1");
SDeserializerPluginConfiguration deserializer = client.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
Path path = Paths.get("../../TestFiles/TestData/data/export1.ifc");
client.checkinSync(project.getOid(), "test", deserializer.getOid(), path, new CheckinProgressHandler() {
@Override
public void progress(String title, int progress) {
System.out.println(title + ": " + progress);
}
});
}
use of org.bimserver.plugins.services.CheckinProgressHandler in project BIMserver by opensourceBIM.
the class BimServerClient method checkin.
public SLongCheckinActionState checkin(long poid, String comment, long deserializerOid, long fileSize, String filename, InputStream inputStream, CheckinProgressHandler progressHandler) throws ServerException, UserException, PublicInterfaceNotFoundException {
long topicId = getServiceInterface().initiateCheckin(poid, deserializerOid);
ProgressHandler progressHandlerWrapper = new ProgressHandler() {
@Override
public void progress(SLongActionState state) {
progressHandler.progress(state.getTitle(), state.getProgress());
}
};
getNotificationsManager().registerProgressHandler(topicId, progressHandlerWrapper);
return channel.checkinSync(baseAddress, token, poid, comment, deserializerOid, false, fileSize, filename, inputStream, topicId);
}
use of org.bimserver.plugins.services.CheckinProgressHandler in project BIMserver by opensourceBIM.
the class BimServerClient method checkin.
public SLongCheckinActionState checkin(long poid, String comment, long deserializerOid, URL url, CheckinProgressHandler progressHandler) throws ServerException, UserException, PublicInterfaceNotFoundException {
long topicId = getServiceInterface().initiateCheckin(poid, deserializerOid);
ProgressHandler progressHandlerWrapper = new ProgressHandler() {
@Override
public void progress(SLongActionState state) {
progressHandler.progress(state.getTitle(), state.getProgress());
}
};
getNotificationsManager().registerProgressHandler(topicId, progressHandlerWrapper);
try {
InputStream openStream = url.openStream();
try {
channel.checkinAsync(baseAddress, token, poid, comment, deserializerOid, false, -1, url.toString(), openStream, topicId);
} finally {
openStream.close();
}
} catch (IOException e) {
e.printStackTrace();
}
getNotificationsManager().unregisterProgressHandler(topicId, progressHandlerWrapper);
return (SLongCheckinActionState) getRegistry().getProgress(topicId);
}
Aggregations