Java Code Examples for org.apache.atlas.model.typedef.AtlasTypesDef#getClassificationDefs()
The following examples show how to use
org.apache.atlas.model.typedef.AtlasTypesDef#getClassificationDefs() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AtlasTypeUtil.java From atlas with Apache License 2.0 | 5 votes |
public static List<AtlasTypeDefHeader> toTypeDefHeader(AtlasTypesDef typesDef) { List<AtlasTypeDefHeader> headerList = new LinkedList<>(); if (CollectionUtils.isNotEmpty(typesDef.getEnumDefs())) { for (AtlasEnumDef enumDef : typesDef.getEnumDefs()) { headerList.add(new AtlasTypeDefHeader(enumDef)); } } if (CollectionUtils.isNotEmpty(typesDef.getStructDefs())) { for (AtlasStructDef structDef : typesDef.getStructDefs()) { headerList.add(new AtlasTypeDefHeader(structDef)); } } if (CollectionUtils.isNotEmpty(typesDef.getClassificationDefs())) { for (AtlasClassificationDef classificationDef : typesDef.getClassificationDefs()) { headerList.add(new AtlasTypeDefHeader(classificationDef)); } } if (CollectionUtils.isNotEmpty(typesDef.getEntityDefs())) { for (AtlasEntityDef entityDef : typesDef.getEntityDefs()) { headerList.add(new AtlasTypeDefHeader(entityDef)); } } if (CollectionUtils.isNotEmpty(typesDef.getRelationshipDefs())) { for (AtlasRelationshipDef relationshipDef : typesDef.getRelationshipDefs()) { headerList.add(new AtlasTypeDefHeader(relationshipDef)); } } return headerList; }
Example 2
Source File: BulkFetchAndUpdate.java From atlas with Apache License 2.0 | 5 votes |
private List<AtlasClassificationDef> getAllClassificationsDefs() throws Exception { MultivaluedMap<String, String> searchParams = new MultivaluedMapImpl(); searchParams.add(SearchFilter.PARAM_TYPE, "CLASSIFICATION"); SearchFilter searchFilter = new SearchFilter(searchParams); AtlasTypesDef typesDef = atlasClientV2.getAllTypeDefs(searchFilter); displayCrLf("Found classifications: " + typesDef.getClassificationDefs().size()); return typesDef.getClassificationDefs(); }
Example 3
Source File: BaseResourceIT.java From incubator-atlas with Apache License 2.0 | 5 votes |
protected void batchCreateTypes(AtlasTypesDef typesDef) throws AtlasServiceException { AtlasTypesDef toCreate = new AtlasTypesDef(); for (AtlasEnumDef enumDef : typesDef.getEnumDefs()) { if (atlasClientV2.typeWithNameExists(enumDef.getName())) { LOG.warn("Type with name {} already exists. Skipping", enumDef.getName()); } else { toCreate.getEnumDefs().add(enumDef); } } for (AtlasStructDef structDef : typesDef.getStructDefs()) { if (atlasClientV2.typeWithNameExists(structDef.getName())) { LOG.warn("Type with name {} already exists. Skipping", structDef.getName()); } else { toCreate.getStructDefs().add(structDef); } } for (AtlasEntityDef entityDef : typesDef.getEntityDefs()) { if (atlasClientV2.typeWithNameExists(entityDef.getName())) { LOG.warn("Type with name {} already exists. Skipping", entityDef.getName()); } else { toCreate.getEntityDefs().add(entityDef); } } for (AtlasClassificationDef classificationDef : typesDef.getClassificationDefs()) { if (atlasClientV2.typeWithNameExists(classificationDef.getName())) { LOG.warn("Type with name {} already exists. Skipping", classificationDef.getName()); } else { toCreate.getClassificationDefs().add(classificationDef); } } atlasClientV2.createAtlasTypeDefs(toCreate); }
Example 4
Source File: TypeAttributeDifference.java From incubator-atlas with Apache License 2.0 | 5 votes |
private void updateClassificationDef(AtlasTypesDef typeDefinitionMap, AtlasImportResult result) throws AtlasBaseException { for (AtlasClassificationDef def: typeDefinitionMap.getClassificationDefs()) { AtlasClassificationDef existing = typeRegistry.getClassificationDefByName(def.getName()); if(existing != null && addAttributes(existing, def)) { typeDefStore.updateClassificationDefByName(existing.getName(), existing); result.incrementMeticsCounter("typedef:classification:update"); } } }
Example 5
Source File: AtlasTypeDefStoreInitializer.java From atlas with Apache License 2.0 | 4 votes |
public static AtlasTypesDef getTypesToCreate(AtlasTypesDef typesDef, AtlasTypeRegistry typeRegistry) { AtlasTypesDef typesToCreate = new AtlasTypesDef(); if (CollectionUtils.isNotEmpty(typesDef.getEnumDefs())) { for (AtlasEnumDef enumDef : typesDef.getEnumDefs()) { if (!typeRegistry.isRegisteredType(enumDef.getName())) { typesToCreate.getEnumDefs().add(enumDef); } } } if (CollectionUtils.isNotEmpty(typesDef.getStructDefs())) { for (AtlasStructDef structDef : typesDef.getStructDefs()) { if (!typeRegistry.isRegisteredType(structDef.getName())) { typesToCreate.getStructDefs().add(structDef); } } } if (CollectionUtils.isNotEmpty(typesDef.getClassificationDefs())) { for (AtlasClassificationDef classificationDef : typesDef.getClassificationDefs()) { if (!typeRegistry.isRegisteredType(classificationDef.getName())) { typesToCreate.getClassificationDefs().add(classificationDef); } } } if (CollectionUtils.isNotEmpty(typesDef.getEntityDefs())) { for (AtlasEntityDef entityDef : typesDef.getEntityDefs()) { if (!typeRegistry.isRegisteredType(entityDef.getName())) { typesToCreate.getEntityDefs().add(entityDef); } } } if (CollectionUtils.isNotEmpty(typesDef.getRelationshipDefs())) { for (AtlasRelationshipDef relationshipDef : typesDef.getRelationshipDefs()) { if (!typeRegistry.isRegisteredType(relationshipDef.getName())) { typesToCreate.getRelationshipDefs().add(relationshipDef); } } } if (CollectionUtils.isNotEmpty(typesDef.getBusinessMetadataDefs())) { for (AtlasBusinessMetadataDef businessMetadataDef : typesDef.getBusinessMetadataDefs()) { if (!typeRegistry.isRegisteredType(businessMetadataDef.getName())) { typesToCreate.getBusinessMetadataDefs().add(businessMetadataDef); } } } return typesToCreate; }
Example 6
Source File: AtlasTypeDefStoreInitializer.java From atlas with Apache License 2.0 | 4 votes |
public static AtlasTypesDef getTypesToUpdate(AtlasTypesDef typesDef, AtlasTypeRegistry typeRegistry, boolean checkTypeVersion) { AtlasTypesDef typesToUpdate = new AtlasTypesDef(); if (CollectionUtils.isNotEmpty(typesDef.getStructDefs())) { for (AtlasStructDef newStructDef : typesDef.getStructDefs()) { AtlasStructDef oldStructDef = typeRegistry.getStructDefByName(newStructDef.getName()); if (oldStructDef == null) { continue; } if (updateTypeAttributes(oldStructDef, newStructDef, checkTypeVersion)) { typesToUpdate.getStructDefs().add(newStructDef); } } } if (CollectionUtils.isNotEmpty(typesDef.getClassificationDefs())) { for (AtlasClassificationDef newClassifDef : typesDef.getClassificationDefs()) { AtlasClassificationDef oldClassifDef = typeRegistry.getClassificationDefByName(newClassifDef.getName()); if (oldClassifDef == null) { continue; } if (updateTypeAttributes(oldClassifDef, newClassifDef, checkTypeVersion)) { typesToUpdate.getClassificationDefs().add(newClassifDef); } } } if (CollectionUtils.isNotEmpty(typesDef.getEntityDefs())) { for (AtlasEntityDef newEntityDef : typesDef.getEntityDefs()) { AtlasEntityDef oldEntityDef = typeRegistry.getEntityDefByName(newEntityDef.getName()); if (oldEntityDef == null) { continue; } if (updateTypeAttributes(oldEntityDef, newEntityDef, checkTypeVersion)) { typesToUpdate.getEntityDefs().add(newEntityDef); } } } if (CollectionUtils.isNotEmpty(typesDef.getEnumDefs())) { for (AtlasEnumDef newEnumDef : typesDef.getEnumDefs()) { AtlasEnumDef oldEnumDef = typeRegistry.getEnumDefByName(newEnumDef.getName()); if (oldEnumDef == null) { continue; } if (isTypeUpdateApplicable(oldEnumDef, newEnumDef, checkTypeVersion)) { if (CollectionUtils.isNotEmpty(oldEnumDef.getElementDefs())) { for (AtlasEnumElementDef oldEnumElem : oldEnumDef.getElementDefs()) { if (!newEnumDef.hasElement(oldEnumElem.getValue())) { newEnumDef.addElement(oldEnumElem); } } } typesToUpdate.getEnumDefs().add(newEnumDef); } } } if (CollectionUtils.isNotEmpty(typesDef.getRelationshipDefs())) { for (AtlasRelationshipDef relationshipDef : typesDef.getRelationshipDefs()) { AtlasRelationshipDef oldRelationshipDef = typeRegistry.getRelationshipDefByName(relationshipDef.getName()); if (oldRelationshipDef == null) { continue; } if (updateTypeAttributes(oldRelationshipDef, relationshipDef, checkTypeVersion)) { typesToUpdate.getRelationshipDefs().add(relationshipDef); } } } if (CollectionUtils.isNotEmpty(typesDef.getBusinessMetadataDefs())) { for (AtlasBusinessMetadataDef businessMetadataDef : typesDef.getBusinessMetadataDefs()) { AtlasBusinessMetadataDef oldDef = typeRegistry.getBusinessMetadataDefByName(businessMetadataDef.getName()); if (oldDef == null) { continue; } if (updateTypeAttributes(oldDef, businessMetadataDef, checkTypeVersion)) { typesToUpdate.getBusinessMetadataDefs().add(businessMetadataDef); } } } return typesToUpdate; }
Example 7
Source File: AtlasTypeDefStoreInitializer.java From incubator-atlas with Apache License 2.0 | 4 votes |
public static AtlasTypesDef getTypesToCreate(AtlasTypesDef typesDef, AtlasTypeRegistry typeRegistry) { AtlasTypesDef typesToCreate = new AtlasTypesDef(); if (CollectionUtils.isNotEmpty(typesDef.getEnumDefs())) { for (AtlasEnumDef enumDef : typesDef.getEnumDefs()) { if (!typeRegistry.isRegisteredType(enumDef.getName())) { typesToCreate.getEnumDefs().add(enumDef); } } } if (CollectionUtils.isNotEmpty(typesDef.getStructDefs())) { for (AtlasStructDef structDef : typesDef.getStructDefs()) { if (!typeRegistry.isRegisteredType(structDef.getName())) { typesToCreate.getStructDefs().add(structDef); } } } if (CollectionUtils.isNotEmpty(typesDef.getClassificationDefs())) { for (AtlasClassificationDef classificationDef : typesDef.getClassificationDefs()) { if (!typeRegistry.isRegisteredType(classificationDef.getName())) { typesToCreate.getClassificationDefs().add(classificationDef); } } } if (CollectionUtils.isNotEmpty(typesDef.getEntityDefs())) { for (AtlasEntityDef entityDef : typesDef.getEntityDefs()) { if (!typeRegistry.isRegisteredType(entityDef.getName())) { typesToCreate.getEntityDefs().add(entityDef); } } } if (CollectionUtils.isNotEmpty(typesDef.getRelationshipDefs())) { for (AtlasRelationshipDef relationshipDef : typesDef.getRelationshipDefs()) { if (!typeRegistry.isRegisteredType(relationshipDef.getName())) { typesToCreate.getRelationshipDefs().add(relationshipDef); } } } return typesToCreate; }
Example 8
Source File: AtlasTypeDefStoreInitializer.java From incubator-atlas with Apache License 2.0 | 4 votes |
public static AtlasTypesDef getTypesToUpdate(AtlasTypesDef typesDef, AtlasTypeRegistry typeRegistry) { AtlasTypesDef typesToUpdate = new AtlasTypesDef(); if (CollectionUtils.isNotEmpty(typesDef.getStructDefs())) { for (AtlasStructDef newStructDef : typesDef.getStructDefs()) { AtlasStructDef oldStructDef = typeRegistry.getStructDefByName(newStructDef.getName()); if (oldStructDef == null) { continue; } if (updateTypeAttributes(oldStructDef, newStructDef)) { typesToUpdate.getStructDefs().add(newStructDef); } } } if (CollectionUtils.isNotEmpty(typesDef.getClassificationDefs())) { for (AtlasClassificationDef newClassifDef : typesDef.getClassificationDefs()) { AtlasClassificationDef oldClassifDef = typeRegistry.getClassificationDefByName(newClassifDef.getName()); if (oldClassifDef == null) { continue; } if (updateTypeAttributes(oldClassifDef, newClassifDef)) { typesToUpdate.getClassificationDefs().add(newClassifDef); } } } if (CollectionUtils.isNotEmpty(typesDef.getEntityDefs())) { for (AtlasEntityDef newEntityDef : typesDef.getEntityDefs()) { AtlasEntityDef oldEntityDef = typeRegistry.getEntityDefByName(newEntityDef.getName()); if (oldEntityDef == null) { continue; } if (updateTypeAttributes(oldEntityDef, newEntityDef)) { typesToUpdate.getEntityDefs().add(newEntityDef); } } } if (CollectionUtils.isNotEmpty(typesDef.getEnumDefs())) { for (AtlasEnumDef newEnumDef : typesDef.getEnumDefs()) { AtlasEnumDef oldEnumDef = typeRegistry.getEnumDefByName(newEnumDef.getName()); if (oldEnumDef == null) { continue; } if (isTypeUpdateApplicable(oldEnumDef, newEnumDef)) { if (CollectionUtils.isNotEmpty(oldEnumDef.getElementDefs())) { for (AtlasEnumElementDef oldEnumElem : oldEnumDef.getElementDefs()) { if (!newEnumDef.hasElement(oldEnumElem.getValue())) { newEnumDef.addElement(oldEnumElem); } } } typesToUpdate.getEnumDefs().add(newEnumDef); } } } if (CollectionUtils.isNotEmpty(typesDef.getRelationshipDefs())) { for (AtlasRelationshipDef relationshipDef : typesDef.getRelationshipDefs()) { AtlasRelationshipDef oldRelationshipDef = typeRegistry.getRelationshipDefByName(relationshipDef.getName()); if (oldRelationshipDef == null) { continue; } if (updateTypeAttributes(oldRelationshipDef, relationshipDef)) { typesToUpdate.getRelationshipDefs().add(relationshipDef); } } } return typesToUpdate; }