public void normalizeAttributeValues(Map<String, Object> obj) { if (obj != null) { for (AtlasAttributeDef attributeDef : structDef.getAttributeDefs()) { String attributeName = attributeDef.getName(); if (obj.containsKey(attributeName)) { Object attributeValue = getNormalizedValue(obj.get(attributeName), attributeDef); obj.put(attributeName, attributeValue); } else if (!attributeDef.getIsOptional()) { obj.put(attributeName, createDefaultValue(attributeDef)); } } } }
public void normalizeAttributeValues(Map<String, Object> obj) { if (obj != null) { for (AtlasAttributeDef attributeDef : structDef.getAttributeDefs()) { String attributeName = attributeDef.getName(); if (obj.containsKey(attributeName)) { Object attributeValue = getNormalizedValue(obj.get(attributeName), attributeDef); obj.put(attributeName, attributeValue); } else if (!attributeDef.getIsOptional()) { obj.put(attributeName, createDefaultValue(attributeDef)); } } } }
public void populateDefaultValues(AtlasStruct obj) { if (obj != null) { Map<String, Object> attributes = obj.getAttributes(); if (attributes == null) { attributes = new HashMap<>(); } for (AtlasAttributeDef attributeDef : structDef.getAttributeDefs()) { if (!attributeDef.getIsOptional()) { attributes.put(attributeDef.getName(), createDefaultValue(attributeDef)); } } obj.setAttributes(attributes); } }
public void populateDefaultValues(AtlasStruct obj) { if (obj != null) { Map<String, Object> attributes = obj.getAttributes(); if (attributes == null) { attributes = new HashMap<>(); } for (AtlasAttributeDef attributeDef : structDef.getAttributeDefs()) { if (!attributeDef.getIsOptional()) { attributes.put(attributeDef.getName(), createDefaultValue(attributeDef)); } } obj.setAttributes(attributes); } }
@Test public void testStructTypeDefaultValue() { AtlasStruct defValue = structType.createDefaultValue(); assertNotNull(defValue); assertEquals(defValue.getTypeName(), structType.getTypeName()); }
@Test public void testStructTypeDefaultValue() { AtlasStruct defValue = structType.createDefaultValue(); assertNotNull(defValue); assertEquals(defValue.getTypeName(), structType.getTypeName()); }
public static AtlasStruct newStruct(AtlasStructDef structDef, AtlasTypeRegistry typesRegistry) { AtlasStruct ret = null; AtlasStructType structType = typesRegistry.getStructTypeByName(structDef.getName()); if (structType != null) { ret = structType.createDefaultValue(); } else { LOG.error("failed to get struct-type {}", structDef.getName()); } return ret; }
public static AtlasStruct newStruct(AtlasStructDef structDef, AtlasTypeRegistry typesRegistry) { AtlasStruct ret = null; AtlasStructType structType = typesRegistry.getStructTypeByName(structDef.getName()); if (structType != null) { ret = structType.createDefaultValue(); } else { LOG.error("failed to get struct-type {}", structDef.getName()); } return ret; }
public void normalizeAttributeValues(AtlasStruct obj) { if (obj != null) { for (AtlasAttributeDef attributeDef : structDef.getAttributeDefs()) { String attributeName = attributeDef.getName(); if (obj.hasAttribute(attributeName)) { Object attributeValue = getNormalizedValue(obj.getAttribute(attributeName), attributeDef); obj.setAttribute(attributeName, attributeValue); } else if (!attributeDef.getIsOptional()) { obj.setAttribute(attributeName, createDefaultValue(attributeDef)); } } } }
public void normalizeAttributeValues(AtlasStruct obj) { if (obj != null) { for (AtlasAttributeDef attributeDef : structDef.getAttributeDefs()) { String attributeName = attributeDef.getName(); if (obj.hasAttribute(attributeName)) { Object attributeValue = getNormalizedValue(obj.getAttribute(attributeName), attributeDef); obj.setAttribute(attributeName, attributeValue); } else if (!attributeDef.getIsOptional()) { obj.setAttribute(attributeName, createDefaultValue(attributeDef)); } } } }