private void addStructType(AtlasStructType structType, ExportService.ExportContext context) { if (!context.structTypes.contains(structType.getTypeName())) { context.structTypes.add(structType.getTypeName()); addAttributeTypes(structType, context); } }
private void addStructType(AtlasStructType structType, ExportContext context) { if (!context.structTypes.contains(structType.getTypeName())) { context.structTypes.add(structType.getTypeName()); addAttributeTypes(structType, context); } }
private static void addVertexPropertiesForCollectionAttributes(Collection<? extends AtlasStructType> types, Map<String, Map<String, List<String>>> typeAttrMap) { for (AtlasStructType type : types) { Map<String, List<String>> collectionProperties = getVertexPropertiesForCollectionAttributes(type); if(collectionProperties != null && collectionProperties.size() > 0) { typeAttrMap.put(type.getTypeName(), collectionProperties); } } }
void visitStruct(AtlasStructType structType, Object val) throws AtlasBaseException { if (structType == null || val == null) { return; } final AtlasStruct struct; if (val instanceof AtlasStruct) { struct = (AtlasStruct) val; } else if (val instanceof Map) { Map attributes = AtlasTypeUtil.toStructAttributes((Map) val); struct = new AtlasStruct(structType.getTypeName(), attributes); } else { throw new AtlasBaseException(AtlasErrorCode.INVALID_STRUCT_VALUE, val.toString()); } visitStruct(structType, struct); }
void visitStruct(AtlasStructType structType, Object val) throws AtlasBaseException { if (structType == null || val == null) { return; } final AtlasStruct struct; if (val instanceof AtlasStruct) { struct = (AtlasStruct) val; } else if (val instanceof Map) { Map attributes = AtlasTypeUtil.toStructAttributes((Map) val); struct = new AtlasStruct(structType.getTypeName(), attributes); } else { throw new AtlasBaseException(AtlasErrorCode.INVALID_STRUCT_VALUE, val.toString()); } visitStruct(structType, struct); }
messages.add(objName + "=" + obj + ": invalid value for type " + getTypeName());
messages.add(objName + "=" + obj + ": invalid value for type " + getTypeName());
LOG.warn("Ignoring unknown attribute {}.{}", structType.getTypeName(), attributeName);
@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()); }
protected Map<String, Object> fromV2ToV1(AtlasStructType structType, Map<String, Object> attributes, ConverterContext context) throws AtlasBaseException { Map<String, Object> ret = null; if (MapUtils.isNotEmpty(attributes)) { ret = new HashMap<>(); // Only process the requested/set attributes for (String attrName : attributes.keySet()) { AtlasAttribute attr = structType.getAttribute(attrName); if (attr == null) { LOG.warn("ignored unknown attribute {}.{}", structType.getTypeName(), attrName); continue; } AtlasType attrType = attr.getAttributeType(); Object v2Value = attributes.get(attr.getName()); Object v1Value; AtlasFormatConverter attrConverter = converterRegistry.getConverter(attrType.getTypeCategory()); v1Value = attrConverter.fromV2ToV1(v2Value, attrType, context); ret.put(attr.getName(), v1Value); } } return ret; }
LOG.warn("ignored unknown attribute {}.{}", structType.getTypeName(), attrName); continue;
private void validateAttributes(final AtlasStructType structType, final FilterCriteria filterCriteria) throws AtlasBaseException { if (filterCriteria != null) { FilterCriteria.Condition condition = filterCriteria.getCondition(); if (condition != null && CollectionUtils.isNotEmpty(filterCriteria.getCriterion())) { for (FilterCriteria criteria : filterCriteria.getCriterion()) { validateAttributes(structType, criteria); } } else { String attributeName = filterCriteria.getAttributeName(); if (StringUtils.isNotEmpty(attributeName) && structType.getAttributeType(attributeName) == null) { throw new AtlasBaseException(AtlasErrorCode.UNKNOWN_ATTRIBUTE, attributeName, structType.getTypeName()); } } } }
} else if (!attributeDef.getIsOptional()) { ret = false; messages.add(fieldName + ": mandatory attribute value missing in type " + getTypeName()); } else if (!attributeDef.getIsOptional()) { ret = false; messages.add(fieldName + ": mandatory attribute value missing in type " + getTypeName()); messages.add(objName + "=" + obj + ": invalid value for type " + getTypeName());
messages.add(fieldName + ": mandatory attribute value missing in type " + getTypeName()); messages.add(fieldName + ": mandatory attribute value missing in type " + getTypeName()); messages.add(fieldName + ": mandatory attribute value missing in type " + getTypeName()); messages.add(objName + "=" + obj + ": invalid value for type " + getTypeName());
LOG.warn("ignored unknown attribute {}.{}", structType.getTypeName(), attrName); continue;
if (!(attrType instanceof AtlasArrayType)) { throw new AtlasBaseException(AtlasErrorCode.INVALID_ATTRIBUTE_TYPE_FOR_CARDINALITY, getTypeName(), attributeDef.getName()); throw new AtlasBaseException(AtlasErrorCode.ATTRIBUTE_TYPE_INVALID, getTypeName(), attributeDef.getName());
@Override public void resolveReferences(AtlasTypeRegistry typeRegistry) throws AtlasBaseException { Map<String, AtlasAttribute> a = new HashMap<>(); for (AtlasAttributeDef attributeDef : structDef.getAttributeDefs()) { AtlasType attrType = typeRegistry.getType(attributeDef.getTypeName()); AtlasAttribute attribute = new AtlasAttribute(this, attributeDef, attrType); Cardinality cardinality = attributeDef.getCardinality(); if (cardinality == Cardinality.LIST || cardinality == Cardinality.SET) { if (!(attrType instanceof AtlasArrayType)) { throw new AtlasBaseException(AtlasErrorCode.INVALID_ATTRIBUTE_TYPE_FOR_CARDINALITY, getTypeName(), attributeDef.getName()); } AtlasArrayType arrayType = (AtlasArrayType)attrType; arrayType.setMinCount(attributeDef.getValuesMinCount()); arrayType.setMaxCount(attributeDef.getValuesMaxCount()); } a.put(attributeDef.getName(), attribute); } resolveConstraints(typeRegistry); this.allAttributes = Collections.unmodifiableMap(a); this.uniqAttributes = getUniqueAttributes(this.allAttributes); }
getTypeName(), attributeDef.getName(), CONSTRAINT_TYPE_OWNED_REF, attributeDef.getTypeName()); getTypeName(), attributeDef.getName(), CONSTRAINT_TYPE_INVERSE_REF, attributeDef.getTypeName()); getTypeName(), attributeDef.getName(), CONSTRAINT_PARAM_ATTRIBUTE, CONSTRAINT_TYPE_INVERSE_REF, String.valueOf(constraint.getParams())); getTypeName(), attributeDef.getName(), CONSTRAINT_TYPE_INVERSE_REF, attrType.getTypeName(), inverseRefAttrName); getTypeName(), attributeDef.getName(), CONSTRAINT_TYPE_INVERSE_REF, attrType.getTypeName(), inverseRefAttrName);
getTypeName(), attributeDef.getName(), CONSTRAINT_TYPE_OWNED_REF, attributeDef.getTypeName()); getTypeName(), attributeDef.getName(), CONSTRAINT_TYPE_INVERSE_REF, attributeDef.getTypeName()); getTypeName(), attributeDef.getName(), CONSTRAINT_PARAM_ATTRIBUTE, CONSTRAINT_TYPE_INVERSE_REF, String.valueOf(constraint.getParams())); getTypeName(), attributeDef.getName(), CONSTRAINT_TYPE_INVERSE_REF, attrType.getTypeName(), inverseRefAttrName); getTypeName(), attributeDef.getName(), CONSTRAINT_TYPE_INVERSE_REF, attrType.getTypeName(), inverseRefAttrName);