Skip to content

Commit 73185d3

Browse files
rahulvudutalaMarkLogic Builder
authored andcommitted
DHFPROD-10566: Make step-defs read database name from hubconfig and renaming variables
1 parent 281631a commit 73185d3

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

marklogic-data-hub/src/main/java/com/marklogic/hub/impl/HubProjectImpl.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ public int upgradeLegacyFlows(FlowManager flowManager) {
500500
return upgradeLegacyFlows(flowManager, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), "data-hub-STAGING", "data-hub-FINAL");
501501
}
502502

503-
public int upgradeLegacyFlows(FlowManager flowManager, List<String> legacyEntities, List<String> legacyFlowTypes, List<String> legacyFlowNames, String sourceDb, String targetDb) {
503+
public int upgradeLegacyFlows(FlowManager flowManager, List<String> legacyEntities, List<String> legacyFlowTypes, List<String> legacyFlowNames, String stagingDb, String finalDb) {
504504
Set<String> legacyEntitiesSet = new HashSet<>(legacyEntities);
505505
Set<String> legacyFlowTypesSet = new HashSet<>(legacyFlowTypes);
506506
Set<String> legacyFlowNamesSet = new HashSet<>(legacyFlowNames);
@@ -579,7 +579,7 @@ public int upgradeLegacyFlows(FlowManager flowManager, List<String> legacyEntiti
579579
JsonNode stepPayLoad = scaffolding.getStepConfig(newStepName, stepType, newStepName, null, acceptSourceModule);
580580
// Save StepDefinition to local file
581581
scaffolding.saveStepDefinition(newStepName, newStepName, stepType, true);
582-
updateStepOptionsFor4xFlow(stepName, stepFile, stepPayLoad, mainModulePath, legacyEntityDir.getName(), sourceDb, targetDb);
582+
updateStepOptionsFor4xFlow(stepName, stepFile, stepPayLoad, mainModulePath, legacyEntityDir.getName(), stagingDb, finalDb);
583583
// Save Step to local file
584584
scaffolding.saveLocalStep(stepType, stepPayLoad);
585585
// Add step to local Flow
@@ -598,7 +598,7 @@ public int upgradeLegacyFlows(FlowManager flowManager, List<String> legacyEntiti
598598
return flowsUpdated;
599599
}
600600

601-
private void updateStepOptionsFor4xFlow(String stepName, File stepFile, JsonNode stepPayLoad, String mainModulePath, String entityType, String sourceDb, String finalDb) {
601+
private void updateStepOptionsFor4xFlow(String stepName, File stepFile, JsonNode stepPayLoad, String mainModulePath, String entityType, String stagingDb, String finalDb) {
602602
ObjectNode step = (ObjectNode) stepPayLoad;
603603
ObjectMapper mapper = new ObjectMapper();
604604
Properties properties = new Properties();
@@ -618,7 +618,7 @@ private void updateStepOptionsFor4xFlow(String stepName, File stepFile, JsonNode
618618
optionsNode.put("mainModuleUri", mainModulePath.concat("/").concat(properties.getOrDefault("mainModule", "main.sjs").toString()));
619619

620620
if(step.get("stepDefinitionType").asText().equals("custom")) {
621-
step.put("sourceDatabase", sourceDb);
621+
step.put("sourceDatabase", stagingDb);
622622
step.put("targetDatabase", finalDb);
623623
step.put("sourceQueryIsModule", true);
624624
mainModulePath = mainModulePath.concat("/").concat(properties.getOrDefault("collectorModule", "collector.sjs").toString());
@@ -628,7 +628,7 @@ private void updateStepOptionsFor4xFlow(String stepName, File stepFile, JsonNode
628628

629629
optionsNode.put("entity", entityType);
630630
} else {
631-
step.put("targetDatabase", sourceDb);
631+
step.put("targetDatabase", stagingDb);
632632
step.put("inputFilePath", "");
633633
}
634634
step.putIfAbsent("options", optionsNode);

marklogic-data-hub/src/main/java/com/marklogic/hub/impl/ScaffoldingImpl.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,17 @@ public String saveStepDefinition(String stepName, String stepDefName, String ste
184184
stepDefinition = StepDefinition.create(stepDefName, StepDefinitionType.getStepDefinitionType(stepType));
185185
stepDefinition.setModulePath("/custom-modules/" + stepType.toLowerCase() + "/" + stepDefName + "/main.mjs");
186186
if(legacyUpgrade) {
187+
Map<String, Object> options = stepDefinition.getOptions();
188+
HubConfigImpl config = (HubConfigImpl) hubConfig;
189+
if(stepDefinition.getType().toString().equalsIgnoreCase("custom")) {
190+
options.put("sourceDatabase", config.getStagingDbName());
191+
options.put("targetDatabase", config.getFinalDbName());
192+
}
193+
194+
if(stepDefinition.getType().toString().equalsIgnoreCase("ingestion")) {
195+
options.put("targetDatabase", config.getStagingDbName());
196+
}
197+
stepDefinition.setOptions(options);
187198
stepDefinitionManager.saveLocalStepDefinition(stepDefinition);
188199
} else {
189200
stepDefinitionManager.saveStepDefinition(stepDefinition);

0 commit comments

Comments
 (0)