1452: Implement a GUI for StatMan Algorithms Importer
Task-Url: https://support.d4science.org/issues/1452 Updated Importer git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/statistical-algorithms-importer@121696 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
8dc3149234
commit
c77b18b404
46
pom.xml
46
pom.xml
|
@ -79,6 +79,24 @@
|
|||
<artifactId>log4j</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>home-library</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>home-library-jcr</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>home-library-model</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
</profile>
|
||||
|
@ -212,7 +230,7 @@
|
|||
<artifactId>juniversalchardet</artifactId>
|
||||
<version>1.0.3</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- AceGWT Widget -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.portlets.widget</groupId>
|
||||
|
@ -220,6 +238,32 @@
|
|||
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Workspace Explorer -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.portlets.widgets</groupId>
|
||||
<artifactId>workspace-explorer</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>home-library</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>home-library-jcr</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>home-library-model</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- LOGGING -->
|
||||
<dependency>
|
||||
<groupId>com.allen-sauer.gwt.log</groupId>
|
||||
|
|
|
@ -30,7 +30,7 @@ public class StatAlgoImporter implements EntryPoint {
|
|||
|
||||
private static final String JSP_TAG_ID = "StatAlgoImporterPortlet";
|
||||
|
||||
private static final int RIBBON_HEIGHT = 110;
|
||||
private static final int RIBBON_HEIGHT = 104;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private final StatAlgoImporterServiceAsync statAlgoImporterService = GWT
|
||||
|
@ -106,9 +106,8 @@ public class StatAlgoImporter implements EntryPoint {
|
|||
// estData.setMaxSize(510);
|
||||
// estData.setMinSize(310);
|
||||
mainPanelLayout.setEastWidget(toolsPanel, eastData);
|
||||
// codeUploadPanel.expand();
|
||||
toolsPanel.enable();
|
||||
|
||||
toolsPanel.collapse();
|
||||
|
||||
bind(mainPanelLayout);
|
||||
controller.setMainPanelLayout(mainPanelLayout);
|
||||
|
|
|
@ -3,12 +3,13 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.client;
|
|||
import java.util.Date;
|
||||
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.ImportCodeEvent;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.ProjectStatusEvent;
|
||||
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.MainCodeDescription;
|
||||
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.ProjectStatusEventType;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.type.SessionExpiredType;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.type.StatAlgoImporterRibbonType;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.type.UIStateType;
|
||||
|
@ -41,11 +42,11 @@ public class StatAlgoImporterController {
|
|||
private UserInfo userInfo;
|
||||
@SuppressWarnings("unused")
|
||||
private BorderLayoutContainer mainPanel;
|
||||
private ProjectManager pm;
|
||||
|
||||
|
||||
|
||||
public StatAlgoImporterController() {
|
||||
eventBus = new SimpleEventBus();
|
||||
pm = new ProjectManager(eventBus);
|
||||
init();
|
||||
}
|
||||
|
||||
|
@ -76,27 +77,31 @@ public class StatAlgoImporterController {
|
|||
}
|
||||
|
||||
private void callHello() {
|
||||
StatAlgoImporterServiceAsync.INSTANCE.hello(new AsyncCallback<UserInfo>() {
|
||||
StatAlgoImporterServiceAsync.INSTANCE
|
||||
.hello(new AsyncCallback<UserInfo>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
Log.info("No valid user found: " + caught.getMessage());
|
||||
if (caught instanceof StatAlgoImporterSessionExpiredException) {
|
||||
UtilsGXT3.alert("Error", "Expired Session");
|
||||
sessionExpiredShowDelayed();
|
||||
} else {
|
||||
UtilsGXT3.alert("Error", "No user found: "+caught.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
Log.info("No valid user found: " + caught.getMessage());
|
||||
if (caught instanceof StatAlgoImporterSessionExpiredException) {
|
||||
UtilsGXT3.alert("Error", "Expired Session");
|
||||
sessionExpiredShowDelayed();
|
||||
} else {
|
||||
UtilsGXT3.alert(
|
||||
"Error",
|
||||
"No user found: "
|
||||
+ caught.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(UserInfo result) {
|
||||
userInfo = result;
|
||||
Log.info("Hello: " + userInfo.getUsername());
|
||||
@Override
|
||||
public void onSuccess(UserInfo result) {
|
||||
userInfo = result;
|
||||
Log.info("Hello: " + userInfo.getUsername());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
@ -165,12 +170,12 @@ public class StatAlgoImporterController {
|
|||
|
||||
@Override
|
||||
public void onSelect(StatAlgoImporterRibbonEvent event) {
|
||||
Log.debug("Catch StatRunnerRibbonEvent");
|
||||
Log.debug("Catch StatAlgoImportRibbonEvent");
|
||||
doMenuCommand(event);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
eventBus.addHandler(ImportCodeEvent.TYPE,
|
||||
new ImportCodeEvent.ImportCodeEventHandler() {
|
||||
|
||||
|
@ -178,55 +183,84 @@ public class StatAlgoImporterController {
|
|||
public void onImportCode(ImportCodeEvent event) {
|
||||
Log.debug("Catch ImportCodeEvent");
|
||||
doImportCodeCommand(event);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
eventBus.addHandler(MainCodeSetEvent.TYPE,
|
||||
new MainCodeSetEvent.MainCodeSetEventHandler() {
|
||||
|
||||
@Override
|
||||
public void onMainCodeSet(MainCodeSetEvent event) {
|
||||
Log.debug("Catch MainCodeSetEvent");
|
||||
doMainCodeSetCommand(event);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
eventBus.fireEvent(new UIStateEvent(UIStateType.START));
|
||||
|
||||
}
|
||||
|
||||
private void doMenuCommand(StatAlgoImporterRibbonEvent event) {
|
||||
StatAlgoImporterRibbonType eventType=event.getStatRunnerRibbonType();
|
||||
if(eventType==null){
|
||||
StatAlgoImporterRibbonType eventType = event.getStatRunnerRibbonType();
|
||||
if (eventType == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch(eventType){
|
||||
Log.debug("StatAlgoRibbonEvent: " + event);
|
||||
|
||||
switch (eventType) {
|
||||
case PROJECT_CREATE:
|
||||
showCreateProjectDialog();
|
||||
break;
|
||||
case PROJECT_OPEN:
|
||||
break;
|
||||
case ALGORITHM_CREATE:
|
||||
break;
|
||||
case ALGORITHM_IMPORT:
|
||||
showCodeUploadPanel();
|
||||
showCodeUploadDialog();
|
||||
break;
|
||||
case HELP:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void showCreateProjectDialog() {
|
||||
pm.createProject();
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void doMainCodeSetCommand(MainCodeSetEvent event) {
|
||||
MainCodeDescription mainCodeDescription = event.getMainCodeDescription();
|
||||
if (mainCodeDescription != null
|
||||
&& mainCodeDescription.getId() != null) {
|
||||
pm.setMainCode(mainCodeDescription);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void doImportCodeCommand(ImportCodeEvent event) {
|
||||
ImportCodeDescription importCodeDesc=event.getImportCodeDescription();
|
||||
if(importCodeDesc!=null && importCodeDesc.getImportCodeType()!=null){
|
||||
ProjectStatusEvent projectStatusEvent= new ProjectStatusEvent(ProjectStatusEventType.UPDATE);
|
||||
eventBus.fireEvent(projectStatusEvent);
|
||||
Log.debug("ProjectStatusEvent fired");
|
||||
ImportCodeDescription importCodeDesc = event.getImportCodeDescription();
|
||||
if (importCodeDesc != null
|
||||
&& importCodeDesc.getImportCodeType() != null) {
|
||||
pm.importCode(importCodeDesc);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void showCodeUploadPanel() {
|
||||
CodeUploadDialog codeUploadDialog=new CodeUploadDialog(eventBus);
|
||||
}
|
||||
|
||||
private void showCodeUploadDialog() {
|
||||
CodeUploadDialog codeUploadDialog = new CodeUploadDialog(eventBus);
|
||||
codeUploadDialog.show();
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.event;
|
||||
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.maindata.MainCodeDescription;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* Main Code Set Event
|
||||
*
|
||||
*
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class MainCodeSetEvent extends
|
||||
GwtEvent<MainCodeSetEvent.MainCodeSetEventHandler> {
|
||||
|
||||
public static Type<MainCodeSetEventHandler> TYPE = new Type<MainCodeSetEventHandler>();
|
||||
private MainCodeDescription mainCodeDescription;
|
||||
|
||||
public interface MainCodeSetEventHandler extends EventHandler {
|
||||
void onMainCodeSet(MainCodeSetEvent event);
|
||||
}
|
||||
|
||||
public interface HasMainCodeSetEventHandler extends HasHandlers {
|
||||
public HandlerRegistration addMainCodeSetEventHandler(
|
||||
MainCodeSetEventHandler handler);
|
||||
}
|
||||
|
||||
public MainCodeSetEvent(MainCodeDescription mainCodeDescription) {
|
||||
this.mainCodeDescription = mainCodeDescription;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dispatch(MainCodeSetEventHandler handler) {
|
||||
handler.onMainCodeSet(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type<MainCodeSetEventHandler> getAssociatedType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public static Type<MainCodeSetEventHandler> getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public static void fire(HasHandlers source,
|
||||
MainCodeSetEvent importCodeEvent) {
|
||||
source.fireEvent(importCodeEvent);
|
||||
}
|
||||
|
||||
public MainCodeDescription getMainCodeDescription() {
|
||||
return mainCodeDescription;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MainCodeSetEvent [mainCodeDescription=" + mainCodeDescription
|
||||
+ "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -20,7 +20,8 @@ public class ProjectStatusEvent extends
|
|||
|
||||
public static Type<ProjectStatusEventHandler> TYPE = new Type<ProjectStatusEventHandler>();
|
||||
private ProjectStatusEventType projectStatusEventType;
|
||||
|
||||
private String projectFolderId;
|
||||
|
||||
public interface ProjectStatusEventHandler extends EventHandler {
|
||||
void onProjectStatus(ProjectStatusEvent event);
|
||||
}
|
||||
|
@ -30,8 +31,9 @@ public class ProjectStatusEvent extends
|
|||
ProjectStatusEventHandler handler);
|
||||
}
|
||||
|
||||
public ProjectStatusEvent(ProjectStatusEventType projectStatusEventType) {
|
||||
public ProjectStatusEvent(ProjectStatusEventType projectStatusEventType,String projectFolderId) {
|
||||
this.projectStatusEventType = projectStatusEventType;
|
||||
this.projectFolderId = projectFolderId;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -57,9 +59,16 @@ public class ProjectStatusEvent extends
|
|||
return projectStatusEventType;
|
||||
}
|
||||
|
||||
public String getProjectFolderId() {
|
||||
return projectFolderId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ProjectStatusEvent [projectStatusEventType="
|
||||
+ projectStatusEventType + "]";
|
||||
+ projectStatusEventType + ", projectFolderId="
|
||||
+ projectFolderId + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.controller;
|
||||
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.type.ControllerRequestEventType;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ControllerRequestEvent extends
|
||||
GwtEvent<ControllerRequestEvent.ControllerRequestEventHandler> {
|
||||
|
||||
public static Type<ControllerRequestEventHandler> TYPE = new Type<ControllerRequestEventHandler>();
|
||||
private ControllerRequestEventType controllerRequestEventType;
|
||||
private String projectFolderId;
|
||||
|
||||
public interface ControllerRequestEventHandler extends EventHandler {
|
||||
void onControllerRequest(ControllerRequestEvent event);
|
||||
}
|
||||
|
||||
public interface HasControllerRequestEventHandler extends HasHandlers {
|
||||
public HandlerRegistration addControllerRequestEventHandler(
|
||||
ControllerRequestEventHandler handler);
|
||||
}
|
||||
|
||||
public ControllerRequestEvent(ControllerRequestEventType projectStatusEventType) {
|
||||
this.controllerRequestEventType = projectStatusEventType;
|
||||
}
|
||||
|
||||
public ControllerRequestEvent(ControllerRequestEventType projectStatusEventType, String projectFolderId) {
|
||||
this.controllerRequestEventType = projectStatusEventType;
|
||||
this.projectFolderId = projectFolderId;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void dispatch(ControllerRequestEventHandler handler) {
|
||||
handler.onControllerRequest(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type<ControllerRequestEventHandler> getAssociatedType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public static Type<ControllerRequestEventHandler> getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public static void fire(HasHandlers source,
|
||||
ControllerRequestEvent projectStatusEvent) {
|
||||
source.fireEvent(projectStatusEvent);
|
||||
}
|
||||
|
||||
public ControllerRequestEventType getControllerRequestEventType() {
|
||||
return controllerRequestEventType;
|
||||
}
|
||||
|
||||
public String getProjectFolderId() {
|
||||
return projectFolderId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ControllerRequestEvent [controllerRequestEventType="
|
||||
+ controllerRequestEventType + ", projectFolderId="
|
||||
+ projectFolderId + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -58,8 +58,7 @@ public class CodeEditPanel extends ContentPanel {
|
|||
|
||||
add(v);
|
||||
editor.startEditor();
|
||||
loadCode();
|
||||
|
||||
editor.setShowPrintMargin(false);
|
||||
}
|
||||
|
||||
private void loadCode() {
|
||||
|
@ -82,16 +81,24 @@ public class CodeEditPanel extends ContentPanel {
|
|||
|
||||
public void onSuccess(ArrayList<CodeData> result) {
|
||||
Log.debug("loaded " + result.size() + " code lines");
|
||||
String text = new String();
|
||||
for (CodeData codeData : result) {
|
||||
//Log.debug("Read: " + codeData);
|
||||
text+=codeData.getCodeLine()+"\r\n";
|
||||
if (result != null && result.size() > 0) {
|
||||
|
||||
String text = new String();
|
||||
for (CodeData codeData : result) {
|
||||
// Log.debug("Read: " + codeData);
|
||||
text += codeData.getCodeLine() + "\r\n";
|
||||
}
|
||||
|
||||
editor.setShowPrintMargin(false);
|
||||
editor.setMode(AceEditorMode.R);
|
||||
editor.setTheme(AceEditorTheme.ECLIPSE);
|
||||
editor.setText(text);
|
||||
} else {
|
||||
editor.setShowPrintMargin(false);
|
||||
editor.setMode(AceEditorMode.R);
|
||||
editor.setTheme(AceEditorTheme.ECLIPSE);
|
||||
editor.setText("");
|
||||
}
|
||||
|
||||
editor.setShowPrintMargin(false);
|
||||
editor.setMode(AceEditorMode.R);
|
||||
editor.setTheme(AceEditorTheme.ECLIPSE);
|
||||
editor.setText(text);
|
||||
forceLayout();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.maindata;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class MainCodeDescription implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -6624452446980057923L;
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
private String owner;
|
||||
private String path;
|
||||
|
||||
public MainCodeDescription(String id, String name, String owner, String path) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.owner = owner;
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setOwner(String owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MainCodeDescription [id=" + id + ", name=" + name + ", owner="
|
||||
+ owner + ", path=" + path + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -54,11 +54,21 @@ public class MainDataPanel extends SimpleContainer {
|
|||
}
|
||||
|
||||
private void doProjectStatusCommand(ProjectStatusEvent event) {
|
||||
if (codeEditPanel == null) {
|
||||
addCodeEditPanel();
|
||||
} else {
|
||||
codeEditPanel.codeUpdate();
|
||||
if(event.getProjectStatusEventType()==null){
|
||||
return;
|
||||
}
|
||||
switch(event.getProjectStatusEventType()){
|
||||
case OPEN:
|
||||
addCodeEditPanel();
|
||||
break;
|
||||
case UPDATE:
|
||||
codeEditPanel.codeUpdate();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void addCodeEditPanel() {
|
||||
|
|
|
@ -0,0 +1,114 @@
|
|||
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.project;
|
||||
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.ProjectStatusEvent;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.maindata.MainCodeDescription;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.type.ProjectStatusEventType;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.upload.ImportCodeDescription;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.utils.UtilsGXT3;
|
||||
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;
|
||||
import org.gcube.portlets.widgets.wsexplorer.shared.ItemType;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.event.shared.EventBus;
|
||||
import com.sencha.gxt.core.client.dom.XDOM;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author giancarlo
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ProjectManager {
|
||||
private EventBus eventBus;
|
||||
private String projectFolderId;
|
||||
|
||||
public ProjectManager(EventBus eventBus){
|
||||
this.eventBus=eventBus;
|
||||
}
|
||||
|
||||
public void createProject(){
|
||||
/*
|
||||
List<ItemType> selectableTypes = new ArrayList<ItemType>();
|
||||
selectableTypes.add(ItemType.FOLDER);
|
||||
List<ItemType> showableTypes = new ArrayList<ItemType>();
|
||||
showableTypes.addAll(Arrays.asList(ItemType.FOLDER));
|
||||
*/
|
||||
/*
|
||||
List<String> allowedMimeTypes = Arrays.asList("text/csv",
|
||||
"application/zip", "application/x-zip",
|
||||
"application/x-zip-compressed", "application/octet-stream",
|
||||
"application/x-compress", "application/x-compressed",
|
||||
"multipart/x-zip");
|
||||
List<String> allowedFileExtensions = Arrays.asList("csv", "zip");
|
||||
|
||||
FilterCriteria filterCriteria = new FilterCriteria(allowedMimeTypes,
|
||||
allowedFileExtensions, new HashMap<String, String>());
|
||||
*/
|
||||
WorkspaceExplorerSelectDialog wselectDialog = new WorkspaceExplorerSelectDialog(
|
||||
"Select Project Folder",true);
|
||||
|
||||
WorskpaceExplorerSelectNotificationListener handler = new WorskpaceExplorerSelectNotificationListener() {
|
||||
|
||||
@Override
|
||||
public void onSelectedItem(Item item) {
|
||||
|
||||
if (item.getType() == ItemType.FOLDER) {
|
||||
createProjectOnWorkspace(item);
|
||||
|
||||
} else {
|
||||
UtilsGXT3.info("Attention", "Select a valid project folder!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed(Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAborted() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNotValidSelection() {
|
||||
UtilsGXT3.info("Attention", "Select a valid project folder!");
|
||||
}
|
||||
};
|
||||
|
||||
wselectDialog.addWorkspaceExplorerSelectNotificationListener(handler);
|
||||
wselectDialog.setZIndex(XDOM.getTopZIndex());
|
||||
wselectDialog.show();
|
||||
}
|
||||
|
||||
protected void createProjectOnWorkspace(Item item){
|
||||
Log.debug("Item selected: "+item);
|
||||
projectFolderId=item.getId();
|
||||
ProjectStatusEvent projectStatusEvent= new ProjectStatusEvent(ProjectStatusEventType.OPEN, projectFolderId);
|
||||
eventBus.fireEvent(projectStatusEvent);
|
||||
Log.debug("ProjectStatusEvent fired");
|
||||
|
||||
}
|
||||
|
||||
public void importCode(ImportCodeDescription importCodeDesc) {
|
||||
ProjectStatusEvent projectStatusEvent= new ProjectStatusEvent(ProjectStatusEventType.UPDATE, projectFolderId);
|
||||
eventBus.fireEvent(projectStatusEvent);
|
||||
Log.debug("ProjectStatusEvent fired");
|
||||
|
||||
}
|
||||
|
||||
public void setMainCode(MainCodeDescription mainCodeDescription) {
|
||||
ProjectStatusEvent projectStatusEvent= new ProjectStatusEvent(ProjectStatusEventType.UPDATE, projectFolderId);
|
||||
eventBus.fireEvent(projectStatusEvent);
|
||||
Log.debug("ProjectStatusEvent fired");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -33,7 +33,7 @@ import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
|
|||
*
|
||||
*/
|
||||
public class HomeToolBar {
|
||||
private static final String GROUP_HEIGHT = "72px";
|
||||
private static final String GROUP_HEIGHT = "64px";
|
||||
private HomeToolBarMessages msgs;
|
||||
private EventBus eventBus;
|
||||
private ToolBar toolBar;
|
||||
|
@ -42,9 +42,12 @@ public class HomeToolBar {
|
|||
private TextButton btnCreateProject;
|
||||
private TextButton btnOpenProject;
|
||||
|
||||
//Algorithm
|
||||
private TextButton btnImportAlgorithm;
|
||||
private TextButton btnCreateAlgorithm;
|
||||
//Resources
|
||||
private TextButton btnAddResource;
|
||||
|
||||
|
||||
//Software
|
||||
private TextButton btnCreateSoftware;
|
||||
|
||||
|
||||
// Help
|
||||
|
@ -98,7 +101,7 @@ public class HomeToolBar {
|
|||
|
||||
public void onSelect(SelectEvent event) {
|
||||
eventBus.fireEvent(new StatAlgoImporterRibbonEvent(
|
||||
StatAlgoImporterRibbonType.ALGORITHM_IMPORT));
|
||||
StatAlgoImporterRibbonType.PROJECT_CREATE));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -117,33 +120,31 @@ public class HomeToolBar {
|
|||
|
||||
public void onSelect(SelectEvent event) {
|
||||
eventBus.fireEvent(new StatAlgoImporterRibbonEvent(
|
||||
StatAlgoImporterRibbonType.ALGORITHM_IMPORT));
|
||||
StatAlgoImporterRibbonType.PROJECT_OPEN));
|
||||
}
|
||||
});
|
||||
|
||||
homeLayout.setWidget(0, 1, btnOpenProject);
|
||||
homeLayout.getFlexCellFormatter().setRowSpan(0, 1, 2);
|
||||
|
||||
|
||||
// Algorithm
|
||||
ButtonGroup algorithmGroup = new ButtonGroup();
|
||||
algorithmGroup.setId("Algorithm");
|
||||
algorithmGroup.setHeadingText(msgs.algorithmGroupHeadingText());
|
||||
algorithmGroup.setHeight(GROUP_HEIGHT);
|
||||
toolBar.add(algorithmGroup);
|
||||
// Resources
|
||||
ButtonGroup resourcesGroup = new ButtonGroup();
|
||||
resourcesGroup.setId("Resource");
|
||||
resourcesGroup.setHeadingText(msgs.resourceGroupHeadingText());
|
||||
resourcesGroup.setHeight(GROUP_HEIGHT);
|
||||
toolBar.add(resourcesGroup);
|
||||
|
||||
FlexTable algorithmLayout = new FlexTable();
|
||||
algorithmGroup.add(algorithmLayout);
|
||||
FlexTable resourcesLayout = new FlexTable();
|
||||
resourcesGroup.add(resourcesLayout);
|
||||
|
||||
btnImportAlgorithm = new TextButton(msgs.importButton(),
|
||||
btnAddResource = new TextButton(msgs.btnAddResourceText(),
|
||||
StatAlgoImporterResources.INSTANCE.upload24());
|
||||
btnImportAlgorithm.setId("importButton");
|
||||
btnImportAlgorithm.setScale(ButtonScale.SMALL);
|
||||
btnImportAlgorithm.setIconAlign(IconAlign.LEFT);
|
||||
btnImportAlgorithm.setArrowAlign(ButtonArrowAlign.BOTTOM);
|
||||
btnImportAlgorithm.setToolTip(msgs.importButtonToolTip());
|
||||
btnImportAlgorithm.getElement().setMargins(new Margins(0, 4, 0, 0));
|
||||
btnImportAlgorithm.addSelectHandler(new SelectHandler() {
|
||||
btnAddResource.setId("btnAddResource");
|
||||
btnAddResource.setScale(ButtonScale.SMALL);
|
||||
btnAddResource.setIconAlign(IconAlign.LEFT);
|
||||
btnAddResource.setArrowAlign(ButtonArrowAlign.BOTTOM);
|
||||
btnAddResource.setToolTip(msgs.btnAddResourceToolTip());
|
||||
btnAddResource.addSelectHandler(new SelectHandler() {
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
eventBus.fireEvent(new StatAlgoImporterRibbonEvent(
|
||||
|
@ -151,19 +152,28 @@ public class HomeToolBar {
|
|||
}
|
||||
});
|
||||
|
||||
algorithmLayout.setWidget(0, 0, btnImportAlgorithm);
|
||||
algorithmLayout.getFlexCellFormatter().setRowSpan(0, 0, 2);
|
||||
|
||||
resourcesLayout.setWidget(0, 0, btnAddResource);
|
||||
resourcesLayout.getFlexCellFormatter().setRowSpan(0, 0, 2);
|
||||
|
||||
btnCreateAlgorithm = new TextButton(msgs.createAlgorithmButton(),
|
||||
StatAlgoImporterResources.INSTANCE.algorithm24());
|
||||
btnCreateAlgorithm.setId("createAlgorithmButton");
|
||||
btnCreateAlgorithm.setScale(ButtonScale.SMALL);
|
||||
btnCreateAlgorithm.setIconAlign(IconAlign.LEFT);
|
||||
btnCreateAlgorithm.setArrowAlign(ButtonArrowAlign.BOTTOM);
|
||||
btnCreateAlgorithm.setToolTip(msgs.createAlgorithmButtonToolTip());
|
||||
// Software
|
||||
ButtonGroup softwareGroup = new ButtonGroup();
|
||||
softwareGroup.setId("SoftwareGroup");
|
||||
softwareGroup.setHeadingText(msgs.softwareGroupHeadingText());
|
||||
softwareGroup.setHeight(GROUP_HEIGHT);
|
||||
toolBar.add(softwareGroup);
|
||||
|
||||
btnCreateAlgorithm.addSelectHandler(new SelectHandler() {
|
||||
FlexTable softwareLayout = new FlexTable();
|
||||
softwareGroup.add(softwareLayout);
|
||||
|
||||
btnCreateSoftware = new TextButton(msgs.btnCreateSoftwareText(),
|
||||
StatAlgoImporterResources.INSTANCE.algorithm24());
|
||||
btnCreateSoftware.setId("createAlgorithmButton");
|
||||
btnCreateSoftware.setScale(ButtonScale.SMALL);
|
||||
btnCreateSoftware.setIconAlign(IconAlign.LEFT);
|
||||
btnCreateSoftware.setArrowAlign(ButtonArrowAlign.BOTTOM);
|
||||
btnCreateSoftware.setToolTip(msgs.btnCreateSoftwareToolTip());
|
||||
|
||||
btnCreateSoftware.addSelectHandler(new SelectHandler() {
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
eventBus.fireEvent(new StatAlgoImporterRibbonEvent(
|
||||
|
@ -171,8 +181,8 @@ public class HomeToolBar {
|
|||
}
|
||||
});
|
||||
|
||||
algorithmLayout.setWidget(0, 1, btnCreateAlgorithm);
|
||||
algorithmLayout.getFlexCellFormatter().setRowSpan(0, 1, 2);
|
||||
softwareLayout.setWidget(0, 0, btnCreateSoftware);
|
||||
softwareLayout.getFlexCellFormatter().setRowSpan(0, 0, 2);
|
||||
|
||||
// Help
|
||||
ButtonGroup helpGroup = new ButtonGroup();
|
||||
|
@ -308,8 +318,10 @@ public class HomeToolBar {
|
|||
try {
|
||||
switch (uiStateType) {
|
||||
case START:
|
||||
btnImportAlgorithm.enable();
|
||||
btnCreateAlgorithm.enable();
|
||||
btnCreateProject.enable();
|
||||
btnOpenProject.enable();
|
||||
btnAddResource.enable();
|
||||
btnCreateSoftware.enable();
|
||||
btnHelp.enable();
|
||||
|
||||
// testButton.disable();
|
||||
|
|
|
@ -43,23 +43,26 @@ public interface HomeToolBarMessages extends Messages {
|
|||
|
||||
@DefaultMessage("Open Project")
|
||||
String btnOpenProjectToolTip();
|
||||
|
||||
|
||||
//
|
||||
@DefaultMessage("Algorithm")
|
||||
String algorithmGroupHeadingText();
|
||||
@DefaultMessage("Resource")
|
||||
String resourceGroupHeadingText();
|
||||
|
||||
@DefaultMessage("Import")
|
||||
String importButton();
|
||||
@DefaultMessage("Add")
|
||||
String btnAddResourceText();
|
||||
|
||||
@DefaultMessage("Import algorithm")
|
||||
String importButtonToolTip();
|
||||
@DefaultMessage("Add Resource")
|
||||
String btnAddResourceToolTip();
|
||||
|
||||
//
|
||||
@DefaultMessage("Software")
|
||||
String softwareGroupHeadingText();
|
||||
|
||||
@DefaultMessage("Create")
|
||||
String createAlgorithmButton();
|
||||
String btnCreateSoftwareText();
|
||||
|
||||
@DefaultMessage("Create algorithm for Statistical Manager")
|
||||
String createAlgorithmButtonToolTip();
|
||||
@DefaultMessage("Create Software")
|
||||
String btnCreateSoftwareToolTip();
|
||||
|
||||
//
|
||||
@DefaultMessage("Help")
|
||||
|
@ -72,4 +75,6 @@ public interface HomeToolBarMessages extends Messages {
|
|||
String helpButtonToolTip();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -19,7 +19,7 @@ import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.Verti
|
|||
*/
|
||||
public class StatAlgoImporterRibbon {
|
||||
|
||||
private static final String RIBBON_HEIGHT = "76px";
|
||||
private static final String RIBBON_HEIGHT = "70px";
|
||||
|
||||
private TabPanel ribbon;
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ 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.ProjectOnWorkspaceStatus;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.session.UserInfo;
|
||||
|
||||
import com.google.gwt.user.client.rpc.RemoteService;
|
||||
|
@ -37,6 +38,14 @@ public interface StatAlgoImporterService extends RemoteService {
|
|||
throws StatAlgoImporterServiceException;
|
||||
|
||||
// Code
|
||||
public ArrayList<CodeData> getCode() throws StatAlgoImporterServiceException;
|
||||
public ArrayList<CodeData> getCode()
|
||||
throws StatAlgoImporterServiceException;
|
||||
|
||||
public ProjectOnWorkspaceStatus createProjectOnWorkspace(String itemId)
|
||||
throws StatAlgoImporterServiceException;
|
||||
//
|
||||
public void setMainCode(String itemId)
|
||||
throws StatAlgoImporterServiceException;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
*/
|
||||
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.rpc;
|
||||
|
||||
|
||||
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.ProjectOnWorkspaceStatus;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.session.UserInfo;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
|
@ -15,15 +15,15 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
|
|||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public interface StatAlgoImporterServiceAsync {
|
||||
|
||||
public static StatAlgoImporterServiceAsync INSTANCE = (StatAlgoImporterServiceAsync) GWT
|
||||
.create(StatAlgoImporterService.class);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param callback
|
||||
|
@ -34,7 +34,9 @@ public interface StatAlgoImporterServiceAsync {
|
|||
|
||||
void getCode(AsyncCallback<ArrayList<CodeData>> callback);
|
||||
|
||||
void createProjectOnWorkspace(String itemId,
|
||||
AsyncCallback<ProjectOnWorkspaceStatus> callback);
|
||||
|
||||
|
||||
void setMainCode(String itemId, AsyncCallback<Void> callback);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.tools;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.event.shared.EventBus;
|
||||
import com.sencha.gxt.widget.core.client.ContentPanel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author giancarlo
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ExplorerProjectPanel extends ContentPanel {
|
||||
|
||||
//private EventBus eventBus;
|
||||
|
||||
|
||||
public ExplorerProjectPanel(EventBus eventBus) {
|
||||
super();
|
||||
Log.debug("ExplorerProjectPanel");
|
||||
//this.eventBus = eventBus;
|
||||
|
||||
// msgs = GWT.create(ServiceCategoryMessages.class);
|
||||
init();
|
||||
create();
|
||||
|
||||
}
|
||||
|
||||
private void init() {
|
||||
forceLayoutOnResize = true;
|
||||
setBodyBorder(false);
|
||||
setBorders(false);
|
||||
setHeaderVisible(false);
|
||||
setResize(true);
|
||||
|
||||
}
|
||||
|
||||
private void create() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.tools;
|
||||
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.ProjectStatusEvent;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.tools.explorer.ExplorerProjectPanel;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.tools.input.InputVariablePanel;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
|
@ -13,7 +14,7 @@ import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.Verti
|
|||
|
||||
/**
|
||||
*
|
||||
* @author giancarlo email: <a
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
|
@ -39,11 +40,6 @@ public class ToolsPanel extends ContentPanel {
|
|||
setBodyBorder(false);
|
||||
setBorders(false);
|
||||
setHideCollapseTool(true);
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected void create() {
|
||||
|
||||
}
|
||||
|
||||
|
@ -53,7 +49,7 @@ public class ToolsPanel extends ContentPanel {
|
|||
|
||||
@Override
|
||||
public void onProjectStatus(ProjectStatusEvent event) {
|
||||
Log.debug("Catch ShowCodeEvent");
|
||||
Log.debug("Catch ProjectStatusEvent");
|
||||
doProjectStatusCommand(event);
|
||||
|
||||
}
|
||||
|
@ -62,22 +58,49 @@ public class ToolsPanel extends ContentPanel {
|
|||
|
||||
private void doProjectStatusCommand(ProjectStatusEvent event) {
|
||||
if (first) {
|
||||
first = false;
|
||||
addPanel();
|
||||
expand();
|
||||
} else {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void addPanel() {
|
||||
VerticalLayoutContainer v = new VerticalLayoutContainer();
|
||||
|
||||
private void create() {
|
||||
inputVariablePanel = new InputVariablePanel(eventBus);
|
||||
explorerProjectPanel = new ExplorerProjectPanel(eventBus);
|
||||
//v.add(inputVariablePanel, new VerticalLayoutData(1, 1, new Margins(0)));
|
||||
v.add(inputVariablePanel, new VerticalLayoutData(1, 1,
|
||||
new Margins(0)));
|
||||
|
||||
/*
|
||||
* AccordionLayoutAppearance appearance = GWT
|
||||
* .<AccordionLayoutAppearance> create(AccordionLayoutAppearance.class);
|
||||
* inputVariablePanel = new InputVariablePanel(eventBus, appearance);
|
||||
* explorerProjectPanel = new ExplorerProjectPanel(eventBus,
|
||||
* appearance);
|
||||
*
|
||||
* AccordionLayoutContainer accordion = new AccordionLayoutContainer();
|
||||
* accordion.setExpandMode(ExpandMode.MULTI);
|
||||
* accordion.add(inputVariablePanel);
|
||||
* accordion.add(explorerProjectPanel);
|
||||
* accordion.setActiveWidget(inputVariablePanel);
|
||||
*/
|
||||
/*
|
||||
* BoxLayoutData flex = new BoxLayoutData(new Margins(0, 0, 5, 0));
|
||||
* flex.setFlex(1);
|
||||
*
|
||||
* BoxLayoutData flex2 = new BoxLayoutData(new Margins(0));
|
||||
* flex2.setFlex(3);
|
||||
*
|
||||
* VBoxLayoutContainer c = new VBoxLayoutContainer(); c.setPadding(new
|
||||
* Padding(5)); c.setVBoxLayoutAlign(VBoxLayoutAlign.STRETCH);
|
||||
* c.add(inputVariablePanel, flex); c.add(explorerProjectPanel, flex2);
|
||||
*/
|
||||
|
||||
VerticalLayoutContainer v = new VerticalLayoutContainer();
|
||||
v.add(inputVariablePanel,
|
||||
new VerticalLayoutData(1, 0.5, new Margins(0)));
|
||||
v.add(explorerProjectPanel, new VerticalLayoutData(1, 0.5, new Margins(
|
||||
0)));
|
||||
|
||||
add(v, new MarginData(new Margins(0)));
|
||||
|
||||
forceLayout();
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,248 @@
|
|||
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.tools.explorer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
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.SessionExpiredEvent;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.UIStateEvent;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.maindata.MainCodeDescription;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.resource.StatAlgoImporterResources;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.rpc.StatAlgoImporterServiceAsync;
|
||||
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.code.CodeData;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterSessionExpiredException;
|
||||
import org.gcube.portlets.widgets.wsexplorer.client.explore.WorkspaceResourcesExplorerPanel;
|
||||
import org.gcube.portlets.widgets.wsexplorer.client.notification.WorkspaceExplorerSelectNotification.WorskpaceExplorerSelectNotificationListener;
|
||||
import org.gcube.portlets.widgets.wsexplorer.shared.Item;
|
||||
import org.gcube.portlets.widgets.wsexplorer.shared.ItemType;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.event.shared.EventBus;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.sencha.gxt.cell.core.client.ButtonCell.ButtonScale;
|
||||
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.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.SelectEvent;
|
||||
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
|
||||
import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author giancarlo email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ExplorerProjectPanel extends ContentPanel {
|
||||
|
||||
private EventBus eventBus;
|
||||
private Item selectedItem;
|
||||
private TextButton btnSetMain;
|
||||
|
||||
public ExplorerProjectPanel(EventBus eventBus) {
|
||||
super();
|
||||
Log.debug("ExplorerProjectPanel");
|
||||
this.eventBus = eventBus;
|
||||
|
||||
// msgs = GWT.create(ServiceCategoryMessages.class);
|
||||
init();
|
||||
bindToEvents();
|
||||
|
||||
}
|
||||
|
||||
public ExplorerProjectPanel(EventBus eventBus,
|
||||
AccordionLayoutAppearance appearance) {
|
||||
super(appearance);
|
||||
Log.debug("ExplorerProjectPanel");
|
||||
this.eventBus = eventBus;
|
||||
|
||||
// msgs = GWT.create(ServiceCategoryMessages.class);
|
||||
init();
|
||||
bindToEvents();
|
||||
|
||||
}
|
||||
|
||||
private void init() {
|
||||
setId("ExplorerProjectPanel");
|
||||
forceLayoutOnResize = true;
|
||||
setBodyBorder(true);
|
||||
setBorders(true);
|
||||
setHeaderVisible(true);
|
||||
setResize(true);
|
||||
setAnimCollapse(false);
|
||||
setHeadingText("Project Explorer");
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
private void bindToEvents() {
|
||||
eventBus.addHandler(UIStateEvent.TYPE,
|
||||
new UIStateEvent.UIStateHandler() {
|
||||
|
||||
public void onUIState(UIStateEvent event) {
|
||||
manageUIStateEvents(event);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
eventBus.addHandler(ProjectStatusEvent.TYPE,
|
||||
new ProjectStatusEvent.ProjectStatusEventHandler() {
|
||||
|
||||
@Override
|
||||
public void onProjectStatus(ProjectStatusEvent event) {
|
||||
manageProjectStatusEvents(event);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void manageUIStateEvents(UIStateEvent event) {
|
||||
Log.debug("InputVariablePanel recieved event from UI: "
|
||||
+ event.toString());
|
||||
switch (event.getUiStateType()) {
|
||||
case START:
|
||||
break;
|
||||
case WAITING:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void manageProjectStatusEvents(ProjectStatusEvent event) {
|
||||
Log.debug("InputVariablePanel recieved event ProjectStatus: "
|
||||
+ event.toString());
|
||||
switch (event.getProjectStatusEventType()) {
|
||||
case OPEN:
|
||||
create(event);
|
||||
break;
|
||||
case UPDATE:
|
||||
create(event);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void create(ProjectStatusEvent event) {
|
||||
try {
|
||||
|
||||
WorkspaceResourcesExplorerPanel wsResourcesExplorerPanel = new WorkspaceResourcesExplorerPanel(
|
||||
event.getProjectFolderId(), false);
|
||||
|
||||
WorskpaceExplorerSelectNotificationListener listener = new WorskpaceExplorerSelectNotificationListener() {
|
||||
@Override
|
||||
public void onSelectedItem(Item item) {
|
||||
Log.debug("Listener Selected Item " + item);
|
||||
selectedItem = item;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed(Throwable throwable) {
|
||||
Log.error(throwable.getLocalizedMessage());
|
||||
throwable.printStackTrace();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAborted() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNotValidSelection() {
|
||||
selectedItem = null;
|
||||
}
|
||||
};
|
||||
|
||||
wsResourcesExplorerPanel
|
||||
.addWorkspaceExplorerSelectNotificationListener(listener);
|
||||
|
||||
btnSetMain = new TextButton("Set Main");
|
||||
btnSetMain.setIcon(StatAlgoImporterResources.INSTANCE.add16());
|
||||
btnSetMain.setScale(ButtonScale.SMALL);
|
||||
btnSetMain.setIconAlign(IconAlign.LEFT);
|
||||
btnSetMain.setToolTip("Set main code");
|
||||
btnSetMain.addSelectHandler(new SelectHandler() {
|
||||
|
||||
@Override
|
||||
public void onSelect(SelectEvent event) {
|
||||
setMainCode(event);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
ToolBar toolBar = new ToolBar();
|
||||
toolBar.add(btnSetMain, new BoxLayoutData(new Margins(0)));
|
||||
|
||||
VerticalLayoutContainer v = new VerticalLayoutContainer();
|
||||
|
||||
v.add(toolBar, new VerticalLayoutData(1, -1, new Margins(0)));
|
||||
v.add(wsResourcesExplorerPanel, new VerticalLayoutData(1, 1,
|
||||
new Margins(0)));
|
||||
add(v, new MarginData(new Margins(0)));
|
||||
wsResourcesExplorerPanel.ensureDebugId("wsResourceExplorerPanel");
|
||||
forceLayout();
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.error("Error opening wsResourceExplorerPanel");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void setMainCode(SelectEvent event) {
|
||||
Log.debug("Set Main Code");
|
||||
if (selectedItem != null&& selectedItem.getType().compareTo(ItemType.EXTERNAL_FILE)==0) {
|
||||
loadData();
|
||||
} else {
|
||||
UtilsGXT3.info("Attention", "Select a valid file to be used as main!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void loadData() {
|
||||
StatAlgoImporterServiceAsync.INSTANCE.setMainCode(selectedItem.getId(), new AsyncCallback<Void>(){
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
if (caught instanceof StatAlgoImporterSessionExpiredException) {
|
||||
eventBus.fireEvent(new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
Log.error("Error setting main code: "
|
||||
+ caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error",
|
||||
caught.getLocalizedMessage());
|
||||
}
|
||||
caught.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Void result) {
|
||||
MainCodeDescription mainCodeDescription=new MainCodeDescription(selectedItem.getId(), selectedItem.getName(), selectedItem.getOwner(), selectedItem.getPath());
|
||||
MainCodeSetEvent mainCodeSetEvent=new MainCodeSetEvent(mainCodeDescription);
|
||||
eventBus.fireEvent(mainCodeSetEvent);
|
||||
Log.debug("Fired: "+mainCodeSetEvent);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -11,7 +11,6 @@ import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.InputT
|
|||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.cell.client.AbstractCell;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.dom.client.Style.Unit;
|
||||
import com.google.gwt.event.shared.EventBus;
|
||||
import com.google.gwt.safehtml.shared.SafeHtml;
|
||||
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
|
||||
|
|
|
@ -6,11 +6,12 @@ import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.UIStat
|
|||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.event.shared.EventBus;
|
||||
import com.sencha.gxt.widget.core.client.ContentPanel;
|
||||
import com.sencha.gxt.widget.core.client.container.AccordionLayoutContainer.AccordionLayoutAppearance;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author giancarlo
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
* @author giancarlo email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class InputVariablePanel extends ContentPanel {
|
||||
|
@ -23,18 +24,32 @@ public class InputVariablePanel extends ContentPanel {
|
|||
super();
|
||||
Log.debug("Open InputVariablePanel");
|
||||
this.eventBus = eventBus;
|
||||
setId("InputVariablePanel");
|
||||
setHeaderVisible(false);
|
||||
setResize(true);
|
||||
setBodyBorder(false);
|
||||
setBorders(false);
|
||||
forceLayoutOnResize = true;
|
||||
inputVariableTabPanel = new InputVariableTabPanel(eventBus, this);
|
||||
add(inputVariableTabPanel);
|
||||
startPanel();
|
||||
init();
|
||||
bindToEvents();
|
||||
|
||||
}
|
||||
|
||||
public InputVariablePanel(EventBus eventBus,
|
||||
AccordionLayoutAppearance appearance) {
|
||||
super(appearance);
|
||||
Log.debug("Open InputVariablePanel");
|
||||
this.eventBus = eventBus;
|
||||
init();
|
||||
bindToEvents();
|
||||
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
setId("InputVariablePanel");
|
||||
setHeaderVisible(true);
|
||||
setAnimCollapse(false);
|
||||
setResize(true);
|
||||
setBodyBorder(true);
|
||||
setBorders(true);
|
||||
setHeadingText("Input");
|
||||
forceLayoutOnResize = true;
|
||||
|
||||
}
|
||||
|
||||
protected void bindToEvents() {
|
||||
eventBus.addHandler(UIStateEvent.TYPE,
|
||||
|
@ -45,20 +60,18 @@ public class InputVariablePanel extends ContentPanel {
|
|||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
eventBus.addHandler(ProjectStatusEvent.TYPE,
|
||||
new ProjectStatusEvent.ProjectStatusEventHandler() {
|
||||
|
||||
|
||||
@Override
|
||||
public void onProjectStatus(ProjectStatusEvent event) {
|
||||
manageProjectStatusEvents(event);
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected void manageUIStateEvents(UIStateEvent event) {
|
||||
Log.debug("InputVariablePanel recieved event from UI: "
|
||||
+ event.toString());
|
||||
|
@ -72,13 +85,13 @@ public class InputVariablePanel extends ContentPanel {
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void manageProjectStatusEvents(ProjectStatusEvent event) {
|
||||
Log.debug("InputVariablePanel recieved event ProjectStatus: "
|
||||
+ event.toString());
|
||||
switch (event.getProjectStatusEventType()) {
|
||||
case OPEN:
|
||||
startPanel();
|
||||
create();
|
||||
break;
|
||||
case UPDATE:
|
||||
updatePanel();
|
||||
|
@ -88,14 +101,18 @@ public class InputVariablePanel extends ContentPanel {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
private void closePanelOnly() {
|
||||
collapse();
|
||||
disable();
|
||||
state = InputVariablePanelState.CLOSED;
|
||||
}*/
|
||||
|
||||
private void create(){
|
||||
inputVariableTabPanel = new InputVariableTabPanel(eventBus, this);
|
||||
add(inputVariableTabPanel);
|
||||
startPanel();
|
||||
forceLayout();
|
||||
}
|
||||
|
||||
/*
|
||||
* private void closePanelOnly() { collapse(); disable(); state =
|
||||
* InputVariablePanelState.CLOSED; }
|
||||
*/
|
||||
|
||||
private void startPanel() {
|
||||
enable();
|
||||
expand();
|
||||
|
@ -111,6 +128,4 @@ public class InputVariablePanel extends ContentPanel {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.type;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public enum ControllerRequestEventType {
|
||||
PROJECTOPEN;
|
||||
|
||||
}
|
|
@ -8,5 +8,6 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.client.type;
|
|||
*/
|
||||
public enum ProjectStatusEventType {
|
||||
OPEN,
|
||||
MAINCODESET,
|
||||
UPDATE;
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ public class CodeUploadPanel extends FormPanel {
|
|||
private CodeUploadDialog parent;
|
||||
private FileUploadField fileUploadField;
|
||||
|
||||
private TextButton uploadCodeBtn;
|
||||
private TextButton btnUploadCode;
|
||||
private TextButton cancelBtn;
|
||||
|
||||
//private FileUploadProgressUpdater progressUpdater;
|
||||
|
@ -79,12 +79,12 @@ public class CodeUploadPanel extends FormPanel {
|
|||
setEncoding(Encoding.MULTIPART);
|
||||
setMethod(Method.POST);
|
||||
|
||||
uploadCodeBtn = new TextButton("Upload");
|
||||
uploadCodeBtn.setIcon(StatAlgoImporterResources.INSTANCE.upload24());
|
||||
uploadCodeBtn.setIconAlign(IconAlign.RIGHT);
|
||||
uploadCodeBtn.setToolTip("Upload Code");
|
||||
btnUploadCode = new TextButton("Upload");
|
||||
btnUploadCode.setIcon(StatAlgoImporterResources.INSTANCE.upload24());
|
||||
btnUploadCode.setIconAlign(IconAlign.RIGHT);
|
||||
btnUploadCode.setToolTip("Upload Code");
|
||||
|
||||
uploadCodeBtn.addSelectHandler(new SelectHandler() {
|
||||
btnUploadCode.addSelectHandler(new SelectHandler() {
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
Log.info("request upload");
|
||||
|
@ -177,7 +177,7 @@ public class CodeUploadPanel extends FormPanel {
|
|||
});
|
||||
|
||||
|
||||
parent.addButton(uploadCodeBtn);
|
||||
parent.addButton(btnUploadCode);
|
||||
parent.addButton(cancelBtn);
|
||||
parent.setButtonAlign(BoxLayoutPack.CENTER);
|
||||
|
||||
|
@ -213,7 +213,7 @@ public class CodeUploadPanel extends FormPanel {
|
|||
|
||||
protected void disableUpload() {
|
||||
fileUploadField.disable();
|
||||
uploadCodeBtn.disable();
|
||||
btnUploadCode.disable();
|
||||
uploadProgressBar.setVisible(true);;
|
||||
cancelBtn.setEnabled(true);
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import org.gcube.portlets.user.statisticalalgorithmsimporter.server.file.CodeFil
|
|||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.Constants;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterSessionExpiredException;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.file.FileUploadMonitor;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.session.ProjectSession;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.session.SessionConstants;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -111,5 +112,31 @@ public class SessionUtil {
|
|||
return fileUploadSession;
|
||||
}
|
||||
|
||||
//
|
||||
public static void setProject(HttpSession httpSession,
|
||||
ProjectSession p) throws StatAlgoImporterSessionExpiredException {
|
||||
|
||||
ProjectSession projectSession = (ProjectSession) httpSession
|
||||
.getAttribute(SessionConstants.PROJECT_SESSION);
|
||||
if (projectSession != null)
|
||||
httpSession
|
||||
.removeAttribute(SessionConstants.PROJECT_SESSION);
|
||||
httpSession.setAttribute(
|
||||
SessionConstants.PROJECT_SESSION, p);
|
||||
|
||||
}
|
||||
|
||||
public static ProjectSession getProjectSession(
|
||||
HttpSession httpSession) {
|
||||
ProjectSession projectSession = (ProjectSession) httpSession
|
||||
.getAttribute(SessionConstants.PROJECT_SESSION);
|
||||
if (projectSession == null) {
|
||||
logger.error("ProjectSession was not acquired");
|
||||
}
|
||||
return projectSession;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -7,11 +7,13 @@ 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.CodeFileReader;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.file.CodeReader;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.file.CodeFileUploadSession;
|
||||
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.ProjectOnWorkspaceStatus;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.session.ProjectSession;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.session.UserInfo;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -28,19 +30,25 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
private static Logger logger = LoggerFactory
|
||||
.getLogger(StatAlgoImporterServiceImpl.class);
|
||||
|
||||
/**
|
||||
*
|
||||
* {@inheritDoc}
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void init() throws ServletException {
|
||||
super.init();
|
||||
System.out.println("Fix JAXP: jdk.xml.entityExpansionLimit=0");
|
||||
System.setProperty("jdk.xml.entityExpansionLimit", "0");
|
||||
|
||||
System.out.println("initializing StatisticalRunner");
|
||||
System.out.println("initializing StatAlgoImporterService");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* {@inheritDoc}
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public UserInfo hello() throws StatAlgoImporterServiceException {
|
||||
|
@ -66,7 +74,9 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* {@inheritDoc}
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public FileUploadMonitor getFileUploadMonitor()
|
||||
|
@ -90,31 +100,89 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
return fileUploadMonitor;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* {@inheritDoc}
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public ArrayList<CodeData> getCode() throws StatAlgoImporterServiceException {
|
||||
public ArrayList<CodeData> getCode()
|
||||
throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
SessionUtil.getAslSession(session);
|
||||
ASLSession aslSession=SessionUtil.getAslSession(session);
|
||||
logger.debug("getCode()");
|
||||
CodeFileUploadSession codeFileUploadSession = SessionUtil
|
||||
.getCodeFileUploadSession(session);
|
||||
|
||||
CodeFileReader codeFileReader = new CodeFileReader(
|
||||
codeFileUploadSession);
|
||||
ArrayList<CodeData> codeList = codeFileReader.getCodeList();
|
||||
for (CodeData codeData : codeList) {
|
||||
logger.debug("" + codeData.getId() + " "
|
||||
+ codeData.getCodeLine());
|
||||
ProjectSession projectSession = SessionUtil
|
||||
.getProjectSession(session);
|
||||
if (projectSession != null) {
|
||||
CodeReader codeFileReader = new CodeReader(
|
||||
projectSession, aslSession.getUsername());
|
||||
ArrayList<CodeData> codeList = codeFileReader.getCodeList();
|
||||
for (CodeData codeData : codeList) {
|
||||
logger.debug("" + codeData.getId() + " "
|
||||
+ codeData.getCodeLine());
|
||||
}
|
||||
return codeList;
|
||||
} else {
|
||||
return new ArrayList<CodeData>();
|
||||
}
|
||||
return codeList;
|
||||
} catch (StatAlgoImporterServiceException e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
logger.error("getCode(): " + e.getLocalizedMessage(), e);
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* {@inheritDoc}
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public ProjectOnWorkspaceStatus createProjectOnWorkspace(String itemId)
|
||||
throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
SessionUtil.getAslSession(session);
|
||||
logger.debug("createProjectOnWorkspace()");
|
||||
|
||||
return new ProjectOnWorkspaceStatus();
|
||||
} catch (StatAlgoImporterServiceException e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
logger.error(
|
||||
"createProjectOnWorkspace(): " + e.getLocalizedMessage(), e);
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMainCode(String itemId)
|
||||
throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
SessionUtil.getAslSession(session);
|
||||
logger.debug("SetMainCode()");
|
||||
|
||||
|
||||
|
||||
|
||||
return;
|
||||
} catch (StatAlgoImporterServiceException e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
logger.error(
|
||||
"setMainCode(): " + e.getLocalizedMessage(), e);
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,71 +0,0 @@
|
|||
package org.gcube.portlets.user.statisticalalgorithmsimporter.server.file;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.code.CodeData;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterServiceException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* CodeFileReader
|
||||
*
|
||||
* Read code and convert it in ArrayList
|
||||
*
|
||||
* @author giancarlo email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class CodeFileReader {
|
||||
private Logger logger = LoggerFactory.getLogger(CodeFileReader.class);
|
||||
private ArrayList<CodeData> codeList;
|
||||
|
||||
public CodeFileReader(CodeFileUploadSession codeFileUploadSession)
|
||||
throws StatAlgoImporterServiceException {
|
||||
|
||||
try {
|
||||
if(codeFileUploadSession==null|| codeFileUploadSession.getCodeFile()==null){
|
||||
throw new StatAlgoImporterServiceException("CodeFileUploadSession is invalid");
|
||||
}
|
||||
|
||||
codeList = new ArrayList<CodeData>();
|
||||
FileInputStream fio=new FileInputStream(codeFileUploadSession.getCodeFile());
|
||||
|
||||
InputStreamReader isr = new InputStreamReader(fio);
|
||||
|
||||
BufferedReader br = new BufferedReader((Reader) isr );
|
||||
|
||||
String s;
|
||||
int i = 1;
|
||||
while ((s = br.readLine()) != null) {
|
||||
CodeData codeData = new CodeData(i, s);
|
||||
codeList.add(codeData);
|
||||
i++;
|
||||
}
|
||||
fio.close();
|
||||
logger.trace("CodeList size: " + codeList.size());
|
||||
|
||||
} catch (FileNotFoundException e) {
|
||||
logger.error("File Not Found: "+e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
|
||||
|
||||
} catch (IOException e) {
|
||||
logger.error("IOException: "+e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public ArrayList<CodeData> getCodeList() {
|
||||
return codeList;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
package org.gcube.portlets.user.statisticalalgorithmsimporter.server.file;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.storage.FilesStorage;
|
||||
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.session.ProjectSession;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* CodeFileReader
|
||||
*
|
||||
* Read code and convert it in ArrayList
|
||||
*
|
||||
* @author giancarlo email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class CodeReader {
|
||||
private Logger logger = LoggerFactory.getLogger(CodeReader.class);
|
||||
private ArrayList<CodeData> code;
|
||||
|
||||
public CodeReader(CodeFileUploadSession codeFileUploadSession)
|
||||
throws StatAlgoImporterServiceException {
|
||||
|
||||
try {
|
||||
if (codeFileUploadSession == null
|
||||
|| codeFileUploadSession.getCodeFile() == null) {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"CodeFileUploadSession is invalid");
|
||||
}
|
||||
|
||||
code = new ArrayList<CodeData>();
|
||||
FileInputStream fio = new FileInputStream(
|
||||
codeFileUploadSession.getCodeFile());
|
||||
|
||||
InputStreamReader isr = new InputStreamReader(fio);
|
||||
|
||||
BufferedReader br = new BufferedReader((Reader) isr);
|
||||
|
||||
String s;
|
||||
int i = 1;
|
||||
while ((s = br.readLine()) != null) {
|
||||
CodeData codeData = new CodeData(i, s);
|
||||
code.add(codeData);
|
||||
i++;
|
||||
}
|
||||
fio.close();
|
||||
logger.trace("CodeList size: " + code.size());
|
||||
|
||||
} catch (FileNotFoundException e) {
|
||||
logger.error("File Not Found: " + e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
|
||||
|
||||
} catch (IOException e) {
|
||||
logger.error("IOException: " + e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public CodeReader(ProjectSession projectSession, String user)
|
||||
throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
|
||||
if (projectSession == null || projectSession.getMainCode() == null
|
||||
|| projectSession.getMainCode().getItemId() == null) {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"MainCodeSession is invalid");
|
||||
}
|
||||
|
||||
String itemId = projectSession.getMainCode().getItemId();
|
||||
|
||||
code = new ArrayList<CodeData>();
|
||||
FilesStorage filesStorage = new FilesStorage();
|
||||
InputStream is = filesStorage.retrieveItemOnWorkspace(user, itemId);
|
||||
|
||||
InputStreamReader isr = new InputStreamReader(is);
|
||||
|
||||
BufferedReader br = new BufferedReader((Reader) isr);
|
||||
|
||||
String s;
|
||||
int i = 1;
|
||||
while ((s = br.readLine()) != null) {
|
||||
CodeData codeData = new CodeData(i, s);
|
||||
code.add(codeData);
|
||||
i++;
|
||||
}
|
||||
is.close();
|
||||
logger.trace("Code size: " + code.size());
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
new StatAlgoImporterServiceException(e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<CodeData> getCodeList() {
|
||||
return code;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,381 @@
|
|||
package org.gcube.portlets.user.statisticalalgorithmsimporter.server.storage;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
|
||||
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.ItemNotFoundException;
|
||||
import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
|
||||
import org.gcube.common.homelibrary.util.WorkspaceUtil;
|
||||
import org.gcube.contentmanagement.blobstorage.service.IClient;
|
||||
import org.gcube.contentmanager.storageclient.model.protocol.smp.SMPUrl;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.AccessType;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.MemoryType;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.StorageClient;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterServiceException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
|
||||
public class FilesStorage {
|
||||
|
||||
public static final Logger logger = LoggerFactory
|
||||
.getLogger(FilesStorage.class);
|
||||
|
||||
public String storageCSVTempFile(String user, File file) {
|
||||
try {
|
||||
IClient client = new StorageClient(user, AccessType.PUBLIC,
|
||||
MemoryType.VOLATILE).getClient();
|
||||
String remotePath = "/CSVimport/" + file.getName();
|
||||
logger.debug("remotePath: " + remotePath);
|
||||
String id = client.put(true).LFile(file.getAbsolutePath())
|
||||
.RFile(remotePath);
|
||||
// url = client.getUrl().RFile(remotePath);
|
||||
return id;
|
||||
|
||||
} catch (Throwable e) {
|
||||
logger.error("Error no csv file loaded on storage"
|
||||
+ e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String storageCodelistMappingTempFile(String user, File file) {
|
||||
try {
|
||||
// String url = null;
|
||||
IClient client = new StorageClient(user, AccessType.PUBLIC,
|
||||
MemoryType.VOLATILE).getClient();
|
||||
String remotePath = "/CodelistMappingImport/" + file.getName();
|
||||
logger.debug("remotePath: " + remotePath);
|
||||
String id = client.put(true).LFile(file.getAbsolutePath())
|
||||
.RFile(remotePath);
|
||||
// url = client.getUrl().RFile(remotePath);
|
||||
return id;
|
||||
} catch (Throwable e) {
|
||||
logger.error("Error no codelist mapping file loaded on storage"
|
||||
+ e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String storageCodelistMappingTempFile(String user, String url)
|
||||
throws StatAlgoImporterServiceException {
|
||||
InputStream is = null;
|
||||
try {
|
||||
URL address = new URL(url);
|
||||
is = address.openStream();
|
||||
|
||||
IClient client = new StorageClient(user, AccessType.PUBLIC,
|
||||
MemoryType.VOLATILE).getClient();
|
||||
String remotePath = "/CodelistMappingImport/" + address.getFile();
|
||||
logger.debug("remotePath: " + remotePath);
|
||||
String id = client.put(true).LFile(is).RFile(remotePath);
|
||||
is.close();
|
||||
|
||||
return id;
|
||||
} catch (IOException e) {
|
||||
logger.error("Error no codelist mapping file loaded on storage"
|
||||
+ e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"Error no codelist mapping file loaded on storage"
|
||||
+ e.getLocalizedMessage());
|
||||
} catch (Throwable e) {
|
||||
logger.error("Error no codelist mapping file loaded on storage"
|
||||
+ e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* user
|
||||
*
|
||||
* @param user
|
||||
* User
|
||||
* @param remotePath
|
||||
* File path on storage
|
||||
* @param file
|
||||
* Destination file
|
||||
* @throws StatAlgoImporterServiceException
|
||||
*/
|
||||
public void retriveFile(String user, WorkspaceItem wi, File file)
|
||||
throws StatAlgoImporterServiceException {
|
||||
InputStream is = null;
|
||||
try {
|
||||
|
||||
org.gcube.common.homelibrary.home.workspace.folder.items.File gcubeItem = ((org.gcube.common.homelibrary.home.workspace.folder.items.File) wi);
|
||||
SMPUrl smsHome = new SMPUrl(gcubeItem.getPublicLink());
|
||||
/*
|
||||
* Handler.activateProtocol(); URL smsHome = null; smsHome = new
|
||||
* URL(gcubeItem.getPublicLink());
|
||||
*/
|
||||
logger.debug("smsHome: [host:" + smsHome.getHost() + " path:"
|
||||
+ smsHome.getPath() + " ref:" + smsHome.getRef()
|
||||
+ " userinfo:" + smsHome.getUserInfo() + " ]");
|
||||
URLConnection uc = null;
|
||||
uc = (URLConnection) smsHome.openConnection();
|
||||
is = uc.getInputStream();
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("Error retrieving file from storage", e);
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"Error retrieving file from storage: "
|
||||
+ e.getLocalizedMessage(), e);
|
||||
}
|
||||
|
||||
try {
|
||||
BufferedInputStream bis = new BufferedInputStream(is);
|
||||
FileOutputStream os = new FileOutputStream(file);
|
||||
BufferedOutputStream bos = new BufferedOutputStream(os);
|
||||
byte[] buffer = new byte[1024];
|
||||
int readCount;
|
||||
while ((readCount = bis.read(buffer)) > 0) {
|
||||
bos.write(buffer, 0, readCount);
|
||||
}
|
||||
bos.close();
|
||||
} catch (IOException e) {
|
||||
logger.error(
|
||||
"Error trasferring file from storage: "
|
||||
+ e.getLocalizedMessage(), e);
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"Error trasferring file from storage: "
|
||||
+ e.getLocalizedMessage(), e);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public InputStream retrieveItemOnWorkspace(String user, String itemId)
|
||||
throws StatAlgoImporterServiceException {
|
||||
Workspace ws;
|
||||
try {
|
||||
ws = HomeLibrary.getUserWorkspace(user);
|
||||
|
||||
WorkspaceItem workSpaceItem = ws.getItem(itemId);
|
||||
if(workSpaceItem.isFolder()){
|
||||
throw new StatAlgoImporterServiceException("Folder is not valid item!");
|
||||
}
|
||||
|
||||
return retrieveImputStream(user, workSpaceItem);
|
||||
|
||||
} catch (WorkspaceFolderNotFoundException | InternalErrorException
|
||||
| HomeNotFoundException | ItemNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param user
|
||||
* User
|
||||
* @param remotePath
|
||||
* File path on storage
|
||||
* @return InputStream back to read the file
|
||||
* @throws StatAlgoImporterServiceException
|
||||
*/
|
||||
public InputStream retrieveImputStream(String user, WorkspaceItem wi)
|
||||
throws StatAlgoImporterServiceException {
|
||||
InputStream is = null;
|
||||
try {
|
||||
|
||||
org.gcube.common.homelibrary.home.workspace.folder.items.File gcubeItem = ((org.gcube.common.homelibrary.home.workspace.folder.items.File) wi);
|
||||
SMPUrl smsHome = new SMPUrl(gcubeItem.getPublicLink());
|
||||
|
||||
/*
|
||||
* Handler.activateProtocol(); URL smsHome = null; smsHome = new
|
||||
* URL(null, gcubeItem.getPublicLink(), new URLStreamHandler() {
|
||||
*
|
||||
* @Override protected URLConnection openConnection(URL u) throws
|
||||
* IOException { return new SMPURLConnection(u); }
|
||||
*
|
||||
* });
|
||||
*/
|
||||
logger.debug("smsHome: [host:" + smsHome.getHost() + " path:"
|
||||
+ smsHome.getPath() + " ref:" + smsHome.getRef()
|
||||
+ " userinfo:" + smsHome.getUserInfo() + " ]");
|
||||
URLConnection uc = null;
|
||||
uc = (URLConnection) smsHome.openConnection();
|
||||
is = uc.getInputStream();
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("Error retrieving file from storage", e);
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"Error retrieving file from storage: "
|
||||
+ e.getLocalizedMessage(), e);
|
||||
}
|
||||
|
||||
return is;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param user
|
||||
* User
|
||||
* @param remotePath
|
||||
* File path on storage
|
||||
* @return InputStream back to read the file
|
||||
* @throws StatAlgoImporterServiceException
|
||||
*/
|
||||
public InputStream retrieveImputStream(String uri)
|
||||
throws StatAlgoImporterServiceException {
|
||||
InputStream is = null;
|
||||
try {
|
||||
|
||||
SMPUrl smsHome = new SMPUrl(uri);
|
||||
/*
|
||||
* Handler.activateProtocol(); URL smsHome = null; smsHome = new
|
||||
* URL(null, uri, new URLStreamHandler() {
|
||||
*
|
||||
* @Override protected URLConnection openConnection(URL u) throws
|
||||
* IOException { return new SMPURLConnection(u); }
|
||||
*
|
||||
* });
|
||||
*/
|
||||
|
||||
logger.debug("smsHome: [host:" + smsHome.getHost() + " path:"
|
||||
+ smsHome.getPath() + " ref:" + smsHome.getRef()
|
||||
+ " userinfo:" + smsHome.getUserInfo() + " ]");
|
||||
URLConnection uc = null;
|
||||
uc = (URLConnection) smsHome.openConnection();
|
||||
is = uc.getInputStream();
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("Error retrieving file from storage", e);
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"Error retrieving file from storage: "
|
||||
+ e.getLocalizedMessage(), e);
|
||||
}
|
||||
|
||||
return is;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param user
|
||||
* User
|
||||
* @param remotePath
|
||||
* File path on storage
|
||||
* @return InputStream back to read the file
|
||||
* @throws StatAlgoImporterServiceException
|
||||
*/
|
||||
public void createItemOnWorkspace(String uri, String user,
|
||||
String item_name, String item_description, String item_mimetype,
|
||||
String item_folder) throws StatAlgoImporterServiceException {
|
||||
InputStream is = null;
|
||||
try {
|
||||
|
||||
SMPUrl smsHome = new SMPUrl(uri);
|
||||
|
||||
/*
|
||||
* URL smsHome = new SMPUrl(); smsHome = new URL(null, uri, new
|
||||
* URLStreamHandler() {
|
||||
*
|
||||
* @Override protected URLConnection openConnection(URL u) throws
|
||||
* IOException { return new SMPURLConnection(u); }
|
||||
*
|
||||
* });
|
||||
*/
|
||||
|
||||
logger.debug("smsHome: [host:" + smsHome.getHost() + " path:"
|
||||
+ smsHome.getPath() + " ref:" + smsHome.getRef()
|
||||
+ " userinfo:" + smsHome.getUserInfo() + " ]");
|
||||
|
||||
URLConnection uc = null;
|
||||
uc = (URLConnection) smsHome.openConnection();
|
||||
is = uc.getInputStream();
|
||||
|
||||
Workspace ws = HomeLibrary.getUserWorkspace(user);
|
||||
|
||||
WorkspaceFolder folder = (WorkspaceFolder) ws.getItem(item_folder);
|
||||
String uniqueName = WorkspaceUtil.getUniqueName(item_name, folder);
|
||||
|
||||
logger.debug("ws.createExternalFile [folder: " + folder
|
||||
+ ", uniqueName: " + uniqueName + ", description: "
|
||||
+ item_description + ", mimetype: " + item_mimetype
|
||||
+ ", InputStream: " + is + "]");
|
||||
WorkspaceUtil.createExternalFile(folder, uniqueName,
|
||||
item_description, item_mimetype, is);
|
||||
|
||||
is.close();
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("Error creating item on workspace", e);
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"Error creating item on workspace: "
|
||||
+ e.getLocalizedMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param storageId
|
||||
* @param user
|
||||
* @param item_name
|
||||
* @param item_description
|
||||
* @param item_mimetype
|
||||
* @param item_folder
|
||||
* @throws StatAlgoImporterServiceException
|
||||
*/
|
||||
public void createItemOnWorkspaceByStorageId(String storageId, String user,
|
||||
String item_name, String item_description, String item_mimetype,
|
||||
String item_folder) throws StatAlgoImporterServiceException {
|
||||
|
||||
try {
|
||||
|
||||
Workspace ws = HomeLibrary.getUserWorkspace(user);
|
||||
|
||||
WorkspaceFolder folder = (WorkspaceFolder) ws.getItem(item_folder);
|
||||
String uniqueName = WorkspaceUtil.getUniqueName(item_name, folder);
|
||||
|
||||
logger.debug("ws.createExternalFile [folder: " + folder
|
||||
+ ", uniqueName: " + uniqueName + ", description: "
|
||||
+ item_description + ", mimetype: " + item_mimetype
|
||||
+ ", StorageId: " + storageId + "]");
|
||||
WorkspaceUtil.createExternalFile(folder, uniqueName,
|
||||
item_description, item_mimetype, storageId);
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("Error creating item on workspace", e);
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"Error creating item on workspace: "
|
||||
+ e.getLocalizedMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
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 MainCode implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 6328159797277211090L;
|
||||
private String itemId;
|
||||
|
||||
public MainCode(String itemId) {
|
||||
super();
|
||||
this.itemId = itemId;
|
||||
}
|
||||
|
||||
public String getItemId() {
|
||||
return itemId;
|
||||
}
|
||||
|
||||
public void setItemId(String itemId) {
|
||||
this.itemId = itemId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MainCode [itemId=" + itemId + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author giancarlo
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ProjectOnWorkspaceStatus implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -6324401286337995414L;
|
||||
|
||||
public ProjectOnWorkspaceStatus(){
|
||||
super();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package org.gcube.portlets.user.statisticalalgorithmsimporter.shared.session;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.MainCode;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ProjectSession implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -7906477664944910362L;
|
||||
|
||||
private MainCode mainCode;
|
||||
|
||||
public ProjectSession() {
|
||||
super();
|
||||
|
||||
}
|
||||
|
||||
public MainCode getMainCode() {
|
||||
return mainCode;
|
||||
}
|
||||
|
||||
public void setMainCode(MainCode mainCode) {
|
||||
this.mainCode = mainCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ProjectSession [mainCode=" + mainCode + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -10,5 +10,7 @@ public class SessionConstants {
|
|||
|
||||
public static final String FILE_UPLOAD_MONITOR="FILE_UPLOAD_MONITOR";
|
||||
public static final String IMPORT_CODE_FILE_UPLOAD_SESSION = "IMPORT_CODE_FILE_UPLOAD_SESSION";
|
||||
public static final String PROJECT_SESSION = "PROJECT_SESSION";
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -3,11 +3,16 @@
|
|||
|
||||
<inherits name='com.google.gwt.user.User' />
|
||||
<inherits name="com.google.gwt.http.HTTP" />
|
||||
|
||||
<inherits name="com.google.gwt.resources.Resources" />
|
||||
|
||||
|
||||
<!-- <inherits name="com.google.gwt.i18n.I18N" /> -->
|
||||
|
||||
<!-- <inherits name='com.extjs.gxt.ui.GXT' /> -->
|
||||
<inherits name='com.sencha.gxt.ui.GXT' />
|
||||
|
||||
|
||||
<!-- GXT Theme -->
|
||||
<!-- <inherits name='com.sencha.gxt.theme.blue.Blue' /> -->
|
||||
<!-- <inherits name='com.sencha.gxt.theme.gray.Gray' /> -->
|
||||
|
@ -17,13 +22,19 @@
|
|||
<!-- <inherits name="com.google.gwt.logging.Logging" /> -->
|
||||
<inherits name="com.allen_sauer.gwt.log.gwt-log-TRACE" />
|
||||
|
||||
<inherits name="com.google.gwt.resources.Resources" />
|
||||
<!-- Debug CSS style -->
|
||||
<set-configuration-property name="CssResource.style"
|
||||
value="pretty" />
|
||||
|
||||
<inherits name='org.gcube.portlets.widgets.sessionchecker.SessionChecker' />
|
||||
|
||||
<inherits name='edu.ycp.cs.dh.acegwt.acegwt' />
|
||||
|
||||
|
||||
<!-- inherits WorkspaceExplorer widget -->
|
||||
<inherits name='org.gcube.portlets.widgets.wsexplorer.WorkspaceExplorer' />
|
||||
|
||||
<!-- Specify the app entry point class. -->
|
||||
<entry-point class='org.gcube.portlets.user.statisticalalgorithmsimporter.client.StatAlgoImporter' />
|
||||
<!-- <entry-point
|
||||
class='org.gcube.portlets.user.statisticalalgorithmsimporter.client.StatAlgoImporter' /> -->
|
||||
|
||||
<!-- <set-configuration-property name="locale.cookie" value="AMLangCookie"
|
||||
/> <set-configuration-property name="locale.queryparam" value="AMLang" />
|
||||
|
@ -34,21 +45,22 @@
|
|||
name="locale" values="es" /> <set-property name="locale" value="en, it, es"
|
||||
/> <set-property-fallback name="locale" value="en" /> -->
|
||||
|
||||
<!-- <set-property name="log_DivLogger" value="ENABLED" /> <set-property
|
||||
name="log_ConsoleLogger" value="ENABLED" /> <set-property name="log_GWTLogger"
|
||||
|
||||
<!-- <set-property name="log_ConsoleLogger" value="ENABLED" /> <set-property
|
||||
name="log_DivLogger" value="ENABLED" /> <set-property name="log_GWTLogger"
|
||||
value="ENABLED" /> <set-property name="log_SystemLogger" value="ENABLED"
|
||||
/> -->
|
||||
<!-- Not in GWT 2.6 <set-property name="log_FirebugLogger" value="ENABLED"
|
||||
/> -->
|
||||
|
||||
|
||||
<set-property name="log_DivLogger" value="DISABLED" />
|
||||
<set-property name="log_ConsoleLogger" value="DISABLED" />
|
||||
<set-property name="log_DivLogger" value="DISABLED" />
|
||||
<set-property name="log_GWTLogger" value="DISABLED" />
|
||||
<set-property name="log_SystemLogger" value="DISABLED" />
|
||||
|
||||
|
||||
<!-- Not in GWT 2.6 <set-property name="log_FirebugLogger" value="DISABLED"
|
||||
/> -->
|
||||
|
||||
<!-- Specify the paths for translatable code -->
|
||||
<source path='client' />
|
||||
<source path='shared' />
|
||||
|
||||
</module>
|
||||
|
|
|
@ -24,12 +24,14 @@
|
|||
|
||||
<!-- Debug CSS style -->
|
||||
<set-configuration-property name="CssResource.style"
|
||||
value="pretty" />
|
||||
value="pretty" />
|
||||
|
||||
<inherits name='org.gcube.portlets.widgets.sessionchecker.SessionChecker' />
|
||||
<inherits name='edu.ycp.cs.dh.acegwt.acegwt' />
|
||||
|
||||
|
||||
|
||||
<!-- inherits WorkspaceExplorer widget -->
|
||||
<inherits name='org.gcube.portlets.widgets.wsexplorer.WorkspaceExplorer' />
|
||||
|
||||
<!-- Specify the app entry point class. -->
|
||||
<entry-point
|
||||
class='org.gcube.portlets.user.statisticalalgorithmsimporter.client.StatAlgoImporter' />
|
||||
|
@ -44,20 +46,19 @@
|
|||
values="en" /> <extend-property name="locale" values="it" /> <extend-property
|
||||
name="locale" values="es" /> <set-property name="locale" value="en, it, es"
|
||||
/> <set-property-fallback name="locale" value="en" /> -->
|
||||
|
||||
|
||||
<set-property name="log_ConsoleLogger" value="ENABLED" /> <set-property
|
||||
name="log_DivLogger" value="ENABLED" /> <set-property name="log_GWTLogger"
|
||||
value="ENABLED" /> <set-property name="log_SystemLogger" value="ENABLED"
|
||||
/>
|
||||
|
||||
|
||||
<set-property name="log_ConsoleLogger" value="ENABLED" />
|
||||
<set-property name="log_DivLogger" value="ENABLED" />
|
||||
<set-property name="log_GWTLogger" value="ENABLED" />
|
||||
<set-property name="log_SystemLogger" value="ENABLED" />
|
||||
<!-- Not in GWT 2.6 <set-property name="log_FirebugLogger" value="ENABLED"
|
||||
/> -->
|
||||
|
||||
<!--
|
||||
<set-property name="log_ConsoleLogger" value="DISABLED" />
|
||||
<set-property name="log_DivLogger" value="DISABLED" />
|
||||
<set-property name="log_GWTLogger" value="DISABLED" />
|
||||
<set-property name="log_SystemLogger" value="DISABLED" /> -->
|
||||
<!-- <set-property name="log_ConsoleLogger" value="DISABLED" /> <set-property
|
||||
name="log_DivLogger" value="DISABLED" /> <set-property name="log_GWTLogger"
|
||||
value="DISABLED" /> <set-property name="log_SystemLogger" value="DISABLED"
|
||||
/> -->
|
||||
<!-- Not in GWT 2.6 <set-property name="log_FirebugLogger" value="DISABLED"
|
||||
/> -->
|
||||
|
||||
|
|
|
@ -20,12 +20,14 @@
|
|||
<!-- If you add any GWT meta tags, they must -->
|
||||
<!-- be added before this line. -->
|
||||
<!-- -->
|
||||
<link rel="stylesheet" type="text/css" href="gxt/css/gxt-all.css" />
|
||||
<!-- <link rel="stylesheet" type="text/css" href="gxt/css/gxt-all.css" /> -->
|
||||
<link type="text/css" rel="stylesheet" href="StatAlgoImporter.css">
|
||||
<script src="statalgoimporter/js/jquery-1.11.3.min.js"></script>
|
||||
<script src="statalgoimporter/ace/ace.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="statalgoimporter/ace/theme-eclipse.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="statalgoimporter/ace/mode-r.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="statalgoimporter/js/bootstrap.min.js"></script>
|
||||
|
||||
<script type="text/javascript"
|
||||
src="statalgoimporter/statalgoimporter.nocache.js"></script>
|
||||
|
||||
|
|
|
@ -8,6 +8,13 @@
|
|||
<!-- <link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/gxt/css/gxt-all.css" /> -->
|
||||
<link rel="stylesheet" href="<%= request.getContextPath()%>/StatAlgoImporter.css" type="text/css">
|
||||
|
||||
<script src='<%=request.getContextPath()%>/statalgoimporter/js/jquery-1.11.3.min.js'></script>
|
||||
<script src='<%=request.getContextPath()%>/statalgoimporter/ace/ace.js' type='text/javascript' charset='utf-8'></script>
|
||||
<script src='<%=request.getContextPath()%>/statalgoimporter/ace/theme-eclipse.js' type='text/javascript' charset='utf-8'></script>
|
||||
<script src='<%=request.getContextPath()%>/statalgoimporter/ace/mode-r.js' type='text/javascript' charset='utf-8'></script>
|
||||
<script src='<%=request.getContextPath()%>/statalgoimporter/js/bootstrap.min.js'></script>
|
||||
|
||||
|
||||
<script src='<%=request.getContextPath()%>/statalgoimporter/statalgoimporter.nocache.js'></script>
|
||||
|
||||
|
||||
|
|
|
@ -31,7 +31,14 @@
|
|||
<servlet-class>org.gcube.portlets.user.statisticalalgorithmsimporter.server.LocalUploadServlet</servlet-class>
|
||||
</servlet>
|
||||
|
||||
|
||||
<!-- Workspace Explorer -->
|
||||
<servlet>
|
||||
<servlet-name>workspaceExplorer</servlet-name>
|
||||
<servlet-class>org.gcube.portlets.widgets.wsexplorer.server.WorkspaceExplorerServiceImpl</servlet-class>
|
||||
</servlet>
|
||||
|
||||
|
||||
|
||||
<!-- Servlets Mapping -->
|
||||
<!-- JUnit -->
|
||||
<servlet-mapping>
|
||||
|
@ -51,13 +58,20 @@
|
|||
<url-pattern>/statalgoimporter/statalgoimporterservice</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<!--StatRunnerService -->
|
||||
<!-- Local Upload -->
|
||||
<servlet-mapping>
|
||||
<servlet-name>LocalUploadServlet</servlet-name>
|
||||
<url-pattern>/statalgoimporter/LocalUploadServlet</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
|
||||
<!-- Workspace Explorer -->
|
||||
<servlet-mapping>
|
||||
<servlet-name>workspaceExplorer</servlet-name>
|
||||
<url-pattern>/statalgoimporter/WorkspaceExplorerService</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
|
||||
|
||||
<!-- Default page to serve -->
|
||||
<welcome-file-list>
|
||||
<welcome-file>StatAlgoImporter.html</welcome-file>
|
||||
|
|
Loading…
Reference in New Issue