use of com.emc.storageos.db.client.constraint.AlternateIdConstraint in project coprhd-controller by CoprHD.
the class ModelClientImpl method findByAlternateId.
@Override
public <T extends DataObject> List<NamedElement> findByAlternateId(Class<T> clazz, String columnField, String value) throws DatabaseException {
LOG.debug("findByAlternateId({}, {}, {})", new Object[] { clazz, columnField, value });
DataObjectType doType = TypeMap.getDoType(clazz);
AlternateIdConstraint constraint = new AlternateIdConstraintImpl(doType.getColumnField(columnField), value);
return queryNamedElementsByConstraint(constraint);
}
use of com.emc.storageos.db.client.constraint.AlternateIdConstraint in project coprhd-controller by CoprHD.
the class ExportUtils method getInitiatorExportMasks.
/**
* Gets all the export masks that this initiator is member of.
*
* @param initiator the initiator
* @param dbClient an instance of {@link DbClient}
* @param permissionsHelper an instance of {@link PermissionsHelper}
* @param user a pointer to the logged in user
* @return all the export masks that this initiator is member of
*/
private static Map<ExportMask, List<ExportGroup>> getInitiatorExportMasks(Initiator initiator, DbClient dbClient, PermissionsHelper permissionsHelper, StorageOSUser user) throws DatabaseException {
Map<ExportMask, List<ExportGroup>> exportMasks = new HashMap<ExportMask, List<ExportGroup>>();
AlternateIdConstraint constraint = AlternateIdConstraint.Factory.getExportGroupInitiatorConstraint(initiator.getId().toString());
List<ExportGroup> exportGroups = getExportGroupsByConstraint(constraint, dbClient, permissionsHelper, user);
List<ExportMask> masks = getMasksForExportGroups(exportGroups, dbClient);
for (ExportMask exportMask : masks) {
if (exportMask != null && !exportMask.getInactive() && (exportMask.hasInitiator(initiator.getId().toString()) || (exportMask.hasExistingInitiator(initiator))) && exportMask.getVolumes() != null) {
List<ExportGroup> maskGroups = new ArrayList<ExportGroup>();
exportMasks.put(exportMask, maskGroups);
for (ExportGroup group : exportGroups) {
for (ExportMask em : ExportMaskUtils.getExportMasks(dbClient, group)) {
if (em.getId().toString().equals(exportMask.getId().toString())) {
maskGroups.add(group);
}
}
}
}
}
_log.info("Found {} export masks for initiator {}", exportMasks.size(), initiator.getInitiatorPort());
return exportMasks;
}
Aggregations