Search in sources :

Example 6 with HierarchicalType

use of org.apache.atlas.typesystem.types.HierarchicalType in project incubator-atlas by apache.

the class TypeVertexFinder method visitSuperType.

@Override
public void visitSuperType(String typeName, String superTypeName) throws AtlasException {
    HierarchicalType superType = typeSystem.getDataType(HierarchicalType.class, superTypeName);
    visitDataType(superType);
}
Also used : HierarchicalType(org.apache.atlas.typesystem.types.HierarchicalType)

Example 7 with HierarchicalType

use of org.apache.atlas.typesystem.types.HierarchicalType in project incubator-atlas by apache.

the class DefaultPropertyMapper method getDataType.

//todo: abstract this via AtlasTypeSystem
protected synchronized HierarchicalType getDataType(String type) {
    HierarchicalType dataType = typeInstances.get(type);
    //todo: are there still cases where type can be null?
    if (dataType == null) {
        dataType = createDataType(type);
        typeInstances.put(type, dataType);
    }
    return dataType;
}
Also used : HierarchicalType(org.apache.atlas.typesystem.types.HierarchicalType)

Example 8 with HierarchicalType

use of org.apache.atlas.typesystem.types.HierarchicalType in project incubator-atlas by apache.

the class DefaultPropertyMapper method toFullyQualifiedName.

@Override
public String toFullyQualifiedName(String propName, String type) {
    HierarchicalType dataType = getDataType(type);
    String replacement = m_cleanToQualifiedMap.get(propName);
    if (replacement == null && dataType != null) {
        FieldMapping fieldMap = dataType.fieldMapping();
        if (fieldMap.fields.containsKey(propName)) {
            try {
                replacement = dataType.getQualifiedName(propName);
            } catch (AtlasException e) {
                throw new CatalogRuntimeException(String.format("Unable to resolve fully qualified property name for type '%s': %s", type, e), e);
            }
        }
    }
    if (replacement == null) {
        replacement = propName;
    }
    return replacement;
}
Also used : FieldMapping(org.apache.atlas.typesystem.types.FieldMapping) CatalogRuntimeException(org.apache.atlas.catalog.exception.CatalogRuntimeException) AtlasException(org.apache.atlas.AtlasException) HierarchicalType(org.apache.atlas.typesystem.types.HierarchicalType)

Example 9 with HierarchicalType

use of org.apache.atlas.typesystem.types.HierarchicalType in project incubator-atlas by apache.

the class DefaultPropertyMapperTest method testToCleanName_specifiedMappings.

@Test
public void testToCleanName_specifiedMappings() {
    String typeName = "testType";
    HierarchicalType dataType = createNiceMock(HierarchicalType.class);
    // currently only use key in map
    Map<String, AttributeInfo> fields = new HashMap<>();
    fields.put("foo", null);
    fields.put("prop", null);
    // can't mock FieldMapping due to direct access to final instance var 'fields'
    FieldMapping fieldMapping = new FieldMapping(fields, null, null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    // mock expectations
    expect(dataType.fieldMapping()).andReturn(fieldMapping).anyTimes();
    replay(dataType);
    Map<String, String> cleanToQualifiedMap = new HashMap<>();
    cleanToQualifiedMap.put("prop1", "property_1");
    Map<String, String> qualifiedToCleanMap = new HashMap<>();
    qualifiedToCleanMap.put("property_1", "prop1");
    PropertyMapper propertyMapper = new TestDefaultPropertyMapper(typeName, qualifiedToCleanMap, cleanToQualifiedMap, dataType);
    assertEquals(propertyMapper.toCleanName("property_1", typeName), "prop1");
    assertEquals(propertyMapper.toCleanName("Prefix.prop", typeName), "prop");
    assertEquals(propertyMapper.toCleanName("foo", typeName), "foo");
    assertEquals(propertyMapper.toCleanName("other", typeName), "other");
    assertEquals(propertyMapper.toCleanName("Prefix.other", typeName), "Prefix.other");
    verify(dataType);
}
Also used : AttributeInfo(org.apache.atlas.typesystem.types.AttributeInfo) HashMap(java.util.HashMap) FieldMapping(org.apache.atlas.typesystem.types.FieldMapping) HierarchicalType(org.apache.atlas.typesystem.types.HierarchicalType) Test(org.testng.annotations.Test)

Example 10 with HierarchicalType

use of org.apache.atlas.typesystem.types.HierarchicalType in project incubator-atlas by apache.

the class TypePersistenceVisitor method visitSuperType.

@Override
public void visitSuperType(String typeName, String superTypeName) throws AtlasException {
    AtlasVertex vertex = typeVertices.get(typeName);
    HierarchicalType superType = typeSystem.getDataType(HierarchicalType.class, superTypeName);
    AtlasVertex superVertex = typeVertices.get(superTypeName);
    graphHelper.getOrCreateEdge(vertex, superVertex, GraphBackedTypeStore.SUPERTYPE_EDGE_LABEL);
}
Also used : AtlasVertex(org.apache.atlas.repository.graphdb.AtlasVertex) HierarchicalType(org.apache.atlas.typesystem.types.HierarchicalType)

Aggregations

HierarchicalType (org.apache.atlas.typesystem.types.HierarchicalType)10 FieldMapping (org.apache.atlas.typesystem.types.FieldMapping)6 HashMap (java.util.HashMap)4 AttributeInfo (org.apache.atlas.typesystem.types.AttributeInfo)4 Test (org.testng.annotations.Test)4 ArrayList (java.util.ArrayList)1 AtlasException (org.apache.atlas.AtlasException)1 CatalogRuntimeException (org.apache.atlas.catalog.exception.CatalogRuntimeException)1 AtlasVertex (org.apache.atlas.repository.graphdb.AtlasVertex)1 ClassType (org.apache.atlas.typesystem.types.ClassType)1 TraitType (org.apache.atlas.typesystem.types.TraitType)1