ReloadMetadataExample.java 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /***************************************************************************************
  2. * IBM Confidential
  3. *
  4. * OCO Source Materials
  5. *
  6. * IBM Cognos Products: Moser
  7. *
  8. * (C) Copyright IBM Corp. 2020
  9. *
  10. * The source code for this program is not published or otherwise
  11. * divested of its trade secrets, irrespective of what has been
  12. * deposited with the U.S. Copyright Office.
  13. *
  14. ***************************************************************************************/
  15. import java.io.IOException;
  16. import com.ibm.bi.platform.modeling.sdk.examples.SchemaImportHelper;
  17. import com.ibm.bi.platform.modeling.sdk.examples.internal.ModelingHelper;
  18. import com.ibm.bi.platform.modeling.sdk.examples.internal.UnexpectedHTTPResponseException;
  19. /**
  20. * example which will reload a datasource schema
  21. *
  22. */
  23. public class ReloadMetadataExample {
  24. /**
  25. * Execute example which will reload a datasource schema
  26. *
  27. * @param args
  28. * args[0] ca server url origin, e.g. http://localhost:9300/
  29. *
  30. * args[1] file location with login credentials, e.g. { "parameters": [ { "name":
  31. * "CAMNamespace", "value": "LDAP" }, { "name": "h_CAM_action",
  32. * "value": "logonAs" }, { "name": "CAMUsername", "value":
  33. * "hmiller" }, { "name": "CAMPassword", "value": "hillock" } ] }
  34. *
  35. * args[2] datasource store Id
  36. * args[3] connection store id
  37. * args[4] signon store id
  38. *
  39. * args[5] file location with schema import options
  40. * , e.g.
  41. * {"schema":"FOODMART","catalog":"null","type":"dataSourceSchema",
  42. * "schemaType":"user","defaultName":"FOODMART","status":"pending"}
  43. *
  44. * or
  45. *
  46. * { "schema": "Person", "catalog": "AdventureWorks2014",
  47. * "schemaType": "user", "specification": { "dataStatistics":
  48. * "none", "excludedTables": [], "dataSamplingSize": 1000,
  49. * "version": "1.0", "importPrimaryForeignKeys": true },
  50. * "defaultName": "AdventureWorks2014/Person", "status":
  51. * "pending", "type":"dataSourceSchema" }
  52. */
  53. public static void main(String[] args) {
  54. if (args.length < 6) {
  55. System.err.print(
  56. "Correct arguments: origin fileWithCredentials datasourceId connectionId signonId fileWithschemaImportDefintion");
  57. return;
  58. }
  59. String origin = args[0];
  60. SchemaImportHelper helper = new SchemaImportHelper(origin);
  61. try {
  62. String credentials = ModelingHelper.stringFromFile(args[1]), datasourceId = args[2],
  63. connectionId = args[3], signonId = args[4], importOptions = ModelingHelper.stringFromFile(args[5]);
  64. helper.authenticate(credentials);
  65. helper.runReLoadMetadataExample(datasourceId, connectionId, signonId, importOptions);
  66. } catch (UnexpectedHTTPResponseException e) {
  67. try {
  68. System.out.println("Response :" + ModelingHelper.httpEntityToString(e.getResponse().getEntity()));
  69. } catch (IOException io) {
  70. }
  71. e.printStackTrace();
  72. } catch (IOException e) {
  73. e.printStackTrace();
  74. }
  75. }
  76. }