use of org.bimserver.interfaces.objects.SProject 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.interfaces.objects.SProject in project BIMserver by opensourceBIM.
the class TestNewQueryViaClient method start.
private void start() {
try (JsonBimServerClientFactory factory = new JsonBimServerClientFactory("http://localhost:8080")) {
BimServerClient client = factory.create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
String projectName = "Test " + new Random().nextInt();
SProject project = client.getServiceInterface().addProject(projectName, "ifc2x3tc1");
SDeserializerPluginConfiguration deserializer = client.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
client.checkin(project.getOid(), "Test Model", deserializer.getOid(), false, Flow.SYNC, Paths.get("C:/Git/TestFiles/TestData/data/AC11-FZK-Haus-IFC.ifc"));
project = client.getServiceInterface().getProjectByPoid(project.getOid());
System.out.println(project.getName());
ClientIfcModel model = client.getModel(project, project.getLastRevisionId(), false, false);
Query query = new Query(model.getPackageMetaData());
QueryPart queryPart = query.createQueryPart();
queryPart.addType(Ifc2x3tc1Package.eINSTANCE.getIfcWall(), true);
for (IfcWall ifcWall : model.getAllWithSubTypes(IfcWall.class)) {
System.out.println(ifcWall.getGlobalId());
}
} catch (ServiceException e) {
e.printStackTrace();
} catch (ChannelConnectionException e) {
e.printStackTrace();
} catch (PublicInterfaceNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (BimServerClientException e) {
e.printStackTrace();
} catch (Exception e1) {
e1.printStackTrace();
}
}
use of org.bimserver.interfaces.objects.SProject 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.interfaces.objects.SProject in project BIMserver by opensourceBIM.
the class TestUploadDir method process.
private void process(Path directory, SProject parentProject) throws ServerException, UserException, PublicInterfaceNotFoundException, IOException {
if (Files.isDirectory(directory)) {
SProject project = null;
if (parentProject == null) {
project = client.getServiceInterface().addProject(directory.getFileName().toString(), "ifc2x3tc1");
} else {
project = client.getServiceInterface().addProjectAsSubProject(directory.getFileName().toString(), parentProject.getOid(), "ifc2x3tc1");
}
for (Path file : PathUtils.list(directory)) {
process(file, project);
}
} else {
String lowerCase = directory.getFileName().toString().toLowerCase();
if (lowerCase.endsWith("ifc") || lowerCase.endsWith("ifcxml") || lowerCase.endsWith("ifczip")) {
SDeserializerPluginConfiguration deserializerForExtension = client.getServiceInterface().getSuggestedDeserializerForExtension(directory.getFileName().toString().substring(directory.getFileName().toString().lastIndexOf(".") + 1), parentProject.getOid());
System.out.println("Checking in " + directory.toString() + " - " + Formatters.bytesToString(directory.toFile().length()));
try {
client.checkin(parentProject.getOid(), "", deserializerForExtension.getOid(), false, Flow.SYNC, directory);
} catch (UserException e) {
e.printStackTrace();
}
} else {
System.out.println("Ignoring " + directory.toString());
}
}
}
use of org.bimserver.interfaces.objects.SProject 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();
}
}
Aggregations