use of org.apache.atlas.model.typedef.AtlasEntityDef in project incubator-atlas by apache.
the class TypeConverterUtil method toAtlasEntityDefs.
private static List<AtlasEntityDef> toAtlasEntityDefs(List<HierarchicalTypeDefinition<ClassType>> classTypeDefinitions, AtlasTypeRegistry registry) throws AtlasBaseException {
List<AtlasEntityDef> atlasEntityDefs = new ArrayList<AtlasEntityDef>();
for (HierarchicalTypeDefinition<ClassType> classType : classTypeDefinitions) {
List<AtlasAttributeDef> attrDefs = new ArrayList<AtlasAttributeDef>();
AtlasEntityDef atlasEntityDef = new AtlasEntityDef();
String classTypeDefName = classType.typeName;
atlasEntityDef.setName(classTypeDefName);
atlasEntityDef.setDescription(classType.typeDescription);
atlasEntityDef.setTypeVersion(classType.typeVersion);
atlasEntityDef.setSuperTypes(classType.superTypes);
AttributeDefinition[] attrDefinitions = classType.attributeDefinitions;
for (AttributeDefinition oldAttr : attrDefinitions) {
AtlasAttributeDef newAttr = toAtlasAttributeDef(oldAttr);
attrDefs.add(newAttr);
}
atlasEntityDef.setAttributeDefs(attrDefs);
atlasEntityDefs.add(atlasEntityDef);
}
return atlasEntityDefs;
}
use of org.apache.atlas.model.typedef.AtlasEntityDef in project incubator-atlas by apache.
the class TestAtlasEntityType method createColumnEntityDefWithInvalidInverseAttributeType.
private AtlasEntityDef createColumnEntityDefWithInvalidInverseAttributeType() {
AtlasEntityDef column = new AtlasEntityDef(TYPE_COLUMN);
AtlasAttributeDef attrTable = new AtlasAttributeDef(ATTR_TABLE, TYPE_TABLE);
Map<String, Object> params = new HashMap<>();
params.put(AtlasConstraintDef.CONSTRAINT_PARAM_ATTRIBUTE, ATTR_NAME);
attrTable.addConstraint(new AtlasConstraintDef(AtlasConstraintDef.CONSTRAINT_TYPE_INVERSE_REF, params));
column.addAttribute(attrTable);
return column;
}
use of org.apache.atlas.model.typedef.AtlasEntityDef in project incubator-atlas by apache.
the class TestAtlasEntityType method createColumnEntityDef.
private AtlasEntityDef createColumnEntityDef() {
AtlasEntityDef column = new AtlasEntityDef(TYPE_COLUMN);
AtlasAttributeDef attrTable = new AtlasAttributeDef(ATTR_TABLE, TYPE_TABLE);
Map<String, Object> params = new HashMap<>();
params.put(AtlasConstraintDef.CONSTRAINT_PARAM_ATTRIBUTE, ATTR_COLUMNS);
attrTable.addConstraint(new AtlasConstraintDef(AtlasConstraintDef.CONSTRAINT_TYPE_INVERSE_REF, params));
column.addAttribute(attrTable);
return column;
}
use of org.apache.atlas.model.typedef.AtlasEntityDef in project incubator-atlas by apache.
the class TestAtlasEntityType method createColumnEntityDefWithNonExistingInverseAttribute.
private AtlasEntityDef createColumnEntityDefWithNonExistingInverseAttribute() {
AtlasEntityDef column = new AtlasEntityDef(TYPE_COLUMN);
AtlasAttributeDef attrTable = new AtlasAttributeDef(ATTR_TABLE, TYPE_TABLE);
Map<String, Object> params = new HashMap<>();
params.put(AtlasConstraintDef.CONSTRAINT_PARAM_ATTRIBUTE, "non-existing:" + ATTR_COLUMNS);
attrTable.addConstraint(new AtlasConstraintDef(AtlasConstraintDef.CONSTRAINT_TYPE_INVERSE_REF, params));
column.addAttribute(attrTable);
return column;
}
use of org.apache.atlas.model.typedef.AtlasEntityDef in project incubator-atlas by apache.
the class TestAtlasEntityType method testConstraintInValidInverseRef_InvalidAttributeTypeForInverseAttribute.
@Test
public void testConstraintInValidInverseRef_InvalidAttributeTypeForInverseAttribute() {
AtlasTypeRegistry typeRegistry = new AtlasTypeRegistry();
AtlasTransientTypeRegistry ttr = null;
boolean commit = false;
List<AtlasEntityDef> entityDefs = new ArrayList<>();
AtlasErrorCode errorCode = null;
entityDefs.add(createTableEntityDef());
entityDefs.add(createColumnEntityDefWithInvaidAttributeTypeForInverseAttribute());
try {
ttr = typeRegistry.lockTypeRegistryForUpdate();
ttr.addTypes(entityDefs);
commit = true;
} catch (AtlasBaseException excp) {
errorCode = excp.getAtlasErrorCode();
} finally {
typeRegistry.releaseTypeRegistryForUpdate(ttr, commit);
}
assertEquals(errorCode, AtlasErrorCode.CONSTRAINT_INVERSE_REF_ATTRIBUTE_INVALID_TYPE, "expected invalid constraint failure - missing refAttribute");
}
Aggregations