Search in sources :

Example 1 with FieldDescriptor

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);
    }
}
Also used : MetadataRepositoryException(com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException) Node(javax.jcr.Node) MetadataRepositoryException(com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException) RepositoryException(javax.jcr.RepositoryException) PropertyDefinition(javax.jcr.nodetype.PropertyDefinition) FieldDescriptor(com.thinkbiganalytics.metadata.api.extension.FieldDescriptor) UserFieldDescriptor(com.thinkbiganalytics.metadata.api.extension.UserFieldDescriptor) HashSet(java.util.HashSet)

Example 2 with FieldDescriptor

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);
}
Also used : ExtensibleType(com.thinkbiganalytics.metadata.api.extension.ExtensibleType) HashMap(java.util.HashMap) ExtensibleType(com.thinkbiganalytics.metadata.api.extension.ExtensibleType) FieldDescriptor(com.thinkbiganalytics.metadata.api.extension.FieldDescriptor) Test(org.junit.Test)

Example 3 with FieldDescriptor

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);
}
Also used : ExtensibleType(com.thinkbiganalytics.metadata.api.extension.ExtensibleType) HashMap(java.util.HashMap) ExtensibleType(com.thinkbiganalytics.metadata.api.extension.ExtensibleType) FieldDescriptor(com.thinkbiganalytics.metadata.api.extension.FieldDescriptor) Test(org.testng.annotations.Test)

Aggregations

FieldDescriptor (com.thinkbiganalytics.metadata.api.extension.FieldDescriptor)3 ExtensibleType (com.thinkbiganalytics.metadata.api.extension.ExtensibleType)2 HashMap (java.util.HashMap)2 UserFieldDescriptor (com.thinkbiganalytics.metadata.api.extension.UserFieldDescriptor)1 MetadataRepositoryException (com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException)1 HashSet (java.util.HashSet)1 Node (javax.jcr.Node)1 RepositoryException (javax.jcr.RepositoryException)1 PropertyDefinition (javax.jcr.nodetype.PropertyDefinition)1 Test (org.junit.Test)1 Test (org.testng.annotations.Test)1