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