use of org.bimserver.models.store.Revision in project BIMserver by opensourceBIM.
the class CompareDatabaseAction method getModelCompare.
public org.bimserver.plugins.modelcompare.ModelCompare getModelCompare() throws ModelCompareException, BimserverDatabaseException {
Revision revision1 = getDatabaseSession().get(roid1, OldQuery.getDefault());
Revision revision2 = getDatabaseSession().get(roid2, OldQuery.getDefault());
PackageMetaData packageMetaData = bimServer.getMetaDataManager().getPackageMetaData(revision1.getProject().getSchema());
if (revision1.getProject().getSchema().equals(revision2.getProject().getSchema())) {
ModelComparePluginConfiguration modelCompareObject = getDatabaseSession().get(StorePackage.eINSTANCE.getModelComparePluginConfiguration(), mcid, OldQuery.getDefault());
if (modelCompareObject != null) {
ModelComparePlugin modelComparePlugin = bimServer.getPluginManager().getModelComparePlugin(modelCompareObject.getPluginDescriptor().getPluginClassName(), true);
if (modelComparePlugin != null) {
org.bimserver.plugins.modelcompare.ModelCompare modelCompare = modelComparePlugin.createModelCompare(new PluginConfiguration(modelCompareObject.getSettings()), packageMetaData);
return modelCompare;
} else {
throw new ModelCompareException("No Model Compare found " + modelCompareObject.getPluginDescriptor().getPluginClassName());
}
} else {
throw new ModelCompareException("No configured Model Compare found");
}
} else {
throw new ModelCompareException("Not the same schema");
}
}
use of org.bimserver.models.store.Revision in project BIMserver by opensourceBIM.
the class DownloadQueryDatabaseAction method execute.
@Override
public IfcModelInterface execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException, ServerException {
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
SerializerPluginConfiguration serializerPluginConfiguration = getDatabaseSession().get(StorePackage.eINSTANCE.getSerializerPluginConfiguration(), serializerOid, OldQuery.getDefault());
BimDatabaseAction<IfcModelInterface> action = new DownloadDatabaseAction(getBimServer(), session, AccessMethod.INTERNAL, roid, -1, serializerPluginConfiguration.getOid(), getAuthorization(), null);
IfcModelInterface ifcModel = session.executeAndCommitAction(action);
QueryEnginePluginConfiguration queryEngineObject = session.get(StorePackage.eINSTANCE.getQueryEnginePluginConfiguration(), qeid, OldQuery.getDefault());
Revision revision = session.get(roid, OldQuery.getDefault());
PackageMetaData packageMetaData = getBimServer().getMetaDataManager().getPackageMetaData(revision.getProject().getSchema());
if (objectIDM == null) {
objectIDM = new HideAllInversesObjectIDM(CollectionUtils.singleSet(Ifc2x3tc1Package.eINSTANCE), packageMetaData);
}
if (queryEngineObject != null) {
QueryEnginePlugin queryEnginePlugin = getBimServer().getPluginManager().getQueryEngine(queryEngineObject.getPluginDescriptor().getPluginClassName(), true);
if (queryEnginePlugin != null) {
QueryEngine queryEngine = queryEnginePlugin.getQueryEngine(new PluginConfiguration(queryEngineObject.getSettings()));
final IfcModelInterface result = new ServerIfcModel(packageMetaData, null, getDatabaseSession());
ModelHelper modelHelper = new ModelHelper(getBimServer().getMetaDataManager(), objectIDM, result);
modelHelper.setOidProvider(new OidProvider() {
private long oid = 1000000;
@Override
public long newOid(EClass eClass) {
return oid++;
}
});
IfcModelInterface finalResult = queryEngine.query(ifcModel, code, new Reporter() {
@Override
public void error(Throwable error) {
}
@Override
public void warning(String warning) {
}
@Override
public void info(String info) {
}
}, modelHelper);
return finalResult;
} else {
throw new UserException("No Query Engine found " + queryEngineObject.getPluginDescriptor().getPluginClassName());
}
} else {
throw new UserException("No configured query engine found with qeid " + qeid);
}
} catch (BimserverDatabaseException e) {
throw new UserException(e);
} catch (QueryEngineException e) {
throw new UserException(e);
} catch (PluginException e) {
throw new UserException(e);
} finally {
session.close();
}
}
use of org.bimserver.models.store.Revision in project BIMserver by opensourceBIM.
the class GenericCheckinDatabaseAction method createNewVirtualRevision.
private Revision createNewVirtualRevision(DatabaseSession session, Project project, ConcreteRevision concreteRevision, String comment, Date date, User user, long size) throws BimserverLockConflictException, BimserverDatabaseException {
Revision revision = session.create(Revision.class);
revision.setLastConcreteRevision(concreteRevision);
revision.setComment(comment);
revision.setDate(date);
revision.setUser(user);
user.getRevisions().add(revision);
revision.setSize(size);
revision.setId(project.getRevisions().size() + 1);
revision.getConcreteRevisions().add(concreteRevision);
revision.setProject(project);
return revision;
}
use of org.bimserver.models.store.Revision in project BIMserver by opensourceBIM.
the class GenericCheckinDatabaseAction method createNewConcreteRevision.
public CreateRevisionResult createNewConcreteRevision(DatabaseSession session, long size, Project project, User user, String comment) throws BimserverDatabaseException, BimserverLockConflictException {
CreateRevisionResult result = new CreateRevisionResult();
ConcreteRevision concreteRevision = getDatabaseSession().create(ConcreteRevision.class);
concreteRevision.setSize(size);
Date date = new Date();
concreteRevision.setDate(date);
concreteRevision.setId(project.getConcreteRevisions().size() + 1);
concreteRevision.setUser(user);
concreteRevision.setProject(project);
project.setLastConcreteRevision(concreteRevision);
Revision newRevision = createNewVirtualRevision(session, project, concreteRevision, comment, date, user, size);
for (Checkout checkout : project.getCheckouts()) {
if (checkout.getUser() == user) {
checkout.setActive(false);
session.store(checkout);
}
}
project.setLastRevision(newRevision);
Project parent = project.getParent();
result.addRevision(newRevision);
while (parent != null) {
Revision revision = getDatabaseSession().create(Revision.class);
result.addRevision(revision);
revision.setComment("generated for subproject " + project.getName() + ", revision " + concreteRevision.getId() + ", by " + user.getName());
revision.setDate(date);
revision.setUser(getSystemUser());
revision.setProject(parent);
if (parent.getLastRevision() != null) {
Revision lastRevision = parent.getLastRevision();
for (ConcreteRevision oldRevision : lastRevision.getConcreteRevisions()) {
if (oldRevision.getProject() != project && oldRevision.getProject() != parent) {
revision.getConcreteRevisions().add(oldRevision);
revision.setSize((revision.getSize() == null ? 0 : revision.getSize()) + oldRevision.getSize());
session.store(revision);
session.store(oldRevision);
}
}
}
revision.getConcreteRevisions().add(concreteRevision);
revision.setSize((revision.getSize() == null ? 0 : revision.getSize()) + concreteRevision.getSize());
revision.setLastConcreteRevision(concreteRevision);
if (parent.getLastRevision() == null) {
revision.setId(1);
} else {
revision.setId(parent.getLastRevision().getId() + 1);
}
parent.setLastRevision(revision);
session.store(revision);
session.store(parent);
parent = parent.getParent();
}
session.store(project);
session.store(user);
session.store(concreteRevision);
result.setConcreteRevision(concreteRevision);
return result;
}
use of org.bimserver.models.store.Revision in project BIMserver by opensourceBIM.
the class GetAllCheckoutsOfRevisionDatabaseAction method execute.
@Override
public List<Checkout> execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
Revision revision = getRevisionByRoid(roid);
Condition condition = new HasReferenceToCondition(StorePackage.eINSTANCE.getCheckout_Revision(), revision);
return CollectionUtils.mapToList(getDatabaseSession().query(condition, Checkout.class, OldQuery.getDefault()));
}
Aggregations