use of org.bimserver.models.store.Revision 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.Revision in project BIMserver by opensourceBIM.
the class LongDownloadOrCheckoutAction method executeAction.
protected void executeAction(BimDatabaseAction<? extends IfcModelInterface> action, DownloadParameters downloadParameters, DatabaseSession session, boolean commit) throws BimserverDatabaseException, UserException, NoSerializerFoundException, ServerException {
try {
if (action == null) {
checkoutResult = new SCheckoutResult();
checkoutResult.setFile(new CachingDataHandler(getBimServer().getDiskCacheManager(), downloadParameters));
checkoutResult.setSerializerOid(downloadParameters.getSerializerOid());
} else {
Revision revision = session.get(StorePackage.eINSTANCE.getRevision(), downloadParameters.getRoid(), OldQuery.getDefault());
if (revision == null) {
throw new UserException("Revision with roid " + downloadParameters.getRoid() + " not found");
}
// Little hack to make
revision.getProject().getGeoTag().load();
// sure this is
// lazily loaded,
// because after the
// executeAndCommitAction
// the session won't
// be usable
IfcModelInterface ifcModel = session.executeAndCommitAction(action);
// Session is closed after this
DatabaseSession newSession = getBimServer().getDatabase().createSession();
RenderEnginePlugin renderEnginePlugin = null;
try {
PluginConfiguration serializerPluginConfiguration = newSession.get(StorePackage.eINSTANCE.getPluginConfiguration(), downloadParameters.getSerializerOid(), OldQuery.getDefault());
if (serializerPluginConfiguration != null) {
if (serializerPluginConfiguration instanceof MessagingSerializerPluginConfiguration) {
try {
messagingSerializer = getBimServer().getSerializerFactory().createMessagingSerializer(getUserName(), ifcModel, downloadParameters);
} catch (SerializerException e) {
e.printStackTrace();
}
} else if (serializerPluginConfiguration instanceof SerializerPluginConfiguration) {
RenderEnginePluginConfiguration renderEngine = ((SerializerPluginConfiguration) serializerPluginConfiguration).getRenderEngine();
if (renderEngine != null) {
renderEnginePlugin = getBimServer().getPluginManager().getRenderEnginePlugin(renderEngine.getPluginDescriptor().getPluginClassName(), true);
}
checkoutResult = convertModelToCheckoutResult(revision.getProject(), getUserName(), ifcModel, renderEnginePlugin, downloadParameters);
}
}
} catch (BimserverDatabaseException e) {
LOGGER.error("", e);
} finally {
newSession.close();
}
}
} finally {
done();
}
}
use of org.bimserver.models.store.Revision in project BIMserver by opensourceBIM.
the class NewRevisionNotification method process.
@Override
public void process() throws BimserverDatabaseException, UserException, ServerException {
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
Project project = session.get(StorePackage.eINSTANCE.getProject(), poid, OldQuery.getDefault());
if (project == null) {
LOGGER.error("Project with oid " + poid + " not found");
return;
}
Revision revision = session.get(StorePackage.eINSTANCE.getRevision(), roid, OldQuery.getDefault());
if (revision == null) {
LOGGER.error("Revision with roid " + roid + " not found");
return;
}
if (project.isSendEmailOnNewRevision() && sendEmail) {
sendEmail(session, project, revision);
}
for (NewService newService : project.getNewServices()) {
if (soid == -1 || newService.getOid() == soid) {
triggerNewRevision(session, getBimServer().getNotificationsManager(), getBimServer(), getBimServer().getNotificationsManager().getSiteAddress(), project, roid, Trigger.NEW_REVISION, newService);
}
}
for (Service service : project.getServices()) {
if (soid == -1 || service.getOid() == soid) {
triggerNewRevision(session, getBimServer().getNotificationsManager(), getBimServer(), getBimServer().getNotificationsManager().getSiteAddress(), project, roid, Trigger.NEW_REVISION, service);
}
}
if (soid == -1) {
// Only execute if we are not triggering a specific service with this notification
NewRevisionTopic newRevisionTopic = getBimServer().getNotificationsManager().getNewRevisionTopic();
if (newRevisionTopic != null) {
newRevisionTopic.process(session, poid, roid, this);
}
NewRevisionOnSpecificProjectTopic newRevisionOnSpecificProjectTopic = getBimServer().getNotificationsManager().getNewRevisionOnSpecificProjectTopic(new NewRevisionOnSpecificProjectTopicKey(poid));
if (newRevisionOnSpecificProjectTopic != null) {
newRevisionOnSpecificProjectTopic.process(session, poid, roid, this);
}
}
} finally {
session.close();
}
}
use of org.bimserver.models.store.Revision in project BIMserver by opensourceBIM.
the class GetAllRevisionsByUserDatabaseAction method execute.
@Override
public Set<Revision> execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
User user = getUserByUoid(uoid);
Condition condition = new HasReferenceToCondition(StorePackage.eINSTANCE.getRevision_User(), user);
return CollectionUtils.mapToSet(getDatabaseSession().query(condition, Revision.class, OldQuery.getDefault()));
}
use of org.bimserver.models.store.Revision in project BIMserver by opensourceBIM.
the class GetCheckinWarningsDatabaseAction method checkInterleavingCommits.
private void checkInterleavingCommits(Project project, User user, Set<String> warnings) {
Checkout lastOwnActiveCheckout = null;
for (Checkout checkout : project.getCheckouts()) {
if (checkout.getUser() == user && checkout.getActive()) {
lastOwnActiveCheckout = checkout;
}
}
if (lastOwnActiveCheckout != null) {
Project mainProject = project;
while (mainProject.getParent() != null) {
mainProject = mainProject.getParent();
}
int newRevisionsAfterCheckout = 0;
for (Revision virtualRevision : mainProject.getRevisions()) {
if (lastOwnActiveCheckout.getDate().before(virtualRevision.getDate()) && lastOwnActiveCheckout.getRevision() != virtualRevision) {
newRevisionsAfterCheckout++;
}
}
if (newRevisionsAfterCheckout == 1) {
warnings.add("Warning, after your last checkout of this project (revision " + lastOwnActiveCheckout.getRevision().getId() + "), a new revision has been checked-in");
} else if (newRevisionsAfterCheckout > 1) {
warnings.add("Warning, after your last checkout of this project (revision " + lastOwnActiveCheckout.getRevision().getId() + "), " + newRevisionsAfterCheckout + " new revisions have been checked-in");
}
}
}
Aggregations