use of org.bimserver.plugins.services.BimServerClientInterface in project BIMserver by opensourceBIM.
the class TestMultiple method main.
public static void main(String[] args) throws InterruptedException {
try (BimServerClientFactory factory = new JsonBimServerClientFactory("http://localhost:8080")) {
BimServerClientInterface client = factory.create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
ThreadPoolExecutor executor = new ThreadPoolExecutor(2, 2, 1, TimeUnit.DAYS, new ArrayBlockingQueue<>(2));
for (int i = 0; i < 2; i++) {
executor.submit(new Runnable() {
@Override
public void run() {
try {
SProject project = client.getServiceInterface().addProject("P" + new Random().nextInt(), "ifc2x3tc1");
SDeserializerPluginConfiguration deserializer = client.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
client.checkin(project.getOid(), "Test", deserializer.getOid(), false, Flow.ASYNC, Paths.get("C:\\Git\\TestFiles\\TestData\\data\\HITOS_070308.ifc"));
} catch (ServerException e) {
e.printStackTrace();
} catch (UserException e) {
e.printStackTrace();
} catch (PublicInterfaceNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
});
}
executor.shutdown();
executor.awaitTermination(1, TimeUnit.HOURS);
} catch (BimServerClientException e) {
e.printStackTrace();
} catch (ServiceException e) {
e.printStackTrace();
} catch (ChannelConnectionException e) {
e.printStackTrace();
} catch (Exception e1) {
e1.printStackTrace();
}
}
use of org.bimserver.plugins.services.BimServerClientInterface in project BIMserver by opensourceBIM.
the class TestNotification method main.
@SuppressWarnings("unused")
public static void main(String[] args) {
try {
BimServerClientInterface client = LocalDevSetup.setupJson("http://localhost:8080");
// SProject newProject = client.getServiceInterface().addProject("test" + Math.random());
// SDeserializerPluginConfiguration deserializerByName = client.getServiceInterface().getDeserializerByName("IfcStepDeserializer");
// client.checkin(newProject.getOid(), "test", deserializerByName.getOid(), false, true, new File("../TestData/data/AC11-Institute-Var-2-IFC.ifc"));
// newProject = client.getServiceInterface().getProjectByPoid(newProject.getOid());
SProject project = client.getServiceInterface().getProjectByPoid(458753L);
SSerializerPluginConfiguration geometrySerializer = client.getServiceInterface().getSerializerByName("JsonGeometrySerializer");
for (int i = 0; i < 100; i++) {
// final CountDownLatch countDownLatch = new CountDownLatch(1);
// final Long downloadByTypes = client.getServiceInterface().downloadByTypes(Collections.singleton(project.getLastRevisionId()), "ifc2x3tc1", Collections.singleton("IfcWindow"), geometrySerializer.getOid(), true, false, false, false);
// final ProgressHandler progressHandler = new ProgressHandler() {
// @Override
// public void progress(SLongActionState state) {
// if (state.getProgress() == 100) {
// countDownLatch.countDown();
// }
// }
// };
// client.getNotificationsManager().registerProgressHandler(downloadByTypes, progressHandler);
// try {
// countDownLatch.await(20, TimeUnit.SECONDS);
// client.getNotificationsManager().unregisterProgressHandler(downloadByTypes, progressHandler);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
}
client.disconnect();
System.out.println("Done");
} catch (ServiceException e) {
e.printStackTrace();
} catch (PublicInterfaceNotFoundException e) {
e.printStackTrace();
}
}
use of org.bimserver.plugins.services.BimServerClientInterface in project BIMserver by opensourceBIM.
the class FileLoader method load.
private void load(Path dir) {
// JsonBimServerClientFactory factory = new JsonBimServerClientFactory("http://sandbox.bimserver.org");
try {
final BimServerClientInterface client = LocalDevSetup.setupJson("http://localhost:8080");
ExecutorService executorService = new ThreadPoolExecutor(1, 1, 1, TimeUnit.HOURS, new ArrayBlockingQueue<Runnable>(200));
for (final Path file : PathUtils.list(dir)) {
executorService.submit(new Runnable() {
@Override
public void run() {
System.out.println(file.getFileName());
SProject project;
try {
project = client.getServiceInterface().addProject(file.getFileName().toString(), "ifc2x3tc1");
SDeserializerPluginConfiguration deserializer = client.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
client.checkin(project.getOid(), file.getFileName().toString(), deserializer.getOid(), false, Flow.SYNC, file);
} catch (ServerException e) {
e.printStackTrace();
} catch (UserException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (PublicInterfaceNotFoundException e) {
e.printStackTrace();
}
}
});
}
executorService.awaitTermination(1, TimeUnit.HOURS);
System.out.println("Done");
} catch (InterruptedException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
use of org.bimserver.plugins.services.BimServerClientInterface in project BIMserver by opensourceBIM.
the class RegenerateGeometry method start.
private void start() {
try {
BimServerClientInterface client = LocalDevSetup.setupJson("http://localhost:8080");
List<SProject> allProjects = client.getServiceInterface().getAllProjects(false, true);
Set<Long> croids = new HashSet<Long>();
for (SProject project : allProjects) {
for (Long roid : project.getRevisions()) {
SRevision revision = client.getServiceInterface().getRevision(roid);
for (long croid : revision.getConcreteRevisions()) {
croids.add(croid);
}
}
}
for (long croid : croids) {
client.getAdminInterface().regenerateGeometry(croid);
}
System.out.println("Done");
} catch (ServiceException e) {
e.printStackTrace();
} catch (PublicInterfaceNotFoundException e) {
e.printStackTrace();
}
}
use of org.bimserver.plugins.services.BimServerClientInterface in project BIMserver by opensourceBIM.
the class TestUploadSameModelALot method start.
private void start() {
try {
BimServerClientInterface client = LocalDevSetup.setupJson("http://localhost:8080");
client.getSettingsInterface().setGenerateGeometryOnCheckin(false);
for (int i = 0; i < 20; i++) {
SProject project = client.getServiceInterface().addProject("P" + i, "ifc2x3tc1");
SDeserializerPluginConfiguration deserializerForExtension = client.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
System.out.println(i);
client.checkin(project.getOid(), "C" + i, deserializerForExtension.getOid(), false, Flow.SYNC, Paths.get("../TestData/data/AC11-FZK-Haus-IFC.ifc"));
}
} catch (ServiceException e) {
e.printStackTrace();
} catch (PublicInterfaceNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
Aggregations