use of org.bimserver.GeometryGeneratingException in project BIMserver by opensourceBIM.
the class RegenerateGeometryDatabaseAction method execute.
@Override
public Void execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException, ServerException {
ProgressListener progressListener = new ProgressListener() {
@Override
public void updateProgress(String state, int percentage) {
setProgress("Generating geometry...", percentage);
}
};
GeometryGenerationReport report = new GeometryGenerationReport();
report.setOriginalIfcFileName("rerun");
report.setOriginalIfcFileSize(-1);
report.setOriginalDeserializer("rerun");
StreamingGeometryGenerator streamingGeometryGenerator = new StreamingGeometryGenerator(bimServer, progressListener, eoid, report);
Revision revision = getDatabaseSession().get(roid, OldQuery.getDefault());
ConcreteRevision concreteRevision = revision.getConcreteRevisions().get(0);
PackageMetaData packageMetaData = bimServer.getMetaDataManager().getPackageMetaData(revision.getProject().getSchema());
int highestStopId = AbstractDownloadDatabaseAction.findHighestStopRid(concreteRevision.getProject(), concreteRevision);
QueryContext queryContext = new QueryContext(getDatabaseSession(), packageMetaData, revision.getProject().getId(), revision.getId(), roid, concreteRevision.getOid(), highestStopId);
try {
// TODO get the actual amount of products
GenerateGeometryResult generateGeometry = streamingGeometryGenerator.generateGeometry(uoid, getDatabaseSession(), queryContext, 1000);
for (Revision other : concreteRevision.getRevisions()) {
other.setHasGeometry(true);
}
concreteRevision.setMultiplierToMm(generateGeometry.getMultiplierToMm());
concreteRevision.setBounds(generateGeometry.getBounds());
concreteRevision.setBoundsUntransformed(generateGeometry.getBoundsUntransformed());
byte[] htmlBytes = report.toHtml().getBytes(Charsets.UTF_8);
byte[] jsonBytes = report.toJson().toString().getBytes(Charsets.UTF_8);
storeExtendedData(htmlBytes, "text/html", "html", revision);
storeExtendedData(jsonBytes, "application/json", "json", revision);
getDatabaseSession().store(revision);
getDatabaseSession().store(concreteRevision);
renderEngineName = streamingGeometryGenerator.getRenderEngineName();
} catch (GeometryGeneratingException e) {
e.printStackTrace();
}
return null;
}
Aggregations