use of org.bimserver.models.store.ConcreteRevision in project BIMserver by opensourceBIM.
the class AdminServiceImpl method regenerateGeometry.
@Override
public void regenerateGeometry(Long croid) throws ServerException, UserException {
LOGGER.info("Regenerating geometry for concrete revision" + croid);
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
// Normally we wouldn't be allowed to change existing data
session.setOverwriteEnabled(true);
ConcreteRevision concreteRevision = session.get(StorePackage.eINSTANCE.getConcreteRevision(), croid, OldQuery.getDefault());
PackageMetaData packageMetaData = getBimServer().getMetaDataManager().getPackageMetaData(concreteRevision.getProject().getSchema());
IfcModelInterface model = new BasicIfcModel(packageMetaData, null);
session.getMap(model, new OldQuery(packageMetaData, concreteRevision.getProject().getId(), concreteRevision.getId(), -1));
User user = session.get(getAuthorization().getUoid(), OldQuery.getDefault());
UserSettings userSettings = user.getUserSettings();
RenderEnginePluginConfiguration defaultRenderEngine = userSettings.getDefaultRenderEngine();
if (defaultRenderEngine == null) {
throw new BimBotsException("No default render engine has been selected for this user");
}
RenderEnginePool pool = getBimServer().getRenderEnginePools().getRenderEnginePool(model.getPackageMetaData().getSchema(), defaultRenderEngine.getPluginDescriptor().getPluginClassName(), new PluginConfiguration(defaultRenderEngine.getSettings()));
new GeometryGenerator(getBimServer()).generateGeometry(pool, getBimServer().getPluginManager(), session, model, concreteRevision.getProject().getId(), concreteRevision.getId(), true, null);
session.commit();
} catch (Exception e) {
handleException(e);
} finally {
session.close();
}
}
use of org.bimserver.models.store.ConcreteRevision in project BIMserver by opensourceBIM.
the class BimServer method cleanupStaleData.
private void cleanupStaleData() throws BimserverDatabaseException {
long s = System.nanoTime();
try (DatabaseSession session = bimDatabase.createSession()) {
for (Project project : session.getAll(Project.class)) {
int recordsRemoved = 0;
if (project.getName().equals("INT-Store")) {
continue;
}
if (project.getRevisions().size() == 0) {
recordsRemoved += checkPidRid(session, project, project.getId(), 0);
} else {
ConcreteRevision lastConcreteRevision = project.getLastConcreteRevision();
if (lastConcreteRevision != null) {
recordsRemoved += checkPidRid(session, project, project.getId(), lastConcreteRevision.getId());
}
}
if (recordsRemoved > 0) {
LOGGER.info("Removed " + recordsRemoved + " stale records for project " + project.getName());
}
}
}
long e = System.nanoTime();
LOGGER.info("Checking for stale records took " + ((e - s) / 1000000) + " ms");
}
Aggregations