private static String getQualifiedAttributeName(AtlasStructDef structDef, String attrName) { final String typeName = structDef.getName(); return attrName.contains(".") ? attrName : String.format("%s.%s", typeName, attrName); }
public String getQualifiedAttributePropertyKey(String attrName) throws AtlasBaseException { if ( allAttributes.containsKey(attrName)) { return allAttributes.get(attrName).getVertexPropertyName(); } throw new AtlasBaseException(AtlasErrorCode.UNKNOWN_ATTRIBUTE, attrName, structDef.getName()); }
public String getQualifiedAttributeName(String attrName) throws AtlasBaseException { if ( allAttributes.containsKey(attrName)) { return allAttributes.get(attrName).getQualifiedName(); } throw new AtlasBaseException(AtlasErrorCode.UNKNOWN_ATTRIBUTE, attrName, structDef.getName()); }
private void rectifyOwnedReferenceError(AtlasStructDef structDef, AtlasAttributeDef attributeDef) { List<AtlasConstraintDef> constraints = attributeDef.getConstraints(); if (CollectionUtils.isNotEmpty(constraints)) { for (int i = 0; i < constraints.size(); i++) { AtlasConstraintDef constraint = constraints.get(i); if (constraint.isConstraintType(AtlasConstraintDef.CONSTRAINT_TYPE_OWNED_REF)) { LOG.warn("Invalid constraint ownedRef for attribute {}.{}", structDef.getName(), attributeDef.getName()); constraints.remove(i); i--; } } } }
public String getQualifiedAttributeName(String attrName) throws AtlasBaseException { if ( allAttributes.containsKey(attrName)) { return allAttributes.get(attrName).getQualifiedName(); } throw new AtlasBaseException(AtlasErrorCode.UNKNOWN_ATTRIBUTE, attrName, structDef.getName()); }
@Override public AtlasStruct createDefaultValue() { AtlasStruct ret = new AtlasStruct(structDef.getName()); populateDefaultValues(ret); return ret; }
@Override public AtlasStruct createDefaultValue() { AtlasStruct ret = new AtlasStruct(structDef.getName()); populateDefaultValues(ret); return ret; }
@Override public Object createDefaultValue(Object defaultValue) { AtlasStruct ret = new AtlasStruct(structDef.getName()); populateDefaultValues(ret); return ret; }
@Override public Object createDefaultValue(Object defaultValue) { AtlasStruct ret = new AtlasStruct(structDef.getName()); populateDefaultValues(ret); return ret; }
@Override public AtlasStructDef update(AtlasStructDef structDef) throws AtlasBaseException { if (LOG.isDebugEnabled()) { LOG.debug("==> AtlasStructDefStoreV1.update({})", structDef); } validateType(structDef); AtlasStructDef ret = StringUtils.isNotBlank(structDef.getGuid()) ? updateByGuid(structDef.getGuid(), structDef) : updateByName(structDef.getName(), structDef); if (LOG.isDebugEnabled()) { LOG.debug("<== AtlasStructDefStoreV1.update({}): {}", structDef, ret); } return ret; }
@Override public AtlasStructDef update(AtlasStructDef structDef) throws AtlasBaseException { if (LOG.isDebugEnabled()) { LOG.debug("==> AtlasStructDefStoreV1.update({})", structDef); } validateType(structDef); AtlasStructDef ret = StringUtils.isNotBlank(structDef.getGuid()) ? updateByGuid(structDef.getGuid(), structDef) : updateByName(structDef.getName(), structDef); if (LOG.isDebugEnabled()) { LOG.debug("<== AtlasStructDefStoreV1.update({}): {}", structDef, ret); } return ret; }
private void updateStructDef(AtlasTypesDef typeDefinitionMap, AtlasImportResult result) throws AtlasBaseException { for (AtlasStructDef def : typeDefinitionMap.getStructDefs()) { AtlasStructDef existing = typeRegistry.getStructDefByName(def.getName()); if (existing != null && addAttributes(existing, def)) { typeDefStore.updateStructDefByName(existing.getName(), existing); result.incrementMeticsCounter("typedef:struct:update"); } } }
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; }
private void updateCollectionWithDifferingAttributes(List<AtlasStructDef.AtlasAttributeDef> difference, AtlasStructDef existing, AtlasStructDef.AtlasAttributeDef incoming) throws AtlasBaseException { AtlasStructDef.AtlasAttributeDef existingAttribute = existing.getAttribute(incoming.getName()); if (existingAttribute == null) { difference.add(incoming); } else { if (!existingAttribute.getTypeName().equals(incoming.getTypeName())) { LOG.error("Attribute definition difference found: {}, {}", existingAttribute, incoming); throw new AtlasBaseException(AtlasErrorCode.INVALID_IMPORT_ATTRIBUTE_TYPE_CHANGED, existing.getName(), existingAttribute.getName(), existingAttribute.getTypeName(), incoming.getTypeName()); } } }
private void checkAndUpdate(AtlasStructDef structDef) { for (AtlasAttributeDef attrDef : structDef.getAttributeDefs()) { String attrTypeName = getAttributeTypeName(attrDef.getTypeName()); if (classificationIndexMap.containsKey(attrTypeName)) { ClassificationToStructDefName pair = createLegacyStructDefFromClassification(attrTypeName); if (pair != null) { updateAttributeWithNewType(pair.getTypeName(), pair.getLegacyTypeName(), attrDef); addStructDefToTypesDef(structDef.getName(), attrDef.getName(), pair); LOG.info("scrubbed: {}:{} -> {}", structDef.getName(), attrDef.getName(), attrDef.getTypeName()); } } } }
private ClassificationToStructDefName createLegacyStructDefFromClassification(String typeName) { AtlasClassificationDef classificationDef = getClassificationDefByName(typeName); if (classificationDef == null) { return null; } AtlasStructDef structDef = getStructDefFromClassificationDef(classificationDef); addStructDefToTypesDef(structDef); return new ClassificationToStructDefName(classificationDef.getName(), structDef.getName()); }
private static TypesDef structToTypesDef(AtlasStructType structType, AtlasTypeRegistry registry) { String typeName = structType.getStructDef().getName(); String typeDesc = structType.getStructDef().getDescription(); String typeVersion = structType.getStructDef().getTypeVersion(); List<AttributeDefinition> attributes = getAttributes(structType, registry); StructTypeDefinition structTypeDef = new StructTypeDefinition(typeName, typeDesc, typeVersion, attributes); TypesDef ret = new TypesDef(null, Arrays.asList(structTypeDef), null, null); return ret; }
private void updateStructDef(AtlasTypesDef typeDefinitionMap, AtlasImportResult result) throws AtlasBaseException { for (AtlasStructDef def: typeDefinitionMap.getStructDefs()) { AtlasStructDef existing = typeRegistry.getStructDefByName(def.getName()); if(existing != null && addAttributes(existing, def)) { typeDefStore.updateStructDefByName(existing.getName(), existing); result.incrementMeticsCounter("typedef:struct:update"); } } }