@Test(dependsOnMethods = "createTypesAndRelationships") public void testRelationshipAttributes() throws Exception { Map<String, AtlasAttribute> employeeRelationAttrs = getRelationAttrsForType(EMPLOYEE_TYPE); Assert.assertNotNull(employeeRelationAttrs); Assert.assertEquals(employeeRelationAttrs.size(), 2); Assert.assertTrue(employeeRelationAttrs.containsKey("department")); Assert.assertTrue(employeeRelationAttrs.containsKey("address")); AtlasAttribute deptAttr = employeeRelationAttrs.get("department"); Assert.assertEquals(deptAttr.getTypeName(), DEPARTMENT_TYPE); AtlasAttribute addrAttr = employeeRelationAttrs.get("address"); Assert.assertEquals(addrAttr.getTypeName(), ADDRESS_TYPE); Map<String, AtlasAttribute> deptRelationAttrs = getRelationAttrsForType(DEPARTMENT_TYPE); Assert.assertNotNull(deptRelationAttrs); Assert.assertEquals(deptRelationAttrs.size(), 1); Assert.assertTrue(deptRelationAttrs.containsKey("employees")); AtlasAttribute employeesAttr = deptRelationAttrs.get("employees"); Assert.assertEquals(employeesAttr.getTypeName(),AtlasBaseTypeDef.getArrayTypeName(EMPLOYEE_TYPE)); Map<String, AtlasAttribute> addressRelationAttrs = getRelationAttrsForType(ADDRESS_TYPE); Assert.assertNotNull(addressRelationAttrs); Assert.assertEquals(addressRelationAttrs.size(), 1); Assert.assertTrue(addressRelationAttrs.containsKey("employees")); AtlasAttribute employeesAttr1 = addressRelationAttrs.get("employees"); Assert.assertEquals(employeesAttr1.getTypeName(),AtlasBaseTypeDef.getArrayTypeName(EMPLOYEE_TYPE)); }
@Test(dependsOnMethods = "createTypesAndRelationships") public void testRelationshipAttributes() throws Exception { Map<String, AtlasAttribute> employeeRelationAttrs = getRelationAttrsForType(EMPLOYEE_TYPE); Assert.assertNotNull(employeeRelationAttrs); Assert.assertEquals(employeeRelationAttrs.size(), 2); Assert.assertTrue(employeeRelationAttrs.containsKey("department")); Assert.assertTrue(employeeRelationAttrs.containsKey("address")); AtlasAttribute deptAttr = employeeRelationAttrs.get("department"); Assert.assertEquals(deptAttr.getTypeName(), DEPARTMENT_TYPE); AtlasAttribute addrAttr = employeeRelationAttrs.get("address"); Assert.assertEquals(addrAttr.getTypeName(), ADDRESS_TYPE); Map<String, AtlasAttribute> deptRelationAttrs = getRelationAttrsForType(DEPARTMENT_TYPE); Assert.assertNotNull(deptRelationAttrs); Assert.assertEquals(deptRelationAttrs.size(), 1); Assert.assertTrue(deptRelationAttrs.containsKey("employees")); AtlasAttribute employeesAttr = deptRelationAttrs.get("employees"); Assert.assertEquals(employeesAttr.getTypeName(),AtlasBaseTypeDef.getArrayTypeName(EMPLOYEE_TYPE)); Map<String, AtlasAttribute> addressRelationAttrs = getRelationAttrsForType(ADDRESS_TYPE); Assert.assertNotNull(addressRelationAttrs); Assert.assertEquals(addressRelationAttrs.size(), 1); Assert.assertTrue(addressRelationAttrs.containsKey("employees")); AtlasAttribute employeesAttr1 = addressRelationAttrs.get("employees"); Assert.assertEquals(employeesAttr1.getTypeName(),AtlasBaseTypeDef.getArrayTypeName(EMPLOYEE_TYPE)); }
relation = EDGE_LABEL_PREFIX + attribute.getQualifiedName(); } else { throw new AtlasBaseException(AtlasErrorCode.INVALID_RELATIONSHIP_ATTRIBUTE, relation, attribute.getTypeName());
@Override public String getTypeFromEdge(GremlinQueryComposer.Context context, String item) { AtlasEntityType et = context.getActiveEntityType(); if(et == null) { return ""; } AtlasStructType.AtlasAttribute attr = et.getAttribute(item); if(attr == null) { return null; } AtlasType at = attr.getAttributeType(); switch (at.getTypeCategory()) { case ARRAY: AtlasArrayType arrType = ((AtlasArrayType)at); return getCollectionElementType(arrType.getElementType()); case MAP: AtlasMapType mapType = ((AtlasMapType)at); return getCollectionElementType(mapType.getValueType()); } return context.getActiveEntityType().getAttribute(item).getTypeName(); }
@Override public String getTypeFromEdge(GremlinQueryComposer.Context context, String item) { AtlasEntityType et = context.getActiveEntityType(); if(et == null) { return ""; } AtlasStructType.AtlasAttribute attr = et.getAttribute(item); if(attr == null) { return null; } AtlasType at = attr.getAttributeType(); switch (at.getTypeCategory()) { case ARRAY: AtlasArrayType arrType = ((AtlasArrayType)at); return getCollectionElementType(arrType.getElementType()); case MAP: AtlasMapType mapType = ((AtlasMapType)at); return getCollectionElementType(mapType.getValueType()); } return context.getActiveEntityType().getAttribute(item).getTypeName(); }