Search in sources :

Example 11 with Condition

use of org.bimserver.database.query.conditions.Condition 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()));
}
Also used : Condition(org.bimserver.database.query.conditions.Condition) HasReferenceToCondition(org.bimserver.database.query.conditions.HasReferenceToCondition) User(org.bimserver.models.store.User) HasReferenceToCondition(org.bimserver.database.query.conditions.HasReferenceToCondition) Revision(org.bimserver.models.store.Revision)

Example 12 with Condition

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

the class RemoteServiceImpl method getPrivateProfiles.

@Override
public List<SProfileDescriptor> getPrivateProfiles(String serviceIdentifier, String token) throws UserException, ServerException {
    DatabaseSession session = getServiceMap().getBimServer().getDatabase().createSession();
    List<SProfileDescriptor> descriptors = new ArrayList<SProfileDescriptor>();
    try {
        Condition condition = new AttributeCondition(StorePackage.eINSTANCE.getUser_Token(), new StringLiteral(token));
        User user = session.querySingle(condition, User.class, OldQuery.getDefault());
        if (user != null) {
            for (InternalServicePluginConfiguration internalServicePluginConfiguration : user.getUserSettings().getServices()) {
                if (internalServicePluginConfiguration.getPluginDescriptor().getPluginClassName().equals(serviceIdentifier)) {
                    SProfileDescriptor sProfileDescriptor = new SProfileDescriptor();
                    descriptors.add(sProfileDescriptor);
                    sProfileDescriptor.setIdentifier("" + internalServicePluginConfiguration.getOid());
                    sProfileDescriptor.setName(internalServicePluginConfiguration.getName());
                    sProfileDescriptor.setDescription(internalServicePluginConfiguration.getDescription());
                    sProfileDescriptor.setPublicProfile(false);
                }
            }
        }
    } catch (BimserverDatabaseException e) {
        handleException(e);
    } finally {
        session.close();
    }
    return descriptors;
}
Also used : AttributeCondition(org.bimserver.database.query.conditions.AttributeCondition) Condition(org.bimserver.database.query.conditions.Condition) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) User(org.bimserver.models.store.User) StringLiteral(org.bimserver.database.query.literals.StringLiteral) DatabaseSession(org.bimserver.database.DatabaseSession) InternalServicePluginConfiguration(org.bimserver.models.store.InternalServicePluginConfiguration) ArrayList(java.util.ArrayList) AttributeCondition(org.bimserver.database.query.conditions.AttributeCondition) SProfileDescriptor(org.bimserver.interfaces.objects.SProfileDescriptor)

Example 13 with Condition

use of org.bimserver.database.query.conditions.Condition 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()));
}
Also used : Condition(org.bimserver.database.query.conditions.Condition) HasReferenceToCondition(org.bimserver.database.query.conditions.HasReferenceToCondition) Checkout(org.bimserver.models.store.Checkout) Revision(org.bimserver.models.store.Revision) HasReferenceToCondition(org.bimserver.database.query.conditions.HasReferenceToCondition)

Example 14 with Condition

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

the class GetAllModelComparesDatabaseAction method execute.

@Override
public List<ModelComparePluginConfiguration> execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
    Condition condition = new IsOfTypeCondition(StorePackage.eINSTANCE.getModelComparePluginConfiguration());
    Map<Long, ModelComparePluginConfiguration> result = getDatabaseSession().query(condition, ModelComparePluginConfiguration.class, OldQuery.getDefault());
    List<ModelComparePluginConfiguration> mapToList = CollectionUtils.mapToList(result);
    if (onlyEnabled) {
        Iterator<ModelComparePluginConfiguration> iterator = mapToList.iterator();
        while (iterator.hasNext()) {
            ModelComparePluginConfiguration modelCompare = iterator.next();
            if (!bimServer.getPluginManager().isEnabled(modelCompare.getPluginDescriptor().getPluginClassName()) || !modelCompare.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) ModelComparePluginConfiguration(org.bimserver.models.store.ModelComparePluginConfiguration)

Example 15 with Condition

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

the class GetAllModelMergersDatabaseAction method execute.

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

Aggregations

Condition (org.bimserver.database.query.conditions.Condition)20 IsOfTypeCondition (org.bimserver.database.query.conditions.IsOfTypeCondition)10 User (org.bimserver.models.store.User)9 AttributeCondition (org.bimserver.database.query.conditions.AttributeCondition)8 StringLiteral (org.bimserver.database.query.literals.StringLiteral)6 HasReferenceToCondition (org.bimserver.database.query.conditions.HasReferenceToCondition)5 ArrayList (java.util.ArrayList)4 DatabaseSession (org.bimserver.database.DatabaseSession)4 IOException (java.io.IOException)3 Not (org.bimserver.database.query.conditions.Not)3 EnumLiteral (org.bimserver.database.query.literals.EnumLiteral)3 Checkout (org.bimserver.models.store.Checkout)3 InternalServicePluginConfiguration (org.bimserver.models.store.InternalServicePluginConfiguration)3 PluginDescriptor (org.bimserver.models.store.PluginDescriptor)3 Project (org.bimserver.models.store.Project)3 PluginContext (org.bimserver.plugins.PluginContext)3 WebModulePlugin (org.bimserver.plugins.web.WebModulePlugin)3 HashSet (java.util.HashSet)2 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)2 AndCondition (org.bimserver.database.query.conditions.AndCondition)2