use of org.bimserver.client.BimServerClient in project BIMserver by opensourceBIM.
the class TestServerRestart method test.
// @Test // This test requires user interaction, should be moved to non/semiautomated tests in Test module
public void test() {
try (JsonBimServerClientFactory factory = new JsonBimServerClientFactory("http://localhost:8080")) {
try (BimServerClient client = factory.create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"))) {
try (Scanner scanner = new Scanner(System.in)) {
for (int i = 0; i < 10; i++) {
System.out.println("Restart server now, then press key");
scanner.nextLine();
try {
checkin(client);
} catch (UserException e) {
if (e.getErrorCode() == DefaultErrorCode.ENDPOINT_NOT_FOUND) {
client.getNotificationsManager().startAndWaitForInit();
checkin(client);
} else {
System.err.println(e.getMessage());
}
}
}
}
Thread.sleep(5000);
}
} catch (BimServerClientException e) {
e.printStackTrace();
} catch (Exception e1) {
e1.printStackTrace();
}
}
use of org.bimserver.client.BimServerClient 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.client.BimServerClient 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.client.BimServerClient in project BIMserver by opensourceBIM.
the class SoapBimServerClientFactory method create.
@Override
public BimServerClient create(AuthenticationInfo authenticationInfo) throws ServiceException, ChannelConnectionException {
SoapChannel soapChannel = new SoapChannel(getHttpClient(), address + "/soap11", true, getServicesMap().getInterfaceClasses());
BimServerClient bimServerClient = new BimServerClient(this.getMetaDataManager(), address, getServicesMap(), soapChannel);
soapChannel.connect(bimServerClient);
bimServerClient.setAuthentication(authenticationInfo);
bimServerClient.connect();
return bimServerClient;
}
use of org.bimserver.client.BimServerClient in project BIMserver by opensourceBIM.
the class TestGetGeometry 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, (title, progress) -> System.out.println(title + ": " + progress));
PackageMetaData packageMetaData = client.getMetaDataManager().getPackageMetaData("ifc2x3tc1");
GeometryTargetImpl geometryTargetImpl = new GeometryTargetImpl(packageMetaData);
GeometryLoader geometryLoader = new GeometryLoader(client, packageMetaData, geometryTargetImpl);
Set<Long> oids = new HashSet<>();
// Only to gather oids
ClientIfcModel model = client.getModel(project, actionState.getRoid(), true, false, false);
for (IfcWall ifcWall : model.getAllWithSubTypes(IfcWall.class)) {
oids.add(ifcWall.getOid());
}
geometryLoader.loadProducts(actionState.getRoid(), oids);
System.out.println(geometryTargetImpl);
Set<Long> geometryDataOids = new HashSet<>();
for (GeometryInfo geometryInfo : geometryTargetImpl.getAllGeometryInfo()) {
GeometryData geometryData = geometryInfo.getData();
System.out.println(geometryInfo.getPrimitiveCount());
System.out.println(geometryData.getNrIndices());
geometryDataOids.add(geometryData.getOid());
}
geometryTargetImpl = new GeometryTargetImpl(packageMetaData);
geometryLoader = new GeometryLoader(client, packageMetaData, geometryTargetImpl);
geometryLoader.loadGeometryData(actionState.getRoid(), geometryDataOids);
System.out.println(geometryTargetImpl);
}
}
Thread.sleep(1000);
}
Aggregations