Java Code Examples for org.apache.atlas.model.instance.AtlasEntity#getRelationshipAttributes()

The following examples show how to use org.apache.atlas.model.instance.AtlasEntity#getRelationshipAttributes() . 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: PreprocessorContext.java    From atlas with Apache License 2.0 6 votes vote down vote up
public void prepareForPostUpdate() {
    if (postUpdateEntities != null) {
        ListIterator<AtlasEntity> iter = postUpdateEntities.listIterator();

        while (iter.hasNext()) {
            AtlasEntity entity       = iter.next();
            String      assignedGuid = getAssignedGuid(entity.getGuid());

            // no need to perform partial-update for entities that are created/deleted while processing this message
            if (createdEntities.contains(assignedGuid) || deletedEntities.contains(assignedGuid)) {
                iter.remove();
            } else {
                entity.setGuid(assignedGuid);

                if (entity.getAttributes() != null) {
                    setAssignedGuids(entity.getAttributes().values());
                }

                if (entity.getRelationshipAttributes() != null) {
                    setAssignedGuids(entity.getRelationshipAttributes().values());
                }
            }
        }
    }
}
 
Example 2
Source File: QuickStartV2IT.java    From atlas with Apache License 2.0 5 votes vote down vote up
private void verifyColumnsAreAddedToTable(AtlasEntity table) {
    Map<String, Object> tableAttributes = table.getRelationshipAttributes();
    List<Map>           columns         = (List<Map>) tableAttributes.get("columns");

    assertEquals(4, columns.size());

    for (Map colMap : columns) {
        String colGuid = (String) colMap.get("guid");

        assertNotNull(UUID.fromString(colGuid));
    }
}
 
Example 3
Source File: QuickStartV2IT.java    From atlas with Apache License 2.0 5 votes vote down vote up
private void verifyDBIsLinkedToTable(AtlasEntity table) throws AtlasServiceException {
    AtlasEntity         db              = getDB(SALES_DB);
    Map<String, Object> tableAttributes = table.getRelationshipAttributes();
    Map                 dbFromTable     = (Map) tableAttributes.get("db");

    assertEquals(db.getGuid(), dbFromTable.get("guid"));
}
 
Example 4
Source File: QuickStartV2IT.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Test
public void testViewIsAdded() throws AtlasServiceException {
    Map<String, String> attributes                 = Collections.singletonMap(REFERENCEABLE_ATTRIBUTE_NAME, PRODUCT_DIM_VIEW + CLUSTER_SUFFIX);
    AtlasEntity         view                       = atlasClientV2.getEntityByAttribute(VIEW_TYPE, attributes).getEntity();
    Map<String, Object> viewAttributes             = view.getAttributes();
    Map<String, Object> viewRelationshipAttributes = view.getRelationshipAttributes();

    assertEquals(PRODUCT_DIM_VIEW, viewAttributes.get(NAME));

    String productDimId   = getTable(PRODUCT_DIM_TABLE).getGuid();
    List   inputTables    = (List) viewRelationshipAttributes.get("inputTables");
    Map    inputTablesMap = (Map) inputTables.get(0);

    assertEquals(productDimId, inputTablesMap.get("guid"));
}
 
Example 5
Source File: EntityAuditListenerV2.java    From atlas with Apache License 2.0 4 votes vote down vote up
private String getAuditEventDetail(AtlasEntity entity, EntityAuditActionV2 action) {
    Map<String, Object> prunedAttributes = pruneEntityAttributesForAudit(entity);

    String auditPrefix  = getV2AuditPrefix(action);
    String auditString  = auditPrefix + AtlasType.toJson(entity);
    byte[] auditBytes   = auditString.getBytes(StandardCharsets.UTF_8);
    long   auditSize    = auditBytes != null ? auditBytes.length : 0;
    long   auditMaxSize = auditRepository.repositoryMaxSize();

    if (auditMaxSize >= 0 && auditSize > auditMaxSize) { // don't store attributes in audit
        LOG.warn("audit record too long: entityType={}, guid={}, size={}; maxSize={}. entity attribute values not stored in audit",
                entity.getTypeName(), entity.getGuid(), auditSize, auditMaxSize);

        Map<String, Object> attrValues    = entity.getAttributes();
        Map<String, Object> relAttrValues = entity.getRelationshipAttributes();

        entity.setAttributes(null);
        entity.setRelationshipAttributes(null);

        auditString = auditPrefix + AtlasType.toJson(entity);
        auditBytes  = auditString.getBytes(StandardCharsets.UTF_8); // recheck auditString size
        auditSize   = auditBytes != null ? auditBytes.length : 0;

        if (auditMaxSize >= 0 && auditSize > auditMaxSize) { // don't store classifications and meanings as well
            LOG.warn("audit record still too long: entityType={}, guid={}, size={}; maxSize={}. audit will have only summary details",
                    entity.getTypeName(), entity.getGuid(), auditSize, auditMaxSize);

            AtlasEntity shallowEntity = new AtlasEntity();

            shallowEntity.setGuid(entity.getGuid());
            shallowEntity.setTypeName(entity.getTypeName());
            shallowEntity.setCreateTime(entity.getCreateTime());
            shallowEntity.setUpdateTime(entity.getUpdateTime());
            shallowEntity.setCreatedBy(entity.getCreatedBy());
            shallowEntity.setUpdatedBy(entity.getUpdatedBy());
            shallowEntity.setStatus(entity.getStatus());
            shallowEntity.setVersion(entity.getVersion());

            auditString = auditPrefix + AtlasType.toJson(shallowEntity);
        }

        entity.setAttributes(attrValues);
        entity.setRelationshipAttributes(relAttrValues);
    }

    restoreEntityAttributes(entity, prunedAttributes);

    return auditString;
}
 
Example 6
Source File: HBaseBridge.java    From atlas with Apache License 2.0 4 votes vote down vote up
private void clearRelationshipAttributes(AtlasEntity entity) {
    if (entity != null && entity.getRelationshipAttributes() != null) {
        entity.getRelationshipAttributes().clear();
    }
}
 
Example 7
Source File: KafkaBridge.java    From atlas with Apache License 2.0 4 votes vote down vote up
private void clearRelationshipAttributes(AtlasEntity entity) {
    if (entity != null && entity.getRelationshipAttributes() != null) {
        entity.getRelationshipAttributes().clear();
    }
}
 
Example 8
Source File: HiveMetaStoreBridge.java    From atlas with Apache License 2.0 4 votes vote down vote up
private void clearRelationshipAttributes(AtlasEntity entity) {
    if (entity != null && entity.getRelationshipAttributes() != null) {
        entity.getRelationshipAttributes().clear();
    }
}