Skip to content

Commit

Permalink
Resolution of review comment and display of results-directory
Browse files Browse the repository at this point in the history
  • Loading branch information
sandepat committed Jul 1, 2024
1 parent 357563f commit a2c7841
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 105 deletions.
2 changes: 1 addition & 1 deletion coverage/src/test/java/Coverage/Coverage.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package coverage;
package Coverage;

import org.junit.jupiter.api.Test;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,27 +170,26 @@ private static void verifyBoutiquesTool(BoutiquesApplication boutiquesTool)
* display warning message if any.
*
* @param application BoutiquesApplication object to cehck warning message
* @throws ApplicationImporterException
* **/
private static void checkvipdot(BoutiquesApplication application) {
private static void checkvipdot(BoutiquesApplication application) throws ApplicationImporterException {
Set<String> commandLineFlags = application.getCommandLineFlag();
Set<String> vipDotInputIds = application.getVipDotInputIds();
Set<String> commonValues = new HashSet<>(application.getVipDotInputIds());
Set<String> inputIds = application.getinputIds();
Set<String> commonValues = new HashSet<>(vipDotInputIds);

commonValues.retainAll(commandLineFlags);

if (!commonValues.isEmpty()) {
String warningMessage = "<b>" + String.join(", ", commonValues) + "</b> appears as command-line flag input(s), it should not be included in Dot iteration. Importing it may cause functionality issues, although the application will still be imported.";
Layout.getInstance().setWarningMessage(warningMessage);
}

// Extract the IDs from inputs
Set<String> inputIds = application.getInputs().stream().map(BoutiquesInput::getId).collect(Collectors.toSet());
// Check if all vipDotInputIds are in inputs
if (!inputIds.containsAll(vipDotInputIds)) {
Set<String> incorrectInputs = new HashSet<>(vipDotInputIds);
incorrectInputs.removeAll(inputIds);
String warningMessage = "<b>" + String.join(", ", incorrectInputs) + "</b> appears in vipDotInputIds but not in inputs. Please ensure all ids are correct.";
Layout.getInstance().setWarningMessage(warningMessage);
String errorMessage = "<b>" + String.join(", ", incorrectInputs) + "</b> appears in vipDotInputIds but not in inputs. Please ensure all ids are correct.";
throw new ApplicationImporterException(errorMessage);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public void setTool(BoutiquesApplication bt) {
dockerIndex.setValue(bt.getContainerIndex());
schemaVersion.setValue(bt.getSchemaVersion());
vipContainer.setValue(bt.getVipContainer());
dotInputs.setValue(String.join(", ", bt.getVipDotInputIds()));
String dotInputsValue = String.join(", ", bt.getVipDotInputIds());
dotInputs.setValue(dotInputsValue + (bt.getVipDotIncludesResultsDir() ? (dotInputsValue.isEmpty() ? "results-directory" : ", results-directory") : ""));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public class BoutiquesApplication implements IsSerializable {
private Map<String, String> tags = new HashMap<>();
private String jsonFile;
private Set<String> vipDotInputIds;
private String resultDirs;
private Set<String> inputIds;

Check warning

Code scanning / PMD

Avoid unused private fields such as 'classBusiness'. Warning

Avoid unused private fields such as 'inputIds'.
private boolean vipDotIncludesResultsDir;

private BoutiquesApplicationExtensions boutiquesExtensions;

Expand Down Expand Up @@ -248,8 +249,14 @@ public Set<String> getCommandLineFlag() {
.collect(Collectors.toSet());
}

public String getVipDotResultDirs() {
return resultDirs;
public Set<String> getinputIds() {
return this.getInputs().stream()
.map(BoutiquesInput::getId)
.collect(Collectors.toSet());
}

public boolean getVipDotIncludesResultsDir() {
return vipDotIncludesResultsDir;
}

public void addInput(BoutiquesInput input){
Expand Down Expand Up @@ -308,7 +315,7 @@ public void setVipDotInputIds(Set<String> inputIds) {
this.vipDotInputIds = inputIds;
}

public void setVipDotResultDirs(String resultDirs) {
this.resultDirs = resultDirs;
public void setVipDotIncludesResultsDir(boolean vipDotIncludesResultsDir) {
this.vipDotIncludesResultsDir = vipDotIncludesResultsDir;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public BoutiquesApplication parseApplication(String descriptor) throws InvalidBo
if (customObject != null) {
application.setVipContainer(getStringValue(customObject, "vip:imagepath", true));
application.setVipDotInputIds(getArrayValueAsStringSet(customObject, "vip:dot", true));
application.setVipDotResultDirs(getStringValue(customObject, "vip:dot-result-directory", true));
application.setVipDotIncludesResultsDir(getBooleanValue(customObject, "vip:dot-with-results-directory", true));
}
// Json descriptor
application.setJsonFile(parsedDescriptor.toString());
Expand Down
179 changes: 89 additions & 90 deletions vip-portal/src/main/resources/vm/gwendia-standalone.vm
Original file line number Diff line number Diff line change
Expand Up @@ -5,112 +5,111 @@
<source name="results-directory" type="URI" optional="false" default="/vip/Home" pretty-name="Results directory">
<source-comment>Directory where the results will be stored.</source-comment>
</source>
#foreach( $input in $tool.getInputs() )
#set($type="string")
#if($input.getType().getCamelName()=="File")
#set($type="URI")
#end
#if($input.getType().getCamelName()=="Flag")
#if($input.getDefaultValue() && $input.getDefaultValue()!="")
<source name="$input.getId()" type="string" optional="$input.isOptional()" default="$input.getDefaultValue()" vip-type-restriction="flag" pretty-name="$input.getName()">
#else
<source name="$input.getId()" type="string" optional="$input.isOptional()" default="false" vip-type-restriction="flag" pretty-name="$input.getName()">
#end
#else
#if($input.getDefaultValue() && $input.getDefaultValue()!="")
#if($input.getType().getCamelName()=="Number" && $input.isInteger())
<source name="$input.getId()" type="$type" optional="$input.isOptional()" default="$input.getDefaultValue().intValue()" pretty-name="$input.getName()">
#else
<source name="$input.getId()" type="$type" optional="$input.isOptional()" default="$input.getDefaultValue()" pretty-name="$input.getName()">
#end
#else
#if($input.isOptional()==true)
<source name="$input.getId()" type="$type" optional="$input.isOptional()" default="No_value_provided" pretty-name="$input.getName()">
#else
<source name="$input.getId()" type="$type" optional="$input.isOptional()" pretty-name="$input.getName()">
#end
#end
#end
#if($input.getDescription())
<source-comment>$esc.xml($input.getDescription())</source-comment>
#else
<source-comment></source-comment>
#end
</source>
#foreach( $input in $tool.getInputs() )
#set($type="string")
#if($input.getType().getCamelName()=="File")
#set($type="URI")
#end
#if($input.getType().getCamelName()=="Flag")
#if($input.getDefaultValue() && $input.getDefaultValue()!="")
<source name="$input.getId()" type="string" optional="$input.isOptional()" default="$input.getDefaultValue()" vip-type-restriction="flag" pretty-name="$input.getName()">
#else
<source name="$input.getId()" type="string" optional="$input.isOptional()" default="false" vip-type-restriction="flag" pretty-name="$input.getName()">
#end
#foreach($output in $tool.getOutputFiles())
<sink name="$output.getId()" type="URI" />
#else
#if($input.getDefaultValue() && $input.getDefaultValue()!="")
#if($input.getType().getCamelName()=="Number" && $input.isInteger())
<source name="$input.getId()" type="$type" optional="$input.isOptional()" default="$input.getDefaultValue().intValue()" pretty-name="$input.getName()">
#else
<source name="$input.getId()" type="$type" optional="$input.isOptional()" default="$input.getDefaultValue()" pretty-name="$input.getName()">
#end
#else
#if($input.isOptional()==true)
<source name="$input.getId()" type="$type" optional="$input.isOptional()" default="No_value_provided" pretty-name="$input.getName()">
#else
<source name="$input.getId()" type="$type" optional="$input.isOptional()" pretty-name="$input.getName()">
#end
#end
#end
#if($input.getDescription())
<source-comment>$esc.xml($input.getDescription())</source-comment>
#else
<source-comment></source-comment>
#end
</source>
#end
#foreach($output in $tool.getOutputFiles())
<sink name="$output.getId()" type="URI" />
#end
</interface>
<processors>
<processor name="append-date" >
<in name="dir" type="URI" depth="0" />
<out name="result" type="string" depth="0" />
<beanshell>
/*----------Beginning of Beanshell------------*/
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
<beanshell>/*----------Beginning of Beanshell------------*/
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

String result = dir.toString();
if ( result.startsWith("/") || result.startsWith("lfn:") ) {
DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy_HH:mm:ss");
result = result + "/" + (dateFormat.format(System.currentTimeMillis()));
}
/*------------End of Beanshell------------*/
String result = dir.toString();
if ( result.startsWith("/") || result.startsWith("lfn:") ) {
DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy_HH:mm:ss");
result = result + "/" + (dateFormat.format(System.currentTimeMillis()));
}
/*------------End of Beanshell------------*/
</beanshell>
</processor>
<processor name="$tool.getName()" >
<in name="results-directory" type="string" depth="0"/>
#foreach($input in $tool.getInputs())
#if($input.getType().getCamelName()=="File" )
<in name="$input.getId()" type="URI" depth="0"/>
#else
<in name="$input.getId()" type="string" depth="0"/>
#end
#end
#foreach( $output in $tool.getOutputFiles() )
<out name="$output.getId()" type="URI" depth="0"/>
#end
<iterationstrategy>
<cross>
#if($tools.getVipDotResultDirs)
<dot>
<port name="results-directory" />
#foreach($input in $tool.getInputs())
#if($tool.getVipDotInputIds().contains($input.getId()))
<port name="$input.getId()"/>
#end
#end
</dot>
#else
<port name="results-directory" />
#foreach($input in $tool.getInputs())
#if(!$tool.getVipDotInputIds().contains($input.getId()))
<port name="$input.getId()"/>
#end
#end
#end
#if($tool.getVipDotInputIds() && !$tool.getVipDotInputIds().isEmpty() && !$tools.getVipDotResultDirs)
<dot>
#foreach($dotInput in $tool.getVipDotInputIds())
<port name="$dotInput"/>
#end
</dot>
#end
</cross>
</iterationstrategy>
#foreach($input in $tool.getInputs())
#if($input.getType().getCamelName()=="File" )
<in name="$input.getId()" type="URI" depth="0"/>
#else
<in name="$input.getId()" type="string" depth="0"/>
#end
#end
#foreach( $output in $tool.getOutputFiles() )
<out name="$output.getId()" type="URI" depth="0"/>
#end
<iterationstrategy>
<cross>
#if($tools.getVipDotResultDirs)
<dot>
<port name="results-directory" />
#foreach($input in $tool.getInputs())
#if($tool.getVipDotInputIds().contains($input.getId()))
<port name="$input.getId()"/>
#end
#end
</dot>
#else
<port name="results-directory" />
#foreach($input in $tool.getInputs())
#if(!$tool.getVipDotInputIds().contains($input.getId()))
<port name="$input.getId()"/>
#end
#end
#end
#if($tool.getVipDotInputIds() && !$tool.getVipDotInputIds().isEmpty() && !$tools.getVipDotResultDirs)
<dot>
#foreach($dotInput in $tool.getVipDotInputIds())
<port name="$dotInput"/>
#end
</dot>
#end
</cross>
</iterationstrategy>
<gasw descriptor="$fileAccessProtocol:$tool.getGASWLFN()"/>
</processor>
</processors>
<links>
<link from="results-directory" to="append-date:dir" />
<link from="append-date:result" to="$tool.getName():results-directory" />
#foreach( $input in $tool.getInputs() )
<link from="$input.getId()" to="$tool.getName():$input.getId()" />
#end
#foreach($output in $tool.getOutputFiles())
<link from="$tool.getName():$output.getId()" to="$output.getId()" />
#end
#foreach( $input in $tool.getInputs() )
<link from="$input.getId()" to="$tool.getName():$input.getId()" />
#end
#foreach($output in $tool.getOutputFiles())
<link from="$tool.getName():$output.getId()" to="$output.getId()" />
#end
</links>
</workflow>
</workflow>

0 comments on commit a2c7841

Please sign in to comment.