Search in sources :

Example 26 with DataObjectType

use of com.emc.storageos.db.client.impl.DataObjectType in project coprhd-controller by CoprHD.

the class BourneDbClient method findByAlternateId.

public <T extends DataObject> List<NamedElement> findByAlternateId(Class<T> clazz, String columnField, String value) throws DataAccessException {
    LOG.debug("findByAlternateId(class={}, columnField={}, value={})", new Object[] { clazz, columnField, value });
    DataObjectType doType = TypeMap.getDoType(clazz);
    AlternateIdConstraint constraint = new AlternateIdConstraintImpl(doType.getColumnField(columnField), value);
    return queryNamedElementsByConstraint(constraint);
}
Also used : DataObjectType(com.emc.storageos.db.client.impl.DataObjectType) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint)

Example 27 with DataObjectType

use of com.emc.storageos.db.client.impl.DataObjectType in project coprhd-controller by CoprHD.

the class BourneDbClient method findByContainmentAndPrefix.

public <T extends DataObject> List<NamedElement> findByContainmentAndPrefix(Class<T> clazz, String columnField, URI id, String labelPrefix) throws DataAccessException {
    LOG.debug("findByContainmentAndPrefix({}, {}, {}, {})", new Object[] { clazz, columnField, id, labelPrefix });
    DataObjectType doType = TypeMap.getDoType(clazz);
    ContainmentPrefixConstraint constraint = new ContainmentPrefixConstraintImpl(id, labelPrefix, doType.getColumnField(columnField));
    return queryNamedElementsByConstraint(constraint);
}
Also used : ContainmentPrefixConstraint(com.emc.storageos.db.client.constraint.ContainmentPrefixConstraint) DataObjectType(com.emc.storageos.db.client.impl.DataObjectType)

Example 28 with DataObjectType

use of com.emc.storageos.db.client.impl.DataObjectType in project coprhd-controller by CoprHD.

the class ConstraintDescriptor method toConstraint.

public Constraint toConstraint() throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
    log.info("ConstraintDescriptor {}", this);
    Class type = Class.forName(dataObjectClassName);
    DataObjectType doType = TypeMap.getDoType(type);
    ColumnField field = doType.getColumnField(columnFieldName);
    Class constraintClass = Class.forName(constraintClassName);
    List<Class> parameterTypes = new ArrayList(arguments.size() + 1);
    List<Object> args = new ArrayList(arguments.size() + 1);
    int i = 1;
    for (Object arg : arguments) {
        if (i == columnFieldPosition) {
            parameterTypes.add(ColumnField.class);
            args.add(field);
        }
        i++;
        parameterTypes.add(arg.getClass());
        args.add(arg);
    }
    if (i == columnFieldPosition) {
        parameterTypes.add(ColumnField.class);
        args.add(field);
    }
    Constructor constructor = constraintClass.getConstructor(parameterTypes.toArray(new Class[0]));
    Constraint constraint = (Constraint) constructor.newInstance(args.toArray());
    return constraint;
}
Also used : Constructor(java.lang.reflect.Constructor) ColumnField(com.emc.storageos.db.client.impl.ColumnField) ArrayList(java.util.ArrayList) DataObjectType(com.emc.storageos.db.client.impl.DataObjectType)

Aggregations

DataObjectType (com.emc.storageos.db.client.impl.DataObjectType)28 ColumnField (com.emc.storageos.db.client.impl.ColumnField)10 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)8 URI (java.net.URI)8 ArrayList (java.util.ArrayList)7 ContainmentPrefixConstraint (com.emc.storageos.db.client.constraint.ContainmentPrefixConstraint)5 AlternateIdConstraintImpl (com.emc.storageos.db.client.constraint.impl.AlternateIdConstraintImpl)5 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)4 NamedElementQueryResultList (com.emc.storageos.db.client.constraint.NamedElementQueryResultList)4 PrefixConstraint (com.emc.storageos.db.client.constraint.PrefixConstraint)4 DbClientImpl (com.emc.storageos.db.client.impl.DbClientImpl)4 UserPreferences (com.emc.storageos.db.client.model.UserPreferences)4 Test (org.junit.Test)4 Constraint (com.emc.storageos.db.client.constraint.Constraint)3 ContainmentPermissionsConstraint (com.emc.storageos.db.client.constraint.ContainmentPermissionsConstraint)3 CompositeColumnName (com.emc.storageos.db.client.impl.CompositeColumnName)3 Rows (com.netflix.astyanax.model.Rows)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 com.emc.storageos.db.client.constraint (com.emc.storageos.db.client.constraint)2 AggregatedConstraint (com.emc.storageos.db.client.constraint.AggregatedConstraint)2