use of org.teiid.metadata.ExtensionMetadataProperty in project teiid by teiid.
the class TranslatorUtil method readExtensionPropertyMetadataAsExtendedMetadataProperties.
private static void readExtensionPropertyMetadataAsExtendedMetadataProperties(ExtendedPropertyMetadataList propertyDefns, Class clazz) {
Map<Field, ExtensionMetadataProperty> tps = TranslatorUtil.getExtensionMetadataProperties(clazz);
for (Field f : tps.keySet()) {
ExtensionMetadataProperty tp = tps.get(f);
ExtendedPropertyMetadata epm = new ExtendedPropertyMetadata();
epm.category = PropertyType.EXTENSION_METADATA.name();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < tp.applicable().length; i++) {
sb.append(tp.applicable()[i].getName());
if (tp.applicable().length - 1 > i) {
// $NON-NLS-1$
sb.append(",");
}
}
epm.owner = sb.toString();
try {
epm.name = (String) f.get(null);
} catch (IllegalArgumentException e) {
continue;
} catch (IllegalAccessException e) {
continue;
}
epm.description = tp.description();
epm.displayName = tp.display();
epm.required = tp.required();
epm.dataType = tp.datatype().getName();
// allowed values
if (tp.allowed() != null && !tp.allowed().isEmpty()) {
epm.allowed = new ArrayList<String>();
// $NON-NLS-1$
StringTokenizer st = new StringTokenizer(tp.allowed(), ",");
while (st.hasMoreTokens()) {
epm.allowed.add(st.nextToken().trim());
}
}
propertyDefns.add(epm);
}
}
use of org.teiid.metadata.ExtensionMetadataProperty in project teiid by teiid.
the class TranslatorUtil method buildExtensionMetadataProperties.
private static void buildExtensionMetadataProperties(Class<?> attachmentClass, Map<Field, ExtensionMetadataProperty> props) {
Class<?>[] baseInterfaces = attachmentClass.getInterfaces();
for (Class<?> clazz : baseInterfaces) {
buildExtensionMetadataProperties(clazz, props);
}
Class<?> superClass = attachmentClass.getSuperclass();
if (superClass != null) {
buildExtensionMetadataProperties(superClass, props);
}
Field[] fields = attachmentClass.getDeclaredFields();
for (Field f : fields) {
ExtensionMetadataProperty tp = f.getAnnotation(ExtensionMetadataProperty.class);
if (tp != null) {
f.setAccessible(true);
props.put(f, tp);
}
}
}
Aggregations