use of org.bimserver.plugins.services.BimServerClientInterface in project BIMserver by opensourceBIM.
the class TestChangeGeometryError 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");
// Look for a deserializer
SDeserializerPluginConfiguration deserializer = bimServerClient.getServiceInterface().getSuggestedDeserializerForExtension("ifc", newProject.getOid());
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"));
newProject = bimServerClient.getServiceInterface().getProjectByPoid(newProject.getOid());
IfcModelInterface model = bimServerClient.getModel(newProject, newProject.getLastRevisionId(), false, true, true);
List<IfcWall> walls = model.getAllWithSubTypes(Ifc2x3tc1Package.eINSTANCE.getIfcWall());
IfcWall firstWall = walls.get(0);
firstWall.getGeometry().getData().setVertices(new byte[10]);
model.commit("Tried to change geometry, which should not be possible");
fail("This have thrown an error");
} catch (Throwable e) {
if (e instanceof AssertionError) {
throw (AssertionError) e;
}
e.printStackTrace();
assertEquals("Only objects from the following schemas are allowed to be changed: Ifc2x3tc1 and IFC4, this object (GeometryData) is from the \"geometry\" package", e.getMessage());
}
}
use of org.bimserver.plugins.services.BimServerClientInterface in project BIMserver by opensourceBIM.
the class TestConstantlyDownloading method main.
public static void main(String[] args) {
long poid = 196609;
try {
BimServerClientInterface client = LocalDevSetup.setupJson("http://localhost:8080");
for (int i = 0; i < 200; i++) {
SProject project = client.getServiceInterface().getProjectByPoid(poid);
long roid = project.getLastRevisionId();
SSerializerPluginConfiguration serializer = client.getPluginInterface().getSerializerByPluginClassName("org.bimserver.geometry.json.JsonGeometrySerializerPlugin");
System.out.println(i);
client.download(roid, serializer.getOid(), new ByteArrayOutputStream());
}
} catch (ServiceException e) {
e.printStackTrace();
} catch (PublicInterfaceNotFoundException e) {
e.printStackTrace();
} catch (BimServerClientException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of org.bimserver.plugins.services.BimServerClientInterface in project BIMserver by opensourceBIM.
the class TestInstall method main.
public static void main(String[] args) {
ArrayList<String> pluginList = new ArrayList<>();
pluginList.add("C:/plugins/ifcplugins-0.0.15.jar");
try (BimServerClientFactory factory = new JsonBimServerClientFactory("http://localhost:8080")) {
BimServerClientInterface client = factory.create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
for (String each : pluginList) {
try {
DataSource fds = new FileDataSource(new File(each));
DataHandler handler = new DataHandler(fds);
client.getPluginInterface().installPluginBundleFromFile(handler, true, true);
System.out.println("Plugin " + each + " successfully installed !");
} catch (Exception e) {
e.printStackTrace();
}
}
} catch (BimServerClientException e1) {
e1.printStackTrace();
} catch (ServiceException e1) {
e1.printStackTrace();
} catch (ChannelConnectionException e1) {
e1.printStackTrace();
} catch (Exception e2) {
e2.printStackTrace();
}
}
use of org.bimserver.plugins.services.BimServerClientInterface in project BIMserver by opensourceBIM.
the class TestProtocolBuffers method main.
public static void main(String[] args) {
try {
BimServerClientInterface client = LocalDevSetup.setupSoap("http://localhost:8080");
System.out.println(client.getServiceInterface().getAllProjects(true, true));
} catch (ServiceException e) {
e.printStackTrace();
} catch (PublicInterfaceNotFoundException e) {
e.printStackTrace();
}
}
use of org.bimserver.plugins.services.BimServerClientInterface in project BIMserver by opensourceBIM.
the class TestGuid method main.
public static void main(String[] args) {
BimServerClientInterface client = LocalDevSetup.setupJson("http://localhost:8080");
try {
SProject project = client.getServiceInterface().addProject("testProject2", "ifc2x3tc1");
Long tid = client.getLowLevelInterface().startTransaction(project.getOid());
client.getLowLevelInterface().createObject(tid, "IfcWall", false);
Long roid = client.getLowLevelInterface().commitTransaction(tid, "test commit");
SSerializerPluginConfiguration serializer = client.getServiceInterface().getSerializerByContentType("application/ifc");
client.download(roid, serializer.getOid(), Paths.get("test2.ifc"));
} catch (ServerException | UserException | PublicInterfaceNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (BimServerClientException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Aggregations