1452: Implement a GUI for StatMan Algorithms Importer

Task-Url: https://support.d4science.org/issues/1452

Added VRE information to Project Info

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/statistical-algorithms-importer@122225 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2016-01-14 11:31:23 +00:00
parent f2aed31faa
commit 0e4a66f5a6
23 changed files with 574 additions and 213 deletions

10
pom.xml
View File

@ -80,11 +80,6 @@
<artifactId>slf4j-log4j12</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>home-library</artifactId>
@ -295,7 +290,7 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>compile</scope>
<scope>provided</scope>
</dependency>
<dependency>
@ -303,11 +298,12 @@
<artifactId>slf4j-log4j12</artifactId>
<scope>provided</scope>
</dependency>
<!--
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<scope>provided</scope>
</dependency>
</dependency> -->
<!-- <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId>
<version>1.0.1</version> <scope>runtime</scope> </dependency> -->

View File

@ -8,6 +8,7 @@ import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.InputR
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.MainCodeSetEvent;
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.StatAlgoImporterRibbonEvent;
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.monitor.StatAlgoImporterMonitor;
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.project.ProjectManager;
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.rpc.StatAlgoImporterServiceAsync;
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.type.SessionExpiredType;
@ -42,7 +43,7 @@ public class StatAlgoImporterController {
@SuppressWarnings("unused")
private BorderLayoutContainer mainPanel;
private ProjectManager pm;
private StatAlgoImporterMonitor monitor;
private enum InputRequestType {
Save,
@ -256,11 +257,11 @@ public class StatAlgoImporterController {
private void doInputReadyCommand(InputReadyEvent event) {
switch(inputRequestType){
case Save:
pm.saveProject(event.getInputData());
pm.saveProject(event.getInputData(), monitor);
break;
case SoftwareCreate:
pm.createSofware(event.getInputData());
break;
pm.createSofware(event.getInputData(), monitor);
break;
default:
break;
@ -269,6 +270,7 @@ public class StatAlgoImporterController {
}
private void projectSaveRequest() {
monitor= new StatAlgoImporterMonitor();
inputRequestType=InputRequestType.Save;
InputRequestEvent inputRequestEvent = new InputRequestEvent();
eventBus.fireEvent(inputRequestEvent);
@ -276,6 +278,7 @@ public class StatAlgoImporterController {
}
private void softwareCreateRequest() {
monitor= new StatAlgoImporterMonitor();
inputRequestType=InputRequestType.SoftwareCreate;
InputRequestEvent inputRequestEvent = new InputRequestEvent();
eventBus.fireEvent(inputRequestEvent);

View File

@ -53,7 +53,7 @@ public class StatAlgoImporterMonitor extends AutoProgressMessageBox {
}
private void create() {
setProgressText("Updating...");
setProgressText("In progress...");
auto();
show();
}

View File

@ -6,6 +6,7 @@ import java.util.List;
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.ProjectStatusEvent;
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.monitor.StatAlgoImporterMonitor;
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.rpc.StatAlgoImporterServiceAsync;
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.type.ProjectStatusEventType;
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.type.SessionExpiredType;
@ -287,7 +288,7 @@ public class ProjectManager {
});
}
public void saveProject(InputData inputData) {
public void saveProject(InputData inputData, final StatAlgoImporterMonitor monitor) {
Log.debug("Save Project: " + inputData);
StatAlgoImporterServiceAsync.INSTANCE.saveProject(inputData,
@ -295,11 +296,13 @@ public class ProjectManager {
@Override
public void onSuccess(Void result) {
monitor.hide();
UtilsGXT3.info("Save", "Project saved!");
}
@Override
public void onFailure(Throwable caught) {
monitor.hide();
if (caught instanceof StatAlgoImporterSessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
@ -310,12 +313,12 @@ public class ProjectManager {
caught.getLocalizedMessage());
}
caught.printStackTrace();
}
});
}
public void createSofware(InputData inputData) {
public void createSofware(InputData inputData, final StatAlgoImporterMonitor monitor) {
Log.debug("Create Software: " + inputData);
StatAlgoImporterServiceAsync.INSTANCE.createSoftware(inputData,
@ -323,6 +326,7 @@ public class ProjectManager {
@Override
public void onSuccess(Void result) {
monitor.hide();
fireProjectStatusSoftwareCreatedEvent();
UtilsGXT3.info("Create Software", "Software Created!");
@ -330,6 +334,7 @@ public class ProjectManager {
@Override
public void onFailure(Throwable caught) {
monitor.hide();
if (caught instanceof StatAlgoImporterSessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));

View File

@ -0,0 +1,23 @@
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.properties;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.DeployableVRE;
import com.sencha.gxt.core.client.ValueProvider;
import com.sencha.gxt.data.shared.ModelKeyProvider;
import com.sencha.gxt.data.shared.PropertyAccess;
/**
*
* @author giancarlo email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public interface DeployableVREProperties extends PropertyAccess<DeployableVRE> {
ModelKeyProvider<DeployableVRE> id();
ValueProvider<DeployableVRE, String> name();
ValueProvider<DeployableVRE, String> description();
}

View File

@ -62,12 +62,13 @@ public class EnvironmentVariablesPanel extends ContentPanel {
private EventBus eventBus;
private ListStore<EnvironmentVariables> storeEnvironmentVariable;
private Grid<EnvironmentVariables> gridEnvironmentVariable;
private ListStore<DataType> storeComboInputType;
private ComboBox<DataType> comboInputType;
private GridRowEditing<EnvironmentVariables> gridEnvironmentVariableEditing;
private TextButton btnAdd;
private boolean addStatus;
private int seq = 0;
private ListStore<DataType> storeComboInputType;
private ComboBox<DataType> comboInputType;
interface InputTypeTemplates extends XTemplates {
@XTemplate("<span title=\"{value}\">{value}</span>")
@ -355,6 +356,10 @@ public class EnvironmentVariablesPanel extends ContentPanel {
storeEnvironmentVariable.commitChanges();
seq = project.getInputData().getListEnvironmentVariables().size();
} else {
storeEnvironmentVariable.clear();
storeEnvironmentVariable.commitChanges();
seq=0;
}
}

View File

@ -153,7 +153,7 @@ public class InterpreterInfoPanel extends ContentPanel {
gridInterpreterPackageInfoEditing.addEditor(versionColumn,
new TextField());
btnAdd = new TextButton();
btnAdd = new TextButton("Add");
btnAdd.setIcon(StatAlgoImporterResources.INSTANCE.add16());
// btnAdd.setIconAlign(IconAlign.);
btnAdd.setToolTip("Add Package Info");

View File

@ -1,18 +1,50 @@
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.tools.input;
import java.util.ArrayList;
import java.util.List;
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.properties.DeployableVREProperties;
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.resource.StatAlgoImporterResources;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.DeployableVRE;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.ProjectInfo;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.ProjectInfo;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.shared.EventBus;
import com.sencha.gxt.cell.core.client.ButtonCell.ButtonScale;
import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign;
import com.sencha.gxt.core.client.Style.SelectionMode;
import com.sencha.gxt.core.client.dom.ScrollSupport.ScrollMode;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.data.shared.ListStore;
import com.sencha.gxt.widget.core.client.ContentPanel;
import com.sencha.gxt.widget.core.client.button.ButtonBar;
import com.sencha.gxt.widget.core.client.button.TextButton;
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData;
import com.sencha.gxt.widget.core.client.container.MarginData;
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.event.BeforeStartEditEvent;
import com.sencha.gxt.widget.core.client.event.BeforeStartEditEvent.BeforeStartEditHandler;
import com.sencha.gxt.widget.core.client.event.CancelEditEvent;
import com.sencha.gxt.widget.core.client.event.CancelEditEvent.CancelEditHandler;
import com.sencha.gxt.widget.core.client.event.CompleteEditEvent;
import com.sencha.gxt.widget.core.client.event.CompleteEditEvent.CompleteEditHandler;
import com.sencha.gxt.widget.core.client.event.SelectEvent;
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
import com.sencha.gxt.widget.core.client.form.FieldLabel;
import com.sencha.gxt.widget.core.client.form.TextField;
import com.sencha.gxt.widget.core.client.form.validator.RegExValidator;
import com.sencha.gxt.widget.core.client.grid.ColumnConfig;
import com.sencha.gxt.widget.core.client.grid.ColumnModel;
import com.sencha.gxt.widget.core.client.grid.Grid;
import com.sencha.gxt.widget.core.client.grid.Grid.GridCell;
import com.sencha.gxt.widget.core.client.grid.GridSelectionModel;
import com.sencha.gxt.widget.core.client.grid.editing.GridRowEditing;
import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
/**
*
@ -24,9 +56,14 @@ public class ProjectInfoPanel extends ContentPanel {
@SuppressWarnings("unused")
private EventBus eventBus;
private TextField projectName;
private TextField projectDescription;
private TextField projectClassName;
private TextField packageName;
private TextField packageDescription;
private ListStore<DeployableVRE> storeDeployableVRE;
private Grid<DeployableVRE> gridDeployableVRE;
private GridRowEditing<DeployableVRE> gridDeployableVREEditing;
private TextButton btnAdd;
private boolean addStatus;
private int seq = 0;
public ProjectInfoPanel(Project project, EventBus eventBus) {
super();
@ -52,90 +89,276 @@ public class ProjectInfoPanel extends ContentPanel {
private void create(Project project) {
projectName = new TextField();
projectName.setAllowBlank(false);
projectName.setEmptyText("Enter name...");
FieldLabel projectNameLabel = new FieldLabel(projectName, "Name");
projectDescription = new TextField();
projectDescription.setAllowBlank(false);
projectDescription.setEmptyText("Enter description...");
FieldLabel projectDescriptionLabel = new FieldLabel(projectDescription,
packageName = new TextField();
packageName.setAllowBlank(false);
packageName.addValidator(new RegExValidator("^[a-zA-Z0-9]*$", "Attention only characters a-z,A-Z,0-9 are allowed"));
packageName.setEmptyText("Enter name...");
packageName.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
packageName.validate();
}
});
FieldLabel packageNameLabel = new FieldLabel(packageName, "Name");
packageDescription = new TextField();
packageDescription.setAllowBlank(false);
packageDescription.setEmptyText("Enter description...");
FieldLabel projectDescriptionLabel = new FieldLabel(packageDescription,
"Description");
if (project != null && project.getInputData() != null
&& project.getInputData().getProjectInfo() != null) {
projectClassName = new TextField();
projectClassName.setAllowBlank(false);
projectClassName.setEmptyText("Enter class name...");
FieldLabel projectClassNameLabel = new FieldLabel(projectClassName,
"Class Name");
if (project != null && project.getInputData()!=null && project.getInputData().getProjectInfo() != null) {
if (project.getInputData().getProjectInfo().getName() != null) {
projectName.setValue(project.getInputData().getProjectInfo().getName());
if (project.getInputData().getProjectInfo().getPackageName() != null) {
packageName.setValue(project.getInputData().getProjectInfo()
.getPackageName());
}
if (project.getInputData().getProjectInfo().getDescription() != null) {
projectDescription.setValue(project.getInputData().getProjectInfo()
.getDescription());
}
if (project.getInputData().getProjectInfo().getClassName() != null) {
projectClassName.setValue(project.getInputData().getProjectInfo()
.getClassName());
if (project.getInputData().getProjectInfo().getPackageDescription() != null) {
packageDescription.setValue(project.getInputData()
.getProjectInfo().getPackageDescription());
}
}
// Grid
DeployableVREProperties props = GWT
.create(DeployableVREProperties.class);
ColumnConfig<DeployableVRE, String> nameColumn = new ColumnConfig<DeployableVRE, String>(
props.name(), 100, "Name");
// nameColumn.setMenuDisabled(true);
ColumnConfig<DeployableVRE, String> descriptionColumn = new ColumnConfig<DeployableVRE, String>(
props.description(), 100, "Description");
// descriptionColumn.setMenuDisabled(true);
ArrayList<ColumnConfig<DeployableVRE, ?>> l = new ArrayList<ColumnConfig<DeployableVRE, ?>>();
l.add(nameColumn);
l.add(descriptionColumn);
ColumnModel<DeployableVRE> columns = new ColumnModel<DeployableVRE>(l);
storeDeployableVRE = new ListStore<DeployableVRE>(props.id());
if (project != null && project.getInputData() != null && project.getInputData().getProjectInfo()!=null
&& project.getInputData().getProjectInfo().getListDeployableVRE() != null) {
storeDeployableVRE.addAll(project.getInputData().getProjectInfo()
.getListDeployableVRE());
seq = project.getInputData().getProjectInfo()
.getListDeployableVRE().size();
}
final GridSelectionModel<DeployableVRE> sm = new GridSelectionModel<DeployableVRE>();
sm.setSelectionMode(SelectionMode.SINGLE);
gridDeployableVRE = new Grid<DeployableVRE>(storeDeployableVRE, columns);
gridDeployableVRE.setSelectionModel(sm);
gridDeployableVRE.getView().setStripeRows(true);
gridDeployableVRE.getView().setColumnLines(true);
gridDeployableVRE.getView().setAutoExpandColumn(nameColumn);
gridDeployableVRE.getView().setAutoFill(true);
gridDeployableVRE.setBorders(false);
gridDeployableVRE.setColumnReordering(false);
// EDITING //
gridDeployableVREEditing = new GridRowEditing<DeployableVRE>(
gridDeployableVRE);
gridDeployableVREEditing.addEditor(nameColumn, new TextField());
gridDeployableVREEditing.addEditor(descriptionColumn, new TextField());
btnAdd = new TextButton("Add");
btnAdd.setIcon(StatAlgoImporterResources.INSTANCE.add16());
btnAdd.setScale(ButtonScale.SMALL);
btnAdd.setIconAlign(IconAlign.LEFT);
btnAdd.setToolTip("Add VRE");
btnAdd.addSelectHandler(new SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
addDeployableVRE(event);
}
});
TextButton btnDelete = new TextButton("Delete");
btnDelete.addSelectHandler(new SelectEvent.SelectHandler() {
public void onSelect(SelectEvent event) {
GridCell cell = gridDeployableVREEditing.getActiveCell();
int rowIndex = cell.getRow();
gridDeployableVREEditing.cancelEditing();
storeDeployableVRE.remove(rowIndex);
storeDeployableVRE.commitChanges();
gridDeployableVREEditing.getCancelButton().setVisible(true);
btnAdd.setEnabled(true);
if (addStatus) {
addStatus = false;
}
List<DeployableVRE> listSelected = storeDeployableVRE.getAll();
List<DeployableVRE> listNewSelected = new ArrayList<DeployableVRE>();
for (int i = 0; i < listSelected.size(); i++) {
DeployableVRE var = listSelected.get(i);
var.setId(i);
listNewSelected.add(var);
}
storeDeployableVRE.clear();
storeDeployableVRE.addAll(listNewSelected);
storeDeployableVRE.commitChanges();
seq = listNewSelected.size();
Log.debug("Current Seq: " + seq);
}
});
ButtonBar buttonBar = gridDeployableVREEditing.getButtonBar();
buttonBar.add(btnDelete);
gridDeployableVREEditing
.addBeforeStartEditHandler(new BeforeStartEditHandler<DeployableVRE>() {
@Override
public void onBeforeStartEdit(
BeforeStartEditEvent<DeployableVRE> event) {
editingBeforeStart(event);
}
});
gridDeployableVREEditing
.addCancelEditHandler(new CancelEditHandler<DeployableVRE>() {
@Override
public void onCancelEdit(
CancelEditEvent<DeployableVRE> event) {
storeDeployableVRE.rejectChanges();
btnAdd.setEnabled(true);
}
});
gridDeployableVREEditing
.addCompleteEditHandler(new CompleteEditHandler<DeployableVRE>() {
@Override
public void onCompleteEdit(
CompleteEditEvent<DeployableVRE> event) {
try {
if (addStatus) {
addStatus = false;
}
storeDeployableVRE.commitChanges();
gridDeployableVREEditing.getCancelButton()
.setVisible(true);
btnAdd.setEnabled(true);
} catch (Throwable e) {
Log.error("Error: " + e.getLocalizedMessage());
e.printStackTrace();
}
}
});
// /
FieldLabel deployableVRELabel = new FieldLabel(null, "Deployable VRE");
ToolBar toolBar = new ToolBar();
toolBar.add(btnAdd, new BoxLayoutData(new Margins(0)));
VerticalLayoutContainer vlc = new VerticalLayoutContainer();
vlc.setAdjustForScroll(false);
vlc.setScrollMode(ScrollMode.NONE);
vlc.add(projectNameLabel, new VerticalLayoutData(1, -1, new Margins(5,
0, 5, 0)));
vlc.add(packageNameLabel, new VerticalLayoutData(1, -1, new Margins(0)));
vlc.add(projectDescriptionLabel, new VerticalLayoutData(1, -1,
new Margins(5, 0, 5, 0)));
vlc.add(projectClassNameLabel, new VerticalLayoutData(1, -1,
new Margins(5, 0, 5, 0)));
new Margins(0)));
vlc.add(deployableVRELabel, new VerticalLayoutData(1, -1, new Margins(0)));
vlc.add(toolBar, new VerticalLayoutData(1, -1, new Margins(0)));
vlc.add(gridDeployableVRE, new VerticalLayoutData(1, 1, new Margins(0)));
add(vlc, new MarginData(new Margins(0)));
}
public void update(Project project) {
Log.debug("Update Project Info: " + project);
if (project != null && project.getInputData()!=null && project.getInputData().getProjectInfo() != null) {
if (project != null && project.getInputData() != null
&& project.getInputData().getProjectInfo() != null) {
if (project.getInputData().getProjectInfo().getName() != null) {
projectName.setValue(project.getInputData().getProjectInfo().getName());
if (project.getInputData().getProjectInfo().getPackageName() != null) {
packageName.setValue(project.getInputData().getProjectInfo()
.getPackageName());
} else {
projectName.clear();
packageName.clear();
}
if (project.getInputData().getProjectInfo().getDescription() != null) {
projectDescription.setValue(project.getInputData().getProjectInfo()
.getDescription());
if (project.getInputData().getProjectInfo().getPackageDescription() != null) {
packageDescription.setValue(project.getInputData()
.getProjectInfo().getPackageDescription());
} else {
projectDescription.clear();
packageDescription.clear();
}
if (project.getInputData().getProjectInfo().getClassName() != null) {
projectClassName.setValue(project.getInputData().getProjectInfo()
.getClassName());
if (project.getInputData().getProjectInfo().getListDeployableVRE() != null) {
storeDeployableVRE.clear();
storeDeployableVRE.addAll(project.getInputData()
.getProjectInfo().getListDeployableVRE());
storeDeployableVRE.commitChanges();
seq = project.getInputData().getProjectInfo()
.getListDeployableVRE().size();
} else {
projectClassName.clear();
storeDeployableVRE.clear();
storeDeployableVRE.commitChanges();
seq = 0;
}
} else {
projectName.clear();
projectDescription.clear();
projectClassName.clear();
packageName.clear();
packageDescription.clear();
storeDeployableVRE.clear();
storeDeployableVRE.commitChanges();
seq = 0;
}
}
public ProjectInfo getProjectInfo() {
String name = projectName.getCurrentValue();
String description = projectDescription.getCurrentValue();
String className = projectClassName.getCurrentValue();
private void editingBeforeStart(BeforeStartEditEvent<DeployableVRE> event) {
// TODO Auto-generated method stub
return new ProjectInfo(name, description, className);
}
private void addDeployableVRE(SelectEvent event) {
try {
seq++;
DeployableVRE newEnvironmentVariable = new DeployableVRE(seq, "",
"");
Log.debug("New DeployableVRE: " + newEnvironmentVariable);
gridDeployableVREEditing.cancelEditing();
addStatus = true;
gridDeployableVREEditing.getCancelButton().setVisible(false);
storeDeployableVRE.add(newEnvironmentVariable);
int row = storeDeployableVRE.indexOf(newEnvironmentVariable);
gridDeployableVREEditing.startEditing(new GridCell(row, 0));
} catch (Throwable e) {
e.printStackTrace();
}
}
public ProjectInfo getProjectInfo() {
String name = packageName.getCurrentValue();
String description = packageDescription.getCurrentValue();
ArrayList<DeployableVRE> listDeployableVRE = new ArrayList<>(
gridDeployableVRE.getStore().getAll());
return new ProjectInfo(name, description, listDeployableVRE);
}
}

View File

@ -443,6 +443,10 @@ public class SelectedRowsPanel extends ContentPanel {
storeSelectedRows.commitChanges();
seq = project.getInputData().getListSelectedRows().size();
} else {
storeSelectedRows.clear();
storeSelectedRows.commitChanges();
seq=0;
}
}

View File

@ -45,7 +45,7 @@ public class AlgorithmGenerator {
try {
Path tempFile = Files.createTempFile(project.getInputData()
.getProjectInfo().getClassName(), EXTENTION_JAVA);
.getProjectInfo().getPackageName(), EXTENTION_JAVA);
List<String> lines = createJavaCode();
Files.write(tempFile, lines, Charset.defaultCharset(),
@ -80,7 +80,7 @@ public class AlgorithmGenerator {
"import org.gcube.dataanalysis.executor.rscripts.generic.GenericRScript;",
"", "public class "
+ project.getInputData().getProjectInfo()
.getClassName()
.getPackageName()
+ " extends GenericRScript {", "",
" public static enum operators {",
@ -88,7 +88,7 @@ public class AlgorithmGenerator {
" };", "", " @Override",
" public String getDescription() {", " return \""
+ project.getInputData().getProjectInfo()
.getDescription() + "\";", " }", "",
.getPackageDescription() + "\";", " }", "",
" protected void initVariables(){",
" mainScriptName=\"" + mainScriptRelativePath + "\";",
" packageURL=\"" + packageUrl + "\";",

View File

@ -0,0 +1,123 @@
package org.gcube.portlets.user.statisticalalgorithmsimporter.server.generator;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.ArrayList;
import java.util.List;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterServiceException;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.DeployableVRE;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.InterpreterPackageInfo;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* @author Giancarlo Panichi email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class InfoGenerator {
private static final String EXTENTION_TXT = ".txt";
public static final Logger logger = LoggerFactory
.getLogger(InfoGenerator.class);
private Project project;
public InfoGenerator(Project project) {
super();
this.project = project;
}
@Override
public String toString() {
return "IntegrationInfoGenerator [project=" + project + "]";
}
public Path createIntegrationInfo() throws StatAlgoImporterServiceException {
try {
Path tempFile = Files.createTempFile(project.getInputData()
.getProjectInfo().getPackageName(), EXTENTION_TXT);
List<String> lines = createInfo();
Files.write(tempFile, lines, Charset.defaultCharset(),
StandardOpenOption.WRITE);
logger.debug(tempFile.toString());
return tempFile;
} catch (IOException e) {
logger.error(e.getLocalizedMessage());
e.printStackTrace();
throw new StatAlgoImporterServiceException(e.getLocalizedMessage(),
e);
}
}
private List<String> createInfo() {
ArrayList<String> infos = new ArrayList<String>();
if (project.getInputData() != null) {
if (project.getInputData().getProjectInfo() != null) {
if (project.getInputData().getProjectInfo().getPackageName() != null) {
infos.add("Package Name: "
+ project.getInputData().getProjectInfo()
.getPackageName());
} else {
infos.add("Package Name: ");
}
infos.add("");
if (project.getInputData().getProjectInfo().getPackageDescription() != null) {
infos.add("Package Description: "
+ project.getInputData().getProjectInfo()
.getPackageDescription());
} else {
infos.add("Package Description: ");
}
infos.add("");
if (project.getInputData().getProjectInfo()
.getListDeployableVRE() != null
&& project.getInputData().getProjectInfo()
.getListDeployableVRE().size() > 0) {
infos.add("Deployable VRE:");
for (DeployableVRE deployableVRE : project.getInputData()
.getProjectInfo().getListDeployableVRE()) {
infos.add("" + deployableVRE.getName() + ", " + deployableVRE.getDescription());
}
infos.add("");
}
}
if (project.getInputData().getInterpreterInfo() != null) {
if (project.getInputData().getInterpreterInfo().getVersion() != null) {
infos.add("Interpreter Version: "
+ project.getInputData().getInterpreterInfo()
.getVersion());
} else {
infos.add("Interpreter Version: Any");
}
infos.add("");
if (project.getInputData().getInterpreterInfo()
.getInterpreterPackagesInfo() != null
&& project.getInputData().getInterpreterInfo()
.getInterpreterPackagesInfo().size() > 0) {
infos.add("Packages:");
for (InterpreterPackageInfo info : project.getInputData()
.getInterpreterInfo().getInterpreterPackagesInfo()) {
infos.add("" + info.getName() + " " + info.getVersion());
}
}
}
}
return infos;
}
}

View File

@ -1,87 +0,0 @@
package org.gcube.portlets.user.statisticalalgorithmsimporter.server.generator;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.ArrayList;
import java.util.List;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterServiceException;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.InterpreterPackageInfo;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* @author Giancarlo Panichi email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class IntegrationInfoGenerator {
private static final String EXTENTION_JAVA = ".txt";
public static final Logger logger = LoggerFactory
.getLogger(IntegrationInfoGenerator.class);
private Project project;
public IntegrationInfoGenerator(Project project) {
super();
this.project = project;
}
@Override
public String toString() {
return "IntegrationInfoGenerator [project=" + project + "]";
}
public Path createIntegrationInfo() throws StatAlgoImporterServiceException {
try {
Path tempFile = Files.createTempFile(project.getInputData()
.getProjectInfo().getClassName(), EXTENTION_JAVA);
List<String> lines = createInfo();
Files.write(tempFile, lines, Charset.defaultCharset(),
StandardOpenOption.WRITE);
logger.debug(tempFile.toString());
return tempFile;
} catch (IOException e) {
logger.error(e.getLocalizedMessage());
e.printStackTrace();
throw new StatAlgoImporterServiceException(e.getLocalizedMessage(),
e);
}
}
private List<String> createInfo() {
ArrayList<String> infos = new ArrayList<String>();
if (project.getInputData().getInterpreterInfo() != null) {
if (project.getInputData().getInterpreterInfo().getVersion() != null) {
infos.add("Interpreter Version: "
+ project.getInputData().getInterpreterInfo()
.getVersion());
} else {
infos.add("Interpreter Version: Any");
}
infos.add("");
if (project.getInputData().getInterpreterInfo()
.getInterpreterPackagesInfo() != null
&& project.getInputData().getInterpreterInfo()
.getInterpreterPackagesInfo().size() > 0) {
infos.add("Packages:");
for (InterpreterPackageInfo info : project.getInputData()
.getInterpreterInfo().getInterpreterPackagesInfo()) {
infos.add("" + info.getName() + " " + info.getVersion());
}
}
}
return infos;
}
}

View File

@ -38,10 +38,10 @@ public class ProjectBuilder {
private static final String ALGORITHM_MIMETYPE = "text/plain";
private static final String ALGORITHM_DESCRIPTION = "Statistical Algorithm Java Code";
private static final String ALGORITHM_EXTENTION = ".java";
private static final String INTEGRATION_INFO_NAME = "IntegrationInfo";
private static final String INTEGRATION_INFO_MIMETYPE = "text/plain";
private static final String INTEGRATION_INFO_DESCRIPTION = "Integration Info";
private static final String INTEGRATION_INFO_EXTENTION = ".txt";
private static final String INFO_NAME = "Info";
private static final String INFO_MIMETYPE = "text/plain";
private static final String INFO_DESCRIPTION = "Info";
private static final String INFO_EXTENTION = ".txt";
private static final String PROJECT_PACKAGE_MIMETYPE = "application/zip";
private static final String PROJECT_PACKAGE_DESCRIPTION = "Statical Algorithm Project Package";
private static final String PROJECT_PACKAGE_EXTENTION = ".zip";
@ -94,7 +94,7 @@ public class ProjectBuilder {
"Attention No Project Information Set!");
}
if (project.getInputData().getProjectInfo().getClassName() == null) {
if (project.getInputData().getProjectInfo().getPackageName() == null) {
throw new StatAlgoImporterServiceException(
"Attention No Project Class Name Set!");
}
@ -133,7 +133,7 @@ public class ProjectBuilder {
algorithmItem = filesStorage.createItemOnWorkspace(aslSession
.getUsername(), Files.newInputStream(algorithmJava,
StandardOpenOption.READ), project.getInputData()
.getProjectInfo().getClassName()
.getProjectInfo().getPackageName()
+ ALGORITHM_EXTENTION, ALGORITHM_DESCRIPTION,
ALGORITHM_MIMETYPE, project.getProjectTarget()
.getTargetFolder().getId());
@ -207,7 +207,7 @@ public class ProjectBuilder {
try {
projectPackageItem = filesStorage.createItemOnWorkspace(
aslSession.getUsername(), inputStream, project
.getInputData().getProjectInfo().getClassName()
.getInputData().getProjectInfo().getPackageName()
+ PROJECT_PACKAGE_EXTENTION,
PROJECT_PACKAGE_DESCRIPTION, PROJECT_PACKAGE_MIMETYPE,
targetFolder.getId());
@ -240,7 +240,7 @@ public class ProjectBuilder {
private void createIntegrationInfo()
throws StatAlgoImporterServiceException {
IntegrationInfoGenerator integrationInfoGenerator = new IntegrationInfoGenerator(
InfoGenerator integrationInfoGenerator = new InfoGenerator(
project);
infoTXT = integrationInfoGenerator.createIntegrationInfo();
@ -251,8 +251,8 @@ public class ProjectBuilder {
infoItem = filesStorage.createItemOnWorkspace(
aslSession.getUsername(),
Files.newInputStream(infoTXT, StandardOpenOption.READ),
INTEGRATION_INFO_NAME + INTEGRATION_INFO_EXTENTION,
INTEGRATION_INFO_DESCRIPTION, INTEGRATION_INFO_MIMETYPE,
INFO_NAME + INFO_EXTENTION,
INFO_DESCRIPTION, INFO_MIMETYPE,
project.getProjectTarget().getTargetFolder().getId());
} catch (IOException e) {
logger.error(e.getLocalizedMessage());
@ -297,11 +297,11 @@ public class ProjectBuilder {
storage.downloadInputFile(ECOLOGICAL_ENGINE_SMART_EXECUTOR_JAR_URL,
ecologicalEngineSmartExecutorJar);
Path algorithmTempFile = new File(tempDirectory.toFile(), project
.getInputData().getProjectInfo().getClassName()
.getInputData().getProjectInfo().getPackageName()
+ ALGORITHM_EXTENTION).toPath();
Files.copy(algorithmJava, algorithmTempFile);
Path infoTempFile = new File(tempDirectory.toFile(),
INTEGRATION_INFO_NAME + INTEGRATION_INFO_EXTENTION)
INFO_NAME + INFO_EXTENTION)
.toPath();
Files.copy(infoTXT, infoTempFile);
@ -322,7 +322,7 @@ public class ProjectBuilder {
}
private void copyJarOnWorkspace(Path tempDirectory) throws StatAlgoImporterServiceException {
Path codeJar=Paths.get(tempDirectory.toString(),project.getInputData().getProjectInfo().getClassName()
Path codeJar=Paths.get(tempDirectory.toString(),project.getInputData().getProjectInfo().getPackageName()
+ JAR_EXTENTION);
FilesStorage filesStorage = new FilesStorage();
@ -331,7 +331,7 @@ public class ProjectBuilder {
try {
codeJarItem = filesStorage.createItemOnWorkspace(aslSession
.getUsername(), Files.newInputStream(codeJar,
StandardOpenOption.READ), project.getInputData().getProjectInfo().getClassName()
StandardOpenOption.READ), project.getInputData().getProjectInfo().getPackageName()
+ JAR_EXTENTION, CODE_JAR_DESCRIPTION,
CODE_JAR_MIMETYPE, project.getProjectTarget()
.getTargetFolder().getId());
@ -369,7 +369,7 @@ public class ProjectBuilder {
ProcessBuilder pb = new ProcessBuilder("javac", "-cp",
tempDirectory.toAbsolutePath().toString() + "/*", project
.getInputData().getProjectInfo().getClassName()
.getInputData().getProjectInfo().getPackageName()
+ ALGORITHM_EXTENTION);
pb.directory(tempDirectory.toFile());
Path logTXT = new File(tempDirectory.toFile(), LOG_TXT).toPath();
@ -398,7 +398,7 @@ public class ProjectBuilder {
List<String> commands = new ArrayList<>();
commands.add("jar");
commands.add("-cvf");
commands.add(project.getInputData().getProjectInfo().getClassName()
commands.add(project.getInputData().getProjectInfo().getPackageName()
+ JAR_EXTENTION);
DirectoryStream<Path> directoryStream = Files

View File

@ -8,7 +8,7 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.shared;
*/
public class Constants {
public static final String APPLICATION_ID = "org.gcube.portlets.user.statisticalrunner.server.portlet.StatisticalRunnerPortlet";
public static final String APPLICATION_ID = "org.gcube.portlets.user.statisticalalgorithmsimporter.server.portlet.StatAlgoImporterPortlet";
public static final String STATRUNNER_ID = "StatRunnerId";
public static final String STATRUNNER_LANG_COOKIE = "StatRunnerLangCookie";
public static final String STATRUNNER_LANG = "StatRunnerLang";

View File

@ -1,29 +1,37 @@
package org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project;
package org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input;
import java.io.Serializable;
/**
*
* @author Giancarlo Panichi email: <a
* @author giancarlo email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class ProjectInfo implements Serializable {
public class DeployableVRE implements Serializable {
private static final long serialVersionUID = 7304965177776383842L;
private static final long serialVersionUID = -7548059008384829524L;
private int id;
private String name;
private String description;
private String className;
public ProjectInfo() {
public DeployableVRE() {
super();
}
public ProjectInfo(String name, String description, String className) {
public DeployableVRE(int id, String name, String description) {
super();
this.id = id;
this.name = name;
this.description = description;
this.className = className;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
@ -42,18 +50,12 @@ public class ProjectInfo implements Serializable {
this.description = description;
}
public String getClassName() {
return className;
}
public void setClassName(String className) {
this.className = className;
}
@Override
public String toString() {
return "ProjectInfo [name=" + name + ", description=" + description
+ ", className=" + className + "]";
return "DeployableVRE [id=" + id + ", name=" + name + ", description="
+ description + "]";
}
}

View File

@ -0,0 +1,62 @@
package org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input;
import java.io.Serializable;
import java.util.ArrayList;
/**
*
* @author Giancarlo Panichi email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class ProjectInfo implements Serializable {
private static final long serialVersionUID = 7304965177776383842L;
private String packageName;
private String packageDescription;
private ArrayList<DeployableVRE> listDeployableVRE;
public ProjectInfo() {
super();
}
public ProjectInfo(String packageName, String pacakgeDescription,
ArrayList<DeployableVRE> listDeployableVRE) {
super();
this.packageName = packageName;
this.packageDescription = pacakgeDescription;
this.listDeployableVRE = listDeployableVRE;
}
public String getPackageName() {
return packageName;
}
public void setPackageName(String packageName) {
this.packageName = packageName;
}
public String getPackageDescription() {
return packageDescription;
}
public void setPackageDescription(String packageDescription) {
this.packageDescription = packageDescription;
}
public ArrayList<DeployableVRE> getListDeployableVRE() {
return listDeployableVRE;
}
public void setListDeployableVRE(ArrayList<DeployableVRE> listDeployableVRE) {
this.listDeployableVRE = listDeployableVRE;
}
@Override
public String toString() {
return "ProjectInfo [packageName=" + packageName
+ ", packageDescription=" + packageDescription
+ ", listDeployableVRE=" + listDeployableVRE + "]";
}
}

View File

@ -5,6 +5,7 @@ import java.util.ArrayList;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.EnvironmentVariables;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.InterpreterInfo;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.ProjectInfo;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.SelectedRowsVariables;
/**

View File

@ -50,18 +50,19 @@
values="en" /> <extend-property name="locale" values="it" /> <extend-property
name="locale" values="es" /> <set-property name="locale" value="en, it, es"
/> <set-property-fallback name="locale" value="en" /> -->
<!--
<set-property name="log_ConsoleLogger" value="ENABLED" /> <set-property
name="log_DivLogger" value="ENABLED" /> <set-property name="log_GWTLogger"
value="ENABLED" /> <set-property name="log_SystemLogger" value="ENABLED"
/>
/> -->
<!-- Not in GWT 2.6 <set-property name="log_FirebugLogger" value="ENABLED"
/> -->
<!--
<set-property name="log_ConsoleLogger" value="DISABLED" />
<set-property name="log_DivLogger" value="DISABLED" />
<set-property name="log_GWTLogger" value="DISABLED" />
<set-property name="log_SystemLogger" value="DISABLED" /> -->
<set-property name="log_SystemLogger" value="DISABLED" />
<!-- Not in GWT 2.6 <set-property name="log_FirebugLogger" value="DISABLED"
/> -->

View File

@ -18,7 +18,7 @@
<script src='<%=request.getContextPath()%>/statalgoimporter/statalgoimporter.nocache.js'></script>
<div id="StatisticalRunnerPortlet" style="width: 100%; height: 100%">
<div id="StatAlgoImporterPortlet" style="width: 100%; height: 100%">
</div>

View File

@ -1,5 +1,5 @@
<display>
<category name="gCube Applications">
<portlet id="StatisticalRunner" />
<portlet id="StatisticalAlgorithmsImporter" />
</category>
</display>

View File

@ -1,4 +1,4 @@
name=StatisticalRunner
name=StatisticalAlgorithmsImporter
module-group-id=liferay
module-incremental-version=1
tags=

View File

@ -3,7 +3,7 @@
<liferay-portlet-app>
<portlet>
<portlet-name>StatisticalRunner</portlet-name>
<portlet-name>StatisticalAlgorithmsImporter</portlet-name>
<icon>/icon.png</icon>
<layout-cacheable>false</layout-cacheable>
<instanceable>false</instanceable>

View File

@ -1,18 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<portlet-app xmlns='http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd' version='2.0'>
<portlet>
<description>StatisticalRunner</description>
<portlet-name>StatisticalRunner</portlet-name>
<display-name>StatisticalRunner</display-name>
<portlet-class>org.gcube.portlets.user.statisticalrunner.server.portlet.StatisticalRunnerPortlet</portlet-class>
<description>StatisticalAlgorithmsImporter</description>
<portlet-name>StatisticalAlgorithmsImporter</portlet-name>
<display-name>StatisticalAlgorithmsImporter</display-name>
<portlet-class>org.gcube.portlets.user.statisticalalgorithmsimporter.server.portlet.StatAlgoImporterPortlet</portlet-class>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>view</portlet-mode>
</supports>
<portlet-info>
<title>StatisticalRunner</title>
<short-title>StatisticalRunner</short-title>
<title>StatisticalAlgorithmsImporter</title>
<short-title>StatisticalAlgorithmsImporter</short-title>
</portlet-info>
</portlet>
</portlet-app>