Search in sources :

Example 1 with AttributeDefinition

use of org.apache.atlas.v1.model.typedef.AttributeDefinition in project atlas by apache.

the class AtlasStructDefStoreV1 method toAttributeDefinition.

public static AttributeDefinition toAttributeDefinition(AtlasAttribute attribute) {
    final AtlasAttributeDef attrDef = attribute.getAttributeDef();
    AttributeDefinition ret = new AttributeDefinition();
    ret.setName(attrDef.getName());
    ret.setDataTypeName(attrDef.getTypeName());
    ret.setMultiplicity(getMultiplicity(attrDef));
    ret.setIsComposite(attribute.isOwnedRef());
    ret.setIsUnique(attrDef.getIsUnique());
    ret.setIsIndexable(attrDef.getIsIndexable());
    ret.setReverseAttributeName(attribute.getInverseRefAttributeName());
    ret.setDescription(attrDef.getDescription());
    ret.setDefaultValue(attrDef.getDefaultValue());
    return ret;
}
Also used : AtlasAttributeDef(org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef) AttributeDefinition(org.apache.atlas.v1.model.typedef.AttributeDefinition)

Example 2 with AttributeDefinition

use of org.apache.atlas.v1.model.typedef.AttributeDefinition in project atlas by apache.

the class TypeConverterUtil method toAtlasClassificationDefs.

private static List<AtlasClassificationDef> toAtlasClassificationDefs(List<TraitTypeDefinition> traitTypeDefinitions) {
    List<AtlasClassificationDef> ret = new ArrayList<>();
    for (TraitTypeDefinition traitType : traitTypeDefinitions) {
        List<AtlasAttributeDef> attrDefs = new ArrayList<AtlasAttributeDef>();
        if (CollectionUtils.isNotEmpty(traitType.getAttributeDefinitions())) {
            for (AttributeDefinition attrDefinition : traitType.getAttributeDefinitions()) {
                attrDefs.add(toAtlasAttributeDef(attrDefinition));
            }
        }
        AtlasClassificationDef classifDef = new AtlasClassificationDef(traitType.getTypeName(), traitType.getTypeDescription(), traitType.getTypeVersion(), attrDefs, traitType.getSuperTypes());
        ret.add(classifDef);
    }
    return ret;
}
Also used : AtlasClassificationDef(org.apache.atlas.model.typedef.AtlasClassificationDef) TraitTypeDefinition(org.apache.atlas.v1.model.typedef.TraitTypeDefinition) AtlasAttributeDef(org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef) AttributeDefinition(org.apache.atlas.v1.model.typedef.AttributeDefinition)

Example 3 with AttributeDefinition

use of org.apache.atlas.v1.model.typedef.AttributeDefinition in project atlas by apache.

the class TypeConverterUtil method toAtlasEntityDefs.

private static List<AtlasEntityDef> toAtlasEntityDefs(List<ClassTypeDefinition> classTypeDefinitions, AtlasTypeRegistry registry) {
    List<AtlasEntityDef> ret = new ArrayList<>();
    for (ClassTypeDefinition classType : classTypeDefinitions) {
        List<AtlasAttributeDef> attrDefs = new ArrayList<AtlasAttributeDef>();
        if (CollectionUtils.isNotEmpty(classType.getAttributeDefinitions())) {
            for (AttributeDefinition oldAttr : classType.getAttributeDefinitions()) {
                AtlasAttributeDef newAttr = toAtlasAttributeDef(oldAttr);
                attrDefs.add(newAttr);
            }
        }
        AtlasEntityDef entityDef = new AtlasEntityDef(classType.getTypeName(), classType.getTypeDescription(), classType.getTypeVersion(), attrDefs, classType.getSuperTypes());
        ret.add(entityDef);
    }
    return ret;
}
Also used : AtlasEntityDef(org.apache.atlas.model.typedef.AtlasEntityDef) AtlasAttributeDef(org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef) AttributeDefinition(org.apache.atlas.v1.model.typedef.AttributeDefinition) ClassTypeDefinition(org.apache.atlas.v1.model.typedef.ClassTypeDefinition)

Example 4 with AttributeDefinition

use of org.apache.atlas.v1.model.typedef.AttributeDefinition in project atlas by apache.

the class TypeConverterUtil method classificationToTypesDef.

private static TypesDef classificationToTypesDef(AtlasClassificationType classificationType, AtlasTypeRegistry registry) {
    String typeName = classificationType.getClassificationDef().getName();
    String typeDesc = classificationType.getClassificationDef().getDescription();
    String typeVersion = classificationType.getClassificationDef().getTypeVersion();
    Set<String> superTypes = new HashSet<>(classificationType.getClassificationDef().getSuperTypes());
    List<AttributeDefinition> attributes = getAttributes(classificationType, registry);
    TraitTypeDefinition traitTypeDef = new TraitTypeDefinition(typeName, typeDesc, typeVersion, attributes, superTypes);
    TypesDef ret = new TypesDef(null, null, Arrays.asList(traitTypeDef), null);
    return ret;
}
Also used : TypesDef(org.apache.atlas.v1.model.typedef.TypesDef) AtlasTypesDef(org.apache.atlas.model.typedef.AtlasTypesDef) TraitTypeDefinition(org.apache.atlas.v1.model.typedef.TraitTypeDefinition) AttributeDefinition(org.apache.atlas.v1.model.typedef.AttributeDefinition)

Example 5 with AttributeDefinition

use of org.apache.atlas.v1.model.typedef.AttributeDefinition in project atlas by apache.

the class AtlasClient method createTraitType.

/**
 * Creates trait type with specifiedName, superTraits and attributes
 * @param traitName the name of the trait type
 * @param superTraits the list of super traits from which this trait type inherits attributes
 * @param attributeDefinitions the list of attributes of the trait type
 * @return the list of types created
 * @throws AtlasServiceException
 */
public List<String> createTraitType(String traitName, Set<String> superTraits, AttributeDefinition... attributeDefinitions) throws AtlasServiceException {
    TraitTypeDefinition piiTrait = TypesUtil.createTraitTypeDef(traitName, null, superTraits, Arrays.asList(attributeDefinitions));
    TypesDef typesDef = new TypesDef(Collections.emptyList(), Collections.emptyList(), Collections.singletonList(piiTrait), Collections.emptyList());
    LOG.debug("Creating trait type {} {}", traitName, AtlasType.toV1Json(piiTrait));
    return createType(AtlasType.toV1Json(typesDef));
}
Also used : TypesDef(org.apache.atlas.v1.model.typedef.TypesDef) TraitTypeDefinition(org.apache.atlas.v1.model.typedef.TraitTypeDefinition)

Aggregations

AttributeDefinition (org.apache.atlas.v1.model.typedef.AttributeDefinition)10 AtlasAttributeDef (org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef)8 AtlasTypesDef (org.apache.atlas.model.typedef.AtlasTypesDef)4 Multiplicity (org.apache.atlas.v1.model.typedef.Multiplicity)4 TypesDef (org.apache.atlas.v1.model.typedef.TypesDef)4 ClassTypeDefinition (org.apache.atlas.v1.model.typedef.ClassTypeDefinition)3 TraitTypeDefinition (org.apache.atlas.v1.model.typedef.TraitTypeDefinition)3 AtlasClassificationDef (org.apache.atlas.model.typedef.AtlasClassificationDef)2 AtlasEntityDef (org.apache.atlas.model.typedef.AtlasEntityDef)2 AtlasStructDef (org.apache.atlas.model.typedef.AtlasStructDef)2 AtlasConstraintDef (org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef)2 StructTypeDefinition (org.apache.atlas.v1.model.typedef.StructTypeDefinition)2 java.util (java.util)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 Collectors (java.util.stream.Collectors)1 AtlasClassification (org.apache.atlas.model.instance.AtlasClassification)1 AtlasEntity (org.apache.atlas.model.instance.AtlasEntity)1 AtlasEntityHeader (org.apache.atlas.model.instance.AtlasEntityHeader)1 AtlasObjectId (org.apache.atlas.model.instance.AtlasObjectId)1