Search in sources :

Example 16 with NamedElement

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;
}
Also used : ActionableEvent(com.emc.storageos.db.client.model.ActionableEvent) NamedElement(com.emc.storageos.db.client.constraint.NamedElementQueryResultList.NamedElement)

Example 17 with NamedElement

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;
}
Also used : Cluster(com.emc.storageos.db.client.model.Cluster) NamedElement(com.emc.storageos.db.client.constraint.NamedElementQueryResultList.NamedElement)

Example 18 with NamedElement

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());
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) CustomServicesWorkflow(com.emc.storageos.db.client.model.uimodels.CustomServicesWorkflow) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) NamedElement(com.emc.storageos.db.client.constraint.NamedElementQueryResultList.NamedElement)

Example 19 with NamedElement

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;
}
Also used : TimeSeriesConstraint(com.emc.storageos.db.client.constraint.TimeSeriesConstraint) NamedElement(com.emc.storageos.db.client.constraint.NamedElementQueryResultList.NamedElement)

Example 20 with NamedElement

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;
}
Also used : NamedElementQueryResultList(com.emc.storageos.db.client.constraint.NamedElementQueryResultList) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) NamedElement(com.emc.storageos.db.client.constraint.NamedElementQueryResultList.NamedElement)

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