AtlasClientV2#updateClassifications method is used to update the classifications by unique attributes.
Signature
public void updateClassifications(String typeName, Map<String, String> uniqAttributes, List<AtlasClassification> classifications) throws AtlasServiceException
Before running the application.
Below snippet set the attribute ‘durationDaya’ value to 123.
AtlasClassification atlasClassification = new AtlasClassification();
atlasClassification.setTypeName("sensitive_data");
atlasClassification.setAttribute("durationInDays", 123);
atlasClassification.setPropagate(false);
atlasClassification.setRemovePropagationsOnEntityDelete(false);
atlasClassification.setValidityPeriods(Collections.EMPTY_LIST);
Map<String, String> uniqAttributes = new HashMap<>();
uniqAttributes.put("qualifiedName", "CreateEntity_DEMO1");
atlasClient.updateClassifications("DemoType1", uniqAttributes, Arrays.asList(atlasClassification));
Find the below working application.
Create atlas-application.properties file under src/main/resources folder.
atlas-application.properties
atlas.client.readTimeoutMSecs=30000 atlas.client.connectTimeoutMSecs=30000
Define UpdateClassificationOfEntityByUniqueAttributes class.
UpdateClassificationOfEntityByUniqueAttributes.java
package com.sample.app.classifications;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.apache.atlas.AtlasClientV2;
import org.apache.atlas.AtlasServiceException;
import org.apache.atlas.model.instance.AtlasClassification;
public class UpdateClassificationOfEntityByUniqueAttributes {
public static void main(String[] args) throws AtlasServiceException {
AtlasClientV2 atlasClient = new AtlasClientV2(new String[] { "http://localhost:21000" },
new String[] { "admin", "admin" });
AtlasClassification atlasClassification = new AtlasClassification();
atlasClassification.setTypeName("sensitive_data");
atlasClassification.setAttribute("durationInDays", 123);
atlasClassification.setPropagate(false);
atlasClassification.setRemovePropagationsOnEntityDelete(false);
atlasClassification.setValidityPeriods(Collections.EMPTY_LIST);
Map<String, String> uniqAttributes = new HashMap<>();
uniqAttributes.put("qualifiedName", "CreateEntity_DEMO1");
atlasClient.updateClassifications("DemoType1", uniqAttributes, Arrays.asList(atlasClassification));
}
}
After running the application.
No comments:
Post a Comment