Added support to default value for ListParameter [#24026]

This commit is contained in:
Giancarlo Panichi 2022-12-14 12:20:27 +01:00
parent ccc1e1bf61
commit 05cefb74e8
966 changed files with 266 additions and 83 deletions

0
.classpath Normal file → Executable file
View File

0
.gitignore vendored Normal file → Executable file
View File

0
.project Normal file → Executable file
View File

0
.settings/org.eclipse.core.resources.prefs Normal file → Executable file
View File

0
.settings/org.eclipse.jdt.core.prefs Normal file → Executable file
View File

0
.settings/org.eclipse.m2e.core.prefs Normal file → Executable file
View File

3
.settings/org.eclipse.wst.common.component Normal file → Executable file
View File

@ -4,6 +4,9 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="data-miner-manager-cl-1.10.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/data-miner-manager-cl/data-miner-manager-cl">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="java-output-path" value="/data-miner-manager/target/data-miner-executor-1.0.0-SNAPSHOT/WEB-INF/classes"/>
<property name="context-root" value="data-miner-executor"/>
</wb-module>

View File

View File

0
.settings/org.eclipse.wst.validation.prefs Normal file → Executable file
View File

21
CHANGELOG.md Normal file → Executable file
View File

@ -3,19 +3,19 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
# Changelog for "data-miner-executor"
## [v1.4.0-SNAPSHOT]
- Updated to maven-portal-bom-3.7.0 [#22732]
- Added support to default value for ListParameter [#24026]
## [v1.3.0] - 2021-10-06
### Features
- Added cluster description in Service Info [#19213]
- Added cluster description in Service Info [#19213]
## [v1.2.0] - 2019-10-02
### Features
- Added service info [#12594]
- Added support to show log information [#11711]
- Added support to show files html, json, pdf, txt [#17106]
@ -23,21 +23,12 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Added Item Id support [#16503]
## [v1.1.0] - 2019-03-13
### Features
- Added automatic run [#16155]
## [v1.0.0] - 2019-01-31
### Features
- First release
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

0
FUNDING.md Normal file → Executable file
View File

0
LICENSE.md Normal file → Executable file
View File

0
README.md Normal file → Executable file
View File

23
changelog.xml Normal file → Executable file
View File

@ -1,8 +1,19 @@
<ReleaseNotes>
<Changeset component="org.gcube.portlets.user.data-miner-executor.1-3-0" date="2021-10-06">
<Changeset
component="org.gcube.portlets.user.data-miner-executor.1-4-0"
date="2022-12-14">
<Change>Updated to maven-portal-bom-3.7.0 [#22732]</Change>
<Change>Added support to default value for ListParameter [#24026]
</Change>
</Changeset>
<Changeset
component="org.gcube.portlets.user.data-miner-executor.1-3-0"
date="2021-10-06">
<Change>Updated to Git and Jenkins</Change>
</Changeset>
<Changeset component="org.gcube.portlets.user.data-miner-executor.1-2-0" date="2019-10-02">
<Changeset
component="org.gcube.portlets.user.data-miner-executor.1-2-0"
date="2019-10-02">
<Change>Added service info [#12594]</Change>
<Change>Added support to show log information [#11711]</Change>
<Change>Added support to show files html, json, pdf, txt [#17106]
@ -12,10 +23,14 @@
</Change>
<Change>Added Item Id support [#16503]</Change>
</Changeset>
<Changeset component="org.gcube.portlets.user.data-miner-executor.1-1-0" date="2019-03-13">
<Changeset
component="org.gcube.portlets.user.data-miner-executor.1-1-0"
date="2019-03-13">
<Change>Added automatic run [#16155]</Change>
</Changeset>
<Changeset component="org.gcube.portlets.user.data-miner-executor.1-0-0" date="2019-01-31">
<Changeset
component="org.gcube.portlets.user.data-miner-executor.1-0-0"
date="2019-01-31">
<Change>First release</Change>
</Changeset>
</ReleaseNotes>

0
descriptor.xml Normal file → Executable file
View File

4
pom.xml Normal file → Executable file
View File

@ -12,7 +12,7 @@
<groupId>org.gcube.portlets.user</groupId>
<artifactId>data-miner-executor</artifactId>
<version>1.3.0</version>
<version>1.4.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>data-miner-executor</name>
@ -285,7 +285,7 @@
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>maven-portal-bom</artifactId>
<version>3.6.3</version>
<version>3.7.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>

0
profile.xml Normal file → Executable file
View File

View File

Before

Width:  |  Height:  |  Size: 496 B

After

Width:  |  Height:  |  Size: 496 B

View File

Before

Width:  |  Height:  |  Size: 99 B

After

Width:  |  Height:  |  Size: 99 B

View File

Before

Width:  |  Height:  |  Size: 462 B

After

Width:  |  Height:  |  Size: 462 B

View File

Before

Width:  |  Height:  |  Size: 99 B

After

Width:  |  Height:  |  Size: 99 B

View File

Before

Width:  |  Height:  |  Size: 492 B

After

Width:  |  Height:  |  Size: 492 B

View File

Before

Width:  |  Height:  |  Size: 120 B

After

Width:  |  Height:  |  Size: 120 B

View File

@ -3,20 +3,22 @@
*/
package org.gcube.portlets.user.dataminerexecutor.client.parametersfield;
import java.util.ArrayList;
import java.util.List;
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.ListParameter;
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.ObjectParameter;
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.Parameter;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.user.client.ui.Widget;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData;
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutPack;
import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer;
import com.sencha.gxt.widget.core.client.container.HtmlLayoutContainer;
import com.sencha.gxt.widget.core.client.container.MarginData;
import com.sencha.gxt.widget.core.client.container.SimpleContainer;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
/**
*
@ -27,75 +29,132 @@ import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.Verti
public class ListStringFld extends AbstractFld {
private SimpleContainer fieldContainer;
// private TextField textField;
private String value;
private HBoxLayoutContainer horiz;
private SimpleContainer listContainer;
private VerticalLayoutContainer vp;
private List<StringItem> items;
private ListParameter listParameter;
/**
* @param parameter
* parameter
*
* @param parameter parameter
*/
public ListStringFld(Parameter parameter) {
super(parameter);
// ObjectParameter p = (ObjectParameter) parameter;
Log.debug("Create String List field: " + parameter.getName());
value = parameter.getValue();
listParameter = (ListParameter) parameter;
ListParameter listParameter = (ListParameter) parameter;
StringBuilder columnListHtml = new StringBuilder();
String tempValue = new String(value);
int pos = tempValue.indexOf(listParameter.getSeparator());
while (pos > -1) {
SafeHtmlBuilder safeValue = new SafeHtmlBuilder();
safeValue.appendEscaped(tempValue.substring(0, pos));
columnListHtml.append("<span style='display:block;overflow-wrap: break-word;'>"
+ safeValue.toSafeHtml().asString() + "</span>");
tempValue = tempValue.substring(pos + 1, tempValue.length());
pos = tempValue.indexOf(listParameter.getSeparator());
}
if (tempValue != null && !tempValue.isEmpty()) {
SafeHtmlBuilder safeValue = new SafeHtmlBuilder();
safeValue.appendEscaped(tempValue);
columnListHtml.append("<span style='display:block;overflow-wrap: break-word;'>"
+ safeValue.toSafeHtml().asString() + "</span>");
} else {
columnListHtml.append("<span style='display:block;overflow-wrap: break-word;'></span>");
}
HtmlLayoutContainer descr;
descr = new HtmlLayoutContainer("<p style='margin-left:5px !important;'></p>");
descr.addStyleName("workflow-fieldDescription");
descr = new HtmlLayoutContainer(
"<p style='margin-left:5px !important;'>" + parameter.getDescription() + "</p>");
descr.addStyleName("workflow-fieldDescription");
SimpleContainer vContainer = new SimpleContainer();
VerticalLayoutContainer vField = new VerticalLayoutContainer();
HtmlLayoutContainer typeDescription = new HtmlLayoutContainer("");
typeDescription.setStylePrimaryName("workflow-parameters-description");
HtmlLayoutContainer val = new HtmlLayoutContainer(columnListHtml.toString());
val.addStyleName("workflow-fieldValue");
vField.add(val, new VerticalLayoutData(-1, -1, new Margins(0)));
vField.add(typeDescription, new VerticalLayoutData(-1, -1, new Margins(0)));
vContainer.add(vField);
listContainer = new SimpleContainer();
vp = new VerticalLayoutContainer();
items = new ArrayList<StringItem>();
listContainer.add(vp, new MarginData(new Margins()));
fieldContainer = new SimpleContainer();
HBoxLayoutContainer horiz = new HBoxLayoutContainer();
horiz = new HBoxLayoutContainer();
horiz.setPack(BoxLayoutPack.START);
horiz.setEnableOverflow(false);
horiz.add(vContainer, new BoxLayoutData(new Margins()));
horiz.add(descr, new BoxLayoutData(new Margins()));
HtmlLayoutContainer descr;
if (listParameter.getDescription() == null) {
descr = new HtmlLayoutContainer("<p style='margin-left:5px !important;'></p>");
descr.addStyleName("workflow-fieldDescription");
} else {
/* listContainer.setToolTip(listParameter.getDescription()); */
descr = new HtmlLayoutContainer(
"<p style='margin-left:5px !important;'>" + listParameter.getDescription() + "</p>");
descr.addStyleName("workflow-fieldDescription");
}
horiz.add(listContainer, new BoxLayoutData(new Margins(0)));
horiz.add(descr, new BoxLayoutData(new Margins(0)));
fieldContainer.add(horiz);
fieldContainer.forceLayout();
addField(null);
}
protected void addField(StringItem upperItem) {
if (upperItem == null) {
if (listParameter.getDefaultValue() == null || listParameter.getDefaultValue().isEmpty()) {
ObjectParameter objPar = new ObjectParameter(listParameter.getName(), listParameter.getDescription(),
listParameter.getType(), listParameter.getDefaultValue());
StringItem item = new StringItem(this, objPar, true);
items.add(item);
vp.add(item);
} else {
String separator=listParameter.getSeparator();
String tmpDefault=listParameter.getDefaultValue();
int firstSharp=tmpDefault.indexOf(separator);
if(firstSharp>-1) {
String[] defaultValues=tmpDefault.split(separator);
int pos=0;
for(String dv:defaultValues) {
ObjectParameter objPar = new ObjectParameter(listParameter.getName(), listParameter.getDescription(),
listParameter.getType(), dv);
StringItem item=null;
if(pos==0) {
item = new StringItem(this, objPar, true);
} else {
item = new StringItem(this, objPar, false);
}
items.add(pos,item);
vp.insert(item,pos);
pos+=1;
item.showCancelButton();
item.forceLayout();
}
} else {
ObjectParameter objPar = new ObjectParameter(listParameter.getName(), listParameter.getDescription(),
listParameter.getType(), listParameter.getDefaultValue());
StringItem item = new StringItem(this, objPar, true);
items.add(item);
vp.add(item);
}
}
} else {
ObjectParameter objPar = new ObjectParameter(listParameter.getName(), listParameter.getDescription(),
listParameter.getType(), null);
// search the position of the upper item
int pos = items.indexOf(upperItem);
if (pos > -1) {
upperItem.showCancelButton();
upperItem.forceLayout();
StringItem item = new StringItem(this, objPar, false);
items.add(pos + 1, item);
vp.insert(item, pos + 1);// don't use new VerticalLayoutData(1,
// -1,new Margins(0))
} else {
upperItem.forceLayout();
StringItem item = new StringItem(this, objPar, true);
items.add(item);
vp.add(item);// don't use new VerticalLayoutData(-1, -1, new
// Margins(0))
}
}
forceLayout();
}
protected void forceLayout() {
vp.forceLayout();
horiz.forceLayout();
fieldContainer.forceLayout();
}
protected void removeField(StringItem item) {
items.remove(item);
vp.remove(item);
if (items.size() == 1) {
items.get(0).hideCancelButton();
items.get(0).forceLayout();
}
forceLayout();
}
/**
@ -103,6 +162,16 @@ public class ListStringFld extends AbstractFld {
*/
@Override
public String getValue() {
String separator = listParameter.getSeparator();
String value = "";
boolean first = true;
for (StringItem item : items) {
String itemValue = item.getValue();
if (itemValue != null && !itemValue.contentEquals("")) {
value += (first ? "" : separator) + itemValue;
first = false;
}
}
return value;
}
@ -114,13 +183,18 @@ public class ListStringFld extends AbstractFld {
return fieldContainer;
}
/**
*
*/
@Override
public boolean isValid() {
if (value != null && !value.isEmpty()) {
return true;
} else {
return false;
}
boolean valid = false;
for (StringItem item : items)
if (item.isValid()) {
valid = true;
break;
}
return valid;
}
}

View File

@ -0,0 +1,100 @@
package org.gcube.portlets.user.dataminerexecutor.client.parametersfield;
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.ObjectParameter;
import org.gcube.portlets.user.dataminerexecutor.client.DataMinerExecutor;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.widget.core.client.button.TextButton;
import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer;
import com.sencha.gxt.widget.core.client.event.SelectEvent;
import com.sencha.gxt.widget.core.client.form.TextField;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class StringItem extends HBoxLayoutContainer {
private ListStringFld parent;
private TextField field;
private TextButton addBtn;
private TextButton removeBtn;
/**
*
* @param parent parend
* @param objectParameter object parameter
* @param first true if is first
*/
public StringItem(ListStringFld parent, ObjectParameter objectParameter, boolean first) {
super();
this.parent=parent;
create(objectParameter,first);
}
private void create( ObjectParameter objectParameter, boolean first){
field = new TextField();
field.setAllowBlank(false);
if(objectParameter!=null && objectParameter.getDefaultValue()!=null &&
!objectParameter.getDefaultValue().isEmpty()) {
field.setValue(objectParameter.getDefaultValue());
}
addBtn = new TextButton("");
addBtn.setIcon(DataMinerExecutor.resources.add());
addBtn.addSelectHandler(new SelectEvent.SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
parent.addField(StringItem.this);
}
});
removeBtn = new TextButton("");
removeBtn.setIcon(DataMinerExecutor.resources.cancel());
removeBtn.addSelectHandler(new SelectEvent.SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
parent.removeField(StringItem.this);
}
});
removeBtn.setVisible(!first);
setPack(BoxLayoutPack.START);
setEnableOverflow(false);
add(field, new BoxLayoutData(new Margins()));
add(addBtn, new BoxLayoutData(new Margins()));
add(removeBtn, new BoxLayoutData(new Margins()));
forceLayout();
}
public void showCancelButton() {
removeBtn.setVisible(true);
}
public void hideCancelButton() {
removeBtn.setVisible(false);
}
public String getValue() {
return field.getCurrentValue();
}
public boolean isValid() {
return field.isValid();
}
}

View File

Before

Width:  |  Height:  |  Size: 733 B

After

Width:  |  Height:  |  Size: 733 B

View File

Before

Width:  |  Height:  |  Size: 137 B

After

Width:  |  Height:  |  Size: 137 B

View File

Before

Width:  |  Height:  |  Size: 293 B

After

Width:  |  Height:  |  Size: 293 B

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

Before

Width:  |  Height:  |  Size: 723 B

After

Width:  |  Height:  |  Size: 723 B

View File

Before

Width:  |  Height:  |  Size: 271 B

After

Width:  |  Height:  |  Size: 271 B

View File

Before

Width:  |  Height:  |  Size: 349 B

After

Width:  |  Height:  |  Size: 349 B

View File

Before

Width:  |  Height:  |  Size: 587 B

After

Width:  |  Height:  |  Size: 587 B

Some files were not shown because too many files have changed in this diff Show More