Java Code Examples for org.apache.atlas.model.instance.AtlasEntity#setClassifications()
The following examples show how to use
org.apache.atlas.model.instance.AtlasEntity#setClassifications() .
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: QuickStartV2.java From atlas with Apache License 2.0 | 6 votes |
AtlasEntity createProcess(String name, String description, String user, List<AtlasEntity> inputs, List<AtlasEntity> outputs, String queryText, String queryPlan, String queryId, String queryGraph, String... classificationNames) throws Exception { AtlasEntity entity = new AtlasEntity(LOAD_PROCESS_TYPE); // set attributes entity.setAttribute("name", name); entity.setAttribute(REFERENCEABLE_ATTRIBUTE_NAME, name + CLUSTER_SUFFIX); entity.setAttribute("description", description); entity.setAttribute("user", user); entity.setAttribute("startTime", System.currentTimeMillis()); entity.setAttribute("endTime", System.currentTimeMillis() + 10000); entity.setAttribute("queryText", queryText); entity.setAttribute("queryPlan", queryPlan); entity.setAttribute("queryId", queryId); entity.setAttribute("queryGraph", queryGraph); // set relationship attributes entity.setRelationshipAttribute("inputs", toAtlasRelatedObjectIds(inputs)); entity.setRelationshipAttribute("outputs", toAtlasRelatedObjectIds(outputs)); // set classifications entity.setClassifications(toAtlasClassifications(classificationNames)); return createInstance(entity); }
Example 2
Source File: QuickStartV2.java From atlas with Apache License 2.0 | 6 votes |
AtlasEntity createProcessExecution(AtlasEntity hiveProcess, String name, String description, String user, String queryText, String queryPlan, String queryId, String queryGraph, String... classificationNames) throws Exception { AtlasEntity entity = new AtlasEntity(LOAD_PROCESS_EXECUTION_TYPE); Long startTime = System.currentTimeMillis(); Long endTime = System.currentTimeMillis() + 10000; // set attributes entity.setAttribute("name", name); entity.setAttribute(REFERENCEABLE_ATTRIBUTE_NAME, name + CLUSTER_SUFFIX + startTime.toString() + endTime.toString()); entity.setAttribute("description", description); entity.setAttribute("user", user); entity.setAttribute("startTime", startTime); entity.setAttribute("endTime", endTime); entity.setAttribute("queryText", queryText); entity.setAttribute("queryPlan", queryPlan); entity.setAttribute("queryId", queryId); entity.setAttribute("queryGraph", queryGraph); entity.setRelationshipAttribute("process", AtlasTypeUtil.toAtlasRelatedObjectId(hiveProcess)); // set classifications entity.setClassifications(toAtlasClassifications(classificationNames)); return createInstance(entity); }
Example 3
Source File: QuickStartV2.java From atlas with Apache License 2.0 | 6 votes |
AtlasEntity createView(String name, AtlasEntity database, List<AtlasEntity> inputTables, String... classificationNames) throws Exception { AtlasEntity entity = new AtlasEntity(VIEW_TYPE); // set attributes entity.setAttribute("name", name); entity.setAttribute(REFERENCEABLE_ATTRIBUTE_NAME, name + CLUSTER_SUFFIX); // set relationship attributes entity.setRelationshipAttribute("db", toAtlasRelatedObjectId(database)); entity.setRelationshipAttribute("inputTables", toAtlasRelatedObjectIds(inputTables)); // set classifications entity.setClassifications(toAtlasClassifications(classificationNames)); return createInstance(entity); }
Example 4
Source File: Action.java From atlas with Apache License 2.0 | 6 votes |
@Override public void apply(AtlasTransformableEntity transformableEntity) { AtlasEntity entity = transformableEntity.getEntity(); if (entity.getClassifications() == null) { entity.setClassifications(new ArrayList<>()); } boolean hasClassification = false; for (AtlasClassification c : entity.getClassifications()) { hasClassification = c.getTypeName().equals(classificationName); if (hasClassification) { break; } } if (!hasClassification) { entity.getClassifications().add(new AtlasClassification(classificationName)); } }
Example 5
Source File: ImportTransformer.java From atlas with Apache License 2.0 | 6 votes |
@Override public Object apply(Object o) { if (!(o instanceof AtlasEntity)) { return o; } AtlasEntity entity = (AtlasEntity) o; if(!passThruFilters(entity)) { return o; } if(entity.getClassifications() == null) { entity.setClassifications(new ArrayList<AtlasClassification>()); } for (AtlasClassification c : entity.getClassifications()) { if (c.getTypeName().equals(classificationName)) { return entity; } } entity.getClassifications().add(new AtlasClassification(classificationName)); return entity; }
Example 6
Source File: ImportTransformsTest.java From atlas with Apache License 2.0 | 6 votes |
@Test public void removeClassificationTransform_RemovesSpecifiedClassification() throws AtlasBaseException { List<AtlasClassification> classifications = new ArrayList<>(); classifications.add(new AtlasClassification("cl2_to_cl1")); String s = String.format(jsonReplaceRemoveClassification, "cl1", "cl2", "cl2", "cl1"); ImportTransforms t = ImportTransforms.fromJson(s); AtlasEntity entity = getHiveTableAtlasEntity(); String expected_qualifiedName = entity.getAttribute(ATTR_NAME_QUALIFIED_NAME).toString().replace("@cl1", "@cl2"); entity.setClassifications(classifications); assertEquals(entity.getClassifications().size(), 1); t.apply(entity); assertEquals(entity.getClassifications().size(), 0); assertNotNull(t); assertEquals(entity.getAttribute(ATTR_NAME_QUALIFIED_NAME), expected_qualifiedName); }
Example 7
Source File: EntityGraphRetriever.java From atlas with Apache License 2.0 | 6 votes |
private void mapClassifications(AtlasVertex entityVertex, AtlasEntity entity) throws AtlasBaseException { List<AtlasEdge> edges = getAllClassificationEdges(entityVertex); if (CollectionUtils.isNotEmpty(edges)) { List<AtlasClassification> allClassifications = new ArrayList<>(); for (AtlasEdge edge : edges) { AtlasVertex classificationVertex = edge.getInVertex(); AtlasClassification classification = toAtlasClassification(classificationVertex); if (classification != null) { allClassifications.add(classification); } } entity.setClassifications(allClassifications); } }
Example 8
Source File: QuickStartV2.java From atlas with Apache License 2.0 | 6 votes |
AtlasEntity createDatabase(String name, String description, String owner, String locationUri, String... classificationNames) throws Exception { AtlasEntity entity = new AtlasEntity(DATABASE_TYPE); // set attributes entity.setAttribute("name", name); entity.setAttribute(REFERENCEABLE_ATTRIBUTE_NAME, name + CLUSTER_SUFFIX); entity.setAttribute("description", description); entity.setAttribute("owner", owner); entity.setAttribute("locationuri", locationUri); entity.setAttribute("createTime", System.currentTimeMillis()); // set classifications entity.setClassifications(toAtlasClassifications(classificationNames)); return createInstance(entity); }
Example 9
Source File: BasicTestSetup.java From atlas with Apache License 2.0 | 6 votes |
protected AtlasEntity loadProcess(String name, String description, String user, List<AtlasEntity> inputTables, List<AtlasEntity> outputTables, String queryText, String queryPlan, String queryId, String queryGraph, String... traitNames) { AtlasEntity process = new AtlasEntity(HIVE_PROCESS_TYPE); process.setAttribute("name", name); process.setAttribute(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, name); process.setAttribute("description", description); process.setAttribute("userName", user); process.setAttribute("startTime", System.currentTimeMillis()); process.setAttribute("endTime", System.currentTimeMillis() + 10000); process.setAttribute("operationType", "load"); process.setAttribute("inputs", getAtlasObjectIds(inputTables)); process.setAttribute("outputs", getAtlasObjectIds(outputTables)); process.setAttribute("queryText", queryText); process.setAttribute("queryPlan", queryPlan); process.setAttribute("queryId", queryId); process.setAttribute("queryGraph", queryGraph); process.setClassifications(Stream.of(traitNames).map(AtlasClassification::new).collect(Collectors.toList())); return process; }
Example 10
Source File: BasicSearchClassificationTest.java From atlas with Apache License 2.0 | 6 votes |
private void createDimensionalTaggedEntityWithAttr() throws AtlasBaseException { AtlasEntity entityToDelete = new AtlasEntity(HIVE_TABLE_TYPE); entityToDelete.setAttribute("name", "Entity1"); entityToDelete.setAttribute(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, "entity.one"); List<AtlasClassification> cls = new ArrayList<>(); cls.add(new AtlasClassification(DIMENSIONAL_CLASSIFICATION, new HashMap<String, Object>() {{ put("attr1", "Test"); }})); entityToDelete.setClassifications(cls); //create entity final EntityMutationResponse response = entityStore.createOrUpdate(new AtlasEntityStream(new AtlasEntity.AtlasEntitiesWithExtInfo(entityToDelete)), false); AtlasEntityHeader entityHeader = response.getCreatedEntities().get(0); dimensionalTagGuid = entityHeader.getGuid(); }
Example 11
Source File: BasicSearchClassificationTest.java From atlas with Apache License 2.0 | 6 votes |
private void createDimensionTaggedEntityAndDelete() throws AtlasBaseException { AtlasEntity entityToDelete = new AtlasEntity(HIVE_TABLE_TYPE); entityToDelete.setAttribute("name", "entity to be deleted"); entityToDelete.setAttribute(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, "entity.tobedeleted"); List<AtlasClassification> cls = new ArrayList<>(); cls.add(new AtlasClassification(DIMENSION_CLASSIFICATION)); entityToDelete.setClassifications(cls); //create entity EntityMutationResponse response = entityStore.createOrUpdate(new AtlasEntityStream(new AtlasEntity.AtlasEntitiesWithExtInfo(entityToDelete)), false); AtlasEntityHeader entityHeader = response.getCreatedEntities().get(0); dimensionTagDeleteGuid = entityHeader.getGuid(); //delete entity entityStore.deleteById(dimensionTagDeleteGuid); }
Example 12
Source File: EntityGraphMapper.java From atlas with Apache License 2.0 | 5 votes |
private AtlasEntityHeader constructHeader(AtlasEntity entity, AtlasVertex vertex) throws AtlasBaseException { AtlasEntityHeader header = entityRetriever.toAtlasEntityHeaderWithClassifications(vertex); if (entity.getClassifications() == null) { entity.setClassifications(header.getClassifications()); } return header; }
Example 13
Source File: BaseResourceIT.java From incubator-atlas with Apache License 2.0 | 5 votes |
protected AtlasEntity createHiveTableInstanceV2(AtlasEntity databaseInstance, String tableName) throws Exception { AtlasEntity tableInstance = new AtlasEntity(HIVE_TABLE_TYPE_V2); tableInstance.setClassifications( Arrays.asList(new AtlasClassification("classification"), new AtlasClassification("pii"), new AtlasClassification("phi"), new AtlasClassification("pci"), new AtlasClassification("sox"), new AtlasClassification("sec"), new AtlasClassification("finance")) ); tableInstance.setAttribute(NAME, tableName); tableInstance.setAttribute(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, tableName); tableInstance.setAttribute("db", AtlasTypeUtil.getAtlasObjectId(databaseInstance)); tableInstance.setAttribute(DESCRIPTION, "bar table"); tableInstance.setAttribute("lastAccessTime", "2014-07-11T08:00:00.000Z"); tableInstance.setAttribute("type", "managed"); tableInstance.setAttribute("level", 2); tableInstance.setAttribute("tableType", "MANAGED"); // enum tableInstance.setAttribute("compressed", false); AtlasClassification classification = tableInstance.getClassifications().get(0); classification.setAttribute("tag", "foundation_etl"); AtlasStruct serde1Instance = new AtlasStruct("serdeType"); serde1Instance.setAttribute(NAME, "serde1"); serde1Instance.setAttribute("serde", "serde1"); tableInstance.setAttribute("serde1", serde1Instance); AtlasStruct serde2Instance = new AtlasStruct("serdeType"); serde2Instance.setAttribute(NAME, "serde2"); serde2Instance.setAttribute("serde", "serde2"); tableInstance.setAttribute("serde2", serde2Instance); List<AtlasClassification> traits = tableInstance.getClassifications(); Assert.assertEquals(traits.size(), 7); return tableInstance; }
Example 14
Source File: QuickStartV2.java From incubator-atlas with Apache License 2.0 | 5 votes |
AtlasEntity createDatabase(String name, String description, String owner, String locationUri, String... traitNames) throws Exception { AtlasEntity entity = new AtlasEntity(DATABASE_TYPE); entity.setClassifications(toAtlasClassifications(traitNames)); entity.setAttribute("name", name); entity.setAttribute("description", description); entity.setAttribute("owner", owner); entity.setAttribute("locationuri", locationUri); entity.setAttribute("createTime", System.currentTimeMillis()); return createInstance(entity, traitNames); }
Example 15
Source File: QuickStartV2.java From incubator-atlas with Apache License 2.0 | 5 votes |
AtlasEntity createView(String name, AtlasEntity db, List<AtlasEntity> inputTables, String... traitNames) throws Exception { AtlasEntity entity = new AtlasEntity(VIEW_TYPE); entity.setClassifications(toAtlasClassifications(traitNames)); entity.setAttribute("name", name); entity.setAttribute(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, name); entity.setAttribute("db", db); entity.setAttribute("inputTables", inputTables); return createInstance(entity, traitNames); }
Example 16
Source File: AtlasGlossaryTermDTO.java From atlas with Apache License 2.0 | 5 votes |
@Override public AtlasEntity toEntity(final AtlasGlossaryTerm obj) throws AtlasBaseException { if (LOG.isDebugEnabled()) { LOG.debug("==> AtlasGlossaryTermDTO.toEntity()", obj); } Objects.requireNonNull(obj, "atlasGlossaryTerm"); Objects.requireNonNull(obj.getQualifiedName(), "atlasGlossaryTerm qualifiedName must be specified"); Objects.requireNonNull(obj.getAnchor(), "atlasGlossaryTerm anchor must be specified"); AtlasEntity ret = getDefaultAtlasEntity(obj); ret.setAttribute("qualifiedName", obj.getQualifiedName()); ret.setAttribute("name", obj.getName()); ret.setAttribute("shortDescription", obj.getShortDescription()); ret.setAttribute("longDescription", obj.getLongDescription()); ret.setAttribute("examples", obj.getExamples()); ret.setAttribute("abbreviation", obj.getAbbreviation()); ret.setAttribute("usage", obj.getUsage()); ret.setAttribute("anchor", new AtlasObjectId(obj.getAnchor().getGlossaryGuid())); ret.setAttribute("additionalAttributes", obj.getAdditionalAttributes()); if (CollectionUtils.isNotEmpty(obj.getClassifications())) { if (LOG.isDebugEnabled()) { LOG.debug("Processing term classifications"); } ret.setClassifications(obj.getClassifications()); } if (LOG.isDebugEnabled()) { LOG.debug("<== AtlasGlossaryTermDTO.toEntity() : {}", ret); } return ret; }
Example 17
Source File: BaseResourceIT.java From atlas with Apache License 2.0 | 5 votes |
protected AtlasEntity createHiveTableInstanceV2(AtlasEntity databaseInstance, String tableName) throws Exception { AtlasEntity tableInstance = new AtlasEntity(HIVE_TABLE_TYPE_V2); tableInstance.setClassifications( Arrays.asList(new AtlasClassification(CLASSIFICATION), new AtlasClassification(PII_TAG), new AtlasClassification(PHI_TAG), new AtlasClassification(PCI_TAG), new AtlasClassification(SOX_TAG), new AtlasClassification(SEC_TAG), new AtlasClassification(FINANCE_TAG)) ); tableInstance.setAttribute(NAME, tableName); tableInstance.setAttribute(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, tableName); tableInstance.setAttribute("db", AtlasTypeUtil.getAtlasObjectId(databaseInstance)); tableInstance.setAttribute(DESCRIPTION, "bar table"); tableInstance.setAttribute("lastAccessTime", "2014-07-11T08:00:00.000Z"); tableInstance.setAttribute("type", "managed"); tableInstance.setAttribute("level", 2); tableInstance.setAttribute("tableType", "MANAGED"); // enum tableInstance.setAttribute("compressed", false); AtlasClassification classification = tableInstance.getClassifications().get(0); classification.setAttribute("tag", "foundation_etl"); AtlasStruct serde1Instance = new AtlasStruct("serdeType"); serde1Instance.setAttribute(NAME, "serde1"); serde1Instance.setAttribute("serde", "serde1"); tableInstance.setAttribute("serde1", serde1Instance); AtlasStruct serde2Instance = new AtlasStruct("serdeType"); serde2Instance.setAttribute(NAME, "serde2"); serde2Instance.setAttribute("serde", "serde2"); tableInstance.setAttribute("serde2", serde2Instance); List<AtlasClassification> traits = tableInstance.getClassifications(); Assert.assertEquals(traits.size(), 7); return tableInstance; }
Example 18
Source File: QuickStartV2.java From atlas with Apache License 2.0 | 5 votes |
AtlasEntity createTable(String name, String description, AtlasEntity database, String owner, String tableType, List<AtlasEntity> columns, String... classificationNames) throws Exception { AtlasEntity tblEntity = new AtlasEntity(TABLE_TYPE); // set attributes tblEntity.setAttribute("name", name); tblEntity.setAttribute(REFERENCEABLE_ATTRIBUTE_NAME, name + CLUSTER_SUFFIX); tblEntity.setAttribute("description", description); tblEntity.setAttribute("owner", owner); tblEntity.setAttribute("tableType", tableType); tblEntity.setAttribute("createTime", System.currentTimeMillis()); tblEntity.setAttribute("lastAccessTime", System.currentTimeMillis()); tblEntity.setAttribute("retention", System.currentTimeMillis()); // set relationship attributes AtlasEntity storageDesc = createStorageDescriptor("hdfs://host:8000/apps/warehouse/sales", "TextInputFormat", "TextOutputFormat", true); storageDesc.setRelationshipAttribute("table", toAtlasRelatedObjectId(tblEntity)); tblEntity.setRelationshipAttribute("db", toAtlasRelatedObjectId(database)); tblEntity.setRelationshipAttribute("sd", toAtlasRelatedObjectId(storageDesc)); tblEntity.setRelationshipAttribute("columns", toAtlasRelatedObjectIds(columns)); // set classifications tblEntity.setClassifications(toAtlasClassifications(classificationNames)); AtlasEntityWithExtInfo entityWithExtInfo = new AtlasEntityWithExtInfo(); entityWithExtInfo.setEntity(tblEntity); entityWithExtInfo.addReferredEntity(storageDesc); for (AtlasEntity column : columns) { column.setRelationshipAttribute("table", toAtlasRelatedObjectId(tblEntity)); entityWithExtInfo.addReferredEntity(column); } return createInstance(entityWithExtInfo); }
Example 19
Source File: QuickStartV2.java From atlas with Apache License 2.0 | 5 votes |
AtlasEntity createColumn(String databaseName, String tableName, String columnName, String dataType, String comment, String... classificationNames) { AtlasEntity ret = new AtlasEntity(COLUMN_TYPE); // set attributes ret.setAttribute("name", columnName); ret.setAttribute(REFERENCEABLE_ATTRIBUTE_NAME, databaseName + "." + tableName + "." + columnName + CLUSTER_SUFFIX); ret.setAttribute("dataType", dataType); ret.setAttribute("comment", comment); // set classifications ret.setClassifications(toAtlasClassifications(classificationNames)); return ret; }
Example 20
Source File: EntityGraphRetriever.java From incubator-atlas with Apache License 2.0 | 4 votes |
private void mapClassifications(AtlasVertex entityVertex, AtlasEntity entity, AtlasEntityExtInfo entityExtInfo) throws AtlasBaseException { final List<AtlasClassification> classifications = getClassifications(entityVertex, null); entity.setClassifications(classifications); }