Java Code Examples for org.apache.atlas.model.typedef.AtlasBaseTypeDef#ATLAS_TYPE_INT

The following examples show how to use org.apache.atlas.model.typedef.AtlasBaseTypeDef#ATLAS_TYPE_INT . 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: AtlasEntityStoreV2.java    From atlas with Apache License 2.0 5 votes vote down vote up
private List assignMultipleValues(String bmAttributeValues, String elementTypeName, List failedTermMsgList, int lineIndex) {

        String[] arr = bmAttributeValues.split(FileUtils.ESCAPE_CHARACTER + FileUtils.PIPE_CHARACTER);
        try {
            switch (elementTypeName) {

                case AtlasBaseTypeDef.ATLAS_TYPE_FLOAT:
                    return AtlasGraphUtilsV2.floatParser(arr, failedTermMsgList, lineIndex);

                case AtlasBaseTypeDef.ATLAS_TYPE_INT:
                    return AtlasGraphUtilsV2.intParser(arr, failedTermMsgList, lineIndex);

                case AtlasBaseTypeDef.ATLAS_TYPE_LONG:
                    return AtlasGraphUtilsV2.longParser(arr, failedTermMsgList, lineIndex);

                case AtlasBaseTypeDef.ATLAS_TYPE_SHORT:
                    return AtlasGraphUtilsV2.shortParser(arr, failedTermMsgList, lineIndex);

                case AtlasBaseTypeDef.ATLAS_TYPE_DOUBLE:
                    return AtlasGraphUtilsV2.doubleParser(arr, failedTermMsgList, lineIndex);

                case AtlasBaseTypeDef.ATLAS_TYPE_DATE:
                    return AtlasGraphUtilsV2.dateParser(arr, failedTermMsgList, lineIndex);

                case AtlasBaseTypeDef.ATLAS_TYPE_BOOLEAN:
                    return AtlasGraphUtilsV2.booleanParser(arr, failedTermMsgList, lineIndex);

                default:
                    return Arrays.asList(arr);
            }
        } catch (Exception e) {
            LOG.error("On line index " + lineIndex + "the provided BusinessMetadata AttributeValue " + bmAttributeValues + " are not of type - " + elementTypeName);
            failedTermMsgList.add("On line index " + lineIndex + "the provided BusinessMetadata AttributeValue " + bmAttributeValues + " are not of type - " + elementTypeName);
        }
        return null;
    }
 
Example 2
Source File: TestUtilsV2.java    From atlas with Apache License 2.0 5 votes vote down vote up
public static AtlasEntityDef createPrimitiveEntityDef() {

        AtlasEntityDef newtestEntityDef = new AtlasEntityDef("newtest");
        AtlasAttributeDef attrName = new AtlasAttributeDef("name", AtlasBaseTypeDef.ATLAS_TYPE_STRING);

        AtlasAttributeDef attrDescription = new AtlasAttributeDef("description", AtlasBaseTypeDef.ATLAS_TYPE_STRING);
        attrDescription.setIsOptional(false);

        AtlasAttributeDef attrcheck = new AtlasAttributeDef("check", AtlasBaseTypeDef.ATLAS_TYPE_STRING);
        attrcheck.setIsOptional(true);

        AtlasAttributeDef attrSourceCode = new AtlasAttributeDef("sourcecode", AtlasBaseTypeDef.ATLAS_TYPE_STRING);
        attrSourceCode.setDefaultValue("Hello World");
        attrSourceCode.setIsOptional(true);

        AtlasAttributeDef attrCost = new AtlasAttributeDef("Cost", AtlasBaseTypeDef.ATLAS_TYPE_INT);
        attrCost.setIsOptional(true);
        attrCost.setDefaultValue("30");

        AtlasAttributeDef attrDiskUsage = new AtlasAttributeDef("diskUsage", AtlasBaseTypeDef.ATLAS_TYPE_FLOAT);
        attrDiskUsage.setIsOptional(true);
        attrDiskUsage.setDefaultValue("70.50");

        AtlasAttributeDef attrisStoreUse = new AtlasAttributeDef("isstoreUse", AtlasBaseTypeDef.ATLAS_TYPE_BOOLEAN);
        attrisStoreUse.setIsOptional(true);
        attrisStoreUse.setDefaultValue("true");

        newtestEntityDef.addAttribute(attrName);
        newtestEntityDef.addAttribute(attrDescription);
        newtestEntityDef.addAttribute(attrcheck);
        newtestEntityDef.addAttribute(attrSourceCode);
        newtestEntityDef.addAttribute(attrCost);
        newtestEntityDef.addAttribute(attrDiskUsage);
        newtestEntityDef.addAttribute(attrisStoreUse);

        populateSystemAttributes(newtestEntityDef);

        return newtestEntityDef;
    }
 
Example 3
Source File: TestUtilsV2.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
public static AtlasEntityDef createPrimitiveEntityDef() {

        AtlasEntityDef newtestEntityDef = new AtlasEntityDef("newtest");
        AtlasAttributeDef attrName = new AtlasAttributeDef("name", AtlasBaseTypeDef.ATLAS_TYPE_STRING);

        AtlasAttributeDef attrDescription = new AtlasAttributeDef("description", AtlasBaseTypeDef.ATLAS_TYPE_STRING);
        attrDescription.setIsOptional(false);

        AtlasAttributeDef attrcheck = new AtlasAttributeDef("check", AtlasBaseTypeDef.ATLAS_TYPE_STRING);
        attrcheck.setIsOptional(true);

        AtlasAttributeDef attrSourceCode = new AtlasAttributeDef("sourcecode", AtlasBaseTypeDef.ATLAS_TYPE_STRING);
        attrSourceCode.setDefaultValue("Hello World");
        attrSourceCode.setIsOptional(true);

        AtlasAttributeDef attrCost = new AtlasAttributeDef("Cost", AtlasBaseTypeDef.ATLAS_TYPE_INT);
        attrCost.setIsOptional(true);
        attrCost.setDefaultValue("30");

        AtlasAttributeDef attrDiskUsage = new AtlasAttributeDef("diskUsage", AtlasBaseTypeDef.ATLAS_TYPE_FLOAT);
        attrDiskUsage.setIsOptional(true);
        attrDiskUsage.setDefaultValue("70.50");

        AtlasAttributeDef attrisStoreUse = new AtlasAttributeDef("isstoreUse", AtlasBaseTypeDef.ATLAS_TYPE_BOOLEAN);
        attrisStoreUse.setIsOptional(true);
        attrisStoreUse.setDefaultValue("true");

        newtestEntityDef.addAttribute(attrName);
        newtestEntityDef.addAttribute(attrDescription);
        newtestEntityDef.addAttribute(attrcheck);
        newtestEntityDef.addAttribute(attrSourceCode);
        newtestEntityDef.addAttribute(attrCost);
        newtestEntityDef.addAttribute(attrDiskUsage);
        newtestEntityDef.addAttribute(attrisStoreUse);

        return newtestEntityDef;
    }
 
Example 4
Source File: SearchProcessor.java    From atlas with Apache License 2.0 4 votes vote down vote up
private Predicate toInMemoryPredicate(AtlasStructType type, String attrName, SearchParameters.Operator op, String attrVal) {
    Predicate ret = null;

    AtlasAttribute                    attribute = type.getAttribute(attrName);
    VertexAttributePredicateGenerator predicate = OPERATOR_PREDICATE_MAP.get(op);

    if (attribute != null && predicate != null) {
        final AtlasType attrType = attribute.getAttributeType();
        final Class     attrClass;
        final Object    attrValue;

        // Some operators support null comparison, thus the parsing has to be conditional
        switch (attrType.getTypeName()) {
            case AtlasBaseTypeDef.ATLAS_TYPE_STRING:
                attrClass = String.class;
                attrValue = attrVal;
                break;
            case AtlasBaseTypeDef.ATLAS_TYPE_SHORT:
                attrClass = Short.class;
                attrValue = StringUtils.isEmpty(attrVal) ? null : Short.parseShort(attrVal);
                break;
            case AtlasBaseTypeDef.ATLAS_TYPE_INT:
                attrClass = Integer.class;
                attrValue = StringUtils.isEmpty(attrVal) ? null : Integer.parseInt(attrVal);
                break;
            case AtlasBaseTypeDef.ATLAS_TYPE_BIGINTEGER:
                attrClass = BigInteger.class;
                attrValue = StringUtils.isEmpty(attrVal) ? null : new BigInteger(attrVal);
                break;
            case AtlasBaseTypeDef.ATLAS_TYPE_BOOLEAN:
                attrClass = Boolean.class;
                attrValue = StringUtils.isEmpty(attrVal) ? null : Boolean.parseBoolean(attrVal);
                break;
            case AtlasBaseTypeDef.ATLAS_TYPE_BYTE:
                attrClass = Byte.class;
                attrValue = StringUtils.isEmpty(attrVal) ? null : Byte.parseByte(attrVal);
                break;
            case AtlasBaseTypeDef.ATLAS_TYPE_LONG:
            case AtlasBaseTypeDef.ATLAS_TYPE_DATE:
                attrClass = Long.class;
                attrValue = StringUtils.isEmpty(attrVal) ? null : Long.parseLong(attrVal);
                break;
            case AtlasBaseTypeDef.ATLAS_TYPE_FLOAT:
                attrClass = Float.class;
                attrValue = StringUtils.isEmpty(attrVal) ? null : Float.parseFloat(attrVal);
                break;
            case AtlasBaseTypeDef.ATLAS_TYPE_DOUBLE:
                attrClass = Double.class;
                attrValue = StringUtils.isEmpty(attrVal) ? null : Double.parseDouble(attrVal);
                break;
            case AtlasBaseTypeDef.ATLAS_TYPE_BIGDECIMAL:
                attrClass = BigDecimal.class;
                attrValue = StringUtils.isEmpty(attrVal) ? null : new BigDecimal(attrVal);
                break;
            default:
                if (attrType instanceof AtlasEnumType) {
                    attrClass = String.class;
                } else if (attrType instanceof AtlasArrayType) {
                    attrClass = List.class;
                } else {
                    attrClass = Object.class;
                }

                attrValue = attrVal;
                break;
        }

        String vertexPropertyName = attribute.getVertexPropertyName();
        ret = predicate.generatePredicate(
                StringUtils.isEmpty(vertexPropertyName) ? attribute.getQualifiedName() : vertexPropertyName,
                attrValue, attrClass);
    }

    return ret;
}
 
Example 5
Source File: AtlasBuiltInTypes.java    From atlas with Apache License 2.0 4 votes vote down vote up
public AtlasIntType() {
    super(AtlasBaseTypeDef.ATLAS_TYPE_INT, TypeCategory.PRIMITIVE, SERVICE_TYPE_ATLAS_CORE);
}
 
Example 6
Source File: AtlasBuiltInTypes.java    From incubator-atlas with Apache License 2.0 4 votes vote down vote up
public AtlasIntType() {
    super(AtlasBaseTypeDef.ATLAS_TYPE_INT, TypeCategory.PRIMITIVE);
}