Skip to content

Commit 19b7f0a

Browse files
authored
Merge pull request #2463 from marklogic/bugfix/dhfprod-2461
DHFPROD-2461: In Manage Flow page first flow's info gets replaced by second flow's info when running second
2 parents 326efe7 + 0e7c334 commit 19b7f0a

File tree

12 files changed

+97
-23
lines changed

12 files changed

+97
-23
lines changed

marklogic-data-hub/src/main/java/com/marklogic/hub/flow/impl/FlowRunnerImpl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ else if (!isJobSuccess.get()) {
384384
stepsMap.remove(jobId);
385385
flowMap.remove(jobId);
386386
flowResp.remove(runningJobId);
387+
runningFlow = null;
387388
if (!jobQueue.isEmpty()) {
388389
initializeFlow((String) jobQueue.peek());
389390
} else {
@@ -435,6 +436,7 @@ public void afterExecute(Runnable r, Throwable t) {
435436
//Run the next queued flow if stop-on-error is set or if the step queue is empty
436437
if(((FlowRunnerTask)r).getStepQueue().isEmpty() || runningFlow.isStopOnError()) {
437438
jobQueue.remove();
439+
runningFlow = null;
438440
if (!jobQueue.isEmpty()) {
439441
initializeFlow((String) jobQueue.peek());
440442
} else {

marklogic-data-hub/src/main/resources/hub-internal-config/databases/job-database.json

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,45 @@
1717
"range-value-positions": false,
1818
"invalid-values": "reject"
1919
},
20+
{
21+
"scalar-type": "string",
22+
"namespace-uri": "",
23+
"localname": "flow",
24+
"collation": "http://marklogic.com/collation/codepoint",
25+
"range-value-positions": false,
26+
"invalid-values": "ignore"
27+
},
2028
{
2129
"scalar-type": "dateTime",
2230
"namespace-uri": "",
2331
"localname": "startTime",
2432
"collation": "",
2533
"range-value-positions": false,
26-
"invalid-values": "reject"
34+
"invalid-values": "ignore"
2735
},
2836
{
2937
"scalar-type": "dateTime",
3038
"namespace-uri": "",
3139
"localname": "endTime",
3240
"collation": "",
3341
"range-value-positions": false,
34-
"invalid-values": "reject"
42+
"invalid-values": "ignore"
43+
},
44+
{
45+
"scalar-type": "dateTime",
46+
"namespace-uri": "",
47+
"localname": "timeStarted",
48+
"collation": "",
49+
"range-value-positions": false,
50+
"invalid-values": "ignore"
51+
},
52+
{
53+
"scalar-type": "dateTime",
54+
"namespace-uri": "",
55+
"localname": "timeEnded",
56+
"collation": "",
57+
"range-value-positions": false,
58+
"invalid-values": "ignore"
3559
},
3660
{
3761
"scalar-type": "string",

marklogic-data-hub/src/main/resources/ml-modules/root/data-hub/5/extensions/jobs.sjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ function get(context, params) {
2121
let jobId = params["jobid"];
2222
let status = params["status"];
2323
let flow = params["flow-name"];
24+
let latest = params["latest"];
2425

2526
let resp = null;
2627

@@ -36,6 +37,9 @@ function get(context, params) {
3637
else if (fn.exists(flow)) {
3738
resp = datahub.jobs.getJobDocsByFlow(flow);
3839
}
40+
else if (fn.exists(latest)) {
41+
resp = datahub.jobs.getLastestJobDocPerFlow();
42+
}
3943
else{
4044
fn.error(null,"RESTAPI-SRVEXERR", Sequence.from([400, "Bad Request", "Incorrect options"]));
4145
}

marklogic-data-hub/src/main/resources/ml-modules/root/data-hub/5/impl/jobs.sjs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,21 @@ class Jobs {
132132
return docs;
133133
}
134134

135+
getLastestJobDocPerFlow() {
136+
return this.hubutils.queryLatest(function(){
137+
let flowNames = cts.values(cts.jsonPropertyReference("flow"));
138+
let timeQuery = [];
139+
for(let flowName of flowNames) {
140+
let time = cts.values(cts.jsonPropertyReference("timeStarted"), null, ["descending","limit=1"], cts.jsonPropertyRangeQuery("flow", "=", flowName));
141+
timeQuery.push(cts.rangeQuery(cts.jsonPropertyReference("timeStarted"), "=", time));
142+
}
143+
let results = cts.search(cts.orQuery(timeQuery));
144+
if(results) {
145+
return results.toArray();
146+
}
147+
}, this.config.JOBDATABASE);
148+
}
149+
135150
getJobDocsByFlow(flowName) {
136151
return this.hubutils.queryLatest(function() {
137152
let query = [cts.collectionQuery('Job'), cts.jsonPropertyValueQuery('flow', flowName, "case-insensitive")];

marklogic-data-hub/src/main/resources/ml-modules/root/data-hub/5/impl/step.sjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,20 +77,20 @@ class Step {
7777
}
7878

7979
getStepsByType(type = 'custom') {
80-
let query = [cts.collectionQuery('http://marklogic.com/data-hub/step-definition'), cts.jsonPropertyValueQuery('type', type)];
80+
let query = [cts.collectionQuery('http://marklogic.com/data-hub/step-definition'), cts.jsonPropertyValueQuery('type', type, 'case-insensitive')];
8181
return cts.search(cts.andQuery(query)).toArray();
8282
}
8383

8484
getStepByNameAndType(name, type = 'custom') {
85-
let query = [cts.collectionQuery('http://marklogic.com/data-hub/step-definition'), cts.jsonPropertyValueQuery('name', name), cts.jsonPropertyValueQuery('type', type)];
85+
let query = [cts.collectionQuery('http://marklogic.com/data-hub/step-definition'), cts.jsonPropertyValueQuery('name', name, 'case-insensitive'), cts.jsonPropertyValueQuery('type', type, 'case-insensitive')];
8686
let doc = fn.head(cts.search(cts.andQuery(query)));
8787
if(doc) {
8888
return doc.toObject();
8989
}
9090
}
9191

9292
getStepProcessor(flow, name, type = 'custom') {
93-
let query = [cts.collectionQuery('http://marklogic.com/data-hub/step-definition'), cts.jsonPropertyValueQuery('name', name), cts.jsonPropertyValueQuery('type', type)];
93+
let query = [cts.collectionQuery('http://marklogic.com/data-hub/step-definition'), cts.jsonPropertyValueQuery('name', name, 'case-insensitive'), cts.jsonPropertyValueQuery('type', type, 'case-insensitive')];
9494
let doc = fn.head(cts.search(cts.andQuery(query)));
9595
if(doc){
9696
doc = doc.toObject();

ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/RunFlowTask.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ class RunFlowTask extends HubTask {
134134
Map<String, Object> options = new HashMap<>()
135135
def optionsString;
136136
if(project.ext.properties.containsKey("optionsFile")){
137-
def jsonFile = new File(project.ext.optionsFile)
137+
def jsonFile = new File(project.ext.optionsFile.trim())
138138
optionsString = jsonFile.text
139139
}
140140
else if(project.ext.properties.containsKey("options")) {

web/src/main/ui/app/components/flows-new/edit-flow/edit-flow.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export class EditFlowComponent implements OnInit, OnDestroy {
6666
}
6767

6868
ngOnDestroy(): void {
69-
this.runningJobService.stopPolling();
69+
this.runningJobService.stopPolling(this.flow.id);
7070
}
7171

7272
getFlow() {
@@ -155,7 +155,7 @@ export class EditFlowComponent implements OnInit, OnDestroy {
155155
console.log('stop flow response', resp);
156156
this.flow = Flow.fromJSON(resp);
157157
this.getSteps();
158-
this.runningJobService.stopPolling();
158+
this.runningJobService.stopPollingAll();
159159
});
160160
}
161161
createStep(stepObject) {

web/src/main/ui/app/components/flows-new/edit-flow/mapping/mapping.component.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ export class MappingComponent implements OnInit {
9494
} else if (this.step.options.sourceDatabase === this.envService.settings.finalDbName) {
9595
this.sourceDbType = 'FINAL';
9696
}
97+
if(!this.step.options.collections || this.step.options.collections.length === 0){
98+
this.step.options.collections = [`${this.step.name}`, 'mdm-content'];
99+
}
97100
this.loadEntity();
98101
this.loadMap();
99102
}

web/src/main/ui/app/components/flows-new/manage-flows/manage-flows.component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export class ManageFlowsComponent implements OnInit, OnDestroy {
3939
this.getFlows();
4040
}
4141
ngOnDestroy(): void {
42-
this.runningJobService.stopPolling();
42+
this.runningJobService.stopPollingAll();
4343
}
4444

4545
createFlow(newFlow) {
@@ -84,6 +84,7 @@ export class ManageFlowsComponent implements OnInit, OnDestroy {
8484

8585
runFlow(runObject): void {
8686
this.manageFlowsService.runFlow(runObject).subscribe(resp => {
87+
// console.log('run enpoint', resp);
8788
// TODO add response check
8889
const flowIndex = this.flows.findIndex(flow => flow.id === runObject.id);
8990
this.pollFlow(flowIndex, runObject.id);
@@ -101,7 +102,7 @@ export class ManageFlowsComponent implements OnInit, OnDestroy {
101102
this.manageFlowsService.stopFlow(flowId).subscribe(resp => {
102103
console.log('stop flow response', resp);
103104
this.getFlows();
104-
this.runningJobService.stopPolling();
105+
this.runningJobService.stopPolling(flowId);
105106
});
106107
}
107108

web/src/main/ui/app/components/flows-new/manage-flows/ui/manage-flows-ui.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ <h1>Manage Flows</h1>
121121
color="primary"
122122
class="run-flow-button"
123123
*ngIf="checkRunStatus(flow)"
124-
[disabled]="flow.steps.length ? false : true"
124+
[disabled]="checkRunDisabled(flow)"
125125
(click)="openRunDialog(flow)"
126126
>
127127
<span>RUN</span>

0 commit comments

Comments
 (0)