@Override public void updateSignatureHash(MessageDigest digester, Object val) throws AtlasException { if( !(val instanceof ITypedStruct)) { throw new IllegalArgumentException("Unexpected value type " + val.getClass().getSimpleName() + ". Expected instance of ITypedStruct"); } digester.update(getName().getBytes(Charset.forName("UTF-8"))); if(fieldMapping.fields != null && val != null) { IStruct typedValue = (IStruct) val; for (AttributeInfo aInfo : fieldMapping.fields.values()) { Object attrVal = typedValue.get(aInfo.name); if(attrVal != null) { aInfo.dataType().updateSignatureHash(digester, attrVal); } } } }
public void setInt(String attrName, int val) throws AtlasException { AttributeInfo i = fieldMapping.fields.get(attrName); if (i == null) { throw new AtlasException(String.format("Unknown field %s for Struct %s", attrName, getTypeName())); } if (i.dataType() != DataTypes.INT_TYPE && !(i.dataType() instanceof EnumType)) { throw new AtlasException( String.format("Field %s for Struct %s is not a %s, call generic set method", attrName, getTypeName(), DataTypes.INT_TYPE.getName())); } int pos = fieldMapping.fieldPos.get(attrName); int nullPos = fieldMapping.fieldNullPos.get(attrName); nullFlags[nullPos] = false; ints[pos] = val; explicitSets[nullPos] = true; }
void processStruct(Object val) throws AtlasException { if (val == null || !(val instanceof IStruct)) { return; } IStruct i = (IStruct) val; IConstructableType type = typeSystem.getDataType(IConstructableType.class, i.getTypeName()); for (Map.Entry<String, AttributeInfo> e : type.fieldMapping().fields.entrySet()) { AttributeInfo aInfo = e.getValue(); String attrName = e.getKey(); if (aInfo.dataType().getTypeCategory() != DataTypes.TypeCategory.PRIMITIVE) { processValue(aInfo.dataType(), i.get(attrName)); } } }
void processStruct(Object val) throws AtlasException { if (val == null || !(val instanceof IStruct)) { return; } IStruct i = (IStruct) val; IConstructableType type = typeSystem.getDataType(IConstructableType.class, i.getTypeName()); for (Map.Entry<String, AttributeInfo> e : type.fieldMapping().fields.entrySet()) { AttributeInfo aInfo = e.getValue(); String attrName = e.getKey(); if (aInfo.dataType().getTypeCategory() != DataTypes.TypeCategory.PRIMITIVE) { processValue(aInfo.dataType(), i.get(attrName)); } } }
public void setBoolean(String attrName, boolean val) throws AtlasException { AttributeInfo i = fieldMapping.fields.get(attrName); if (i == null) { throw new AtlasException(String.format("Unknown field %s for Struct %s", attrName, getTypeName())); } if (i.dataType() != DataTypes.BOOLEAN_TYPE) { throw new AtlasException( String.format("Field %s for Struct %s is not a %s, call generic set method", attrName, getTypeName(), DataTypes.BOOLEAN_TYPE.getName())); } int pos = fieldMapping.fieldPos.get(attrName); int nullPos = fieldMapping.fieldNullPos.get(attrName); nullFlags[nullPos] = false; bools[pos] = val; explicitSets[nullPos] = true; }
public void setLong(String attrName, long val) throws AtlasException { AttributeInfo i = fieldMapping.fields.get(attrName); if (i == null) { throw new AtlasException(String.format("Unknown field %s for Struct %s", attrName, getTypeName())); } if (i.dataType() != DataTypes.LONG_TYPE) { throw new AtlasException( String.format("Field %s for Struct %s is not a %s, call generic set method", attrName, getTypeName(), DataTypes.LONG_TYPE.getName())); } int pos = fieldMapping.fieldPos.get(attrName); int nullPos = fieldMapping.fieldNullPos.get(attrName); nullFlags[nullPos] = false; longs[pos] = val; explicitSets[nullPos] = true; }
public void setString(String attrName, String val) throws AtlasException { AttributeInfo i = fieldMapping.fields.get(attrName); if (i == null) { throw new AtlasException(String.format("Unknown field %s for Struct %s", attrName, getTypeName())); } if (i.dataType() != DataTypes.STRING_TYPE) { throw new AtlasException( String.format("Field %s for Struct %s is not a %s, call generic set method", attrName, getTypeName(), DataTypes.STRING_TYPE.getName())); } int pos = fieldMapping.fieldPos.get(attrName); int nullPos = fieldMapping.fieldNullPos.get(attrName); nullFlags[nullPos] = val == null; strings[pos] = val; explicitSets[nullPos] = true; }
public void setBoolean(String attrName, boolean val) throws AtlasException { AttributeInfo i = fieldMapping.fields.get(attrName); if (i == null) { throw new AtlasException(String.format("Unknown field %s for Struct %s", attrName, getTypeName())); } if (i.dataType() != DataTypes.BOOLEAN_TYPE) { throw new AtlasException( String.format("Field %s for Struct %s is not a %s, call generic set method", attrName, getTypeName(), DataTypes.BOOLEAN_TYPE.getName())); } int pos = fieldMapping.fieldPos.get(attrName); int nullPos = fieldMapping.fieldNullPos.get(attrName); nullFlags[nullPos] = false; bools[pos] = val; explicitSets[nullPos] = true; }
protected void outputFields(IStruct s, Appendable buf, String fieldPrefix, Set<? extends IStruct> inProcess) throws AtlasException { for (Map.Entry<String, AttributeInfo> e : fields.entrySet()) { String attrName = e.getKey(); AttributeInfo i = e.getValue(); Object aVal = s.get(attrName); TypeUtils.outputVal(attrName + " : ", buf, fieldPrefix); if (aVal != null && aVal instanceof Id) { TypeUtils.outputVal(aVal.toString(), buf, ""); } else { i.dataType().output(aVal, buf, fieldPrefix, inProcess); } TypeUtils.outputVal("\n", buf, ""); } }
public void setDouble(String attrName, double val) throws AtlasException { AttributeInfo i = fieldMapping.fields.get(attrName); if (i == null) { throw new AtlasException(String.format("Unknown field %s for Struct %s", attrName, getTypeName())); } if (i.dataType() != DataTypes.DOUBLE_TYPE) { throw new AtlasException( String.format("Field %s for Struct %s is not a %s, call generic set method", attrName, getTypeName(), DataTypes.DOUBLE_TYPE.getName())); } int pos = fieldMapping.fieldPos.get(attrName); int nullPos = fieldMapping.fieldNullPos.get(attrName); nullFlags[nullPos] = false; doubles[pos] = val; explicitSets[nullPos] = true; }
public void setBigInt(String attrName, BigInteger val) throws AtlasException { AttributeInfo i = fieldMapping.fields.get(attrName); if (i == null) { throw new AtlasException(String.format("Unknown field %s for Struct %s", attrName, getTypeName())); } if (i.dataType() != DataTypes.BIGINTEGER_TYPE) { throw new AtlasException( String.format("Field %s for Struct %s is not a %s, call generic set method", attrName, getTypeName(), DataTypes.BIGINTEGER_TYPE.getName())); } int pos = fieldMapping.fieldPos.get(attrName); int nullPos = fieldMapping.fieldNullPos.get(attrName); nullFlags[nullPos] = val == null; bigIntegers[pos] = val; explicitSets[nullPos] = true; }
public void setDate(String attrName, Date val) throws AtlasException { AttributeInfo i = fieldMapping.fields.get(attrName); if (i == null) { throw new AtlasException(String.format("Unknown field %s for Struct %s", attrName, getTypeName())); } if (i.dataType() != DataTypes.DATE_TYPE) { throw new AtlasException( String.format("Field %s for Struct %s is not a %s, call generic set method", attrName, getTypeName(), DataTypes.DATE_TYPE.getName())); } int pos = fieldMapping.fieldPos.get(attrName); int nullPos = fieldMapping.fieldNullPos.get(attrName); nullFlags[nullPos] = val == null; dates[pos] = val; explicitSets[nullPos] = true; }
public void setShort(String attrName, short val) throws AtlasException { AttributeInfo i = fieldMapping.fields.get(attrName); if (i == null) { throw new AtlasException(String.format("Unknown field %s for Struct %s", attrName, getTypeName())); } if (i.dataType() != DataTypes.SHORT_TYPE) { throw new AtlasException( String.format("Field %s for Struct %s is not a %s, call generic set method", attrName, getTypeName(), DataTypes.SHORT_TYPE.getName())); } int pos = fieldMapping.fieldPos.get(attrName); int nullPos = fieldMapping.fieldNullPos.get(attrName); nullFlags[nullPos] = false; shorts[pos] = val; explicitSets[nullPos] = true; }
protected void outputFields(IStruct s, Appendable buf, String fieldPrefix, Set<? extends IStruct> inProcess) throws AtlasException { for (Map.Entry<String, AttributeInfo> e : fields.entrySet()) { String attrName = e.getKey(); AttributeInfo i = e.getValue(); Object aVal = s.get(attrName); TypeUtils.outputVal(attrName + " : ", buf, fieldPrefix); if (aVal != null && aVal instanceof Id) { TypeUtils.outputVal(aVal.toString(), buf, ""); } else { i.dataType().output(aVal, buf, fieldPrefix, inProcess); } TypeUtils.outputVal("\n", buf, ""); } }
public boolean getBoolean(String attrName) throws AtlasException { AttributeInfo i = fieldMapping.fields.get(attrName); if (i == null) { throw new AtlasException(String.format("Unknown field %s for Struct %s", attrName, getTypeName())); } if (i.dataType() != DataTypes.BOOLEAN_TYPE) { throw new AtlasException( String.format("Field %s for Struct %s is not a %s, call generic get method", attrName, getTypeName(), DataTypes.BOOLEAN_TYPE.getName())); } int pos = fieldMapping.fieldPos.get(attrName); int nullPos = fieldMapping.fieldNullPos.get(attrName); if (nullFlags[nullPos]) { return DataTypes.BOOLEAN_TYPE.nullValue(); } return bools[pos]; }
public long getLong(String attrName) throws AtlasException { AttributeInfo i = fieldMapping.fields.get(attrName); if (i == null) { throw new AtlasException(String.format("Unknown field %s for Struct %s", attrName, getTypeName())); } if (i.dataType() != DataTypes.LONG_TYPE) { throw new AtlasException( String.format("Field %s for Struct %s is not a %s, call generic get method", attrName, getTypeName(), DataTypes.LONG_TYPE.getName())); } int pos = fieldMapping.fieldPos.get(attrName); int nullPos = fieldMapping.fieldNullPos.get(attrName); if (nullFlags[nullPos]) { return DataTypes.LONG_TYPE.nullValue(); } return longs[pos]; }
void visitStruct(Object val) throws AtlasException { if (val == null || !(val instanceof IStruct)) { return; } IStruct i = (IStruct) val; IConstructableType type = typeSystem.getDataType(IConstructableType.class, i.getTypeName()); for (Map.Entry<String, AttributeInfo> e : type.fieldMapping().fields.entrySet()) { AttributeInfo aInfo = e.getValue(); String attrName = e.getKey(); if (aInfo.dataType().getTypeCategory() != DataTypes.TypeCategory.PRIMITIVE) { Object aVal = i.get(attrName); nodeProcessor.processNode(new Node(i, attrName, aInfo, aVal)); traverseValue(aInfo.dataType(), aVal); } } }
void visitStruct(Object val) throws AtlasException { if (val == null || !(val instanceof IStruct)) { return; } IStruct i = (IStruct) val; IConstructableType type = typeSystem.getDataType(IConstructableType.class, i.getTypeName()); for (Map.Entry<String, AttributeInfo> e : type.fieldMapping().fields.entrySet()) { AttributeInfo aInfo = e.getValue(); String attrName = e.getKey(); if (aInfo.dataType().getTypeCategory() != DataTypes.TypeCategory.PRIMITIVE) { Object aVal = i.get(attrName); nodeProcessor.processNode(new Node(i, attrName, aInfo, aVal)); traverseValue(aInfo.dataType(), aVal); } } }
private void setupRecursiveTypes() throws AtlasException { for (AttributeInfo info : recursiveRefs) { info.setDataType(dataType(info.dataType().getName())); } for (DataTypes.ArrayType arrType : recursiveArrayTypes) { arrType.setElemType(dataType(arrType.getElemType().getName())); } for (DataTypes.MapType mapType : recursiveMapTypes) { mapType.setKeyType(dataType(mapType.getKeyType().getName())); mapType.setValueType(dataType(mapType.getValueType().getName())); } }
private void setupRecursiveTypes() throws AtlasException { for (AttributeInfo info : recursiveRefs) { info.setDataType(dataType(info.dataType().getName())); } for (DataTypes.ArrayType arrType : recursiveArrayTypes) { arrType.setElemType(dataType(arrType.getElemType().getName())); } for (DataTypes.MapType mapType : recursiveMapTypes) { mapType.setKeyType(dataType(mapType.getKeyType().getName())); mapType.setValueType(dataType(mapType.getValueType().getName())); } }