Search in sources :

Example 16 with AlternateIdConstraint

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);
}
Also used : AlternateIdConstraintImpl(com.emc.storageos.db.client.constraint.impl.AlternateIdConstraintImpl) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint)

Example 17 with AlternateIdConstraint

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;
}
Also used : ExportGroup(com.emc.storageos.db.client.model.ExportGroup) HashMap(java.util.HashMap) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) ITLRestRepList(com.emc.storageos.model.block.export.ITLRestRepList) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint)

Aggregations

AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)17 URI (java.net.URI)11 AlternateIdConstraintImpl (com.emc.storageos.db.client.constraint.impl.AlternateIdConstraintImpl)7 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)6 DataObjectType (com.emc.storageos.db.client.impl.DataObjectType)6 NamedElementQueryResultList (com.emc.storageos.db.client.constraint.NamedElementQueryResultList)4 UserPreferences (com.emc.storageos.db.client.model.UserPreferences)4 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 ExportGroup (com.emc.storageos.db.client.model.ExportGroup)3 NamedURI (com.emc.storageos.db.client.model.NamedURI)2 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)2 DbClient (com.emc.storageos.db.client.DbClient)1 Constraint (com.emc.storageos.db.client.constraint.Constraint)1 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)1 ContainmentPermissionsConstraint (com.emc.storageos.db.client.constraint.ContainmentPermissionsConstraint)1 ContainmentPrefixConstraint (com.emc.storageos.db.client.constraint.ContainmentPrefixConstraint)1 PrefixConstraint (com.emc.storageos.db.client.constraint.PrefixConstraint)1 TypeMap (com.emc.storageos.db.client.impl.TypeMap)1 DataObject (com.emc.storageos.db.client.model.DataObject)1