use of com.thinkbiganalytics.metadata.api.extension.FieldDescriptor in project kylo by Teradata.
the class JcrExtensibleType method getFieldDescriptors.
@Override
public Set<FieldDescriptor> getFieldDescriptors() {
try {
Set<FieldDescriptor> set = new HashSet<>();
for (PropertyDefinition def : this.nodeType.getPropertyDefinitions()) {
if (this.typeNode.hasNode(def.getName())) {
Node descrNode = this.typeNode.getNode(def.getName());
set.add(new JcrFieldDescriptor(descrNode, def));
}
}
return set;
} catch (RepositoryException e) {
throw new MetadataRepositoryException("Unable to get property descriptors for type: " + this.nodeType.getName(), e);
}
}
use of com.thinkbiganalytics.metadata.api.extension.FieldDescriptor in project kylo by Teradata.
the class JcrPropertyTest method testGetPropertyTypes.
@Test
public void testGetPropertyTypes() throws RepositoryException {
Map<String, FieldDescriptor.Type> propertyTypeMap = metadata.commit(() -> {
provider.ensureTypeDescriptors();
ExtensibleType feedType = provider.getType("tba:feed");
Set<FieldDescriptor> fields = feedType.getFieldDescriptors();
Map<String, FieldDescriptor.Type> map = new HashMap<>();
for (FieldDescriptor field : fields) {
map.put(field.getName(), field.getType());
}
return map;
}, MetadataAccess.SERVICE);
log.info("Property Types {} ", propertyTypeMap);
}
use of com.thinkbiganalytics.metadata.api.extension.FieldDescriptor in project kylo by Teradata.
the class JcrExtensibleProvidersTest method testGetPersonType.
@Test(dependsOnMethods = "testCreatePersonType")
public void testGetPersonType() {
final ExtensibleType.ID id = metadata.commit(() -> {
ExtensibleType type = typeProvider.getType("Person");
return type.getId();
}, MetadataAccess.SERVICE);
assertThat(id).isNotNull();
Map<String, FieldDescriptor.Type> fields = metadata.commit(() -> {
ExtensibleType type = typeProvider.getType("Person");
Map<String, FieldDescriptor.Type> map = new HashMap<>();
for (FieldDescriptor descr : type.getFieldDescriptors()) {
map.put(descr.getName(), descr.getType());
}
return map;
}, MetadataAccess.SERVICE);
assertThat(fields).isNotNull();
assertThat(fields).containsEntry("name", FieldDescriptor.Type.STRING);
assertThat(fields).containsEntry("description", FieldDescriptor.Type.STRING);
assertThat(fields).containsEntry("age", FieldDescriptor.Type.LONG);
}
Aggregations