Java Code Examples for org.apache.atlas.type.AtlasStructType#getAttributeType()

The following examples show how to use org.apache.atlas.type.AtlasStructType#getAttributeType() . 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: SearchContext.java    From atlas with Apache License 2.0 6 votes vote down vote up
private void validateAttributes(final AtlasStructType structType, final String... attributeNames) throws AtlasBaseException {
    for (String attributeName : attributeNames) {
        if (StringUtils.isNotEmpty(attributeName) && (structType == null || structType.getAttributeType(attributeName) == null)) {
            if (structType == null) {
                throw new AtlasBaseException(AtlasErrorCode.UNKNOWN_TYPENAME, "NULL");
            }

            String name = structType.getTypeName();
            if (name.equals(MATCH_ALL_ENTITY_TYPES.getTypeName())) {
                name = ALL_ENTITY_TYPES;
            } else if (name.equals(MATCH_ALL_CLASSIFICATION_TYPES.getTypeName())) {
                name = ALL_CLASSIFICATION_TYPES;
            }
            throw new AtlasBaseException(AtlasErrorCode.UNKNOWN_ATTRIBUTE, attributeName, name);
        }
    }
}
 
Example 2
Source File: AtlasEntityTestBase.java    From atlas with Apache License 2.0 6 votes vote down vote up
protected void validateEntity(AtlasEntityExtInfo entityExtInfo, AtlasStruct actual, AtlasStruct expected) throws AtlasBaseException, AtlasException {
    if (expected == null) {
        Assert.assertNull(actual, "expected null instance. Found " + actual);

        return;
    }

    Assert.assertNotNull(actual, "found null instance");

    AtlasStructType entityType = (AtlasStructType) typeRegistry.getType(actual.getTypeName());
    for (String attrName : expected.getAttributes().keySet()) {
        Object expectedVal = expected.getAttribute(attrName);
        Object actualVal   = actual.getAttribute(attrName);

        AtlasType attrType = entityType.getAttributeType(attrName);
        validateAttribute(entityExtInfo, actualVal, expectedVal, attrType, attrName);
    }
}
 
Example 3
Source File: AtlasEntityStoreV1Test.java    From incubator-atlas with Apache License 2.0 6 votes vote down vote up
private void validateEntity(AtlasEntityExtInfo entityExtInfo, AtlasStruct actual, AtlasStruct expected) throws AtlasBaseException, AtlasException {
    if (expected == null) {
        Assert.assertNull(actual, "expected null instance. Found " + actual);

        return;
    }

    Assert.assertNotNull(actual, "found null instance");

    AtlasStructType entityType = (AtlasStructType) typeRegistry.getType(actual.getTypeName());
    for (String attrName : expected.getAttributes().keySet()) {
        Object expectedVal = expected.getAttribute(attrName);
        Object actualVal   = actual.getAttribute(attrName);

        AtlasType attrType = entityType.getAttributeType(attrName);
        validateAttribute(entityExtInfo, actualVal, expectedVal, attrType, attrName);
    }
}