1452: Implement a GUI for StatMan Algorithms Importer
Task-Url: https://support.d4science.org/issues/1452 Updated Code Generation git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/statistical-algorithms-importer@122204 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
5597655c7e
commit
6e41b0e124
7
pom.xml
7
pom.xml
|
@ -277,7 +277,12 @@
|
|||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- Uri Resolver Manager -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>uri-resolver-manager</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- LOGGING -->
|
||||
|
|
|
@ -3,8 +3,8 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.client;
|
|||
import java.util.Date;
|
||||
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.DeleteItemEvent;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.InputSaveEvent;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.InputSaveReadyEvent;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.InputReadyEvent;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.InputRequestEvent;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.MainCodeSetEvent;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.SessionExpiredEvent;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.StatAlgoImporterRibbonEvent;
|
||||
|
@ -43,6 +43,14 @@ public class StatAlgoImporterController {
|
|||
private BorderLayoutContainer mainPanel;
|
||||
private ProjectManager pm;
|
||||
|
||||
|
||||
private enum InputRequestType {
|
||||
Save,
|
||||
SoftwareCreate;
|
||||
}
|
||||
private InputRequestType inputRequestType;
|
||||
|
||||
|
||||
public StatAlgoImporterController() {
|
||||
eventBus = new SimpleEventBus();
|
||||
pm = new ProjectManager(eventBus);
|
||||
|
@ -199,13 +207,13 @@ public class StatAlgoImporterController {
|
|||
|
||||
});
|
||||
|
||||
eventBus.addHandler(InputSaveReadyEvent.TYPE,
|
||||
new InputSaveReadyEvent.InputSaveReadyEventHandler() {
|
||||
eventBus.addHandler(InputReadyEvent.TYPE,
|
||||
new InputReadyEvent.InputReadyEventHandler() {
|
||||
|
||||
@Override
|
||||
public void onInputSaveReady(InputSaveReadyEvent event) {
|
||||
Log.debug("Catch InputSaveReadyEvent");
|
||||
doInputSaveReadyCommand(event);
|
||||
public void onInputReady(InputReadyEvent event) {
|
||||
Log.debug("Catch InputReadyEvent");
|
||||
doInputReadyCommand(event);
|
||||
|
||||
}
|
||||
});
|
||||
|
@ -235,6 +243,7 @@ public class StatAlgoImporterController {
|
|||
showAddResourceDialog();
|
||||
break;
|
||||
case SOFTWARE_CREATE:
|
||||
softwareCreateRequest();
|
||||
break;
|
||||
case HELP:
|
||||
break;
|
||||
|
@ -244,18 +253,37 @@ public class StatAlgoImporterController {
|
|||
}
|
||||
}
|
||||
|
||||
protected void doInputSaveReadyCommand(InputSaveReadyEvent event) {
|
||||
pm.saveProject(event.getInputData());
|
||||
private void doInputReadyCommand(InputReadyEvent event) {
|
||||
switch(inputRequestType){
|
||||
case Save:
|
||||
pm.saveProject(event.getInputData());
|
||||
break;
|
||||
case SoftwareCreate:
|
||||
pm.createSofware(event.getInputData());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void projectSaveRequest() {
|
||||
InputSaveEvent inputSaveEvent = new InputSaveEvent();
|
||||
eventBus.fireEvent(inputSaveEvent);
|
||||
Log.debug("ProjectSaveRequest: " + inputSaveEvent);
|
||||
inputRequestType=InputRequestType.Save;
|
||||
InputRequestEvent inputRequestEvent = new InputRequestEvent();
|
||||
eventBus.fireEvent(inputRequestEvent);
|
||||
Log.debug("ProjectSaveRequest: " + inputRequestEvent);
|
||||
}
|
||||
|
||||
private void softwareCreateRequest() {
|
||||
inputRequestType=InputRequestType.SoftwareCreate;
|
||||
InputRequestEvent inputRequestEvent = new InputRequestEvent();
|
||||
eventBus.fireEvent(inputRequestEvent);
|
||||
Log.debug("SoftwareCreateRequest: " + inputRequestEvent);
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void showCreateProjectDialog() {
|
||||
pm.createProject();
|
||||
|
||||
|
@ -270,6 +298,8 @@ public class StatAlgoImporterController {
|
|||
pm.addResource();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void doMainCodeSetCommand(MainCodeSetEvent event) {
|
||||
ItemDescription itemDescription = event.getItemDescription();
|
||||
if (itemDescription != null && itemDescription.getId() != null) {
|
||||
|
@ -286,6 +316,9 @@ public class StatAlgoImporterController {
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private void showCodeUploadDialog() {
|
||||
CodeUploadDialog codeUploadDialog = new CodeUploadDialog(eventBus);
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.event;
|
||||
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.InputData;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* Input Save Ready Event
|
||||
*
|
||||
*
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class InputReadyEvent extends
|
||||
GwtEvent<InputReadyEvent.InputReadyEventHandler> {
|
||||
|
||||
public static Type<InputReadyEventHandler> TYPE = new Type<InputReadyEventHandler>();
|
||||
private InputData inputData;
|
||||
|
||||
public interface InputReadyEventHandler extends EventHandler {
|
||||
void onInputReady(InputReadyEvent event);
|
||||
}
|
||||
|
||||
public interface HasInputReadyEventHandler extends HasHandlers {
|
||||
public HandlerRegistration addInputReadyEventHandler(
|
||||
InputReadyEventHandler handler);
|
||||
}
|
||||
|
||||
public InputReadyEvent(InputData inputData) {
|
||||
this.inputData = inputData;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dispatch(InputReadyEventHandler handler) {
|
||||
handler.onInputReady(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type<InputReadyEventHandler> getAssociatedType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public static Type<InputReadyEventHandler> getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public static void fire(HasHandlers source,
|
||||
InputReadyEvent inputSaveReadyEvent) {
|
||||
source.fireEvent(inputSaveReadyEvent);
|
||||
}
|
||||
|
||||
public InputData getInputData() {
|
||||
return inputData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "InputReadyEvent [inputData=" + inputData + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.event;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* Input Save Event
|
||||
*
|
||||
*
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class InputRequestEvent extends
|
||||
GwtEvent<InputRequestEvent.InputRequestEventHandler> {
|
||||
|
||||
public static Type<InputRequestEventHandler> TYPE = new Type<InputRequestEventHandler>();
|
||||
|
||||
public interface InputRequestEventHandler extends EventHandler {
|
||||
void onInputRequest(InputRequestEvent event);
|
||||
}
|
||||
|
||||
public interface HasInputRequestEventHandler extends HasHandlers {
|
||||
public HandlerRegistration addInputRequestEventHandler(
|
||||
InputRequestEventHandler handler);
|
||||
}
|
||||
|
||||
public InputRequestEvent() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dispatch(InputRequestEventHandler handler) {
|
||||
handler.onInputRequest(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type<InputRequestEventHandler> getAssociatedType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public static Type<InputRequestEventHandler> getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public static void fire(HasHandlers source, InputRequestEvent inputSaveEvent) {
|
||||
source.fireEvent(inputSaveEvent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "InputRequestEvent []";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.event;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* Input Save Event
|
||||
*
|
||||
*
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class InputSaveEvent extends
|
||||
GwtEvent<InputSaveEvent.InputSaveEventHandler> {
|
||||
|
||||
public static Type<InputSaveEventHandler> TYPE = new Type<InputSaveEventHandler>();
|
||||
|
||||
public interface InputSaveEventHandler extends EventHandler {
|
||||
void onInputSave(InputSaveEvent event);
|
||||
}
|
||||
|
||||
public interface HasInputSaveEventHandler extends HasHandlers {
|
||||
public HandlerRegistration addInputSaveEventHandler(
|
||||
InputSaveEventHandler handler);
|
||||
}
|
||||
|
||||
public InputSaveEvent() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dispatch(InputSaveEventHandler handler) {
|
||||
handler.onInputSave(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type<InputSaveEventHandler> getAssociatedType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public static Type<InputSaveEventHandler> getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public static void fire(HasHandlers source, InputSaveEvent inputSaveEvent) {
|
||||
source.fireEvent(inputSaveEvent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "InputSaveEvent []";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.event;
|
||||
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.InputData;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* Input Save Ready Event
|
||||
*
|
||||
*
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class InputSaveReadyEvent extends
|
||||
GwtEvent<InputSaveReadyEvent.InputSaveReadyEventHandler> {
|
||||
|
||||
public static Type<InputSaveReadyEventHandler> TYPE = new Type<InputSaveReadyEventHandler>();
|
||||
private InputData inputData;
|
||||
|
||||
public interface InputSaveReadyEventHandler extends EventHandler {
|
||||
void onInputSaveReady(InputSaveReadyEvent event);
|
||||
}
|
||||
|
||||
public interface HasInputSaveReadyEventHandler extends HasHandlers {
|
||||
public HandlerRegistration addInputSaveReadyEventHandler(
|
||||
InputSaveReadyEventHandler handler);
|
||||
}
|
||||
|
||||
public InputSaveReadyEvent(InputData inputData) {
|
||||
this.inputData = inputData;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dispatch(InputSaveReadyEventHandler handler) {
|
||||
handler.onInputSaveReady(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type<InputSaveReadyEventHandler> getAssociatedType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public static Type<InputSaveReadyEventHandler> getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public static void fire(HasHandlers source,
|
||||
InputSaveReadyEvent inputSaveReadyEvent) {
|
||||
source.fireEvent(inputSaveReadyEvent);
|
||||
}
|
||||
|
||||
public InputData getInputData() {
|
||||
return inputData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "InputSaveReadyEvent [inputData=" + inputData + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -58,17 +58,22 @@ public class MainDataPanel extends SimpleContainer {
|
|||
return;
|
||||
}
|
||||
switch (event.getProjectStatusEventType()) {
|
||||
case ADD_RESOURCE:
|
||||
break;
|
||||
case DELETE_RESOURCE:
|
||||
break;
|
||||
case MAIN_CODE_SET:
|
||||
codeEditPanel.codeUpdate(event.getProject());
|
||||
break;
|
||||
case OPEN:
|
||||
addCodeEditPanel(event.getProject());
|
||||
break;
|
||||
case UPDATE:
|
||||
codeEditPanel.codeUpdate(event.getProject());
|
||||
break;
|
||||
case ADD_RESOURCE:
|
||||
case DELETE_RESOURCE:
|
||||
case MAIN_CODE_SET:
|
||||
case SAVE:
|
||||
break;
|
||||
case START:
|
||||
break;
|
||||
case UPDATE:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ public class ProjectManager {
|
|||
public void onSelectedItem(Item item) {
|
||||
|
||||
if (item.getType() == ItemType.FOLDER) {
|
||||
openProjectOnServer(item);
|
||||
createProjectOnServer(item);
|
||||
|
||||
} else {
|
||||
UtilsGXT3.info("Attention",
|
||||
|
@ -315,36 +315,72 @@ public class ProjectManager {
|
|||
});
|
||||
}
|
||||
|
||||
public void setMainCode(final ItemDescription itemDescription) {
|
||||
if(project!=null&& project.getMainCode()!=null&& project.getMainCode().getItemDescription()!=null){
|
||||
final ConfirmMessageBox mb = new ConfirmMessageBox("Attention",
|
||||
"All previous configurations will be lost. Would you like to change main code?");
|
||||
mb.addDialogHideHandler(new DialogHideHandler() {
|
||||
public void createSofware(InputData inputData) {
|
||||
Log.debug("Create Software: " + inputData);
|
||||
|
||||
StatAlgoImporterServiceAsync.INSTANCE.createSoftware(inputData,
|
||||
new AsyncCallback<Void>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(Void result) {
|
||||
fireProjectStatusSoftwareCreatedEvent();
|
||||
UtilsGXT3.info("Create Software", "Software Created!");
|
||||
|
||||
@Override
|
||||
public void onDialogHide(DialogHideEvent event) {
|
||||
switch (event.getHideButton()) {
|
||||
case NO:
|
||||
break;
|
||||
case YES:
|
||||
setMainCodeOnServer(itemDescription);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
mb.setWidth(300);
|
||||
mb.show();
|
||||
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
if (caught instanceof StatAlgoImporterSessionExpiredException) {
|
||||
eventBus.fireEvent(new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
Log.error("Error in create software: "
|
||||
+ caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error",
|
||||
caught.getLocalizedMessage());
|
||||
}
|
||||
caught.printStackTrace();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void setMainCodeOnServer(final ItemDescription itemDescription){
|
||||
public void setMainCode(final ItemDescription itemDescription) {
|
||||
if (project != null) {
|
||||
if (project.getMainCode() != null
|
||||
&& project.getMainCode().getItemDescription() != null) {
|
||||
final ConfirmMessageBox mb = new ConfirmMessageBox("Attention",
|
||||
"All previous configurations will be lost. Would you like to change main code?");
|
||||
mb.addDialogHideHandler(new DialogHideHandler() {
|
||||
|
||||
@Override
|
||||
public void onDialogHide(DialogHideEvent event) {
|
||||
switch (event.getHideButton()) {
|
||||
case NO:
|
||||
break;
|
||||
case YES:
|
||||
setMainCodeOnServer(itemDescription);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
mb.setWidth(300);
|
||||
mb.show();
|
||||
} else {
|
||||
setMainCodeOnServer(itemDescription);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void setMainCodeOnServer(final ItemDescription itemDescription) {
|
||||
|
||||
Log.debug("Set Main Code: " + itemDescription);
|
||||
StatAlgoImporterServiceAsync.INSTANCE.setMainCode(itemDescription,
|
||||
|
@ -428,7 +464,6 @@ public class ProjectManager {
|
|||
}
|
||||
|
||||
protected void fireProjectStatusDeleteEvent() {
|
||||
// TODO Auto-generated method stub
|
||||
ProjectStatusEvent projectStatusEvent = new ProjectStatusEvent(
|
||||
ProjectStatusEventType.DELETE_RESOURCE, project);
|
||||
eventBus.fireEvent(projectStatusEvent);
|
||||
|
@ -449,6 +484,13 @@ public class ProjectManager {
|
|||
Log.debug("ProjectStatusEvent fired! " + projectStatusEvent);
|
||||
}
|
||||
|
||||
protected void fireProjectStatusSoftwareCreatedEvent() {
|
||||
ProjectStatusEvent projectStatusEvent = new ProjectStatusEvent(
|
||||
ProjectStatusEventType.SOFTWARE_CREATED, project);
|
||||
eventBus.fireEvent(projectStatusEvent);
|
||||
Log.debug("ProjectStatusEvent fired! " + projectStatusEvent);
|
||||
}
|
||||
|
||||
|
||||
protected void fireProjectStatusStartEvent() {
|
||||
ProjectStatusEvent projectStatusEvent = new ProjectStatusEvent(
|
||||
|
|
|
@ -64,6 +64,6 @@ public interface StatAlgoImporterService extends RemoteService {
|
|||
|
||||
public void saveCode(String code) throws StatAlgoImporterServiceException;
|
||||
|
||||
public void createAlgorithm() throws StatAlgoImporterServiceException;
|
||||
public void createSoftware(InputData inputData) throws StatAlgoImporterServiceException;
|
||||
|
||||
}
|
||||
|
|
|
@ -55,6 +55,6 @@ public interface StatAlgoImporterServiceAsync {
|
|||
|
||||
void saveCode(String code, AsyncCallback<Void> asyncCallback);
|
||||
|
||||
void createAlgorithm(AsyncCallback<Void> callback);
|
||||
void createSoftware(InputData inputData, AsyncCallback<Void> callback);
|
||||
|
||||
}
|
||||
|
|
|
@ -116,6 +116,8 @@ public class ExplorerProjectPanel extends ContentPanel {
|
|||
break;
|
||||
case MAIN_CODE_SET:
|
||||
break;
|
||||
case SOFTWARE_CREATED:
|
||||
reloadWSResourceExplorerPanel();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -242,7 +244,7 @@ public class ExplorerProjectPanel extends ContentPanel {
|
|||
|
||||
@Override
|
||||
public void onSelect(SelectEvent event) {
|
||||
reloadWSResourceExplorerPanel(event);
|
||||
reloadWSResourceExplorerPanel();
|
||||
}
|
||||
|
||||
|
||||
|
@ -270,7 +272,7 @@ public class ExplorerProjectPanel extends ContentPanel {
|
|||
}
|
||||
}
|
||||
|
||||
protected void reloadWSResourceExplorerPanel(SelectEvent event) {
|
||||
protected void reloadWSResourceExplorerPanel() {
|
||||
if(wsResourcesExplorerPanel!=null){
|
||||
wsResourcesExplorerPanel.refreshRootFolderView();
|
||||
}
|
||||
|
|
|
@ -20,5 +20,9 @@ public interface InputVariableMessages extends Messages {
|
|||
@DefaultMessage("Interpreter")
|
||||
String interpreterInfo();
|
||||
|
||||
@DefaultMessage("Info")
|
||||
String projectInfo();
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.tools.input;
|
||||
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.InputSaveEvent;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.InputRequestEvent;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.NewSelectedRowsVariableEvent;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.ProjectStatusEvent;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.SelectedRowsVariables;
|
||||
|
@ -67,13 +67,13 @@ public class InputVariablePanel extends ContentPanel {
|
|||
}
|
||||
});
|
||||
|
||||
eventBus.addHandler(InputSaveEvent.TYPE,
|
||||
new InputSaveEvent.InputSaveEventHandler() {
|
||||
eventBus.addHandler(InputRequestEvent.TYPE,
|
||||
new InputRequestEvent.InputRequestEventHandler() {
|
||||
|
||||
@Override
|
||||
public void onInputSave(InputSaveEvent event) {
|
||||
Log.debug("Catch InputSaveEvent");
|
||||
manageInputSaveEvents(event);
|
||||
public void onInputRequest(InputRequestEvent event) {
|
||||
Log.debug("Catch InputRequestEvent");
|
||||
manageInputRequestEvents(event);
|
||||
|
||||
}
|
||||
});
|
||||
|
@ -102,9 +102,8 @@ public class InputVariablePanel extends ContentPanel {
|
|||
|
||||
}
|
||||
|
||||
protected void manageInputSaveEvents(InputSaveEvent event) {
|
||||
inputVariableTabPanel.saveInput();
|
||||
|
||||
protected void manageInputRequestEvents(InputRequestEvent event) {
|
||||
inputVariableTabPanel.requestInput();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.tools.input;
|
||||
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.InputSaveReadyEvent;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.InputReadyEvent;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.SelectedRowsVariables;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.InputData;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project;
|
||||
|
@ -25,6 +25,7 @@ public class InputVariableTabPanel extends TabPanel {
|
|||
private EnvironmentVariablesPanel enviromentVariablesPanel;
|
||||
private SelectedRowsPanel selectedRowsPanel;
|
||||
private InterpreterInfoPanel interpreterInfoPanel;
|
||||
private ProjectInfoPanel projectInfoPanel;
|
||||
|
||||
public InputVariableTabPanel(EventBus eventBus,
|
||||
InputVariablePanel toolBoxPanel) {
|
||||
|
@ -50,6 +51,7 @@ public class InputVariableTabPanel extends TabPanel {
|
|||
addEnvironmentVariablesPanel(project);
|
||||
addSelectedRowsPanel(project);
|
||||
addInterpreterInfoPanel(project);
|
||||
addProjectInfoPanel(project);
|
||||
setActiveWidget(getWidget(0));
|
||||
|
||||
}
|
||||
|
@ -92,7 +94,7 @@ public class InputVariableTabPanel extends TabPanel {
|
|||
enviromentVariablesPanel.update(project);
|
||||
selectedRowsPanel.update(project);
|
||||
interpreterInfoPanel.update(project);
|
||||
|
||||
projectInfoPanel.update(project);
|
||||
forceLayout();
|
||||
} catch (Throwable e) {
|
||||
Log.error("Error in InputVariableTabPanel: "
|
||||
|
@ -101,27 +103,33 @@ public class InputVariableTabPanel extends TabPanel {
|
|||
}
|
||||
}
|
||||
|
||||
public void saveInput() {
|
||||
InputData inputVariables = new InputData();
|
||||
public void requestInput() {
|
||||
InputData inputData = new InputData();
|
||||
if (enviromentVariablesPanel != null) {
|
||||
inputVariables.setListEnvironmentVariables(enviromentVariablesPanel
|
||||
inputData.setListEnvironmentVariables(enviromentVariablesPanel
|
||||
.getEnvironmentVariables());
|
||||
}
|
||||
|
||||
if (selectedRowsPanel != null) {
|
||||
inputVariables.setListSelectedRows(selectedRowsPanel
|
||||
inputData.setListSelectedRows(selectedRowsPanel
|
||||
.getSelectedRows());
|
||||
}
|
||||
|
||||
if (interpreterInfoPanel != null) {
|
||||
inputVariables.setInterpreterInfo(interpreterInfoPanel
|
||||
inputData.setInterpreterInfo(interpreterInfoPanel
|
||||
.getInterpreterInfo());
|
||||
}
|
||||
|
||||
InputSaveReadyEvent inputSaveReadyEvent = new InputSaveReadyEvent(
|
||||
inputVariables);
|
||||
eventBus.fireEvent(inputSaveReadyEvent);
|
||||
Log.debug("Fired InputSaveReadyEvent");
|
||||
if (projectInfoPanel != null) {
|
||||
inputData.setProjectInfo(projectInfoPanel
|
||||
.getProjectInfo());
|
||||
}
|
||||
|
||||
|
||||
InputReadyEvent inputReadyEvent = new InputReadyEvent(
|
||||
inputData);
|
||||
eventBus.fireEvent(inputReadyEvent);
|
||||
Log.debug("Fired InputReadyEvent");
|
||||
|
||||
}
|
||||
|
||||
|
@ -156,6 +164,17 @@ public class InputVariableTabPanel extends TabPanel {
|
|||
|
||||
}
|
||||
|
||||
private void addProjectInfoPanel(Project project) {
|
||||
TabItemConfig projectInfoPanelItemConf = new TabItemConfig(
|
||||
msgs.projectInfo(), false);
|
||||
|
||||
projectInfoPanel = new ProjectInfoPanel(project, eventBus);
|
||||
projectInfoPanel.setHeaderVisible(false);
|
||||
add(projectInfoPanel, projectInfoPanelItemConf);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void addSelectedRowsVariable(
|
||||
SelectedRowsVariables selectedRowsVariable) {
|
||||
setActiveWidget(selectedRowsPanel);
|
||||
|
|
|
@ -0,0 +1,141 @@
|
|||
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.tools.input;
|
||||
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.ProjectInfo;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.event.shared.EventBus;
|
||||
import com.sencha.gxt.core.client.dom.ScrollSupport.ScrollMode;
|
||||
import com.sencha.gxt.core.client.util.Margins;
|
||||
import com.sencha.gxt.widget.core.client.ContentPanel;
|
||||
import com.sencha.gxt.widget.core.client.container.MarginData;
|
||||
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
|
||||
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
|
||||
import com.sencha.gxt.widget.core.client.form.FieldLabel;
|
||||
import com.sencha.gxt.widget.core.client.form.TextField;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author giancarlo email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ProjectInfoPanel extends ContentPanel {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private EventBus eventBus;
|
||||
private TextField projectName;
|
||||
private TextField projectDescription;
|
||||
private TextField projectClassName;
|
||||
|
||||
public ProjectInfoPanel(Project project, EventBus eventBus) {
|
||||
super();
|
||||
Log.debug("ProjectInfoPanel");
|
||||
this.eventBus = eventBus;
|
||||
|
||||
// msgs = GWT.create(ServiceCategoryMessages.class);
|
||||
try {
|
||||
init();
|
||||
create(project);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void init() {
|
||||
setHeaderVisible(false);
|
||||
setResize(true);
|
||||
setBodyBorder(false);
|
||||
setBorders(false);
|
||||
forceLayoutOnResize = true;
|
||||
}
|
||||
|
||||
private void create(Project project) {
|
||||
|
||||
projectName = new TextField();
|
||||
projectName.setAllowBlank(false);
|
||||
projectName.setEmptyText("Enter name...");
|
||||
FieldLabel projectNameLabel = new FieldLabel(projectName, "Name");
|
||||
|
||||
projectDescription = new TextField();
|
||||
projectDescription.setAllowBlank(false);
|
||||
projectDescription.setEmptyText("Enter description...");
|
||||
FieldLabel projectDescriptionLabel = new FieldLabel(projectDescription,
|
||||
"Description");
|
||||
|
||||
projectClassName = new TextField();
|
||||
projectClassName.setAllowBlank(false);
|
||||
projectClassName.setEmptyText("Enter class name...");
|
||||
FieldLabel projectClassNameLabel = new FieldLabel(projectClassName,
|
||||
"Class Name");
|
||||
|
||||
if (project != null && project.getInputData()!=null && project.getInputData().getProjectInfo() != null) {
|
||||
|
||||
if (project.getInputData().getProjectInfo().getName() != null) {
|
||||
projectName.setValue(project.getInputData().getProjectInfo().getName());
|
||||
}
|
||||
if (project.getInputData().getProjectInfo().getDescription() != null) {
|
||||
projectDescription.setValue(project.getInputData().getProjectInfo()
|
||||
.getDescription());
|
||||
}
|
||||
if (project.getInputData().getProjectInfo().getClassName() != null) {
|
||||
projectClassName.setValue(project.getInputData().getProjectInfo()
|
||||
.getClassName());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
VerticalLayoutContainer vlc = new VerticalLayoutContainer();
|
||||
vlc.setAdjustForScroll(false);
|
||||
vlc.setScrollMode(ScrollMode.NONE);
|
||||
|
||||
vlc.add(projectNameLabel, new VerticalLayoutData(1, -1, new Margins(5,
|
||||
0, 5, 0)));
|
||||
vlc.add(projectDescriptionLabel, new VerticalLayoutData(1, -1,
|
||||
new Margins(5, 0, 5, 0)));
|
||||
vlc.add(projectClassNameLabel, new VerticalLayoutData(1, -1,
|
||||
new Margins(5, 0, 5, 0)));
|
||||
|
||||
add(vlc, new MarginData(new Margins(0)));
|
||||
|
||||
}
|
||||
|
||||
public void update(Project project) {
|
||||
Log.debug("Update Project Info: " + project);
|
||||
if (project != null && project.getInputData()!=null && project.getInputData().getProjectInfo() != null) {
|
||||
|
||||
if (project.getInputData().getProjectInfo().getName() != null) {
|
||||
projectName.setValue(project.getInputData().getProjectInfo().getName());
|
||||
} else {
|
||||
projectName.clear();
|
||||
}
|
||||
if (project.getInputData().getProjectInfo().getDescription() != null) {
|
||||
projectDescription.setValue(project.getInputData().getProjectInfo()
|
||||
.getDescription());
|
||||
} else {
|
||||
projectDescription.clear();
|
||||
}
|
||||
if (project.getInputData().getProjectInfo().getClassName() != null) {
|
||||
projectClassName.setValue(project.getInputData().getProjectInfo()
|
||||
.getClassName());
|
||||
} else {
|
||||
projectClassName.clear();
|
||||
}
|
||||
|
||||
} else {
|
||||
projectName.clear();
|
||||
projectDescription.clear();
|
||||
projectClassName.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public ProjectInfo getProjectInfo() {
|
||||
String name = projectName.getCurrentValue();
|
||||
String description = projectDescription.getCurrentValue();
|
||||
String className = projectClassName.getCurrentValue();
|
||||
|
||||
return new ProjectInfo(name, description, className);
|
||||
|
||||
}
|
||||
}
|
|
@ -13,6 +13,8 @@ public enum ProjectStatusEventType {
|
|||
UPDATE,
|
||||
ADD_RESOURCE,
|
||||
DELETE_RESOURCE,
|
||||
SOFTWARE_CREATED,
|
||||
SAVE;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -355,14 +355,16 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
|
||||
@Override
|
||||
public void createAlgorithm() throws StatAlgoImporterServiceException {
|
||||
public void createSoftware(InputData inputData) throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
logger.debug("createAlgorithm()");
|
||||
logger.debug("createSoftware(): "+inputData);
|
||||
Project project = SessionUtil.getProjectSession(session);
|
||||
if (project != null) {
|
||||
ProjectBuilder projectBuilder=new ProjectBuilder(project, aslSession);
|
||||
project.setInputData(inputData);
|
||||
SessionUtil.setProjectSession(session,project);
|
||||
ProjectBuilder projectBuilder=new ProjectBuilder(project, aslSession, session);
|
||||
projectBuilder.build();
|
||||
} else {
|
||||
throw new StatAlgoImporterServiceException("No project open!");
|
||||
|
@ -373,7 +375,7 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
e.printStackTrace();
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
logger.error("createAlgorithm(): " + e.getLocalizedMessage(), e);
|
||||
logger.error("createSoftware(): " + e.getLocalizedMessage(), e);
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.nio.charset.Charset;
|
|||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -43,8 +44,8 @@ public class AlgorithmGenerator {
|
|||
public Path createAlgorithm() throws StatAlgoImporterServiceException {
|
||||
|
||||
try {
|
||||
Path tempFile = Files.createTempFile(project.getClassName(),
|
||||
EXTENTION_JAVA);
|
||||
Path tempFile = Files.createTempFile(project.getInputData()
|
||||
.getProjectInfo().getClassName(), EXTENTION_JAVA);
|
||||
|
||||
List<String> lines = createJavaCode();
|
||||
Files.write(tempFile, lines, Charset.defaultCharset(),
|
||||
|
@ -65,7 +66,9 @@ public class AlgorithmGenerator {
|
|||
String mainScriptRelativePath = retrieveMainScriptRelativePath();
|
||||
String packageUrl = retrievePackageUrl();
|
||||
|
||||
List<String> code = Arrays
|
||||
ArrayList<String> code = new ArrayList<String>();
|
||||
|
||||
code.addAll(Arrays
|
||||
.asList("package org.gcube.dataanalysis.executor.rscripts;",
|
||||
"",
|
||||
"import java.io.File;",
|
||||
|
@ -75,24 +78,26 @@ public class AlgorithmGenerator {
|
|||
"import org.gcube.dataanalysis.ecoengine.datatypes.StatisticalType;",
|
||||
"import org.gcube.dataanalysis.ecoengine.datatypes.enumtypes.PrimitiveTypes;",
|
||||
"import org.gcube.dataanalysis.executor.rscripts.generic.GenericRScript;",
|
||||
"", "public class " + project.getClassName()
|
||||
"", "public class "
|
||||
+ project.getInputData().getProjectInfo()
|
||||
.getClassName()
|
||||
+ " extends GenericRScript {", "",
|
||||
|
||||
" public static enum operators {",
|
||||
" EQUAL, NOT_EQUAL, CONTAINS, BEGINS_WITH, ENDS_WITH",
|
||||
" };",
|
||||
|
||||
" @Override", " public String getDescription() {",
|
||||
" return \"" + project.getDescription() + "\";", " }",
|
||||
"", " protected void initVariables(){",
|
||||
" };", "", " @Override",
|
||||
" public String getDescription() {", " return \""
|
||||
+ project.getInputData().getProjectInfo()
|
||||
.getDescription() + "\";", " }", "",
|
||||
" protected void initVariables(){",
|
||||
" mainScriptName=\"" + mainScriptRelativePath + "\";",
|
||||
" packageURL=\"" + packageUrl + "\";",
|
||||
" environmentalvariables = new ArrayList<String>();");
|
||||
" environmentalvariables = new ArrayList<String>();"));
|
||||
|
||||
for (EnvironmentVariables envVariable : project.getInputData()
|
||||
.getListEnvironmentVariables()) {
|
||||
code.add(" environmentalvariables.add(\"" + envVariable.getName()
|
||||
+ "\")");
|
||||
+ "\");");
|
||||
}
|
||||
|
||||
for (SelectedRowsVariables selVariable : project.getInputData()
|
||||
|
@ -100,11 +105,11 @@ public class AlgorithmGenerator {
|
|||
switch (selVariable.getIoType()) {
|
||||
case INPUT:
|
||||
code.add(" inputvariables.add(\"" + selVariable.getName()
|
||||
+ "\")");
|
||||
+ "\");");
|
||||
break;
|
||||
case OUTPUT:
|
||||
code.add(" outputvariables.add(\"" + selVariable.getName()
|
||||
+ "\")");
|
||||
+ "\");");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -113,11 +118,13 @@ public class AlgorithmGenerator {
|
|||
}
|
||||
|
||||
code.add(" }");
|
||||
code.add("");
|
||||
code.add(" @Override");
|
||||
code.add(" protected void setInputParameters() {");
|
||||
createInputParameters(code);
|
||||
|
||||
code.add(" }");
|
||||
code.add("");
|
||||
code.add(" @Override");
|
||||
code.add(" public StatisticalType getOutput() {");
|
||||
createOutputParameters(code);
|
||||
|
@ -128,7 +135,7 @@ public class AlgorithmGenerator {
|
|||
return code;
|
||||
}
|
||||
|
||||
private void createInputParameters(List<String> code) {
|
||||
private void createInputParameters(ArrayList<String> code) {
|
||||
|
||||
for (SelectedRowsVariables selVariable : project.getInputData()
|
||||
.getListSelectedRows()) {
|
||||
|
@ -200,7 +207,7 @@ public class AlgorithmGenerator {
|
|||
* STRING, NUMBER, ENUMERATED, CONSTANT, RANDOM, FILE, MAP, BOOLEAN, IMAGES
|
||||
*/
|
||||
|
||||
private void createOutputParameters(List<String> code) {
|
||||
private void createOutputParameters(ArrayList<String> code) {
|
||||
for (SelectedRowsVariables selVariable : project.getInputData()
|
||||
.getListSelectedRows()) {
|
||||
if (selVariable.getIoType().compareTo(IOType.OUTPUT) == 0) {
|
||||
|
@ -268,11 +275,24 @@ public class AlgorithmGenerator {
|
|||
.getPath();
|
||||
String mainCodePath = project.getMainCode().getItemDescription()
|
||||
.getPath();
|
||||
return mainCodePath.substring(projectPath.length());
|
||||
|
||||
String relativePath = project.getProjectFolder().getItemDescription()
|
||||
.getName()
|
||||
+ mainCodePath.substring(projectPath.length());
|
||||
return relativePath;
|
||||
|
||||
}
|
||||
|
||||
private String retrievePackageUrl() {
|
||||
return project.getProjectTarget().getPackageUrl().getPublicLink();
|
||||
String packageUrl = "";
|
||||
if (project.getProjectTarget() != null
|
||||
&& project.getProjectTarget().getPackageUrl() != null) {
|
||||
if (project.getProjectTarget().getPackageUrl().getPublicLink() != null) {
|
||||
packageUrl = project.getProjectTarget().getPackageUrl()
|
||||
.getPublicLink();
|
||||
}
|
||||
}
|
||||
return packageUrl;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,87 @@
|
|||
package org.gcube.portlets.user.statisticalalgorithmsimporter.server.generator;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterServiceException;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.InterpreterPackageInfo;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class IntegrationInfoGenerator {
|
||||
private static final String EXTENTION_JAVA = ".txt";
|
||||
public static final Logger logger = LoggerFactory
|
||||
.getLogger(IntegrationInfoGenerator.class);
|
||||
|
||||
private Project project;
|
||||
|
||||
public IntegrationInfoGenerator(Project project) {
|
||||
super();
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "IntegrationInfoGenerator [project=" + project + "]";
|
||||
}
|
||||
|
||||
public Path createIntegrationInfo() throws StatAlgoImporterServiceException {
|
||||
|
||||
try {
|
||||
Path tempFile = Files.createTempFile(project.getInputData()
|
||||
.getProjectInfo().getClassName(), EXTENTION_JAVA);
|
||||
|
||||
List<String> lines = createInfo();
|
||||
Files.write(tempFile, lines, Charset.defaultCharset(),
|
||||
StandardOpenOption.WRITE);
|
||||
logger.debug(tempFile.toString());
|
||||
return tempFile;
|
||||
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(e.getLocalizedMessage(),
|
||||
e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private List<String> createInfo() {
|
||||
ArrayList<String> infos = new ArrayList<String>();
|
||||
if (project.getInputData().getInterpreterInfo() != null) {
|
||||
if (project.getInputData().getInterpreterInfo().getVersion() != null) {
|
||||
infos.add("Interpreter Version: "
|
||||
+ project.getInputData().getInterpreterInfo()
|
||||
.getVersion());
|
||||
} else {
|
||||
infos.add("Interpreter Version: Any");
|
||||
}
|
||||
infos.add("");
|
||||
if (project.getInputData().getInterpreterInfo()
|
||||
.getInterpreterPackagesInfo() != null
|
||||
&& project.getInputData().getInterpreterInfo()
|
||||
.getInterpreterPackagesInfo().size() > 0) {
|
||||
infos.add("Packages:");
|
||||
for (InterpreterPackageInfo info : project.getInputData()
|
||||
.getInterpreterInfo().getInterpreterPackagesInfo()) {
|
||||
infos.add("" + info.getName() + " " + info.getVersion());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return infos;
|
||||
}
|
||||
}
|
|
@ -1,14 +1,24 @@
|
|||
package org.gcube.portlets.user.statisticalalgorithmsimporter.server.generator;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.gcube.application.framework.core.session.ASLSession;
|
||||
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
|
||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.SessionUtil;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.storage.FilesStorage;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterServiceException;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.ProjectTarget;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.workspace.ItemDescription;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -22,29 +32,92 @@ public class ProjectBuilder {
|
|||
private static final String ALGORITHM_MIMETYPE = "text/plain";
|
||||
private static final String ALGORITHM_DESCRIPTION = "Statistical Algorithm Java Code";
|
||||
private static final String ALGORITHM_EXTENTION = ".java";
|
||||
private static final String INTEGRATION_INFO_NAME = "IntegrationInfo";
|
||||
private static final String INTEGRATION_INFO_MIMETYPE = "text/plain";
|
||||
private static final String INTEGRATION_INFO_DESCRIPTION = "Integration Info";
|
||||
private static final String INTEGRATION_INFO_EXTENTION = ".txt";
|
||||
private static final String PROJECT_PACKAGE_MIMETYPE = "application/zip";
|
||||
private static final String PROJECT_PACKAGE_DESCRIPTION = "Statical Algorithm Project Package";
|
||||
private static final String PROJECT_PACKAGE_EXTENTION = ".zip";
|
||||
|
||||
public static final Logger logger = LoggerFactory
|
||||
.getLogger(ProjectBuilder.class);
|
||||
|
||||
private Project project;
|
||||
private ASLSession aslSession;
|
||||
private HttpSession session;
|
||||
private ProjectTarget projectTarget;
|
||||
|
||||
public ProjectBuilder(Project project, ASLSession aslSession) {
|
||||
public ProjectBuilder(Project project, ASLSession aslSession,
|
||||
HttpSession session) {
|
||||
this.project = project;
|
||||
this.aslSession = aslSession;
|
||||
this.session = session;
|
||||
}
|
||||
|
||||
private void checkInfo() throws StatAlgoImporterServiceException {
|
||||
if (project == null) {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"Attention No Project Found!");
|
||||
}
|
||||
|
||||
if (project.getProjectFolder() == null) {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"Attention No Project Folder Found!");
|
||||
}
|
||||
|
||||
if (project.getInputData() == null) {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"Attention No Input Set!");
|
||||
}
|
||||
|
||||
if (project.getInputData().getProjectInfo() == null) {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"Attention No Project Information Set!");
|
||||
}
|
||||
|
||||
if (project.getInputData().getProjectInfo().getClassName() == null) {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"Attention No Project Class Name Set!");
|
||||
}
|
||||
|
||||
if (project.getMainCode() == null) {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"Attention No Main Code Set");
|
||||
}
|
||||
|
||||
if (project.getInputData() == null) {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"Attention No Input Data Set!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void build() throws StatAlgoImporterServiceException {
|
||||
checkInfo();
|
||||
createProjectPackage();
|
||||
createAlgorithm();
|
||||
createIntegrationInfo();
|
||||
|
||||
SessionUtil.setProjectSession(session, project);
|
||||
|
||||
}
|
||||
|
||||
protected void createAlgorithm() throws StatAlgoImporterServiceException {
|
||||
AlgorithmGenerator algorithmGenerator = new AlgorithmGenerator(project);
|
||||
Path algorithm = algorithmGenerator.createAlgorithm();
|
||||
|
||||
FilesStorage filesStorage = new FilesStorage();
|
||||
WorkspaceItem algorithmItem;
|
||||
|
||||
try {
|
||||
filesStorage.saveItemOnWorkspace(aslSession.getUsername(),
|
||||
algorithmItem = filesStorage.createItemOnWorkspace(
|
||||
aslSession.getUsername(),
|
||||
Files.newInputStream(algorithm, StandardOpenOption.READ),
|
||||
project.getClassName() + ALGORITHM_EXTENTION,
|
||||
ALGORITHM_DESCRIPTION, ALGORITHM_MIMETYPE, project
|
||||
.getProjectFolder().getItemDescription().getId());
|
||||
project.getInputData().getProjectInfo().getClassName()
|
||||
+ ALGORITHM_EXTENTION, ALGORITHM_DESCRIPTION,
|
||||
ALGORITHM_MIMETYPE, project.getProjectTarget()
|
||||
.getTargetFolder().getId());
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
|
@ -52,6 +125,142 @@ public class ProjectBuilder {
|
|||
e);
|
||||
}
|
||||
|
||||
ItemDescription codeSource;
|
||||
try {
|
||||
codeSource = new ItemDescription(algorithmItem.getId(),
|
||||
algorithmItem.getName(), algorithmItem.getOwner()
|
||||
.getPortalLogin(), algorithmItem.getPath(),
|
||||
algorithmItem.getType().name());
|
||||
codeSource.setPublicLink(algorithmItem.getPublicLink(true));
|
||||
} catch (InternalErrorException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
|
||||
|
||||
}
|
||||
|
||||
projectTarget.setCodeSource(codeSource);
|
||||
logger.debug("ProjectTarget: " + projectTarget);
|
||||
project.setProjectTarget(projectTarget);
|
||||
|
||||
}
|
||||
|
||||
private void createProjectPackage() throws StatAlgoImporterServiceException {
|
||||
FilesStorage filesStorage = new FilesStorage();
|
||||
filesStorage.deleteTargetFolder(aslSession.getUsername(), project
|
||||
.getProjectFolder().getItemDescription().getId());
|
||||
|
||||
File projectPackageFile = filesStorage.zipFolder(
|
||||
aslSession.getUsername(), project.getProjectFolder()
|
||||
.getItemDescription().getId());
|
||||
|
||||
WorkspaceFolder targetFolder = filesStorage.createTargetFolder(
|
||||
aslSession.getUsername(), project.getProjectFolder()
|
||||
.getItemDescription().getId());
|
||||
logger.debug("TargetFolder:" + targetFolder);
|
||||
|
||||
ItemDescription tFolder;
|
||||
try {
|
||||
tFolder = new ItemDescription(targetFolder.getId(),
|
||||
targetFolder.getName(), targetFolder.getOwner()
|
||||
.getPortalLogin(), targetFolder.getPath(),
|
||||
targetFolder.getType().name());
|
||||
} catch (InternalErrorException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
|
||||
|
||||
}
|
||||
projectTarget = new ProjectTarget(tFolder);
|
||||
|
||||
InputStream inputStream;
|
||||
try {
|
||||
inputStream = Files.newInputStream(projectPackageFile.toPath(),
|
||||
StandardOpenOption.READ);
|
||||
} catch (IOException e) {
|
||||
logger.error("Error input stream generation: "
|
||||
+ e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
WorkspaceItem projectPackageItem;
|
||||
try {
|
||||
projectPackageItem = filesStorage.createItemOnWorkspace(
|
||||
aslSession.getUsername(), inputStream, project
|
||||
.getInputData().getProjectInfo().getClassName()
|
||||
+ PROJECT_PACKAGE_EXTENTION,
|
||||
PROJECT_PACKAGE_DESCRIPTION, PROJECT_PACKAGE_MIMETYPE,
|
||||
targetFolder.getId());
|
||||
} catch (InternalErrorException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
|
||||
|
||||
}
|
||||
|
||||
logger.debug("ProjectPackageItem:" + projectPackageItem);
|
||||
ItemDescription packageUrl;
|
||||
try {
|
||||
packageUrl = new ItemDescription(projectPackageItem.getId(),
|
||||
projectPackageItem.getName(), projectPackageItem.getOwner()
|
||||
.getPortalLogin(), projectPackageItem.getPath(),
|
||||
projectPackageItem.getType().name());
|
||||
packageUrl.setPublicLink(projectPackageItem.getPublicLink(true));
|
||||
} catch (InternalErrorException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
|
||||
|
||||
}
|
||||
|
||||
projectTarget.setPackageUrl(packageUrl);
|
||||
project.setProjectTarget(projectTarget);
|
||||
|
||||
}
|
||||
|
||||
private void createIntegrationInfo()
|
||||
throws StatAlgoImporterServiceException {
|
||||
IntegrationInfoGenerator integrationInfoGenerator = new IntegrationInfoGenerator(
|
||||
project);
|
||||
Path infoFile = integrationInfoGenerator.createIntegrationInfo();
|
||||
|
||||
FilesStorage filesStorage = new FilesStorage();
|
||||
WorkspaceItem infoItem;
|
||||
|
||||
try {
|
||||
infoItem = filesStorage.createItemOnWorkspace(
|
||||
aslSession.getUsername(),
|
||||
Files.newInputStream(infoFile, StandardOpenOption.READ),
|
||||
INTEGRATION_INFO_NAME
|
||||
+ INTEGRATION_INFO_EXTENTION, INTEGRATION_INFO_DESCRIPTION,
|
||||
INTEGRATION_INFO_MIMETYPE, project.getProjectTarget()
|
||||
.getTargetFolder().getId());
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(e.getLocalizedMessage(),
|
||||
e);
|
||||
}
|
||||
|
||||
ItemDescription integrationItemDescription;
|
||||
try {
|
||||
integrationItemDescription = new ItemDescription(infoItem.getId(),
|
||||
infoItem.getName(), infoItem.getOwner().getPortalLogin(),
|
||||
infoItem.getPath(), infoItem.getType().name());
|
||||
integrationItemDescription.setPublicLink(infoItem
|
||||
.getPublicLink(true));
|
||||
} catch (InternalErrorException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
|
||||
|
||||
}
|
||||
|
||||
projectTarget.setIntegrationInfo(integrationItemDescription);
|
||||
logger.debug("ProjectTarget: " + projectTarget);
|
||||
project.setProjectTarget(projectTarget);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package org.gcube.portlets.user.statisticalalgorithmsimporter.server.storage;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URLConnection;
|
||||
|
||||
|
@ -8,6 +10,7 @@ import org.gcube.common.homelibrary.home.HomeLibrary;
|
|||
import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
|
||||
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
|
||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
||||
import org.gcube.common.homelibrary.home.workspace.exceptions.InsufficientPrivilegesException;
|
||||
import org.gcube.common.homelibrary.home.workspace.exceptions.ItemAlreadyExistException;
|
||||
|
@ -15,6 +18,8 @@ import org.gcube.common.homelibrary.home.workspace.exceptions.ItemNotFoundExcept
|
|||
import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
|
||||
import org.gcube.common.homelibrary.home.workspace.exceptions.WrongDestinationException;
|
||||
import org.gcube.common.homelibrary.home.workspace.exceptions.WrongItemTypeException;
|
||||
import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalFile;
|
||||
import org.gcube.common.homelibrary.util.zip.ZipUtil;
|
||||
import org.gcube.contentmanager.storageclient.model.protocol.smp.SMPUrl;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterServiceException;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -32,6 +37,7 @@ public class FilesStorage {
|
|||
private static final String STATISTICAL_ALGORITHM_PROJECT_MIMETYPE = "text/xml";
|
||||
private static final String STATISTICAL_ALGORITHM_PROJECT_FILE_DESCRIPTION = "Statistical Algorithm Project File";
|
||||
private static final String STATISTICAL_ALGORITHM_PROJECT_FILE_NAME = "stat_algo.project";
|
||||
private static final String STATISTICAL_ALGORITHM_TARGET_FOLDER_NAME = "Target";
|
||||
|
||||
public static final Logger logger = LoggerFactory
|
||||
.getLogger(FilesStorage.class);
|
||||
|
@ -80,8 +86,66 @@ public class FilesStorage {
|
|||
|
||||
}
|
||||
|
||||
public void saveStatisticalAlgorithmProject(String user, InputStream inputStream,
|
||||
String folderId) throws StatAlgoImporterServiceException {
|
||||
public void deleteTargetFolder(String user, String folderId)
|
||||
throws StatAlgoImporterServiceException {
|
||||
Workspace ws;
|
||||
try {
|
||||
ws = HomeLibrary.getUserWorkspace(user);
|
||||
|
||||
WorkspaceItem workSpaceItem = ws.getItem(folderId);
|
||||
if (!workSpaceItem.isFolder()) {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"No valid project folder!");
|
||||
}
|
||||
|
||||
WorkspaceItem target = ws.find(
|
||||
STATISTICAL_ALGORITHM_TARGET_FOLDER_NAME, folderId);
|
||||
|
||||
if (target != null) {
|
||||
ws.removeItems(target.getId());
|
||||
}
|
||||
|
||||
return;
|
||||
} catch (WrongItemTypeException | WorkspaceFolderNotFoundException
|
||||
| InternalErrorException | HomeNotFoundException
|
||||
| ItemNotFoundException | InsufficientPrivilegesException e) {
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public WorkspaceFolder createTargetFolder(String user, String folderId)
|
||||
throws StatAlgoImporterServiceException {
|
||||
Workspace ws;
|
||||
try {
|
||||
ws = HomeLibrary.getUserWorkspace(user);
|
||||
|
||||
WorkspaceItem workSpaceItem = ws.getItem(folderId);
|
||||
if (!workSpaceItem.isFolder()) {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"No valid project folder!");
|
||||
}
|
||||
|
||||
WorkspaceFolder projectTargetFolder = ws.createFolder("Target",
|
||||
"Project Target", folderId);
|
||||
|
||||
return projectTargetFolder;
|
||||
} catch (WorkspaceFolderNotFoundException
|
||||
| InternalErrorException | HomeNotFoundException
|
||||
| ItemNotFoundException | InsufficientPrivilegesException
|
||||
| ItemAlreadyExistException | WrongDestinationException e) {
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void saveStatisticalAlgorithmProject(String user,
|
||||
InputStream inputStream, String folderId)
|
||||
throws StatAlgoImporterServiceException {
|
||||
Workspace ws;
|
||||
try {
|
||||
ws = HomeLibrary.getUserWorkspace(user);
|
||||
|
@ -115,11 +179,9 @@ public class FilesStorage {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void saveItemOnWorkspace(String user, InputStream inputStream, String name,
|
||||
String description, String mimeType,
|
||||
String folderId) throws StatAlgoImporterServiceException {
|
||||
public void saveItemOnWorkspace(String user, InputStream inputStream,
|
||||
String name, String description, String mimeType, String folderId)
|
||||
throws StatAlgoImporterServiceException {
|
||||
Workspace ws;
|
||||
try {
|
||||
ws = HomeLibrary.getUserWorkspace(user);
|
||||
|
@ -130,13 +192,10 @@ public class FilesStorage {
|
|||
"Destination is not a folder!");
|
||||
}
|
||||
|
||||
WorkspaceItem projectItem = ws.find(
|
||||
name, folderId);
|
||||
WorkspaceItem projectItem = ws.find(name, folderId);
|
||||
|
||||
if (projectItem == null) {
|
||||
ws.createExternalFile(name,
|
||||
description,
|
||||
mimeType, inputStream,
|
||||
ws.createExternalFile(name, description, mimeType, inputStream,
|
||||
folderId);
|
||||
} else {
|
||||
ws.updateItem(projectItem.getId(), inputStream);
|
||||
|
@ -154,10 +213,8 @@ public class FilesStorage {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public InputStream retrieveProjectItemOnWorkspace(String user, String folderId)
|
||||
public WorkspaceItem createItemOnWorkspace(String user, InputStream inputStream,
|
||||
String name, String description, String mimeType, String folderId)
|
||||
throws StatAlgoImporterServiceException {
|
||||
Workspace ws;
|
||||
try {
|
||||
|
@ -166,12 +223,44 @@ public class FilesStorage {
|
|||
WorkspaceItem workSpaceItem = ws.getItem(folderId);
|
||||
if (!workSpaceItem.isFolder()) {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"Folder is not valid item!");
|
||||
"Destination is not a folder!");
|
||||
}
|
||||
|
||||
WorkspaceItem projectItem=ws.find(STATISTICAL_ALGORITHM_PROJECT_FILE_NAME, folderId);
|
||||
|
||||
if(projectItem==null){
|
||||
ExternalFile workspaceItem=ws.createExternalFile(name, description, mimeType, inputStream,
|
||||
folderId);
|
||||
|
||||
return workspaceItem;
|
||||
} catch ( WorkspaceFolderNotFoundException
|
||||
| InternalErrorException | HomeNotFoundException
|
||||
| ItemNotFoundException | InsufficientPrivilegesException
|
||||
| ItemAlreadyExistException | WrongDestinationException e) {
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public InputStream retrieveProjectItemOnWorkspace(String user,
|
||||
String folderId) throws StatAlgoImporterServiceException {
|
||||
Workspace ws;
|
||||
try {
|
||||
ws = HomeLibrary.getUserWorkspace(user);
|
||||
|
||||
WorkspaceItem workSpaceItem = ws.getItem(folderId);
|
||||
if (!workSpaceItem.isFolder()) {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"Item is not valid folder!");
|
||||
}
|
||||
|
||||
WorkspaceItem projectItem = ws.find(
|
||||
STATISTICAL_ALGORITHM_PROJECT_FILE_NAME, folderId);
|
||||
|
||||
if (projectItem == null) {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"No project found in this folder!");
|
||||
}
|
||||
|
@ -179,15 +268,13 @@ public class FilesStorage {
|
|||
return retrieveImputStream(user, projectItem);
|
||||
|
||||
} catch (WorkspaceFolderNotFoundException | InternalErrorException
|
||||
| HomeNotFoundException | ItemNotFoundException | WrongItemTypeException e) {
|
||||
| HomeNotFoundException | ItemNotFoundException
|
||||
| WrongItemTypeException e) {
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -200,7 +287,7 @@ public class FilesStorage {
|
|||
WorkspaceItem workSpaceItem = ws.getItem(itemId);
|
||||
if (workSpaceItem.isFolder()) {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"Folder is not valid item!");
|
||||
"Item is not valid folder!");
|
||||
}
|
||||
|
||||
return retrieveImputStream(user, workSpaceItem);
|
||||
|
@ -248,12 +335,14 @@ public class FilesStorage {
|
|||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param user User
|
||||
* @param itemId Item on workspace
|
||||
* @param data String to save
|
||||
* @param user
|
||||
* User
|
||||
* @param itemId
|
||||
* Item on workspace
|
||||
* @param data
|
||||
* String to save
|
||||
* @throws StatAlgoImporterServiceException
|
||||
*/
|
||||
public void saveItem(String user, String itemId, String data)
|
||||
|
@ -263,13 +352,13 @@ public class FilesStorage {
|
|||
ws = HomeLibrary.getUserWorkspace(user);
|
||||
|
||||
WorkspaceItem workSpaceItem = ws.getItem(itemId);
|
||||
if (workSpaceItem==null) {
|
||||
if (workSpaceItem == null) {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"No item retrieved on workspace!");
|
||||
} else {
|
||||
if (workSpaceItem.isFolder()) {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"Folder is not valid item!");
|
||||
"Item is not valid folder!");
|
||||
} else {
|
||||
|
||||
}
|
||||
|
@ -282,11 +371,39 @@ public class FilesStorage {
|
|||
return;
|
||||
|
||||
} catch (WorkspaceFolderNotFoundException | InternalErrorException
|
||||
| HomeNotFoundException | ItemNotFoundException | InsufficientPrivilegesException | ItemAlreadyExistException | WrongDestinationException e) {
|
||||
| HomeNotFoundException | ItemNotFoundException
|
||||
| InsufficientPrivilegesException | ItemAlreadyExistException
|
||||
| WrongDestinationException e) {
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public File zipFolder(String user, String folderId)
|
||||
throws StatAlgoImporterServiceException {
|
||||
Workspace ws;
|
||||
try {
|
||||
ws = HomeLibrary.getUserWorkspace(user);
|
||||
|
||||
WorkspaceItem workSpaceItem = ws.getItem(folderId);
|
||||
if (!workSpaceItem.isFolder()) {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"Item is not valid folder!");
|
||||
}
|
||||
|
||||
WorkspaceFolder folder = (WorkspaceFolder) workSpaceItem;
|
||||
|
||||
File fileZip = ZipUtil.zipFolder(folder);
|
||||
|
||||
return fileZip;
|
||||
|
||||
} catch (IOException | InternalErrorException
|
||||
| WorkspaceFolderNotFoundException | HomeNotFoundException
|
||||
| ItemNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
package org.gcube.portlets.user.statisticalalgorithmsimporter.server.uriresolver;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.application.framework.core.session.ASLSession;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterServiceException;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.workspace.ItemDescription;
|
||||
import org.gcube.portlets.user.uriresolvermanager.UriResolverManager;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Client for retrieve link
|
||||
*
|
||||
*
|
||||
* @author giancarlo email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class UriResolverSMIClient {
|
||||
private static Logger logger = LoggerFactory
|
||||
.getLogger(UriResolverSMIClient.class);
|
||||
|
||||
public UriResolverSMIClient() {
|
||||
|
||||
}
|
||||
|
||||
public String resolve(ItemDescription itemDescription, ASLSession aslSession)
|
||||
throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
|
||||
String link = "";
|
||||
|
||||
logger.debug("Get uri from resolver: " + itemDescription);
|
||||
|
||||
UriResolverManager resolver;
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
if (itemDescription != null) {
|
||||
resolver = new UriResolverManager();
|
||||
params.put("smp-id", itemDescription.getId());
|
||||
if (itemDescription.getName() == null) {
|
||||
params.put("fileName", "");
|
||||
} else {
|
||||
params.put("fileName", itemDescription.getName());
|
||||
}
|
||||
if (itemDescription.getType() == null) {
|
||||
params.put("contentType", "");
|
||||
} else {
|
||||
params.put("contentType", itemDescription.getType());
|
||||
}
|
||||
logger.debug("Uri Resolver params: " + params);
|
||||
link = resolver.getLink(params, true); // true, link is shorted
|
||||
// otherwise none
|
||||
} else {
|
||||
logger.debug("No valid ItemDescription: "+itemDescription);
|
||||
throw new StatAlgoImporterServiceException (
|
||||
"No valid ItemDescription: "+itemDescription);
|
||||
|
||||
}
|
||||
|
||||
logger.debug("Retrieved Link: " + link);
|
||||
return link;
|
||||
|
||||
} catch (StatAlgoImporterServiceException e) {
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"Error retrieving uri from resolver: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -16,9 +16,11 @@ import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.Select
|
|||
public class InputData implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -2405068429998054485L;
|
||||
private ProjectInfo projectInfo;
|
||||
private InterpreterInfo interpreterInfo;
|
||||
private ArrayList<EnvironmentVariables> listEnvironmentVariables;
|
||||
private ArrayList<SelectedRowsVariables> listSelectedRows;
|
||||
private InterpreterInfo interpreterInfo;
|
||||
|
||||
|
||||
public InputData() {
|
||||
super();
|
||||
|
@ -26,11 +28,12 @@ public class InputData implements Serializable {
|
|||
|
||||
public InputData(ArrayList<EnvironmentVariables> listEnvironmentVariables,
|
||||
ArrayList<SelectedRowsVariables> listSelectedRows,
|
||||
InterpreterInfo interpreterInfo) {
|
||||
InterpreterInfo interpreterInfo, ProjectInfo projectInfo) {
|
||||
super();
|
||||
this.listEnvironmentVariables = listEnvironmentVariables;
|
||||
this.listSelectedRows = listSelectedRows;
|
||||
this.interpreterInfo = interpreterInfo;
|
||||
this.projectInfo = projectInfo;
|
||||
}
|
||||
|
||||
public ArrayList<EnvironmentVariables> getListEnvironmentVariables() {
|
||||
|
@ -59,12 +62,22 @@ public class InputData implements Serializable {
|
|||
this.interpreterInfo = interpreterInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "InputData [listEnvironmentVariables="
|
||||
+ listEnvironmentVariables + ", listSelectedRows="
|
||||
+ listSelectedRows + ", interpreterInfo=" + interpreterInfo
|
||||
+ "]";
|
||||
public ProjectInfo getProjectInfo() {
|
||||
return projectInfo;
|
||||
}
|
||||
|
||||
public void setProjectInfo(ProjectInfo projectInfo) {
|
||||
this.projectInfo = projectInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "InputData [projectInfo=" + projectInfo + ", interpreterInfo="
|
||||
+ interpreterInfo + ", listEnvironmentVariables="
|
||||
+ listEnvironmentVariables + ", listSelectedRows="
|
||||
+ listSelectedRows + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -12,9 +12,6 @@ public class Project implements Serializable {
|
|||
|
||||
private static final long serialVersionUID = -7906477664944910362L;
|
||||
|
||||
private String name;
|
||||
private String description;
|
||||
private String className;
|
||||
private ProjectFolder projectFolder;
|
||||
private MainCode mainCode;
|
||||
private InputData inputData;
|
||||
|
@ -30,30 +27,6 @@ public class Project implements Serializable {
|
|||
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getClassName() {
|
||||
return className;
|
||||
}
|
||||
|
||||
public void setClassName(String className) {
|
||||
this.className = className;
|
||||
}
|
||||
|
||||
public MainCode getMainCode() {
|
||||
return mainCode;
|
||||
}
|
||||
|
@ -88,15 +61,9 @@ public class Project implements Serializable {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Project [name=" + name + ", description=" + description
|
||||
+ ", className=" + className + ", projectFolder="
|
||||
+ projectFolder + ", mainCode=" + mainCode + ", inputData="
|
||||
+ inputData + ", projectTarget=" + projectTarget + "]";
|
||||
return "Project [projectFolder=" + projectFolder + ", mainCode="
|
||||
+ mainCode + ", inputData=" + inputData + ", projectTarget="
|
||||
+ projectTarget + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
package org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ProjectInfo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 7304965177776383842L;
|
||||
private String name;
|
||||
private String description;
|
||||
private String className;
|
||||
|
||||
public ProjectInfo() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ProjectInfo(String name, String description, String className) {
|
||||
super();
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.className = className;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getClassName() {
|
||||
return className;
|
||||
}
|
||||
|
||||
public void setClassName(String className) {
|
||||
this.className = className;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ProjectInfo [name=" + name + ", description=" + description
|
||||
+ ", className=" + className + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -13,14 +13,29 @@ import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.workspace.It
|
|||
public class ProjectTarget implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 480665662744105383L;
|
||||
private ItemDescription targetFolder;
|
||||
private ItemDescription packageUrl;
|
||||
private ItemDescription codeSource;
|
||||
private ItemDescription integrationInfo;
|
||||
private ItemDescription codeJar;
|
||||
|
||||
public ProjectTarget() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ProjectTarget(ItemDescription targetFolder) {
|
||||
super();
|
||||
this.targetFolder = targetFolder;
|
||||
}
|
||||
|
||||
public ItemDescription getTargetFolder() {
|
||||
return targetFolder;
|
||||
}
|
||||
|
||||
public void setTargetFolder(ItemDescription targetFolder) {
|
||||
this.targetFolder = targetFolder;
|
||||
}
|
||||
|
||||
public ItemDescription getPackageUrl() {
|
||||
return packageUrl;
|
||||
}
|
||||
|
@ -45,10 +60,25 @@ public class ProjectTarget implements Serializable {
|
|||
this.codeJar = codeJar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ProjectTarget [packageUrl=" + packageUrl + ", codeSource="
|
||||
+ codeSource + ", codeJar=" + codeJar + "]";
|
||||
|
||||
|
||||
public ItemDescription getIntegrationInfo() {
|
||||
return integrationInfo;
|
||||
}
|
||||
|
||||
public void setIntegrationInfo(ItemDescription integrationInfo) {
|
||||
this.integrationInfo = integrationInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ProjectTarget [targetFolder=" + targetFolder + ", packageUrl="
|
||||
+ packageUrl + ", codeSource=" + codeSource
|
||||
+ ", integrationInfo=" + integrationInfo + ", codeJar="
|
||||
+ codeJar + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -51,10 +51,10 @@
|
|||
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
|
||||
<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"
|
||||
/> -->
|
||||
|
||||
|
|
Loading…
Reference in New Issue