Skip to content

Commit

Permalink
Merge pull request #480 from sandepat/custom_properties
Browse files Browse the repository at this point in the history
vip:dot
  • Loading branch information
axlbonnet authored Jul 9, 2024
2 parents ac404ee + 9a9297c commit 25f77f8
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 14 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 @@ -31,6 +31,9 @@
*/
package fr.insalyon.creatis.vip.applicationimporter.client.view.applicationdisplay;

import java.util.HashSet;
import java.util.Set;

import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.IButton;
Expand All @@ -39,6 +42,7 @@
import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.layout.VLayout;
import com.smartgwt.client.widgets.tab.Tab;

import fr.insalyon.creatis.vip.application.client.bean.boutiquesTools.BoutiquesApplication;
import fr.insalyon.creatis.vip.application.client.view.boutiquesParsing.BoutiquesParser;
import fr.insalyon.creatis.vip.application.client.view.boutiquesParsing.InvalidBoutiquesDescriptorException;
Expand All @@ -49,6 +53,7 @@
import fr.insalyon.creatis.vip.core.client.view.layout.Layout;
import fr.insalyon.creatis.vip.core.client.view.util.WidgetUtil;


public class DisplayTab extends Tab {

// Layouts
Expand Down Expand Up @@ -158,6 +163,34 @@ private static void verifyBoutiquesTool(BoutiquesApplication boutiquesTool)
if (boutiquesTool.getAuthor() == null) {
throw new ApplicationImporterException("Boutiques file must have an author");
}
checkvipdot(boutiquesTool);
}

/**
* display warning message if any.
*
* @param application BoutiquesApplication object to cehck warning message
* @throws ApplicationImporterException
* **/
private static void checkvipdot(BoutiquesApplication application) throws ApplicationImporterException {
Set<String> commandLineFlags = application.getCommandLineFlag();
Set<String> vipDotInputIds = 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);
}
// Check if all vipDotInputIds are in inputs
if (!inputIds.containsAll(vipDotInputIds)) {
Set<String> incorrectInputs = new HashSet<>(vipDotInputIds);
incorrectInputs.removeAll(inputIds);
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 @@ -46,7 +46,8 @@ public class GeneralLayout extends AbstractFormLayout {
version,
schemaVersion,
description,
vipContainer;
vipContainer,
dotInputs;

public GeneralLayout(String width, String height) {
super(width, height);
Expand All @@ -63,8 +64,9 @@ public GeneralLayout(String width, String height) {
schemaVersion = new LocalTextField("Schema Version", false, false);
description = new LocalTextField("Description", false, false);
vipContainer = new LocalTextField("VIP Container", false, false);
dotInputs = new LocalTextField("DOT Inputs", false, false);

this.addMembers(name, commandLine, dockerImage, dockerIndex, version, schemaVersion, description, vipContainer);
this.addMembers(name, commandLine, dockerImage, dockerIndex, version, schemaVersion, description, vipContainer, dotInputs);
}

public void setTool(BoutiquesApplication bt) {
Expand All @@ -76,5 +78,7 @@ public void setTool(BoutiquesApplication bt) {
dockerIndex.setValue(bt.getContainerIndex());
schemaVersion.setValue(bt.getSchemaVersion());
vipContainer.setValue(bt.getVipContainer());
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
@@ -1,5 +1,6 @@
package fr.insalyon.creatis.vip.application.client.bean.boutiquesTools;

import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
Expand All @@ -10,6 +11,8 @@

import com.google.gwt.user.client.rpc.IsSerializable;

import fr.insalyon.creatis.vip.application.client.bean.boutiquesTools.BoutiquesInput.InputType;

/**
* Representation of an application Boutiques descriptor
*
Expand Down Expand Up @@ -38,6 +41,8 @@ public class BoutiquesApplication implements IsSerializable {
private Set<BoutiquesOutputFile> outputFiles = new HashSet<>();
private Map<String, String> tags = new HashMap<>();
private String jsonFile;
private Set<String> vipDotInputIds;
private boolean vipDotIncludesResultsDir;

private BoutiquesApplicationExtensions boutiquesExtensions;

Expand Down Expand Up @@ -229,6 +234,30 @@ public String getVipContainer() {
return vipContainer;
}

public Set<String> getVipDotInputIds() {
if (vipDotInputIds == null) {
return Collections.emptySet();
}
return vipDotInputIds;
}

public Set<String> getCommandLineFlag() {
return inputs.stream()
.filter(i -> InputType.FLAG.equals(i.getType()))
.map(BoutiquesInput::getId)
.collect(Collectors.toSet());
}

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

public boolean getVipDotIncludesResultsDir() {
return vipDotIncludesResultsDir;
}

public void addInput(BoutiquesInput input){
this.inputs.add(input);
}
Expand Down Expand Up @@ -280,4 +309,12 @@ public void addTag(String key, String value) {
public void setVipContainer(String vipContainer) {
this.vipContainer = vipContainer;
}
}

public void setVipDotInputIds(Set<String> inputIds) {
this.vipDotInputIds = inputIds;
}

public void setVipDotIncludesResultsDir(boolean vipDotIncludesResultsDir) {
this.vipDotIncludesResultsDir = vipDotIncludesResultsDir;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ public BoutiquesApplication parseApplication(String descriptor) throws InvalidBo
// Custom property
JSONObject customObject = getObjectValue(parsedDescriptor, "custom", true);
if (customObject != null) {
String vipImagePath = getStringValue(customObject, "vip:imagepath", true);
application.setVipContainer(vipImagePath);
application.setVipContainer(getStringValue(customObject, "vip:imagepath", true));
application.setVipDotInputIds(getArrayValueAsStringSet(customObject, "vip:dot", true));
application.setVipDotIncludesResultsDir(getBooleanValue(customObject, "vip:dot-with-results-directory", true));
}
// Json descriptor
application.setJsonFile(parsedDescriptor.toString());
Expand Down Expand Up @@ -241,6 +242,4 @@ private BoutiquesOutputFile parseBoutiquesOutputFile(JSONObject outputFile)
bof.setCommandLineFlag(commandLineFlag);
return bof;
}


}
28 changes: 22 additions & 6 deletions vip-portal/src/main/resources/vm/gwendia-standalone.vm
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,30 @@ if ( result.startsWith("/") || result.startsWith("lfn:") ) {
#foreach( $output in $tool.getOutputFiles() )
<out name="$output.getId()" type="URI" depth="0"/>
#end
<iterationstrategy>
<cross>
<iterationstrategy>
<cross>
#if($tool.getVipDotInputIds() && !$tool.getVipDotInputIds().isEmpty())
<dot>
#if($tools.getVipDotResultDirs)
<port name="results-directory" />
#end
#foreach($dotInput in $tool.getVipDotInputIds())
<port name="$dotInput"/>
#end
</dot>
#if( ! $tools.getVipDotResultDirs)
<port name="results-directory" />
#end
#else
<port name="results-directory" />
#end
#foreach($input in $tool.getInputs())
<port name="$input.getId()"/>
#if(!$tool.getVipDotInputIds().contains($input.getId()))
<port name="$input.getId()"/>
#end
#end
</cross>
</iterationstrategy>
</cross>
</iterationstrategy>
<gasw descriptor="$fileAccessProtocol:$tool.getGASWLFN()"/>
</processor>
</processors>
Expand All @@ -92,4 +108,4 @@ if ( result.startsWith("/") || result.startsWith("lfn:") ) {
<link from="$tool.getName():$output.getId()" to="$output.getId()" />
#end
</links>
</workflow>
</workflow>

0 comments on commit 25f77f8

Please sign in to comment.