Search in sources :

Example 11 with NamedElement

use of com.emc.storageos.db.client.constraint.NamedElementQueryResultList.NamedElement in project coprhd-controller by CoprHD.

the class InMemoryDbClient method findByPrefix.

@Override
public <T extends DataObject> List<NamedElement> findByPrefix(Class<T> clazz, String columnField, String prefix) throws DataAccessException {
    List<NamedElement> results = Lists.newArrayList();
    for (URI modelId : findAllIds(clazz)) {
        T model = findById(clazz, modelId);
        Object o = getColumnField(model, columnField);
        if (o != null && o.toString().startsWith(prefix)) {
            results.add(createNamedElement(model));
        }
    }
    return results;
}
Also used : DataObject(com.emc.storageos.db.client.model.DataObject) NamedElement(com.emc.storageos.db.client.constraint.NamedElementQueryResultList.NamedElement) URI(java.net.URI)

Example 12 with NamedElement

use of com.emc.storageos.db.client.constraint.NamedElementQueryResultList.NamedElement in project coprhd-controller by CoprHD.

the class BasePermissionsHelper method getSubtenantRolesForUser.

public Map<String, Collection<String>> getSubtenantRolesForUser(StorageOSUser user) {
    Map<String, Collection<String>> subTenantRoles = new HashMap<String, Collection<String>>();
    URI userHomeTenant = URI.create(user.getTenantId());
    NamedElementQueryResultList subtenants = new NamedElementQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getTenantOrgSubTenantConstraint(userHomeTenant), subtenants);
    for (NamedElement sub : subtenants) {
        Collection<String> roles = getTenantRolesForUser(user, sub.getId(), false);
        if (!CollectionUtils.isEmpty(roles)) {
            subTenantRoles.put(sub.getId().toString(), roles);
        }
    }
    return subTenantRoles;
}
Also used : HashMap(java.util.HashMap) Collection(java.util.Collection) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) NamedElementQueryResultList(com.emc.storageos.db.client.constraint.NamedElementQueryResultList) NamedElement(com.emc.storageos.db.client.constraint.NamedElementQueryResultList.NamedElement)

Example 13 with NamedElement

use of com.emc.storageos.db.client.constraint.NamedElementQueryResultList.NamedElement in project coprhd-controller by CoprHD.

the class CustomServicesPrimitiveManagerImpl method deactivate.

@Override
public <T extends CustomServicesDBPrimitive> void deactivate(final Class<T> clazz, final URI id) {
    final CustomServicesDBPrimitive primitive = findById(clazz, id);
    if (null == primitive) {
        throw APIException.notFound.unableToFindEntityInURL(id);
    }
    List<NamedElement> workflows = client.customServicesWorkflows().getByPrimitive(id);
    if (null != workflows && !workflows.isEmpty()) {
        throw APIException.badRequests.resourceHasActiveReferencesWithType(primitive.getClass().getSimpleName(), id, CustomServicesWorkflow.class.getSimpleName());
    }
    client.delete(primitive);
}
Also used : CustomServicesDBPrimitive(com.emc.storageos.db.client.model.uimodels.CustomServicesDBPrimitive) CustomServicesWorkflow(com.emc.storageos.db.client.model.uimodels.CustomServicesWorkflow) NamedElement(com.emc.storageos.db.client.constraint.NamedElementQueryResultList.NamedElement)

Example 14 with NamedElement

use of com.emc.storageos.db.client.constraint.NamedElementQueryResultList.NamedElement in project coprhd-controller by CoprHD.

the class CustomServicesPrimitiveManagerImpl method getByLabel.

@Override
public <T extends ModelObject> List<T> getByLabel(Class<T> clazz, final String label) {
    final List<NamedElement> neList = client.findByLabel(clazz, label);
    final ImmutableList.Builder<URI> ids = ImmutableList.<URI>builder();
    for (final NamedElement ne : neList) {
        if (ne.getName().equals(label)) {
            ids.add(ne.getId());
        }
    }
    return client.findByIds(clazz, ids.build());
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) NamedElement(com.emc.storageos.db.client.constraint.NamedElementQueryResultList.NamedElement) URI(java.net.URI)

Example 15 with NamedElement

use of com.emc.storageos.db.client.constraint.NamedElementQueryResultList.NamedElement in project coprhd-controller by CoprHD.

the class WorkflowHelper method addResource.

private static void addResource(Builder builder, NamedURI id, CustomServicesResourceDAOs resourceDAOs) {
    final CustomServicesResourceDAO<?> dao = resourceDAOs.getByModel(URIUtil.getTypeName(id.getURI()));
    if (null == dao) {
        throw new RuntimeException("Resource type for " + id + " not found");
    }
    final CustomServicesPrimitiveResourceType resource = dao.getResource(id.getURI());
    if (null == resource) {
        throw new RuntimeException("Resource " + id + " not found");
    }
    builder.addResource(new ResourcePackage(CustomServicesPrimitiveMapper.map(resource), resource.resource()));
    for (final NamedElement related : dao.listRelatedResources(id.getURI())) {
        addResource(builder, new NamedURI(related.getId(), related.getName()), resourceDAOs);
    }
}
Also used : NamedURI(com.emc.storageos.db.client.model.NamedURI) ResourcePackage(com.emc.sa.workflow.CustomServicesWorkflowPackage.ResourcePackage) CustomServicesPrimitiveResourceType(com.emc.storageos.primitives.CustomServicesPrimitiveResourceType) NamedElement(com.emc.storageos.db.client.constraint.NamedElementQueryResultList.NamedElement)

Aggregations

NamedElement (com.emc.storageos.db.client.constraint.NamedElementQueryResultList.NamedElement)32 URI (java.net.URI)14 DataObject (com.emc.storageos.db.client.model.DataObject)6 ArrayList (java.util.ArrayList)6 NamedURI (com.emc.storageos.db.client.model.NamedURI)4 CustomServicesWorkflow (com.emc.storageos.db.client.model.uimodels.CustomServicesWorkflow)4 Order (com.emc.storageos.db.client.model.uimodels.Order)3 NamedElementQueryResultList (com.emc.storageos.db.client.constraint.NamedElementQueryResultList)2 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)2 ActionableEvent (com.emc.storageos.db.client.model.ActionableEvent)2 Cluster (com.emc.storageos.db.client.model.Cluster)2 ExportGroup (com.emc.storageos.db.client.model.ExportGroup)2 Host (com.emc.storageos.db.client.model.Host)2 ScheduledEvent (com.emc.storageos.db.client.model.uimodels.ScheduledEvent)2 ImmutableList (com.google.common.collect.ImmutableList)2 HashSet (java.util.HashSet)2 ServiceDescriptor (com.emc.sa.descriptor.ServiceDescriptor)1 ResourcePackage (com.emc.sa.workflow.CustomServicesWorkflowPackage.ResourcePackage)1 TimeSeriesConstraint (com.emc.storageos.db.client.constraint.TimeSeriesConstraint)1 CatalogCategory (com.emc.storageos.db.client.model.uimodels.CatalogCategory)1