use of com.emc.storageos.db.client.impl.ColumnField in project coprhd-controller by CoprHD.
the class DataObjectScanner method addToTypeMap.
private void addToTypeMap(Class clazz, Map<String, ColumnFamily> useCfMap) {
DependencyInterceptor dependencyInterceptor = new DependencyInterceptor(this.modelClasses);
Map<String, List<String>> indexCfTypeMap = new HashMap<String, List<String>>();
DataObjectType doType = TypeMap.getDoType(clazz);
useCfMap.put(doType.getCF().getName(), doType.getCF());
boolean include = (clazz.getAnnotation(ExcludeFromGarbageCollection.class) == null);
Iterator<ColumnField> it = doType.getColumnFields().iterator();
while (it.hasNext()) {
ColumnField field = it.next();
if (field.getIndex() == null) {
continue;
}
useCfMap.put(field.getIndexCF().getName(), field.getIndexCF());
// for dependency processing
if (field.getIndexRefType() != null) {
_log.info(" index: " + field.getIndex().getClass().getSimpleName() + " class: " + clazz.getSimpleName() + " field: " + field.getName() + " indexCF: " + field.getIndexCF().getName() + " reference: " + field.getIndexRefType());
if (isDuplicateIndexCf(field, indexCfTypeMap)) {
_log.error("Class: {} has muliple indexed columns of the same type configured to use the same index column family: {}", clazz.getName(), field.getIndexCF().getName());
throw new IllegalStateException("Class: " + clazz.getName() + " has muliple indexed columns of the same type configured to use the same index column family: " + field.getIndexCF().getName());
}
// check first before adding the dependency
if (!isDependencyValidated(field.getIndexRefType(), clazz)) {
_log.error("Class: {} is a global object but it has illegal reference to a non-global dependency: {}", clazz.getName(), field.getIndexRefType());
throw new IllegalStateException("Class: " + clazz.getName() + " is a global object but it has illegal reference to a non-global dependency: " + field.getIndexRefType());
}
if (dependencyInterceptor.isConcretModelClass(field.getIndexRefType())) {
_dependencyTracker.addDependency(field.getIndexRefType(), clazz, field);
} else {
_log.info("reference type is abstract class, need special process");
dependencyInterceptor.handleDependency(_dependencyTracker, clazz, field);
}
}
}
if (include) {
_dependencyTracker.includeClass(clazz);
} else {
_dependencyTracker.excludeClass(clazz);
}
}
use of com.emc.storageos.db.client.impl.ColumnField in project coprhd-controller by CoprHD.
the class BourneDbClient method findBy.
public <T extends DataObject> List<NamedElement> findBy(Class<T> clazz, String columnField, URI id) throws DataAccessException {
LOG.debug("findBy({}, {}, {})", new Object[] { clazz, columnField, id });
DataObjectType doType = TypeMap.getDoType(clazz);
ColumnField field = doType.getColumnField(columnField);
ContainmentConstraint constraint = new ContainmentConstraintImpl(id, clazz, field);
return queryNamedElementsByConstraint(constraint);
}
use of com.emc.storageos.db.client.impl.ColumnField 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;
}
Aggregations