Skip to content

Commit 326efe7

Browse files
authored
Merge pull request #2464 from marklogic/bugfix/dhfprod-2407
DHFPROD-2407: Add default properties to steps if they don't exist
2 parents cae0bcb + 873efcf commit 326efe7

File tree

3 files changed

+80
-5
lines changed

3 files changed

+80
-5
lines changed

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {Component, OnInit, OnDestroy} from '@angular/core';
22
import {ActivatedRoute, Router} from '@angular/router';
3-
import {timer} from 'rxjs';
43
import {Flow} from "../models/flow.model";
4+
import {Step} from '../models/step.model';
55
import {StepType} from '../models/step.model';
66
import {ProjectService} from '../../../services/projects';
77
import {ManageFlowsService} from "../services/manage-flows.service";
@@ -89,11 +89,16 @@ export class EditFlowComponent implements OnInit, OnDestroy {
8989
}
9090
getSteps() {
9191
this.manageFlowsService.getSteps(this.flowId).subscribe( resp => {
92-
console.log('steps', resp);
93-
const newArray = [];
94-
this.flow.steps.map(step => {
95-
newArray.push(resp.find(item => item.id === step.id));
92+
93+
const newArray = resp.map( step => {
94+
const newStep = Step.fromJSON(step, this.projectDirectory, this.databases);
95+
// No Target Entity from default mapping step created by gradle
96+
// if (newStep.stepDefinitionType === this.stepType.MAPPING) {
97+
// this.createMapping(newStep);
98+
// }
99+
return newStep;
96100
});
101+
console.log('steps', newArray);
97102
this.stepsArray = newArray;
98103
this.selectedStepId = (this.stepsArray.length > 0) ? this.stepsArray[0].id : null;
99104
});
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
export class MappingOptions {
2+
public collections: string[] = [];
23
public sourceQuery: string = '';
34
public sourceCollection: string = '';
45
public sourceDatabase: string = '';
56
public targetDatabase: string;
67
public mapping: any;
8+
public targetEntity: string;
79
}

web/src/main/ui/app/components/flows-new/models/step.model.ts

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,88 @@ export class Step {
4242
step.options.outputFormat = 'json';
4343
return step;
4444
}
45+
4546
static createMappingStep(): Step {
4647
const step = new Step();
4748
step.options = new MappingOptions();
4849
return step;
4950
}
51+
5052
static createMasteringStep(): Step {
5153
const step = new Step();
5254
step.options = new MasteringOptions();
5355
return step;
5456
}
57+
5558
static createCustomStep(): Step {
5659
const step = new Step();
5760
step.modulePath = '';
5861
step.options = new CustomOptions();
5962
return step;
6063
}
64+
65+
static fromJSON(json, projectDirectory, databases) {
66+
const newStep = new Step();
67+
if (json.id) {
68+
newStep.id = json.id;
69+
}
70+
if (json.name) {
71+
newStep.name = json.name;
72+
}
73+
if (json.selectedSource) {
74+
newStep.selectedSource = json.selectedSource;
75+
}
76+
if (json.stepDefinitionName) {
77+
newStep.stepDefinitionName = json.stepDefinitionName;
78+
}
79+
if (json.stepDefinitionType) {
80+
newStep.stepDefinitionType = json.stepDefinitionType;
81+
}
82+
if (json.fileLocations) {
83+
newStep.fileLocations = json.fileLocations;
84+
}
85+
if (json.isValid) {
86+
newStep.isValid = json.isValid;
87+
}
88+
if (json.modulePath) {
89+
newStep.modulePath = json.modulePath;
90+
}
91+
// Check options
92+
if (json.options) {
93+
// set defaults for each step type
94+
if (json.stepDefinitionType === StepType.INGESTION) {
95+
// Hard check to see if it's default gradle step
96+
if (json.fileLocations.inputFilePath === 'path/to/folder') {
97+
const fileLocations = {
98+
inputFilePath: projectDirectory,
99+
inputFileType: 'json',
100+
outputURIReplacement: ''
101+
};
102+
newStep.fileLocations = fileLocations;
103+
}
104+
newStep.options = new IngestionOptions();
105+
newStep.options.permissions = 'rest-reader,read,rest-writer,update';
106+
newStep.options.outputFormat = 'json';
107+
newStep.options.targetDatabase = databases.staging;
108+
}
109+
if (json.stepDefinitionType === StepType.MAPPING) {
110+
newStep.options = new MappingOptions();
111+
newStep.options.sourceDatabase = databases.staging;
112+
newStep.options.targetDatabase = databases.final;
113+
}
114+
if (json.stepDefinitionType === StepType.MASTERING) {
115+
newStep.options = new MasteringOptions();
116+
newStep.options.sourceDatabase = databases.final;
117+
newStep.options.targetDatabase = databases.final;
118+
}
119+
if (json.stepDefinitionType === StepType.CUSTOM) {
120+
newStep.options = new CustomOptions();
121+
newStep.options.sourceDatabase = databases.staging;
122+
newStep.options.targetDatabase = databases.final;
123+
}
124+
const newOptions = Object.assign(newStep.options, json.options);
125+
newStep.options = newOptions;
126+
}
127+
return newStep;
128+
}
61129
}

0 commit comments

Comments
 (0)