use of org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef in project incubator-atlas by apache.
the class RestUtilsTest method testV1toV2toV1Conversion.
private void testV1toV2toV1Conversion(List<HierarchicalTypeDefinition<ClassType>> typesToTest, boolean[] compositeExpected) throws AtlasBaseException {
List<AtlasEntityDef> convertedEntityDefs = convertV1toV2(typesToTest);
AtlasTypeRegistry registry = createRegistry(convertedEntityDefs);
for (int i = 0; i < convertedEntityDefs.size(); i++) {
AtlasEntityDef def = convertedEntityDefs.get(i);
for (AtlasAttributeDef attrDef : def.getAttributeDefs()) {
AtlasAttributeDef converted = convertToJsonAndBack(registry, def, attrDef, compositeExpected[i]);
Assert.assertEquals(converted, attrDef);
}
}
List<HierarchicalTypeDefinition<ClassType>> convertedBackTypeDefs = convertV2toV1(convertedEntityDefs);
for (int i = 0; i < typesToTest.size(); i++) {
HierarchicalTypeDefinition<ClassType> convertedBack = convertedBackTypeDefs.get(i);
Assert.assertEquals(convertedBack, typesToTest.get(i));
AttributeDefinition[] attributeDefinitions = convertedBack.attributeDefinitions;
if (attributeDefinitions.length > 0) {
Assert.assertEquals(attributeDefinitions[0].isComposite, compositeExpected[i]);
}
}
}
use of org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef in project incubator-atlas by apache.
the class AtlasTypeDefGraphStore method rectifyAttributesIfNeeded.
private void rectifyAttributesIfNeeded(final Set<String> entityNames, AtlasStructDef structDef) {
List<AtlasAttributeDef> attributeDefs = structDef.getAttributeDefs();
if (CollectionUtils.isNotEmpty(attributeDefs)) {
for (AtlasAttributeDef attributeDef : attributeDefs) {
if (!hasOwnedReferenceConstraint(attributeDef.getConstraints())) {
continue;
}
Set<String> referencedTypeNames = AtlasTypeUtil.getReferencedTypeNames(attributeDef.getTypeName());
boolean valid = false;
for (String referencedTypeName : referencedTypeNames) {
if (entityNames.contains(referencedTypeName)) {
valid = true;
break;
}
}
if (!valid) {
rectifyOwnedReferenceError(structDef, attributeDef);
}
}
}
}
Aggregations