Skip to content

Commit fd55c38

Browse files
author
Bruce An
committed
added defaults for steps in step model
1 parent 1a27a49 commit fd55c38

File tree

3 files changed

+33
-5
lines changed

3 files changed

+33
-5
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,16 @@ export class EditFlowComponent implements OnInit, OnDestroy {
8989
}
9090
getSteps() {
9191
this.manageFlowsService.getSteps(this.flowId).subscribe( resp => {
92+
9293
const newArray = resp.map( step => {
93-
return Step.fromJSON(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;
94100
});
101+
console.log('steps', newArray);
95102
this.stepsArray = newArray;
96103
this.selectedStepId = (this.stepsArray.length > 0) ? this.stepsArray[0].id : null;
97104
});
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: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export class Step {
6262
return step;
6363
}
6464

65-
static fromJSON(json) {
65+
static fromJSON(json, projectDirectory, databases) {
6666
const newStep = new Step();
6767
if (json.id) {
6868
newStep.id = json.id;
@@ -79,28 +79,47 @@ export class Step {
7979
if (json.stepDefinitionType) {
8080
newStep.stepDefinitionType = json.stepDefinitionType;
8181
}
82-
if (json.isValid) {
83-
newStep.isValid = json.isValid;
84-
}
8582
if (json.fileLocations) {
8683
newStep.fileLocations = json.fileLocations;
8784
}
85+
if (json.isValid) {
86+
newStep.isValid = json.isValid;
87+
}
8888
if (json.modulePath) {
8989
newStep.modulePath = json.modulePath;
9090
}
9191
// Check options
9292
if (json.options) {
93+
// set defaults for each step type
9394
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+
}
94104
newStep.options = new IngestionOptions();
105+
newStep.options.permissions = 'rest-reader,read,rest-writer,update';
106+
newStep.options.outputFormat = 'json';
107+
newStep.options.targetDatabase = databases.final;
95108
}
96109
if (json.stepDefinitionType === StepType.MAPPING) {
97110
newStep.options = new MappingOptions();
111+
newStep.options.sourceDatabase = databases.staging;
112+
newStep.options.targetDatabase = databases.final;
98113
}
99114
if (json.stepDefinitionType === StepType.MASTERING) {
100115
newStep.options = new MasteringOptions();
116+
newStep.options.sourceDatabase = databases.final;
117+
newStep.options.targetDatabase = databases.final;
101118
}
102119
if (json.stepDefinitionType === StepType.CUSTOM) {
103120
newStep.options = new CustomOptions();
121+
newStep.options.sourceDatabase = databases.staging;
122+
newStep.options.targetDatabase = databases.final;
104123
}
105124
const newOptions = Object.assign(newStep.options, json.options);
106125
newStep.options = newOptions;

0 commit comments

Comments
 (0)