refs 2521: Explore the possibility to port the StatMan interface onto Dataminer

https://support.d4science.org/issues/2521

Fixed Computation View

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/data-miner-manager@128681 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2016-05-19 09:57:05 +00:00
parent 288a732d93
commit 17fbaf90ca
6 changed files with 158 additions and 7 deletions

View File

@ -0,0 +1,58 @@
package org.gcube.portlets.user.dataminermanager.client.computations;
import org.gcube.portlets.user.dataminermanager.shared.data.computations.ComputationValue;
import org.gcube.portlets.user.dataminermanager.shared.data.computations.ComputationValueFile;
import org.gcube.portlets.user.dataminermanager.shared.data.computations.ComputationValueFileList;
import org.gcube.portlets.user.dataminermanager.shared.data.computations.ComputationValueImage;
import com.sencha.gxt.core.client.util.Margins;
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;
import com.sencha.gxt.widget.core.client.form.TextField;
/**
*
* @author Giancarlo Panichi email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class ComputationValueFileListPanel extends SimpleContainer {
private ComputationValueFileList computationValueFileList;
public ComputationValueFileListPanel(ComputationValueFileList computationValueFileList) {
this.computationValueFileList = computationValueFileList;
init();
create();
}
private void init(){
setBorders(false);
}
private void create() {
VerticalLayoutContainer lc = new VerticalLayoutContainer();
SimpleContainer simpleContainer;
TextField textField;
for(ComputationValue computationValue: computationValueFileList.getFileList()){
if(computationValue instanceof ComputationValueFile){
ComputationValueFile computationValueFile=(ComputationValueFile) computationValue;
simpleContainer=new ComputationValueFilePanel(computationValueFile);
lc.add(simpleContainer, new VerticalLayoutData(1, -1, new Margins(0)));
} else {
if(computationValue instanceof ComputationValueImage){
ComputationValueImage computationValueImage=(ComputationValueImage) computationValue;
simpleContainer=new ComputationValueImagePanel(computationValueImage);
lc.add(simpleContainer, new VerticalLayoutData(1, -1, new Margins(0)));
} else {
textField = new TextField();
textField.setValue(computationValue.getValue());
textField.setReadOnly(true);
lc.add(textField, new VerticalLayoutData(1, -1, new Margins(0)));
}
}
}
add(lc);
}
}

View File

@ -6,6 +6,7 @@ import org.gcube.portlets.user.dataminermanager.client.util.UtilsGXT3;
import org.gcube.portlets.user.dataminermanager.shared.data.computations.ComputationData;
import org.gcube.portlets.user.dataminermanager.shared.data.computations.ComputationValue;
import org.gcube.portlets.user.dataminermanager.shared.data.computations.ComputationValueFile;
import org.gcube.portlets.user.dataminermanager.shared.data.computations.ComputationValueFileList;
import org.gcube.portlets.user.dataminermanager.shared.data.computations.ComputationValueImage;
import com.allen_sauer.gwt.log.client.Log;
@ -213,6 +214,13 @@ public class ComputationsViewerPanel extends FramedPanel {
fieldLabel.setLabelWidth(200);
fieldLabel.setLabelWordWrap(true);
break;
case FileList:
ComputationValueFileList computationValueFileList=(ComputationValueFileList) computationValue;
simpleContainer=new ComputationValueFileListPanel(computationValueFileList);
fieldLabel = new FieldLabel(simpleContainer, key);
fieldLabel.setLabelWidth(200);
fieldLabel.setLabelWordWrap(true);
break;
case String:
default:
TextField textField = new TextField();
@ -259,6 +267,12 @@ public class ComputationsViewerPanel extends FramedPanel {
fieldLabel.setLabelWidth(200);
fieldLabel.setLabelWordWrap(true);
break;
case FileList:
ComputationValueFileList computationValueFileList=(ComputationValueFileList) computationValue;
simpleContainer=new ComputationValueFileListPanel(computationValueFileList);
fieldLabel = new FieldLabel(simpleContainer, key);
fieldLabel.setLabelWidth(200);
fieldLabel.setLabelWordWrap(true);
case String:
default:
TextField textField = new TextField();

View File

@ -2,12 +2,14 @@ package org.gcube.portlets.user.dataminermanager.server.smservice.wps.computatio
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.gcube.portlets.user.dataminermanager.shared.data.computations.ComputationValue;
import org.gcube.portlets.user.dataminermanager.shared.data.computations.ComputationValueFile;
import org.gcube.portlets.user.dataminermanager.shared.data.computations.ComputationValueFileList;
import org.gcube.portlets.user.dataminermanager.shared.data.computations.ComputationValueImage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -34,8 +36,8 @@ public class ComputationValueBuilder {
if (value != null && !value.isEmpty()
&& value.startsWith("http")) {
if (value.contains("|")) {
ComputationValue valueString = new ComputationValue(value);
computationsValueParameters.put(key, valueString);
ComputationValue valueFileList = createComputationValueFileList(value);
computationsValueParameters.put(key, valueFileList);
} else {
ComputationValue computationValue = retrieveFileName(value);
computationsValueParameters.put(key, computationValue);
@ -51,6 +53,25 @@ public class ComputationValueBuilder {
}
private ComputationValue createComputationValueFileList(String value) {
ArrayList<ComputationValue> fileList=new ArrayList<>();
int indexSeparator;
String file;
ComputationValue computationValue;
while((indexSeparator=value.indexOf("|"))!=-1){
file=value.substring(0, indexSeparator);
value=value.substring(indexSeparator+1);
computationValue=retrieveFileName(file);
fileList.add(computationValue);
}
computationValue=retrieveFileName(value);
fileList.add(computationValue);
ComputationValueFileList computationValueFileList=new ComputationValueFileList(fileList, "|");
return computationValueFileList;
}
private ComputationValue retrieveFileName(final String value) {
HttpURLConnection conn = null;

View File

@ -13,19 +13,22 @@ public class ComputationValue implements Serializable {
private static final long serialVersionUID = -2047623108851748745L;
protected ComputationValueType type;
protected String value;
public ComputationValue() {
super();
}
public ComputationValue(ComputationValueType type) {
super();
this.type = type;
}
public ComputationValue(String value) {
super();
this.type = ComputationValueType.String;
this.value = value;
}
public ComputationValue(ComputationValueType type, String value) {
super();
this.type = type;
@ -47,7 +50,7 @@ public class ComputationValue implements Serializable {
public void setValue(String value) {
this.value = value;
}
@Override
public String toString() {
return "ComputationValue [type=" + type + ", value=" + value + "]";

View File

@ -0,0 +1,55 @@
package org.gcube.portlets.user.dataminermanager.shared.data.computations;
import java.util.ArrayList;
/**
*
* @author Giancarlo Panichi email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class ComputationValueFileList extends ComputationValue {
private static final long serialVersionUID = -5845606225432949795L;
private ArrayList<ComputationValue> fileList;
private String separator;
public ComputationValueFileList() {
super();
}
public ComputationValueFileList(ArrayList<ComputationValue> fileList,
String separator) {
super(ComputationValueType.FileList);
this.fileList = fileList;
this.separator = separator;
value = new String();
for (ComputationValue file : fileList) {
value = value + file.getValue();
}
}
public ArrayList<ComputationValue> getFileList() {
return fileList;
}
public void setFileList(ArrayList<ComputationValue> fileList) {
this.fileList = fileList;
}
public String getSeparator() {
return separator;
}
public void setSeparator(String separator) {
this.separator = separator;
}
@Override
public String toString() {
return "ComputationValueFileList [fileList=" + fileList
+ ", separator=" + separator + ", type=" + type + ", value="
+ value + "]";
}
}

View File

@ -7,5 +7,5 @@ package org.gcube.portlets.user.dataminermanager.shared.data.computations;
*
*/
public enum ComputationValueType {
File, Image, String;
FileList, File, Image, String;
}