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);
}
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;
}
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;
}
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);
}
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);
}
Aggregations