Search in sources :

Example 1 with NamedElement

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

the class ComputeSystemHelper method updateClusterTenant.

/**
 * Updates the Cluster's tenant.
 *
 * @param dbClient DBClient for the database operations.
 * @param dataCenterId data center URI.
 * @param tenantId tenant id to be updated.
 */
private static void updateClusterTenant(DbClient dbClient, URI dataCenterId, URI tenantId) {
    List<NamedElement> clustersUris = listChildren(dbClient, dataCenterId, Cluster.class, "label", "vcenterDataCenter");
    for (NamedElement clusterUri : clustersUris) {
        Cluster cluster = dbClient.queryObject(Cluster.class, clusterUri.getId());
        if (cluster != null) {
            cluster.setTenant(tenantId);
            dbClient.persistObject(cluster);
        }
    }
}
Also used : Cluster(com.emc.storageos.db.client.model.Cluster) NamedElement(com.emc.storageos.db.client.constraint.NamedElementQueryResultList.NamedElement)

Example 2 with NamedElement

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

the class ExportGroupService method searchForHostExport.

/**
 * Performs the search query based on the host Id.
 *
 * @param hostId the host Id to search
 * @param resRepLists search result are placed in this param
 * @param selfOnly true or false
 */
private void searchForHostExport(String hostId, List<SearchResultResourceRep> resRepLists, boolean selfOnly, boolean authorized) {
    URIQueryResultList egUris = new URIQueryResultList();
    Set<URI> resultUris = new HashSet<URI>();
    List<ExportGroup> exportGroups = new ArrayList<ExportGroup>();
    if (selfOnly) {
        exportGroups = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, ExportGroup.class, AlternateIdConstraint.Factory.getConstraint(ExportGroup.class, "hosts", hostId));
    } else {
        List<NamedElement> initiatorElements = getModelClient().initiators().findIdsByHost(URI.create(hostId));
        List<URI> initiators = toURIs(initiatorElements);
        for (URI iUri : initiators) {
            _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getExportGroupInitiatorConstraint(iUri.toString()), egUris);
            for (URI eUri : egUris) {
                resultUris.add(eUri);
            }
        }
        exportGroups = _dbClient.queryObject(ExportGroup.class, resultUris, true);
    }
    buildExportGroupSearchResponse(exportGroups, resRepLists, selfOnly, ExportGroupType.Host.name(), authorized);
}
Also used : ExportGroup(com.emc.storageos.db.client.model.ExportGroup) ArrayList(java.util.ArrayList) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) NamedElement(com.emc.storageos.db.client.constraint.NamedElementQueryResultList.NamedElement) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) HashSet(java.util.HashSet)

Example 3 with NamedElement

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

the class ExportGroupService method searchForClusterExport.

/**
 * Performs the search query based on the cluster Id.
 *
 * @param clusterId search param
 * @param resRepLists result
 * @param selfOnly true or false
 */
private void searchForClusterExport(String clusterId, List<SearchResultResourceRep> resRepLists, boolean selfOnly, boolean authorized) {
    URIQueryResultList egUris = new URIQueryResultList();
    Set<URI> resultUris = new HashSet<URI>();
    List<ExportGroup> exportGroups = new ArrayList<ExportGroup>();
    if (selfOnly) {
        exportGroups = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, ExportGroup.class, AlternateIdConstraint.Factory.getConstraint(ExportGroup.class, "clusters", clusterId));
    } else {
        List<NamedElement> hostElements = getModelClient().hosts().findIdsByCluster(URI.create(clusterId));
        List<URI> hosts = toURIs(hostElements);
        for (URI hUri : hosts) {
            List<NamedElement> initiatorElements = getModelClient().initiators().findIdsByHost(hUri);
            List<URI> initiators = toURIs(initiatorElements);
            for (URI iUri : initiators) {
                _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getExportGroupInitiatorConstraint(iUri.toString()), egUris);
                for (URI eUri : egUris) {
                    resultUris.add(eUri);
                }
            }
        }
        exportGroups = _dbClient.queryObject(ExportGroup.class, resultUris, true);
    }
    buildExportGroupSearchResponse(exportGroups, resRepLists, selfOnly, ExportGroupType.Cluster.name(), authorized);
}
Also used : ExportGroup(com.emc.storageos.db.client.model.ExportGroup) ArrayList(java.util.ArrayList) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) NamedElement(com.emc.storageos.db.client.constraint.NamedElementQueryResultList.NamedElement) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) HashSet(java.util.HashSet)

Example 4 with NamedElement

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

the class HostFinder method findByUuid.

public Host findByUuid(String uuid) {
    List<NamedElement> hostIds = client.findByAlternateId(Host.class, HOST_UUID_COLUMN_NAME, uuid);
    Iterable<Host> hosts = client.findByIds(Host.class, toURIs(hostIds), true);
    for (Host host : hosts) {
        return host;
    }
    return null;
}
Also used : Host(com.emc.storageos.db.client.model.Host) NamedElement(com.emc.storageos.db.client.constraint.NamedElementQueryResultList.NamedElement)

Example 5 with NamedElement

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

the class BaseModelTest method findByAlternateId.

protected List<URI> findByAlternateId(String columnName, String value) {
    List<NamedElement> results = getModelClient().findByAlternateId(type, columnName, value);
    List<URI> ids = new ArrayList<URI>();
    for (NamedElement result : results) {
        ids.add(result.getId());
    }
    return ids;
}
Also used : ArrayList(java.util.ArrayList) NamedElement(com.emc.storageos.db.client.constraint.NamedElementQueryResultList.NamedElement) URI(java.net.URI)

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