Search in sources :

Example 1 with IsOfTypeCondition

use of org.bimserver.database.query.conditions.IsOfTypeCondition in project BIMserver by opensourceBIM.

the class GetAllDatabaseAction method execute.

@Override
public List<T> execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
    Condition condition = new IsOfTypeCondition(eClass);
    Map<Long, T> result = getDatabaseSession().query(condition, clazz, OldQuery.getDefault());
    return CollectionUtils.mapToList(result);
}
Also used : IsOfTypeCondition(org.bimserver.database.query.conditions.IsOfTypeCondition) Condition(org.bimserver.database.query.conditions.Condition) IsOfTypeCondition(org.bimserver.database.query.conditions.IsOfTypeCondition)

Example 2 with IsOfTypeCondition

use of org.bimserver.database.query.conditions.IsOfTypeCondition in project BIMserver by opensourceBIM.

the class GetLogsDatabaseAction method execute.

@Override
public List<LogAction> execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
    User user = getUserByUoid(authorization.getUoid());
    if (user.getUserType() != UserType.ADMIN) {
        throw new UserException("Only admin users can retrieve log");
    }
    Map<Long, LogAction> query = getDatabaseSession().query(new IsOfTypeCondition(LogPackage.eINSTANCE.getLogAction()), LogAction.class, OldQuery.getDefault());
    ArrayList<LogAction> list = new ArrayList<LogAction>(query.values());
    return list;
}
Also used : User(org.bimserver.models.store.User) LogAction(org.bimserver.models.log.LogAction) IsOfTypeCondition(org.bimserver.database.query.conditions.IsOfTypeCondition) ArrayList(java.util.ArrayList) UserException(org.bimserver.shared.exceptions.UserException)

Example 3 with IsOfTypeCondition

use of org.bimserver.database.query.conditions.IsOfTypeCondition in project BIMserver by opensourceBIM.

the class GetAllDeserializersDatabaseAction method execute.

@Override
public List<DeserializerPluginConfiguration> execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
    Condition condition = new IsOfTypeCondition(StorePackage.eINSTANCE.getDeserializerPluginConfiguration());
    Map<Long, DeserializerPluginConfiguration> result = getDatabaseSession().query(condition, DeserializerPluginConfiguration.class, OldQuery.getDefault());
    List<DeserializerPluginConfiguration> mapToList = CollectionUtils.mapToList(result);
    if (onlyEnabled) {
        Iterator<DeserializerPluginConfiguration> iterator = mapToList.iterator();
        while (iterator.hasNext()) {
            DeserializerPluginConfiguration deserializer = iterator.next();
            if (!bimServer.getPluginManager().isEnabled(deserializer.getPluginDescriptor().getPluginClassName()) || !deserializer.getEnabled()) {
                iterator.remove();
            }
        }
    }
    return mapToList;
}
Also used : IsOfTypeCondition(org.bimserver.database.query.conditions.IsOfTypeCondition) Condition(org.bimserver.database.query.conditions.Condition) IsOfTypeCondition(org.bimserver.database.query.conditions.IsOfTypeCondition) DeserializerPluginConfiguration(org.bimserver.models.store.DeserializerPluginConfiguration)

Example 4 with IsOfTypeCondition

use of org.bimserver.database.query.conditions.IsOfTypeCondition in project BIMserver by opensourceBIM.

the class GetAllObjectIDMsDatabaseAction method execute.

public List<ObjectIDMPluginConfiguration> execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
    Condition condition = new IsOfTypeCondition(StorePackage.eINSTANCE.getObjectIDMPluginConfiguration());
    Map<Long, ObjectIDMPluginConfiguration> result = getDatabaseSession().query(condition, ObjectIDMPluginConfiguration.class, OldQuery.getDefault());
    List<ObjectIDMPluginConfiguration> mapToList = CollectionUtils.mapToList(result);
    if (onlyEnabled) {
        Iterator<ObjectIDMPluginConfiguration> iterator = mapToList.iterator();
        while (iterator.hasNext()) {
            ObjectIDMPluginConfiguration objectIdm = iterator.next();
            if (!bimServer.getPluginManager().isEnabled(objectIdm.getPluginDescriptor().getPluginClassName()) || !objectIdm.getEnabled()) {
                iterator.remove();
            }
        }
    }
    return mapToList;
}
Also used : IsOfTypeCondition(org.bimserver.database.query.conditions.IsOfTypeCondition) Condition(org.bimserver.database.query.conditions.Condition) IsOfTypeCondition(org.bimserver.database.query.conditions.IsOfTypeCondition) ObjectIDMPluginConfiguration(org.bimserver.models.store.ObjectIDMPluginConfiguration)

Example 5 with IsOfTypeCondition

use of org.bimserver.database.query.conditions.IsOfTypeCondition 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;
}
Also used : IsOfTypeCondition(org.bimserver.database.query.conditions.IsOfTypeCondition) AttributeCondition(org.bimserver.database.query.conditions.AttributeCondition) Condition(org.bimserver.database.query.conditions.Condition) AndCondition(org.bimserver.database.query.conditions.AndCondition) HasReferenceToCondition(org.bimserver.database.query.conditions.HasReferenceToCondition) User(org.bimserver.models.store.User) IsOfTypeCondition(org.bimserver.database.query.conditions.IsOfTypeCondition) AttributeCondition(org.bimserver.database.query.conditions.AttributeCondition) AndCondition(org.bimserver.database.query.conditions.AndCondition) Project(org.bimserver.models.store.Project) Not(org.bimserver.database.query.conditions.Not) StringLiteral(org.bimserver.database.query.literals.StringLiteral) HasReferenceToCondition(org.bimserver.database.query.conditions.HasReferenceToCondition) EnumLiteral(org.bimserver.database.query.literals.EnumLiteral) HashSet(java.util.HashSet)

Aggregations

IsOfTypeCondition (org.bimserver.database.query.conditions.IsOfTypeCondition)11 Condition (org.bimserver.database.query.conditions.Condition)10 User (org.bimserver.models.store.User)3 AttributeCondition (org.bimserver.database.query.conditions.AttributeCondition)2 Not (org.bimserver.database.query.conditions.Not)2 EnumLiteral (org.bimserver.database.query.literals.EnumLiteral)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 AndCondition (org.bimserver.database.query.conditions.AndCondition)1 HasReferenceToCondition (org.bimserver.database.query.conditions.HasReferenceToCondition)1 StringLiteral (org.bimserver.database.query.literals.StringLiteral)1 LogAction (org.bimserver.models.log.LogAction)1 DeserializerPluginConfiguration (org.bimserver.models.store.DeserializerPluginConfiguration)1 ModelComparePluginConfiguration (org.bimserver.models.store.ModelComparePluginConfiguration)1 ModelMergerPluginConfiguration (org.bimserver.models.store.ModelMergerPluginConfiguration)1 ObjectIDMPluginConfiguration (org.bimserver.models.store.ObjectIDMPluginConfiguration)1 Project (org.bimserver.models.store.Project)1 QueryEnginePluginConfiguration (org.bimserver.models.store.QueryEnginePluginConfiguration)1 RenderEnginePluginConfiguration (org.bimserver.models.store.RenderEnginePluginConfiguration)1 SerializerPluginConfiguration (org.bimserver.models.store.SerializerPluginConfiguration)1