public static Collection<AtlasObjectId> toObjectIds(Collection<AtlasEntity> entities) { List<AtlasObjectId> ret = new ArrayList<>(); if (CollectionUtils.isNotEmpty(entities)) { for (AtlasEntity entity : entities) { if (entity != null) { ret.add(AtlasTypeUtil.getAtlasObjectId(entity)); } } } return ret; }
public static Collection<AtlasObjectId> toObjectIds(Collection<AtlasEntity> entities) { List<AtlasObjectId> ret = new ArrayList<>(); if (CollectionUtils.isNotEmpty(entities)) { for (AtlasEntity entity : entities) { if (entity != null) { ret.add(AtlasTypeUtil.getAtlasObjectId(entity)); } } } return ret; }
public static List<AtlasObjectId> getAtlasObjectIds(List<AtlasEntity> entities) { final List<AtlasObjectId> ret; if (CollectionUtils.isNotEmpty(entities)) { ret = new ArrayList<>(entities.size()); for (AtlasEntity entity : entities) { ret.add(getAtlasObjectId(entity)); } } else { ret = new ArrayList<>(); } return ret; }
private static List<AtlasObjectId> getAtlasObjectIds(AtlasEntity... entities) { List<AtlasObjectId> ret = new ArrayList<>(); if (ArrayUtils.isNotEmpty(entities)) { for (AtlasEntity entity : entities) { ret.add(getAtlasObjectId(entity)); } } return ret; } }
@Override protected void verifyRelationshipAttributeUpdate_NonComposite_ManyToOne(AtlasEntity a1, AtlasEntity a2, AtlasEntity a3, AtlasEntity b) { verifyRelationshipAttributeValue(a1, "oneB", b.getGuid()); verifyRelationshipAttributeValue(a2, "oneB", b.getGuid()); verifyRelationshipAttributeList(b, "manyA", ImmutableList.of(getAtlasObjectId(a1), getAtlasObjectId(a2), getAtlasObjectId(a3))); }
@Override protected void verify_testInverseReferenceAutoUpdate_Map(AtlasEntity a1, AtlasEntity b1, AtlasEntity b2, AtlasEntity b3) { Object value = a1.getAttribute("mapToB"); assertTrue(value instanceof Map); Map<String, AtlasObjectId> refMap = (Map<String, AtlasObjectId>) value; assertEquals(refMap.size(), 1); AtlasObjectId referencedEntityId = refMap.get("b3"); assertEquals(referencedEntityId, AtlasTypeUtil.getAtlasObjectId(b3)); verifyReferenceValue(b1, "mappedFromA", null); verifyReferenceValue(b2, "mappedFromA", null); }
@Override protected void verify_testInverseReferenceAutoUpdate_Map(AtlasEntity a1, AtlasEntity b1, AtlasEntity b2, AtlasEntity b3) { Object value = a1.getAttribute("mapToB"); assertTrue(value instanceof Map); Map<String, AtlasObjectId> refMap = (Map<String, AtlasObjectId>) value; assertEquals(refMap.size(), 1); AtlasObjectId referencedEntityId = refMap.get("b3"); assertEquals(referencedEntityId, AtlasTypeUtil.getAtlasObjectId(b3)); verifyReferenceValue(b1, "mappedFromA", null); verifyReferenceValue(b2, "mappedFromA", null); }
@Override protected void verify_testInverseReferenceAutoUpdate_NonCompositeManyToOne(AtlasEntity a1, AtlasEntity a2, AtlasEntity a3, AtlasEntity b) { verifyReferenceValue(a1, "oneB", b.getGuid()); verifyReferenceValue(a2, "oneB", b.getGuid()); verifyReferenceList(b, "manyA", ImmutableList.of(AtlasTypeUtil.getAtlasObjectId(a1), AtlasTypeUtil.getAtlasObjectId(a2), AtlasTypeUtil.getAtlasObjectId(a3))); }
@Override protected void verify_testInverseReferenceAutoUpdate_NonCompositeManyToOne(AtlasEntity a1, AtlasEntity a2, AtlasEntity a3, AtlasEntity b) { verifyReferenceValue(a1, "oneB", b.getGuid()); verifyReferenceValue(a2, "oneB", b.getGuid()); verifyReferenceList(b, "manyA", ImmutableList.of(AtlasTypeUtil.getAtlasObjectId(a1), AtlasTypeUtil.getAtlasObjectId(a2), AtlasTypeUtil.getAtlasObjectId(a3))); }
@Override protected void verifyRelationshipAttributeUpdate_NonComposite_ManyToOne(AtlasEntity a1, AtlasEntity a2, AtlasEntity a3, AtlasEntity b) { verifyRelationshipAttributeValue(a1, "oneB", b.getGuid()); verifyRelationshipAttributeValue(a2, "oneB", b.getGuid()); verifyRelationshipAttributeList(b, "manyA", ImmutableList.of(getAtlasObjectId(a1), getAtlasObjectId(a2), getAtlasObjectId(a3))); }
@Override protected void verify_testInverseReferenceAutoUpdate_Map(AtlasEntity a1, AtlasEntity b1, AtlasEntity b2, AtlasEntity b3) { Object value = a1.getAttribute("mapToB"); assertTrue(value instanceof Map); Map<String, AtlasObjectId> refMap = (Map<String, AtlasObjectId>) value; assertEquals(refMap.size(), 3); AtlasObjectId referencedEntityId = refMap.get("b3"); assertEquals(referencedEntityId, AtlasTypeUtil.getAtlasObjectId(b3)); verifyReferenceValue(b1, "mappedFromA", a1.getGuid()); verifyReferenceValue(b2, "mappedFromA", a1.getGuid()); }
@Override protected void verify_testInverseReferenceAutoUpdate_Map(AtlasEntity a1, AtlasEntity b1, AtlasEntity b2, AtlasEntity b3) { Object value = a1.getAttribute("mapToB"); assertTrue(value instanceof Map); Map<String, AtlasObjectId> refMap = (Map<String, AtlasObjectId>) value; assertEquals(refMap.size(), 3); AtlasObjectId referencedEntityId = refMap.get("b3"); assertEquals(referencedEntityId, AtlasTypeUtil.getAtlasObjectId(b3)); verifyReferenceValue(b1, "mappedFromA", a1.getGuid()); verifyReferenceValue(b2, "mappedFromA", a1.getGuid()); }
@Override protected void verifyRelationshipAttributeUpdate_NonComposite_ManyToOne(AtlasEntity a1, AtlasEntity a2, AtlasEntity a3, AtlasEntity b) { verifyRelationshipAttributeValue(a1, "oneB", null); verifyRelationshipAttributeValue(a2, "oneB", null); verifyRelationshipAttributeList(b, "manyA", ImmutableList.of(getAtlasObjectId(a3))); }
@Override protected void verify_testInverseReferenceAutoUpdate_NonCompositeManyToOne(AtlasEntity a1, AtlasEntity a2, AtlasEntity a3, AtlasEntity b) { verifyReferenceValue(a1, "oneB", null); verifyReferenceValue(a2, "oneB", null); verifyReferenceList(b, "manyA", ImmutableList.of(AtlasTypeUtil.getAtlasObjectId(a3))); }
private AtlasEntity toHiveTableEntity(AtlasEntity entHiveDb, String tableName) { AtlasEntity entHiveTable = new AtlasEntity(HiveDataTypes.HIVE_TABLE.getName()); String qualifiedName = HiveMetaStoreBridge.getTableQualifiedName((String)entHiveDb.getAttribute(AtlasConstants.CLUSTER_NAME_ATTRIBUTE), (String)entHiveDb.getAttribute(AtlasClient.NAME), tableName); entHiveTable.setAttribute(AtlasClient.NAME, tableName.toLowerCase()); entHiveTable.setAttribute(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, qualifiedName); entHiveTable.setAttribute(ATTRIBUTE_DB, AtlasTypeUtil.getAtlasObjectId(entHiveDb)); return entHiveTable; }
@Override protected void verifyRelationshipAttributeUpdate_NonComposite_ManyToOne(AtlasEntity a1, AtlasEntity a2, AtlasEntity a3, AtlasEntity b) { verifyRelationshipAttributeValue(a1, "oneB", null); verifyRelationshipAttributeValue(a2, "oneB", null); verifyRelationshipAttributeList(b, "manyA", ImmutableList.of(getAtlasObjectId(a3))); }
@Override protected void verify_testInverseReferenceAutoUpdate_NonCompositeManyToOne(AtlasEntity a1, AtlasEntity a2, AtlasEntity a3, AtlasEntity b) { verifyReferenceValue(a1, "oneB", null); verifyReferenceValue(a2, "oneB", null); verifyReferenceList(b, "manyA", ImmutableList.of(AtlasTypeUtil.getAtlasObjectId(a3))); }
AtlasEntity createTable(String name, String description, AtlasEntity db, AtlasEntity sd, String owner, String tableType, List<AtlasEntity> columns, String... traitNames) throws Exception { AtlasEntity entity = new AtlasEntity(TABLE_TYPE); entity.setClassifications(toAtlasClassifications(traitNames)); entity.setAttribute("name", name); entity.setAttribute(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, name); entity.setAttribute("description", description); entity.setAttribute("owner", owner); entity.setAttribute("tableType", tableType); entity.setAttribute("createTime", System.currentTimeMillis()); entity.setAttribute("lastAccessTime", System.currentTimeMillis()); entity.setAttribute("retention", System.currentTimeMillis()); entity.setAttribute("db", AtlasTypeUtil.getAtlasObjectId(db)); entity.setAttribute("sd", AtlasTypeUtil.getAtlasObjectId(sd)); entity.setAttribute("columns", AtlasTypeUtil.toObjectIds(columns)); return createInstance(entity, traitNames); }
public static AtlasEntity createColumnEntity(AtlasEntity tableEntity, String colName) { AtlasEntity entity = new AtlasEntity(COLUMN_TYPE); entity.setAttribute(NAME, colName); entity.setAttribute("type", "VARCHAR(32)"); entity.setAttribute("table", getAtlasObjectId(tableEntity)); return entity; }
@BeforeClass public void setUp() throws Exception { new GraphBackedSearchIndexer(typeRegistry); // create employee relationship types AtlasTypesDef employeeTypes = getDepartmentEmployeeTypes(); typeDefStore.createTypesDef(employeeTypes); AtlasEntitiesWithExtInfo employeeInstances = getDepartmentEmployeeInstances(); EntityMutationResponse response = entityStore.createOrUpdate(new AtlasEntityStream(employeeInstances), false); for (AtlasEntityHeader entityHeader : response.getCreatedEntities()) { employeeNameIdMap.put((String) entityHeader.getAttribute(NAME), getAtlasObjectId(entityHeader)); } init(); AtlasTypesDef typesDef = getInverseReferenceTestTypes(); AtlasTypesDef typesToCreate = AtlasTypeDefStoreInitializer.getTypesToCreate(typesDef, typeRegistry); if (!typesToCreate.isEmpty()) { typeDefStore.createTypesDef(typesToCreate); } }