Search in sources :

Example 6 with NamedElementQueryResultList

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

the class VmaxSnapshotOperations method terminateAnyRestoreSessionsForVolume.

/**
 * Look up any snapshot objects associated with the give volume. For each, can to terminate
 * any existing restore sessions.
 *
 * @param storage [in] - StorageSystem object representing the array
 * @param volume [in] - Volume to use for lookup
 * @param taskCompleter [in] - TaskCompleter used for updating status of operation
 * @throws Exception
 */
private void terminateAnyRestoreSessionsForVolume(StorageSystem storage, BlockObject volume, TaskCompleter taskCompleter) throws Exception {
    if (storage.checkIfVmax3()) {
        terminateAnyRestoreSessions(storage, null, volume.getId(), taskCompleter);
        return;
    }
    NamedElementQueryResultList snapshots = new NamedElementQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getVolumeSnapshotConstraint(volume.getId()), snapshots);
    for (NamedElementQueryResultList.NamedElement ne : snapshots) {
        BlockSnapshot snapshot = _dbClient.queryObject(BlockSnapshot.class, ne.getId());
        if (snapshot != null && !snapshot.getInactive()) {
            CIMObjectPath syncObjectPath = _cimPath.getSyncObject(storage, snapshot);
            if (_helper.checkExists(storage, syncObjectPath, false, false) != null) {
                terminateAnyRestoreSessions(storage, volume, snapshot.getId(), taskCompleter);
            }
        }
    }
}
Also used : BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) CIMObjectPath(javax.cim.CIMObjectPath) NamedElementQueryResultList(com.emc.storageos.db.client.constraint.NamedElementQueryResultList)

Example 7 with NamedElementQueryResultList

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

the class TaskUtils method findResourceTaskIds.

public static List<NamedURI> findResourceTaskIds(DbClient dbClient, URI resourceId) {
    NamedElementQueryResultList results = new NamedElementQueryResultList();
    dbClient.queryByConstraint(ContainmentConstraint.Factory.getResourceTaskConstraint(resourceId), results);
    List<NamedURI> uris = Lists.newArrayList();
    Iterator<NamedElementQueryResultList.NamedElement> it = results.iterator();
    while (it.hasNext()) {
        NamedElementQueryResultList.NamedElement element = it.next();
        uris.add(new NamedURI(element.getId(), element.getName()));
    }
    return uris;
}
Also used : NamedURI(com.emc.storageos.db.client.model.NamedURI) NamedElementQueryResultList(com.emc.storageos.db.client.constraint.NamedElementQueryResultList)

Example 8 with NamedElementQueryResultList

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

the class DbIndexTest method verifyPermissionsDbIndex.

private void verifyPermissionsDbIndex(DataObject obj, ColumnField field, Object val, boolean indexByKey, DbClient client) {
    switch(field.getType()) {
        case TrackingSetMap:
            for (String key : ((AbstractChangeTrackingSetMap<String>) val).keySet()) {
                ContainmentPermissionsConstraintImpl constraint = new ContainmentPermissionsConstraintImpl(key, field, obj.getClass());
                NamedElementQueryResultList results = new NamedElementQueryResultList();
                client.queryByConstraint(constraint, results);
                HashSet<String> setFromIndex = new HashSet<String>();
                for (NamedElementQueryResultList.NamedElement elem : results) {
                    if (elem.getId().equals(obj.getId())) {
                        setFromIndex.add(elem.getName());
                    }
                }
                AbstractChangeTrackingSet<String> values = ((AbstractChangeTrackingSetMap<String>) val).get(key);
                assertTrue("The value set from index is not same as what is currently in object", setFromIndex.equals(values));
            }
            break;
        case Id:
        case NamedURI:
        case NestedObject:
        case Primitive:
        case TrackingMap:
        case TrackingSet:
        default:
            throw new IllegalArgumentException(String.format("Field type %s is not supported by PermissionsDbIndex", field.getType().toString()));
    }
}
Also used : ContainmentPermissionsConstraintImpl(com.emc.storageos.db.client.constraint.impl.ContainmentPermissionsConstraintImpl) NamedElementQueryResultList(com.emc.storageos.db.client.constraint.NamedElementQueryResultList) HashSet(java.util.HashSet)

Example 9 with NamedElementQueryResultList

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

the class ModelClientImpl method queryNamedElementsByConstraint.

protected List<NamedElement> queryNamedElementsByConstraint(Constraint constraint) {
    NamedElementQueryResultList queryResults = new NamedElementQueryResultList();
    dbClient.queryByConstraint(constraint, queryResults);
    return queryResults;
}
Also used : NamedElementQueryResultList(com.emc.storageos.db.client.constraint.NamedElementQueryResultList)

Example 10 with NamedElementQueryResultList

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

the class OrderService method exportOrders.

private void exportOrders(List<URI> tids, long startTime, long endTime, OutputStream outputStream, OrderJobStatus status) {
    PrintStream out = new PrintStream(outputStream);
    out.println("ORDER DETAILS");
    out.println("-------------");
    List<URI> orderIDs = status.getOrderIDs();
    if (!orderIDs.isEmpty()) {
        dumpOrders(out, orderIDs, status);
    } else {
        long completed = 0;
        long failed = 0;
        for (URI tid : tids) {
            TimeSeriesConstraint constraint = TimeSeriesConstraint.Factory.getOrders(tid, startTime, endTime);
            DbClientImpl dbclient = (DbClientImpl) _dbClient;
            constraint.setKeyspace(dbclient.getKeyspace(Order.class));
            NamedElementQueryResultList ids = new NamedElementQueryResultList();
            _dbClient.queryByConstraint(constraint, ids);
            for (NamedElementQueryResultList.NamedElement namedID : ids) {
                URI id = namedID.getId();
                try {
                    dumpOrder(out, id, status);
                    completed++;
                } catch (Exception e) {
                    failed++;
                }
            }
        }
        status.setTotal(completed + failed);
    }
    try {
        saveJobInfo(status);
    } catch (Exception e) {
        log.error("Failed to save job info status={} e=", status, e);
    }
}
Also used : Order(com.emc.storageos.db.client.model.uimodels.Order) PrintStream(java.io.PrintStream) TimeSeriesConstraint(com.emc.storageos.db.client.constraint.TimeSeriesConstraint) DbClientImpl(com.emc.storageos.db.client.impl.DbClientImpl) URI(java.net.URI) NamedElementQueryResultList(com.emc.storageos.db.client.constraint.NamedElementQueryResultList) InvalidParameterException(java.security.InvalidParameterException) WebApplicationException(javax.ws.rs.WebApplicationException) URISyntaxException(java.net.URISyntaxException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException)

Aggregations

NamedElementQueryResultList (com.emc.storageos.db.client.constraint.NamedElementQueryResultList)18 URI (java.net.URI)11 ArrayList (java.util.ArrayList)6 NamedURI (com.emc.storageos.db.client.model.NamedURI)5 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)4 AlternateIdConstraintImpl (com.emc.storageos.db.client.constraint.impl.AlternateIdConstraintImpl)4 DataObjectType (com.emc.storageos.db.client.impl.DataObjectType)4 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)4 UserPreferences (com.emc.storageos.db.client.model.UserPreferences)4 StorageOSUser (com.emc.storageos.security.authentication.StorageOSUser)4 HashSet (java.util.HashSet)4 GET (javax.ws.rs.GET)4 Produces (javax.ws.rs.Produces)4 AbstractChangeTrackingSet (com.emc.storageos.db.client.model.AbstractChangeTrackingSet)3 StringSet (com.emc.storageos.db.client.model.StringSet)3 Set (java.util.Set)3 Path (javax.ws.rs.Path)3 NamedElement (com.emc.storageos.db.client.constraint.NamedElementQueryResultList.NamedElement)2 TimeSeriesConstraint (com.emc.storageos.db.client.constraint.TimeSeriesConstraint)2 Order (com.emc.storageos.db.client.model.uimodels.Order)2