use of com.emc.storageos.db.client.model.PermissionsIndex in project coprhd-controller by CoprHD.
the class ColumnField method processProperty.
/**
* Helper to reflect on PropertyDescriptor and fill out _type and _name
* information;
*/
private void processProperty() {
// ignore if no get method
if (_property.getReadMethod() == null) {
return;
}
Method readMethod = _property.getReadMethod();
Annotation[] annotations = readMethod.getAnnotations();
ColumnFamily<String, IndexColumnName> indexCF = null;
int minPrefixChars;
boolean isLazyLoadable = false;
boolean hasRelationIndex = false;
for (int i = 0; i < annotations.length; i++) {
Annotation a = annotations[i];
if (a instanceof Id) {
_colType = ColumnType.Id;
_name = "Id";
} else if (a instanceof Name) {
_name = ((Name) a).value();
if (Number.class.isAssignableFrom(_valueType) || _valueType == URI.class || _valueType == String.class || _valueType == Date.class || _valueType == Boolean.class || _valueType == Byte.class || _valueType == Long.class || _valueType == byte[].class || _valueType.isEnum() || _valueType == Calendar.class) {
_colType = ColumnType.Primitive;
compositeName = new CompositeColumnName(_name);
} else if (NamedURI.class == _valueType) {
_colType = ColumnType.NamedURI;
compositeName = new CompositeColumnName(_name);
} else if (AbstractChangeTrackingSet.class.isAssignableFrom(_valueType)) {
_colType = ColumnType.TrackingSet;
} else if (AbstractChangeTrackingMap.class.isAssignableFrom(_valueType)) {
_colType = ColumnType.TrackingMap;
} else if (AbstractChangeTrackingSetMap.class.isAssignableFrom(_valueType)) {
_colType = ColumnType.TrackingSetMap;
} else if (AbstractSerializableNestedObject.class.isAssignableFrom(_valueType)) {
_colType = ColumnType.NestedObject;
compositeName = new CompositeColumnName(_name);
} else if (Collection.class.isAssignableFrom(_valueType) || DataObject.class.isAssignableFrom(_valueType)) {
isLazyLoadable = true;
} else {
throw new IllegalArgumentException(_name + " " + _valueType + " " + _property + " " + _parentType.getDataObjectClass());
}
} else if (a instanceof Ttl) {
_ttl = ((Ttl) a).value();
} else if (a instanceof RelationIndex) {
indexCF = new ColumnFamily<String, IndexColumnName>(((RelationIndex) a).cf(), StringSerializer.get(), IndexColumnNameSerializer.get());
_indexRefType = ((RelationIndex) a).type();
deactivateIfEmpty = ((RelationIndex) a).deactivateIfEmpty();
_index = new RelationDbIndex(indexCF);
} else if (a instanceof AlternateId) {
indexCF = new ColumnFamily<String, IndexColumnName>(((AlternateId) a).value(), StringSerializer.get(), IndexColumnNameSerializer.get());
_index = new AltIdDbIndex(indexCF);
} else if (a instanceof ClassNameTimeSeries) {
ColumnFamily<String, ClassNameTimeSeriesIndexColumnName> newIndexCF = new ColumnFamily<String, ClassNameTimeSeriesIndexColumnName>(((ClassNameTimeSeries) a).value(), StringSerializer.get(), ClassNameTimeSeriesSerializer.get());
_index = new ClassNameTimeSeriesDBIndex(newIndexCF);
} else if (a instanceof TimeSeriesAlternateId) {
ColumnFamily<String, TimeSeriesIndexColumnName> newIndexCF = new ColumnFamily<String, TimeSeriesIndexColumnName>(((TimeSeriesAlternateId) a).value(), StringSerializer.get(), TimeSeriesColumnNameSerializer.get());
_index = new TimeSeriesDbIndex(newIndexCF);
} else if (a instanceof NamedRelationIndex) {
indexCF = new ColumnFamily<String, IndexColumnName>(((NamedRelationIndex) a).cf(), StringSerializer.get(), IndexColumnNameSerializer.get());
_indexRefType = ((NamedRelationIndex) a).type();
_index = new NamedRelationDbIndex(indexCF);
} else if (a instanceof PrefixIndex) {
indexCF = new ColumnFamily<String, IndexColumnName>(((PrefixIndex) a).cf(), StringSerializer.get(), IndexColumnNameSerializer.get());
minPrefixChars = ((PrefixIndex) a).minChars();
_index = new PrefixDbIndex(indexCF, minPrefixChars);
} else if (a instanceof PermissionsIndex && AbstractChangeTrackingSetMap.class.isAssignableFrom(_valueType)) {
indexCF = new ColumnFamily<String, IndexColumnName>(((PermissionsIndex) a).value(), StringSerializer.get(), IndexColumnNameSerializer.get());
_index = new PermissionsDbIndex(indexCF);
} else if (a instanceof Encrypt && _valueType == String.class) {
_encrypt = true;
} else if (a instanceof ScopedLabelIndex) {
ScopedLabelIndex scopeLabelIndex = (ScopedLabelIndex) a;
indexCF = new ColumnFamily<String, IndexColumnName>(scopeLabelIndex.cf(), StringSerializer.get(), IndexColumnNameSerializer.get());
minPrefixChars = scopeLabelIndex.minChars();
_index = new ScopedLabelDbIndex(indexCF, minPrefixChars);
} else if (a instanceof ClockIndependent) {
clockIndValue = ((ClockIndependent) a).value();
} else if (a instanceof DecommissionedIndex && Boolean.class.isAssignableFrom(_valueType)) {
if (!_property.getName().equals(DataObject.INACTIVE_FIELD_NAME) || _parentType.getDataObjectClass().getAnnotation(NoInactiveIndex.class) == null) {
indexCF = new ColumnFamily<String, IndexColumnName>(((DecommissionedIndex) a).value(), StringSerializer.get(), IndexColumnNameSerializer.get());
_index = new DecommissionedDbIndex(indexCF);
}
} else if (a instanceof IndexByKey && (AbstractChangeTrackingMap.class.isAssignableFrom(_valueType) || AbstractChangeTrackingSet.class.isAssignableFrom(_valueType))) {
_indexByKey = true;
} else if (a instanceof Relation) {
hasRelationIndex = true;
if (((Relation) a).type().equals(DataObject.class)) {
_mappedByType = _valueType;
} else {
_mappedByType = ((Relation) a).type();
}
_mappedByField = ((Relation) a).mappedBy();
} else if (a instanceof AggregatedIndex) {
indexCF = new ColumnFamily<String, IndexColumnName>(((AggregatedIndex) a).cf(), StringSerializer.get(), IndexColumnNameSerializer.get());
String groupBy = ((AggregatedIndex) a).groupBy();
boolean global = ((AggregatedIndex) a).classGlobal();
_index = new AggregateDbIndex(indexCF, groupBy, global);
}
}
if (_name == null) {
String className = _parentType.getDataObjectClass().getName();
String fieldName = _property.getName();
throw new IllegalArgumentException(String.format("@Name annotation missing from field '%s' in class '%s'", fieldName, className));
}
if (_index != null) {
_index.setFieldName(_name);
_index.setIndexByKey(_indexByKey);
}
if (isLazyLoadable && hasRelationIndex) {
lazyLoaded = true;
}
}
Aggregations