ref 8819: Extend The Algorithms Importer to Manage Many Processes as Black Boxes

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

Updated the support for Processes as Black Boxes

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/statistical-algorithms-importer@149379 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2017-06-09 16:35:45 +00:00
parent 2e5a551a6a
commit 27640a0cff
20 changed files with 879 additions and 434 deletions

View File

@ -2,6 +2,7 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.client;
import java.util.Date; import java.util.Date;
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.BinaryCodeSetEvent;
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.DeleteItemEvent; import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.DeleteItemEvent;
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.InputReadyEvent; import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.InputReadyEvent;
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.InputRequestEvent; import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.InputRequestEvent;
@ -218,6 +219,20 @@ public class StatAlgoImporterController {
}); });
eventBus.addHandler(BinaryCodeSetEvent.TYPE,
new BinaryCodeSetEvent.BinaryCodeSetEventHandler() {
@Override
public void onBinaryCodeSet(BinaryCodeSetEvent event) {
Log.debug("Catch BinaryCodeSetEvent");
doBinaryCodeSetCommand(event);
}
});
eventBus.addHandler(DeleteItemEvent.TYPE, eventBus.addHandler(DeleteItemEvent.TYPE,
new DeleteItemEvent.DeleteItemEventHandler() { new DeleteItemEvent.DeleteItemEventHandler() {
@ -419,6 +434,15 @@ public class StatAlgoImporterController {
} }
private void doBinaryCodeSetCommand(BinaryCodeSetEvent event) {
ItemDescription itemDescription = event.getItemDescription();
if (itemDescription != null && itemDescription.getId() != null) {
pm.setBinaryCode(itemDescription);
}
}
private void doSetNewMainCodeEvent(NewMainCodeEvent event) { private void doSetNewMainCodeEvent(NewMainCodeEvent event) {
monitor = new StatAlgoImporterMonitor(); monitor = new StatAlgoImporterMonitor();
pm.setNewMainCode(event, monitor); pm.setNewMainCode(event, monitor);

View File

@ -0,0 +1,62 @@
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.event;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.workspace.ItemDescription;
import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.event.shared.HasHandlers;
/**
* Binary Code Set Event
*
*
* @author Giancarlo Panichi
*
*
*/
public class BinaryCodeSetEvent extends GwtEvent<BinaryCodeSetEvent.BinaryCodeSetEventHandler> {
public static Type<BinaryCodeSetEventHandler> TYPE = new Type<BinaryCodeSetEventHandler>();
private ItemDescription itemDescription;
public interface BinaryCodeSetEventHandler extends EventHandler {
void onBinaryCodeSet(BinaryCodeSetEvent event);
}
public interface HasBinaryCodeSetEventHandler extends HasHandlers {
public HandlerRegistration addBinaryCodeSetEventHandler(BinaryCodeSetEventHandler handler);
}
public BinaryCodeSetEvent(ItemDescription itemDescription) {
this.itemDescription = itemDescription;
}
@Override
protected void dispatch(BinaryCodeSetEventHandler handler) {
handler.onBinaryCodeSet(this);
}
@Override
public Type<BinaryCodeSetEventHandler> getAssociatedType() {
return TYPE;
}
public static Type<BinaryCodeSetEventHandler> getType() {
return TYPE;
}
public static void fire(HasHandlers source, BinaryCodeSetEvent binaryCodeSetEvent) {
source.fireEvent(binaryCodeSetEvent);
}
public ItemDescription getItemDescription() {
return itemDescription;
}
@Override
public String toString() {
return "BinaryCodeSetEvent [itemDescription=" + itemDescription + "]";
}
}

View File

@ -68,6 +68,7 @@ public class MainDataPanel extends SimpleContainer {
case OPEN: case OPEN:
addCodeEditPanel(event.getProject()); addCodeEditPanel(event.getProject());
break; break;
case BINARY_CODE_SET:
case SAVE: case SAVE:
case START: case START:
case UPDATE: case UPDATE:

View File

@ -20,6 +20,7 @@ import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.St
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.InputData; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.InputData;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.ProjectCreateSession; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.ProjectCreateSession;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.ProjectSupportBlackBox;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.workspace.ItemDescription; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.workspace.ItemDescription;
import org.gcube.portlets.widgets.githubconnector.client.GitHubConnectorWizard; import org.gcube.portlets.widgets.githubconnector.client.GitHubConnectorWizard;
import org.gcube.portlets.widgets.githubconnector.client.wizard.event.WizardEvent; import org.gcube.portlets.widgets.githubconnector.client.wizard.event.WizardEvent;
@ -517,6 +518,45 @@ public class ProjectManager {
}); });
} }
public void setBinaryCode(final ItemDescription itemDescription) {
if (project != null) {
if (project.getProjectConfig() != null && project.getProjectConfig().getProjectSupport() != null
&& project.getProjectConfig().getProjectSupport() instanceof ProjectSupportBlackBox) {
setBinaryCodeOnServer(itemDescription);
}
} else {
}
}
private void setBinaryCodeOnServer(final ItemDescription itemDescription) {
Log.debug("Set Binary Code: " + itemDescription);
StatAlgoImporterServiceAsync.INSTANCE.setBinaryCode(itemDescription, new AsyncCallback<Project>() {
@Override
public void onFailure(Throwable caught) {
if (caught instanceof StatAlgoImporterSessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(SessionExpiredType.EXPIREDONSERVER));
} else {
Log.error("Error setting code: " + caught.getLocalizedMessage());
UtilsGXT3.alert("Error", caught.getLocalizedMessage());
}
caught.printStackTrace();
}
@Override
public void onSuccess(Project result) {
project = result;
fireProjectStatusBinaryCodeSetEvent();
}
});
}
public void deleteItem(final ItemDescription itemDescription) { public void deleteItem(final ItemDescription itemDescription) {
if (project != null && project.getMainCode() != null && project.getMainCode().getItemDescription() != null if (project != null && project.getMainCode() != null && project.getMainCode().getItemDescription() != null
&& itemDescription.getId().compareTo(project.getMainCode().getItemDescription().getId()) == 0) { && itemDescription.getId().compareTo(project.getMainCode().getItemDescription().getId()) == 0) {
@ -821,6 +861,12 @@ public class ProjectManager {
eventBus.fireEvent(projectStatusEvent); eventBus.fireEvent(projectStatusEvent);
} }
private void fireProjectStatusBinaryCodeSetEvent() {
ProjectStatusEvent projectStatusEvent = new ProjectStatusEvent(ProjectStatusEventType.BINARY_CODE_SET, project);
Log.debug("Project Manager ProjectStatusEvent fire! " + projectStatusEvent);
eventBus.fireEvent(projectStatusEvent);
}
private void fireProjectStatusSoftwareCreatedEvent() { private void fireProjectStatusSoftwareCreatedEvent() {
ProjectStatusEvent projectStatusEvent = new ProjectStatusEvent(ProjectStatusEventType.SOFTWARE_CREATED, ProjectStatusEvent projectStatusEvent = new ProjectStatusEvent(ProjectStatusEventType.SOFTWARE_CREATED,
project); project);
@ -851,11 +897,12 @@ public class ProjectManager {
} }
/*
private void fireProjectStatusOpenEvent() { private void fireProjectStatusOpenEvent() {
ProjectStatusEvent projectStatusEvent = new ProjectStatusEvent(ProjectStatusEventType.OPEN, project); ProjectStatusEvent projectStatusEvent = new ProjectStatusEvent(ProjectStatusEventType.OPEN, project);
Log.debug("Project Manager ProjectStatusEvent fire! " + projectStatusEvent); Log.debug("Project Manager ProjectStatusEvent fire! " + projectStatusEvent);
eventBus.fireEvent(projectStatusEvent); eventBus.fireEvent(projectStatusEvent);
} }*/
} }

View File

@ -58,6 +58,8 @@ public interface StatAlgoImporterService extends RemoteService {
// //
public Project setMainCode(ItemDescription itemDescription) throws StatAlgoImporterServiceException; public Project setMainCode(ItemDescription itemDescription) throws StatAlgoImporterServiceException;
public Project setBinaryCode(ItemDescription itemDescription) throws StatAlgoImporterServiceException;
public void addResourceToProject(ItemDescription itemDescription) throws StatAlgoImporterServiceException; public void addResourceToProject(ItemDescription itemDescription) throws StatAlgoImporterServiceException;
public Project deleteResourceOnProject(ItemDescription itemDescription) throws StatAlgoImporterServiceException; public Project deleteResourceOnProject(ItemDescription itemDescription) throws StatAlgoImporterServiceException;
@ -80,4 +82,5 @@ public interface StatAlgoImporterService extends RemoteService {
public void repackageSoftware() throws StatAlgoImporterServiceException; public void repackageSoftware() throws StatAlgoImporterServiceException;
} }

View File

@ -38,7 +38,9 @@ public interface StatAlgoImporterServiceAsync {
void createProjectOnWorkspace(ProjectCreateSession projectCreateSession, AsyncCallback<Project> callback); void createProjectOnWorkspace(ProjectCreateSession projectCreateSession, AsyncCallback<Project> callback);
void setMainCode(ItemDescription itemDescription, AsyncCallback<Project> callback); void setMainCode(ItemDescription itemDescription, AsyncCallback<Project> asyncCallback);
void setBinaryCode(ItemDescription itemDescription, AsyncCallback<Project> asyncCallback);
void addResourceToProject(ItemDescription itemDescription, AsyncCallback<Void> asyncCallback); void addResourceToProject(ItemDescription itemDescription, AsyncCallback<Void> asyncCallback);
@ -64,4 +66,5 @@ public interface StatAlgoImporterServiceAsync {
} }

View File

@ -1,5 +1,6 @@
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.tools.explorer; package org.gcube.portlets.user.statisticalalgorithmsimporter.client.tools.explorer;
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.BinaryCodeSetEvent;
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.DeleteItemEvent; import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.DeleteItemEvent;
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.MainCodeSetEvent; import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.MainCodeSetEvent;
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.ProjectStatusEvent; import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.ProjectStatusEvent;
@ -9,6 +10,7 @@ import org.gcube.portlets.user.statisticalalgorithmsimporter.client.rpc.StatAlgo
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.type.SessionExpiredType; import org.gcube.portlets.user.statisticalalgorithmsimporter.client.type.SessionExpiredType;
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.utils.UtilsGXT3; import org.gcube.portlets.user.statisticalalgorithmsimporter.client.utils.UtilsGXT3;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterSessionExpiredException; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterSessionExpiredException;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.ProjectSupportBlackBox;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.workspace.ItemDescription; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.workspace.ItemDescription;
import org.gcube.portlets.widgets.workspaceuploader.client.WorkspaceUploadNotification.WorskpaceUploadNotificationListener; import org.gcube.portlets.widgets.workspaceuploader.client.WorkspaceUploadNotification.WorskpaceUploadNotificationListener;
import org.gcube.portlets.widgets.workspaceuploader.client.uploader.DialogUpload.UPLOAD_TYPE; import org.gcube.portlets.widgets.workspaceuploader.client.uploader.DialogUpload.UPLOAD_TYPE;
@ -103,6 +105,7 @@ public class ExplorerProjectPanel extends ContentPanel {
} }
private void manageProjectStatusEvents(ProjectStatusEvent event) { private void manageProjectStatusEvents(ProjectStatusEvent event) {
switch (event.getProjectStatusEventType()) { switch (event.getProjectStatusEventType()) {
case START: case START:
break; break;
@ -115,6 +118,7 @@ public class ExplorerProjectPanel extends ContentPanel {
break; break;
case SAVE: case SAVE:
case MAIN_CODE_SET: case MAIN_CODE_SET:
case BINARY_CODE_SET:
case SOFTWARE_CREATED: case SOFTWARE_CREATED:
case SOFTWARE_PUBLISH: case SOFTWARE_PUBLISH:
case SOFTWARE_REPACKAGE: case SOFTWARE_REPACKAGE:
@ -201,6 +205,22 @@ public class ExplorerProjectPanel extends ContentPanel {
dnd.addWorkspaceUploadNotificationListener(workspaceUploaderListener); dnd.addWorkspaceUploadNotificationListener(workspaceUploaderListener);
// ToolBar // ToolBar
if (event.getProject().getProjectConfig().getProjectSupport() instanceof ProjectSupportBlackBox) {
btnSetMain = new TextButton("Set Code");
btnSetMain.setIcon(StatAlgoImporterResources.INSTANCE.add16());
btnSetMain.setScale(ButtonScale.SMALL);
btnSetMain.setIconAlign(IconAlign.LEFT);
btnSetMain.setToolTip("Set code");
btnSetMain.addSelectHandler(new SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
setBinaryCode(event);
}
});
} else {
btnSetMain = new TextButton("Set Main"); btnSetMain = new TextButton("Set Main");
btnSetMain.setIcon(StatAlgoImporterResources.INSTANCE.add16()); btnSetMain.setIcon(StatAlgoImporterResources.INSTANCE.add16());
btnSetMain.setScale(ButtonScale.SMALL); btnSetMain.setScale(ButtonScale.SMALL);
@ -214,6 +234,7 @@ public class ExplorerProjectPanel extends ContentPanel {
} }
}); });
}
btnOpen = new TextButton("Open"); btnOpen = new TextButton("Open");
btnOpen.setIcon(StatAlgoImporterResources.INSTANCE.download16()); btnOpen.setIcon(StatAlgoImporterResources.INSTANCE.download16());
@ -283,14 +304,7 @@ public class ExplorerProjectPanel extends ContentPanel {
} }
private void setMainCode(SelectEvent event) {
Log.debug("Set Main Code");
if (selectedItem != null && selectedItem.getType().compareTo(ItemType.EXTERNAL_FILE) == 0) {
loadData();
} else {
UtilsGXT3.info("Attention", "Select a valid file to be used as main!");
}
}
private void deleteItem(SelectEvent event) { private void deleteItem(SelectEvent event) {
ItemDescription itemDescription = new ItemDescription(selectedItem.getId(), selectedItem.getName(), ItemDescription itemDescription = new ItemDescription(selectedItem.getId(), selectedItem.getName(),
@ -300,7 +314,17 @@ public class ExplorerProjectPanel extends ContentPanel {
Log.debug("Fired: " + deleteItemEvent); Log.debug("Fired: " + deleteItemEvent);
} }
private void loadData() { private void setMainCode(SelectEvent event) {
Log.debug("Set Code");
if (selectedItem != null && selectedItem.getType().compareTo(ItemType.EXTERNAL_FILE) == 0) {
setMainCodeData();
} else {
UtilsGXT3.info("Attention", "Select a valid file to be used as main!");
}
}
private void setMainCodeData() {
ItemDescription itemDescription = new ItemDescription(selectedItem.getId(), selectedItem.getName(), ItemDescription itemDescription = new ItemDescription(selectedItem.getId(), selectedItem.getName(),
selectedItem.getOwner(), selectedItem.getPath(), selectedItem.getType().name()); selectedItem.getOwner(), selectedItem.getPath(), selectedItem.getType().name());
MainCodeSetEvent mainCodeSetEvent = new MainCodeSetEvent(itemDescription); MainCodeSetEvent mainCodeSetEvent = new MainCodeSetEvent(itemDescription);
@ -309,6 +333,25 @@ public class ExplorerProjectPanel extends ContentPanel {
} }
private void setBinaryCode(SelectEvent event) {
Log.debug("Set Code");
if (selectedItem != null && selectedItem.getType().compareTo(ItemType.EXTERNAL_FILE) == 0) {
setBinaryCodeData();
} else {
UtilsGXT3.info("Attention", "Select a valid file to be used!");
}
}
private void setBinaryCodeData() {
ItemDescription itemDescription = new ItemDescription(selectedItem.getId(), selectedItem.getName(),
selectedItem.getOwner(), selectedItem.getPath(), selectedItem.getType().name());
BinaryCodeSetEvent binaryCodeSetEvent = new BinaryCodeSetEvent(itemDescription);
eventBus.fireEvent(binaryCodeSetEvent);
Log.debug("Fired: " + binaryCodeSetEvent);
}
private void openFile() { private void openFile() {
if (selectedItem != null && !selectedItem.isFolder()) { if (selectedItem != null && !selectedItem.isFolder()) {

View File

@ -11,6 +11,7 @@ import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.DataTy
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.IOType; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.IOType;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.InputOutputVariables; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.InputOutputVariables;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.ProjectSupportBlackBox;
import com.allen_sauer.gwt.log.client.Log; import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.cell.client.AbstractCell; import com.google.gwt.cell.client.AbstractCell;
@ -22,6 +23,8 @@ import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.event.shared.EventBus; import com.google.gwt.event.shared.EventBus;
import com.google.gwt.safehtml.shared.SafeHtml; import com.google.gwt.safehtml.shared.SafeHtml;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder; import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.sencha.gxt.cell.core.client.ButtonCell.ButtonScale;
import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign;
import com.sencha.gxt.cell.core.client.form.ComboBoxCell.TriggerAction; import com.sencha.gxt.cell.core.client.form.ComboBoxCell.TriggerAction;
import com.sencha.gxt.core.client.Style.SelectionMode; import com.sencha.gxt.core.client.Style.SelectionMode;
import com.sencha.gxt.core.client.XTemplates; import com.sencha.gxt.core.client.XTemplates;
@ -36,6 +39,7 @@ import com.sencha.gxt.dnd.core.client.GridDropTarget;
import com.sencha.gxt.widget.core.client.ContentPanel; 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.ButtonBar;
import com.sencha.gxt.widget.core.client.button.TextButton; 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.MarginData;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer; 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.container.VerticalLayoutContainer.VerticalLayoutData;
@ -56,6 +60,7 @@ 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.Grid.GridCell;
import com.sencha.gxt.widget.core.client.grid.GridSelectionModel; 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.grid.editing.GridRowEditing;
import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
/** /**
* *
@ -74,6 +79,7 @@ public class InputOutputVariablesPanel extends ContentPanel {
private ListStore<IOType> storeComboIOType; private ListStore<IOType> storeComboIOType;
private ComboBox<IOType> comboIOType; private ComboBox<IOType> comboIOType;
private GridRowEditing<InputOutputVariables> gridInputOutputVariablesEditing; private GridRowEditing<InputOutputVariables> gridInputOutputVariablesEditing;
private TextButton btnAddVariable;
private TextButton btnAdd; private TextButton btnAdd;
private boolean addStatus; private boolean addStatus;
private int seq = 0; private int seq = 0;
@ -119,8 +125,7 @@ public class InputOutputVariablesPanel extends ContentPanel {
} }
// Grid // Grid
InputOutputVariablesProperties props = GWT InputOutputVariablesProperties props = GWT.create(InputOutputVariablesProperties.class);
.create(InputOutputVariablesProperties.class);
ColumnConfig<InputOutputVariables, String> nameColumn = new ColumnConfig<InputOutputVariables, String>( ColumnConfig<InputOutputVariables, String> nameColumn = new ColumnConfig<InputOutputVariables, String>(
props.name(), 100, "Name"); props.name(), 100, "Name");
@ -136,10 +141,8 @@ public class InputOutputVariablesPanel extends ContentPanel {
dataTypeColumn.setCell(new AbstractCell<DataType>() { dataTypeColumn.setCell(new AbstractCell<DataType>() {
@Override @Override
public void render(Context context, DataType inputType, public void render(Context context, DataType inputType, SafeHtmlBuilder sb) {
SafeHtmlBuilder sb) { DataTypeTemplates inputTypeTemplates = GWT.create(DataTypeTemplates.class);
DataTypeTemplates inputTypeTemplates = GWT
.create(DataTypeTemplates.class);
sb.append(inputTypeTemplates.format(inputType.getLabel())); sb.append(inputTypeTemplates.format(inputType.getLabel()));
} }
}); });
@ -154,10 +157,8 @@ public class InputOutputVariablesPanel extends ContentPanel {
ioTypeColumn.setCell(new AbstractCell<IOType>() { ioTypeColumn.setCell(new AbstractCell<IOType>() {
@Override @Override
public void render(Context context, IOType ioType, public void render(Context context, IOType ioType, SafeHtmlBuilder sb) {
SafeHtmlBuilder sb) { IOTypeTemplates ioTypeTemplates = GWT.create(IOTypeTemplates.class);
IOTypeTemplates ioTypeTemplates = GWT
.create(IOTypeTemplates.class);
sb.append(ioTypeTemplates.format(ioType.getLabel())); sb.append(ioTypeTemplates.format(ioType.getLabel()));
} }
}); });
@ -169,11 +170,9 @@ public class InputOutputVariablesPanel extends ContentPanel {
l.add(defaultValueColumn); l.add(defaultValueColumn);
l.add(ioTypeColumn); l.add(ioTypeColumn);
ColumnModel<InputOutputVariables> columns = new ColumnModel<InputOutputVariables>( ColumnModel<InputOutputVariables> columns = new ColumnModel<InputOutputVariables>(l);
l);
storeInputOutputVariables = new ListStore<InputOutputVariables>( storeInputOutputVariables = new ListStore<InputOutputVariables>(props.id());
props.id());
/* /*
* ArrayList<InputOutputVariablesVariables> list = new ArrayList<>(); * ArrayList<InputOutputVariablesVariables> list = new ArrayList<>();
@ -186,18 +185,15 @@ public class InputOutputVariablesPanel extends ContentPanel {
if (project != null && project.getInputData() != null if (project != null && project.getInputData() != null
&& project.getInputData().getListInputOutputVariables() != null) { && project.getInputData().getListInputOutputVariables() != null) {
checkOutputParameterOnlyFileTypeIsSupported(project.getInputData() checkOutputParameterOnlyFileTypeIsSupported(project.getInputData().getListInputOutputVariables());
.getListInputOutputVariables());
storeInputOutputVariables.addAll(project.getInputData() storeInputOutputVariables.addAll(project.getInputData().getListInputOutputVariables());
.getListInputOutputVariables());
} }
final GridSelectionModel<InputOutputVariables> sm = new GridSelectionModel<InputOutputVariables>(); final GridSelectionModel<InputOutputVariables> sm = new GridSelectionModel<InputOutputVariables>();
sm.setSelectionMode(SelectionMode.SINGLE); sm.setSelectionMode(SelectionMode.SINGLE);
gridInputOutputVariables = new Grid<InputOutputVariables>( gridInputOutputVariables = new Grid<InputOutputVariables>(storeInputOutputVariables, columns);
storeInputOutputVariables, columns);
gridInputOutputVariables.setSelectionModel(sm); gridInputOutputVariables.setSelectionModel(sm);
gridInputOutputVariables.getView().setStripeRows(true); gridInputOutputVariables.getView().setStripeRows(true);
gridInputOutputVariables.getView().setColumnLines(true); gridInputOutputVariables.getView().setColumnLines(true);
@ -207,36 +203,30 @@ public class InputOutputVariablesPanel extends ContentPanel {
gridInputOutputVariables.setColumnReordering(false); gridInputOutputVariables.setColumnReordering(false);
// DND // DND
GridDragSource<InputOutputVariables> ds = new GridDragSource<InputOutputVariables>( GridDragSource<InputOutputVariables> ds = new GridDragSource<InputOutputVariables>(gridInputOutputVariables);
gridInputOutputVariables);
ds.addDragStartHandler(new DndDragStartEvent.DndDragStartHandler() { ds.addDragStartHandler(new DndDragStartEvent.DndDragStartHandler() {
@Override @Override
public void onDragStart(DndDragStartEvent event) { public void onDragStart(DndDragStartEvent event) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
ArrayList<InputOutputVariables> draggingSelection = (ArrayList<InputOutputVariables>) event ArrayList<InputOutputVariables> draggingSelection = (ArrayList<InputOutputVariables>) event.getData();
.getData();
Log.debug("Start Drag: " + draggingSelection); Log.debug("Start Drag: " + draggingSelection);
} }
}); });
GridDropTarget<InputOutputVariables> dt = new GridDropTarget<InputOutputVariables>( GridDropTarget<InputOutputVariables> dt = new GridDropTarget<InputOutputVariables>(gridInputOutputVariables);
gridInputOutputVariables);
dt.setFeedback(Feedback.BOTH); dt.setFeedback(Feedback.BOTH);
dt.setAllowSelfAsSource(true); dt.setAllowSelfAsSource(true);
// EDITING // // EDITING //
// DataType // DataType
DataTypePropertiesCombo dataTypePropertiesCombo = GWT DataTypePropertiesCombo dataTypePropertiesCombo = GWT.create(DataTypePropertiesCombo.class);
.create(DataTypePropertiesCombo.class);
storeComboDataType = new ListStore<DataType>( storeComboDataType = new ListStore<DataType>(dataTypePropertiesCombo.id());
dataTypePropertiesCombo.id());
comboDataType = new ComboBox<DataType>(storeComboDataType, comboDataType = new ComboBox<DataType>(storeComboDataType, dataTypePropertiesCombo.label());
dataTypePropertiesCombo.label());
comboDataType.setClearValueOnParseError(false); comboDataType.setClearValueOnParseError(false);
comboDataType.setEditable(false); comboDataType.setEditable(false);
@ -248,13 +238,11 @@ public class InputOutputVariablesPanel extends ContentPanel {
storeComboDataType.commitChanges(); storeComboDataType.commitChanges();
// IOType // IOType
IOTypePropertiesCombo ioTypePropertiesCombo = GWT IOTypePropertiesCombo ioTypePropertiesCombo = GWT.create(IOTypePropertiesCombo.class);
.create(IOTypePropertiesCombo.class);
storeComboIOType = new ListStore<IOType>(ioTypePropertiesCombo.id()); storeComboIOType = new ListStore<IOType>(ioTypePropertiesCombo.id());
comboIOType = new ComboBox<IOType>(storeComboIOType, comboIOType = new ComboBox<IOType>(storeComboIOType, ioTypePropertiesCombo.label());
ioTypePropertiesCombo.label());
comboIOType.setClearValueOnParseError(false); comboIOType.setClearValueOnParseError(false);
comboIOType.setEditable(false); comboIOType.setEditable(false);
@ -267,34 +255,26 @@ public class InputOutputVariablesPanel extends ContentPanel {
// //
TextField nameColumnEditing = new TextField(); TextField nameColumnEditing = new TextField();
nameColumnEditing.addValidator(new RegExValidator("^[^\"]*$", nameColumnEditing.addValidator(new RegExValidator("^[^\"]*$", "Attention character \" is not allowed"));
"Attention character \" is not allowed"));
TextField descriptionColumnEditing = new TextField(); TextField descriptionColumnEditing = new TextField();
descriptionColumnEditing.addValidator(new RegExValidator("^[^\"]*$", descriptionColumnEditing.addValidator(new RegExValidator("^[^\"]*$", "Attention character \" is not allowed"));
"Attention character \" is not allowed"));
TextField defaultValueColumnEditing = new TextField(); TextField defaultValueColumnEditing = new TextField();
defaultValueColumnEditing.setAllowBlank(false); defaultValueColumnEditing.setAllowBlank(false);
defaultValueColumnEditing.addValidator(new RegExValidator( defaultValueColumnEditing.addValidator(
"^[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*$", new RegExValidator("^[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*$", "Attention character \" is not allowed"));
"Attention character \" is not allowed"));
gridInputOutputVariablesEditing = new GridRowEditing<InputOutputVariables>( gridInputOutputVariablesEditing = new GridRowEditing<InputOutputVariables>(gridInputOutputVariables);
gridInputOutputVariables); gridInputOutputVariablesEditing.addEditor(nameColumn, nameColumnEditing);
gridInputOutputVariablesEditing gridInputOutputVariablesEditing.addEditor(descriptionColumn, descriptionColumnEditing);
.addEditor(nameColumn, nameColumnEditing); gridInputOutputVariablesEditing.addEditor(dataTypeColumn, comboDataType);
gridInputOutputVariablesEditing.addEditor(descriptionColumn, gridInputOutputVariablesEditing.addEditor(defaultValueColumn, defaultValueColumnEditing);
descriptionColumnEditing);
gridInputOutputVariablesEditing
.addEditor(dataTypeColumn, comboDataType);
gridInputOutputVariablesEditing.addEditor(defaultValueColumn,
defaultValueColumnEditing);
gridInputOutputVariablesEditing.addEditor(ioTypeColumn, comboIOType); gridInputOutputVariablesEditing.addEditor(ioTypeColumn, comboIOType);
btnAdd = new TextButton(); btnAddVariable = new TextButton();
btnAdd.setIcon(StatAlgoImporterResources.INSTANCE.add16()); btnAddVariable.setIcon(StatAlgoImporterResources.INSTANCE.add16());
// btnAdd.setIconAlign(IconAlign.); // btnAdd.setIconAlign(IconAlign.);
btnAdd.setToolTip("Add Input/Output Variable"); btnAddVariable.setToolTip("Add Input/Output Variable");
btnAdd.addSelectHandler(new SelectHandler() { btnAddVariable.addSelectHandler(new SelectHandler() {
@Override @Override
public void onSelect(SelectEvent event) { public void onSelect(SelectEvent event) {
@ -314,15 +294,13 @@ public class InputOutputVariablesPanel extends ContentPanel {
storeInputOutputVariables.remove(rowIndex); storeInputOutputVariables.remove(rowIndex);
storeInputOutputVariables.commitChanges(); storeInputOutputVariables.commitChanges();
gridInputOutputVariablesEditing.getCancelButton().setVisible( gridInputOutputVariablesEditing.getCancelButton().setVisible(true);
true); btnAddVariable.setEnabled(true);
btnAdd.setEnabled(true);
if (addStatus) { if (addStatus) {
addStatus = false; addStatus = false;
} }
List<InputOutputVariables> listIOVariables = storeInputOutputVariables List<InputOutputVariables> listIOVariables = storeInputOutputVariables.getAll();
.getAll();
List<InputOutputVariables> listNewIOVariables = new ArrayList<InputOutputVariables>(); List<InputOutputVariables> listNewIOVariables = new ArrayList<InputOutputVariables>();
for (int i = 0; i < listIOVariables.size(); i++) { for (int i = 0; i < listIOVariables.size(); i++) {
InputOutputVariables var = listIOVariables.get(i); InputOutputVariables var = listIOVariables.get(i);
@ -342,45 +320,38 @@ public class InputOutputVariablesPanel extends ContentPanel {
ButtonBar buttonBar = gridInputOutputVariablesEditing.getButtonBar(); ButtonBar buttonBar = gridInputOutputVariablesEditing.getButtonBar();
buttonBar.add(btnDelete); buttonBar.add(btnDelete);
gridInputOutputVariablesEditing gridInputOutputVariablesEditing.addBeforeStartEditHandler(new BeforeStartEditHandler<InputOutputVariables>() {
.addBeforeStartEditHandler(new BeforeStartEditHandler<InputOutputVariables>() {
@Override @Override
public void onBeforeStartEdit( public void onBeforeStartEdit(BeforeStartEditEvent<InputOutputVariables> event) {
BeforeStartEditEvent<InputOutputVariables> event) {
editingBeforeStart(event); editingBeforeStart(event);
} }
}); });
gridInputOutputVariablesEditing gridInputOutputVariablesEditing.addCancelEditHandler(new CancelEditHandler<InputOutputVariables>() {
.addCancelEditHandler(new CancelEditHandler<InputOutputVariables>() {
@Override @Override
public void onCancelEdit( public void onCancelEdit(CancelEditEvent<InputOutputVariables> event) {
CancelEditEvent<InputOutputVariables> event) {
storeInputOutputVariables.rejectChanges(); storeInputOutputVariables.rejectChanges();
btnAdd.setEnabled(true); btnAddVariable.setEnabled(true);
} }
}); });
gridInputOutputVariablesEditing gridInputOutputVariablesEditing.addCompleteEditHandler(new CompleteEditHandler<InputOutputVariables>() {
.addCompleteEditHandler(new CompleteEditHandler<InputOutputVariables>() {
@Override @Override
public void onCompleteEdit( public void onCompleteEdit(CompleteEditEvent<InputOutputVariables> event) {
CompleteEditEvent<InputOutputVariables> event) {
try { try {
if (addStatus) { if (addStatus) {
addStatus = false; addStatus = false;
} }
storeInputOutputVariables.commitChanges(); storeInputOutputVariables.commitChanges();
gridInputOutputVariablesEditing.getCancelButton() gridInputOutputVariablesEditing.getCancelButton().setVisible(true);
.setVisible(true); btnAddVariable.setEnabled(true);
btnAdd.setEnabled(true);
} catch (Throwable e) { } catch (Throwable e) {
Log.error("Error: " + e.getLocalizedMessage()); Log.error("Error: " + e.getLocalizedMessage());
@ -389,34 +360,49 @@ public class InputOutputVariablesPanel extends ContentPanel {
} }
}); });
// ToolBar toolBar = new ToolBar();
// toolBar.add(btnAdd, new BoxLayoutData(new Margins(0)));
VerticalLayoutContainer vlc = new VerticalLayoutContainer(); VerticalLayoutContainer vlc = new VerticalLayoutContainer();
vlc.setAdjustForScroll(false); vlc.setAdjustForScroll(false);
vlc.setScrollMode(ScrollMode.NONE); vlc.setScrollMode(ScrollMode.NONE);
// vlc.add(toolBar, new VerticalLayoutData(1, -1, new Margins(0))); if (project != null && project.getProjectConfig() != null
vlc.add(gridInputOutputVariables, new VerticalLayoutData(1, 1, && project.getProjectConfig().getProjectSupport() != null) {
new Margins(0))); if (project.getProjectConfig().getProjectSupport() instanceof ProjectSupportBlackBox) {
btnAdd = new TextButton("Add");
btnAdd.setIcon(StatAlgoImporterResources.INSTANCE.add16());
btnAdd.setScale(ButtonScale.SMALL);
btnAdd.setIconAlign(IconAlign.LEFT);
btnAdd.setToolTip("Add Input/Output");
btnAdd.addSelectHandler(new SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
addInputOutputVariable(event);
}
});
ToolBar toolBar = new ToolBar();
toolBar.add(btnAdd, new BoxLayoutData(new Margins(0)));
vlc.add(toolBar, new VerticalLayoutData(1, -1, new Margins(0)));
}
}
vlc.add(gridInputOutputVariables, new VerticalLayoutData(1, 1, new Margins(0)));
add(vlc, new MarginData(new Margins(0))); add(vlc, new MarginData(new Margins(0)));
} }
private void editingBeforeStart( private void editingBeforeStart(BeforeStartEditEvent<InputOutputVariables> event) {
BeforeStartEditEvent<InputOutputVariables> event) { if (storeInputOutputVariables != null && storeInputOutputVariables.size() > 0) {
if (storeInputOutputVariables != null
&& storeInputOutputVariables.size() > 0) {
int rowIndex = event.getEditCell().getRow(); int rowIndex = event.getEditCell().getRow();
InputOutputVariables currentInputOutputVariable = storeInputOutputVariables InputOutputVariables currentInputOutputVariable = storeInputOutputVariables.get(rowIndex);
.get(rowIndex); if (currentInputOutputVariable != null && currentInputOutputVariable.getIoType() != null
if (currentInputOutputVariable != null && currentInputOutputVariable.getIoType().compareTo(IOType.OUTPUT) == 0) {
&& currentInputOutputVariable.getIoType() != null
&& currentInputOutputVariable.getIoType().compareTo(
IOType.OUTPUT) == 0) {
storeComboDataType.clear(); storeComboDataType.clear();
storeComboDataType.add(DataType.FILE); storeComboDataType.add(DataType.FILE);
storeComboDataType.commitChanges(); storeComboDataType.commitChanges();
@ -432,14 +418,12 @@ public class InputOutputVariablesPanel extends ContentPanel {
} }
} }
private void addHandlersForComboDataType( private void addHandlersForComboDataType(LabelProvider<DataType> labelProvider) {
LabelProvider<DataType> labelProvider) {
comboDataType.addValueChangeHandler(new ValueChangeHandler<DataType>() { comboDataType.addValueChangeHandler(new ValueChangeHandler<DataType>() {
@Override @Override
public void onValueChange(ValueChangeEvent<DataType> event) { public void onValueChange(ValueChangeEvent<DataType> event) {
} }
}); });
@ -451,7 +435,6 @@ public class InputOutputVariablesPanel extends ContentPanel {
} }
}); });
} }
private void addHandlersForComboIOType(LabelProvider<IOType> labelProvider) { private void addHandlersForComboIOType(LabelProvider<IOType> labelProvider) {
@ -505,7 +488,7 @@ public class InputOutputVariablesPanel extends ContentPanel {
storeComboDataType.add(DataType.FILE); storeComboDataType.add(DataType.FILE);
storeComboDataType.commitChanges(); storeComboDataType.commitChanges();
comboDataType.clear(); comboDataType.clear();
comboDataType.setValue(DataType.FILE,true,true); comboDataType.setValue(DataType.FILE, true, true);
} }
private void setComboForInputParameter() { private void setComboForInputParameter() {
@ -514,8 +497,7 @@ public class InputOutputVariablesPanel extends ContentPanel {
storeComboDataType.commitChanges(); storeComboDataType.commitChanges();
} }
public void addNewInputOutputVariables( public void addNewInputOutputVariables(InputOutputVariables inputOutputVariable) {
InputOutputVariables inputOutputVariable) {
try { try {
Log.debug("Current Seq: " + seq); Log.debug("Current Seq: " + seq);
seq++; seq++;
@ -539,16 +521,14 @@ public class InputOutputVariablesPanel extends ContentPanel {
try { try {
Log.debug("Current Seq: " + seq); Log.debug("Current Seq: " + seq);
seq++; seq++;
InputOutputVariables newInputOutputVariablesVariable = new InputOutputVariables( InputOutputVariables newInputOutputVariablesVariable = new InputOutputVariables(seq, "", "", "",
seq, "", "", "", DataType.STRING, IOType.INPUT, ""); DataType.STRING, IOType.INPUT, "");
Log.debug("New Input/Output Variable: " Log.debug("New Input/Output Variable: " + newInputOutputVariablesVariable);
+ newInputOutputVariablesVariable);
gridInputOutputVariablesEditing.cancelEditing(); gridInputOutputVariablesEditing.cancelEditing();
addStatus = true; addStatus = true;
gridInputOutputVariablesEditing.getCancelButton().setVisible(false); gridInputOutputVariablesEditing.getCancelButton().setVisible(false);
storeInputOutputVariables.add(newInputOutputVariablesVariable); storeInputOutputVariables.add(newInputOutputVariablesVariable);
int row = storeInputOutputVariables int row = storeInputOutputVariables.indexOf(newInputOutputVariablesVariable);
.indexOf(newInputOutputVariablesVariable);
storeComboDataType.clear(); storeComboDataType.clear();
storeComboDataType.addAll(DataType.asList()); storeComboDataType.addAll(DataType.asList());
@ -568,12 +548,10 @@ public class InputOutputVariablesPanel extends ContentPanel {
Log.debug("Update Input/Output Variables: " + project); Log.debug("Update Input/Output Variables: " + project);
if (project != null && project.getInputData() != null if (project != null && project.getInputData() != null
&& project.getInputData().getListInputOutputVariables() != null) { && project.getInputData().getListInputOutputVariables() != null) {
checkOutputParameterOnlyFileTypeIsSupported(project.getInputData() checkOutputParameterOnlyFileTypeIsSupported(project.getInputData().getListInputOutputVariables());
.getListInputOutputVariables());
storeInputOutputVariables.clear(); storeInputOutputVariables.clear();
storeInputOutputVariables.addAll(project.getInputData() storeInputOutputVariables.addAll(project.getInputData().getListInputOutputVariables());
.getListInputOutputVariables());
storeInputOutputVariables.commitChanges(); storeInputOutputVariables.commitChanges();
seq = project.getInputData().getListInputOutputVariables().size(); seq = project.getInputData().getListInputOutputVariables().size();
@ -585,13 +563,10 @@ public class InputOutputVariablesPanel extends ContentPanel {
} }
private void checkOutputParameterOnlyFileTypeIsSupported( private void checkOutputParameterOnlyFileTypeIsSupported(ArrayList<InputOutputVariables> inputOutputVarialbles) {
ArrayList<InputOutputVariables> inputOutputVarialbles) {
for (InputOutputVariables ioVariable : inputOutputVarialbles) { for (InputOutputVariables ioVariable : inputOutputVarialbles) {
if (ioVariable.getIoType() != null if (ioVariable.getIoType() != null && ioVariable.getIoType().compareTo(IOType.OUTPUT) == 0) {
&& ioVariable.getIoType().compareTo(IOType.OUTPUT) == 0) { if (ioVariable.getDataType() == null || ioVariable.getDataType().compareTo(DataType.FILE) != 0) {
if (ioVariable.getDataType() == null
|| ioVariable.getDataType().compareTo(DataType.FILE) != 0) {
ioVariable.setDataType(DataType.FILE); ioVariable.setDataType(DataType.FILE);
} }
} }

View File

@ -129,6 +129,8 @@ public class InputVariablePanel extends ContentPanel {
case MAIN_CODE_SET: case MAIN_CODE_SET:
setMainCode(event.getProject()); setMainCode(event.getProject());
break; break;
case BINARY_CODE_SET:
setBinaryCode(event.getProject());
default: default:
break; break;
} }
@ -167,4 +169,10 @@ public class InputVariablePanel extends ContentPanel {
} }
private void setBinaryCode(Project project) {
inputVariableTabPanel.setBinaryCode(project);
Log.debug("ToolBoxPanel Updated");
}
} }

View File

@ -90,6 +90,22 @@ public class InputVariableTabPanel extends TabPanel {
} }
public void setBinaryCode(Project project) {
try {
globalVariablesPanel.update(project);
inputOutputVariablesPanel.update(project);
projectInfoPanel.update(project);
interpreterInfoPanel.update(project);
forceLayout();
} catch (Throwable e) {
Log.error("Error in InputVariableTabPanel: "
+ e.getLocalizedMessage());
e.printStackTrace();
}
}
public void updateTabs(Project project) { public void updateTabs(Project project) {
try { try {
globalVariablesPanel.update(project); globalVariablesPanel.update(project);

View File

@ -7,16 +7,5 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.client.type;
* *
*/ */
public enum ProjectStatusEventType { public enum ProjectStatusEventType {
START, START, OPEN, MAIN_CODE_SET, BINARY_CODE_SET, UPDATE, ADD_RESOURCE, DELETE_RESOURCE, DELETE_MAIN_CODE, SOFTWARE_CREATED, SOFTWARE_PUBLISH, SOFTWARE_REPACKAGE, EXPLORER_REFRESH, SAVE;
OPEN,
MAIN_CODE_SET,
UPDATE,
ADD_RESOURCE,
DELETE_RESOURCE,
DELETE_MAIN_CODE,
SOFTWARE_CREATED,
SOFTWARE_PUBLISH,
SOFTWARE_REPACKAGE,
EXPLORER_REFRESH,
SAVE;
} }

View File

@ -9,6 +9,8 @@ import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Proj
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.ProjectSupportBlackBox; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.ProjectSupportBlackBox;
import com.allen_sauer.gwt.log.client.Log; import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.event.shared.EventBus; import com.google.gwt.event.shared.EventBus;
import com.sencha.gxt.core.client.util.Margins; import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.widget.core.client.container.BorderLayoutContainer; import com.sencha.gxt.widget.core.client.container.BorderLayoutContainer;
@ -133,11 +135,20 @@ public class WorkAreaPanel extends SimpleContainer {
} }
private void fireProjectStatusOpenEvent(Project project) { private void fireProjectStatusOpenEvent(final Project project) {
try { try {
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
ProjectStatusEvent projectStatusEvent = new ProjectStatusEvent(ProjectStatusEventType.OPEN, project); ProjectStatusEvent projectStatusEvent = new ProjectStatusEvent(ProjectStatusEventType.OPEN, project);
Log.debug("Work Area Panel ProjectStatusEvent fire! " + projectStatusEvent); Log.debug("Work Area Panel ProjectStatusEvent fire! " + projectStatusEvent);
eventBus.fireEvent(projectStatusEvent); eventBus.fireEvent(projectStatusEvent);
}
});
} catch (Throwable e) { } catch (Throwable e) {
Log.error(e.getLocalizedMessage(), e); Log.error(e.getLocalizedMessage(), e);
} }

View File

@ -46,11 +46,9 @@ import com.google.gwt.user.server.rpc.RemoteServiceServlet;
* The server side implementation of the RPC service. * The server side implementation of the RPC service.
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements StatAlgoImporterService {
StatAlgoImporterService {
private static Logger logger = LoggerFactory private static Logger logger = LoggerFactory.getLogger(StatAlgoImporterServiceImpl.class);
.getLogger(StatAlgoImporterServiceImpl.class);
/** /**
* *
@ -65,13 +63,11 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
System.out.println("initializing StatAlgoImporterService"); System.out.println("initializing StatAlgoImporterService");
String notificationRecipientsFile = "/statalgoimporter/properties/NotificationRecipients.txt"; String notificationRecipientsFile = "/statalgoimporter/properties/NotificationRecipients.txt";
InputStream notificationRecipientsInputStream = this InputStream notificationRecipientsInputStream = this.getServletContext()
.getServletContext().getResourceAsStream( .getResourceAsStream(notificationRecipientsFile);
notificationRecipientsFile);
String text = null; String text = null;
try { try {
text = IOUtils.toString(notificationRecipientsInputStream, text = IOUtils.toString(notificationRecipientsInputStream, StandardCharsets.UTF_8.name());
StandardCharsets.UTF_8.name());
} catch (IOException e) { } catch (IOException e) {
System.out.println(e.getLocalizedMessage()); System.out.println(e.getLocalizedMessage());
System.out.println(e.getStackTrace().toString()); System.out.println(e.getStackTrace().toString());
@ -104,14 +100,10 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
@Override @Override
public UserInfo hello() throws StatAlgoImporterServiceException { public UserInfo hello() throws StatAlgoImporterServiceException {
try { try {
ServiceCredentials serviceCredentials = SessionUtil ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
.getServiceCredentials(this.getThreadLocalRequest());
logger.debug("hello()"); logger.debug("hello()");
UserInfo userInfo = new UserInfo(serviceCredentials.getUserName(), UserInfo userInfo = new UserInfo(serviceCredentials.getUserName(), serviceCredentials.getGroupId(),
serviceCredentials.getGroupId(), serviceCredentials.getGroupName(), serviceCredentials.getScope(), serviceCredentials.getEmail(),
serviceCredentials.getGroupName(),
serviceCredentials.getScope(),
serviceCredentials.getEmail(),
serviceCredentials.getFullName()); serviceCredentials.getFullName());
logger.debug("UserInfo: " + userInfo); logger.debug("UserInfo: " + userInfo);
return userInfo; return userInfo;
@ -126,40 +118,34 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
} }
@Override @Override
public SAIDescriptor getSAIDescripor() throws StatAlgoImporterServiceException { public SAIDescriptor getSAIDescripor() throws StatAlgoImporterServiceException {
HttpServletRequest httpRequest = null; HttpServletRequest httpRequest = null;
try { try {
httpRequest = this.getThreadLocalRequest(); httpRequest = this.getThreadLocalRequest();
ServiceCredentials serviceCredentials = SessionUtil ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
.getServiceCredentials(httpRequest);
logger.debug("getSAIDescriptor()"); logger.debug("getSAIDescriptor()");
SAIDescriptor saiDescriptor=BuildSAIDescriptor.build(serviceCredentials.getScope()); SAIDescriptor saiDescriptor = BuildSAIDescriptor.build(serviceCredentials.getScope());
return saiDescriptor; return saiDescriptor;
} catch (StatAlgoImporterServiceException e) { } catch (StatAlgoImporterServiceException e) {
logger.error("Error retrieving SAI descriptor: "+e.getLocalizedMessage(),e); logger.error("Error retrieving SAI descriptor: " + e.getLocalizedMessage(), e);
throw e; throw e;
} catch (Throwable e) { } catch (Throwable e) {
logger.error("Error retrieving SAI descriptor: "+e.getLocalizedMessage(),e); logger.error("Error retrieving SAI descriptor: " + e.getLocalizedMessage(), e);
throw new StatAlgoImporterServiceException(e.getLocalizedMessage(),e); throw new StatAlgoImporterServiceException(e.getLocalizedMessage(), e);
} }
} }
@Override @Override
public Project restoreUISession(String value) public Project restoreUISession(String value) throws StatAlgoImporterServiceException {
throws StatAlgoImporterServiceException {
HttpServletRequest httpRequest = null; HttpServletRequest httpRequest = null;
try { try {
httpRequest = this.getThreadLocalRequest(); httpRequest = this.getThreadLocalRequest();
ServiceCredentials serviceCredentials = SessionUtil ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
.getServiceCredentials(httpRequest);
logger.debug("restoreUISession(): " + value); logger.debug("restoreUISession(): " + value);
Project project = SessionUtil.getProjectSession(httpRequest, Project project = SessionUtil.getProjectSession(httpRequest, serviceCredentials);
serviceCredentials);
return project; return project;
} catch (StatAlgoImporterServiceException e) { } catch (StatAlgoImporterServiceException e) {
e.printStackTrace(); e.printStackTrace();
@ -172,30 +158,25 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
} }
/** /**
* *
* {@inheritDoc} * {@inheritDoc}
* *
*/ */
@Override @Override
public FileUploadMonitor getFileUploadMonitor() public FileUploadMonitor getFileUploadMonitor() throws StatAlgoImporterServiceException {
throws StatAlgoImporterServiceException {
HttpServletRequest httpRequest = this.getThreadLocalRequest(); HttpServletRequest httpRequest = this.getThreadLocalRequest();
ServiceCredentials serviceCredentials = SessionUtil ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
.getServiceCredentials(httpRequest);
FileUploadMonitor fileUploadMonitor = null; FileUploadMonitor fileUploadMonitor = null;
try { try {
fileUploadMonitor = SessionUtil.getFileUploadMonitor(httpRequest, fileUploadMonitor = SessionUtil.getFileUploadMonitor(httpRequest, serviceCredentials);
serviceCredentials);
} catch (Exception e) { } catch (Exception e) {
logger.error("Error retrieving the fileUploadMonitor", e); logger.error("Error retrieving the fileUploadMonitor", e);
} }
if (fileUploadMonitor == null) { if (fileUploadMonitor == null) {
throw new StatAlgoImporterServiceException( throw new StatAlgoImporterServiceException("Error retrieving the fileUploadMonitor: null");
"Error retrieving the fileUploadMonitor: null");
} }
logger.debug("FileUploadMonitor: " + fileUploadMonitor); logger.debug("FileUploadMonitor: " + fileUploadMonitor);
@ -209,24 +190,19 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
* *
*/ */
@Override @Override
public ArrayList<CodeData> getCode() public ArrayList<CodeData> getCode() throws StatAlgoImporterServiceException {
throws StatAlgoImporterServiceException {
try { try {
HttpServletRequest httpRequest = this.getThreadLocalRequest(); HttpServletRequest httpRequest = this.getThreadLocalRequest();
ServiceCredentials serviceCredentials = SessionUtil ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
.getServiceCredentials(httpRequest);
logger.debug("getCode()"); logger.debug("getCode()");
Project projectSession = SessionUtil.getProjectSession(httpRequest, Project projectSession = SessionUtil.getProjectSession(httpRequest, serviceCredentials);
serviceCredentials);
if (projectSession != null) { if (projectSession != null) {
CodeReader codeFileReader = new CodeReader(projectSession, CodeReader codeFileReader = new CodeReader(projectSession, serviceCredentials);
serviceCredentials);
ArrayList<CodeData> codeList = codeFileReader.getCodeList(); ArrayList<CodeData> codeList = codeFileReader.getCodeList();
for (CodeData codeData : codeList) { for (CodeData codeData : codeList) {
logger.debug("" + codeData.getId() + " " logger.debug("" + codeData.getId() + " " + codeData.getCodeLine());
+ codeData.getCodeLine());
} }
return codeList; return codeList;
} else { } else {
@ -253,26 +229,24 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
throws StatAlgoImporterServiceException { throws StatAlgoImporterServiceException {
try { try {
HttpServletRequest httpRequest = this.getThreadLocalRequest(); HttpServletRequest httpRequest = this.getThreadLocalRequest();
ServiceCredentials serviceCredentials = SessionUtil ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
.getServiceCredentials(httpRequest);
logger.debug("createProjectOnWorkspace(): " + projectCreateSession); logger.debug("createProjectOnWorkspace(): " + projectCreateSession);
Project project; Project project;
if (ProjectArchiver.existProjectInFolder(projectCreateSession.getNewProjectFolder(), if (ProjectArchiver.existProjectInFolder(projectCreateSession.getNewProjectFolder(), serviceCredentials)) {
serviceCredentials)) {
throw new StatAlgoImporterServiceException( throw new StatAlgoImporterServiceException(
"Attention a project is present in this folder, use open or another folder!"); "Attention a project is present in this folder, use open or another folder!");
} else { } else {
ProjectFolder projectFolder = new ProjectFolder(projectCreateSession.getNewProjectFolder()); ProjectFolder projectFolder = new ProjectFolder(projectCreateSession.getNewProjectFolder());
ProjectConfig projectConfig=null; ProjectConfig projectConfig = null;
if (projectCreateSession.getProjectSetup() != null if (projectCreateSession.getProjectSetup() != null
&& projectCreateSession.getProjectSetup().getProjectSupportType() != null) { && projectCreateSession.getProjectSetup().getProjectSupportType() != null) {
switch(projectCreateSession.getProjectSetup().getProjectSupportType()){ switch (projectCreateSession.getProjectSetup().getProjectSupportType()) {
case BlackBox: case BlackBox:
projectConfig=new ProjectConfig(projectCreateSession.getProjectSetup().getLanguage(), projectConfig = new ProjectConfig(projectCreateSession.getProjectSetup().getLanguage(),
new ProjectSupportBlackBox()); new ProjectSupportBlackBox());
break; break;
case REdit: case REdit:
projectConfig=new ProjectConfig(projectCreateSession.getProjectSetup().getLanguage(), projectConfig = new ProjectConfig(projectCreateSession.getProjectSetup().getLanguage(),
new ProjectSupportREdit()); new ProjectSupportREdit());
break; break;
default: default:
@ -280,9 +254,8 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
} }
} }
project = new Project(projectFolder,projectConfig); project = new Project(projectFolder, projectConfig);
SessionUtil.setProjectSession(httpRequest, serviceCredentials, SessionUtil.setProjectSession(httpRequest, serviceCredentials, project);
project);
} }
@ -292,34 +265,28 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
e.printStackTrace(); e.printStackTrace();
throw e; throw e;
} catch (Throwable e) { } catch (Throwable e) {
logger.error( logger.error("createProjectOnWorkspace(): " + e.getLocalizedMessage(), e);
"createProjectOnWorkspace(): " + e.getLocalizedMessage(), e);
e.printStackTrace(); e.printStackTrace();
throw new StatAlgoImporterServiceException(e.getLocalizedMessage()); throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
} }
} }
@Override @Override
public Project openProjectOnWorkspace(ItemDescription newProjectFolder) public Project openProjectOnWorkspace(ItemDescription newProjectFolder) throws StatAlgoImporterServiceException {
throws StatAlgoImporterServiceException {
try { try {
HttpServletRequest httpRequest = this.getThreadLocalRequest(); HttpServletRequest httpRequest = this.getThreadLocalRequest();
ServiceCredentials serviceCredentials = SessionUtil ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
.getServiceCredentials(httpRequest);
logger.debug("openProjectOnWorkspace()"); logger.debug("openProjectOnWorkspace()");
Project project = ProjectArchiver.readProject(newProjectFolder, Project project = ProjectArchiver.readProject(newProjectFolder, serviceCredentials);
serviceCredentials); SessionUtil.setProjectSession(httpRequest, serviceCredentials, project);
SessionUtil.setProjectSession(httpRequest, serviceCredentials,
project);
return project; return project;
} catch (StatAlgoImporterServiceException e) { } catch (StatAlgoImporterServiceException e) {
e.printStackTrace(); e.printStackTrace();
throw e; throw e;
} catch (Throwable e) { } catch (Throwable e) {
logger.error( logger.error("openProjectOnWorkspace(): " + e.getLocalizedMessage(), e);
"openProjectOnWorkspace(): " + e.getLocalizedMessage(), e);
e.printStackTrace(); e.printStackTrace();
throw new StatAlgoImporterServiceException(e.getLocalizedMessage()); throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
} }
@ -327,24 +294,19 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
} }
@Override @Override
public Project setMainCode(ItemDescription itemDescription) public Project setMainCode(ItemDescription itemDescription) throws StatAlgoImporterServiceException {
throws StatAlgoImporterServiceException {
try { try {
HttpServletRequest httpRequest = this.getThreadLocalRequest(); HttpServletRequest httpRequest = this.getThreadLocalRequest();
ServiceCredentials serviceCredentials = SessionUtil ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
.getServiceCredentials(httpRequest);
logger.debug("SetMainCode(): " + itemDescription); logger.debug("SetMainCode(): " + itemDescription);
Project project = SessionUtil.getProjectSession(httpRequest, Project project = SessionUtil.getProjectSession(httpRequest, serviceCredentials);
serviceCredentials);
if (project != null) { if (project != null) {
project.setMainCode(new MainCode(itemDescription)); project.setMainCode(new MainCode(itemDescription));
project.setInputData(null); project.setInputData(null);
project.setProjectTarget(null); project.setProjectTarget(null);
WPS4RParser wps4Parser = new WPS4RParser(project, WPS4RParser wps4Parser = new WPS4RParser(project, serviceCredentials);
serviceCredentials);
project = wps4Parser.parse(); project = wps4Parser.parse();
SessionUtil.setProjectSession(httpRequest, serviceCredentials, SessionUtil.setProjectSession(httpRequest, serviceCredentials, project);
project);
logger.debug("Project: " + project); logger.debug("Project: " + project);
} else { } else {
throw new StatAlgoImporterServiceException("No project open!"); throw new StatAlgoImporterServiceException("No project open!");
@ -363,27 +325,57 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
} }
@Override @Override
public void addResourceToProject(ItemDescription itemDescription) public Project setBinaryCode(ItemDescription itemDescription) throws StatAlgoImporterServiceException {
throws StatAlgoImporterServiceException {
try { try {
HttpServletRequest httpRequest = this.getThreadLocalRequest(); HttpServletRequest httpRequest = this.getThreadLocalRequest();
ServiceCredentials serviceCredentials = SessionUtil ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
.getServiceCredentials(httpRequest); logger.debug("SetBinaryCode(): " + itemDescription);
Project project = SessionUtil.getProjectSession(httpRequest, serviceCredentials);
if (project != null && project.getProjectConfig() != null) {
ProjectSupportBlackBox projectSupportBlackBox;
if (project.getProjectConfig().getProjectSupport() != null
&& project.getProjectConfig().getProjectSupport() instanceof ProjectSupportBlackBox) {
projectSupportBlackBox = (ProjectSupportBlackBox) project.getProjectConfig().getProjectSupport();
projectSupportBlackBox.setBinaryItem(itemDescription);
SessionUtil.setProjectSession(httpRequest, serviceCredentials, project);
logger.debug("Project: " + project);
} else {
throw new StatAlgoImporterServiceException("Error in project setup!");
}
} else {
throw new StatAlgoImporterServiceException("No project open!");
}
return project;
} catch (StatAlgoImporterServiceException e) {
e.printStackTrace();
throw e;
} catch (Throwable e) {
logger.error("setBinaryCode(): " + e.getLocalizedMessage(), e);
e.printStackTrace();
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
}
}
@Override
public void addResourceToProject(ItemDescription itemDescription) throws StatAlgoImporterServiceException {
try {
HttpServletRequest httpRequest = this.getThreadLocalRequest();
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
logger.debug("addResourceToProject(): " + itemDescription); logger.debug("addResourceToProject(): " + itemDescription);
if (itemDescription == null || itemDescription.getId() == null) { if (itemDescription == null || itemDescription.getId() == null) {
throw new StatAlgoImporterServiceException( throw new StatAlgoImporterServiceException(
"Add resource to project is failed, invalid resource: " "Add resource to project is failed, invalid resource: " + itemDescription);
+ itemDescription);
} }
Project project = SessionUtil.getProjectSession(httpRequest, Project project = SessionUtil.getProjectSession(httpRequest, serviceCredentials);
serviceCredentials);
if (project != null && project.getProjectFolder() != null if (project != null && project.getProjectFolder() != null
&& project.getProjectFolder().getFolder() != null) { && project.getProjectFolder().getFolder() != null) {
FilesStorage fileStorage = new FilesStorage(); FilesStorage fileStorage = new FilesStorage();
fileStorage.copyItemOnFolder(serviceCredentials.getUserName(), fileStorage.copyItemOnFolder(serviceCredentials.getUserName(), itemDescription.getId(),
itemDescription.getId(), project.getProjectFolder() project.getProjectFolder().getFolder().getId());
.getFolder().getId());
} else { } else {
throw new StatAlgoImporterServiceException("No project open!"); throw new StatAlgoImporterServiceException("No project open!");
} }
@ -393,8 +385,7 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
e.printStackTrace(); e.printStackTrace();
throw e; throw e;
} catch (Throwable e) { } catch (Throwable e) {
logger.error("addResourceToProject(): " + e.getLocalizedMessage(), logger.error("addResourceToProject(): " + e.getLocalizedMessage(), e);
e);
e.printStackTrace(); e.printStackTrace();
throw new StatAlgoImporterServiceException(e.getLocalizedMessage()); throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
} }
@ -402,109 +393,76 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
} }
@Override @Override
public Project deleteResourceOnProject(ItemDescription itemDescription) public Project deleteResourceOnProject(ItemDescription itemDescription) throws StatAlgoImporterServiceException {
throws StatAlgoImporterServiceException {
try { try {
HttpServletRequest httpRequest = this.getThreadLocalRequest(); HttpServletRequest httpRequest = this.getThreadLocalRequest();
ServiceCredentials serviceCredentials = SessionUtil ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
.getServiceCredentials(httpRequest);
logger.debug("deleteResourceOnProject(): " + itemDescription); logger.debug("deleteResourceOnProject(): " + itemDescription);
if (itemDescription == null || itemDescription.getId() == null) { if (itemDescription == null || itemDescription.getId() == null) {
throw new StatAlgoImporterServiceException( throw new StatAlgoImporterServiceException(
"Delete resource on project is failed, invalid resource: " "Delete resource on project is failed, invalid resource: " + itemDescription);
+ itemDescription);
} }
Project project = SessionUtil.getProjectSession(httpRequest, Project project = SessionUtil.getProjectSession(httpRequest, serviceCredentials);
serviceCredentials); checkProjectInfoForDelete(itemDescription, httpRequest, serviceCredentials, project);
checkProjectInfoForDelete(itemDescription, httpRequest,
serviceCredentials, project);
FilesStorage fileStorage = new FilesStorage(); FilesStorage fileStorage = new FilesStorage();
fileStorage.deleteItemOnFolder(serviceCredentials.getUserName(), fileStorage.deleteItemOnFolder(serviceCredentials.getUserName(), itemDescription.getId());
itemDescription.getId());
return project; return project;
} catch (StatAlgoImporterServiceException e) { } catch (StatAlgoImporterServiceException e) {
e.printStackTrace(); e.printStackTrace();
throw e; throw e;
} catch (Throwable e) { } catch (Throwable e) {
logger.error( logger.error("deleteResourceOnProject(): " + e.getLocalizedMessage(), e);
"deleteResourceOnProject(): " + e.getLocalizedMessage(), e);
e.printStackTrace(); e.printStackTrace();
throw new StatAlgoImporterServiceException(e.getLocalizedMessage()); throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
} }
} }
private void checkProjectInfoForDelete(ItemDescription itemDescription, private void checkProjectInfoForDelete(ItemDescription itemDescription, HttpServletRequest httpRequest,
HttpServletRequest httpRequest,
ServiceCredentials serviceCredentials, Project project) ServiceCredentials serviceCredentials, Project project)
throws StatAlgoImporterSessionExpiredException, throws StatAlgoImporterSessionExpiredException, StatAlgoImporterServiceException {
StatAlgoImporterServiceException {
if (project != null) { if (project != null) {
if (project.getMainCode() != null if (project.getMainCode() != null && project.getMainCode().getItemDescription() != null
&& project.getMainCode().getItemDescription() != null && project.getMainCode().getItemDescription().getId().compareTo(itemDescription.getId()) == 0) {
&& project.getMainCode().getItemDescription().getId()
.compareTo(itemDescription.getId()) == 0) {
project.setMainCode(null); project.setMainCode(null);
project.setInputData(null); project.setInputData(null);
project.setProjectTarget(null); project.setProjectTarget(null);
SessionUtil.setProjectSession(httpRequest, serviceCredentials, SessionUtil.setProjectSession(httpRequest, serviceCredentials, project);
project);
ProjectArchiver.archive(project, serviceCredentials); ProjectArchiver.archive(project, serviceCredentials);
} else { } else {
if (project.getProjectTarget() != null if (project.getProjectTarget() != null && project.getProjectTarget().getFolder() != null
&& project.getProjectTarget().getFolder() != null && project.getProjectTarget().getFolder().getId().compareTo(itemDescription.getId()) == 0) {
&& project.getProjectTarget().getFolder().getId()
.compareTo(itemDescription.getId()) == 0) {
project.setProjectTarget(null); project.setProjectTarget(null);
SessionUtil.setProjectSession(httpRequest, SessionUtil.setProjectSession(httpRequest, serviceCredentials, project);
serviceCredentials, project);
ProjectArchiver.archive(project, serviceCredentials); ProjectArchiver.archive(project, serviceCredentials);
} else { } else {
if (project.getProjectTarget() != null if (project.getProjectTarget() != null && project.getProjectTarget().getProjectCompile() != null
&& project.getProjectTarget().getProjectCompile() != null && project.getProjectTarget().getProjectCompile().getFolder() != null
&& project.getProjectTarget().getProjectCompile() && project.getProjectTarget().getProjectCompile().getFolder().getId()
.getFolder() != null
&& project.getProjectTarget().getProjectCompile()
.getFolder().getId()
.compareTo(itemDescription.getId()) == 0) { .compareTo(itemDescription.getId()) == 0) {
project.getProjectTarget().setProjectCompile(null); project.getProjectTarget().setProjectCompile(null);
SessionUtil.setProjectSession(httpRequest, SessionUtil.setProjectSession(httpRequest, serviceCredentials, project);
serviceCredentials, project); ProjectArchiver.archive(project, serviceCredentials);
} else {
if (project.getProjectTarget() != null && project.getProjectTarget().getProjectDeploy() != null
&& project.getProjectTarget().getProjectDeploy().getFolder() != null
&& project.getProjectTarget().getProjectDeploy().getFolder().getId()
.compareTo(itemDescription.getId()) == 0) {
project.getProjectTarget().setProjectDeploy(null);
SessionUtil.setProjectSession(httpRequest, serviceCredentials, project);
ProjectArchiver.archive(project, serviceCredentials); ProjectArchiver.archive(project, serviceCredentials);
} else { } else {
if (project.getProjectTarget() != null if (project.getProjectTarget() != null
&& project.getProjectTarget() && project.getProjectTarget().getProjectDeploy() != null
.getProjectDeploy() != null && project.getProjectTarget().getProjectDeploy().getPackageProject() != null
&& project.getProjectTarget() && project.getProjectTarget().getProjectDeploy().getPackageProject().getId()
.getProjectDeploy().getFolder() != null
&& project.getProjectTarget()
.getProjectDeploy().getFolder().getId()
.compareTo(itemDescription.getId()) == 0) { .compareTo(itemDescription.getId()) == 0) {
project.getProjectTarget().setProjectDeploy(null); project.getProjectTarget().getProjectDeploy().setPackageProject(null);
SessionUtil.setProjectSession(httpRequest, SessionUtil.setProjectSession(httpRequest, serviceCredentials, project);
serviceCredentials, project); ProjectArchiver.archive(project, serviceCredentials);
ProjectArchiver
.archive(project, serviceCredentials);
} else {
if (project.getProjectTarget() != null
&& project.getProjectTarget()
.getProjectDeploy() != null
&& project.getProjectTarget()
.getProjectDeploy()
.getPackageProject() != null
&& project.getProjectTarget()
.getProjectDeploy()
.getPackageProject().getId()
.compareTo(itemDescription.getId()) == 0) {
project.getProjectTarget().getProjectDeploy()
.setPackageProject(null);
SessionUtil.setProjectSession(httpRequest,
serviceCredentials, project);
ProjectArchiver.archive(project,
serviceCredentials);
} else { } else {
} }
@ -518,20 +476,16 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
} }
@Override @Override
public void saveProject(InputData inputData) public void saveProject(InputData inputData) throws StatAlgoImporterServiceException {
throws StatAlgoImporterServiceException {
try { try {
HttpServletRequest httpRequest = this.getThreadLocalRequest(); HttpServletRequest httpRequest = this.getThreadLocalRequest();
ServiceCredentials serviceCredentials = SessionUtil ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
.getServiceCredentials(httpRequest);
logger.debug("saveProject():" + inputData); logger.debug("saveProject():" + inputData);
Project project = SessionUtil.getProjectSession(httpRequest, Project project = SessionUtil.getProjectSession(httpRequest, serviceCredentials);
serviceCredentials);
if (project != null) { if (project != null) {
project.setInputData(inputData); project.setInputData(inputData);
SessionUtil.setProjectSession(httpRequest, serviceCredentials, SessionUtil.setProjectSession(httpRequest, serviceCredentials, project);
project);
ProjectArchiver.archive(project, serviceCredentials); ProjectArchiver.archive(project, serviceCredentials);
} else { } else {
throw new StatAlgoImporterServiceException("No project open!"); throw new StatAlgoImporterServiceException("No project open!");
@ -553,21 +507,17 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
public void saveCode(String code) throws StatAlgoImporterServiceException { public void saveCode(String code) throws StatAlgoImporterServiceException {
try { try {
HttpServletRequest httpRequest = this.getThreadLocalRequest(); HttpServletRequest httpRequest = this.getThreadLocalRequest();
ServiceCredentials serviceCredentials = SessionUtil ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
.getServiceCredentials(httpRequest);
logger.debug("saveCode():" + code); logger.debug("saveCode():" + code);
Project project = SessionUtil.getProjectSession(httpRequest, Project project = SessionUtil.getProjectSession(httpRequest, serviceCredentials);
serviceCredentials);
if (project != null) { if (project != null) {
MainCode mainCode = project.getMainCode(); MainCode mainCode = project.getMainCode();
if (mainCode == null || mainCode.getItemDescription() == null) { if (mainCode == null || mainCode.getItemDescription() == null) {
throw new StatAlgoImporterServiceException( throw new StatAlgoImporterServiceException("No main code set!");
"No main code set!");
} else { } else {
MainCodeSave mainCodeSave = new MainCodeSave(); MainCodeSave mainCodeSave = new MainCodeSave();
mainCodeSave.save(serviceCredentials, mainCodeSave.save(serviceCredentials, mainCode.getItemDescription(), code, project);
mainCode.getItemDescription(), code, project);
} }
} else { } else {
throw new StatAlgoImporterServiceException("No project open!"); throw new StatAlgoImporterServiceException("No project open!");
@ -590,26 +540,21 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
throws StatAlgoImporterServiceException { throws StatAlgoImporterServiceException {
try { try {
HttpServletRequest httpRequest = this.getThreadLocalRequest(); HttpServletRequest httpRequest = this.getThreadLocalRequest();
ServiceCredentials serviceCredentials = SessionUtil ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
.getServiceCredentials(httpRequest); logger.debug("saveCode(): itemDescription" + fileDescription + ", code:" + code);
logger.debug("saveCode(): itemDescription" + fileDescription Project project = SessionUtil.getProjectSession(httpRequest, serviceCredentials);
+ ", code:" + code);
Project project = SessionUtil.getProjectSession(httpRequest,
serviceCredentials);
if (project != null && project.getProjectFolder() != null if (project != null && project.getProjectFolder() != null
&& project.getProjectFolder().getFolder() != null) { && project.getProjectFolder().getFolder() != null) {
MainCodeSave mainCodeSave = new MainCodeSave(); MainCodeSave mainCodeSave = new MainCodeSave();
ItemDescription mainCodeItemDescription = mainCodeSave.saveNew( ItemDescription mainCodeItemDescription = mainCodeSave.saveNew(serviceCredentials, fileDescription,
serviceCredentials, fileDescription, code, project); code, project);
MainCode mainCode = new MainCode(mainCodeItemDescription); MainCode mainCode = new MainCode(mainCodeItemDescription);
project.setMainCode(mainCode); project.setMainCode(mainCode);
project.setInputData(null); project.setInputData(null);
project.setProjectTarget(null); project.setProjectTarget(null);
WPS4RParser wps4Parser = new WPS4RParser(project, WPS4RParser wps4Parser = new WPS4RParser(project, serviceCredentials);
serviceCredentials);
project = wps4Parser.parse(); project = wps4Parser.parse();
SessionUtil.setProjectSession(httpRequest, serviceCredentials, SessionUtil.setProjectSession(httpRequest, serviceCredentials, project);
project);
return project; return project;
} else { } else {
throw new StatAlgoImporterServiceException("No project open!"); throw new StatAlgoImporterServiceException("No project open!");
@ -627,24 +572,18 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
} }
@Override @Override
public void createSoftware(InputData inputData) public void createSoftware(InputData inputData) throws StatAlgoImporterServiceException {
throws StatAlgoImporterServiceException {
try { try {
HttpServletRequest httpRequest = this.getThreadLocalRequest(); HttpServletRequest httpRequest = this.getThreadLocalRequest();
ServiceCredentials serviceCredentials = SessionUtil ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
.getServiceCredentials(httpRequest);
logger.debug("createSoftware(): " + inputData); logger.debug("createSoftware(): " + inputData);
Project project = SessionUtil.getProjectSession(httpRequest, Project project = SessionUtil.getProjectSession(httpRequest, serviceCredentials);
serviceCredentials);
if (project != null) { if (project != null) {
project.setInputData(inputData); project.setInputData(inputData);
SessionUtil.setProjectSession(httpRequest, serviceCredentials, SessionUtil.setProjectSession(httpRequest, serviceCredentials, project);
project); ProjectBuilder projectBuilder = new ProjectBuilder(project, serviceCredentials);
ProjectBuilder projectBuilder = new ProjectBuilder(project,
serviceCredentials);
project = projectBuilder.buildTarget(); project = projectBuilder.buildTarget();
SessionUtil.setProjectSession(httpRequest, serviceCredentials, SessionUtil.setProjectSession(httpRequest, serviceCredentials, project);
project);
ProjectArchiver.archive(project, serviceCredentials); ProjectArchiver.archive(project, serviceCredentials);
} else { } else {
throw new StatAlgoImporterServiceException("No project open!"); throw new StatAlgoImporterServiceException("No project open!");
@ -663,16 +602,13 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
} }
@Override @Override
public String getPublicLink(ItemDescription itemDescription) public String getPublicLink(ItemDescription itemDescription) throws StatAlgoImporterServiceException {
throws StatAlgoImporterServiceException {
try { try {
HttpServletRequest httpRequest = this.getThreadLocalRequest(); HttpServletRequest httpRequest = this.getThreadLocalRequest();
ServiceCredentials serviceCredentials = SessionUtil ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
.getServiceCredentials(httpRequest);
logger.debug("GetPublicLink(): " + itemDescription); logger.debug("GetPublicLink(): " + itemDescription);
FilesStorage filesStorage = new FilesStorage(); FilesStorage filesStorage = new FilesStorage();
String link = filesStorage.getPublicLink( String link = filesStorage.getPublicLink(serviceCredentials.getUserName(), itemDescription.getId());
serviceCredentials.getUserName(), itemDescription.getId());
return link; return link;
} catch (StatAlgoImporterServiceException e) { } catch (StatAlgoImporterServiceException e) {
@ -689,21 +625,17 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
public void publishSoftware() throws StatAlgoImporterServiceException { public void publishSoftware() throws StatAlgoImporterServiceException {
try { try {
HttpServletRequest httpRequest = this.getThreadLocalRequest(); HttpServletRequest httpRequest = this.getThreadLocalRequest();
ServiceCredentials serviceCredentials = SessionUtil ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
.getServiceCredentials(httpRequest);
logger.debug("PublishSoftware()"); logger.debug("PublishSoftware()");
ArrayList<Recipient> recipients = SessionUtil ArrayList<Recipient> recipients = SessionUtil.getRecipients(httpRequest.getServletContext());
.getRecipients(httpRequest.getServletContext());
Project project = SessionUtil.getProjectSession(httpRequest, serviceCredentials); Project project = SessionUtil.getProjectSession(httpRequest, serviceCredentials);
if (project != null) { if (project != null) {
ProjectBuilder projectBuilder = new ProjectBuilder(project, ProjectBuilder projectBuilder = new ProjectBuilder(project, serviceCredentials);
serviceCredentials);
project = projectBuilder.buildDeploy(); project = projectBuilder.buildDeploy();
SessionUtil.setProjectSession(httpRequest, serviceCredentials, project); SessionUtil.setProjectSession(httpRequest, serviceCredentials, project);
ProjectArchiver.archive(project, serviceCredentials); ProjectArchiver.archive(project, serviceCredentials);
AlgorithmNotification notify = new AlgorithmNotification( AlgorithmNotification notify = new AlgorithmNotification(this.getThreadLocalRequest(),
this.getThreadLocalRequest(), serviceCredentials, serviceCredentials, project, recipients);
project, recipients);
notify.run(); notify.run();
} else { } else {
throw new StatAlgoImporterServiceException( throw new StatAlgoImporterServiceException(
@ -726,19 +658,16 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
public void repackageSoftware() throws StatAlgoImporterServiceException { public void repackageSoftware() throws StatAlgoImporterServiceException {
try { try {
HttpServletRequest httpRequest = this.getThreadLocalRequest(); HttpServletRequest httpRequest = this.getThreadLocalRequest();
ServiceCredentials serviceCredentials = SessionUtil ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
.getServiceCredentials(httpRequest);
logger.debug("RepackageSoftware()"); logger.debug("RepackageSoftware()");
Project project = SessionUtil.getProjectSession(httpRequest, serviceCredentials); Project project = SessionUtil.getProjectSession(httpRequest, serviceCredentials);
if (project != null) { if (project != null) {
ProjectBuilder projectBuilder = new ProjectBuilder(project, ProjectBuilder projectBuilder = new ProjectBuilder(project, serviceCredentials);
serviceCredentials);
project = projectBuilder.buildRepackage(); project = projectBuilder.buildRepackage();
SessionUtil.setProjectSession(httpRequest, serviceCredentials, project); SessionUtil.setProjectSession(httpRequest, serviceCredentials, project);
ProjectArchiver.archive(project, serviceCredentials); ProjectArchiver.archive(project, serviceCredentials);
} else { } else {
throw new StatAlgoImporterServiceException( throw new StatAlgoImporterServiceException("The script was not packaged correctly!");
"The script was not packaged correctly!");
} }
return; return;
@ -753,6 +682,4 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
} }
} }

View File

@ -0,0 +1,187 @@
package org.gcube.portlets.user.statisticalalgorithmsimporter.server.blackbox;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class GeneralPurposeScriptProducer {
private static final Logger logger = LoggerFactory.getLogger(GeneralPurposeScriptProducer.class);
public static final String REMOTE_TEMPLATE_FILE = "http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-analysis/RConfiguration/RD4SFunctions/SAITemplateForExternalInvocation.R";
public static final String PRE_INSTALLED = "Pre-Installed";
// name,type,default
public class Triple {
String a;
String b;
String c;
public Triple(String a, String b, String c) {
this.a = a;
this.b = b;
this.c = c;
}
}
public String URLReader(String urlToTemplate) throws Exception {
URL remoteFile = new URL(urlToTemplate);
BufferedReader in = new BufferedReader(new InputStreamReader(remoteFile.openStream()));
StringBuffer sb = new StringBuffer();
String inputLine = null;
while ((inputLine = in.readLine()) != null)
sb.append(inputLine + System.lineSeparator());
in.close();
return sb.toString();
}
public Path generateScript(List<Triple> input, List<Triple> output, String mainSoftware, String softwareType)
throws Exception {
return generateScript(input, output, mainSoftware, softwareType, null);
}
public Path generateScript(List<Triple> input, List<Triple> output, String mainSoftware, String softwareType,
String URLtoSoftware) throws Exception {
String mainSoftwareName = mainSoftware;
if (softwareType.equals(PRE_INSTALLED)) {
mainSoftwareName = URLReader(URLtoSoftware);
}
String inputDeclaration = generateInputStrings(input, softwareType, mainSoftwareName);
String processInvocation = generateExternalProcessInvokation(mainSoftwareName, input);
String outputDeclaration = generateOutputStrings(output);
String fileExistenceChecks = generateFileExistenceCheck(output);
String script = URLReader(REMOTE_TEMPLATE_FILE);
script = script.replace("#INPUT_DECLARATION#", inputDeclaration);
script = script.replace("#PROCESS_COMPOSITION#", processInvocation);
script = script.replace("#OUTPUT_DECLARATION#", outputDeclaration);
script = script.replace("#CHECKS#", fileExistenceChecks);
// File outputFile = new File ("SAIExternalInvocationScript.R");
// FileWriter fw = new FileWriter(outputFile);
// fw.write(script);
// fw.close();
Path tempFile = Files.createTempFile("SAIExternalInvocationScript", ".R");
Files.write(tempFile, script.getBytes(), StandardOpenOption.WRITE);
logger.debug("Created output file: " + tempFile.toFile().getAbsolutePath());
return tempFile;
}
private String generateExternalProcessInvokation(String mainSoftware, List<Triple> input) {
StringBuffer sb = new StringBuffer();
sb.append("external_process_to_invoke<-'" + mainSoftware
+ "' #can be a python, fortran, linux-compiled, octave, java process" + System.lineSeparator());
sb.append("#prepare the command to invoke" + System.lineSeparator());
sb.append("command = paste(external_process_to_invoke");
for (Triple in : input) {
sb.append("," + in.a);
}
sb.append(",sep=\" \")" + System.lineSeparator());
sb.append("cat('Command:',command,'\\n')" + System.lineSeparator() + System.lineSeparator());
return sb.toString();
}
private String generateFileExistenceCheck(List<Triple> output) {
StringBuffer sb = new StringBuffer();
sb.append("#check if the output exists before exiting" + System.lineSeparator());
for (Triple o : output) {
sb.append("fexists = file.exists(paste(" + o.a + ",sep=''))" + System.lineSeparator());
sb.append("cat(\"file " + o.a + " exists?\",fexists,\"\\n\")" + System.lineSeparator());
sb.append("if (!fexists){" + System.lineSeparator());
sb.append("\tcat(fexists,\"Error, the output " + o.a + "(" + o.b + ")" + " does not exist!\\n\")"
+ System.lineSeparator());
sb.append("\tstoptheprocess" + System.lineSeparator());
sb.append("}" + System.lineSeparator() + System.lineSeparator());
}
return sb.toString();
}
private String generateInputStrings(List<Triple> input, String softwareType, String mainSoftware) {
StringBuffer sb = new StringBuffer();
sb.append(System.lineSeparator() + "#parameters of the process to invoke" + System.lineSeparator());
sb.append("false<-F" + System.lineSeparator());
sb.append("true<-T" + System.lineSeparator());
sb.append("softwaretype<-'" + softwareType + "'" + System.lineSeparator());
sb.append("softwareName<-'" + mainSoftware + "'" + System.lineSeparator());
String oinput = "overallInput<-'";
String oinputValues = "overallInputValues<-paste(";
String oinputTypes = "overallInputTypes<-'";
for (Triple in : input) {
String value = in.b;
if (in.c.equals("enumerated")) {
value = in.b.substring(0, in.b.indexOf("|"));
sb.append(in.a + "<-\"" + value + "\"" + System.lineSeparator());
} else
sb.append(in.a + "<-\"" + in.b + "\"" + System.lineSeparator());
oinput += in.a + "\t";
oinputValues += in.a + ",";
oinputTypes += in.c + "\t";
sb.append("cat('Input Parameter:" + in.a + "'," + in.a + ",'\\n'" + ")" + System.lineSeparator());
}
sb.append(oinput.trim() + "'" + System.lineSeparator());
sb.append(oinputValues.substring(0, oinputValues.length() - 1) + ",sep='\t')" + System.lineSeparator());
sb.append(oinputTypes.trim() + "'" + System.lineSeparator());
return sb.toString() + System.lineSeparator();
}
private String generateOutputStrings(List<Triple> output) {
StringBuffer sb = new StringBuffer();
sb.append(System.lineSeparator() + "#prepare the final output file" + System.lineSeparator());
sb.append(
"outputfolder <- getwd() #current working folder (a temporary folder is created at each run and set as working directory)"
+ System.lineSeparator());
for (Triple o : output) {
sb.append(o.a + "<-\"" + o.b + "\"" + System.lineSeparator());
sb.append("#fixed code to add some randomness to the output file name and save concurrent requests"
+ System.lineSeparator());
sb.append(o.a + "<-paste(" + o.a + ",'_',Sys.time(),sep='')" + System.lineSeparator());
sb.append(o.a + "<-gsub(' ', '_', " + o.a + ")" + System.lineSeparator());
sb.append(o.a + "<-gsub(':', '_', " + o.a + ")" + System.lineSeparator());
sb.append("file.rename('" + o.b + "'," + o.a + ")" + System.lineSeparator());
sb.append("cat('Output Parameter:" + o.a + "'," + o.a + ",'\\n'" + ")" + System.lineSeparator());
}
return sb.toString() + System.lineSeparator();
}
}

View File

@ -0,0 +1,144 @@
package org.gcube.portlets.user.statisticalalgorithmsimporter.server.blackbox;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.storage.FilesStorage;
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.util.ServiceCredentials;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterServiceException;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.InputOutputVariables;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.ProjectSupportBlackBox;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.workspace.ItemDescription;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class MainGenerator {
private static final Logger logger = LoggerFactory.getLogger(MainGenerator.class);
private static final String R_MIMETYPE = "text/plain";
private static final String R_DESCRIPTION="R script for ";
public void createMain(ServiceCredentials serviceCredentials,Project project) throws StatAlgoImporterServiceException {
logger.debug("Project: " + project);
if (project == null || project.getProjectConfig() == null
|| project.getProjectConfig().getProjectSupport() == null) {
String error = "Error invalid project support!";
logger.error(error);
throw new StatAlgoImporterServiceException(error);
}
ProjectSupportBlackBox projectSupportBlackBox;
if (!(project.getProjectConfig().getProjectSupport() instanceof ProjectSupportBlackBox)) {
String error = "Error invalid project support!";
logger.error(error);
throw new StatAlgoImporterServiceException(error);
} else {
projectSupportBlackBox = (ProjectSupportBlackBox) project.getProjectConfig().getProjectSupport();
}
try {
logger.debug("Language: " + project.getProjectConfig().getLanguage());
logger.debug("Binary software: " + projectSupportBlackBox.getBinaryItem());
GeneralPurposeScriptProducer s = new GeneralPurposeScriptProducer();
List<GeneralPurposeScriptProducer.Triple> input = new ArrayList<>();
List<GeneralPurposeScriptProducer.Triple> output = new ArrayList<>();
for (InputOutputVariables ioV : project.getInputData().getListInputOutputVariables()) {
switch (ioV.getIoType()) {
case INPUT:
input.add(s.new Triple(ioV.getName(), ioV.getDefaultValue(), ioV.getDataType().getId()));
break;
case OUTPUT:
output.add(s.new Triple(ioV.getName(), ioV.getDefaultValue(), ioV.getDataType().getId()));
break;
default:
break;
}
}
logger.debug("Inputs: " + Arrays.toString(input.toArray()));
logger.debug("Outputs: " + Arrays.toString(output.toArray()));
Path producedScript = null;
if (project.getProjectConfig().getLanguage().compareTo(GeneralPurposeScriptProducer.PRE_INSTALLED) == 0) {
producedScript = s.generateScript(input, output, projectSupportBlackBox.getBinaryItem().getName(),
project.getProjectConfig().getLanguage(),
projectSupportBlackBox.getBinaryItem().getPublicLink());
} else {
producedScript = s.generateScript(input, output, projectSupportBlackBox.getBinaryItem().getName(),
project.getProjectConfig().getLanguage());
}
if (producedScript == null || !Files.exists(producedScript)) {
String error = "Error creating script: file not exists!";
logger.error(error);
throw new StatAlgoImporterServiceException(error);
}
//////
FilesStorage filesStorage = new FilesStorage();
WorkspaceItem mainItem;
try {
mainItem = filesStorage.createItemOnWorkspace(
serviceCredentials.getUserName(),
Files.newInputStream(producedScript, StandardOpenOption.READ),
producedScript.getFileName().toString(), R_DESCRIPTION+project.getProjectConfig().getLanguage(),
R_MIMETYPE, project.getProjectFolder().getFolder().getId());
} catch (IOException e) {
logger.error(e.getLocalizedMessage());
e.printStackTrace();
throw new StatAlgoImporterServiceException(e.getLocalizedMessage(),
e);
}
ItemDescription mainItemDescription;
try {
mainItemDescription = new ItemDescription(mainItem.getId(),
mainItem.getName(), mainItem.getOwner().getPortalLogin(),
mainItem.getPath(), mainItem.getType().name());
mainItemDescription.setPublicLink(mainItem
.getPublicLink(false));
} catch (InternalErrorException e) {
logger.error(e.getLocalizedMessage());
e.printStackTrace();
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
}
project.getMainCode().setItemDescription(mainItemDescription);
logger.debug("MainCode: "
+ project.getMainCode().getItemDescription());
} catch (StatAlgoImporterServiceException e) {
throw e;
} catch (Throwable e) {
logger.error("Error gerating main code: " + e.getLocalizedMessage(), e);
throw new StatAlgoImporterServiceException("Error gerating main code: " + e.getLocalizedMessage(), e);
}
}
}

View File

@ -86,6 +86,7 @@ public class ProjectBuilder {
public Project buildTarget() throws StatAlgoImporterServiceException { public Project buildTarget() throws StatAlgoImporterServiceException {
checkInfoForBuild(); checkInfoForBuild();
createBackup(); createBackup();
createMainCodeIfRequest();
createTargetFolder(); createTargetFolder();
createDeployFolder(); createDeployFolder();
createProjectPackage(); createProjectPackage();
@ -128,6 +129,10 @@ public class ProjectBuilder {
createBackupOfPackageProject(); createBackupOfPackageProject();
} }
private void createMainCodeIfRequest() throws StatAlgoImporterServiceException {
//TODO
}
private void repackageProjectPackage() private void repackageProjectPackage()
throws StatAlgoImporterServiceException { throws StatAlgoImporterServiceException {
List<String> idsToExclude = new ArrayList<String>(); List<String> idsToExclude = new ArrayList<String>();

View File

@ -31,21 +31,17 @@ public class BuildSAIDescriptor {
availableProjectConfigurations.add(rBlackBox); availableProjectConfigurations.add(rBlackBox);
ProjectSetup java = new ProjectSetup("Java", ProjectSupportType.BlackBox); ProjectSetup java = new ProjectSetup("Java", ProjectSupportType.BlackBox);
availableProjectConfigurations.add(java); availableProjectConfigurations.add(java);
ProjectSetup knimeWorkflow = new ProjectSetup("Knime Workflow", ProjectSetup knimeWorkflow = new ProjectSetup("Knime Workflow", ProjectSupportType.BlackBox);
ProjectSupportType.BlackBox);
availableProjectConfigurations.add(knimeWorkflow); availableProjectConfigurations.add(knimeWorkflow);
ProjectSetup linuxCompiled = new ProjectSetup("Linux-compiled", ProjectSetup linuxCompiled = new ProjectSetup("Linux-compiled", ProjectSupportType.BlackBox);
ProjectSupportType.BlackBox);
availableProjectConfigurations.add(linuxCompiled); availableProjectConfigurations.add(linuxCompiled);
ProjectSetup octave = new ProjectSetup("Octave", ProjectSupportType.BlackBox); ProjectSetup octave = new ProjectSetup("Octave", ProjectSupportType.BlackBox);
availableProjectConfigurations.add(octave); availableProjectConfigurations.add(octave);
ProjectSetup python = new ProjectSetup("Python", ProjectSupportType.BlackBox); ProjectSetup python = new ProjectSetup("Python", ProjectSupportType.BlackBox);
availableProjectConfigurations.add(python); availableProjectConfigurations.add(python);
ProjectSetup windowsCompiled = new ProjectSetup("Windows-compiled", ProjectSetup windowsCompiled = new ProjectSetup("Windows-compiled", ProjectSupportType.BlackBox);
ProjectSupportType.BlackBox);
availableProjectConfigurations.add(windowsCompiled); availableProjectConfigurations.add(windowsCompiled);
ProjectSetup preInstalled = new ProjectSetup("Pre-Installed", ProjectSetup preInstalled = new ProjectSetup("Pre-Installed", ProjectSupportType.BlackBox);
ProjectSupportType.BlackBox);
availableProjectConfigurations.add(preInstalled); availableProjectConfigurations.add(preInstalled);
saiDescriptor = new SAIDescriptor(availableProjectConfigurations); saiDescriptor = new SAIDescriptor(availableProjectConfigurations);
} else { } else {
@ -74,28 +70,28 @@ public class BuildSAIDescriptor {
} }
} else { } else {
logger.info("SAIDescriptorJAXB use default configuration for scope: " + scope); logger.info("SAIDescriptorJAXB use default configuration for scope: " + scope);
ProjectSetup r = new ProjectSetup("R", ProjectSupportType.REdit); ProjectSetup r = new ProjectSetup("R", ProjectSupportType.REdit);
availableProjectConfigurations.add(r); availableProjectConfigurations.add(r);
ProjectSetup rBlackBox = new ProjectSetup("R-black box", ProjectSupportType.BlackBox); ProjectSetup rBlackBox = new ProjectSetup("R-black box", ProjectSupportType.BlackBox);
availableProjectConfigurations.add(rBlackBox); availableProjectConfigurations.add(rBlackBox);
ProjectSetup java = new ProjectSetup("Java", ProjectSupportType.BlackBox); ProjectSetup java = new ProjectSetup("Java", ProjectSupportType.BlackBox);
availableProjectConfigurations.add(java); availableProjectConfigurations.add(java);
ProjectSetup knimeWorkflow = new ProjectSetup("Knime Workflow", ProjectSetup knimeWorkflow = new ProjectSetup("Knime Workflow", ProjectSupportType.BlackBox);
ProjectSupportType.BlackBox);
availableProjectConfigurations.add(knimeWorkflow); availableProjectConfigurations.add(knimeWorkflow);
ProjectSetup linuxCompiled = new ProjectSetup("Linux-compiled", ProjectSetup linuxCompiled = new ProjectSetup("Linux-compiled", ProjectSupportType.BlackBox);
ProjectSupportType.BlackBox);
availableProjectConfigurations.add(linuxCompiled); availableProjectConfigurations.add(linuxCompiled);
ProjectSetup octave = new ProjectSetup("Octave", ProjectSupportType.BlackBox); ProjectSetup octave = new ProjectSetup("Octave", ProjectSupportType.BlackBox);
availableProjectConfigurations.add(octave); availableProjectConfigurations.add(octave);
ProjectSetup python = new ProjectSetup("Python", ProjectSupportType.BlackBox); ProjectSetup python = new ProjectSetup("Python", ProjectSupportType.BlackBox);
availableProjectConfigurations.add(python); availableProjectConfigurations.add(python);
ProjectSetup windowsCompiled = new ProjectSetup("Windows-compiled", ProjectSetup windowsCompiled = new ProjectSetup("Windows-compiled", ProjectSupportType.BlackBox);
ProjectSupportType.BlackBox);
availableProjectConfigurations.add(windowsCompiled); availableProjectConfigurations.add(windowsCompiled);
} }
saiDescriptor = new SAIDescriptor(availableProjectConfigurations); saiDescriptor = new SAIDescriptor(availableProjectConfigurations);
} }
logger.debug("SAIDescriptor: " + saiDescriptor); logger.debug("SAIDescriptor: " + saiDescriptor);

View File

@ -35,6 +35,9 @@ public class Constants {
public static final String SAI_NAME = "SAIProfile"; public static final String SAI_NAME = "SAIProfile";
public static final String SAI_CATEGORY = "SAI"; public static final String SAI_CATEGORY = "SAI";
// Main Generator
public static final String PRE_INSTALLED = "Pre-Installed";
public static final String REMOTE_TEMPLATE_FILE = "http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-analysis/RConfiguration/RD4SFunctions/SAITemplateForExternalInvocation.R";
} }

View File

@ -21,6 +21,7 @@ public class SAIDescriptor implements Serializable {
public SAIDescriptor(ArrayList<ProjectSetup> availableProjectConfigurations) { public SAIDescriptor(ArrayList<ProjectSetup> availableProjectConfigurations) {
super(); super();
this.availableProjectConfigurations = availableProjectConfigurations; this.availableProjectConfigurations = availableProjectConfigurations;
} }
public ArrayList<ProjectSetup> getAvailableProjectConfigurations() { public ArrayList<ProjectSetup> getAvailableProjectConfigurations() {

View File

@ -56,19 +56,19 @@
name="locale" values="es" /> <set-property name="locale" value="en, it, es" name="locale" values="es" /> <set-property name="locale" value="en, it, es"
/> <set-property-fallback name="locale" value="en" /> --> /> <set-property-fallback name="locale" value="en" /> -->
<!--
<set-property name="log_ConsoleLogger" value="ENABLED" /> <set-property <set-property name="log_ConsoleLogger" value="ENABLED" /> <set-property
name="log_DivLogger" value="ENABLED" /> <set-property name="log_GWTLogger" name="log_DivLogger" value="ENABLED" /> <set-property name="log_GWTLogger"
value="ENABLED" /> <set-property name="log_SystemLogger" value="ENABLED" value="ENABLED" /> <set-property name="log_SystemLogger" value="ENABLED"
/> /> -->
<!-- Not in GWT 2.6 <set-property name="log_FirebugLogger" 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_ConsoleLogger" value="DISABLED" />
<set-property name="log_DivLogger" value="DISABLED" /> <set-property name="log_DivLogger" value="DISABLED" />
<set-property name="log_GWTLogger" 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" <!-- Not in GWT 2.6 <set-property name="log_FirebugLogger" value="DISABLED"
/> --> /> -->