attribInfo.put("includeInNotification", attributeDef.getIncludeInNotification()); attribInfo.put("isComposite", attribute.isOwnedRef()); attribInfo.put("reverseAttributeName", attribute.getInverseRefAttributeName()); attribInfo.put("defaultValue", attributeDef.getDefaultValue()); attribInfo.put("description", attributeDef.getDescription());
attribInfo.put("includeInNotification", attributeDef.getIncludeInNotification()); attribInfo.put("isComposite", attribute.isOwnedRef()); attribInfo.put("reverseAttributeName", attribute.getInverseRefAttributeName()); attribInfo.put("defaultValue", attributeDef.getDefaultValue()); attribInfo.put("description", attributeDef.getDescription());
@Test public void testValidConstraints() { AtlasTypeRegistry typeRegistry = new AtlasTypeRegistry(); AtlasTransientTypeRegistry ttr = null; boolean commit = false; List<AtlasEntityDef> entityDefs = new ArrayList<>(); String failureMsg = null; entityDefs.add(createTableEntityDef()); entityDefs.add(createColumnEntityDef()); try { ttr = typeRegistry.lockTypeRegistryForUpdate(); ttr.addTypes(entityDefs); AtlasEntityType typeTable = ttr.getEntityTypeByName(TYPE_TABLE); AtlasEntityType typeColumn = ttr.getEntityTypeByName(TYPE_COLUMN); assertTrue(typeTable.getAttribute(ATTR_COLUMNS).isOwnedRef()); assertNull(typeTable.getAttribute(ATTR_COLUMNS).getInverseRefAttributeName()); assertFalse(typeColumn.getAttribute(ATTR_TABLE).isOwnedRef()); assertEquals(typeColumn.getAttribute(ATTR_TABLE).getInverseRefAttributeName(), ATTR_COLUMNS); assertEquals(typeColumn.getAttribute(ATTR_TABLE).getInverseRefAttribute(), typeTable.getAttribute(ATTR_COLUMNS)); commit = true; } catch (AtlasBaseException excp) { failureMsg = excp.getMessage(); } finally { typeRegistry.releaseTypeRegistryForUpdate(ttr, commit); } assertNull(failureMsg, "failed to create types " + TYPE_TABLE + " and " + TYPE_COLUMN); }
ret.setIsIndexable(attributeDef.getIsIndexable()); ret.setIsComposite(attribute.isOwnedRef()); ret.setReverseAttributeName(attribute.getInverseRefAttributeName()); ret.setDefaultValue(attributeDef.getDefaultValue()); ret.setDescription(attributeDef.getDescription());
@Test public void testValidConstraints() { AtlasTypeRegistry typeRegistry = new AtlasTypeRegistry(); AtlasTransientTypeRegistry ttr = null; boolean commit = false; List<AtlasEntityDef> entityDefs = new ArrayList<>(); String failureMsg = null; entityDefs.add(createTableEntityDef()); entityDefs.add(createColumnEntityDef()); try { ttr = typeRegistry.lockTypeRegistryForUpdate(); ttr.addTypes(entityDefs); AtlasEntityType typeTable = ttr.getEntityTypeByName(TYPE_TABLE); AtlasEntityType typeColumn = ttr.getEntityTypeByName(TYPE_COLUMN); assertTrue(typeTable.getAttribute(ATTR_COLUMNS).isOwnedRef()); assertNull(typeTable.getAttribute(ATTR_COLUMNS).getInverseRefAttributeName()); assertFalse(typeColumn.getAttribute(ATTR_TABLE).isOwnedRef()); assertEquals(typeColumn.getAttribute(ATTR_TABLE).getInverseRefAttributeName(), ATTR_COLUMNS); assertEquals(typeColumn.getAttribute(ATTR_TABLE).getInverseRefAttribute(), typeTable.getAttribute(ATTR_COLUMNS)); commit = true; } catch (AtlasBaseException excp) { failureMsg = excp.getMessage(); } finally { typeRegistry.releaseTypeRegistryForUpdate(ttr, commit); } assertNull(failureMsg, "failed to create types " + TYPE_TABLE + " and " + TYPE_COLUMN); }
public static AttributeDefinition toAttributeDefinition(AtlasAttribute attribute) { final AtlasAttributeDef attrDef = attribute.getAttributeDef(); AttributeDefinition ret = new AttributeDefinition(); ret.setName(attrDef.getName()); ret.setDataTypeName(attrDef.getTypeName()); ret.setMultiplicity(getMultiplicity(attrDef)); ret.setIsComposite(attribute.isOwnedRef()); ret.setIsUnique(attrDef.getIsUnique()); ret.setIsIndexable(attrDef.getIsIndexable()); ret.setReverseAttributeName(attribute.getInverseRefAttributeName()); ret.setDescription(attrDef.getDescription()); ret.setDefaultValue(attrDef.getDefaultValue()); return ret; } }
@Override void resolveReferencesPhase2(AtlasTypeRegistry typeRegistry) throws AtlasBaseException { super.resolveReferencesPhase2(typeRegistry); for (AtlasAttribute attribute : allAttributes.values()) { if (attribute.getInverseRefAttributeName() == null) { continue; } // Set the inverse reference attribute. AtlasType referencedType = typeRegistry.getType(attribute.getAttributeDef().getTypeName()); AtlasEntityType referencedEntityType = getReferencedEntityType(referencedType); AtlasAttribute inverseReference = referencedEntityType.getAttribute(attribute.getInverseRefAttributeName()); attribute.setInverseRefAttribute(inverseReference); } }
public static AttributeDefinition toAttributeDefinition(AtlasAttribute attribute) { final AtlasAttributeDef attrDef = attribute.getAttributeDef(); AttributeDefinition ret = new AttributeDefinition(); ret.setName(attrDef.getName()); ret.setDataTypeName(attrDef.getTypeName()); ret.setMultiplicity(AtlasTypeUtil.getMultiplicity(attrDef)); ret.setIsComposite(attribute.isOwnedRef()); ret.setIsUnique(attrDef.getIsUnique()); ret.setIsIndexable(attrDef.getIsIndexable()); ret.setReverseAttributeName(attribute.getInverseRefAttributeName()); ret.setDescription(attrDef.getDescription()); ret.setDefaultValue(attrDef.getDefaultValue()); return ret; } }
@Override public void resolveReferencesPhase2(AtlasTypeRegistry typeRegistry) throws AtlasBaseException { super.resolveReferencesPhase2(typeRegistry); for (AtlasAttribute attribute : allAttributes.values()) { if (attribute.getInverseRefAttributeName() == null) { continue; } // Set the inverse reference attribute. AtlasType referencedType = typeRegistry.getType(attribute.getAttributeDef().getTypeName()); AtlasEntityType referencedEntityType = getReferencedEntityType(referencedType); AtlasAttribute inverseReference = referencedEntityType.getAttribute(attribute.getInverseRefAttributeName()); attribute.setInverseRefAttribute(inverseReference); } }