Java Code Examples for org.apache.atlas.model.typedef.AtlasEntityDef#addAttribute()
The following examples show how to use
org.apache.atlas.model.typedef.AtlasEntityDef#addAttribute() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestAtlasEntityType.java From atlas with Apache License 2.0 | 6 votes |
private AtlasEntityDef createTableEntityDefWithOptions() { AtlasEntityDef table = new AtlasEntityDef(TYPE_TABLE); AtlasAttributeDef attrName = new AtlasAttributeDef(ATTR_NAME, AtlasBaseTypeDef.ATLAS_TYPE_STRING); AtlasAttributeDef attrColumns = new AtlasAttributeDef(ATTR_COLUMNS, AtlasBaseTypeDef.getArrayTypeName(TYPE_COLUMN)); AtlasAttributeDef attrOwner = new AtlasAttributeDef(ATTR_OWNER, AtlasBaseTypeDef.ATLAS_TYPE_STRING); attrColumns.addConstraint(new AtlasConstraintDef(AtlasConstraintDef.CONSTRAINT_TYPE_OWNED_REF)); table.addAttribute(attrName); table.addAttribute(attrColumns); table.addAttribute(attrOwner); Map<String,String> options = new HashMap<>(); String key = "dynAttribute:" + ATTR_OWNER; String value = "{" + ATTR_NAME + "}"; options.put(key,value); table.setOptions(options); return table; }
Example 2
Source File: TestAtlasEntityType.java From atlas with Apache License 2.0 | 5 votes |
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; }
Example 3
Source File: TestAtlasEntityType.java From incubator-atlas with Apache License 2.0 | 5 votes |
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; }
Example 4
Source File: TestAtlasEntityType.java From incubator-atlas with Apache License 2.0 | 5 votes |
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; }
Example 5
Source File: TestAtlasEntityType.java From incubator-atlas with Apache License 2.0 | 5 votes |
private AtlasEntityDef createColumnEntityDefWithInvaidAttributeTypeForInverseAttribute() { AtlasEntityDef column = new AtlasEntityDef(TYPE_COLUMN); AtlasAttributeDef attrTable = new AtlasAttributeDef(ATTR_NAME, AtlasBaseTypeDef.ATLAS_TYPE_STRING); 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; }
Example 6
Source File: TestAtlasEntityType.java From incubator-atlas with Apache License 2.0 | 5 votes |
private AtlasEntityDef createColumnEntityDefWithMissingInverseAttribute() { AtlasEntityDef column = new AtlasEntityDef(TYPE_COLUMN); AtlasAttributeDef attrTable = new AtlasAttributeDef(ATTR_TABLE, TYPE_TABLE); attrTable.addConstraint(new AtlasConstraintDef(AtlasConstraintDef.CONSTRAINT_TYPE_INVERSE_REF)); column.addAttribute(attrTable); return column; }
Example 7
Source File: TestAtlasEntityType.java From incubator-atlas with Apache License 2.0 | 5 votes |
private AtlasEntityDef createTableEntityDef() { AtlasEntityDef table = new AtlasEntityDef(TYPE_TABLE); AtlasAttributeDef attrName = new AtlasAttributeDef(ATTR_NAME, AtlasBaseTypeDef.ATLAS_TYPE_STRING); AtlasAttributeDef attrColumns = new AtlasAttributeDef(ATTR_COLUMNS, AtlasBaseTypeDef.getArrayTypeName(TYPE_COLUMN)); attrColumns.addConstraint(new AtlasConstraintDef(AtlasConstraintDef.CONSTRAINT_TYPE_OWNED_REF)); table.addAttribute(attrName); table.addAttribute(attrColumns); return table; }
Example 8
Source File: TestUtilsV2.java From incubator-atlas with Apache License 2.0 | 5 votes |
public static AtlasEntityDef createPrimitiveEntityDef() { AtlasEntityDef newtestEntityDef = new AtlasEntityDef("newtest"); AtlasAttributeDef attrName = new AtlasAttributeDef("name", AtlasBaseTypeDef.ATLAS_TYPE_STRING); AtlasAttributeDef attrDescription = new AtlasAttributeDef("description", AtlasBaseTypeDef.ATLAS_TYPE_STRING); attrDescription.setIsOptional(false); AtlasAttributeDef attrcheck = new AtlasAttributeDef("check", AtlasBaseTypeDef.ATLAS_TYPE_STRING); attrcheck.setIsOptional(true); AtlasAttributeDef attrSourceCode = new AtlasAttributeDef("sourcecode", AtlasBaseTypeDef.ATLAS_TYPE_STRING); attrSourceCode.setDefaultValue("Hello World"); attrSourceCode.setIsOptional(true); AtlasAttributeDef attrCost = new AtlasAttributeDef("Cost", AtlasBaseTypeDef.ATLAS_TYPE_INT); attrCost.setIsOptional(true); attrCost.setDefaultValue("30"); AtlasAttributeDef attrDiskUsage = new AtlasAttributeDef("diskUsage", AtlasBaseTypeDef.ATLAS_TYPE_FLOAT); attrDiskUsage.setIsOptional(true); attrDiskUsage.setDefaultValue("70.50"); AtlasAttributeDef attrisStoreUse = new AtlasAttributeDef("isstoreUse", AtlasBaseTypeDef.ATLAS_TYPE_BOOLEAN); attrisStoreUse.setIsOptional(true); attrisStoreUse.setDefaultValue("true"); newtestEntityDef.addAttribute(attrName); newtestEntityDef.addAttribute(attrDescription); newtestEntityDef.addAttribute(attrcheck); newtestEntityDef.addAttribute(attrSourceCode); newtestEntityDef.addAttribute(attrCost); newtestEntityDef.addAttribute(attrDiskUsage); newtestEntityDef.addAttribute(attrisStoreUse); return newtestEntityDef; }
Example 9
Source File: TypeAttributeDifferenceTest.java From incubator-atlas with Apache License 2.0 | 5 votes |
private AtlasEntityDef getAtlasEntityDefWithAttributes(String... attributeNames) { AtlasEntityDef e = new AtlasEntityDef(); for (AtlasStructDef.AtlasAttributeDef a : getAtlasAttributeDefs(attributeNames)) { e.addAttribute(a); } return e; }
Example 10
Source File: TestAtlasEntityType.java From atlas with Apache License 2.0 | 5 votes |
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; }
Example 11
Source File: TestLoadModelUtils.java From atlas with Apache License 2.0 | 5 votes |
private static void addReplicationAttributes(AtlasTypesDef typesFromJson) throws IOException { if(typesFromJson.getEntityDefs() == null || typesFromJson.getEntityDefs().size() == 0) return; AtlasEntityDef ed = typesFromJson.getEntityDefs().get(0); if(!ed.getName().equals("Referenceable")) return; String replAttr1Json = TestResourceFileUtils.getJson("stocksDB-Entities","replicationAttrs"); String replAttr2Json = StringUtils.replace(replAttr1Json, "From", "To"); ed.addAttribute(AtlasType.fromJson(replAttr1Json, AtlasStructDef.AtlasAttributeDef.class)); ed.addAttribute(AtlasType.fromJson(replAttr2Json, AtlasStructDef.AtlasAttributeDef.class)); }
Example 12
Source File: TestAtlasEntityType.java From atlas with Apache License 2.0 | 5 votes |
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; }
Example 13
Source File: TestAtlasEntityType.java From atlas with Apache License 2.0 | 5 votes |
private AtlasEntityDef createColumnEntityDefWithInvaidAttributeTypeForInverseAttribute() { AtlasEntityDef column = new AtlasEntityDef(TYPE_COLUMN); AtlasAttributeDef attrTable = new AtlasAttributeDef(ATTR_NAME, AtlasBaseTypeDef.ATLAS_TYPE_STRING); 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; }
Example 14
Source File: TestAtlasEntityType.java From incubator-atlas with Apache License 2.0 | 5 votes |
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; }
Example 15
Source File: TestAtlasEntityType.java From atlas with Apache License 2.0 | 5 votes |
private AtlasEntityDef createTableEntityDefForTopSort() { AtlasEntityDef table = new AtlasEntityDef(TYPE_TABLE); AtlasAttributeDef attrName = new AtlasAttributeDef(ATTR_NAME, AtlasBaseTypeDef.ATLAS_TYPE_STRING); AtlasAttributeDef attrOwner = new AtlasAttributeDef(ATTR_OWNER, AtlasBaseTypeDef.ATLAS_TYPE_STRING); AtlasAttributeDef attrDescription = new AtlasAttributeDef(ATTR_DESCRIPTION, AtlasBaseTypeDef.ATLAS_TYPE_STRING); AtlasAttributeDef attrLocation = new AtlasAttributeDef(ATTR_LOCATION, AtlasBaseTypeDef.ATLAS_TYPE_STRING); table.addAttribute(attrName); table.addAttribute(attrOwner); table.addAttribute(attrDescription); table.addAttribute(attrLocation); Map<String,String> options = new HashMap<>(); String key1 = "dynAttribute:" + ATTR_OWNER; String value1 = "{" + ATTR_DESCRIPTION + "}"; String key2 = "dynAttribute:" + ATTR_DESCRIPTION; String value2 = "template"; String key3 = "dynAttribute:" + ATTR_NAME; String value3 = "{" + ATTR_DESCRIPTION + "}@{" + ATTR_OWNER + "}"; String key4 = "dynAttribute:" + ATTR_LOCATION; String value4 = "{" + ATTR_NAME + "}@{" + ATTR_OWNER + "}"; options.put(key1, value1); options.put(key2, value2); options.put(key3, value3); options.put(key4, value4); table.setOptions(options); return table; }
Example 16
Source File: TestAtlasEntityType.java From atlas with Apache License 2.0 | 5 votes |
private AtlasEntityDef createTableEntityDef() { AtlasEntityDef table = new AtlasEntityDef(TYPE_TABLE); AtlasAttributeDef attrName = new AtlasAttributeDef(ATTR_NAME, AtlasBaseTypeDef.ATLAS_TYPE_STRING); AtlasAttributeDef attrColumns = new AtlasAttributeDef(ATTR_COLUMNS, AtlasBaseTypeDef.getArrayTypeName(TYPE_COLUMN)); attrColumns.addConstraint(new AtlasConstraintDef(AtlasConstraintDef.CONSTRAINT_TYPE_OWNED_REF)); table.addAttribute(attrName); table.addAttribute(attrColumns); return table; }
Example 17
Source File: TestUtilsV2.java From atlas with Apache License 2.0 | 5 votes |
public static AtlasEntityDef createPrimitiveEntityDef() { AtlasEntityDef newtestEntityDef = new AtlasEntityDef("newtest"); AtlasAttributeDef attrName = new AtlasAttributeDef("name", AtlasBaseTypeDef.ATLAS_TYPE_STRING); AtlasAttributeDef attrDescription = new AtlasAttributeDef("description", AtlasBaseTypeDef.ATLAS_TYPE_STRING); attrDescription.setIsOptional(false); AtlasAttributeDef attrcheck = new AtlasAttributeDef("check", AtlasBaseTypeDef.ATLAS_TYPE_STRING); attrcheck.setIsOptional(true); AtlasAttributeDef attrSourceCode = new AtlasAttributeDef("sourcecode", AtlasBaseTypeDef.ATLAS_TYPE_STRING); attrSourceCode.setDefaultValue("Hello World"); attrSourceCode.setIsOptional(true); AtlasAttributeDef attrCost = new AtlasAttributeDef("Cost", AtlasBaseTypeDef.ATLAS_TYPE_INT); attrCost.setIsOptional(true); attrCost.setDefaultValue("30"); AtlasAttributeDef attrDiskUsage = new AtlasAttributeDef("diskUsage", AtlasBaseTypeDef.ATLAS_TYPE_FLOAT); attrDiskUsage.setIsOptional(true); attrDiskUsage.setDefaultValue("70.50"); AtlasAttributeDef attrisStoreUse = new AtlasAttributeDef("isstoreUse", AtlasBaseTypeDef.ATLAS_TYPE_BOOLEAN); attrisStoreUse.setIsOptional(true); attrisStoreUse.setDefaultValue("true"); newtestEntityDef.addAttribute(attrName); newtestEntityDef.addAttribute(attrDescription); newtestEntityDef.addAttribute(attrcheck); newtestEntityDef.addAttribute(attrSourceCode); newtestEntityDef.addAttribute(attrCost); newtestEntityDef.addAttribute(attrDiskUsage); newtestEntityDef.addAttribute(attrisStoreUse); populateSystemAttributes(newtestEntityDef); return newtestEntityDef; }
Example 18
Source File: TypeAttributeDifferenceTest.java From atlas with Apache License 2.0 | 5 votes |
private AtlasEntityDef getAtlasEntityDefWithAttributes(String... attributeNames) { AtlasEntityDef e = new AtlasEntityDef(); for (AtlasStructDef.AtlasAttributeDef a : getAtlasAttributeDefs(attributeNames)) { e.addAttribute(a); } return e; }
Example 19
Source File: TestAtlasEntityType.java From atlas with Apache License 2.0 | 3 votes |
private AtlasEntityDef createTableEntityDefWithOwnedRefOnInvalidType() { AtlasEntityDef table = new AtlasEntityDef(TYPE_TABLE); AtlasAttributeDef attrName = new AtlasAttributeDef(ATTR_NAME, AtlasBaseTypeDef.ATLAS_TYPE_STRING); attrName.addConstraint(new AtlasConstraintDef(AtlasConstraintDef.CONSTRAINT_TYPE_OWNED_REF)); table.addAttribute(attrName); return table; }
Example 20
Source File: TestAtlasEntityType.java From incubator-atlas with Apache License 2.0 | 3 votes |
private AtlasEntityDef createTableEntityDefWithOwnedRefOnInvalidType() { AtlasEntityDef table = new AtlasEntityDef(TYPE_TABLE); AtlasAttributeDef attrName = new AtlasAttributeDef(ATTR_NAME, AtlasBaseTypeDef.ATLAS_TYPE_STRING); attrName.addConstraint(new AtlasConstraintDef(AtlasConstraintDef.CONSTRAINT_TYPE_OWNED_REF)); table.addAttribute(attrName); return table; }