use of org.bimserver.bimbots.BimBotsInput in project BIMserver by opensourceBIM.
the class BimBotClient method main.
public static void main(String[] args) {
try (BimBotClient bimBotCaller = new BimBotClient("http://localhost:8080/services", "a70abb752c5a04f5ccce7ea1b79b85c045c594c3d7fb23d6f28e8e8ad04f2750477ec5706013f2bc07be2b9555fd44df")) {
BimBotsInput bimBotsInput = new BimBotsInput(SchemaName.IFC_STEP_2X3TC1, Files.toByteArray(new File("C:\\Git\\TestFiles\\TestData\\data\\export3.ifc")));
BimBotsOutput bimBotsOutput = bimBotCaller.call("3866702", bimBotsInput);
ObjectNode readValue = new ObjectMapper().readValue(bimBotsOutput.getData(), ObjectNode.class);
System.out.println(readValue.toString());
} catch (IOException e) {
e.printStackTrace();
} catch (BimBotExecutionException e) {
e.printStackTrace();
}
}
use of org.bimserver.bimbots.BimBotsInput in project BIMserver by opensourceBIM.
the class BimBotAbstractService method newRevision.
@Override
public void newRevision(RunningService runningService, BimServerClientInterface bimServerClientInterface, long poid, long roid, String userToken, long soid, SObjectType settings) throws Exception {
try {
long start = System.nanoTime();
byte[] data = null;
if (needsRawInput()) {
// We need to generate some, by serializing the current model
SSerializerPluginConfiguration serializerByContentType = bimServerClientInterface.getServiceInterface().getSerializerByContentType("application/ifc");
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
bimServerClientInterface.download(roid, serializerByContentType.getOid(), outputStream);
data = outputStream.toByteArray();
}
BimBotsInput input = new BimBotsInput(SchemaName.IFC_STEP_2X3TC1, data);
SProject project = bimServerClientInterface.getServiceInterface().getProjectByPoid(poid);
String contextId = project.getUuid().toString();
IfcModelInterface model = bimServerClientInterface.getModel(project, roid, preloadCompleteModel(), false, requiresGeometry());
input.setIfcModel(model);
BimBotContext bimBotContext = new BimBotContext() {
@Override
public void updateProgress(String label, int percentage) {
}
@Override
public String getCurrentUser() {
return runningService.getCurrentUser();
}
@Override
public String getContextId() {
return contextId;
}
};
BimBotsOutput output = runBimBot(input, bimBotContext, new PluginConfiguration(settings));
long end = System.nanoTime();
if (output.getSchemaName().contentEquals(SchemaName.IFC_STEP_2X3TC1.name()) || output.getSchemaName().contentEquals(SchemaName.IFC_STEP_4.name())) {
// There is no point in storing the retuned model as extended data, lets make a new revision
output.getModel().checkin(poid, output.getTitle());
} else {
SFile file = new SFile();
SExtendedData extendedData = new SExtendedData();
extendedData.setTimeToGenerate((end - start) / 1000000);
extendedData.setTitle(output.getTitle());
extendedData.setSize(output.getData().length);
file.setFilename(output.getContentDisposition());
SExtendedDataSchema extendedDataSchemaByName = null;
try {
extendedDataSchemaByName = bimServerClientInterface.getServiceInterface().getExtendedDataSchemaByName(output.getSchemaName());
} catch (Exception e) {
extendedDataSchemaByName = new SExtendedDataSchema();
extendedDataSchemaByName.setContentType(output.getContentType());
extendedDataSchemaByName.setName(output.getSchemaName());
bimServerClientInterface.getServiceInterface().addExtendedDataSchema(extendedDataSchemaByName);
}
extendedData.setSchemaId(extendedDataSchemaByName.getOid());
file.setData(output.getData());
file.setSize(output.getData().length);
file.setMime(output.getContentType());
long fileId = bimServerClientInterface.getServiceInterface().uploadFile(file);
extendedData.setFileId(fileId);
bimServerClientInterface.getServiceInterface().addExtendedDataToRevision(roid, extendedData);
}
} catch (BimBotsException e) {
LOGGER.error("", e);
} catch (Throwable e) {
LOGGER.error("", e);
}
}
Aggregations