1452: Implement a GUI for StatMan Algorithms Importer
Task-Url: https://support.d4science.org/issues/1452 Added save project and add/delete resource git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/statistical-algorithms-importer@121805 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
6c76f94416
commit
88bf092513
|
@ -3,11 +3,12 @@ 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.MainCodeSetEvent;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.SessionExpiredEvent;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.StatAlgoImporterRibbonEvent;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.UIStateEvent;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.maindata.ItemDescription;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.project.ProjectManager;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.rpc.StatAlgoImporterServiceAsync;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.type.SessionExpiredType;
|
||||
|
@ -18,6 +19,7 @@ import org.gcube.portlets.user.statisticalalgorithmsimporter.client.utils.UtilsG
|
|||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.Constants;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterSessionExpiredException;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.session.UserInfo;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.workspace.ItemDescription;
|
||||
import org.gcube.portlets.widgets.sessionchecker.client.CheckSession;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
|
@ -198,11 +200,25 @@ public class StatAlgoImporterController {
|
|||
}
|
||||
|
||||
});
|
||||
|
||||
eventBus.addHandler(InputSaveReadyEvent.TYPE,
|
||||
new InputSaveReadyEvent.InputSaveReadyEventHandler() {
|
||||
|
||||
@Override
|
||||
public void onInputSaveReady(InputSaveReadyEvent event) {
|
||||
Log.debug("Catch InputSaveReadyEvent");
|
||||
doInputSaveReadyCommand(event);
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
eventBus.fireEvent(new UIStateEvent(UIStateType.START));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void doMenuCommand(StatAlgoImporterRibbonEvent event) {
|
||||
StatAlgoImporterRibbonType eventType = event.getStatRunnerRibbonType();
|
||||
if (eventType == null) {
|
||||
|
@ -216,10 +232,13 @@ public class StatAlgoImporterController {
|
|||
break;
|
||||
case PROJECT_OPEN:
|
||||
break;
|
||||
case ALGORITHM_CREATE:
|
||||
case PROJECT_SAVE:
|
||||
projectSaveRequest();
|
||||
break;
|
||||
case ALGORITHM_IMPORT:
|
||||
showCodeUploadDialog();
|
||||
case RESOURCE_ADD:
|
||||
showAddResourceDialog();
|
||||
break;
|
||||
case SOFTWARE_CREATE:
|
||||
break;
|
||||
case HELP:
|
||||
break;
|
||||
|
@ -228,11 +247,28 @@ public class StatAlgoImporterController {
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
protected void doInputSaveReadyCommand(InputSaveReadyEvent event) {
|
||||
pm.saveProject(event.getInputVariables());
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void projectSaveRequest() {
|
||||
InputSaveEvent inputSaveEvent=new InputSaveEvent();
|
||||
eventBus.fireEvent(inputSaveEvent);
|
||||
Log.debug("ProjectSaveRequest: "+inputSaveEvent);
|
||||
|
||||
}
|
||||
|
||||
private void showCreateProjectDialog() {
|
||||
pm.createProject();
|
||||
|
||||
}
|
||||
|
||||
private void showAddResourceDialog() {
|
||||
pm.addResource();
|
||||
}
|
||||
|
||||
private void doMainCodeSetCommand(MainCodeSetEvent event) {
|
||||
ItemDescription itemDescription = event.getItemDescription();
|
||||
|
@ -250,6 +286,7 @@ public class StatAlgoImporterController {
|
|||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private void showCodeUploadDialog() {
|
||||
CodeUploadDialog codeUploadDialog = new CodeUploadDialog(eventBus);
|
||||
codeUploadDialog.show();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.event;
|
||||
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.maindata.ItemDescription;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.workspace.ItemDescription;
|
||||
|
||||
import com.google.gwt.event.shared.EventHandler;
|
||||
import com.google.gwt.event.shared.GwtEvent;
|
||||
|
|
|
@ -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 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 []";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.event;
|
||||
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.InputVariables;
|
||||
|
||||
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 InputVariables inputVariables;
|
||||
|
||||
public interface InputSaveReadyEventHandler extends EventHandler {
|
||||
void onInputSaveReady(InputSaveReadyEvent event);
|
||||
}
|
||||
|
||||
public interface HasInputSaveReadyEventHandler extends HasHandlers {
|
||||
public HandlerRegistration addInputSaveReadyEventHandler(
|
||||
InputSaveReadyEventHandler handler);
|
||||
}
|
||||
|
||||
public InputSaveReadyEvent(InputVariables inputVariables) {
|
||||
this.inputVariables = inputVariables;
|
||||
}
|
||||
|
||||
@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 InputVariables getInputVariables() {
|
||||
return inputVariables;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "InputSaveReadyEvent [inputVariables=" + inputVariables + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.event;
|
||||
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.maindata.ItemDescription;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.workspace.ItemDescription;
|
||||
|
||||
import com.google.gwt.event.shared.EventHandler;
|
||||
import com.google.gwt.event.shared.GwtEvent;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.event;
|
||||
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.type.ProjectStatusEventType;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.workspace.ItemDescription;
|
||||
|
||||
import com.google.gwt.event.shared.EventHandler;
|
||||
import com.google.gwt.event.shared.GwtEvent;
|
||||
|
@ -20,7 +21,7 @@ public class ProjectStatusEvent extends
|
|||
|
||||
public static Type<ProjectStatusEventHandler> TYPE = new Type<ProjectStatusEventHandler>();
|
||||
private ProjectStatusEventType projectStatusEventType;
|
||||
private String projectFolderId;
|
||||
private ItemDescription projectFolder;
|
||||
|
||||
public interface ProjectStatusEventHandler extends EventHandler {
|
||||
void onProjectStatus(ProjectStatusEvent event);
|
||||
|
@ -31,9 +32,9 @@ public class ProjectStatusEvent extends
|
|||
ProjectStatusEventHandler handler);
|
||||
}
|
||||
|
||||
public ProjectStatusEvent(ProjectStatusEventType projectStatusEventType,String projectFolderId) {
|
||||
public ProjectStatusEvent(ProjectStatusEventType projectStatusEventType,ItemDescription projectFolder) {
|
||||
this.projectStatusEventType = projectStatusEventType;
|
||||
this.projectFolderId = projectFolderId;
|
||||
this.projectFolder = projectFolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -59,16 +60,18 @@ public class ProjectStatusEvent extends
|
|||
return projectStatusEventType;
|
||||
}
|
||||
|
||||
public String getProjectFolderId() {
|
||||
return projectFolderId;
|
||||
public ItemDescription getProjectFolder() {
|
||||
return projectFolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ProjectStatusEvent [projectStatusEventType="
|
||||
+ projectStatusEventType + ", projectFolderId="
|
||||
+ projectFolderId + "]";
|
||||
+ projectStatusEventType + ", projectFolder=" + projectFolder
|
||||
+ "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,13 +1,18 @@
|
|||
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.project;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.ProjectStatusEvent;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.SessionExpiredEvent;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.maindata.ItemDescription;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.rpc.StatAlgoImporterServiceAsync;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.type.ProjectStatusEventType;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.type.SessionExpiredType;
|
||||
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.InputVariables;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.workspace.ItemDescription;
|
||||
import org.gcube.portlets.widgets.wsexplorer.client.notification.WorkspaceExplorerSelectNotification.WorskpaceExplorerSelectNotificationListener;
|
||||
import org.gcube.portlets.widgets.wsexplorer.client.select.WorkspaceExplorerSelectDialog;
|
||||
import org.gcube.portlets.widgets.wsexplorer.shared.Item;
|
||||
|
@ -26,7 +31,7 @@ import com.sencha.gxt.core.client.dom.XDOM;
|
|||
*/
|
||||
public class ProjectManager {
|
||||
private EventBus eventBus;
|
||||
private String projectFolderId;
|
||||
private ItemDescription projectFolder;
|
||||
@SuppressWarnings("unused")
|
||||
private ItemDescription mainCodeDescription;
|
||||
|
||||
|
@ -56,6 +61,9 @@ public class ProjectManager {
|
|||
|
||||
@Override
|
||||
public void onFailed(Throwable throwable) {
|
||||
Log.error("Error in create project: "
|
||||
+ throwable.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error", throwable.getLocalizedMessage());
|
||||
throwable.printStackTrace();
|
||||
}
|
||||
|
||||
|
@ -75,11 +83,103 @@ public class ProjectManager {
|
|||
wselectDialog.show();
|
||||
}
|
||||
|
||||
public void addResource() {
|
||||
List<ItemType> selectableTypes = new ArrayList<ItemType>();
|
||||
selectableTypes.add(ItemType.EXTERNAL_FILE);
|
||||
selectableTypes.add(ItemType.EXTERNAL_IMAGE);
|
||||
selectableTypes.add(ItemType.IMAGE_DOCUMENT);
|
||||
selectableTypes.add(ItemType.DOCUMENT);
|
||||
selectableTypes.add(ItemType.PDF_DOCUMENT);
|
||||
|
||||
List<ItemType> showableTypes = new ArrayList<ItemType>();
|
||||
showableTypes.addAll(Arrays.asList(ItemType.values()));
|
||||
|
||||
WorkspaceExplorerSelectDialog wselectDialog = new WorkspaceExplorerSelectDialog(
|
||||
"Select a Resource", selectableTypes, showableTypes);
|
||||
|
||||
WorskpaceExplorerSelectNotificationListener handler = new WorskpaceExplorerSelectNotificationListener() {
|
||||
|
||||
@Override
|
||||
public void onSelectedItem(Item item) {
|
||||
if (item.getType() == ItemType.EXTERNAL_FILE
|
||||
|| item.getType() == ItemType.EXTERNAL_IMAGE
|
||||
|| item.getType() == ItemType.IMAGE_DOCUMENT
|
||||
|| item.getType() == ItemType.DOCUMENT
|
||||
|| item.getType() == ItemType.PDF_DOCUMENT) {
|
||||
String filename = item.getName();
|
||||
if (filename != null && !filename.isEmpty()) {
|
||||
addResourceToProject(item);
|
||||
} else {
|
||||
UtilsGXT3.info("Attention", "Select a valid resource!");
|
||||
}
|
||||
|
||||
} else {
|
||||
UtilsGXT3.info("Attention", "Select a valid resource!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed(Throwable throwable) {
|
||||
Log.error("Error in add resource: "
|
||||
+ throwable.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error", throwable.getLocalizedMessage());
|
||||
throwable.printStackTrace();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAborted() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNotValidSelection() {
|
||||
UtilsGXT3.info("Attention", "Select a valid resource!");
|
||||
}
|
||||
};
|
||||
|
||||
wselectDialog.addWorkspaceExplorerSelectNotificationListener(handler);
|
||||
wselectDialog.setZIndex(XDOM.getTopZIndex());
|
||||
wselectDialog.show();
|
||||
}
|
||||
|
||||
protected void addResourceToProject(Item item) {
|
||||
Log.debug("Add Resource To Project Item selected: " + item);
|
||||
ItemDescription itemDescription = new ItemDescription(item.getId(),
|
||||
item.getName(), item.getOwner(), item.getPath(), item.getType()
|
||||
.name());
|
||||
StatAlgoImporterServiceAsync.INSTANCE.addResourceToProject(
|
||||
itemDescription, new AsyncCallback<Void>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(Void result) {
|
||||
fireProjectStatusAddResourceEvent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
if (caught instanceof StatAlgoImporterSessionExpiredException) {
|
||||
eventBus.fireEvent(new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
Log.error("Error in add resource to project: "
|
||||
+ caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error",
|
||||
caught.getLocalizedMessage());
|
||||
}
|
||||
caught.printStackTrace();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
protected void createProjectOnServer(Item item) {
|
||||
Log.debug("Item selected: " + item);
|
||||
projectFolderId = item.getId();
|
||||
Log.debug("Create Project Item selected: " + item);
|
||||
projectFolder = new ItemDescription(item.getId(), item.getName(),
|
||||
item.getOwner(), item.getPath(), item.getType().name());
|
||||
StatAlgoImporterServiceAsync.INSTANCE.createProjectOnWorkspace(
|
||||
item.getId(), new AsyncCallback<Void>() {
|
||||
projectFolder, new AsyncCallback<Void>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(Void result) {
|
||||
|
@ -89,18 +189,55 @@ public class ProjectManager {
|
|||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
Log.debug(caught.getLocalizedMessage());
|
||||
if (caught instanceof StatAlgoImporterSessionExpiredException) {
|
||||
eventBus.fireEvent(new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
Log.error("Error in create project: "
|
||||
+ caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error",
|
||||
caught.getLocalizedMessage());
|
||||
}
|
||||
caught.printStackTrace();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setMainCode(ItemDescription mainCodeDescription) {
|
||||
this.mainCodeDescription = mainCodeDescription;
|
||||
Log.debug("Main: " + mainCodeDescription);
|
||||
StatAlgoImporterServiceAsync.INSTANCE.setMainCode(
|
||||
mainCodeDescription.getId(), new AsyncCallback<Void>() {
|
||||
public void saveProject(InputVariables inputVariables) {
|
||||
Log.debug("Save Project: " + inputVariables);
|
||||
|
||||
StatAlgoImporterServiceAsync.INSTANCE.saveProject(inputVariables,
|
||||
new AsyncCallback<Void>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(Void result) {
|
||||
UtilsGXT3.info("Save",
|
||||
"Project saved!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
if (caught instanceof StatAlgoImporterSessionExpiredException) {
|
||||
eventBus.fireEvent(new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
Log.error("Error on save project: "
|
||||
+ caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error",
|
||||
caught.getLocalizedMessage());
|
||||
}
|
||||
caught.printStackTrace();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setMainCode(ItemDescription itemDescription) {
|
||||
this.mainCodeDescription = itemDescription;
|
||||
Log.debug("Set Main Code: " + itemDescription);
|
||||
StatAlgoImporterServiceAsync.INSTANCE.setMainCode(itemDescription,
|
||||
new AsyncCallback<Void>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
|
@ -119,29 +256,77 @@ public class ProjectManager {
|
|||
|
||||
@Override
|
||||
public void onSuccess(Void result) {
|
||||
fireProjectStatusEventUpdate();
|
||||
fireProjectStatusUpdateEvent();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void deleteItem(ItemDescription itemDescription) {
|
||||
|
||||
StatAlgoImporterServiceAsync.INSTANCE.deleteResourceOnProject(itemDescription,
|
||||
new AsyncCallback<Void>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
if (caught instanceof StatAlgoImporterSessionExpiredException) {
|
||||
eventBus.fireEvent(new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
Log.error("Error deleting resourse: "
|
||||
+ caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error",
|
||||
caught.getLocalizedMessage());
|
||||
}
|
||||
caught.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Void result) {
|
||||
fireProjectStatusDeleteEvent();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected void fireProjectStatusOpenEvent() {
|
||||
ProjectStatusEvent projectStatusEvent = new ProjectStatusEvent(
|
||||
ProjectStatusEventType.OPEN, projectFolderId);
|
||||
ProjectStatusEventType.OPEN, projectFolder);
|
||||
eventBus.fireEvent(projectStatusEvent);
|
||||
Log.debug("ProjectStatusEvent fired");
|
||||
Log.debug("ProjectStatusEvent fired! "+projectStatusEvent);
|
||||
|
||||
}
|
||||
|
||||
protected void fireProjectStatusEventUpdate() {
|
||||
|
||||
protected void fireProjectStatusSaveProjectEvent() {
|
||||
ProjectStatusEvent projectStatusEvent = new ProjectStatusEvent(
|
||||
ProjectStatusEventType.UPDATE, projectFolderId);
|
||||
ProjectStatusEventType.SAVE, projectFolder);
|
||||
eventBus.fireEvent(projectStatusEvent);
|
||||
Log.debug("ProjectStatusEvent fired");
|
||||
Log.debug("ProjectStatusEvent fired! "+projectStatusEvent);
|
||||
}
|
||||
|
||||
|
||||
protected void fireProjectStatusAddResourceEvent() {
|
||||
ProjectStatusEvent projectStatusEvent = new ProjectStatusEvent(
|
||||
ProjectStatusEventType.ADD_RESOURCE, projectFolder);
|
||||
eventBus.fireEvent(projectStatusEvent);
|
||||
Log.debug("ProjectStatusEvent fired! "+projectStatusEvent);
|
||||
}
|
||||
|
||||
protected void fireProjectStatusDeleteEvent() {
|
||||
// TODO Auto-generated method stub
|
||||
ProjectStatusEvent projectStatusEvent = new ProjectStatusEvent(
|
||||
ProjectStatusEventType.DELETE_RESOURCE, projectFolder);
|
||||
eventBus.fireEvent(projectStatusEvent);
|
||||
Log.debug("ProjectStatusEvent fired! "+projectStatusEvent);
|
||||
}
|
||||
|
||||
protected void fireProjectStatusUpdateEvent() {
|
||||
ProjectStatusEvent projectStatusEvent = new ProjectStatusEvent(
|
||||
ProjectStatusEventType.UPDATE, projectFolder);
|
||||
eventBus.fireEvent(projectStatusEvent);
|
||||
Log.debug("ProjectStatusEvent fired! "+projectStatusEvent);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -44,6 +44,9 @@ public interface StatAlgoImporterResources extends ClientBundle {
|
|||
|
||||
@Source("reload_24.png")
|
||||
ImageResource reload24();
|
||||
|
||||
@Source("reload_16.png")
|
||||
ImageResource reload16();
|
||||
|
||||
@Source("input_16.png")
|
||||
ImageResource input16();
|
||||
|
@ -74,6 +77,12 @@ public interface StatAlgoImporterResources extends ClientBundle {
|
|||
|
||||
@Source("project-open_24.png")
|
||||
ImageResource projectOpen24();
|
||||
|
||||
@Source("project-save_32.png")
|
||||
ImageResource projectSave32();
|
||||
|
||||
@Source("project-save_24.png")
|
||||
ImageResource projectSave24();
|
||||
|
||||
@Source("add_24.png")
|
||||
ImageResource add24();
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.0 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
After Width: | Height: | Size: 710 B |
|
@ -41,7 +41,8 @@ public class HomeToolBar {
|
|||
//Home
|
||||
private TextButton btnCreateProject;
|
||||
private TextButton btnOpenProject;
|
||||
|
||||
private TextButton btnSaveProject;
|
||||
|
||||
//Resources
|
||||
private TextButton btnAddResource;
|
||||
|
||||
|
@ -115,7 +116,7 @@ public class HomeToolBar {
|
|||
btnOpenProject.setIconAlign(IconAlign.LEFT);
|
||||
btnOpenProject.setArrowAlign(ButtonArrowAlign.BOTTOM);
|
||||
btnOpenProject.setToolTip(msgs.btnOpenProjectToolTip());
|
||||
|
||||
btnOpenProject.getElement().setMargins(new Margins(0, 4, 0, 0));
|
||||
btnOpenProject.addSelectHandler(new SelectHandler() {
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
|
@ -127,6 +128,27 @@ public class HomeToolBar {
|
|||
homeLayout.setWidget(0, 1, btnOpenProject);
|
||||
homeLayout.getFlexCellFormatter().setRowSpan(0, 1, 2);
|
||||
|
||||
|
||||
btnSaveProject = new TextButton(msgs.btnSaveProject(),
|
||||
StatAlgoImporterResources.INSTANCE.projectSave24());
|
||||
btnSaveProject.setId("btnSaveProject");
|
||||
btnSaveProject.setScale(ButtonScale.SMALL);
|
||||
btnSaveProject.setIconAlign(IconAlign.LEFT);
|
||||
btnSaveProject.setArrowAlign(ButtonArrowAlign.BOTTOM);
|
||||
btnSaveProject.setToolTip(msgs.btnSaveProjectToolTip());
|
||||
|
||||
btnSaveProject.addSelectHandler(new SelectHandler() {
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
eventBus.fireEvent(new StatAlgoImporterRibbonEvent(
|
||||
StatAlgoImporterRibbonType.PROJECT_SAVE));
|
||||
}
|
||||
});
|
||||
|
||||
homeLayout.setWidget(0, 2, btnSaveProject);
|
||||
homeLayout.getFlexCellFormatter().setRowSpan(0, 2, 2);
|
||||
|
||||
|
||||
// Resources
|
||||
ButtonGroup resourcesGroup = new ButtonGroup();
|
||||
resourcesGroup.setId("Resource");
|
||||
|
@ -148,7 +170,7 @@ public class HomeToolBar {
|
|||
|
||||
public void onSelect(SelectEvent event) {
|
||||
eventBus.fireEvent(new StatAlgoImporterRibbonEvent(
|
||||
StatAlgoImporterRibbonType.ALGORITHM_IMPORT));
|
||||
StatAlgoImporterRibbonType.RESOURCE_ADD));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -177,7 +199,7 @@ public class HomeToolBar {
|
|||
|
||||
public void onSelect(SelectEvent event) {
|
||||
eventBus.fireEvent(new StatAlgoImporterRibbonEvent(
|
||||
StatAlgoImporterRibbonType.ALGORITHM_CREATE));
|
||||
StatAlgoImporterRibbonType.SOFTWARE_CREATE));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -320,6 +342,7 @@ public class HomeToolBar {
|
|||
case START:
|
||||
btnCreateProject.enable();
|
||||
btnOpenProject.enable();
|
||||
btnSaveProject.enable();
|
||||
btnAddResource.enable();
|
||||
btnCreateSoftware.enable();
|
||||
btnHelp.enable();
|
||||
|
|
|
@ -44,6 +44,12 @@ public interface HomeToolBarMessages extends Messages {
|
|||
@DefaultMessage("Open Project")
|
||||
String btnOpenProjectToolTip();
|
||||
|
||||
@DefaultMessage("Save")
|
||||
String btnSaveProject();
|
||||
|
||||
@DefaultMessage("Save Project")
|
||||
String btnSaveProjectToolTip();
|
||||
|
||||
//
|
||||
@DefaultMessage("Resource")
|
||||
String resourceGroupHeadingText();
|
||||
|
|
|
@ -5,7 +5,9 @@ import java.util.ArrayList;
|
|||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.code.CodeData;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterServiceException;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.file.FileUploadMonitor;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.InputVariables;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.session.UserInfo;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.workspace.ItemDescription;
|
||||
|
||||
import com.google.gwt.user.client.rpc.RemoteService;
|
||||
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
|
||||
|
@ -40,10 +42,20 @@ public interface StatAlgoImporterService extends RemoteService {
|
|||
public ArrayList<CodeData> getCode()
|
||||
throws StatAlgoImporterServiceException;
|
||||
|
||||
public void createProjectOnWorkspace(String itemId)
|
||||
public void createProjectOnWorkspace(ItemDescription itemDescription)
|
||||
throws StatAlgoImporterServiceException;
|
||||
|
||||
//
|
||||
public void setMainCode(String itemId)
|
||||
public void setMainCode(ItemDescription itemDescription)
|
||||
throws StatAlgoImporterServiceException;
|
||||
|
||||
public void addResourceToProject(ItemDescription itemDescription)
|
||||
throws StatAlgoImporterServiceException;
|
||||
|
||||
public void deleteResourceOnProject(ItemDescription itemDescription)
|
||||
throws StatAlgoImporterServiceException;
|
||||
|
||||
public void saveProject(InputVariables inputVariables)
|
||||
throws StatAlgoImporterServiceException;
|
||||
|
||||
|
||||
|
|
|
@ -7,7 +7,9 @@ import java.util.ArrayList;
|
|||
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.code.CodeData;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.file.FileUploadMonitor;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.InputVariables;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.session.UserInfo;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.workspace.ItemDescription;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
|
@ -33,9 +35,18 @@ public interface StatAlgoImporterServiceAsync {
|
|||
|
||||
void getCode(AsyncCallback<ArrayList<CodeData>> callback);
|
||||
|
||||
void createProjectOnWorkspace(String itemId,
|
||||
void createProjectOnWorkspace(ItemDescription itemDescription,
|
||||
AsyncCallback<Void> callback);
|
||||
|
||||
void setMainCode(String itemId, AsyncCallback<Void> callback);
|
||||
void setMainCode(ItemDescription itemDescription, AsyncCallback<Void> callback);
|
||||
|
||||
void addResourceToProject(ItemDescription itemDescription,
|
||||
AsyncCallback<Void> asyncCallback);
|
||||
|
||||
void saveProject(InputVariables inputVariables,
|
||||
AsyncCallback<Void> asyncCallback);
|
||||
|
||||
void deleteResourceOnProject(ItemDescription itemDescription,
|
||||
AsyncCallback<Void> asyncCallback);
|
||||
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@ import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.Delete
|
|||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.MainCodeSetEvent;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.ProjectStatusEvent;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.UIStateEvent;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.maindata.ItemDescription;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.resource.StatAlgoImporterResources;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.utils.UtilsGXT3;
|
||||
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;
|
||||
import org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload;
|
||||
|
@ -22,13 +22,16 @@ import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign;
|
|||
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.box.ConfirmMessageBox;
|
||||
import com.sencha.gxt.widget.core.client.button.TextButton;
|
||||
import com.sencha.gxt.widget.core.client.container.AccordionLayoutContainer.AccordionLayoutAppearance;
|
||||
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData;
|
||||
import com.sencha.gxt.widget.core.client.container.MarginData;
|
||||
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
|
||||
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
|
||||
import com.sencha.gxt.widget.core.client.event.DialogHideEvent;
|
||||
import com.sencha.gxt.widget.core.client.event.SelectEvent;
|
||||
import com.sencha.gxt.widget.core.client.event.DialogHideEvent.DialogHideHandler;
|
||||
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
|
||||
import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
|
||||
|
||||
|
@ -46,6 +49,7 @@ public class ExplorerProjectPanel extends ContentPanel {
|
|||
private MultipleDNDUpload dnd;
|
||||
private WorkspaceResourcesExplorerPanel wsResourcesExplorerPanel;
|
||||
private TextButton btnDelete;
|
||||
private TextButton btnReload;
|
||||
|
||||
public ExplorerProjectPanel(EventBus eventBus) {
|
||||
super();
|
||||
|
@ -123,10 +127,13 @@ public class ExplorerProjectPanel extends ContentPanel {
|
|||
+ event.toString());
|
||||
switch (event.getProjectStatusEventType()) {
|
||||
case OPEN:
|
||||
case UPDATE:
|
||||
case SAVE:
|
||||
case ADD_RESOURCE:
|
||||
case DELETE_RESOURCE:
|
||||
create(event);
|
||||
break;
|
||||
case UPDATE:
|
||||
create(event);
|
||||
case MAIN_CODE_SET:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -137,7 +144,7 @@ public class ExplorerProjectPanel extends ContentPanel {
|
|||
try {
|
||||
|
||||
wsResourcesExplorerPanel = new WorkspaceResourcesExplorerPanel(
|
||||
event.getProjectFolderId(), false);
|
||||
event.getProjectFolder().getId(), false);
|
||||
|
||||
WorskpaceExplorerSelectNotificationListener wsResourceExplorerListener = new WorskpaceExplorerSelectNotificationListener() {
|
||||
@Override
|
||||
|
@ -176,7 +183,7 @@ public class ExplorerProjectPanel extends ContentPanel {
|
|||
// DND
|
||||
|
||||
dnd = new MultipleDNDUpload();
|
||||
dnd.setParameters(event.getProjectFolderId(), UPLOAD_TYPE.File);
|
||||
dnd.setParameters(event.getProjectFolder().getId(), UPLOAD_TYPE.File);
|
||||
dnd.addUniqueContainer(vResourcesExplorerContainer);
|
||||
WorskpaceUploadNotificationListener workspaceUploaderListener = new WorskpaceUploadNotificationListener() {
|
||||
|
||||
|
@ -230,7 +237,7 @@ public class ExplorerProjectPanel extends ContentPanel {
|
|||
});
|
||||
|
||||
btnDelete = new TextButton("Delete");
|
||||
btnDelete.setIcon(StatAlgoImporterResources.INSTANCE.add16());
|
||||
btnDelete.setIcon(StatAlgoImporterResources.INSTANCE.delete16());
|
||||
btnDelete.setScale(ButtonScale.SMALL);
|
||||
btnDelete.setIconAlign(IconAlign.LEFT);
|
||||
btnDelete.setToolTip("Delete");
|
||||
|
@ -244,11 +251,30 @@ public class ExplorerProjectPanel extends ContentPanel {
|
|||
|
||||
|
||||
});
|
||||
|
||||
btnReload = new TextButton("Reload");
|
||||
btnReload.setIcon(StatAlgoImporterResources.INSTANCE.reload16());
|
||||
btnReload.setScale(ButtonScale.SMALL);
|
||||
btnReload.setIconAlign(IconAlign.LEFT);
|
||||
btnReload.setToolTip("Reload");
|
||||
btnReload.addSelectHandler(new SelectHandler() {
|
||||
|
||||
@Override
|
||||
public void onSelect(SelectEvent event) {
|
||||
reloadWSResourceExplorerPanel(event);
|
||||
}
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
ToolBar toolBar = new ToolBar();
|
||||
toolBar.add(btnSetMain, new BoxLayoutData(new Margins(0)));
|
||||
toolBar.add(btnReload, new BoxLayoutData(new Margins(0)));
|
||||
toolBar.add(btnDelete, new BoxLayoutData(new Margins(0)));
|
||||
|
||||
VerticalLayoutContainer v = new VerticalLayoutContainer();
|
||||
|
||||
|
@ -263,6 +289,13 @@ public class ExplorerProjectPanel extends ContentPanel {
|
|||
}
|
||||
}
|
||||
|
||||
protected void reloadWSResourceExplorerPanel(SelectEvent event) {
|
||||
if(wsResourcesExplorerPanel!=null){
|
||||
wsResourcesExplorerPanel.refreshRootFolderView();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void setMainCode(SelectEvent event) {
|
||||
Log.debug("Set Main Code");
|
||||
if (selectedItem != null
|
||||
|
@ -275,21 +308,39 @@ public class ExplorerProjectPanel extends ContentPanel {
|
|||
}
|
||||
|
||||
private void deleteItem(SelectEvent event) {
|
||||
ItemDescription itemDescription = new ItemDescription(
|
||||
selectedItem.getId(), selectedItem.getName(),
|
||||
selectedItem.getOwner(), selectedItem.getPath());
|
||||
DeleteItemEvent deleteItemEvent = new DeleteItemEvent(
|
||||
itemDescription);
|
||||
eventBus.fireEvent(deleteItemEvent);
|
||||
Log.debug("Fired: " + deleteItemEvent);
|
||||
|
||||
final ConfirmMessageBox mb = new ConfirmMessageBox("Delete",
|
||||
"Would you like to delete this resource?");
|
||||
mb.addDialogHideHandler(new DialogHideHandler() {
|
||||
|
||||
@Override
|
||||
public void onDialogHide(DialogHideEvent event) {
|
||||
switch (event.getHideButton()) {
|
||||
case NO:
|
||||
break;
|
||||
case YES:
|
||||
ItemDescription itemDescription = new ItemDescription(
|
||||
selectedItem.getId(), selectedItem.getName(),
|
||||
selectedItem.getOwner(), selectedItem.getPath(), selectedItem.getType().name());
|
||||
DeleteItemEvent deleteItemEvent = new DeleteItemEvent(
|
||||
itemDescription);
|
||||
eventBus.fireEvent(deleteItemEvent);
|
||||
Log.debug("Fired: " + deleteItemEvent);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
mb.setWidth(300);
|
||||
mb.show();
|
||||
}
|
||||
|
||||
|
||||
private void loadData() {
|
||||
ItemDescription itemDescription = new ItemDescription(
|
||||
selectedItem.getId(), selectedItem.getName(),
|
||||
selectedItem.getOwner(), selectedItem.getPath());
|
||||
selectedItem.getOwner(), selectedItem.getPath(), selectedItem.getType().name());
|
||||
MainCodeSetEvent mainCodeSetEvent = new MainCodeSetEvent(
|
||||
itemDescription);
|
||||
eventBus.fireEvent(mainCodeSetEvent);
|
||||
|
|
|
@ -56,6 +56,7 @@ import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
|
|||
*/
|
||||
public class EnvironmentVariablesPanel extends ContentPanel {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private EventBus eventBus;
|
||||
private ListStore<EnvironmentVariables> storeEnvironmentVariable;
|
||||
private Grid<EnvironmentVariables> gridEnvironmentVariable;
|
||||
|
@ -136,13 +137,13 @@ public class EnvironmentVariablesPanel extends ContentPanel {
|
|||
storeEnvironmentVariable = new ListStore<EnvironmentVariables>(
|
||||
props.id());
|
||||
|
||||
/*ArrayList<EnvironmentVariables> list = new ArrayList<>();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
list.add(new EnvironmentVariables(i, "Test" + i, "Desc",
|
||||
"defaultValue", InputType.STRING));
|
||||
}
|
||||
|
||||
storeEnvironmentVariable.addAll(list);*/
|
||||
/*
|
||||
* ArrayList<EnvironmentVariables> list = new ArrayList<>(); for (int i
|
||||
* = 0; i < 10; i++) { list.add(new EnvironmentVariables(i, "Test" + i,
|
||||
* "Desc", "defaultValue", InputType.STRING)); }
|
||||
*
|
||||
* storeEnvironmentVariable.addAll(list);
|
||||
*/
|
||||
|
||||
final GridSelectionModel<EnvironmentVariables> sm = new GridSelectionModel<EnvironmentVariables>();
|
||||
sm.setSelectionMode(SelectionMode.SINGLE);
|
||||
|
@ -156,7 +157,6 @@ public class EnvironmentVariablesPanel extends ContentPanel {
|
|||
gridEnvironmentVariable.getView().setAutoFill(true);
|
||||
gridEnvironmentVariable.setBorders(false);
|
||||
gridEnvironmentVariable.setColumnReordering(false);
|
||||
|
||||
|
||||
/*
|
||||
* GridDragSource<EnvironmentVariables> ds = new
|
||||
|
@ -196,8 +196,8 @@ public class EnvironmentVariablesPanel extends ContentPanel {
|
|||
gridEnvironmentVariableEditing.addEditor(nameColumn, new TextField());
|
||||
gridEnvironmentVariableEditing.addEditor(descriptionColumn,
|
||||
new TextField());
|
||||
gridEnvironmentVariableEditing
|
||||
.addEditor(inputTypeColumn, comboInputType);
|
||||
gridEnvironmentVariableEditing.addEditor(inputTypeColumn,
|
||||
comboInputType);
|
||||
gridEnvironmentVariableEditing.addEditor(defaultValueColumn,
|
||||
new TextField());
|
||||
|
||||
|
@ -226,8 +226,8 @@ public class EnvironmentVariablesPanel extends ContentPanel {
|
|||
storeEnvironmentVariable.remove(rowIndex);
|
||||
storeEnvironmentVariable.commitChanges();
|
||||
|
||||
gridEnvironmentVariableEditing.getCancelButton()
|
||||
.setVisible(true);
|
||||
gridEnvironmentVariableEditing.getCancelButton().setVisible(
|
||||
true);
|
||||
btnAdd.setEnabled(true);
|
||||
if (addStatus) {
|
||||
addStatus = false;
|
||||
|
@ -291,13 +291,13 @@ public class EnvironmentVariablesPanel extends ContentPanel {
|
|||
VerticalLayoutContainer vlc = new VerticalLayoutContainer();
|
||||
vlc.setAdjustForScroll(false);
|
||||
vlc.setScrollMode(ScrollMode.NONE);
|
||||
|
||||
|
||||
vlc.add(toolBar, new VerticalLayoutData(1, -1, new Margins(0)));
|
||||
vlc.add(gridEnvironmentVariable, new VerticalLayoutData(1, 1,
|
||||
new Margins(0)));
|
||||
|
||||
|
||||
add(vlc, new MarginData(new Margins(0)));
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void editingBeforeStart(
|
||||
|
@ -318,7 +318,7 @@ public class EnvironmentVariablesPanel extends ContentPanel {
|
|||
seq, "", "", "", InputType.STRING);
|
||||
Log.debug("New Environment Variable: " + newEnvironmentVariable);
|
||||
gridEnvironmentVariableEditing.cancelEditing();
|
||||
addStatus = true;
|
||||
addStatus = true;
|
||||
gridEnvironmentVariableEditing.getCancelButton().setVisible(false);
|
||||
storeEnvironmentVariable.add(newEnvironmentVariable);
|
||||
int row = storeEnvironmentVariable.indexOf(newEnvironmentVariable);
|
||||
|
@ -337,4 +337,10 @@ public class EnvironmentVariablesPanel extends ContentPanel {
|
|||
|
||||
}
|
||||
|
||||
public ArrayList<EnvironmentVariables> getEnvironmentVariables() {
|
||||
ArrayList<EnvironmentVariables> listEnviromentVarialbles = new ArrayList<>(
|
||||
gridEnvironmentVariable.getStore().getAll());
|
||||
return listEnviromentVarialbles;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +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.ProjectStatusEvent;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.UIStateEvent;
|
||||
|
||||
|
@ -28,7 +29,7 @@ public class InputVariablePanel extends ContentPanel {
|
|||
bindToEvents();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public InputVariablePanel(EventBus eventBus,
|
||||
AccordionLayoutAppearance appearance) {
|
||||
super(appearance);
|
||||
|
@ -48,7 +49,7 @@ public class InputVariablePanel extends ContentPanel {
|
|||
setBorders(true);
|
||||
setHeadingText("Input");
|
||||
forceLayoutOnResize = true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected void bindToEvents() {
|
||||
|
@ -66,10 +67,28 @@ public class InputVariablePanel extends ContentPanel {
|
|||
|
||||
@Override
|
||||
public void onProjectStatus(ProjectStatusEvent event) {
|
||||
Log.debug("Catch ProjectStatusEvent");
|
||||
manageProjectStatusEvents(event);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
eventBus.addHandler(InputSaveEvent.TYPE,
|
||||
new InputSaveEvent.InputSaveEventHandler() {
|
||||
|
||||
@Override
|
||||
public void onInputSave(InputSaveEvent event) {
|
||||
Log.debug("Catch InputSaveEvent");
|
||||
manageInputSaveEvents(event);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
protected void manageInputSaveEvents(InputSaveEvent event) {
|
||||
inputVariableTabPanel.saveInput();
|
||||
|
||||
}
|
||||
|
||||
protected void manageUIStateEvents(UIStateEvent event) {
|
||||
|
@ -96,18 +115,22 @@ public class InputVariablePanel extends ContentPanel {
|
|||
case UPDATE:
|
||||
updatePanel();
|
||||
break;
|
||||
case ADD_RESOURCE:
|
||||
break;
|
||||
case MAIN_CODE_SET:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void create(){
|
||||
private void create() {
|
||||
inputVariableTabPanel = new InputVariableTabPanel(eventBus, this);
|
||||
add(inputVariableTabPanel);
|
||||
startPanel();
|
||||
forceLayout();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* private void closePanelOnly() { collapse(); disable(); state =
|
||||
* InputVariablePanelState.CLOSED; }
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.tools.input;
|
||||
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.InputSaveReadyEvent;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.InputVariables;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.event.shared.EventBus;
|
||||
|
@ -77,6 +80,25 @@ public class InputVariableTabPanel extends TabPanel {
|
|||
}
|
||||
}
|
||||
|
||||
public void saveInput() {
|
||||
InputVariables inputVariables = new InputVariables();
|
||||
if (enviromentVariablesPanel != null) {
|
||||
inputVariables.setListEnvironmentVariables(enviromentVariablesPanel
|
||||
.getEnvironmentVariables());
|
||||
}
|
||||
|
||||
if (selectedRowsPanel != null) {
|
||||
inputVariables.setListSelectedRows(selectedRowsPanel
|
||||
.getSelectedRows());
|
||||
}
|
||||
|
||||
InputSaveReadyEvent inputSaveReadyEvent = new InputSaveReadyEvent(
|
||||
inputVariables);
|
||||
eventBus.fireEvent(inputSaveReadyEvent);
|
||||
Log.debug("Fired InputSaveReadyEvent");
|
||||
|
||||
}
|
||||
|
||||
// Add
|
||||
private void addSelectedRowsPanel() {
|
||||
TabItemConfig selectedRowsPanelItemConf = new TabItemConfig(
|
||||
|
|
|
@ -55,9 +55,10 @@ import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
|
|||
*/
|
||||
public class SelectedRowsPanel extends ContentPanel {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private EventBus eventBus;
|
||||
private ListStore<EnvironmentVariables> storeEnvironmentVariable;
|
||||
private Grid<EnvironmentVariables> gridEnvironmentVariable;
|
||||
private Grid<EnvironmentVariables> gridSelectedRows;
|
||||
private ListStore<InputType> storeComboInputType;
|
||||
private ComboBox<InputType> comboInputType;
|
||||
private GridRowEditing<EnvironmentVariables> gridEnvironmentVariableEditing;
|
||||
|
@ -146,15 +147,15 @@ public class SelectedRowsPanel extends ContentPanel {
|
|||
final GridSelectionModel<EnvironmentVariables> sm = new GridSelectionModel<EnvironmentVariables>();
|
||||
sm.setSelectionMode(SelectionMode.SINGLE);
|
||||
|
||||
gridEnvironmentVariable = new Grid<EnvironmentVariables>(
|
||||
gridSelectedRows = new Grid<EnvironmentVariables>(
|
||||
storeEnvironmentVariable, columns);
|
||||
gridEnvironmentVariable.setSelectionModel(sm);
|
||||
gridEnvironmentVariable.getView().setStripeRows(true);
|
||||
gridEnvironmentVariable.getView().setColumnLines(true);
|
||||
gridEnvironmentVariable.getView().setAutoExpandColumn(nameColumn);
|
||||
gridEnvironmentVariable.getView().setAutoFill(true);
|
||||
gridEnvironmentVariable.setBorders(false);
|
||||
gridEnvironmentVariable.setColumnReordering(false);
|
||||
gridSelectedRows.setSelectionModel(sm);
|
||||
gridSelectedRows.getView().setStripeRows(true);
|
||||
gridSelectedRows.getView().setColumnLines(true);
|
||||
gridSelectedRows.getView().setAutoExpandColumn(nameColumn);
|
||||
gridSelectedRows.getView().setAutoFill(true);
|
||||
gridSelectedRows.setBorders(false);
|
||||
gridSelectedRows.setColumnReordering(false);
|
||||
|
||||
|
||||
/*
|
||||
|
@ -191,7 +192,7 @@ public class SelectedRowsPanel extends ContentPanel {
|
|||
addHandlersForComboInputType(inputTypePropertiesCombo.label());
|
||||
|
||||
gridEnvironmentVariableEditing = new GridRowEditing<EnvironmentVariables>(
|
||||
gridEnvironmentVariable);
|
||||
gridSelectedRows);
|
||||
gridEnvironmentVariableEditing.addEditor(nameColumn, new TextField());
|
||||
gridEnvironmentVariableEditing.addEditor(descriptionColumn,
|
||||
new TextField());
|
||||
|
@ -291,7 +292,7 @@ public class SelectedRowsPanel extends ContentPanel {
|
|||
vlc.setScrollMode(ScrollMode.NONE);
|
||||
|
||||
vlc.add(toolBar, new VerticalLayoutData(1, -1, new Margins(0)));
|
||||
vlc.add(gridEnvironmentVariable, new VerticalLayoutData(1, 1,
|
||||
vlc.add(gridSelectedRows, new VerticalLayoutData(1, 1,
|
||||
new Margins(0)));
|
||||
|
||||
add(vlc, new MarginData(new Margins(0)));
|
||||
|
@ -334,5 +335,12 @@ public class SelectedRowsPanel extends ContentPanel {
|
|||
public void update() {
|
||||
|
||||
}
|
||||
|
||||
public ArrayList<EnvironmentVariables> getSelectedRows() {
|
||||
ArrayList<EnvironmentVariables> listEnviromentVarialbles = new ArrayList<>(
|
||||
gridSelectedRows.getStore().getAll());
|
||||
return listEnviromentVarialbles;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -8,6 +8,10 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.client.type;
|
|||
*/
|
||||
public enum ProjectStatusEventType {
|
||||
OPEN,
|
||||
MAINCODESET,
|
||||
UPDATE;
|
||||
MAIN_CODE_SET,
|
||||
UPDATE,
|
||||
ADD_RESOURCE,
|
||||
DELETE_RESOURCE,
|
||||
SAVE;
|
||||
|
||||
}
|
||||
|
|
|
@ -9,7 +9,8 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.client.type;
|
|||
public enum StatAlgoImporterRibbonType {
|
||||
PROJECT_CREATE,
|
||||
PROJECT_OPEN,
|
||||
ALGORITHM_IMPORT,
|
||||
ALGORITHM_CREATE,
|
||||
PROJECT_SAVE,
|
||||
RESOURCE_ADD,
|
||||
SOFTWARE_CREATE,
|
||||
HELP;
|
||||
}
|
||||
|
|
|
@ -8,13 +8,17 @@ import javax.servlet.http.HttpSession;
|
|||
import org.gcube.application.framework.core.session.ASLSession;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.rpc.StatAlgoImporterService;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.file.CodeReader;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.storage.FilesStorage;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.storage.ProjectArchiver;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.code.CodeData;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterServiceException;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.file.FileUploadMonitor;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.InputVariables;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.MainCode;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.ProjectFolder;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.session.UserInfo;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.workspace.ItemDescription;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -110,13 +114,12 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession=SessionUtil.getAslSession(session);
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
logger.debug("getCode()");
|
||||
Project projectSession = SessionUtil
|
||||
.getProjectSession(session);
|
||||
Project projectSession = SessionUtil.getProjectSession(session);
|
||||
if (projectSession != null) {
|
||||
CodeReader codeFileReader = new CodeReader(
|
||||
projectSession, aslSession);
|
||||
CodeReader codeFileReader = new CodeReader(projectSession,
|
||||
aslSession);
|
||||
ArrayList<CodeData> codeList = codeFileReader.getCodeList();
|
||||
for (CodeData codeData : codeList) {
|
||||
logger.debug("" + codeData.getId() + " "
|
||||
|
@ -143,17 +146,16 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
*
|
||||
*/
|
||||
@Override
|
||||
public void createProjectOnWorkspace(String itemId)
|
||||
public void createProjectOnWorkspace(ItemDescription itemDescription)
|
||||
throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
SessionUtil.getAslSession(session);
|
||||
logger.debug("createProjectOnWorkspace()");
|
||||
ProjectFolder projectFolder=new ProjectFolder(itemId);
|
||||
ProjectFolder projectFolder = new ProjectFolder(itemDescription);
|
||||
Project projectSession = new Project(projectFolder);
|
||||
SessionUtil.setProjectSession(session, projectSession);
|
||||
|
||||
|
||||
|
||||
return;
|
||||
} catch (StatAlgoImporterServiceException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -167,32 +169,131 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setMainCode(String itemId)
|
||||
public void setMainCode(ItemDescription itemDescription)
|
||||
throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
SessionUtil.getAslSession(session);
|
||||
logger.debug("SetMainCode()");
|
||||
Project project = SessionUtil
|
||||
.getProjectSession(session);
|
||||
Project project = SessionUtil.getProjectSession(session);
|
||||
if (project != null) {
|
||||
project.setMainCode(new MainCode(itemId));
|
||||
project.setMainCode(new MainCode(itemDescription));
|
||||
SessionUtil.setProjectSession(session, project);
|
||||
} else {
|
||||
throw new StatAlgoImporterServiceException("No project open!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
return;
|
||||
} catch (StatAlgoImporterServiceException e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
logger.error(
|
||||
"setMainCode(): " + e.getLocalizedMessage(), e);
|
||||
logger.error("setMainCode(): " + e.getLocalizedMessage(), e);
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addResourceToProject(ItemDescription itemDescription)
|
||||
throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
logger.debug("addResourceToProject(): " + itemDescription);
|
||||
if (itemDescription == null || itemDescription.getId()==null) {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"Add resource to project is failed, invalid resource: "
|
||||
+ itemDescription);
|
||||
}
|
||||
|
||||
Project project = SessionUtil.getProjectSession(session);
|
||||
if (project != null && project.getProjectFolder() != null
|
||||
&& project.getProjectFolder().getItemDescription() != null) {
|
||||
FilesStorage fileStorage = new FilesStorage();
|
||||
fileStorage.copyItemOnFolder(aslSession.getUsername(),
|
||||
itemDescription.getId(), project.getProjectFolder()
|
||||
.getItemDescription().getId());
|
||||
} else {
|
||||
throw new StatAlgoImporterServiceException("No project open!");
|
||||
}
|
||||
|
||||
return;
|
||||
} catch (StatAlgoImporterServiceException e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
logger.error("addResourceToProject(): " + e.getLocalizedMessage(),
|
||||
e);
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteResourceOnProject(ItemDescription itemDescription)
|
||||
throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
logger.debug("deleteResourceOnProject(): " + itemDescription);
|
||||
if (itemDescription == null || itemDescription.getId()==null) {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"Delete resource on project is failed, invalid resource: "
|
||||
+ itemDescription);
|
||||
}
|
||||
|
||||
Project project = SessionUtil.getProjectSession(session);
|
||||
if (project != null) {
|
||||
FilesStorage fileStorage = new FilesStorage();
|
||||
fileStorage.deleteItemOnFolder(aslSession.getUsername(),
|
||||
itemDescription.getId());
|
||||
} else {
|
||||
throw new StatAlgoImporterServiceException("No project open!");
|
||||
}
|
||||
|
||||
return;
|
||||
} catch (StatAlgoImporterServiceException e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
logger.error("deleteResourceOnProject(): " + e.getLocalizedMessage(),
|
||||
e);
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveProject(InputVariables inputVariables)
|
||||
throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession=SessionUtil.getAslSession(session);
|
||||
logger.debug("saveProject():"+inputVariables);
|
||||
Project project = SessionUtil.getProjectSession(session);
|
||||
if (project != null) {
|
||||
project.setInputVariable(inputVariables);
|
||||
SessionUtil.setProjectSession(session, project);
|
||||
ProjectArchiver.archive(project, aslSession);
|
||||
} else {
|
||||
throw new StatAlgoImporterServiceException("No project open!");
|
||||
}
|
||||
|
||||
return;
|
||||
} catch (StatAlgoImporterServiceException e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
logger.error("saveProject(): " + e.getLocalizedMessage(), e);
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -32,13 +32,17 @@ public class CodeReader {
|
|||
throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
|
||||
if (projectSession == null || projectSession.getMainCode() == null
|
||||
|| projectSession.getMainCode().getItemId() == null) {
|
||||
if (projectSession == null
|
||||
|| projectSession.getMainCode() == null
|
||||
|| projectSession.getMainCode().getItemDescription() == null
|
||||
|| projectSession.getMainCode().getItemDescription()
|
||||
.getId() == null) {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"Project hasn't a valid main set!");
|
||||
}
|
||||
|
||||
String itemId = projectSession.getMainCode().getItemId();
|
||||
String itemId = projectSession.getMainCode().getItemDescription()
|
||||
.getId();
|
||||
|
||||
code = new ArrayList<CodeData>();
|
||||
FilesStorage filesStorage = new FilesStorage();
|
||||
|
|
|
@ -8,8 +8,12 @@ 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.WorkspaceItem;
|
||||
import org.gcube.common.homelibrary.home.workspace.exceptions.InsufficientPrivilegesException;
|
||||
import org.gcube.common.homelibrary.home.workspace.exceptions.ItemAlreadyExistException;
|
||||
import org.gcube.common.homelibrary.home.workspace.exceptions.ItemNotFoundException;
|
||||
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.contentmanager.storageclient.model.protocol.smp.SMPUrl;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterServiceException;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -24,9 +28,91 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
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";
|
||||
|
||||
public static final Logger logger = LoggerFactory
|
||||
.getLogger(FilesStorage.class);
|
||||
|
||||
public void copyItemOnFolder(String user, String itemId, String folderId)
|
||||
throws StatAlgoImporterServiceException {
|
||||
Workspace ws;
|
||||
try {
|
||||
ws = HomeLibrary.getUserWorkspace(user);
|
||||
|
||||
WorkspaceItem workSpaceItem = ws.getItem(folderId);
|
||||
if (!workSpaceItem.isFolder()) {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"Destination is not a folder!");
|
||||
}
|
||||
|
||||
ws.copy(itemId, folderId);
|
||||
|
||||
return;
|
||||
} catch (WrongDestinationException | ItemAlreadyExistException
|
||||
| InsufficientPrivilegesException
|
||||
| WorkspaceFolderNotFoundException | InternalErrorException
|
||||
| HomeNotFoundException | ItemNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteItemOnFolder(String user, String itemId)
|
||||
throws StatAlgoImporterServiceException {
|
||||
Workspace ws;
|
||||
try {
|
||||
ws = HomeLibrary.getUserWorkspace(user);
|
||||
|
||||
ws.removeItems(itemId);
|
||||
|
||||
return;
|
||||
} catch (InsufficientPrivilegesException
|
||||
| WorkspaceFolderNotFoundException | InternalErrorException
|
||||
| HomeNotFoundException | ItemNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void saveItemOnFolder(String user, InputStream inputStream,
|
||||
String folderId) throws StatAlgoImporterServiceException {
|
||||
Workspace ws;
|
||||
try {
|
||||
ws = HomeLibrary.getUserWorkspace(user);
|
||||
|
||||
WorkspaceItem workSpaceItem = ws.getItem(folderId);
|
||||
if (!workSpaceItem.isFolder()) {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"Destination is not a folder!");
|
||||
}
|
||||
|
||||
WorkspaceItem projectItem = ws.find(
|
||||
STATISTICAL_ALGORITHM_PROJECT_FILE_NAME, folderId);
|
||||
|
||||
if (projectItem == null) {
|
||||
ws.createExternalFile(STATISTICAL_ALGORITHM_PROJECT_FILE_NAME,
|
||||
STATISTICAL_ALGORITHM_PROJECT_FILE_DESCRIPTION,
|
||||
STATISTICAL_ALGORITHM_PROJECT_MIMETYPE, inputStream,
|
||||
folderId);
|
||||
} else {
|
||||
ws.updateItem(projectItem.getId(), inputStream);
|
||||
}
|
||||
|
||||
return;
|
||||
} catch (WrongItemTypeException | WorkspaceFolderNotFoundException
|
||||
| InternalErrorException | HomeNotFoundException
|
||||
| ItemNotFoundException | InsufficientPrivilegesException
|
||||
| ItemAlreadyExistException | WrongDestinationException e) {
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -38,10 +124,11 @@ public class FilesStorage {
|
|||
ws = HomeLibrary.getUserWorkspace(user);
|
||||
|
||||
WorkspaceItem workSpaceItem = ws.getItem(itemId);
|
||||
if(workSpaceItem.isFolder()){
|
||||
throw new StatAlgoImporterServiceException("Folder is not valid item!");
|
||||
if (workSpaceItem.isFolder()) {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"Folder is not valid item!");
|
||||
}
|
||||
|
||||
|
||||
return retrieveImputStream(user, workSpaceItem);
|
||||
|
||||
} catch (WorkspaceFolderNotFoundException | InternalErrorException
|
||||
|
@ -87,6 +174,4 @@ public class FilesStorage {
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package org.gcube.portlets.user.statisticalalgorithmsimporter.server.storage;
|
||||
|
||||
import java.beans.XMLEncoder;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
import org.gcube.application.framework.core.session.ASLSession;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterServiceException;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -19,13 +22,19 @@ public class ProjectArchiver {
|
|||
.getLogger(ProjectArchiver.class);
|
||||
|
||||
|
||||
public static void archive(Project project) {
|
||||
public static void archive(Project project, ASLSession aslSession)
|
||||
throws StatAlgoImporterServiceException {
|
||||
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
XMLEncoder xmlEncoder = new XMLEncoder(byteArrayOutputStream);
|
||||
xmlEncoder.writeObject(project);
|
||||
xmlEncoder.close();
|
||||
logger.debug("Archived:" + byteArrayOutputStream);
|
||||
|
||||
ByteArrayInputStream byteArrayInputStream=new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
|
||||
FilesStorage filesStorage=new FilesStorage();
|
||||
filesStorage.saveItemOnFolder(aslSession.getUsername(), byteArrayInputStream, project.getProjectFolder().getItemDescription().getId());
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
package org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.EnvironmentVariables;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author giancarlo email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class InputVariables implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -2405068429998054485L;
|
||||
private ArrayList<EnvironmentVariables> listEnvironmentVariables;
|
||||
private ArrayList<EnvironmentVariables> listSelectedRows;
|
||||
|
||||
public InputVariables() {
|
||||
super();
|
||||
}
|
||||
|
||||
public InputVariables(
|
||||
ArrayList<EnvironmentVariables> listEnvironmentVariables,
|
||||
ArrayList<EnvironmentVariables> listSelectedRows) {
|
||||
super();
|
||||
this.listEnvironmentVariables = listEnvironmentVariables;
|
||||
this.listSelectedRows = listSelectedRows;
|
||||
}
|
||||
|
||||
public ArrayList<EnvironmentVariables> getListEnvironmentVariables() {
|
||||
return listEnvironmentVariables;
|
||||
}
|
||||
|
||||
public void setListEnvironmentVariables(
|
||||
ArrayList<EnvironmentVariables> listEnvironmentVariables) {
|
||||
this.listEnvironmentVariables = listEnvironmentVariables;
|
||||
}
|
||||
|
||||
public ArrayList<EnvironmentVariables> getListSelectedRows() {
|
||||
return listSelectedRows;
|
||||
}
|
||||
|
||||
public void setListSelectedRows(
|
||||
ArrayList<EnvironmentVariables> listSelectedRows) {
|
||||
this.listSelectedRows = listSelectedRows;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "InputVariables [listEnvironmentVariables="
|
||||
+ listEnvironmentVariables + ", listSelectedRows="
|
||||
+ listSelectedRows + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -2,6 +2,8 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.workspace.ItemDescription;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
|
@ -11,24 +13,28 @@ import java.io.Serializable;
|
|||
public class MainCode implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 6328159797277211090L;
|
||||
private String itemId;
|
||||
private ItemDescription itemDescription;
|
||||
|
||||
public MainCode(String itemId) {
|
||||
public MainCode() {
|
||||
super();
|
||||
this.itemId = itemId;
|
||||
}
|
||||
|
||||
public String getItemId() {
|
||||
return itemId;
|
||||
public MainCode(ItemDescription itemDescription) {
|
||||
super();
|
||||
this.itemDescription = itemDescription;
|
||||
}
|
||||
|
||||
public void setItemId(String itemId) {
|
||||
this.itemId = itemId;
|
||||
public ItemDescription getItemDescription() {
|
||||
return itemDescription;
|
||||
}
|
||||
|
||||
public void setItemDescription(ItemDescription itemDescription) {
|
||||
this.itemDescription = itemDescription;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MainCode [itemId=" + itemId + "]";
|
||||
return "MainCode [itemDescription=" + itemDescription + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,11 @@ public class Project implements Serializable {
|
|||
|
||||
private ProjectFolder projectFolder;
|
||||
private MainCode mainCode;
|
||||
private InputVariables inputVariable;
|
||||
|
||||
public Project(){
|
||||
super();
|
||||
}
|
||||
|
||||
public Project(ProjectFolder projectFolder) {
|
||||
super();
|
||||
|
@ -37,12 +42,22 @@ public class Project implements Serializable {
|
|||
this.projectFolder = projectFolder;
|
||||
}
|
||||
|
||||
public InputVariables getInputVariable() {
|
||||
return inputVariable;
|
||||
}
|
||||
|
||||
public void setInputVariable(InputVariables inputVariable) {
|
||||
this.inputVariable = inputVariable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Project [projectFolder=" + projectFolder + ", mainCode="
|
||||
+ mainCode + "]";
|
||||
+ mainCode + ", inputVariable=" + inputVariable + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.workspace.ItemDescription;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
|
@ -11,26 +13,31 @@ import java.io.Serializable;
|
|||
public class ProjectFolder implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 3698120963507381801L;
|
||||
private String itemId;
|
||||
|
||||
public ProjectFolder(String itemId) {
|
||||
private ItemDescription itemDescription;
|
||||
|
||||
public ProjectFolder(){
|
||||
super();
|
||||
this.itemId = itemId;
|
||||
}
|
||||
|
||||
public String getItemId() {
|
||||
return itemId;
|
||||
public ProjectFolder(ItemDescription itemDescription) {
|
||||
super();
|
||||
this.itemDescription = itemDescription;
|
||||
}
|
||||
|
||||
public void setItemId(String itemId) {
|
||||
this.itemId = itemId;
|
||||
public ItemDescription getItemDescription() {
|
||||
return itemDescription;
|
||||
}
|
||||
|
||||
public void setItemDescription(ItemDescription itemDescription) {
|
||||
this.itemDescription = itemDescription;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ProjectFolder [itemId=" + itemId + "]";
|
||||
return "ProjectFolder [itemDescription=" + itemDescription + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.maindata;
|
||||
package org.gcube.portlets.user.statisticalalgorithmsimporter.shared.workspace;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
@ -16,17 +16,20 @@ public class ItemDescription implements Serializable {
|
|||
private String name;
|
||||
private String owner;
|
||||
private String path;
|
||||
private String type;
|
||||
|
||||
public ItemDescription(){
|
||||
super();
|
||||
}
|
||||
|
||||
public ItemDescription(String id, String name, String owner, String path) {
|
||||
public ItemDescription(String id, String name, String owner, String path,
|
||||
String type) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.owner = owner;
|
||||
this.path = path;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
|
@ -61,11 +64,20 @@ public class ItemDescription implements Serializable {
|
|||
this.path = path;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ItemDescription [id=" + id + ", name=" + name + ", owner="
|
||||
+ owner + ", path=" + path + "]";
|
||||
+ owner + ", path=" + path + ", type=" + type + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 1.0 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
After Width: | Height: | Size: 710 B |
Loading…
Reference in New Issue