use of com.emc.storageos.db.client.constraint.NamedElementQueryResultList.NamedElement in project coprhd-controller by CoprHD.
the class ActionableEventFinder method findPendingByResource.
public List<ActionableEvent> findPendingByResource(URI resourceId) {
List<NamedElement> events = findIdsByResource(resourceId);
List<ActionableEvent> result = Lists.newArrayList();
for (ActionableEvent event : findByIds(toURIs(events))) {
if (event != null && event.getEventStatus() != null && (event.getEventStatus().equalsIgnoreCase(ActionableEvent.Status.pending.name().toString()) || event.getEventStatus().equalsIgnoreCase(ActionableEvent.Status.failed.name().toString()))) {
result.add(event);
}
}
return result;
}
use of com.emc.storageos.db.client.constraint.NamedElementQueryResultList.NamedElement in project coprhd-controller by CoprHD.
the class ClusterFinder method findClusterByNameAndDatacenter.
/**
* Find the Cluster in a vCenterDataCenter by name.
*
* @param datacenterId vCenterDataCenterId.
* @param name name of the Cluster.
* @param activeOnly indicates whether active only or not.
* @return the Cluster if the name matches, otherwise null.
*/
public Cluster findClusterByNameAndDatacenter(URI datacenterId, String name, boolean activeOnly) {
List<NamedElement> clusters = findIdsByDatacenter(datacenterId);
Iterator<NamedElement> clusterIt = clusters.iterator();
while (clusterIt.hasNext()) {
Cluster cluster = findById(clusterIt.next().getId());
if (cluster != null && cluster.getLabel().equalsIgnoreCase(name)) {
return cluster;
}
}
return null;
}
use of com.emc.storageos.db.client.constraint.NamedElementQueryResultList.NamedElement in project coprhd-controller by CoprHD.
the class CustomServicesWorkflowManagerImpl method getByNameOrId.
@Override
public List<CustomServicesWorkflow> getByNameOrId(final String name) {
if (null == name) {
return null;
}
final List<CustomServicesWorkflow> workflowList = Lists.newArrayList();
try {
// first check if id is passed
if (URIUtil.isValid(new URI(name))) {
CustomServicesWorkflow csWF = client.customServicesWorkflows().findById(URIUtil.uri(name));
if (csWF != null) {
workflowList.add(csWF);
return workflowList;
}
}
} catch (final URISyntaxException e) {
// the passed value is not id.
log.debug("URISyntaxException : uri passed is " + name);
log.debug("Moving on to get by label");
}
final List<NamedElement> workflows = client.findByLabel(CustomServicesWorkflow.class, name);
final ImmutableList.Builder<URI> ids = ImmutableList.<URI>builder();
for (final NamedElement workflow : workflows) {
if (workflow.getName().equals(name)) {
ids.add(workflow.getId());
}
}
return client.findByIds(CustomServicesWorkflow.class, ids.build());
}
use of com.emc.storageos.db.client.constraint.NamedElementQueryResultList.NamedElement in project coprhd-controller by CoprHD.
the class BourneDbClient method findAllOrdersByTimeRange.
@Override
public List<NamedElement> findAllOrdersByTimeRange(URI tid, String columnField, Date startTime, Date endTime, int maxCount) throws DataAccessException {
LOG.debug("findAllOrdersByTimeRange(tid={} columnField={}, startTime={} endTime={} maxCount={})", new Object[] { tid, columnField, startTime, endTime, maxCount });
long startTimeInMS = startTime.getTime();
long endTimeInMS = endTime.getTime();
TimeSeriesConstraint constraint = TimeSeriesConstraint.Factory.getOrders(tid, startTimeInMS, endTimeInMS);
List<NamedElement> allOrderIds = queryNamedElementsByConstraint(constraint, maxCount);
return allOrderIds;
}
use of com.emc.storageos.db.client.constraint.NamedElementQueryResultList.NamedElement in project coprhd-controller by CoprHD.
the class BourneDbClient method queryNamedElementsByConstraint.
protected List<NamedElement> queryNamedElementsByConstraint(Constraint constraint, int maxCount) {
NamedElementQueryResultList queryResults = new NamedElementQueryResultList();
try {
if (maxCount > 0) {
getDbClient().queryByConstraint(constraint, queryResults, null, maxCount);
} else {
getDbClient().queryByConstraint(constraint, queryResults);
}
} catch (DatabaseException e) {
throw new DataAccessException(e);
}
List<NamedElement> results = Lists.newArrayList();
for (NamedElement namedElement : queryResults) {
results.add(namedElement);
}
return results;
}
Aggregations