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:
parent
2e5a551a6a
commit
27640a0cff
|
@ -2,6 +2,7 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.client;
|
|||
|
||||
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.InputReadyEvent;
|
||||
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,
|
||||
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) {
|
||||
monitor = new StatAlgoImporterMonitor();
|
||||
pm.setNewMainCode(event, monitor);
|
||||
|
|
|
@ -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 + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -68,6 +68,7 @@ public class MainDataPanel extends SimpleContainer {
|
|||
case OPEN:
|
||||
addCodeEditPanel(event.getProject());
|
||||
break;
|
||||
case BINARY_CODE_SET:
|
||||
case SAVE:
|
||||
case START:
|
||||
case UPDATE:
|
||||
|
|
|
@ -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.Project;
|
||||
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.widgets.githubconnector.client.GitHubConnectorWizard;
|
||||
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) {
|
||||
if (project != null && project.getMainCode() != null && project.getMainCode().getItemDescription() != null
|
||||
&& itemDescription.getId().compareTo(project.getMainCode().getItemDescription().getId()) == 0) {
|
||||
|
@ -821,6 +861,12 @@ public class ProjectManager {
|
|||
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() {
|
||||
ProjectStatusEvent projectStatusEvent = new ProjectStatusEvent(ProjectStatusEventType.SOFTWARE_CREATED,
|
||||
project);
|
||||
|
@ -851,11 +897,12 @@ public class ProjectManager {
|
|||
|
||||
}
|
||||
|
||||
/*
|
||||
private void fireProjectStatusOpenEvent() {
|
||||
ProjectStatusEvent projectStatusEvent = new ProjectStatusEvent(ProjectStatusEventType.OPEN, project);
|
||||
Log.debug("Project Manager ProjectStatusEvent fire! " + projectStatusEvent);
|
||||
eventBus.fireEvent(projectStatusEvent);
|
||||
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
|
|
|
@ -58,6 +58,8 @@ public interface StatAlgoImporterService extends RemoteService {
|
|||
//
|
||||
public Project setMainCode(ItemDescription itemDescription) throws StatAlgoImporterServiceException;
|
||||
|
||||
public Project setBinaryCode(ItemDescription itemDescription) throws StatAlgoImporterServiceException;
|
||||
|
||||
public void addResourceToProject(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;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -38,7 +38,9 @@ public interface StatAlgoImporterServiceAsync {
|
|||
|
||||
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);
|
||||
|
||||
|
@ -64,4 +66,5 @@ public interface StatAlgoImporterServiceAsync {
|
|||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
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.MainCodeSetEvent;
|
||||
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.utils.UtilsGXT3;
|
||||
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.widgets.workspaceuploader.client.WorkspaceUploadNotification.WorskpaceUploadNotificationListener;
|
||||
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) {
|
||||
|
||||
switch (event.getProjectStatusEventType()) {
|
||||
case START:
|
||||
break;
|
||||
|
@ -115,6 +118,7 @@ public class ExplorerProjectPanel extends ContentPanel {
|
|||
break;
|
||||
case SAVE:
|
||||
case MAIN_CODE_SET:
|
||||
case BINARY_CODE_SET:
|
||||
case SOFTWARE_CREATED:
|
||||
case SOFTWARE_PUBLISH:
|
||||
case SOFTWARE_REPACKAGE:
|
||||
|
@ -201,19 +205,36 @@ public class ExplorerProjectPanel extends ContentPanel {
|
|||
dnd.addWorkspaceUploadNotificationListener(workspaceUploaderListener);
|
||||
|
||||
// ToolBar
|
||||
btnSetMain = new TextButton("Set Main");
|
||||
btnSetMain.setIcon(StatAlgoImporterResources.INSTANCE.add16());
|
||||
btnSetMain.setScale(ButtonScale.SMALL);
|
||||
btnSetMain.setIconAlign(IconAlign.LEFT);
|
||||
btnSetMain.setToolTip("Set main code");
|
||||
btnSetMain.addSelectHandler(new SelectHandler() {
|
||||
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) {
|
||||
setMainCode(event);
|
||||
}
|
||||
@Override
|
||||
public void onSelect(SelectEvent event) {
|
||||
setBinaryCode(event);
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
} else {
|
||||
|
||||
btnSetMain = new TextButton("Set Main");
|
||||
btnSetMain.setIcon(StatAlgoImporterResources.INSTANCE.add16());
|
||||
btnSetMain.setScale(ButtonScale.SMALL);
|
||||
btnSetMain.setIconAlign(IconAlign.LEFT);
|
||||
btnSetMain.setToolTip("Set main code");
|
||||
btnSetMain.addSelectHandler(new SelectHandler() {
|
||||
|
||||
@Override
|
||||
public void onSelect(SelectEvent event) {
|
||||
setMainCode(event);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
btnOpen = new TextButton("Open");
|
||||
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) {
|
||||
ItemDescription itemDescription = new ItemDescription(selectedItem.getId(), selectedItem.getName(),
|
||||
|
@ -300,7 +314,17 @@ public class ExplorerProjectPanel extends ContentPanel {
|
|||
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(),
|
||||
selectedItem.getOwner(), selectedItem.getPath(), selectedItem.getType().name());
|
||||
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() {
|
||||
if (selectedItem != null && !selectedItem.isFolder()) {
|
||||
|
||||
|
|
|
@ -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.InputOutputVariables;
|
||||
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.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.safehtml.shared.SafeHtml;
|
||||
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.core.client.Style.SelectionMode;
|
||||
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.button.ButtonBar;
|
||||
import com.sencha.gxt.widget.core.client.button.TextButton;
|
||||
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData;
|
||||
import com.sencha.gxt.widget.core.client.container.MarginData;
|
||||
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
|
||||
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
|
||||
|
@ -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.GridSelectionModel;
|
||||
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 ComboBox<IOType> comboIOType;
|
||||
private GridRowEditing<InputOutputVariables> gridInputOutputVariablesEditing;
|
||||
private TextButton btnAddVariable;
|
||||
private TextButton btnAdd;
|
||||
private boolean addStatus;
|
||||
private int seq = 0;
|
||||
|
@ -119,8 +125,7 @@ public class InputOutputVariablesPanel extends ContentPanel {
|
|||
}
|
||||
|
||||
// Grid
|
||||
InputOutputVariablesProperties props = GWT
|
||||
.create(InputOutputVariablesProperties.class);
|
||||
InputOutputVariablesProperties props = GWT.create(InputOutputVariablesProperties.class);
|
||||
|
||||
ColumnConfig<InputOutputVariables, String> nameColumn = new ColumnConfig<InputOutputVariables, String>(
|
||||
props.name(), 100, "Name");
|
||||
|
@ -136,10 +141,8 @@ public class InputOutputVariablesPanel extends ContentPanel {
|
|||
dataTypeColumn.setCell(new AbstractCell<DataType>() {
|
||||
|
||||
@Override
|
||||
public void render(Context context, DataType inputType,
|
||||
SafeHtmlBuilder sb) {
|
||||
DataTypeTemplates inputTypeTemplates = GWT
|
||||
.create(DataTypeTemplates.class);
|
||||
public void render(Context context, DataType inputType, SafeHtmlBuilder sb) {
|
||||
DataTypeTemplates inputTypeTemplates = GWT.create(DataTypeTemplates.class);
|
||||
sb.append(inputTypeTemplates.format(inputType.getLabel()));
|
||||
}
|
||||
});
|
||||
|
@ -154,10 +157,8 @@ public class InputOutputVariablesPanel extends ContentPanel {
|
|||
ioTypeColumn.setCell(new AbstractCell<IOType>() {
|
||||
|
||||
@Override
|
||||
public void render(Context context, IOType ioType,
|
||||
SafeHtmlBuilder sb) {
|
||||
IOTypeTemplates ioTypeTemplates = GWT
|
||||
.create(IOTypeTemplates.class);
|
||||
public void render(Context context, IOType ioType, SafeHtmlBuilder sb) {
|
||||
IOTypeTemplates ioTypeTemplates = GWT.create(IOTypeTemplates.class);
|
||||
sb.append(ioTypeTemplates.format(ioType.getLabel()));
|
||||
}
|
||||
});
|
||||
|
@ -169,11 +170,9 @@ public class InputOutputVariablesPanel extends ContentPanel {
|
|||
l.add(defaultValueColumn);
|
||||
l.add(ioTypeColumn);
|
||||
|
||||
ColumnModel<InputOutputVariables> columns = new ColumnModel<InputOutputVariables>(
|
||||
l);
|
||||
ColumnModel<InputOutputVariables> columns = new ColumnModel<InputOutputVariables>(l);
|
||||
|
||||
storeInputOutputVariables = new ListStore<InputOutputVariables>(
|
||||
props.id());
|
||||
storeInputOutputVariables = new ListStore<InputOutputVariables>(props.id());
|
||||
|
||||
/*
|
||||
* ArrayList<InputOutputVariablesVariables> list = new ArrayList<>();
|
||||
|
@ -186,18 +185,15 @@ public class InputOutputVariablesPanel extends ContentPanel {
|
|||
|
||||
if (project != null && project.getInputData() != null
|
||||
&& project.getInputData().getListInputOutputVariables() != null) {
|
||||
checkOutputParameterOnlyFileTypeIsSupported(project.getInputData()
|
||||
.getListInputOutputVariables());
|
||||
checkOutputParameterOnlyFileTypeIsSupported(project.getInputData().getListInputOutputVariables());
|
||||
|
||||
storeInputOutputVariables.addAll(project.getInputData()
|
||||
.getListInputOutputVariables());
|
||||
storeInputOutputVariables.addAll(project.getInputData().getListInputOutputVariables());
|
||||
}
|
||||
|
||||
final GridSelectionModel<InputOutputVariables> sm = new GridSelectionModel<InputOutputVariables>();
|
||||
sm.setSelectionMode(SelectionMode.SINGLE);
|
||||
|
||||
gridInputOutputVariables = new Grid<InputOutputVariables>(
|
||||
storeInputOutputVariables, columns);
|
||||
gridInputOutputVariables = new Grid<InputOutputVariables>(storeInputOutputVariables, columns);
|
||||
gridInputOutputVariables.setSelectionModel(sm);
|
||||
gridInputOutputVariables.getView().setStripeRows(true);
|
||||
gridInputOutputVariables.getView().setColumnLines(true);
|
||||
|
@ -207,36 +203,30 @@ public class InputOutputVariablesPanel extends ContentPanel {
|
|||
gridInputOutputVariables.setColumnReordering(false);
|
||||
|
||||
// DND
|
||||
GridDragSource<InputOutputVariables> ds = new GridDragSource<InputOutputVariables>(
|
||||
gridInputOutputVariables);
|
||||
GridDragSource<InputOutputVariables> ds = new GridDragSource<InputOutputVariables>(gridInputOutputVariables);
|
||||
ds.addDragStartHandler(new DndDragStartEvent.DndDragStartHandler() {
|
||||
|
||||
@Override
|
||||
public void onDragStart(DndDragStartEvent event) {
|
||||
@SuppressWarnings("unchecked")
|
||||
ArrayList<InputOutputVariables> draggingSelection = (ArrayList<InputOutputVariables>) event
|
||||
.getData();
|
||||
ArrayList<InputOutputVariables> draggingSelection = (ArrayList<InputOutputVariables>) event.getData();
|
||||
Log.debug("Start Drag: " + draggingSelection);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
GridDropTarget<InputOutputVariables> dt = new GridDropTarget<InputOutputVariables>(
|
||||
gridInputOutputVariables);
|
||||
GridDropTarget<InputOutputVariables> dt = new GridDropTarget<InputOutputVariables>(gridInputOutputVariables);
|
||||
dt.setFeedback(Feedback.BOTH);
|
||||
dt.setAllowSelfAsSource(true);
|
||||
|
||||
// EDITING //
|
||||
|
||||
// DataType
|
||||
DataTypePropertiesCombo dataTypePropertiesCombo = GWT
|
||||
.create(DataTypePropertiesCombo.class);
|
||||
DataTypePropertiesCombo dataTypePropertiesCombo = GWT.create(DataTypePropertiesCombo.class);
|
||||
|
||||
storeComboDataType = new ListStore<DataType>(
|
||||
dataTypePropertiesCombo.id());
|
||||
storeComboDataType = new ListStore<DataType>(dataTypePropertiesCombo.id());
|
||||
|
||||
comboDataType = new ComboBox<DataType>(storeComboDataType,
|
||||
dataTypePropertiesCombo.label());
|
||||
comboDataType = new ComboBox<DataType>(storeComboDataType, dataTypePropertiesCombo.label());
|
||||
comboDataType.setClearValueOnParseError(false);
|
||||
comboDataType.setEditable(false);
|
||||
|
||||
|
@ -248,13 +238,11 @@ public class InputOutputVariablesPanel extends ContentPanel {
|
|||
storeComboDataType.commitChanges();
|
||||
|
||||
// IOType
|
||||
IOTypePropertiesCombo ioTypePropertiesCombo = GWT
|
||||
.create(IOTypePropertiesCombo.class);
|
||||
IOTypePropertiesCombo ioTypePropertiesCombo = GWT.create(IOTypePropertiesCombo.class);
|
||||
|
||||
storeComboIOType = new ListStore<IOType>(ioTypePropertiesCombo.id());
|
||||
|
||||
comboIOType = new ComboBox<IOType>(storeComboIOType,
|
||||
ioTypePropertiesCombo.label());
|
||||
comboIOType = new ComboBox<IOType>(storeComboIOType, ioTypePropertiesCombo.label());
|
||||
comboIOType.setClearValueOnParseError(false);
|
||||
comboIOType.setEditable(false);
|
||||
|
||||
|
@ -267,34 +255,26 @@ public class InputOutputVariablesPanel extends ContentPanel {
|
|||
|
||||
//
|
||||
TextField nameColumnEditing = new TextField();
|
||||
nameColumnEditing.addValidator(new RegExValidator("^[^\"]*$",
|
||||
"Attention character \" is not allowed"));
|
||||
nameColumnEditing.addValidator(new RegExValidator("^[^\"]*$", "Attention character \" is not allowed"));
|
||||
TextField descriptionColumnEditing = new TextField();
|
||||
descriptionColumnEditing.addValidator(new RegExValidator("^[^\"]*$",
|
||||
"Attention character \" is not allowed"));
|
||||
descriptionColumnEditing.addValidator(new RegExValidator("^[^\"]*$", "Attention character \" is not allowed"));
|
||||
TextField defaultValueColumnEditing = new TextField();
|
||||
defaultValueColumnEditing.setAllowBlank(false);
|
||||
defaultValueColumnEditing.addValidator(new RegExValidator(
|
||||
"^[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*$",
|
||||
"Attention character \" is not allowed"));
|
||||
defaultValueColumnEditing.addValidator(
|
||||
new RegExValidator("^[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*$", "Attention character \" is not allowed"));
|
||||
|
||||
gridInputOutputVariablesEditing = new GridRowEditing<InputOutputVariables>(
|
||||
gridInputOutputVariables);
|
||||
gridInputOutputVariablesEditing
|
||||
.addEditor(nameColumn, nameColumnEditing);
|
||||
gridInputOutputVariablesEditing.addEditor(descriptionColumn,
|
||||
descriptionColumnEditing);
|
||||
gridInputOutputVariablesEditing
|
||||
.addEditor(dataTypeColumn, comboDataType);
|
||||
gridInputOutputVariablesEditing.addEditor(defaultValueColumn,
|
||||
defaultValueColumnEditing);
|
||||
gridInputOutputVariablesEditing = new GridRowEditing<InputOutputVariables>(gridInputOutputVariables);
|
||||
gridInputOutputVariablesEditing.addEditor(nameColumn, nameColumnEditing);
|
||||
gridInputOutputVariablesEditing.addEditor(descriptionColumn, descriptionColumnEditing);
|
||||
gridInputOutputVariablesEditing.addEditor(dataTypeColumn, comboDataType);
|
||||
gridInputOutputVariablesEditing.addEditor(defaultValueColumn, defaultValueColumnEditing);
|
||||
gridInputOutputVariablesEditing.addEditor(ioTypeColumn, comboIOType);
|
||||
|
||||
btnAdd = new TextButton();
|
||||
btnAdd.setIcon(StatAlgoImporterResources.INSTANCE.add16());
|
||||
btnAddVariable = new TextButton();
|
||||
btnAddVariable.setIcon(StatAlgoImporterResources.INSTANCE.add16());
|
||||
// btnAdd.setIconAlign(IconAlign.);
|
||||
btnAdd.setToolTip("Add Input/Output Variable");
|
||||
btnAdd.addSelectHandler(new SelectHandler() {
|
||||
btnAddVariable.setToolTip("Add Input/Output Variable");
|
||||
btnAddVariable.addSelectHandler(new SelectHandler() {
|
||||
|
||||
@Override
|
||||
public void onSelect(SelectEvent event) {
|
||||
|
@ -314,15 +294,13 @@ public class InputOutputVariablesPanel extends ContentPanel {
|
|||
storeInputOutputVariables.remove(rowIndex);
|
||||
storeInputOutputVariables.commitChanges();
|
||||
|
||||
gridInputOutputVariablesEditing.getCancelButton().setVisible(
|
||||
true);
|
||||
btnAdd.setEnabled(true);
|
||||
gridInputOutputVariablesEditing.getCancelButton().setVisible(true);
|
||||
btnAddVariable.setEnabled(true);
|
||||
if (addStatus) {
|
||||
addStatus = false;
|
||||
}
|
||||
|
||||
List<InputOutputVariables> listIOVariables = storeInputOutputVariables
|
||||
.getAll();
|
||||
List<InputOutputVariables> listIOVariables = storeInputOutputVariables.getAll();
|
||||
List<InputOutputVariables> listNewIOVariables = new ArrayList<InputOutputVariables>();
|
||||
for (int i = 0; i < listIOVariables.size(); i++) {
|
||||
InputOutputVariables var = listIOVariables.get(i);
|
||||
|
@ -342,81 +320,89 @@ public class InputOutputVariablesPanel extends ContentPanel {
|
|||
ButtonBar buttonBar = gridInputOutputVariablesEditing.getButtonBar();
|
||||
buttonBar.add(btnDelete);
|
||||
|
||||
gridInputOutputVariablesEditing
|
||||
.addBeforeStartEditHandler(new BeforeStartEditHandler<InputOutputVariables>() {
|
||||
gridInputOutputVariablesEditing.addBeforeStartEditHandler(new BeforeStartEditHandler<InputOutputVariables>() {
|
||||
|
||||
@Override
|
||||
public void onBeforeStartEdit(
|
||||
BeforeStartEditEvent<InputOutputVariables> event) {
|
||||
editingBeforeStart(event);
|
||||
@Override
|
||||
public void onBeforeStartEdit(BeforeStartEditEvent<InputOutputVariables> event) {
|
||||
editingBeforeStart(event);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
gridInputOutputVariablesEditing.addCancelEditHandler(new CancelEditHandler<InputOutputVariables>() {
|
||||
|
||||
@Override
|
||||
public void onCancelEdit(CancelEditEvent<InputOutputVariables> event) {
|
||||
storeInputOutputVariables.rejectChanges();
|
||||
btnAddVariable.setEnabled(true);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
gridInputOutputVariablesEditing.addCompleteEditHandler(new CompleteEditHandler<InputOutputVariables>() {
|
||||
|
||||
@Override
|
||||
public void onCompleteEdit(CompleteEditEvent<InputOutputVariables> event) {
|
||||
try {
|
||||
if (addStatus) {
|
||||
addStatus = false;
|
||||
}
|
||||
});
|
||||
storeInputOutputVariables.commitChanges();
|
||||
|
||||
gridInputOutputVariablesEditing
|
||||
.addCancelEditHandler(new CancelEditHandler<InputOutputVariables>() {
|
||||
gridInputOutputVariablesEditing.getCancelButton().setVisible(true);
|
||||
btnAddVariable.setEnabled(true);
|
||||
|
||||
@Override
|
||||
public void onCancelEdit(
|
||||
CancelEditEvent<InputOutputVariables> event) {
|
||||
storeInputOutputVariables.rejectChanges();
|
||||
btnAdd.setEnabled(true);
|
||||
} catch (Throwable e) {
|
||||
Log.error("Error: " + e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
gridInputOutputVariablesEditing
|
||||
.addCompleteEditHandler(new CompleteEditHandler<InputOutputVariables>() {
|
||||
|
||||
@Override
|
||||
public void onCompleteEdit(
|
||||
CompleteEditEvent<InputOutputVariables> event) {
|
||||
try {
|
||||
if (addStatus) {
|
||||
addStatus = false;
|
||||
}
|
||||
storeInputOutputVariables.commitChanges();
|
||||
|
||||
gridInputOutputVariablesEditing.getCancelButton()
|
||||
.setVisible(true);
|
||||
btnAdd.setEnabled(true);
|
||||
|
||||
} catch (Throwable e) {
|
||||
Log.error("Error: " + e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// ToolBar toolBar = new ToolBar();
|
||||
// toolBar.add(btnAdd, new BoxLayoutData(new Margins(0)));
|
||||
|
||||
VerticalLayoutContainer vlc = new VerticalLayoutContainer();
|
||||
vlc.setAdjustForScroll(false);
|
||||
vlc.setScrollMode(ScrollMode.NONE);
|
||||
|
||||
// vlc.add(toolBar, new VerticalLayoutData(1, -1, new Margins(0)));
|
||||
vlc.add(gridInputOutputVariables, new VerticalLayoutData(1, 1,
|
||||
new Margins(0)));
|
||||
if (project != null && project.getProjectConfig() != null
|
||||
&& project.getProjectConfig().getProjectSupport() != null) {
|
||||
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)));
|
||||
|
||||
}
|
||||
|
||||
private void editingBeforeStart(
|
||||
BeforeStartEditEvent<InputOutputVariables> event) {
|
||||
if (storeInputOutputVariables != null
|
||||
&& storeInputOutputVariables.size() > 0) {
|
||||
private void editingBeforeStart(BeforeStartEditEvent<InputOutputVariables> event) {
|
||||
if (storeInputOutputVariables != null && storeInputOutputVariables.size() > 0) {
|
||||
|
||||
int rowIndex = event.getEditCell().getRow();
|
||||
|
||||
InputOutputVariables currentInputOutputVariable = storeInputOutputVariables
|
||||
.get(rowIndex);
|
||||
if (currentInputOutputVariable != null
|
||||
&& currentInputOutputVariable.getIoType() != null
|
||||
&& currentInputOutputVariable.getIoType().compareTo(
|
||||
IOType.OUTPUT) == 0) {
|
||||
InputOutputVariables currentInputOutputVariable = storeInputOutputVariables.get(rowIndex);
|
||||
if (currentInputOutputVariable != null && currentInputOutputVariable.getIoType() != null
|
||||
&& currentInputOutputVariable.getIoType().compareTo(IOType.OUTPUT) == 0) {
|
||||
storeComboDataType.clear();
|
||||
storeComboDataType.add(DataType.FILE);
|
||||
storeComboDataType.commitChanges();
|
||||
|
@ -432,14 +418,12 @@ public class InputOutputVariablesPanel extends ContentPanel {
|
|||
}
|
||||
}
|
||||
|
||||
private void addHandlersForComboDataType(
|
||||
LabelProvider<DataType> labelProvider) {
|
||||
private void addHandlersForComboDataType(LabelProvider<DataType> labelProvider) {
|
||||
comboDataType.addValueChangeHandler(new ValueChangeHandler<DataType>() {
|
||||
|
||||
@Override
|
||||
public void onValueChange(ValueChangeEvent<DataType> event) {
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -451,7 +435,6 @@ public class InputOutputVariablesPanel extends ContentPanel {
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void addHandlersForComboIOType(LabelProvider<IOType> labelProvider) {
|
||||
|
@ -505,7 +488,7 @@ public class InputOutputVariablesPanel extends ContentPanel {
|
|||
storeComboDataType.add(DataType.FILE);
|
||||
storeComboDataType.commitChanges();
|
||||
comboDataType.clear();
|
||||
comboDataType.setValue(DataType.FILE,true,true);
|
||||
comboDataType.setValue(DataType.FILE, true, true);
|
||||
}
|
||||
|
||||
private void setComboForInputParameter() {
|
||||
|
@ -514,8 +497,7 @@ public class InputOutputVariablesPanel extends ContentPanel {
|
|||
storeComboDataType.commitChanges();
|
||||
}
|
||||
|
||||
public void addNewInputOutputVariables(
|
||||
InputOutputVariables inputOutputVariable) {
|
||||
public void addNewInputOutputVariables(InputOutputVariables inputOutputVariable) {
|
||||
try {
|
||||
Log.debug("Current Seq: " + seq);
|
||||
seq++;
|
||||
|
@ -539,16 +521,14 @@ public class InputOutputVariablesPanel extends ContentPanel {
|
|||
try {
|
||||
Log.debug("Current Seq: " + seq);
|
||||
seq++;
|
||||
InputOutputVariables newInputOutputVariablesVariable = new InputOutputVariables(
|
||||
seq, "", "", "", DataType.STRING, IOType.INPUT, "");
|
||||
Log.debug("New Input/Output Variable: "
|
||||
+ newInputOutputVariablesVariable);
|
||||
InputOutputVariables newInputOutputVariablesVariable = new InputOutputVariables(seq, "", "", "",
|
||||
DataType.STRING, IOType.INPUT, "");
|
||||
Log.debug("New Input/Output Variable: " + newInputOutputVariablesVariable);
|
||||
gridInputOutputVariablesEditing.cancelEditing();
|
||||
addStatus = true;
|
||||
gridInputOutputVariablesEditing.getCancelButton().setVisible(false);
|
||||
storeInputOutputVariables.add(newInputOutputVariablesVariable);
|
||||
int row = storeInputOutputVariables
|
||||
.indexOf(newInputOutputVariablesVariable);
|
||||
int row = storeInputOutputVariables.indexOf(newInputOutputVariablesVariable);
|
||||
|
||||
storeComboDataType.clear();
|
||||
storeComboDataType.addAll(DataType.asList());
|
||||
|
@ -568,12 +548,10 @@ public class InputOutputVariablesPanel extends ContentPanel {
|
|||
Log.debug("Update Input/Output Variables: " + project);
|
||||
if (project != null && project.getInputData() != null
|
||||
&& project.getInputData().getListInputOutputVariables() != null) {
|
||||
checkOutputParameterOnlyFileTypeIsSupported(project.getInputData()
|
||||
.getListInputOutputVariables());
|
||||
checkOutputParameterOnlyFileTypeIsSupported(project.getInputData().getListInputOutputVariables());
|
||||
|
||||
storeInputOutputVariables.clear();
|
||||
storeInputOutputVariables.addAll(project.getInputData()
|
||||
.getListInputOutputVariables());
|
||||
storeInputOutputVariables.addAll(project.getInputData().getListInputOutputVariables());
|
||||
storeInputOutputVariables.commitChanges();
|
||||
seq = project.getInputData().getListInputOutputVariables().size();
|
||||
|
||||
|
@ -585,13 +563,10 @@ public class InputOutputVariablesPanel extends ContentPanel {
|
|||
|
||||
}
|
||||
|
||||
private void checkOutputParameterOnlyFileTypeIsSupported(
|
||||
ArrayList<InputOutputVariables> inputOutputVarialbles) {
|
||||
private void checkOutputParameterOnlyFileTypeIsSupported(ArrayList<InputOutputVariables> inputOutputVarialbles) {
|
||||
for (InputOutputVariables ioVariable : inputOutputVarialbles) {
|
||||
if (ioVariable.getIoType() != null
|
||||
&& ioVariable.getIoType().compareTo(IOType.OUTPUT) == 0) {
|
||||
if (ioVariable.getDataType() == null
|
||||
|| ioVariable.getDataType().compareTo(DataType.FILE) != 0) {
|
||||
if (ioVariable.getIoType() != null && ioVariable.getIoType().compareTo(IOType.OUTPUT) == 0) {
|
||||
if (ioVariable.getDataType() == null || ioVariable.getDataType().compareTo(DataType.FILE) != 0) {
|
||||
ioVariable.setDataType(DataType.FILE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -129,6 +129,8 @@ public class InputVariablePanel extends ContentPanel {
|
|||
case MAIN_CODE_SET:
|
||||
setMainCode(event.getProject());
|
||||
break;
|
||||
case BINARY_CODE_SET:
|
||||
setBinaryCode(event.getProject());
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -167,4 +169,10 @@ public class InputVariablePanel extends ContentPanel {
|
|||
|
||||
}
|
||||
|
||||
private void setBinaryCode(Project project) {
|
||||
inputVariableTabPanel.setBinaryCode(project);
|
||||
Log.debug("ToolBoxPanel Updated");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
try {
|
||||
globalVariablesPanel.update(project);
|
||||
|
|
|
@ -7,16 +7,5 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.client.type;
|
|||
*
|
||||
*/
|
||||
public enum ProjectStatusEventType {
|
||||
START,
|
||||
OPEN,
|
||||
MAIN_CODE_SET,
|
||||
UPDATE,
|
||||
ADD_RESOURCE,
|
||||
DELETE_RESOURCE,
|
||||
DELETE_MAIN_CODE,
|
||||
SOFTWARE_CREATED,
|
||||
SOFTWARE_PUBLISH,
|
||||
SOFTWARE_REPACKAGE,
|
||||
EXPLORER_REFRESH,
|
||||
SAVE;
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@ import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Proj
|
|||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.ProjectSupportBlackBox;
|
||||
|
||||
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.sencha.gxt.core.client.util.Margins;
|
||||
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 {
|
||||
ProjectStatusEvent projectStatusEvent = new ProjectStatusEvent(ProjectStatusEventType.OPEN, project);
|
||||
Log.debug("Work Area Panel ProjectStatusEvent fire! " + projectStatusEvent);
|
||||
eventBus.fireEvent(projectStatusEvent);
|
||||
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
ProjectStatusEvent projectStatusEvent = new ProjectStatusEvent(ProjectStatusEventType.OPEN, project);
|
||||
Log.debug("Work Area Panel ProjectStatusEvent fire! " + projectStatusEvent);
|
||||
eventBus.fireEvent(projectStatusEvent);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
} catch (Throwable e) {
|
||||
Log.error(e.getLocalizedMessage(), e);
|
||||
}
|
||||
|
|
|
@ -46,11 +46,9 @@ import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
|||
* The server side implementation of the RPC service.
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
||||
StatAlgoImporterService {
|
||||
public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements StatAlgoImporterService {
|
||||
|
||||
private static Logger logger = LoggerFactory
|
||||
.getLogger(StatAlgoImporterServiceImpl.class);
|
||||
private static Logger logger = LoggerFactory.getLogger(StatAlgoImporterServiceImpl.class);
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -65,13 +63,11 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
System.out.println("initializing StatAlgoImporterService");
|
||||
String notificationRecipientsFile = "/statalgoimporter/properties/NotificationRecipients.txt";
|
||||
InputStream notificationRecipientsInputStream = this
|
||||
.getServletContext().getResourceAsStream(
|
||||
notificationRecipientsFile);
|
||||
InputStream notificationRecipientsInputStream = this.getServletContext()
|
||||
.getResourceAsStream(notificationRecipientsFile);
|
||||
String text = null;
|
||||
try {
|
||||
text = IOUtils.toString(notificationRecipientsInputStream,
|
||||
StandardCharsets.UTF_8.name());
|
||||
text = IOUtils.toString(notificationRecipientsInputStream, StandardCharsets.UTF_8.name());
|
||||
} catch (IOException e) {
|
||||
System.out.println(e.getLocalizedMessage());
|
||||
System.out.println(e.getStackTrace().toString());
|
||||
|
@ -104,14 +100,10 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
@Override
|
||||
public UserInfo hello() throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(this.getThreadLocalRequest());
|
||||
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
|
||||
logger.debug("hello()");
|
||||
UserInfo userInfo = new UserInfo(serviceCredentials.getUserName(),
|
||||
serviceCredentials.getGroupId(),
|
||||
serviceCredentials.getGroupName(),
|
||||
serviceCredentials.getScope(),
|
||||
serviceCredentials.getEmail(),
|
||||
UserInfo userInfo = new UserInfo(serviceCredentials.getUserName(), serviceCredentials.getGroupId(),
|
||||
serviceCredentials.getGroupName(), serviceCredentials.getScope(), serviceCredentials.getEmail(),
|
||||
serviceCredentials.getFullName());
|
||||
logger.debug("UserInfo: " + userInfo);
|
||||
return userInfo;
|
||||
|
@ -126,40 +118,34 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public SAIDescriptor getSAIDescripor() throws StatAlgoImporterServiceException {
|
||||
HttpServletRequest httpRequest = null;
|
||||
try {
|
||||
httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(httpRequest);
|
||||
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
|
||||
logger.debug("getSAIDescriptor()");
|
||||
SAIDescriptor saiDescriptor=BuildSAIDescriptor.build(serviceCredentials.getScope());
|
||||
SAIDescriptor saiDescriptor = BuildSAIDescriptor.build(serviceCredentials.getScope());
|
||||
return saiDescriptor;
|
||||
|
||||
} catch (StatAlgoImporterServiceException e) {
|
||||
logger.error("Error retrieving SAI descriptor: "+e.getLocalizedMessage(),e);
|
||||
logger.error("Error retrieving SAI descriptor: " + e.getLocalizedMessage(), e);
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
logger.error("Error retrieving SAI descriptor: "+e.getLocalizedMessage(),e);
|
||||
throw new StatAlgoImporterServiceException(e.getLocalizedMessage(),e);
|
||||
logger.error("Error retrieving SAI descriptor: " + e.getLocalizedMessage(), e);
|
||||
throw new StatAlgoImporterServiceException(e.getLocalizedMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Project restoreUISession(String value)
|
||||
throws StatAlgoImporterServiceException {
|
||||
public Project restoreUISession(String value) throws StatAlgoImporterServiceException {
|
||||
HttpServletRequest httpRequest = null;
|
||||
try {
|
||||
httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(httpRequest);
|
||||
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
|
||||
logger.debug("restoreUISession(): " + value);
|
||||
Project project = SessionUtil.getProjectSession(httpRequest,
|
||||
serviceCredentials);
|
||||
Project project = SessionUtil.getProjectSession(httpRequest, serviceCredentials);
|
||||
return project;
|
||||
} catch (StatAlgoImporterServiceException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -172,30 +158,25 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* {@inheritDoc}
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public FileUploadMonitor getFileUploadMonitor()
|
||||
throws StatAlgoImporterServiceException {
|
||||
public FileUploadMonitor getFileUploadMonitor() throws StatAlgoImporterServiceException {
|
||||
|
||||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(httpRequest);
|
||||
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
|
||||
|
||||
FileUploadMonitor fileUploadMonitor = null;
|
||||
try {
|
||||
fileUploadMonitor = SessionUtil.getFileUploadMonitor(httpRequest,
|
||||
serviceCredentials);
|
||||
fileUploadMonitor = SessionUtil.getFileUploadMonitor(httpRequest, serviceCredentials);
|
||||
} catch (Exception e) {
|
||||
logger.error("Error retrieving the fileUploadMonitor", e);
|
||||
}
|
||||
if (fileUploadMonitor == null) {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"Error retrieving the fileUploadMonitor: null");
|
||||
throw new StatAlgoImporterServiceException("Error retrieving the fileUploadMonitor: null");
|
||||
}
|
||||
|
||||
logger.debug("FileUploadMonitor: " + fileUploadMonitor);
|
||||
|
@ -209,24 +190,19 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
*
|
||||
*/
|
||||
@Override
|
||||
public ArrayList<CodeData> getCode()
|
||||
throws StatAlgoImporterServiceException {
|
||||
public ArrayList<CodeData> getCode() throws StatAlgoImporterServiceException {
|
||||
|
||||
try {
|
||||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(httpRequest);
|
||||
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
|
||||
|
||||
logger.debug("getCode()");
|
||||
Project projectSession = SessionUtil.getProjectSession(httpRequest,
|
||||
serviceCredentials);
|
||||
Project projectSession = SessionUtil.getProjectSession(httpRequest, serviceCredentials);
|
||||
if (projectSession != null) {
|
||||
CodeReader codeFileReader = new CodeReader(projectSession,
|
||||
serviceCredentials);
|
||||
CodeReader codeFileReader = new CodeReader(projectSession, serviceCredentials);
|
||||
ArrayList<CodeData> codeList = codeFileReader.getCodeList();
|
||||
for (CodeData codeData : codeList) {
|
||||
logger.debug("" + codeData.getId() + " "
|
||||
+ codeData.getCodeLine());
|
||||
logger.debug("" + codeData.getId() + " " + codeData.getCodeLine());
|
||||
}
|
||||
return codeList;
|
||||
} else {
|
||||
|
@ -253,26 +229,24 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(httpRequest);
|
||||
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
|
||||
logger.debug("createProjectOnWorkspace(): " + projectCreateSession);
|
||||
Project project;
|
||||
if (ProjectArchiver.existProjectInFolder(projectCreateSession.getNewProjectFolder(),
|
||||
serviceCredentials)) {
|
||||
if (ProjectArchiver.existProjectInFolder(projectCreateSession.getNewProjectFolder(), serviceCredentials)) {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"Attention a project is present in this folder, use open or another folder!");
|
||||
} else {
|
||||
ProjectFolder projectFolder = new ProjectFolder(projectCreateSession.getNewProjectFolder());
|
||||
ProjectConfig projectConfig=null;
|
||||
ProjectConfig projectConfig = null;
|
||||
if (projectCreateSession.getProjectSetup() != null
|
||||
&& projectCreateSession.getProjectSetup().getProjectSupportType() != null) {
|
||||
switch(projectCreateSession.getProjectSetup().getProjectSupportType()){
|
||||
switch (projectCreateSession.getProjectSetup().getProjectSupportType()) {
|
||||
case BlackBox:
|
||||
projectConfig=new ProjectConfig(projectCreateSession.getProjectSetup().getLanguage(),
|
||||
projectConfig = new ProjectConfig(projectCreateSession.getProjectSetup().getLanguage(),
|
||||
new ProjectSupportBlackBox());
|
||||
break;
|
||||
case REdit:
|
||||
projectConfig=new ProjectConfig(projectCreateSession.getProjectSetup().getLanguage(),
|
||||
projectConfig = new ProjectConfig(projectCreateSession.getProjectSetup().getLanguage(),
|
||||
new ProjectSupportREdit());
|
||||
break;
|
||||
default:
|
||||
|
@ -280,9 +254,8 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
}
|
||||
}
|
||||
project = new Project(projectFolder,projectConfig);
|
||||
SessionUtil.setProjectSession(httpRequest, serviceCredentials,
|
||||
project);
|
||||
project = new Project(projectFolder, projectConfig);
|
||||
SessionUtil.setProjectSession(httpRequest, serviceCredentials, project);
|
||||
|
||||
}
|
||||
|
||||
|
@ -292,34 +265,28 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
e.printStackTrace();
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
logger.error(
|
||||
"createProjectOnWorkspace(): " + e.getLocalizedMessage(), e);
|
||||
logger.error("createProjectOnWorkspace(): " + e.getLocalizedMessage(), e);
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Project openProjectOnWorkspace(ItemDescription newProjectFolder)
|
||||
throws StatAlgoImporterServiceException {
|
||||
public Project openProjectOnWorkspace(ItemDescription newProjectFolder) throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(httpRequest);
|
||||
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
|
||||
logger.debug("openProjectOnWorkspace()");
|
||||
|
||||
Project project = ProjectArchiver.readProject(newProjectFolder,
|
||||
serviceCredentials);
|
||||
SessionUtil.setProjectSession(httpRequest, serviceCredentials,
|
||||
project);
|
||||
Project project = ProjectArchiver.readProject(newProjectFolder, serviceCredentials);
|
||||
SessionUtil.setProjectSession(httpRequest, serviceCredentials, project);
|
||||
|
||||
return project;
|
||||
} catch (StatAlgoImporterServiceException e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
logger.error(
|
||||
"openProjectOnWorkspace(): " + e.getLocalizedMessage(), e);
|
||||
logger.error("openProjectOnWorkspace(): " + e.getLocalizedMessage(), e);
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
|
||||
}
|
||||
|
@ -327,24 +294,19 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public Project setMainCode(ItemDescription itemDescription)
|
||||
throws StatAlgoImporterServiceException {
|
||||
public Project setMainCode(ItemDescription itemDescription) throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(httpRequest);
|
||||
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
|
||||
logger.debug("SetMainCode(): " + itemDescription);
|
||||
Project project = SessionUtil.getProjectSession(httpRequest,
|
||||
serviceCredentials);
|
||||
Project project = SessionUtil.getProjectSession(httpRequest, serviceCredentials);
|
||||
if (project != null) {
|
||||
project.setMainCode(new MainCode(itemDescription));
|
||||
project.setInputData(null);
|
||||
project.setProjectTarget(null);
|
||||
WPS4RParser wps4Parser = new WPS4RParser(project,
|
||||
serviceCredentials);
|
||||
WPS4RParser wps4Parser = new WPS4RParser(project, serviceCredentials);
|
||||
project = wps4Parser.parse();
|
||||
SessionUtil.setProjectSession(httpRequest, serviceCredentials,
|
||||
project);
|
||||
SessionUtil.setProjectSession(httpRequest, serviceCredentials, project);
|
||||
logger.debug("Project: " + project);
|
||||
} else {
|
||||
throw new StatAlgoImporterServiceException("No project open!");
|
||||
|
@ -363,27 +325,57 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public void addResourceToProject(ItemDescription itemDescription)
|
||||
throws StatAlgoImporterServiceException {
|
||||
public Project setBinaryCode(ItemDescription itemDescription) throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(httpRequest);
|
||||
ServiceCredentials serviceCredentials = SessionUtil.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);
|
||||
if (itemDescription == null || itemDescription.getId() == null) {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"Add resource to project is failed, invalid resource: "
|
||||
+ itemDescription);
|
||||
"Add resource to project is failed, invalid resource: " + itemDescription);
|
||||
}
|
||||
|
||||
Project project = SessionUtil.getProjectSession(httpRequest,
|
||||
serviceCredentials);
|
||||
Project project = SessionUtil.getProjectSession(httpRequest, serviceCredentials);
|
||||
if (project != null && project.getProjectFolder() != null
|
||||
&& project.getProjectFolder().getFolder() != null) {
|
||||
FilesStorage fileStorage = new FilesStorage();
|
||||
fileStorage.copyItemOnFolder(serviceCredentials.getUserName(),
|
||||
itemDescription.getId(), project.getProjectFolder()
|
||||
.getFolder().getId());
|
||||
fileStorage.copyItemOnFolder(serviceCredentials.getUserName(), itemDescription.getId(),
|
||||
project.getProjectFolder().getFolder().getId());
|
||||
} else {
|
||||
throw new StatAlgoImporterServiceException("No project open!");
|
||||
}
|
||||
|
@ -393,8 +385,7 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
e.printStackTrace();
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
logger.error("addResourceToProject(): " + e.getLocalizedMessage(),
|
||||
e);
|
||||
logger.error("addResourceToProject(): " + e.getLocalizedMessage(), e);
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
|
||||
}
|
||||
|
@ -402,109 +393,76 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public Project deleteResourceOnProject(ItemDescription itemDescription)
|
||||
throws StatAlgoImporterServiceException {
|
||||
public Project deleteResourceOnProject(ItemDescription itemDescription) throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(httpRequest);
|
||||
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
|
||||
|
||||
logger.debug("deleteResourceOnProject(): " + itemDescription);
|
||||
if (itemDescription == null || itemDescription.getId() == null) {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"Delete resource on project is failed, invalid resource: "
|
||||
+ itemDescription);
|
||||
"Delete resource on project is failed, invalid resource: " + itemDescription);
|
||||
}
|
||||
|
||||
Project project = SessionUtil.getProjectSession(httpRequest,
|
||||
serviceCredentials);
|
||||
checkProjectInfoForDelete(itemDescription, httpRequest,
|
||||
serviceCredentials, project);
|
||||
Project project = SessionUtil.getProjectSession(httpRequest, serviceCredentials);
|
||||
checkProjectInfoForDelete(itemDescription, httpRequest, serviceCredentials, project);
|
||||
FilesStorage fileStorage = new FilesStorage();
|
||||
fileStorage.deleteItemOnFolder(serviceCredentials.getUserName(),
|
||||
itemDescription.getId());
|
||||
fileStorage.deleteItemOnFolder(serviceCredentials.getUserName(), itemDescription.getId());
|
||||
return project;
|
||||
|
||||
} catch (StatAlgoImporterServiceException e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
logger.error(
|
||||
"deleteResourceOnProject(): " + e.getLocalizedMessage(), e);
|
||||
logger.error("deleteResourceOnProject(): " + e.getLocalizedMessage(), e);
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void checkProjectInfoForDelete(ItemDescription itemDescription,
|
||||
HttpServletRequest httpRequest,
|
||||
private void checkProjectInfoForDelete(ItemDescription itemDescription, HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials, Project project)
|
||||
throws StatAlgoImporterSessionExpiredException,
|
||||
StatAlgoImporterServiceException {
|
||||
throws StatAlgoImporterSessionExpiredException, StatAlgoImporterServiceException {
|
||||
if (project != null) {
|
||||
if (project.getMainCode() != null
|
||||
&& project.getMainCode().getItemDescription() != null
|
||||
&& project.getMainCode().getItemDescription().getId()
|
||||
.compareTo(itemDescription.getId()) == 0) {
|
||||
if (project.getMainCode() != null && project.getMainCode().getItemDescription() != null
|
||||
&& project.getMainCode().getItemDescription().getId().compareTo(itemDescription.getId()) == 0) {
|
||||
project.setMainCode(null);
|
||||
project.setInputData(null);
|
||||
project.setProjectTarget(null);
|
||||
SessionUtil.setProjectSession(httpRequest, serviceCredentials,
|
||||
project);
|
||||
SessionUtil.setProjectSession(httpRequest, serviceCredentials, project);
|
||||
ProjectArchiver.archive(project, serviceCredentials);
|
||||
} else {
|
||||
if (project.getProjectTarget() != null
|
||||
&& project.getProjectTarget().getFolder() != null
|
||||
&& project.getProjectTarget().getFolder().getId()
|
||||
.compareTo(itemDescription.getId()) == 0) {
|
||||
if (project.getProjectTarget() != null && project.getProjectTarget().getFolder() != null
|
||||
&& project.getProjectTarget().getFolder().getId().compareTo(itemDescription.getId()) == 0) {
|
||||
project.setProjectTarget(null);
|
||||
SessionUtil.setProjectSession(httpRequest,
|
||||
serviceCredentials, project);
|
||||
SessionUtil.setProjectSession(httpRequest, serviceCredentials, project);
|
||||
ProjectArchiver.archive(project, serviceCredentials);
|
||||
} else {
|
||||
if (project.getProjectTarget() != null
|
||||
&& project.getProjectTarget().getProjectCompile() != null
|
||||
&& project.getProjectTarget().getProjectCompile()
|
||||
.getFolder() != null
|
||||
&& project.getProjectTarget().getProjectCompile()
|
||||
.getFolder().getId()
|
||||
if (project.getProjectTarget() != null && project.getProjectTarget().getProjectCompile() != null
|
||||
&& project.getProjectTarget().getProjectCompile().getFolder() != null
|
||||
&& project.getProjectTarget().getProjectCompile().getFolder().getId()
|
||||
.compareTo(itemDescription.getId()) == 0) {
|
||||
project.getProjectTarget().setProjectCompile(null);
|
||||
SessionUtil.setProjectSession(httpRequest,
|
||||
serviceCredentials, project);
|
||||
SessionUtil.setProjectSession(httpRequest, 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()
|
||||
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);
|
||||
SessionUtil.setProjectSession(httpRequest, serviceCredentials, project);
|
||||
ProjectArchiver.archive(project, serviceCredentials);
|
||||
} else {
|
||||
if (project.getProjectTarget() != null
|
||||
&& project.getProjectTarget()
|
||||
.getProjectDeploy() != null
|
||||
&& project.getProjectTarget()
|
||||
.getProjectDeploy()
|
||||
.getPackageProject() != null
|
||||
&& project.getProjectTarget()
|
||||
.getProjectDeploy()
|
||||
.getPackageProject().getId()
|
||||
&& 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);
|
||||
project.getProjectTarget().getProjectDeploy().setPackageProject(null);
|
||||
SessionUtil.setProjectSession(httpRequest, serviceCredentials, project);
|
||||
ProjectArchiver.archive(project, serviceCredentials);
|
||||
} else {
|
||||
|
||||
}
|
||||
|
@ -518,20 +476,16 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public void saveProject(InputData inputData)
|
||||
throws StatAlgoImporterServiceException {
|
||||
public void saveProject(InputData inputData) throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(httpRequest);
|
||||
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
|
||||
|
||||
logger.debug("saveProject():" + inputData);
|
||||
Project project = SessionUtil.getProjectSession(httpRequest,
|
||||
serviceCredentials);
|
||||
Project project = SessionUtil.getProjectSession(httpRequest, serviceCredentials);
|
||||
if (project != null) {
|
||||
project.setInputData(inputData);
|
||||
SessionUtil.setProjectSession(httpRequest, serviceCredentials,
|
||||
project);
|
||||
SessionUtil.setProjectSession(httpRequest, serviceCredentials, project);
|
||||
ProjectArchiver.archive(project, serviceCredentials);
|
||||
} else {
|
||||
throw new StatAlgoImporterServiceException("No project open!");
|
||||
|
@ -553,21 +507,17 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
public void saveCode(String code) throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(httpRequest);
|
||||
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
|
||||
|
||||
logger.debug("saveCode():" + code);
|
||||
Project project = SessionUtil.getProjectSession(httpRequest,
|
||||
serviceCredentials);
|
||||
Project project = SessionUtil.getProjectSession(httpRequest, serviceCredentials);
|
||||
if (project != null) {
|
||||
MainCode mainCode = project.getMainCode();
|
||||
if (mainCode == null || mainCode.getItemDescription() == null) {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"No main code set!");
|
||||
throw new StatAlgoImporterServiceException("No main code set!");
|
||||
} else {
|
||||
MainCodeSave mainCodeSave = new MainCodeSave();
|
||||
mainCodeSave.save(serviceCredentials,
|
||||
mainCode.getItemDescription(), code, project);
|
||||
mainCodeSave.save(serviceCredentials, mainCode.getItemDescription(), code, project);
|
||||
}
|
||||
} else {
|
||||
throw new StatAlgoImporterServiceException("No project open!");
|
||||
|
@ -590,26 +540,21 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(httpRequest);
|
||||
logger.debug("saveCode(): itemDescription" + fileDescription
|
||||
+ ", code:" + code);
|
||||
Project project = SessionUtil.getProjectSession(httpRequest,
|
||||
serviceCredentials);
|
||||
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
|
||||
logger.debug("saveCode(): itemDescription" + fileDescription + ", code:" + code);
|
||||
Project project = SessionUtil.getProjectSession(httpRequest, serviceCredentials);
|
||||
if (project != null && project.getProjectFolder() != null
|
||||
&& project.getProjectFolder().getFolder() != null) {
|
||||
MainCodeSave mainCodeSave = new MainCodeSave();
|
||||
ItemDescription mainCodeItemDescription = mainCodeSave.saveNew(
|
||||
serviceCredentials, fileDescription, code, project);
|
||||
ItemDescription mainCodeItemDescription = mainCodeSave.saveNew(serviceCredentials, fileDescription,
|
||||
code, project);
|
||||
MainCode mainCode = new MainCode(mainCodeItemDescription);
|
||||
project.setMainCode(mainCode);
|
||||
project.setInputData(null);
|
||||
project.setProjectTarget(null);
|
||||
WPS4RParser wps4Parser = new WPS4RParser(project,
|
||||
serviceCredentials);
|
||||
WPS4RParser wps4Parser = new WPS4RParser(project, serviceCredentials);
|
||||
project = wps4Parser.parse();
|
||||
SessionUtil.setProjectSession(httpRequest, serviceCredentials,
|
||||
project);
|
||||
SessionUtil.setProjectSession(httpRequest, serviceCredentials, project);
|
||||
return project;
|
||||
} else {
|
||||
throw new StatAlgoImporterServiceException("No project open!");
|
||||
|
@ -627,24 +572,18 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public void createSoftware(InputData inputData)
|
||||
throws StatAlgoImporterServiceException {
|
||||
public void createSoftware(InputData inputData) throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(httpRequest);
|
||||
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
|
||||
logger.debug("createSoftware(): " + inputData);
|
||||
Project project = SessionUtil.getProjectSession(httpRequest,
|
||||
serviceCredentials);
|
||||
Project project = SessionUtil.getProjectSession(httpRequest, serviceCredentials);
|
||||
if (project != null) {
|
||||
project.setInputData(inputData);
|
||||
SessionUtil.setProjectSession(httpRequest, serviceCredentials,
|
||||
project);
|
||||
ProjectBuilder projectBuilder = new ProjectBuilder(project,
|
||||
serviceCredentials);
|
||||
SessionUtil.setProjectSession(httpRequest, serviceCredentials, project);
|
||||
ProjectBuilder projectBuilder = new ProjectBuilder(project, serviceCredentials);
|
||||
project = projectBuilder.buildTarget();
|
||||
SessionUtil.setProjectSession(httpRequest, serviceCredentials,
|
||||
project);
|
||||
SessionUtil.setProjectSession(httpRequest, serviceCredentials, project);
|
||||
ProjectArchiver.archive(project, serviceCredentials);
|
||||
} else {
|
||||
throw new StatAlgoImporterServiceException("No project open!");
|
||||
|
@ -663,16 +602,13 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getPublicLink(ItemDescription itemDescription)
|
||||
throws StatAlgoImporterServiceException {
|
||||
public String getPublicLink(ItemDescription itemDescription) throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(httpRequest);
|
||||
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
|
||||
logger.debug("GetPublicLink(): " + itemDescription);
|
||||
FilesStorage filesStorage = new FilesStorage();
|
||||
String link = filesStorage.getPublicLink(
|
||||
serviceCredentials.getUserName(), itemDescription.getId());
|
||||
String link = filesStorage.getPublicLink(serviceCredentials.getUserName(), itemDescription.getId());
|
||||
|
||||
return link;
|
||||
} catch (StatAlgoImporterServiceException e) {
|
||||
|
@ -689,21 +625,17 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
public void publishSoftware() throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(httpRequest);
|
||||
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
|
||||
logger.debug("PublishSoftware()");
|
||||
ArrayList<Recipient> recipients = SessionUtil
|
||||
.getRecipients(httpRequest.getServletContext());
|
||||
ArrayList<Recipient> recipients = SessionUtil.getRecipients(httpRequest.getServletContext());
|
||||
Project project = SessionUtil.getProjectSession(httpRequest, serviceCredentials);
|
||||
if (project != null) {
|
||||
ProjectBuilder projectBuilder = new ProjectBuilder(project,
|
||||
serviceCredentials);
|
||||
ProjectBuilder projectBuilder = new ProjectBuilder(project, serviceCredentials);
|
||||
project = projectBuilder.buildDeploy();
|
||||
SessionUtil.setProjectSession(httpRequest, serviceCredentials, project);
|
||||
ProjectArchiver.archive(project, serviceCredentials);
|
||||
AlgorithmNotification notify = new AlgorithmNotification(
|
||||
this.getThreadLocalRequest(), serviceCredentials,
|
||||
project, recipients);
|
||||
AlgorithmNotification notify = new AlgorithmNotification(this.getThreadLocalRequest(),
|
||||
serviceCredentials, project, recipients);
|
||||
notify.run();
|
||||
} else {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
|
@ -726,19 +658,16 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
public void repackageSoftware() throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(httpRequest);
|
||||
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
|
||||
logger.debug("RepackageSoftware()");
|
||||
Project project = SessionUtil.getProjectSession(httpRequest, serviceCredentials);
|
||||
if (project != null) {
|
||||
ProjectBuilder projectBuilder = new ProjectBuilder(project,
|
||||
serviceCredentials);
|
||||
ProjectBuilder projectBuilder = new ProjectBuilder(project, serviceCredentials);
|
||||
project = projectBuilder.buildRepackage();
|
||||
SessionUtil.setProjectSession(httpRequest, serviceCredentials, project);
|
||||
ProjectArchiver.archive(project, serviceCredentials);
|
||||
} else {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"The script was not packaged correctly!");
|
||||
throw new StatAlgoImporterServiceException("The script was not packaged correctly!");
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -753,6 +682,4 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -86,6 +86,7 @@ public class ProjectBuilder {
|
|||
public Project buildTarget() throws StatAlgoImporterServiceException {
|
||||
checkInfoForBuild();
|
||||
createBackup();
|
||||
createMainCodeIfRequest();
|
||||
createTargetFolder();
|
||||
createDeployFolder();
|
||||
createProjectPackage();
|
||||
|
@ -128,6 +129,10 @@ public class ProjectBuilder {
|
|||
createBackupOfPackageProject();
|
||||
}
|
||||
|
||||
private void createMainCodeIfRequest() throws StatAlgoImporterServiceException {
|
||||
//TODO
|
||||
}
|
||||
|
||||
private void repackageProjectPackage()
|
||||
throws StatAlgoImporterServiceException {
|
||||
List<String> idsToExclude = new ArrayList<String>();
|
||||
|
|
|
@ -31,21 +31,17 @@ public class BuildSAIDescriptor {
|
|||
availableProjectConfigurations.add(rBlackBox);
|
||||
ProjectSetup java = new ProjectSetup("Java", ProjectSupportType.BlackBox);
|
||||
availableProjectConfigurations.add(java);
|
||||
ProjectSetup knimeWorkflow = new ProjectSetup("Knime Workflow",
|
||||
ProjectSupportType.BlackBox);
|
||||
ProjectSetup knimeWorkflow = new ProjectSetup("Knime Workflow", ProjectSupportType.BlackBox);
|
||||
availableProjectConfigurations.add(knimeWorkflow);
|
||||
ProjectSetup linuxCompiled = new ProjectSetup("Linux-compiled",
|
||||
ProjectSupportType.BlackBox);
|
||||
ProjectSetup linuxCompiled = new ProjectSetup("Linux-compiled", ProjectSupportType.BlackBox);
|
||||
availableProjectConfigurations.add(linuxCompiled);
|
||||
ProjectSetup octave = new ProjectSetup("Octave", ProjectSupportType.BlackBox);
|
||||
availableProjectConfigurations.add(octave);
|
||||
ProjectSetup python = new ProjectSetup("Python", ProjectSupportType.BlackBox);
|
||||
availableProjectConfigurations.add(python);
|
||||
ProjectSetup windowsCompiled = new ProjectSetup("Windows-compiled",
|
||||
ProjectSupportType.BlackBox);
|
||||
ProjectSetup windowsCompiled = new ProjectSetup("Windows-compiled", ProjectSupportType.BlackBox);
|
||||
availableProjectConfigurations.add(windowsCompiled);
|
||||
ProjectSetup preInstalled = new ProjectSetup("Pre-Installed",
|
||||
ProjectSupportType.BlackBox);
|
||||
ProjectSetup preInstalled = new ProjectSetup("Pre-Installed", ProjectSupportType.BlackBox);
|
||||
availableProjectConfigurations.add(preInstalled);
|
||||
saiDescriptor = new SAIDescriptor(availableProjectConfigurations);
|
||||
} else {
|
||||
|
@ -74,28 +70,28 @@ public class BuildSAIDescriptor {
|
|||
}
|
||||
} else {
|
||||
logger.info("SAIDescriptorJAXB use default configuration for scope: " + scope);
|
||||
|
||||
ProjectSetup r = new ProjectSetup("R", ProjectSupportType.REdit);
|
||||
availableProjectConfigurations.add(r);
|
||||
ProjectSetup rBlackBox = new ProjectSetup("R-black box", ProjectSupportType.BlackBox);
|
||||
availableProjectConfigurations.add(rBlackBox);
|
||||
ProjectSetup java = new ProjectSetup("Java", ProjectSupportType.BlackBox);
|
||||
availableProjectConfigurations.add(java);
|
||||
ProjectSetup knimeWorkflow = new ProjectSetup("Knime Workflow",
|
||||
ProjectSupportType.BlackBox);
|
||||
ProjectSetup knimeWorkflow = new ProjectSetup("Knime Workflow", ProjectSupportType.BlackBox);
|
||||
availableProjectConfigurations.add(knimeWorkflow);
|
||||
ProjectSetup linuxCompiled = new ProjectSetup("Linux-compiled",
|
||||
ProjectSupportType.BlackBox);
|
||||
ProjectSetup linuxCompiled = new ProjectSetup("Linux-compiled", ProjectSupportType.BlackBox);
|
||||
availableProjectConfigurations.add(linuxCompiled);
|
||||
ProjectSetup octave = new ProjectSetup("Octave", ProjectSupportType.BlackBox);
|
||||
availableProjectConfigurations.add(octave);
|
||||
ProjectSetup python = new ProjectSetup("Python", ProjectSupportType.BlackBox);
|
||||
availableProjectConfigurations.add(python);
|
||||
ProjectSetup windowsCompiled = new ProjectSetup("Windows-compiled",
|
||||
ProjectSupportType.BlackBox);
|
||||
ProjectSetup windowsCompiled = new ProjectSetup("Windows-compiled", ProjectSupportType.BlackBox);
|
||||
availableProjectConfigurations.add(windowsCompiled);
|
||||
|
||||
}
|
||||
|
||||
saiDescriptor = new SAIDescriptor(availableProjectConfigurations);
|
||||
|
||||
}
|
||||
|
||||
logger.debug("SAIDescriptor: " + saiDescriptor);
|
||||
|
|
|
@ -35,6 +35,9 @@ public class Constants {
|
|||
public static final String SAI_NAME = "SAIProfile";
|
||||
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";
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ public class SAIDescriptor implements Serializable {
|
|||
public SAIDescriptor(ArrayList<ProjectSetup> availableProjectConfigurations) {
|
||||
super();
|
||||
this.availableProjectConfigurations = availableProjectConfigurations;
|
||||
|
||||
}
|
||||
|
||||
public ArrayList<ProjectSetup> getAvailableProjectConfigurations() {
|
||||
|
|
|
@ -56,19 +56,19 @@
|
|||
name="locale" values="es" /> <set-property name="locale" value="en, it, es"
|
||||
/> <set-property-fallback name="locale" value="en" /> -->
|
||||
|
||||
|
||||
<!--
|
||||
<set-property name="log_ConsoleLogger" value="ENABLED" /> <set-property
|
||||
name="log_DivLogger" value="ENABLED" /> <set-property name="log_GWTLogger"
|
||||
value="ENABLED" /> <set-property name="log_SystemLogger" value="ENABLED"
|
||||
/>
|
||||
/> -->
|
||||
<!-- Not in GWT 2.6 <set-property name="log_FirebugLogger" value="ENABLED"
|
||||
/> -->
|
||||
|
||||
<!--
|
||||
|
||||
<set-property name="log_ConsoleLogger" value="DISABLED" />
|
||||
<set-property name="log_DivLogger" value="DISABLED" />
|
||||
<set-property name="log_GWTLogger" value="DISABLED" />
|
||||
<set-property name="log_SystemLogger" value="DISABLED" /> -->
|
||||
<set-property name="log_SystemLogger" value="DISABLED" />
|
||||
<!-- Not in GWT 2.6 <set-property name="log_FirebugLogger" value="DISABLED"
|
||||
/> -->
|
||||
|
||||
|
|
Loading…
Reference in New Issue