metadataEditor.js 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*******************************************************************************
  2. * IBM Confidential
  3. *
  4. * OCO Source Materials
  5. *
  6. * A and PM: PD
  7. *
  8. * (c) Copyright IBM Corp. 2015
  9. *
  10. * The source code for this program is not published or otherwise divested of
  11. * its trade secrets, irrespective of what has been deposited with the U.S.
  12. * Copyright Office.
  13. ******************************************************************************/
  14. require([
  15. "dojo/_base/declare",
  16. "pd/ui/_base",
  17. "pd/controller/mdsrvRequest",
  18. "pd/data/PdColumnAnalyser",
  19. "pd/widgets/MDAnalyseDialog",
  20. "dojo/domReady!"
  21. ],function(declare, _base, mdsrvRequest, PdColumnAnalyser, MDAnalyseDialog){
  22. declare("pd/ui/metadataEditor", [_base], {
  23. mode: pd.statics.MODE_EDIT,
  24. mdAnalyseDlg: null,
  25. renderMainContent: function(pdSpecValue) {
  26. if (this.mode == pd.statics.MODE_REFRESH) {
  27. this.showAnalyseDialog(pdSpecValue);
  28. } else {
  29. this._renderMainContent(pdSpecValue);
  30. this._setRefreshMode();
  31. }
  32. },
  33. _setRefreshMode: function() {
  34. this.mode = pd.statics.MODE_REFRESH;
  35. pd_uploader.uploadUrl = g_pd_gateway + "/metadataUIService?pid=pdm_process&c=processLOBData";
  36. pd_uploader.uploadUrl += "&dataSetStoreID="+encodeURIComponent(this.dataSetStoreID);
  37. pd_uploader.uploadUrl += "&repositoryName="+encodeURIComponent(this.repositoryName);
  38. pd_uploader.uploadUrl += "&repositoryConnection="+encodeURIComponent(this.repositoryConnection);
  39. pd_uploader.uploadUrl += "&repositorySignon="+encodeURIComponent(this.repositorySignon);
  40. },
  41. getTargetUrl: function() {
  42. return g_pd_gateway + "/metadataUIService?pid=pdm_process&c=readLOBDataSpec"
  43. + "&dataSetStoreID="+encodeURIComponent(this.dataSetStoreID)
  44. + "&repositoryName="+encodeURIComponent(this.repositoryName)
  45. + "&repositoryConnection="+encodeURIComponent(this.repositoryConnection)
  46. + "&repositorySignon="+encodeURIComponent(this.repositorySignon);
  47. },
  48. showAnalyseDialog: function(pdSpecValue) {
  49. var analyser = new PdColumnAnalyser({xmlInput: pdSpecValue});
  50. var prunedPdSpec = analyser.getSpecFromXml();
  51. this.mdAnalyseDlg = new MDAnalyseDialog({
  52. okHandler: dojo.hitch(this, this._applyChange, pdSpecValue, prunedPdSpec),
  53. cancelHandler: dojo.hitch(this, this._cancelChange),
  54. delta: analyser.getDeltaFromXml()
  55. });
  56. this.mdAnalyseDlg.show();
  57. },
  58. _closeAnalyseDialog: function(pdSpec) {
  59. if (this.mdAnalyseDlg){
  60. this.mdAnalyseDlg.hide();
  61. }
  62. this._renderMainContent(pdSpec);
  63. },
  64. _applyChange: function(pdSpec, pdPrunedSpec) {
  65. mdsrvRequest.saveDataSet(this.dataSetStoreID, this.repositoryName, this.repositoryConnection, this.repositorySignon, pdPrunedSpec,
  66. dojo.hitch(this, this._closeAnalyseDialog, pdSpec));
  67. },
  68. _cancelChange: function() {
  69. mdsrvRequest.cancelDataSet(this.dataSetStoreID, this.repositoryName, this.repositoryConnection, this.repositorySignon);
  70. },
  71. startup: function() {
  72. this.inherited(arguments);
  73. this.setStatus(pd.statics.STATUS_PROCESS);
  74. pd_uploader.submit();
  75. },
  76. getDataSetName: function() {
  77. return this.dataSetName;
  78. }
  79. });
  80. });