/*************************************************************************************** * IBM Confidential * * OCO Source Materials * * IBM Cognos Products: Moser * * (C) Copyright IBM Corp. 2020 * * The source code for this program is not published or otherwise * divested of its trade secrets, irrespective of what has been * deposited with the U.S. Copyright Office. * ***************************************************************************************/ import java.io.IOException; import com.ibm.bi.platform.modeling.sdk.examples.SchemaImportHelper; import com.ibm.bi.platform.modeling.sdk.examples.internal.ModelingHelper; import com.ibm.bi.platform.modeling.sdk.examples.internal.UnexpectedHTTPResponseException; /** * example which will load a datasource schema with all or subset of tables * defined by a spec loaded from a file */ public class LoadMetadataExample { /** * Execute example which will load a datasource schema * * @param args * args[0] ca server url origin, e.g. http://localhost:9300/ * * args[1] file location with login credentials, e.g. { "parameters": [ { "name": * "CAMNamespace", "value": "LDAP" }, { "name": "h_CAM_action", * "value": "logonAs" }, { "name": "CAMUsername", "value": * "hmiller" }, { "name": "CAMPassword", "value": "hillock" } ] } * * * args[2] datasource store Id * args[3] connection store id * args[4] signon store id * * args[5] file location with schema import options * , e.g. * {"schema":"FOODMART","catalog":"null","type":"dataSourceSchema", * "schemaType":"user","defaultName":"FOODMART"} * * or * * { "schema": "Person", "catalog": "AdventureWorks2014", * "schemaType": "user", "specification": { "dataStatistics": * "none", "excludedTables": [], "dataSamplingSize": 1000, * "version": "1.0", "importPrimaryForeignKeys": true }, * "defaultName": "AdventureWorks2014/Person", "type":"dataSourceSchema" } */ public static void main(String[] args) { if (args.length < 6) { System.err.println("Wrong number of arguments:" + args.length); System.err.println( "Correct arguments: origin fileWithCredentials datasourceId connectionId signonId fileWithschemaImportDefintion"); System.err.println("origin - ca server url origin, e.g. http://localhost:9300/"); System.err.println("fileWithCredentials - login credentials relative file path"); System.err.println("datasourceId - datasource store id"); System.err.println("connectionId - datasource connection store id"); System.err.println("signonId - signon object store id"); System.err.println("fileWithschemaImportDefintion - relative to the current directory file path to import options"); return; } try { String origin = args[0], credentials = ModelingHelper.stringFromFile(args[1]), datasourceId = args[2], connectionId = args[3], signonId = args[4], importOptions = ModelingHelper.stringFromFile(args[5]); SchemaImportHelper helper = new SchemaImportHelper(origin); helper.authenticate(credentials); helper.runLoadMetadataExample(datasourceId, connectionId, signonId, importOptions); } catch (UnexpectedHTTPResponseException e) { try { System.out.println("Response :" + ModelingHelper.httpEntityToString(e.getResponse().getEntity())); } catch (IOException io) { } e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }