use of org.bimserver.interfaces.objects.SDeserializerPluginConfiguration 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.SDeserializerPluginConfiguration 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.SDeserializerPluginConfiguration 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.interfaces.objects.SDeserializerPluginConfiguration 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();
}
}
use of org.bimserver.interfaces.objects.SDeserializerPluginConfiguration in project BIMserver by opensourceBIM.
the class Tmp method main.
public static void main(String[] args) {
BimServerClientInterface bimServerClient = LocalDevSetup.setupJson("http://localhost:8080");
// Create a project
try {
SProject project = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
// Look for a deserializer
SDeserializerPluginConfiguration deserializer = bimServerClient.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
// Checkin file
bimServerClient.checkin(project.getOid(), "test", deserializer.getOid(), false, Flow.SYNC, Paths.get("../TestData/data/AC11-Institute-Var-2-IFC.ifc"));
// Refresh project
project = bimServerClient.getServiceInterface().getProjectByPoid(project.getOid());
// Load model without lazy loading (complete model at once)
IfcModelInterface model = bimServerClient.getModel(project, project.getLastRevisionId(), false, false);
System.out.println(model.getAllWithSubTypes(IfcWall.class).size());
} catch (ServerException | UserException | PublicInterfaceNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (BimServerClientException e) {
e.printStackTrace();
}
}
Aggregations