use of org.bimserver.models.store.ConcreteRevision in project BIMserver by opensourceBIM.
the class LowLevelServiceImpl method startTransaction.
@Override
public Long startTransaction(Long poid) throws UserException, ServerException {
requireAuthenticationAndRunningServer();
DatabaseSession session = getBimServer().getDatabase().createSession();
int pid = -1;
int rid = -1;
long roid = -1;
try {
Project project = (Project) session.get(poid, OldQuery.getDefault());
if (project == null) {
throw new UserException("No project found with poid " + poid);
}
pid = project.getId();
if (project.getLastRevision() != null) {
Revision revision = project.getLastRevision();
ConcreteRevision lastConcreteRevision = revision.getLastConcreteRevision();
rid = lastConcreteRevision.getId();
roid = revision.getOid();
}
LongTransaction longTransaction = getBimServer().getLongTransactionManager().newLongTransaction(getBimServer().getMetaDataManager().getPackageMetaData(project.getSchema()), poid, pid, rid, roid);
return longTransaction.getTid();
} catch (Exception e) {
return handleException(e);
} finally {
session.close();
}
}
use of org.bimserver.models.store.ConcreteRevision in project BIMserver by opensourceBIM.
the class PluginServiceImpl method getAllSerializersForRoids.
@Override
public List<SSerializerPluginConfiguration> getAllSerializersForRoids(Boolean onlyEnabled, Set<Long> roids) throws ServerException, UserException {
requireRealUserAuthentication();
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
Set<Long> poids = new HashSet<>();
for (Long roid : roids) {
Revision revision = session.get(roid, OldQuery.getDefault());
for (ConcreteRevision concreteRevision : revision.getConcreteRevisions()) {
poids.add(concreteRevision.getProject().getOid());
}
}
return getAllSerializersForPoids(onlyEnabled, poids);
} catch (Exception e) {
handleException(e);
} finally {
session.close();
}
return null;
}
use of org.bimserver.models.store.ConcreteRevision in project BIMserver by opensourceBIM.
the class GetDataObjectByGuidDatabaseAction method execute.
@Override
public DataObject execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
Revision virtualRevision = getRevisionByRoid(roid);
ObjectIdentifier objectIdentifier = null;
for (ConcreteRevision concreteRevision : virtualRevision.getConcreteRevisions()) {
objectIdentifier = getDatabaseSession().getOidOfGuid(concreteRevision.getProject().getSchema(), guid, concreteRevision.getProject().getId(), concreteRevision.getId());
if (objectIdentifier != null) {
long oidOfGuid = objectIdentifier.getOid();
if (oidOfGuid != -1) {
break;
}
}
}
if (objectIdentifier == null) {
throw new UserException("Guid " + guid + " not found in this revision/project");
}
return new GetDataObjectByOidDatabaseAction(bimServer, getDatabaseSession(), getAccessMethod(), roid, objectIdentifier.getOid(), authorization).execute();
}
use of org.bimserver.models.store.ConcreteRevision in project BIMserver by opensourceBIM.
the class GetOidByGuidDatabaseAction method execute.
@Override
public Long execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
Revision virtualRevision = getRevisionByRoid(roid);
ObjectIdentifier objectIdentifier = null;
for (ConcreteRevision concreteRevision : virtualRevision.getConcreteRevisions()) {
objectIdentifier = getDatabaseSession().getOidOfGuid(concreteRevision.getProject().getSchema(), guid, concreteRevision.getProject().getId(), concreteRevision.getId());
if (objectIdentifier != null) {
long oidOfGuid = objectIdentifier.getOid();
if (oidOfGuid != -1) {
break;
}
}
}
if (objectIdentifier == null) {
throw new UserException("Guid " + guid + " not found in this revision/project");
}
return objectIdentifier.getOid();
}
use of org.bimserver.models.store.ConcreteRevision in project BIMserver by opensourceBIM.
the class BranchToNewProjectDatabaseAction method execute.
@Override
public ConcreteRevision execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
Revision oldRevision = getDatabaseSession().get(StorePackage.eINSTANCE.getRevision(), roid, OldQuery.getDefault());
Project oldProject = oldRevision.getProject();
final User user = getDatabaseSession().get(StorePackage.eINSTANCE.getUser(), authorization.getUoid(), OldQuery.getDefault());
if (!authorization.hasRightsOnProjectOrSuperProjectsOrSubProjects(user, oldProject)) {
throw new UserException("User has insufficient rights to download revisions from this project");
}
IfcModelSet ifcModelSet = new IfcModelSet();
PackageMetaData lastMetaData = null;
for (ConcreteRevision subRevision : oldRevision.getConcreteRevisions()) {
PackageMetaData packageMetaData = bimServer.getMetaDataManager().getPackageMetaData(subRevision.getProject().getSchema());
if (lastMetaData != null && lastMetaData != packageMetaData) {
throw new UserException("Branching not possible for revision with multiple schemas");
}
IfcModel subModel = new BasicIfcModel(packageMetaData, null);
getDatabaseSession().getMap(subModel, new OldQuery(packageMetaData, subRevision.getProject().getId(), subRevision.getId(), -1, Deep.NO));
subModel.getModelMetaData().setDate(subRevision.getDate());
ifcModelSet.add(subModel);
}
IfcModelInterface model = new BasicIfcModel(lastMetaData, null);
try {
model = bimServer.getMergerFactory().createMerger(getDatabaseSession(), authorization.getUoid()).merge(oldRevision.getProject(), ifcModelSet, new ModelHelper(bimServer.getMetaDataManager(), model));
} catch (MergeException e) {
throw new UserException(e);
}
model.resetOids();
final Project newProject = new AddProjectDatabaseAction(bimServer, getDatabaseSession(), getAccessMethod(), projectName, "ifc2x3tc1", authorization).execute();
CheckinDatabaseAction createCheckinAction = new CheckinDatabaseAction(bimServer, getDatabaseSession(), getAccessMethod(), newProject.getOid(), authorization, model, comment, comment, false, -1);
return createCheckinAction.execute();
}
Aggregations