Skip to content

Commit f695b86

Browse files
committed
Added implementation to load previous input path of each flow and save it on a properties file
1 parent 7d12f0a commit f695b86

File tree

4 files changed

+64
-9
lines changed

4 files changed

+64
-9
lines changed

quick-start/src/main/java/com/marklogic/hub/web/controller/api/FlowApiController.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,9 @@ public void afterJob(JobExecution jobExecution) {
190190

191191
@RequestMapping(value="/run/input", method = RequestMethod.POST)
192192
public BigInteger runInputFlow(@RequestBody RunFlowModel runFlow) {
193+
194+
saveInputPath(runFlow);
195+
193196
CancellableTask task = new CancellableTask() {
194197

195198
@Override
@@ -228,6 +231,23 @@ public void run(BasicFuture<?> resultFuture) {
228231
};
229232
return taskManagerService.addTask(task);
230233
}
234+
235+
@RequestMapping(value = "/input-path", method = RequestMethod.GET, produces = { MediaType.TEXT_PLAIN_VALUE })
236+
@ResponseBody
237+
public String getPreviousInputPath(HttpServletRequest request) {
238+
String entityName = request.getParameter("entityName");
239+
String flowName = request.getParameter("flowName");
240+
return getPreviousInputPath(entityName,flowName);
241+
}
242+
243+
private String getPreviousInputPath(String entityName, String flowName) {
244+
String value = environmentConfiguration.getFlowInputPath(entityName, flowName);
245+
return value == null ? "." : value;
246+
}
247+
248+
private void saveInputPath(RunFlowModel runFlow) {
249+
environmentConfiguration.saveOrUpdateFlowInputPath(runFlow.getEntityName(), runFlow.getFlowName(), runFlow.getInputPath());
250+
}
231251

232252
@RequestMapping(value = "/runInParallel", method = RequestMethod.POST)
233253
public void runFlowsInParallel(HttpServletRequest request) {

quick-start/src/main/resources/static/app/services/dataHubService.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
saveFlow: saveFlow,
3131
displayMessage: displayMessage,
3232
searchPath: searchPath,
33-
showApiDoc: showApiDoc
33+
showApiDoc: showApiDoc,
34+
getPreviousInputPath : getPreviousInputPath
3435
});
3536

3637
function login(loginForm) {
@@ -196,7 +197,17 @@
196197
}
197198

198199
function showApiDoc() {
199-
$window.open('#/api-doc', '_blank');
200+
$window.open('#/api-doc', '_blank');
201+
}
202+
203+
function getPreviousInputPath(entityName, flowName) {
204+
var params = {
205+
entityName: entityName,
206+
flowName: flowName
207+
};
208+
return $http.get('api/flows/input-path', {
209+
'params': params
210+
});
200211
}
201212

202213
}

quick-start/src/main/resources/static/app/services/modalService.js

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,22 @@
1717
openFlowModal: openFlowModal
1818
});
1919

20-
function openLoadDataModal() {
20+
function openLoadDataModal(entityName, flowName) {
2121
var modalInstance = $uibModal.open({
2222
animation: true,
2323
templateUrl: 'top/modal/loadDataModal.html',
2424
controller: 'loadDataModalController',
2525
size: 'sm',
2626
backdrop: 'static',
27-
keyboard: true
27+
keyboard: true,
28+
resolve: {
29+
'entityName': function() {
30+
return entityName;
31+
},
32+
'flowName': function() {
33+
return flowName;
34+
}
35+
}
2836
});
2937

3038
return modalInstance.result;
@@ -68,12 +76,14 @@
6876
}
6977
}
7078

71-
function LoadDataModalController($scope, $uibModalInstance, DataHub) {
79+
function LoadDataModalController($scope, $uibModalInstance, DataHub, entityName, flowName) {
7280
$scope.loadDataForm = {
7381
inputPath: '.',
7482
dataFormat: 'documents',
7583
inputCompressed: false,
76-
collection: null
84+
collection: null,
85+
entityName: entityName,
86+
flowName: flowName
7787
};
7888

7989
$scope.ok = function() {
@@ -125,10 +135,23 @@
125135
}
126136
});
127137
};
128-
138+
129139
$scope.dataForTheTree = [];
140+
141+
$scope.loadPreviousInputPath = function(entityName, flowName) {
142+
DataHub.getPreviousInputPath(entityName, flowName)
143+
.success(function(inputPath) {
144+
$scope.loadDataForm.inputPath = inputPath;
145+
$scope.searchPath($scope.loadDataForm.inputPath);
146+
})
147+
.error(function(error) {
148+
$scope.hasError = true;
149+
$scope.errorMessage = error.message;
150+
});
151+
};
152+
130153
//initialize root
131-
$scope.searchPath($scope.loadDataForm.inputPath);
154+
$scope.loadPreviousInputPath($scope.loadDataForm.entityName, $scope.loadDataForm.flowName);
132155
}
133156

134157
function EntityModalController($scope, $uibModalInstance, DataHub) {

quick-start/src/main/resources/static/top/topController.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@
5454
};
5555

5656
$scope.runInputFlow = function(flow) {
57-
ModalService.openLoadDataModal().then(function (result) {
57+
ModalService.openLoadDataModal(flow.entityName, flow.flowName)
58+
.then(function (result) {
5859
$scope.loading = true;
5960
flow.inputFlowCancelled = false;
6061

0 commit comments

Comments
 (0)