@Override public AtlasEntityWithExtInfo toEntityWithExtInfo(AtlasUserProfile obj) throws AtlasBaseException { AtlasEntity entity = toEntity(obj); AtlasEntityWithExtInfo entityWithExtInfo = new AtlasEntityWithExtInfo(entity); List<AtlasObjectId> objectIds = new ArrayList<>(); for (AtlasUserSavedSearch ss : obj.getSavedSearches()) { AtlasEntity ssEntity = savedSearchDTO.toEntity(ss); entityWithExtInfo.addReferredEntity(ssEntity); objectIds.add(new AtlasObjectId(ssEntity.getGuid(), savedSearchDTO.getEntityType().getTypeName(), savedSearchDTO.getUniqueAttributes(ss))); } if (objectIds.size() > 0) { entity.setAttribute(PROPERTY_SAVED_SEARCHES, objectIds); } return entityWithExtInfo; }
@Override public AtlasEntityWithExtInfo toEntityWithExtInfo(AtlasUserProfile obj) throws AtlasBaseException { AtlasEntity entity = toEntity(obj); AtlasEntityWithExtInfo entityWithExtInfo = new AtlasEntityWithExtInfo(entity); List<AtlasObjectId> objectIds = new ArrayList<>(); for (AtlasUserSavedSearch ss : obj.getSavedSearches()) { AtlasEntity ssEntity = savedSearchDTO.toEntity(ss); entityWithExtInfo.addReferredEntity(ssEntity); objectIds.add(new AtlasObjectId(ssEntity.getGuid(), savedSearchDTO.getEntityType().getTypeName(), savedSearchDTO.getUniqueAttributes(ss))); } if (objectIds.size() > 0) { entity.setAttribute(PROPERTY_SAVED_SEARCHES, objectIds); } return entityWithExtInfo; }
private void addReferredEntities(AtlasEntity.AtlasEntityWithExtInfo entityWithExtInfo, int maxEntries) { for (int i = 1; i <= maxEntries; i++) { AtlasEntity entity1 = new AtlasEntity(); entity1.setGuid(String.format(knownEntityGuidFormat, i)); entityWithExtInfo.addReferredEntity(entity1); } }
col0WithExtendedInfo.addReferredEntity(tableEntity); col0WithExtendedInfo.addReferredEntity(dbEntity.getEntity()); col1WithExtendedInfo.addReferredEntity(tableEntity); col1WithExtendedInfo.addReferredEntity(dbEntity.getEntity());
col0WithExtendedInfo.addReferredEntity(tableEntity); col0WithExtendedInfo.addReferredEntity(dbEntity.getEntity()); col1WithExtendedInfo.addReferredEntity(tableEntity); col1WithExtendedInfo.addReferredEntity(dbEntity.getEntity());
tblEntity.addReferredEntity(dbEntity.getEntity());
tblEntity.addReferredEntity(dbEntity.getEntity());
public static AtlasEntityWithExtInfo createComplexCollectionAttrEntity() { AtlasEntity entity = new AtlasEntity(ENTITY_TYPE_WITH_COMPLEX_COLLECTION_ATTR); entity.setAttribute(NAME, ENTITY_TYPE_WITH_COMPLEX_COLLECTION_ATTR); entity.setAttribute("listOfStructs", Arrays.asList(new AtlasStruct("struct_type", "name", "structArray0"), new AtlasStruct("struct_type", "name", "structArray1"), new AtlasStruct("struct_type", "name", "structArray2"))); entity.setAttribute("mapOfStructs", new HashMap<String, AtlasStruct>() {{ put("key0", new AtlasStruct("struct_type", "name", "structMap0")); put("key1", new AtlasStruct("struct_type", "name", "structMap1")); put("key2", new AtlasStruct("struct_type", "name", "structMap2")); }}); AtlasEntity e1Array = new AtlasEntity(ENTITY_TYPE, new HashMap<String, Object>() {{ put(NAME, "entityArray0"); put("isReplicated", true); }}); AtlasEntity e2Array = new AtlasEntity(ENTITY_TYPE, new HashMap<String, Object>() {{ put(NAME, "entityArray1"); put("isReplicated", false); }}); AtlasEntity e3Array = new AtlasEntity(ENTITY_TYPE, new HashMap<String, Object>() {{ put(NAME, "entityArray2"); put("isReplicated", true); }}); entity.setAttribute("listOfEntities", Arrays.asList(getAtlasObjectId(e1Array), getAtlasObjectId(e2Array), getAtlasObjectId(e3Array))); AtlasEntity e1MapValue = new AtlasEntity(ENTITY_TYPE, new HashMap<String, Object>() {{ put(NAME, "entityMapValue0"); put("isReplicated", false); }}); AtlasEntity e2MapValue = new AtlasEntity(ENTITY_TYPE, new HashMap<String, Object>() {{ put(NAME, "entityMapValue1"); put("isReplicated", true); }}); AtlasEntity e3MapValue = new AtlasEntity(ENTITY_TYPE, new HashMap<String, Object>() {{ put(NAME, "entityMapValue2"); put("isReplicated", false); }}); entity.setAttribute("mapOfEntities", new HashMap<String, Object>() {{ put("key0", getAtlasObjectId(e1MapValue)); put("key1", getAtlasObjectId(e2MapValue)); put("key2", getAtlasObjectId(e3MapValue)); }}); AtlasEntityWithExtInfo ret = new AtlasEntityWithExtInfo(entity); ret.addReferredEntity(e1Array); ret.addReferredEntity(e2Array); ret.addReferredEntity(e3Array); ret.addReferredEntity(e1MapValue); ret.addReferredEntity(e2MapValue); ret.addReferredEntity(e3MapValue); return ret; }
public static AtlasEntityWithExtInfo createTableEntityV2(AtlasEntity dbEntity) { AtlasEntity tblEntity = new AtlasEntity(TABLE_TYPE); tblEntity.setAttribute(NAME, RandomStringUtils.randomAlphanumeric(10)); tblEntity.setAttribute("description", "random table"); tblEntity.setAttribute("type", "type"); tblEntity.setAttribute("tableType", "MANAGED"); tblEntity.setAttribute("database", getAtlasObjectId(dbEntity)); tblEntity.setAttribute("created", new Date()); final AtlasStruct partitionStruct = new AtlasStruct("partition_struct_type", "name", "part0"); tblEntity.setAttribute("partitions", new ArrayList<AtlasStruct>() {{ add(partitionStruct); }}); tblEntity.setAttribute("partitionsMap", new HashMap<String, AtlasStruct>() {{ put("part0", new AtlasStruct("partition_struct_type", "name", "part0")); put("part1", new AtlasStruct("partition_struct_type", "name", "part1")); put("part2", new AtlasStruct("partition_struct_type", "name", "part2")); }}); tblEntity.setAttribute("parametersMap", new java.util.HashMap<String, String>() {{ put("key1", "value1"); }}); AtlasEntityWithExtInfo ret = new AtlasEntityWithExtInfo(tblEntity); ret.addReferredEntity(dbEntity); return ret; }
private void addNewRegions(AtlasEntity.AtlasEntityWithExtInfo entityWithExtInfo) throws AtlasBaseException { Map map = (Map) entityWithExtInfo.getEntity().getAttribute(RDBMS_DB_REGIONS_PROPERTY); AtlasEntity region1 = getDefaultTableEntity("r1"); AtlasEntity region2 = getDefaultTableEntity("r2"); map.put("north", new AtlasObjectId(region1.getGuid(), region1.getTypeName())); map.put("south", new AtlasObjectId(region2.getGuid(), region2.getTypeName())); entityWithExtInfo.addReferredEntity(region1); entityWithExtInfo.addReferredEntity(region2); }
private void addReferredEntities(AtlasEntity.AtlasEntityWithExtInfo entityWithExtInfo, int maxEntries) { for (int i = 1; i <= maxEntries; i++) { AtlasEntity entity1 = new AtlasEntity(); entity1.setGuid(String.format(knownEntityGuidFormat, i)); entityWithExtInfo.addReferredEntity(entity1); } }
private void addNewTables(AtlasEntity.AtlasEntityWithExtInfo entityWithExtInfo) throws AtlasBaseException { List list = (List)entityWithExtInfo.getEntity().getAttribute(RDBMS_DB_TABLES_PROPERTY); AtlasEntity table1 = getDefaultTableEntity("newTable-1"); AtlasEntity table2 = getDefaultTableEntity("newTable-2"); entityWithExtInfo.addReferredEntity(table1); entityWithExtInfo.addReferredEntity(table2); list.add(new AtlasObjectId(table1.getGuid(), table1.getTypeName())); list.add(new AtlasObjectId(table2.getGuid(), table2.getTypeName())); }