Skip to content

Commit

Permalink
taking some code from #8, used to fix a SWOT issue
Browse files Browse the repository at this point in the history
  • Loading branch information
hkryeung committed Oct 18, 2022
1 parent 99fd631 commit 58557b6
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import gov.nasa.cumulus.metadata.aggregator.processor.FootprintProcessor;
import gov.nasa.cumulus.metadata.aggregator.processor.ImageProcessor;
import gov.nasa.cumulus.metadata.state.WorkflowTypeEnum;
import gov.nasa.cumulus.metadata.util.S3Utils;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
Expand All @@ -32,6 +33,7 @@
public class MetadataAggregatorLambda implements ITask{
String className = this.getClass().getName();
private final String region = System.getenv("region");
private WorkflowTypeEnum workflowType;
@Override
public String PerformFunction(String input, Context context) throws Exception {
S3Utils s3Utils = new S3Utils();
Expand Down Expand Up @@ -227,14 +229,14 @@ private String postIngestProcess(String input)
CMRLambdaRestClient elrc = buildLambdaRestClient(input);
setCMRMetadataToProvider(input);
// From this point, determine if we are going to process Footprint (fp) only
if(FootprintProcessor.isFootprintFileExisting(input)) {
if(workflowType == WorkflowTypeEnum.ForgeWorkflow) {
Hashtable<String, String> returnVars = getMetaDataHash(elrc,input);
FootprintProcessor processor = new FootprintProcessor();
output = processor.process(input, returnVars.get("ummgStr"), region,
(new BigInteger(returnVars.get("revisionId"))).add(new BigInteger("1")).toString());
return output;
}
if(ImageProcessor.isImageFileExisting(input)) {
if(workflowType == WorkflowTypeEnum.ThumbnailImageWorkflow) {
Hashtable<String, String> returnVars = getMetaDataHash(elrc,input);
ImageProcessor processor = new ImageProcessor();
output = processor.process(input,returnVars.get("ummgStr"), region,
Expand Down Expand Up @@ -316,4 +318,22 @@ private void setCMRMetadataToProvider(String input)
CMRRestClientProvider.setProvider(provider);
}


// for PR add in Mike, Simon Liu, and normal ppl
public void setWorkFlowType(String stateMachine) throws ParseException {
AdapterLogger.LogInfo("current state machine:" + stateMachine);
if(StringUtils.endsWithIgnoreCase(stateMachine, "IngestWorkflow")) {
workflowType = WorkflowTypeEnum.IngestWorkflow;
} else if(StringUtils.endsWithIgnoreCase(stateMachine, "DMRPPWorkflow")) {
workflowType = WorkflowTypeEnum.DMRPPWorkflow;
} else if (StringUtils.endsWithIgnoreCase(stateMachine, "ThumbnailImageWorkflow")) {
workflowType = WorkflowTypeEnum.ThumbnailImageWorkflow;
} else if (StringUtils.endsWithIgnoreCase(stateMachine, "ForgeWorkflow")) {
workflowType = WorkflowTypeEnum.ForgeWorkflow;
} else {
workflowType = WorkflowTypeEnum.NONE;
}
AdapterLogger.LogInfo("Current workflow type: " + workflowType);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package gov.nasa.cumulus.metadata.state;

public enum WorkflowTypeEnum {
IngestWorkflow,
ForgeWorkflow,
ThumbnailImageWorkflow,
DMRPPWorkflow,
NONE
}

0 comments on commit 58557b6

Please sign in to comment.