private static AttributeDefinition[] getAttributes(AtlasStructType structType, AtlasTypeRegistry registry) throws AtlasBaseException { List<AttributeDefinition> ret = new ArrayList<>(); List<AtlasAttributeDef> attrDefs = structType.getStructDef().getAttributeDefs(); if (CollectionUtils.isNotEmpty(attrDefs)) { for (AtlasAttributeDef attrDef : attrDefs) { AtlasAttribute attribute = structType.getAttribute(attrDef.getName()); ret.add(AtlasStructDefStoreV1.toAttributeDefintion(attribute)); } } return ret.toArray(new AttributeDefinition[ret.size()]); } }
public AtlasAttributeDef getAttributeDef(String attributeName) { AtlasAttribute attribute = getAttribute(attributeName); return attribute != null ? attribute.getAttributeDef() : null; }
public AtlasAttributeDef getAttributeDef(String attributeName) { AtlasAttribute attribute = getAttribute(attributeName); return attribute != null ? attribute.getAttributeDef() : null; }
public AtlasType getAttributeType(String attributeName) { AtlasAttribute attribute = getAttribute(attributeName); return attribute != null ? attribute.getAttributeType() : null; }
public AtlasType getAttributeType(String attributeName) { AtlasAttribute attribute = getAttribute(attributeName); return attribute != null ? attribute.getAttributeType() : null; }
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);
AtlasAttribute attribute = structType.getAttribute(attributeName);
protected AtlasAttribute getAttributeForEdge(String edgeLabel) throws AtlasBaseException { AtlasEdgeLabel atlasEdgeLabel = new AtlasEdgeLabel(edgeLabel); AtlasType parentType = typeRegistry.getType(atlasEdgeLabel.getTypeName()); AtlasStructType parentStructType = (AtlasStructType) parentType; return parentStructType.getAttribute(atlasEdgeLabel.getAttributeName()); }
AtlasAttribute attr = structType.getAttribute(attrName);
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; }
for (Map.Entry<String, Object> entry : structVal1.getAttributes().entrySet()) { String attrName = entry.getKey(); AtlasAttribute attribute = getAttribute(attrName);
private static List<AttributeDefinition> getAttributes(AtlasStructType structType, AtlasTypeRegistry registry) { List<AttributeDefinition> ret = new ArrayList<>(); List<AtlasAttributeDef> attrDefs = structType.getStructDef().getAttributeDefs(); if (CollectionUtils.isNotEmpty(attrDefs)) { for (AtlasAttributeDef attrDef : attrDefs) { AtlasAttribute attribute = structType.getAttribute(attrDef.getName()); AttributeDefinition oldAttrDef = AtlasStructDefStoreV2.toAttributeDefinition(attribute); ret.add(new AttributeDefinition(oldAttrDef.getName(), oldAttrDef.getDataTypeName(), new Multiplicity(oldAttrDef.getMultiplicity()), oldAttrDef.getIsComposite(), oldAttrDef.getIsUnique(), oldAttrDef.getIsIndexable(), oldAttrDef.getReverseAttributeName())); } } return ret; } }
private void mapAttributes(AtlasStruct struct, AtlasVertex vertex, EntityOperation op, EntityMutationContext context) throws AtlasBaseException { if (LOG.isDebugEnabled()) { LOG.debug("==> mapAttributes({}, {})", op, struct.getTypeName()); } if (MapUtils.isNotEmpty(struct.getAttributes())) { AtlasStructType structType = getStructType(struct.getTypeName()); if (op.equals(CREATE)) { for (AtlasAttribute attribute : structType.getAllAttributes().values()) { Object attrValue = struct.getAttribute(attribute.getName()); mapAttribute(attribute, attrValue, vertex, op, context); } } else if (op.equals(UPDATE)) { for (String attrName : struct.getAttributes().keySet()) { AtlasAttribute attribute = structType.getAttribute(attrName); if (attribute != null) { Object attrValue = struct.getAttribute(attrName); mapAttribute(attribute, attrValue, vertex, op, context); } else { LOG.warn("mapAttributes(): invalid attribute {}.{}. Ignored..", struct.getTypeName(), attrName); } } } updateModificationMetadata(vertex); } if (LOG.isDebugEnabled()) { LOG.debug("<== mapAttributes({}, {})", op, struct.getTypeName()); } }
public static void updateVertexPreCreate(AtlasStructDef structDef, AtlasStructType structType, AtlasVertex vertex, AtlasTypeDefGraphStoreV2 typeDefStore) throws AtlasBaseException { List<String> attrNames = new ArrayList<>(structDef.getAttributeDefs().size()); for (AtlasAttributeDef attributeDef : structDef.getAttributeDefs()) { // Validate the mandatory features of an attribute (compatibility with legacy type system) if (StringUtils.isEmpty(attributeDef.getName())) { throw new AtlasBaseException(AtlasErrorCode.MISSING_MANDATORY_ATTRIBUTE, structDef.getName(), "name"); } if (StringUtils.isEmpty(attributeDef.getTypeName())) { throw new AtlasBaseException(AtlasErrorCode.MISSING_MANDATORY_ATTRIBUTE, structDef.getName(), "typeName"); } String propertyKey = AtlasGraphUtilsV2.getTypeDefPropertyKey(structDef, attributeDef.getName()); String encodedPropertyKey = AtlasGraphUtilsV2.encodePropertyKey(propertyKey); vertex.setProperty(encodedPropertyKey, toJsonFromAttribute(structType.getAttribute(attributeDef.getName()))); attrNames.add(attributeDef.getName()); } String typeNamePropertyKey = AtlasGraphUtilsV2.getTypeDefPropertyKey(structDef); String encodedtypeNamePropertyKey = AtlasGraphUtilsV2.encodePropertyKey(typeNamePropertyKey); vertex.setProperty(encodedtypeNamePropertyKey, attrNames); }
public static void updateVertexPreCreate(AtlasStructDef structDef, AtlasStructType structType, AtlasVertex vertex, AtlasTypeDefGraphStoreV2 typeDefStore) throws AtlasBaseException { List<String> attrNames = new ArrayList<>(structDef.getAttributeDefs().size()); for (AtlasAttributeDef attributeDef : structDef.getAttributeDefs()) { // Validate the mandatory features of an attribute (compatibility with legacy type system) if (StringUtils.isEmpty(attributeDef.getName())) { throw new AtlasBaseException(AtlasErrorCode.MISSING_MANDATORY_ATTRIBUTE, structDef.getName(), "name"); } if (StringUtils.isEmpty(attributeDef.getTypeName())) { throw new AtlasBaseException(AtlasErrorCode.MISSING_MANDATORY_ATTRIBUTE, structDef.getName(), "typeName"); } String propertyKey = AtlasGraphUtilsV2.getTypeDefPropertyKey(structDef, attributeDef.getName()); String encodedPropertyKey = AtlasGraphUtilsV2.encodePropertyKey(propertyKey); vertex.setProperty(encodedPropertyKey, toJsonFromAttribute(structType.getAttribute(attributeDef.getName()))); attrNames.add(attributeDef.getName()); } String typeNamePropertyKey = AtlasGraphUtilsV2.getTypeDefPropertyKey(structDef); String encodedtypeNamePropertyKey = AtlasGraphUtilsV2.encodePropertyKey(typeNamePropertyKey); vertex.setProperty(encodedtypeNamePropertyKey, attrNames); }
AtlasAttribute attr = structType.getAttribute(attrName);
private void mapAttributes(AtlasStruct struct, AtlasVertex vertex, EntityOperation op, EntityMutationContext context) throws AtlasBaseException { if (LOG.isDebugEnabled()) { LOG.debug("==> mapAttributes({}, {})", op, struct.getTypeName()); } if (MapUtils.isNotEmpty(struct.getAttributes())) { MetricRecorder metric = RequestContext.get().startMetricRecord("mapAttributes"); AtlasStructType structType = getStructType(struct.getTypeName()); if (op.equals(CREATE)) { for (AtlasAttribute attribute : structType.getAllAttributes().values()) { Object attrValue = struct.getAttribute(attribute.getName()); mapAttribute(attribute, attrValue, vertex, op, context); } } else if (op.equals(UPDATE)) { for (String attrName : struct.getAttributes().keySet()) { AtlasAttribute attribute = structType.getAttribute(attrName); if (attribute != null) { Object attrValue = struct.getAttribute(attrName); mapAttribute(attribute, attrValue, vertex, op, context); } else { LOG.warn("mapAttributes(): invalid attribute {}.{}. Ignored..", struct.getTypeName(), attrName); } } } updateModificationMetadata(vertex); RequestContext.get().endMetricRecord(metric); } if (LOG.isDebugEnabled()) { LOG.debug("<== mapAttributes({}, {})", op, struct.getTypeName()); } }
AtlasGraphUtilsV2.setProperty(vertex, propertyKey, toJsonFromAttribute(structType.getAttribute(attributeDef.getName())));
AtlasGraphUtilsV2.setProperty(vertex, propertyKey, toJsonFromAttribute(structType.getAttribute(attributeDef.getName())));