Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom properties vip:dot #480

Merged
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,35 @@ 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
* **/
private static void checkvipdot(BoutiquesApplication application) {
Set<String> commandLineFlags = application.getCommandLineFlag();
Set<String> vipDotInputIds = application.getVipDotInputIds();
Set<String> commonValues = new HashSet<>(application.getVipDotInputIds());

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());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may add this as a BoutiquesApplication method. (optionally)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the getinputIds method to BoutiquesApplication

// 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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in this case, it should be a error with an exception thrown.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throwing ApplicationImporterException

}
}

/**
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,6 @@ public void setTool(BoutiquesApplication bt) {
dockerIndex.setValue(bt.getContainerIndex());
schemaVersion.setValue(bt.getSchemaVersion());
vipContainer.setValue(bt.getVipContainer());
dotInputs.setValue(String.join(", ", bt.getVipDotInputIds()));
}
}
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 String resultDirs;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename field and getter/setter with vipDotIncludesResultsDir, and change type to boolean.

Copy link
Contributor Author

@sandepat sandepat Jul 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to boolean vipDotIncludesResultsDir


private BoutiquesApplicationExtensions boutiquesExtensions;

Expand Down Expand Up @@ -229,6 +234,24 @@ 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 String getVipDotResultDirs() {
return resultDirs;
}

public void addInput(BoutiquesInput input){
this.inputs.add(input);
}
Expand Down Expand Up @@ -280,4 +303,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 setVipDotResultDirs(String resultDirs) {
this.resultDirs = resultDirs;
}
}
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.setVipDotResultDirs(getStringValue(customObject, "vip:dot-result-directory", true));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename to vip:dot-with-results-directory.
Adapt to vip:dot-result-directory being a boolean.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change to vip:dot-with-results-directory and adapt to the method getBooleanValue

}
// Json descriptor
application.setJsonFile(parsedDescriptor.toString());
Expand Down Expand Up @@ -241,6 +242,4 @@ private BoutiquesOutputFile parseBoutiquesOutputFile(JSONObject outputFile)
bof.setCommandLineFlag(commandLineFlag);
return bof;
}


}
149 changes: 85 additions & 64 deletions vip-portal/src/main/resources/vm/gwendia-standalone.vm
Original file line number Diff line number Diff line change
Expand Up @@ -5,78 +5,99 @@
<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()">
#foreach( $input in $tool.getInputs() )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thnk VS or something else changed the indentation of velocity code and it generetad a lot of diff.
Could it be possible to keep the original indentation ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed, restore original indentation.

#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>
#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
#foreach($output in $tool.getOutputFiles())
<sink name="$output.getId()" type="URI" />
#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
#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>
<port name="results-directory" />
#foreach($input in $tool.getInputs())
<port name="$input.getId()"/>
#end
#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()"/>
Expand All @@ -85,11 +106,11 @@ if ( result.startsWith("/") || result.startsWith("lfn:") ) {
<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>
Loading