Commit 83e9c21f by jyoti0208 Committed by Madhan Neethiraj

ATLAS-3875: updated sample client to improve logging

parent b7255ec7
...@@ -41,14 +41,14 @@ public class DiscoveryExample { ...@@ -41,14 +41,14 @@ public class DiscoveryExample {
List<AtlasEntityHeader> entities = result != null ? result.getEntities() : null; List<AtlasEntityHeader> entities = result != null ? result.getEntities() : null;
int resultCount = entities == null ? 0 : entities.size(); int resultCount = entities == null ? 0 : entities.size();
System.out.println("DSL Query: " + dslQuery); SampleApp.log("DSL Query: " + dslQuery);
System.out.println(" result count: " + resultCount); SampleApp.log(" result count: " + resultCount);
for (int i = 0; i < resultCount; i++) { for (int i = 0; i < resultCount; i++) {
System.out.println(" result # " + (i + 1) + ": " + entities.get(i)); SampleApp.log(" result # " + (i + 1) + ": " + entities.get(i));
} }
} catch (Exception e) { } catch (Exception e) {
System.out.println("query -: " + dslQuery + " failed"); SampleApp.log("query -: " + dslQuery + " failed");
} }
} }
} }
...@@ -59,11 +59,11 @@ public class DiscoveryExample { ...@@ -59,11 +59,11 @@ public class DiscoveryExample {
List<AtlasEntityHeader> entities = result != null && result.getSearchResults() != null ? result.getSearchResults().getEntities() : null; List<AtlasEntityHeader> entities = result != null && result.getSearchResults() != null ? result.getSearchResults().getEntities() : null;
int resultCount = entities == null ? 0 : entities.size(); int resultCount = entities == null ? 0 : entities.size();
System.out.println("Quick search: query-string=" + searchString); SampleApp.log("Quick search: query-string=" + searchString);
System.out.println(" result count: " + resultCount); SampleApp.log(" result count: " + resultCount);
for (int i = 0; i < resultCount; i++) { for (int i = 0; i < resultCount; i++) {
System.out.println(" result # " + (i + 1) + ": " + entities.get(i)); SampleApp.log(" result # " + (i + 1) + ": " + entities.get(i));
} }
} catch (AtlasServiceException e) { } catch (AtlasServiceException e) {
e.printStackTrace(); e.printStackTrace();
...@@ -76,11 +76,11 @@ public class DiscoveryExample { ...@@ -76,11 +76,11 @@ public class DiscoveryExample {
List<AtlasEntityHeader> entities = result != null ? result.getEntities() : null; List<AtlasEntityHeader> entities = result != null ? result.getEntities() : null;
int resultCount = entities == null ? 0 : entities.size(); int resultCount = entities == null ? 0 : entities.size();
System.out.println("Basic search: typeName=" + typeName + ", classification=" + classification + ", query=" + query); SampleApp.log("Basic search: typeName=" + typeName + ", classification=" + classification + ", query=" + query);
System.out.println(" result count: " + resultCount); SampleApp.log(" result count: " + resultCount);
for (int i = 0; i < resultCount; i++) { for (int i = 0; i < resultCount; i++) {
System.out.println(" result # " + (i + 1) + ": " + entities.get(i)); SampleApp.log(" result # " + (i + 1) + ": " + entities.get(i));
} }
} catch (AtlasServiceException e) { } catch (AtlasServiceException e) {
e.printStackTrace(); e.printStackTrace();
......
...@@ -65,25 +65,25 @@ public class EntityExample { ...@@ -65,25 +65,25 @@ public class EntityExample {
if (dbEntity == null) { if (dbEntity == null) {
dbEntity = createDatabaseEntity(DATABASE_NAME); dbEntity = createDatabaseEntity(DATABASE_NAME);
System.out.println("Created database entity: typeName=" + dbEntity.getTypeName() + ", guid=" + dbEntity.getGuid()); SampleApp.log("Created entity: typeName=" + dbEntity.getTypeName() + ", qualifiedName=" + dbEntity.getAttribute(ATTR_QUALIFIED_NAME) + ", guid=" + dbEntity.getGuid());
} }
if (tableEntityCanada == null) { if (tableEntityCanada == null) {
tableEntityCanada = createTableEntity(TABLE_NAME + "_CANADA"); tableEntityCanada = createTableEntity(TABLE_NAME + "_CANADA");
System.out.println("Created table entity : typeName=" + tableEntityCanada.getTypeName() + ", guid=" + tableEntityCanada.getGuid()); SampleApp.log("Created entity: typeName=" + tableEntityCanada.getTypeName() + ", qualifiedName=" + tableEntityCanada.getAttribute(ATTR_QUALIFIED_NAME) + ", guid=" + tableEntityCanada.getGuid());
} }
if (tableEntityUS == null) { if (tableEntityUS == null) {
tableEntityUS = createTableEntity(TABLE_NAME + "_US"); tableEntityUS = createTableEntity(TABLE_NAME + "_US");
System.out.println("Created table entity : typeName=" + tableEntityUS.getTypeName() + ", guid=" + tableEntityUS.getGuid()); SampleApp.log("Created entity: typeName=" + tableEntityUS.getTypeName() + ", qualifiedName=" + tableEntityUS.getAttribute(ATTR_QUALIFIED_NAME) + ", guid=" + tableEntityUS.getGuid());
} }
if (loadProcess == null) { if (loadProcess == null) {
loadProcess = createProcessEntity(PROCESS_NAME); loadProcess = createProcessEntity(PROCESS_NAME);
System.out.println("Created process entity : typeName=" + loadProcess.getTypeName() + ", guid=" + loadProcess.getGuid()); SampleApp.log("Created entity: typeName=" + loadProcess.getTypeName() + ", qualifiedName=" + loadProcess.getAttribute(ATTR_QUALIFIED_NAME) + ", guid=" + loadProcess.getGuid());
} }
} }
...@@ -95,22 +95,23 @@ public class EntityExample { ...@@ -95,22 +95,23 @@ public class EntityExample {
AtlasEntityWithExtInfo entity = client.getEntityByGuid(entityGuid); AtlasEntityWithExtInfo entity = client.getEntityByGuid(entityGuid);
if (entity != null) { if (entity != null) {
System.out.println("Retrieved entity with guid=" + entityGuid + ": " + entity); SampleApp.log("Retrieved entity with guid=" + entityGuid);
SampleApp.log(" " + entity);
} }
} }
public void deleteEntities() throws Exception { public void deleteEntities() throws Exception {
client.deleteEntityByGuid(loadProcess.getGuid()); client.deleteEntityByGuid(loadProcess.getGuid());
System.out.println("Deleted entity: guid=" + loadProcess.getGuid()); SampleApp.log("Deleted entity: guid=" + loadProcess.getGuid());
List<String> entityGuids = Arrays.asList(tableEntityUS.getGuid(), tableEntityCanada.getGuid(), dbEntity.getGuid()); List<String> entityGuids = Arrays.asList(tableEntityUS.getGuid(), tableEntityCanada.getGuid(), dbEntity.getGuid());
client.deleteEntitiesByGuids(entityGuids); client.deleteEntitiesByGuids(entityGuids);
System.out.println("Deleted entities:"); SampleApp.log("Deleted entities:");
for (String entityGuid : entityGuids) { for (String entityGuid : entityGuids) {
System.out.println(" guid=" + entityGuid); SampleApp.log(" guid=" + entityGuid);
} }
} }
...@@ -119,14 +120,14 @@ public class EntityExample { ...@@ -119,14 +120,14 @@ public class EntityExample {
Arrays.asList(createColumn(COLUMN_TIME_ID, "int", "time id"), Arrays.asList(createColumn(COLUMN_TIME_ID, "int", "time id"),
createColumn(COLUMN_CUSTOMER_ID, "int", "customer id", SampleAppConstants.PII_TAG), createColumn(COLUMN_CUSTOMER_ID, "int", "customer id", SampleAppConstants.PII_TAG),
createColumn(COLUMN_COMPANY_ID, "double", "company id", SampleAppConstants.FINANCE_TAG)), createColumn(COLUMN_COMPANY_ID, "double", "company id", SampleAppConstants.FINANCE_TAG)),
SampleAppConstants.METRIC_CLASSIFICATION); SampleAppConstants.METRIC_TAG);
} }
private AtlasEntityHeader createProcessEntity(String processName) throws Exception { private AtlasEntityHeader createProcessEntity(String processName) throws Exception {
return createProcess(processName, "hive query for monthly avg salary", "user ETL", return createProcess(processName, "hive query for monthly avg salary", "user ETL",
asList(tableEntityUS), asList(tableEntityUS),
asList(tableEntityCanada), asList(tableEntityCanada),
"create table as select ", "plan", "id", "graph", SampleAppConstants.CLASSIFICATION); "create table as select ", "plan", "id", "graph", SampleAppConstants.CLASSIFIED_TAG);
} }
private AtlasEntityHeader createProcess(String name, String description, String user, List<AtlasEntity> inputs, List<AtlasEntity> outputs, private AtlasEntityHeader createProcess(String name, String description, String user, List<AtlasEntity> inputs, List<AtlasEntity> outputs,
...@@ -193,7 +194,7 @@ public class EntityExample { ...@@ -193,7 +194,7 @@ public class EntityExample {
} }
} }
} catch (AtlasServiceException e) { } catch (AtlasServiceException e) {
System.out.println("failed in create entity"); SampleApp.log("failed in create entity");
e.printStackTrace(); e.printStackTrace();
} }
......
...@@ -51,12 +51,12 @@ public class GlossaryExample { ...@@ -51,12 +51,12 @@ public class GlossaryExample {
assert (extInfo != null); assert (extInfo != null);
System.out.println("extra info of Glossary is :- " + extInfo.getGuid() + " name is :- " + extInfo.getName() + " language is :- " + extInfo.getLanguage()); SampleApp.log("extra info of Glossary is :- " + extInfo.getGuid() + " name is :- " + extInfo.getName() + " language is :- " + extInfo.getLanguage());
} }
public void createGlossaryTerm() throws Exception { public void createGlossaryTerm() throws Exception {
if (empSalaryTerm != null) { if (empSalaryTerm != null) {
System.out.println("EmpSalaryTerm: term already exists"); SampleApp.log("EmpSalaryTerm: term already exists");
return; return;
} }
...@@ -72,13 +72,13 @@ public class GlossaryExample { ...@@ -72,13 +72,13 @@ public class GlossaryExample {
empSalaryTerm = client.createGlossaryTerm(term); empSalaryTerm = client.createGlossaryTerm(term);
if (empSalaryTerm != null) { if (empSalaryTerm != null) {
System.out.println("Created term for Employee Salary: " + empSalaryTerm); SampleApp.log("Created term for Employee Salary: " + empSalaryTerm);
} }
} }
public void createGlossaryCategory() throws Exception { public void createGlossaryCategory() throws Exception {
if (empCompanyCategory != null) { if (empCompanyCategory != null) {
System.out.println("EmpSalaryCategory: category already exists"); SampleApp.log("EmpSalaryCategory: category already exists");
return; return;
} }
...@@ -94,7 +94,7 @@ public class GlossaryExample { ...@@ -94,7 +94,7 @@ public class GlossaryExample {
empCompanyCategory = client.createGlossaryCategory(category); empCompanyCategory = client.createGlossaryCategory(category);
if (empCompanyCategory != null) { if (empCompanyCategory != null) {
System.out.println("Created Category for Employee Category :- " + empCompanyCategory); SampleApp.log("Created Category for Employee Category :- " + empCompanyCategory);
} }
} }
...@@ -102,7 +102,7 @@ public class GlossaryExample { ...@@ -102,7 +102,7 @@ public class GlossaryExample {
if (empGlossary != null) { if (empGlossary != null) {
client.deleteGlossaryByGuid(empGlossary.getGuid()); client.deleteGlossaryByGuid(empGlossary.getGuid());
System.out.println("empGlossary is not present. Skipping the delete operation."); SampleApp.log("empGlossary is not present. Skipping the delete operation.");
} }
empGlossary = null; empGlossary = null;
......
...@@ -41,7 +41,7 @@ public class LineageExample { ...@@ -41,7 +41,7 @@ public class LineageExample {
AtlasEntityHeader fromEntity = guidEntityMap.get(relation.getFromEntityId()); AtlasEntityHeader fromEntity = guidEntityMap.get(relation.getFromEntityId());
AtlasEntityHeader toEntity = guidEntityMap.get(relation.getToEntityId()); AtlasEntityHeader toEntity = guidEntityMap.get(relation.getToEntityId());
System.out.println(fromEntity.getDisplayText() + "(" + fromEntity.getTypeName() + ") -> " + SampleApp.log(fromEntity.getDisplayText() + "(" + fromEntity.getTypeName() + ") -> " +
toEntity.getDisplayText() + "(" + toEntity.getTypeName() + ")"); toEntity.getDisplayText() + "(" + toEntity.getTypeName() + ")");
} }
} }
......
...@@ -22,7 +22,7 @@ import org.apache.atlas.AtlasException; ...@@ -22,7 +22,7 @@ import org.apache.atlas.AtlasException;
import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.utils.AuthenticationUtil; import org.apache.atlas.utils.AuthenticationUtil;
import java.util.Scanner; import java.util.Date;
public class SampleApp { public class SampleApp {
private AtlasClientV2 client; private AtlasClientV2 client;
...@@ -36,17 +36,17 @@ public class SampleApp { ...@@ -36,17 +36,17 @@ public class SampleApp {
} }
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
String[] basicAuthUsernamePassword = null;
String[] atlasServerUrls = null;
SampleApp sampleApp = null; SampleApp sampleApp = null;
try { try {
atlasServerUrls = getServerUrl();
if (!AuthenticationUtil.isKerberosAuthenticationEnabled()) { if (!AuthenticationUtil.isKerberosAuthenticationEnabled()) {
basicAuthUsernamePassword = getUserInput(); String[] atlasServerUrls = getServerUrl();
String[] basicAuthUsernamePassword = getUserInput();
sampleApp = new SampleApp(atlasServerUrls, basicAuthUsernamePassword); sampleApp = new SampleApp(atlasServerUrls, basicAuthUsernamePassword);
} else { } else {
String[] atlasServerUrls = getServerUrl();
sampleApp = new SampleApp(atlasServerUrls); sampleApp = new SampleApp(atlasServerUrls);
} }
...@@ -75,8 +75,6 @@ public class SampleApp { ...@@ -75,8 +75,6 @@ public class SampleApp {
sampleApp.glossaryExample(); sampleApp.glossaryExample();
entityExample.deleteEntities(); entityExample.deleteEntities();
typeDefExample.removeTypeDefinitions();
} finally { } finally {
if (sampleApp != null && sampleApp.getClient() != null) { if (sampleApp != null && sampleApp.getClient() != null) {
sampleApp.getClient().close(); sampleApp.getClient().close();
...@@ -84,6 +82,10 @@ public class SampleApp { ...@@ -84,6 +82,10 @@ public class SampleApp {
} }
} }
public static void log(String message) {
System.out.println("[" + new Date() + "] " + message);
}
public AtlasClientV2 getClient() { public AtlasClientV2 getClient() {
return client; return client;
} }
...@@ -99,7 +101,7 @@ public class SampleApp { ...@@ -99,7 +101,7 @@ public class SampleApp {
discoveryExample.testSearch(); discoveryExample.testSearch();
discoveryExample.quickSearch(entity.getTypeName()); discoveryExample.quickSearch(entity.getTypeName());
discoveryExample.basicSearch(entity.getTypeName(), SampleAppConstants.METRIC_CLASSIFICATION, (String)entity.getAttribute(SampleAppConstants.ATTR_NAME)); discoveryExample.basicSearch(entity.getTypeName(), SampleAppConstants.METRIC_TAG, (String)entity.getAttribute(SampleAppConstants.ATTR_NAME));
} }
private void glossaryExample() throws Exception { private void glossaryExample() throws Exception {
...@@ -113,39 +115,30 @@ public class SampleApp { ...@@ -113,39 +115,30 @@ public class SampleApp {
} }
private static String[] getUserInput() { private static String[] getUserInput() {
String username = null;
String password = null;
try { try {
Scanner scanner = new Scanner(System.in); String username = System.console().readLine("Enter username: ");
char[] pwChar = System.console().readPassword("Enter password: ");
String password = (pwChar != null) ? new String(pwChar) : "";
System.out.println("Enter username for atlas :- "); return new String[] { username, password };
username = scanner.nextLine();
System.out.println("Enter password for atlas :- ");
password = scanner.nextLine();
} catch (Exception e) { } catch (Exception e) {
System.out.print("Error while reading user input"); System.out.print("Error while reading user input");
System.exit(1); System.exit(1);
} }
return new String[] { username, password }; return null; // will not reach here
} }
private static String[] getServerUrl() { private static String[] getServerUrl() {
String atlasServerUrl = null;
try { try {
Scanner scanner = new Scanner(System.in); String atlasServerUrl = System.console().readLine("Enter Atlas server URL: ");
System.out.println("Enter url for Atlas server :- "); return new String[] { atlasServerUrl };
atlasServerUrl = scanner.nextLine();
} catch (Exception e) { } catch (Exception e) {
System.out.print("Error while reading user input"); System.out.print("Error while reading user input");
System.exit(1); System.exit(1);
} }
return new String[] { atlasServerUrl }; return null; // will not reach here
} }
} }
\ No newline at end of file
...@@ -56,20 +56,20 @@ public final class SampleAppConstants { ...@@ -56,20 +56,20 @@ public final class SampleAppConstants {
public static final String ENTITY_TYPE_DATASET = "DataSet"; public static final String ENTITY_TYPE_DATASET = "DataSet";
public static final String ENTITY_TYPE_PROCESS = "Process"; public static final String ENTITY_TYPE_PROCESS = "Process";
public static final String PII_TAG = "sample_pii_Tag"; public static final String PII_TAG = "SAMPLE_PII";
public static final String FINANCE_TAG = "sample_finance_Tag"; public static final String FINANCE_TAG = "SAMPLE_FINANCE";
public static final String CLASSIFICATION = "classification"; public static final String CLASSIFIED_TAG = "SAMPLE_CLASSIFIED";
public static final String METRIC_CLASSIFICATION = "Metric"; public static final String METRIC_TAG = "SAMPLE_METRIC";
public static final String DATABASE_TYPE = "sample_db_type"; public static final String DATABASE_TYPE = "sample_db_type";
public static final String PROCESS_TYPE = "sample_process_type"; public static final String PROCESS_TYPE = "sample_process_type";
public static final String TABLE_TYPE = "sample_table_type"; public static final String TABLE_TYPE = "sample_table_type";
public static final String COLUMN_TYPE = "sample_column_type"; public static final String COLUMN_TYPE = "sample_column_type";
public static final String TABLE_DATABASE_TYPE = "sample_Table_DB"; public static final String TABLE_DATABASE_TYPE = "sample_db_tables";
public static final String TABLE_COLUMNS_TYPE = "sample_Table_Columns"; public static final String TABLE_COLUMNS_TYPE = "sample_table_columns";
public static final String ENUM_TABLE_TYPE = "tableType"; public static final String ENUM_TABLE_TYPE = "sample_tableType";
public static final String BUSINESS_METADATA_TYPE = "bmWithAllTypes"; public static final String BUSINESS_METADATA_TYPE = "sample_bmWithAllTypes";
public static final String BUSINESS_METADATA_TYPE_MV = "bmWithAllTypesMV"; public static final String BUSINESS_METADATA_TYPE_MV = "sample_bmWithAllTypesMV";
public static final String STRUCT_TYPE_SERDE = "serdeType"; public static final String STRUCT_TYPE_SERDE = "sample_serdeType";
} }
...@@ -58,9 +58,9 @@ public class TypeDefExample { ...@@ -58,9 +58,9 @@ public class TypeDefExample {
SampleAppConstants.COLUMN_TYPE, SampleAppConstants.COLUMN_TYPE,
SampleAppConstants.PROCESS_TYPE, SampleAppConstants.PROCESS_TYPE,
SampleAppConstants.PII_TAG, SampleAppConstants.PII_TAG,
SampleAppConstants.CLASSIFICATION, SampleAppConstants.CLASSIFIED_TAG,
SampleAppConstants.FINANCE_TAG, SampleAppConstants.FINANCE_TAG,
SampleAppConstants.METRIC_CLASSIFICATION SampleAppConstants.METRIC_TAG
}; };
private final AtlasClientV2 client; private final AtlasClientV2 client;
...@@ -104,7 +104,7 @@ public class TypeDefExample { ...@@ -104,7 +104,7 @@ public class TypeDefExample {
assert (!typesDef.isEmpty()); assert (!typesDef.isEmpty());
System.out.println("Created type [" + typeName + "]"); SampleApp.log("Created type: " + typeName);
} }
} }
...@@ -114,7 +114,7 @@ public class TypeDefExample { ...@@ -114,7 +114,7 @@ public class TypeDefExample {
typesDef = null; typesDef = null;
System.out.println("Deleted TypeDef successfully!"); SampleApp.log("Deleted TypesDef successfully!");
} }
} }
...@@ -172,10 +172,10 @@ public class TypeDefExample { ...@@ -172,10 +172,10 @@ public class TypeDefExample {
} }
private List<AtlasClassificationDef> createClassificationDefs() { private List<AtlasClassificationDef> createClassificationDefs() {
AtlasClassificationDef classification = createTraitTypeDef(SampleAppConstants.CLASSIFICATION, Collections.<String>emptySet(), AtlasTypeUtil.createRequiredAttrDef("tag", "string")); AtlasClassificationDef classification = createTraitTypeDef(SampleAppConstants.CLASSIFIED_TAG, Collections.<String>emptySet(), AtlasTypeUtil.createRequiredAttrDef("tag", "string"));
AtlasClassificationDef pii = createTraitTypeDef(SampleAppConstants.PII_TAG, Collections.<String>emptySet()); AtlasClassificationDef pii = createTraitTypeDef(SampleAppConstants.PII_TAG, Collections.<String>emptySet());
AtlasClassificationDef finance = createTraitTypeDef(SampleAppConstants.FINANCE_TAG, Collections.<String>emptySet()); AtlasClassificationDef finance = createTraitTypeDef(SampleAppConstants.FINANCE_TAG, Collections.<String>emptySet());
AtlasClassificationDef metric = createTraitTypeDef(SampleAppConstants.METRIC_CLASSIFICATION, Collections.emptySet()); AtlasClassificationDef metric = createTraitTypeDef(SampleAppConstants.METRIC_TAG, Collections.emptySet());
return Arrays.asList(classification, pii, finance, metric); return Arrays.asList(classification, pii, finance, metric);
} }
...@@ -223,7 +223,7 @@ public class TypeDefExample { ...@@ -223,7 +223,7 @@ public class TypeDefExample {
for (AtlasEnumDef enumDef : typesDef.getEnumDefs()) { for (AtlasEnumDef enumDef : typesDef.getEnumDefs()) {
if (client.typeWithNameExists(enumDef.getName())) { if (client.typeWithNameExists(enumDef.getName())) {
System.out.println("Type " + enumDef.getName() + " already exists. Skipping"); SampleApp.log(enumDef.getName() + ": type already exists. Skipping");
} else { } else {
typesToCreate.getEnumDefs().add(enumDef); typesToCreate.getEnumDefs().add(enumDef);
} }
...@@ -231,7 +231,7 @@ public class TypeDefExample { ...@@ -231,7 +231,7 @@ public class TypeDefExample {
for (AtlasStructDef structDef : typesDef.getStructDefs()) { for (AtlasStructDef structDef : typesDef.getStructDefs()) {
if (client.typeWithNameExists(structDef.getName())) { if (client.typeWithNameExists(structDef.getName())) {
System.out.println("Type " + structDef.getName() + " already exists. Skipping"); SampleApp.log(structDef.getName() + ": type already exists. Skipping");
} else { } else {
typesToCreate.getStructDefs().add(structDef); typesToCreate.getStructDefs().add(structDef);
} }
...@@ -239,7 +239,7 @@ public class TypeDefExample { ...@@ -239,7 +239,7 @@ public class TypeDefExample {
for (AtlasEntityDef entityDef : typesDef.getEntityDefs()) { for (AtlasEntityDef entityDef : typesDef.getEntityDefs()) {
if (client.typeWithNameExists(entityDef.getName())) { if (client.typeWithNameExists(entityDef.getName())) {
System.out.println("Type " + entityDef.getName() + " already exists. Skipping"); SampleApp.log(entityDef.getName() + ": type already exists. Skipping");
} else { } else {
typesToCreate.getEntityDefs().add(entityDef); typesToCreate.getEntityDefs().add(entityDef);
} }
...@@ -247,7 +247,7 @@ public class TypeDefExample { ...@@ -247,7 +247,7 @@ public class TypeDefExample {
for (AtlasClassificationDef classificationDef : typesDef.getClassificationDefs()) { for (AtlasClassificationDef classificationDef : typesDef.getClassificationDefs()) {
if (client.typeWithNameExists(classificationDef.getName())) { if (client.typeWithNameExists(classificationDef.getName())) {
System.out.println("Type " + classificationDef.getName() + " already exists. Skipping"); SampleApp.log(classificationDef.getName() + ": type already exists. Skipping");
} else { } else {
typesToCreate.getClassificationDefs().add(classificationDef); typesToCreate.getClassificationDefs().add(classificationDef);
} }
...@@ -255,7 +255,7 @@ public class TypeDefExample { ...@@ -255,7 +255,7 @@ public class TypeDefExample {
for (AtlasRelationshipDef relationshipDef : typesDef.getRelationshipDefs()) { for (AtlasRelationshipDef relationshipDef : typesDef.getRelationshipDefs()) {
if (client.typeWithNameExists(relationshipDef.getName())) { if (client.typeWithNameExists(relationshipDef.getName())) {
System.out.println("Type " + relationshipDef.getName() + " already exists. Skipping"); SampleApp.log(relationshipDef.getName() + ": type already exists. Skipping");
} else { } else {
typesToCreate.getRelationshipDefs().add(relationshipDef); typesToCreate.getRelationshipDefs().add(relationshipDef);
} }
...@@ -263,7 +263,7 @@ public class TypeDefExample { ...@@ -263,7 +263,7 @@ public class TypeDefExample {
for (AtlasBusinessMetadataDef businessMetadataDef : typesDef.getBusinessMetadataDefs()) { for (AtlasBusinessMetadataDef businessMetadataDef : typesDef.getBusinessMetadataDefs()) {
if (client.typeWithNameExists(businessMetadataDef.getName())) { if (client.typeWithNameExists(businessMetadataDef.getName())) {
System.out.println("Type " + businessMetadataDef.getName() + " already exists. Skipping"); SampleApp.log(businessMetadataDef.getName() + ": type already exists. Skipping");
} else { } else {
typesToCreate.getBusinessMetadataDefs().add(businessMetadataDef); typesToCreate.getBusinessMetadataDefs().add(businessMetadataDef);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment