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;
}
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;
}
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);
}
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());
}
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);
}
}
Aggregations