867572666f0df0188612bd5199186553bd670e30 | 436d3421e4242ab391ef48b4c453bcaed62e7490 | ||
---|---|---|---|
59 | // importProjectFunction & | 59 | // importProjectFunction & |
60 | // exportProjectFunction & | 60 | // exportProjectFunction & |
61 | injectFunction("setCurrentProject", setCurrentProject _, 1) & | 61 | injectFunction("setCurrentProject", setCurrentProject _, 1) & |
62 | injectFunction("removeProject", removeProject _ , 1) & | 62 | injectFunction("removeProject", removeProject _ , 0) & |
63 | injectFunction("removeIntegrationJob", removeIntegrationJob _ , 0) & | ||
63 | injectFunction("removeDataSource", removeDataSource _ , 1) & | 64 | injectFunction("removeDataSource", removeDataSource _ , 1) & |
64 | injectFunction("removeImportJob", removeImportJob _ , 1) & | 65 | injectFunction("removeImportJob", removeImportJob _ , 1) & |
65 | injectFunction("saveDataSource", saveDataSource _ , 2) & | 66 | injectFunction("saveDataSource", saveDataSource _ , 2) & |
66 | saveImportJobFunction & | 67 | injectFunction("saveImportJob", saveImportJob _ , 2) & |
67 | runSchedulerFunction & | 68 | injectFunction("saveIntegrationJob", saveIntegrationJob _ , 2) & |
68 | runIntegrationFunction | 69 | injectFunction("runScheduler", runScheduler _ , 0) & |
70 | injectFunction("runIntegration", runIntegration _ , 0) | ||
69 | } | 71 | } |
70 | 72 | ||
71 | //TODO Fix - ajax calls are executed more times | 73 | //TODO Fix - ajax calls are executed more times |
... | ... | ||
77 | //Callback which executes the provided function | 79 | //Callback which executes the provided function |
78 | def callback(args: String): JsCmd = { | 80 | def callback(args: String): JsCmd = { |
79 | try { | 81 | try { |
80 | val params = args.split(',') | 82 | val params = |
83 | if (numberOfParams>0) | ||
84 | args.split(',') | ||
85 | else Array.empty[String] | ||
81 | // check number of parameters | 86 | // check number of parameters |
82 | if (params.length != numberOfParams) | 87 | if (params.length != numberOfParams) |
83 | throw new Exception("Wrong number of parameters for function "+name+ | 88 | throw new Exception("Wrong number of parameters for function "+name+ |
... | ... | ||
103 | } | 108 | } |
104 | 109 | ||
105 | // JS Command which defines the setCurrentProject function | 110 | // JS Command which defines the setCurrentProject function |
106 | private def setCurrentProject(params : Array[String]) : JsCmd = { | 111 | private def setCurrentProject(args : Array[String]) : JsCmd = { |
107 | User().project = User().workspace.project(params(0)) | 112 | User().project = User().workspace.project(args(0)) |
108 | JSUtils.Empty | 113 | JSUtils.Empty |
109 | } | 114 | } |
110 | 115 | ||
111 | // JS Command which defines the removeDataSource function | 116 | // JS Command which defines the removeDataSource function |
112 | private def removeDataSource(params : Array[String]) : JsCmd = { | 117 | private def removeDataSource(args : Array[String]) : JsCmd = { |
113 | User().project.dataSourceModule.remove(params(0)) | 118 | User().project.dataSourceModule.remove(args(0)) |
114 | updateCmd | 119 | updateCmd |
115 | } | 120 | } |
116 | 121 | ||
117 | // JS Command which defines the removeImportJob function | 122 | // JS Command which defines the removeImportJob function |
118 | private def removeImportJob(params : Array[String]) : JsCmd = { | 123 | private def removeImportJob(args : Array[String]) : JsCmd = { |
119 | User().project.importModule.remove(params(0)) | 124 | User().project.importModule.remove(args(0)) |
120 | updateCmd | 125 | updateCmd |
121 | } | 126 | } |
122 | 127 | ||
123 | // JS Command which defines the removeProject function | 128 | // JS Command which defines the removeProject function |
124 | private def removeProject(params : Array[String]) : JsCmd = { | 129 | private def removeProject(args : Array[String]) : JsCmd = { |
125 | User().workspace.removeProject(params(0)) | 130 | User().workspace.removeProject(User().project.name) |
126 | User().resetCurrentProject() | 131 | User().resetCurrentProject() |
127 | updateCmd | 132 | updateCmd |
128 | } | 133 | } |
129 | 134 | ||
135 | // JS Command which defines the removeIntegrationJob function | ||
136 | private def removeIntegrationJob(args : Array[String]) : JsCmd = { | ||
137 | User().project.integrationModule.remove("integrationJob") | ||
138 | updateCmd | ||
139 | } | ||
140 | |||
130 | // JS Command which defines the saveDataSource function | 141 | // JS Command which defines the saveDataSource function |
131 | private def saveDataSource(params : Array[String]) : JsCmd = { | 142 | private def saveDataSource(args : Array[String]) : JsCmd = { |
132 | User().workspace.saveDataSource(params(0), params(1)) | 143 | User().workspace.saveDataSource(args(0), args(1)) |
133 | updateCmd & | 144 | updateCmd |
134 | JSUtils.Log("Updated dataSource: " + params(0)) | ||
135 | } | 145 | } |
136 | 146 | ||
137 | private def saveImportJobFunction : JsCmd = { | 147 | // JS Command which defines the saveImportJob function |
138 | def callback(args: String): JsCmd = { | 148 | private def saveImportJob(args : Array[String]) : JsCmd = { |
139 | try { | 149 | User().workspace.saveImportJob(args(0), args(1)) |
140 | val Array(taskName, xml) = args.split(',') | 150 | updateCmd |
141 | User().workspace.saveImportJob(taskName, xml) | ||
142 | updateCmd & | ||
143 | JSUtils.Log("Updated importJob: " + taskName) | ||
144 | } catch { | ||
145 | case ex: Exception => Workspace.hideLoadingDialogCmd & | ||
146 | JSUtils.Message(ex.getMessage.encJs) | ||
147 | } | ||
148 | } | ||
149 | val ajaxCall = SHtml.ajaxCall(JsRaw("taskName + ',' + xml"), callback _)._2.cmd | ||
150 | JsCmds.Function("saveImportJob", "taskName" :: "xml" :: Nil, ajaxCall) | ||
151 | } | 151 | } |
152 | 152 | ||
153 | private def runIntegrationFunction : JsCmd = { | 153 | // JS Command which defines the saveIntegrationJob function |
154 | def callback(args: String): JsCmd = { | 154 | private def saveIntegrationJob(args : Array[String]) : JsCmd = { |
155 | User().workspace.saveIntegrationJob("integrationJob", args(0), args(1)) | ||
156 | updateCmd | ||
157 | } | ||
158 | |||
159 | // JS Command which defines the runIntegration function | ||
160 | private def runIntegration(args : Array[String]) : JsCmd = { | ||
155 | if (!runningIntegration) { | 161 | if (!runningIntegration) { |
156 | runningIntegration =true | 162 | runningIntegration =true |
157 | try { | 163 | try { |
... | ... | ||
167 | } | 173 | } |
168 | } | 174 | } |
169 | else JSUtils.Log("An other IntegrationJob is already running, please wait.") | 175 | else JSUtils.Log("An other IntegrationJob is already running, please wait.") |
170 | } | ||
171 | val ajaxCall = SHtml.ajaxCall(JsRaw(""), callback _)._2.cmd | ||
172 | JsCmds.Function("runIntegration", Nil, ajaxCall) | ||
173 | } | 176 | } |
174 | 177 | ||
175 | private def runSchedulerFunction : JsCmd = { | 178 | // JS Command which defines the runScheduler function |
176 | def callback(args: String): JsCmd = { | 179 | private def runScheduler(args : Array[String]) : JsCmd = { |
177 | if (!runningScheduler) { | 180 | if (!runningScheduler) { |
178 | runningScheduler =true | 181 | runningScheduler =true |
179 | try { | 182 | try { |
180 | //MonitorServer.start(Consts.DefaultStatusMonitorrURI) | 183 | //MonitorServer.start(Consts.DefaultStatusMonitorrURI) |
181 | Scheduler(User().project.config).run() | 184 | Scheduler(User().project.config).run() |
182 | runningScheduler = false | 185 | runningScheduler = false |
183 | JSUtils.Empty | 186 | JSUtils.Message("Scheduler execution completed") |
184 | } catch { | 187 | } catch { |
185 | case ex: Exception => { | 188 | case ex: Exception => { |
186 | runningScheduler = false | 189 | runningScheduler = false |
... | ... | ||
189 | } | 192 | } |
190 | } | 193 | } |
191 | else JSUtils.Log("An other Scheduler is already running, please wait.") | 194 | else JSUtils.Log("An other Scheduler is already running, please wait.") |
192 | } | ||
193 | val ajaxCall = SHtml.ajaxCall(JsRaw(""), callback _)._2.cmd | ||
194 | JsCmds.Function("runIntegration", Nil, ajaxCall) | ||
195 | } | 195 | } |
196 | 196 | ||
197 | /** | 197 | /** |
... | ... | ||
207 | /** | 207 | /** |
208 | * JS Command which defines the createProject function | 208 | * JS Command which defines the createProject function |
209 | */ | 209 | */ |
210 | private def createProject (params : Array[String]): JsCmd = { | 210 | private def createProject (args : Array[String]): JsCmd = { |
211 | User().workspace.createProject(params(0)) | 211 | User().workspace.createProject(args(0)) |
212 | updateCmd | 212 | updateCmd |
213 | } | 213 | } |
214 | 214 |