use of org.bimserver.database.query.conditions.HasReferenceToCondition in project BIMserver by opensourceBIM.
the class GetAllCheckoutsByUserDatabaseAction method execute.
@Override
public List<Checkout> execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
User user = getUserByUoid(uoid);
Condition condition = new HasReferenceToCondition(StorePackage.eINSTANCE.getCheckout_User(), user);
// condition = condition.and(new AttributeCondition(StorePackage.eINSTANCE.getCheckout_Active(), new BooleanLiteral(true)));
Map<Long, Checkout> query = getDatabaseSession().query(condition, Checkout.class, OldQuery.getDefault());
return CollectionUtils.mapToList(query);
}
use of org.bimserver.database.query.conditions.HasReferenceToCondition in project BIMserver by opensourceBIM.
the class GetAllNonAuthorizedUsersOfProjectDatabaseAction method execute.
@Override
public Set<User> execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
Project project = getProjectByPoid(poid);
if (project == null) {
throw new UserException("No Project with oid " + poid + " found");
}
Condition condition = new AndCondition(new AndCondition(new Not(new HasReferenceToCondition(StorePackage.eINSTANCE.getUser_HasRightsOn(), project)), new AttributeCondition(StorePackage.eINSTANCE.getUser_State(), new EnumLiteral(ObjectState.ACTIVE))), new Not(new AttributeCondition(StorePackage.eINSTANCE.getUser_UserType(), new EnumLiteral(UserType.SYSTEM))));
return CollectionUtils.mapToSet(getDatabaseSession().query(condition, User.class, OldQuery.getDefault()));
}
use of org.bimserver.database.query.conditions.HasReferenceToCondition in project BIMserver by opensourceBIM.
the class GetAllProjectsDatabaseAction method execute.
@Override
public Set<Project> execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
User user = getUserByUoid(authorization.getUoid());
Not notStoreProject = new Not(new AttributeCondition(StorePackage.eINSTANCE.getProject_Name(), new StringLiteral(Database.STORE_PROJECT_NAME)));
HasReferenceToCondition authorized = new HasReferenceToCondition(StorePackage.eINSTANCE.getProject_HasAuthorizedUsers(), user);
Condition condition = new IsOfTypeCondition(StorePackage.eINSTANCE.getProject()).and(notStoreProject);
// }
if (onlyActive) {
condition = new AndCondition(condition, new AttributeCondition(StorePackage.eINSTANCE.getProject_State(), new EnumLiteral(ObjectState.ACTIVE)));
}
if (user.getUserType() != UserType.ADMIN && user.getUserType() != UserType.SYSTEM) {
condition = condition.and(authorized);
condition = condition.and(new AttributeCondition(StorePackage.eINSTANCE.getProject_State(), new EnumLiteral(ObjectState.ACTIVE)));
}
Map<Long, Project> results = getDatabaseSession().query(condition, Project.class, OldQuery.getDefault());
Set<Project> resultSet = new HashSet<Project>();
for (Project p : results.values()) {
if (p.getParent() == null || !onlyTopLevel) {
resultSet.add(p);
}
}
for (Project project : results.values()) {
addParentProjects(resultSet, project);
}
return resultSet;
}
use of org.bimserver.database.query.conditions.HasReferenceToCondition 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.database.query.conditions.HasReferenceToCondition 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