VME delete completed, not working for GeneralMeasure case but is on the webservice. Fixed bug of show structure when openeing new VMEs

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/reports@90658 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2014-01-28 16:31:13 +00:00
parent e3d900c9dd
commit 03ee613822
22 changed files with 457 additions and 143 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/reports-4.7.3-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<classpathentry kind="src" output="target/reports-4.7.6-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
@ -31,5 +31,5 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/reports-4.7.3-SNAPSHOT/WEB-INF/classes"/>
<classpathentry kind="output" path="target/reports-4.7.6-SNAPSHOT/WEB-INF/classes"/>
</classpath>

View File

@ -2,6 +2,6 @@
<<<<<<<=.mine
>>>>>>>=.r71295
eclipse.preferences.version=1
lastWarOutDir=/Users/massi/Documents/workspace/reports/target/reports-4.7.3-SNAPSHOT
lastWarOutDir=/Users/massi/Documents/workspace/reports/target/reports-4.7.6-SNAPSHOT
warSrcDir=src/main/webapp
warSrcDirIsOutput=false

View File

@ -12,7 +12,7 @@
<groupId>org.gcube.portlets.user</groupId>
<artifactId>reports</artifactId>
<packaging>war</packaging>
<version>4.7.3-SNAPSHOT</version>
<version>4.7.6-SNAPSHOT</version>
<name>gCube Reports Manager</name>
<description>
gCube Reports Portlet.
@ -30,7 +30,7 @@
cersion -->
<setScope>provided</setScope>
<setClassifier>online</setClassifier>
<!-- GWT needs at least java 1.6 -->
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>

View File

@ -191,7 +191,7 @@ public class Headerbar extends Composite{
separator4 = menuBar.addSeparator();
MenuItem vmeMenuDelete = getVMEMenuFake("Delete");
MenuItem vmeMenuDelete = getVMEMenuDelete();
menuBar.addItem(vmeMenuDelete);
menuBar.addSeparator();
@ -332,24 +332,44 @@ public class Headerbar extends Composite{
}
};
private MenuItem getVMEMenuFake(String fakeOption) {
private MenuItem getVMEMenuDelete() {
MenuBar createMenu = new MenuBar(true);
createMenu.setAnimationEnabled(true);
MenuItem toReturn = new MenuItem(fakeOption+" VME-DB", createMenu);
MenuItem toReturn = new MenuItem("Delete VME-DB", createMenu);
toReturn.getElement().getStyle().setWhiteSpace(WhiteSpace.NOWRAP);
MenuItem item = new MenuItem("<font color=\"gray\">"+fakeOption+" VME</font>", true, getNullCommand());
MenuItem item = new MenuItem("Delete VME", true, new Command() {
public void execute() {
presenter.showVMEDeleteDialog(VMETypeIdentifier.Vme);
}
});
createMenu.addItem(item);
createMenu.addSeparator();
item = new MenuItem("<font color=\"gray\">"+fakeOption+" VME General Measure</font>", true, getNullCommand());
item = new MenuItem("Delete VME General Measure", true, new Command() {
public void execute() {
presenter.showVMEDeleteDialog(VMETypeIdentifier.GeneralMeasure);
}
});
createMenu.addItem(item);
item = new MenuItem("<font color=\"gray\">"+fakeOption+" Information Source</font>", true, getNullCommand());
item = new MenuItem("Delete Information Source", true, new Command() {
public void execute() {
presenter.showVMEDeleteDialog(VMETypeIdentifier.InformationSource);
}
});
createMenu.addItem(item);
item = new MenuItem("<font color=\"gray\">"+fakeOption+" Fishing footprint</font>", true, getNullCommand());
item = new MenuItem("Delete Fishing footprint", true, new Command() {
public void execute() {
presenter.showVMEDeleteDialog(VMETypeIdentifier.FisheryAreasHistory);
}
});
createMenu.addItem(item);
item = new MenuItem("<font color=\"gray\">"+fakeOption+" Regional History of VMEs</font>", true, getNullCommand());
item = new MenuItem("Delete Regional History of VMEs", true, new Command() {
public void execute() {
presenter.showVMEDeleteDialog(VMETypeIdentifier.VMEsHistory);
}
});
createMenu.addItem(item);
return toReturn;
}

View File

@ -80,9 +80,7 @@ public class CommonCommands {
};
newTemplate = new Command() {
public void execute() {
presenter.changeTemplateName(TemplateModel.DEFAULT_NAME);
presenter.cleanAll();
presenter.showOpenOptions();
presenter.newDoc();
}
};

View File

@ -18,7 +18,8 @@ import org.gcube.portlets.user.reportgenerator.client.ToolboxPanel;
import org.gcube.portlets.user.reportgenerator.client.WorkspacePanel;
import org.gcube.portlets.user.reportgenerator.client.dialog.AddBiblioEntryDialog;
import org.gcube.portlets.user.reportgenerator.client.dialog.DeleteCitationsDialog;
import org.gcube.portlets.user.reportgenerator.client.dialog.ImportVMEReportDialog;
import org.gcube.portlets.user.reportgenerator.client.dialog.SelectVMEReportDialog;
import org.gcube.portlets.user.reportgenerator.client.dialog.SelectVMEReportDialog.Action;
import org.gcube.portlets.user.reportgenerator.client.dialog.WaitingOperationDialog;
import org.gcube.portlets.user.reportgenerator.client.events.AddBiblioEvent;
import org.gcube.portlets.user.reportgenerator.client.events.AddBiblioEventHandler;
@ -56,6 +57,8 @@ import org.gcube.portlets.user.reportgenerator.client.uibinder.ExportOptions;
import org.gcube.portlets.user.reportgenerator.shared.SessionInfo;
import org.gcube.portlets.user.reportgenerator.shared.UserBean;
import org.gcube.portlets.user.reportgenerator.shared.VMETypeIdentifier;
import org.gcube.portlets.user.reportgenerator.shared.VmeExportResponse;
import org.gcube.portlets.user.reportgenerator.shared.VmeResponseEntry;
import org.gcube.portlets.widgets.exporter.client.ReportExporterPopup;
import org.gcube.portlets.widgets.exporter.client.event.ExportingCompletedEvent;
import org.gcube.portlets.widgets.exporter.client.event.ExportingCompletedEventHandler;
@ -117,6 +120,8 @@ public class Presenter {
*/
private ClientSequence clientSeqSelected = null;
private boolean isShowingStructure = false;
RichTextToolbar currentSelectedToolbar;
RichTextArea areaForBiblio;
@ -129,6 +134,10 @@ public class Presenter {
private boolean menuForWorkflowDocument = false;
private boolean isVME = false;
/**
* by default is set to Type VME, because refs can only be imported and not opened from WorkSpace
*/
private VMETypeIdentifier currentVmeType = VMETypeIdentifier.Vme;
/**
* eventbus events handler
*/
@ -144,16 +153,21 @@ public class Presenter {
eventBus.addHandler(SelectedReportEvent.TYPE, new SelectedReportEventHandler() {
@Override
public void onReportSelected(SelectedReportEvent event) {
if (event.isAssociation()) {
switch (event.getAction()) {
case SELECT:
importVMEReport(event.getId(), event.getName(), event.getType());
break;
case ASSOCIATE:
try {
associateVMRReportRef(event.getType(), event.getId());
associateVMEReportRef(event.getType(), event.getId());
} catch (Exception e) {
e.printStackTrace();
}
}
else {
importVMEReport(event.getId(), event.getName(), event.getType());
}
break;
case DELETE:
deleteVMEReport(event.getId(), event.getName(), event.getType());
break;
}
}
});
@ -305,7 +319,7 @@ public class Presenter {
}
public void showOpenOptions() {
wp.showOpenOptions(isVME);
wp.showOpenOptions(isVME);
}
public void showLoading() {
@ -529,20 +543,35 @@ public class Presenter {
*
*/
public void exportReportToRSG() {
dlg.center();
dlg.show();
Model toSave = model.getSerializableModel();
reportService.exportReportToRSG(toSave, new AsyncCallback<Void>() {
public void onFailure(Throwable caught) {
dlg.hide();
MessageBox.alert("Warning","Report Not Exported: " + caught.getMessage(), null);
}
public void onSuccess(Void result) {
dlg.hide();
MessageBox.info("Exporting to RSG Operation","Report Exported Successfully", null);
refreshWorkspace();
}
});
if (Window.confirm("Are you sure you want to commit the " + model.getTemplateName() + " into the VME Database?")) {
dlg.center();
dlg.show();
Model toSave = model.getSerializableModel();
reportService.exportReportToRSG(currentVmeType, toSave, new AsyncCallback<VmeExportResponse>() {
public void onFailure(Throwable caught) {
dlg.hide();
MessageBox.alert("Warning","Report Not Exported: " + caught.getMessage(), null);
}
public void onSuccess(VmeExportResponse response) {
dlg.hide();
//write ok
if (response.isGloballySucceded())
MessageBox.info("Exporting to RSG Operation","Report Exported Successfully", null);
//runtime exception
else if (response.getResponseMessageList().size() == 1 && response.getResponseMessageList().get(0).getResponseEntryCode().equals("RUNTIME_EXCEPTION")) {
MessageBox.alert("Exporting to RSG Operation Failed","Report Exporting has failed for the following reason: <br/> " + response.getResponseMessageList().get(0).getResponseMessage(), null);
}
//user report compile exception
else {
String failReasons = "";
for (VmeResponseEntry entry : response.getResponseMessageList()) {
failReasons += entry.getResponseMessage() + "<br/>";
}
MessageBox.alert("Exporting to RSG Operation Failed","Report Exporting has failed for the following reasons: <br/> " + failReasons, null);
}
}
});
}
}
/**
* Save the current report in a given folder
@ -829,7 +858,9 @@ public class Presenter {
if (currPage > 1)
titleBar.getSectionSwitchPanel().showPrevButton();
if (isShowingStructure)
showStructure();
}
/**
@ -1149,18 +1180,23 @@ public class Presenter {
/**
* show/hide the structure view
*/
boolean hidden = true;
public void toggleReportStructure() {
if (hidden) {
toolBoxPanel.showStructure(new ReportStructurePanel(eventBus, model.getSerializableModel(), ToolboxPanel.TOOLBOX_WIDTH+"px", ToolboxPanel.TOOLBOX_HEIGHT+"px"));
hidden = false;
if (!isShowingStructure) {
showStructure();
isShowingStructure = true;
}
else {
toolBoxPanel.collapse();
hidden = true;
isShowingStructure = false;
}
}
private void showStructure() {
toolBoxPanel.showStructure(new ReportStructurePanel(eventBus, model.getSerializableModel(), ToolboxPanel.TOOLBOX_WIDTH+"px", ToolboxPanel.TOOLBOX_HEIGHT+"px"));
}
public HorizontalPanel getExportsPanel() {
return exportsPanel;
}
@ -1215,11 +1251,17 @@ public class Presenter {
exportsPanel.clear();
}
public void newDoc() {
changeTemplateName(TemplateModel.DEFAULT_NAME);
cleanAll();
showOpenOptions();
}
/**
*
*/
public void showVMEImportDialog() {
ImportVMEReportDialog dlg = new ImportVMEReportDialog(getEventBus(), VMETypeIdentifier.Vme, false);
SelectVMEReportDialog dlg = new SelectVMEReportDialog(getEventBus(), VMETypeIdentifier.Vme, Action.SELECT);
dlg.show();
}
@ -1227,14 +1269,21 @@ public class Presenter {
*
*/
public void showVMEReportRefImportDialog(VMETypeIdentifier refType) {
ImportVMEReportDialog dlg = new ImportVMEReportDialog(getEventBus(), refType, false);
SelectVMEReportDialog dlg = new SelectVMEReportDialog(getEventBus(), refType, Action.SELECT);
dlg.show();
}
/**
*
*/
public void showVMERefAssociateDialog(VMETypeIdentifier refType) {
ImportVMEReportDialog dlg = new ImportVMEReportDialog(getEventBus(), refType, true);
SelectVMEReportDialog dlg = new SelectVMEReportDialog(getEventBus(), refType, Action.ASSOCIATE);
dlg.show();
}
/**
*
*/
public void showVMEDeleteDialog(VMETypeIdentifier refType) {
SelectVMEReportDialog dlg = new SelectVMEReportDialog(getEventBus(), refType, Action.DELETE);
dlg.show();
}
@ -1257,7 +1306,42 @@ public class Presenter {
});
}
private void deleteVMEReport(String reportId, String name, final VMETypeIdentifier type) {
if (Window.confirm("Are you sure you want to delete " + name + " from the VME Database? (This action is Undoable)")) {
showLoading();
reportService.deleteReportFromRSG(type, reportId, new AsyncCallback<VmeExportResponse>() {
@Override
public void onFailure(Throwable caught) {
dlg.hide();
Window.alert("Could not Delete, error on server.: " + caught.getMessage());
}
@Override
public void onSuccess(VmeExportResponse response) {
dlg.hide();
//delete ok
if (response.getResponseMessageList().size() == 1 && response.getResponseMessageList().get(0).getResponseEntryCode().equalsIgnoreCase("SUCCEEDED"))
MessageBox.info("Delete VME Report Operation","Report Deleted Successfully", null);
//runtime exception
else if (response.getResponseMessageList().size() == 1 && response.getResponseMessageList().get(0).getResponseEntryCode().equals("RUNTIME_EXCEPTION")) {
MessageBox.alert("Delete VME Report Operation Failed","Report Delete has failed for the following reason: <br/> " + response.getResponseMessageList().get(0).getResponseMessage(), null);
}
//user report compile exception
else {
String failReasons = "";
for (VmeResponseEntry entry : response.getResponseMessageList()) {
failReasons += entry.getResponseMessage() + "<br/>";
}
MessageBox.alert("Deleting Operation Failed","Report Deletion has failed for the following reasons: <br/> " + failReasons, null);
}
newDoc();
}
});
}
}
private void importVMEReport(String reportId, String name, final VMETypeIdentifier type) {
showLoading();
reportService.importVMEReport(reportId, name, type, new AsyncCallback<Model>() {
@ -1270,15 +1354,15 @@ public class Presenter {
public void onSuccess(Model toLoad) {
if (toLoad != null) {
loadModel(toLoad, type == VMETypeIdentifier.Vme);
currentVmeType = type;
}
else
Window.alert("Could not Load Report Model, error on server.");
}
});
}
private void associateVMRReportRef(VMETypeIdentifier type, String reportId) throws Exception {
private void associateVMEReportRef(VMETypeIdentifier type, String reportId) throws Exception {
GWT.log("Type="+type);
GWT.log("Id"+reportId);
reportService.getVMEReportRef2Associate(reportId, type, new AsyncCallback<Model>() {

View File

@ -8,6 +8,7 @@ import org.gcube.portlets.d4sreporting.common.shared.Table;
import org.gcube.portlets.user.reportgenerator.shared.SessionInfo;
import org.gcube.portlets.user.reportgenerator.shared.VMEReportBean;
import org.gcube.portlets.user.reportgenerator.shared.VMETypeIdentifier;
import org.gcube.portlets.user.reportgenerator.shared.VmeExportResponse;
import org.gcube.portlets.widgets.exporter.shared.SaveReportFileException;
import org.gcube.portlets.widgets.exporter.shared.SaveReportFileExistException;
import org.gcube.portlets.widgets.exporter.shared.TypeExporter;
@ -88,7 +89,10 @@ public interface ReportService extends RemoteService{
/**
* @param toSave the report instance to save
*/
void exportReportToRSG(Model toSave);
VmeExportResponse exportReportToRSG(VMETypeIdentifier refType, Model toSave);
VmeExportResponse deleteReportFromRSG(VMETypeIdentifier refType, String idToDelete);
Model getWorkflowDocumentFromDocumentLibrary();

View File

@ -8,6 +8,7 @@ import org.gcube.portlets.d4sreporting.common.shared.Table;
import org.gcube.portlets.user.reportgenerator.shared.SessionInfo;
import org.gcube.portlets.user.reportgenerator.shared.VMEReportBean;
import org.gcube.portlets.user.reportgenerator.shared.VMETypeIdentifier;
import org.gcube.portlets.user.reportgenerator.shared.VmeExportResponse;
import org.gcube.portlets.widgets.exporter.shared.TypeExporter;
import com.google.gwt.user.client.rpc.AsyncCallback;
@ -86,5 +87,8 @@ public interface ReportServiceAsync {
void getVMEReportRef2Associate(String id, VMETypeIdentifier refType, AsyncCallback<Model> callback);
void importVMETemplate(VMETypeIdentifier refType,
AsyncCallback<Model> callback);
void exportReportToRSG(Model toSave, AsyncCallback<Void> callback);
void exportReportToRSG(VMETypeIdentifier refType, Model toSave,
AsyncCallback<VmeExportResponse> callback);
void deleteReportFromRSG(VMETypeIdentifier refType, String idToDelete,
AsyncCallback<VmeExportResponse> callback);
}

View File

@ -15,7 +15,6 @@ import com.extjs.gxt.ui.client.event.GridEvent;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.store.GroupingStore;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.store.Store;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Window;
@ -24,11 +23,10 @@ import com.extjs.gxt.ui.client.widget.form.StoreFilterField;
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
import com.extjs.gxt.ui.client.widget.grid.Grid;
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel;
import com.extjs.gxt.ui.client.widget.grid.GridGroupRenderer;
import com.extjs.gxt.ui.client.widget.grid.GroupColumnData;
import com.extjs.gxt.ui.client.widget.grid.GroupingView;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.tips.QuickTip;
import com.extjs.gxt.ui.client.widget.tips.ToolTipConfig;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.shared.HandlerManager;
@ -36,7 +34,7 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
public class ImportVMEReportDialog extends Window {
public class SelectVMEReportDialog extends Window {
private static final int WIDTH = 700;
private static final int HEIGHT = 450;
@ -47,11 +45,13 @@ public class ImportVMEReportDialog extends Window {
private StoreFilterField<VMEReportBean> filter;
private VMETypeIdentifier type;
public enum Action {SELECT, ASSOCIATE, DELETE }
/**
*
* @param eventBus the bus to fire events into
*/
public ImportVMEReportDialog(final HandlerManager eventBus, VMETypeIdentifier type, final boolean isAssociation) {
public SelectVMEReportDialog(final HandlerManager eventBus, VMETypeIdentifier type, final Action action) {
this.eventBus = eventBus;
this.type = type;
setModal(true);
@ -86,7 +86,7 @@ public class ImportVMEReportDialog extends Window {
add(mainPanel);
showLoading();
setHeading(getHeading(type, isAssociation));
setHeading(getHeading(type, action));
if (type == VMETypeIdentifier.Vme) {
reportService.listVMEReports(new AsyncCallback<ArrayList<VMEReportBean>>() {
@Override
@ -97,7 +97,7 @@ public class ImportVMEReportDialog extends Window {
@Override
public void onSuccess(ArrayList<VMEReportBean> refReports) {
mainPanel.unmask();
showAvailableReports(refReports, isAssociation);
showAvailableReports(refReports, action);
}
});
} else {
@ -110,17 +110,18 @@ public class ImportVMEReportDialog extends Window {
@Override
public void onSuccess(ArrayList<VMEReportBean> refReports) {
mainPanel.unmask();
showAvailableReports(refReports, isAssociation);
showAvailableReports(refReports, action);
}
});
}
}
/**
* view for collections step
* @param vDesc
*
* @param reports
* @param isAssociation
*/
public void showAvailableReports(List<VMEReportBean> reports, final boolean isAssociation) {
public void showAvailableReports(List<VMEReportBean> reports, final Action theAction) {
ColumnModel cm = null;
List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
@ -186,14 +187,30 @@ public class ImportVMEReportDialog extends Window {
public void handleEvent(GridEvent<VMEReportBean> ge) {
if (ge != null && ge.getModel() != null) {
hide();
if (isAssociation)
associateSelected(grid.getSelectionModel().getSelectedItem(), type);
else
openSelected(grid.getSelectionModel().getSelectedItem(), type);
switch (theAction) {
case SELECT:
openSelected(grid.getSelectionModel().getSelectedItem(), type, theAction);
break;
case ASSOCIATE:
associateSelected(grid.getSelectionModel().getSelectedItem(), type, theAction);
break;
case DELETE:
deleteSelected(grid.getSelectionModel().getSelectedItem(), type, theAction);
break;
}
}
}
});
final ColumnModel finalCM = cm;
view.setGroupRenderer(new GridGroupRenderer() {
public String render(GroupColumnData data) {
String f = finalCM.getColumnById(data.field).getHeader();
String l = data.models.size() == 1 ? "Item" : "Items";
return f + ": " + data.group + " (" + data.models.size() + " " + l + ")";
}
});
view.setForceFit(true);
ContentPanel gridPanel = new ContentPanel(new FitLayout());
gridPanel.setHeaderVisible(false);
@ -208,33 +225,47 @@ public class ImportVMEReportDialog extends Window {
}
}));
if (isAssociation) {
switch (theAction) {
case SELECT:
gridPanel.addButton(new Button("Open Selected", new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
openSelected(grid.getSelectionModel().getSelectedItem(), type, theAction);
hide();
}
}));
break;
case ASSOCIATE:
gridPanel.addButton(new Button("Associate Selected", new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
hide();
associateSelected(grid.getSelectionModel().getSelectedItem(), type);
associateSelected(grid.getSelectionModel().getSelectedItem(), type, theAction);
}
}));
}
else {
gridPanel.addButton(new Button("Open Selected", new SelectionListener<ButtonEvent>() {
break;
case DELETE:
gridPanel.addButton(new Button("Delete Selected from VME-DB", new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
openSelected(grid.getSelectionModel().getSelectedItem(), type);
hide();
hide();
deleteSelected(grid.getSelectionModel().getSelectedItem(), type, theAction);
}
}));
}
break;
}
mainPanel.add(gridPanel);
mainPanel.setLayout(new FitLayout());
mainPanel.layout();
}
private void associateSelected(VMEReportBean selectedItem, VMETypeIdentifier type) {
eventBus.fireEvent(new SelectedReportEvent(selectedItem.getId(), selectedItem.getName(), type, true));
private void associateSelected(VMEReportBean selectedItem, VMETypeIdentifier type, Action theAction) {
eventBus.fireEvent(new SelectedReportEvent(selectedItem.getId(), selectedItem.getName(), type, theAction));
}
private void openSelected(VMEReportBean selectedItem, VMETypeIdentifier type) {
eventBus.fireEvent(new SelectedReportEvent(selectedItem.getId(), selectedItem.getName(), type, false));
private void openSelected(VMEReportBean selectedItem, VMETypeIdentifier type, Action theAction) {
eventBus.fireEvent(new SelectedReportEvent(selectedItem.getId(), selectedItem.getName(), type, theAction));
}
private void deleteSelected(VMEReportBean selectedItem, VMETypeIdentifier type, Action theAction) {
eventBus.fireEvent(new SelectedReportEvent(selectedItem.getId(), selectedItem.getName(), type, theAction));
}
/**
*
@ -248,7 +279,7 @@ public class ImportVMEReportDialog extends Window {
* @param isAssociation
* @return
*/
private String getHeading(VMETypeIdentifier type, boolean isAssociation) {
private String getHeading(VMETypeIdentifier type, Action theAction) {
String toReturn = "";
switch (type) {
case Vme:
@ -273,8 +304,18 @@ public class ImportVMEReportDialog extends Window {
toReturn = "Unknown Category!";
break;
}
toReturn = isAssociation ? "Associate " + toReturn : "Edit " + toReturn;
switch (theAction) {
case SELECT:
toReturn = "Edit " + toReturn;
break;
case ASSOCIATE:
toReturn = "Associate " + toReturn;
break;
case DELETE:
toReturn = "Delete " + toReturn;
break;
}
return toReturn;
}
}

View File

@ -1,5 +1,6 @@
package org.gcube.portlets.user.reportgenerator.client.events;
import org.gcube.portlets.user.reportgenerator.client.dialog.SelectVMEReportDialog.Action;
import org.gcube.portlets.user.reportgenerator.shared.VMETypeIdentifier;
import com.google.gwt.event.shared.GwtEvent;
@ -9,14 +10,14 @@ public class SelectedReportEvent extends GwtEvent<SelectedReportEventHandler>{
private final String id;
private final String name;
private final VMETypeIdentifier type;
private final boolean isAssociation;
private final Action theAction;
public SelectedReportEvent(String id, String name, VMETypeIdentifier type, boolean isAssociation) {
public SelectedReportEvent(String id, String name, VMETypeIdentifier type, Action theAction) {
super();
this.id = id;
this.name = name;
this.type = type;
this.isAssociation = isAssociation;
this.theAction = theAction;
}
public String getId() {
@ -31,8 +32,8 @@ public class SelectedReportEvent extends GwtEvent<SelectedReportEventHandler>{
return type;
}
public boolean isAssociation() {
return isAssociation;
public Action getAction() {
return theAction;
}
@Override

View File

@ -36,7 +36,6 @@ import org.gcube.portlets.user.reportgenerator.client.targets.TextTableImage;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Hidden;
import com.google.gwt.user.client.ui.Widget;
@ -274,7 +273,7 @@ public class TemplateComponent {
}
}
}
//is it is saved as a Report is an instance of this class else is a simple text in a template
//if it is saved as a Report is an instance of this class else is a simple text in a template
if (sc.getPossibleContent() instanceof AttributeArea) {
AttributeArea sata = (AttributeArea) sc.getPossibleContent();
//in the metadata in this case there an attribute for diplayType
@ -371,6 +370,7 @@ public class TemplateComponent {
RepeatableSequence repeatableSequence = (RepeatableSequence) sc.getPossibleContent();
ClientRepeatableSequence rps = new ClientRepeatableSequence(presenter, repeatableSequence);
rps.setMetadata(sc.getMetadata());
rps.setId(sc.getId());
this.content = rps;
break;
case BODY_TABLE_IMAGE:
@ -380,6 +380,7 @@ public class TemplateComponent {
} else {
RepeatableSequence seq = (RepeatableSequence) sc.getPossibleContent();
tti = new TextTableImage(presenter, seq);
tti.setId(sc.getId());
}
this.content = tti;
break;
@ -521,13 +522,17 @@ public class TemplateComponent {
break;
case REPEAT_SEQUENCE:
ClientRepeatableSequence repSeq = (ClientRepeatableSequence) this.content;
metas = repSeq.getMetadata();
RepeatableSequence toStore = new RepeatableSequence(getSerializableSequence(repSeq), repSeq.getIdentifier(), height);
id = repSeq.getId();
metas = repSeq.getMetadata();
RepeatableSequence toStore = new RepeatableSequence(getSerializableSequence(repSeq), repSeq.getKey(), height);
content = toStore;
break;
case BODY_TABLE_IMAGE:
TextTableImage tti = (TextTableImage) this.content;
RepeatableSequence toSave = new RepeatableSequence(getSerializableSequence(tti), height);
id = tti.getId();
metas = tti.getMetadata();
RepeatableSequence toSave = new RepeatableSequence(getSerializableSequence(tti), height);
content = toSave;
break;
case REPORT_REFERENCE:
@ -551,7 +556,7 @@ public class TemplateComponent {
GWT.log("Serializing sequence ... ");
ArrayList<BasicComponent> sComps = new ArrayList<BasicComponent>();
for (TemplateComponent tc : repSeq.getGroupedComponents()) {
GWT.log(" Got " + tc.getType());
//GWT.log(" Got " + tc.getType());
sComps.add(tc.getSerializable());
}
return sComps;

View File

@ -52,7 +52,10 @@ public class TemplateModel {
public static final String BIBLIO_SECTION = "isBibliography";
public static final String USER_COMMENT = "isComment";
public static final String USER_COMMENT_HEIGHT = "isCommentHeight";
/**
* The id of the model
*/
private String id;
/**
* The name of the template
*/
@ -275,6 +278,7 @@ public class TemplateModel {
public void loadModel(Model toLoad, Presenter presenter) {
//loading template from disk
this.id = toLoad.getUniqueID();
this.author = toLoad.getAuthor();
this.dateCreated = toLoad.getDateCreated();
this.lastEdit = toLoad.getLastEdit();
@ -405,29 +409,12 @@ public class TemplateModel {
}
Model toReturn =
new Model("UniqueID", author, dateCreated, lastEdit, lastEditBy, templateName, columnWidth, currentPage, marginBottom, marginLeft, marginRight, marginTop,
new Model(id, author, dateCreated, lastEdit, lastEditBy, templateName, columnWidth, currentPage, marginBottom, marginLeft, marginRight, marginTop,
pageHeight, pageWidth, serializedsections, totalPages, metadata);
return toReturn;
}
/**
*
* @param folderid .
* @param name .
*/
public void saveReport (Model toSave, String folderid, String name) {
}
/**
*
*
*/
public void saveReport (Model toSave) {
}
/**
* look for the model in the current page and edits its size
* @param toResize .

View File

@ -94,6 +94,7 @@ public class AttributeMultiSelection extends Composite {
CheckBox toAdd = new CheckBox(attr.getName());
toAdd.setStyleName("checkAttribute");
toAdd.setValue(attr.getValue());
toAdd.setTitle(attr.getOptionalValue());
boxes[j] = toAdd;
j++;
}
@ -163,7 +164,7 @@ public class AttributeMultiSelection extends Composite {
public AttributeArea getSerializable() {
ArrayList<Attribute> values = new ArrayList<Attribute>();
for (CheckBox box : getBoxes()) {
values.add(new Attribute(box.getText().trim(), box.getValue()));
values.add(new Attribute(box.getText().trim(), box.getValue(), box.getTitle()));
}
return new AttributeArea(getAttrName().trim(), values);
}

View File

@ -96,6 +96,7 @@ public class AttributeSingleSelection extends Composite {
RadioButton toAdd = new RadioButton(RADIO_NAME, attr.getName());
toAdd.setStyleName("checkAttribute");
toAdd.setValue(attr.getValue());
toAdd.setTitle(attr.getOptionalValue());
boxes[j] = toAdd;
j++;
}
@ -164,7 +165,7 @@ public class AttributeSingleSelection extends Composite {
public AttributeArea getSerializable() {
ArrayList<Attribute> singlevalues = new ArrayList<Attribute>();
for (RadioButton box : getBoxes()) {
singlevalues.add(new Attribute(box.getText().trim(), box.getValue()));
singlevalues.add(new Attribute(box.getText().trim(), box.getValue(), box.getTitle()));
}
return new AttributeArea(getAttrName().trim(), singlevalues);
}

View File

@ -7,8 +7,6 @@ import org.gcube.portlets.d4sreporting.common.shared.BasicComponent;
import org.gcube.portlets.d4sreporting.common.shared.ComponentType;
import org.gcube.portlets.d4sreporting.common.shared.Metadata;
import org.gcube.portlets.d4sreporting.common.shared.RepeatableSequence;
import org.gcube.portlets.d4sreporting.common.shared.ReportReferences;
import org.gcube.portlets.d4sreporting.common.shared.Tuple;
import org.gcube.portlets.user.reportgenerator.client.Presenter.Presenter;
import org.gcube.portlets.user.reportgenerator.client.model.TemplateComponent;
@ -19,10 +17,11 @@ import com.google.gwt.user.client.ui.VerticalPanel;
public class ClientRepeatableSequence extends Composite implements ClientSequence {
protected ArrayList<TemplateComponent> groupedComponents = new ArrayList<TemplateComponent>();
private String id;
private List<Metadata> metas;
private VerticalPanel myPanel = new VerticalPanel();
private Presenter p;
private String identifier;
private String key;
protected RepeatableSequence repSequence;
protected RepeatableSequence originalSequence = new RepeatableSequence();
@ -34,7 +33,7 @@ public class ClientRepeatableSequence extends Composite implements ClientSequenc
public ClientRepeatableSequence(Presenter p, RepeatableSequence sRS) {
this.p = p;
this.repSequence = sRS;
this.identifier = sRS.getKey();
this.key = sRS.getKey();
this.originalSequence = extractOriginalSequence(sRS);
SequenceWidget seqW = new SequenceWidget(p, this, originalSequence, true, false);
myPanel.add(seqW);
@ -245,8 +244,8 @@ public class ClientRepeatableSequence extends Composite implements ClientSequenc
add("not needed", sequence, false);
}
public String getIdentifier() {
return identifier;
public String getKey() {
return key;
}
public List<Metadata> getMetadata() {
@ -256,6 +255,16 @@ public class ClientRepeatableSequence extends Composite implements ClientSequenc
public void setMetadata(List<Metadata> metas) {
this.metas = metas;
}
public String getId() {
if (id == null)
return "-1";
return id;
}
public void setId(String id) {
this.id = id;
}

View File

@ -148,6 +148,7 @@ public class ClientReportReference extends Composite implements ClientSequence,
myPanel.add(seqW);
first.hideClearAssociationButton();
}
this.id = id;
//needed for the model
Tuple toAdd = new Tuple(id, sequence.getGroupedComponents());
tupleList.add(toAdd);
@ -179,7 +180,7 @@ public class ClientReportReference extends Composite implements ClientSequence,
e.printStackTrace();
}
p.showVMERefAssociateDialog(type2Pass);
p.setClientSequenceSelected(this); //important!
p.setClientSequenceSelected(this); //important!
}
public String getRefType() {
@ -209,7 +210,10 @@ public class ClientReportReference extends Composite implements ClientSequence,
public void setMetadata(List<Metadata> metas) {
this.metas = metas;
}
public String getId() {
if (id == null)
return "-1";
return id;
}

View File

@ -32,7 +32,9 @@ public class TextTableImage extends Composite {
public static final int DEFAULT_HEIGHT = 100;
public static final int DEFAULT_WIDTH = 700;
public String id;
private List<Metadata> metas;
private FocusPanel focusPanel = new FocusPanel();
private VerticalPanel mainPanel = new VerticalPanel();
private HorizontalPanel controlPanel;
@ -210,7 +212,23 @@ public class TextTableImage extends Composite {
}
}
}
}
public List<Metadata> getMetadata() {
return metas;
}
public void setMetadata(List<Metadata> metas) {
this.metas = metas;
}
public String getId() {
if (id == null)
return "-1";
return id;
}
public void setId(String id) {
this.id = id;
}
}

View File

@ -2,7 +2,6 @@ package org.gcube.portlets.user.reportgenerator.client.uibinder;
import org.gcube.portlets.user.reportgenerator.client.Presenter.CommonCommands;
import org.gcube.portlets.user.reportgenerator.client.Presenter.Presenter;
import org.gcube.portlets.user.reportgenerator.client.uibinder.ExportOptions.ExportMode;
import org.gcube.portlets.user.reportgenerator.shared.VMETypeIdentifier;
import com.google.gwt.core.client.GWT;
@ -10,7 +9,6 @@ import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
@ -24,7 +22,7 @@ public class OpenOptionsVME extends Composite {
interface OpenOptionsUiBinder extends UiBinder<Widget, OpenOptionsVME> {
}
enum OpenMode {OPEN_REPORT, OPEN_TEMPLATE, UPLOAD }
enum OpenMode {EDIT_VME, NEW_VME, DELETE_VME }
@UiField HTML editVME;
@UiField HTML createVME;
@ -45,30 +43,30 @@ public class OpenOptionsVME extends Composite {
@UiHandler("editVME")
void onEditVMEClick(ClickEvent e) {
GWT.log("editVME");
doAction(OpenMode.OPEN_REPORT);
doAction(OpenMode.EDIT_VME);
}
@UiHandler("createVME")
void onOpenTemplateClick(ClickEvent e) {
doAction(OpenMode.OPEN_TEMPLATE);
doAction(OpenMode.NEW_VME);
}
@UiHandler("deleteVME")
void unUploadClick(ClickEvent e) {
doAction(OpenMode.UPLOAD);
doAction(OpenMode.DELETE_VME);
}
private void doAction(OpenMode mode) {
CommonCommands cmd = new CommonCommands(p);
switch (mode) {
case OPEN_REPORT:
case EDIT_VME:
p.showVMEImportDialog();
break;
case OPEN_TEMPLATE:
case NEW_VME:
p.importVMETemplate(VMETypeIdentifier.Vme);
break;
case UPLOAD:
Window.alert("Not yet available");
case DELETE_VME:
p.showVMEDeleteDialog(VMETypeIdentifier.Vme);
break;
default:
break;

View File

@ -41,6 +41,8 @@ import org.gcube.application.rsg.client.RsgClient;
import org.gcube.application.rsg.service.RsgService;
import org.gcube.application.rsg.service.dto.ReportEntry;
import org.gcube.application.rsg.service.dto.ReportType;
import org.gcube.application.rsg.service.dto.response.Response;
import org.gcube.application.rsg.service.dto.response.ResponseEntry;
import org.gcube.application.rsg.support.builder.exceptions.ReportBuilderException;
import org.gcube.application.rsg.support.builder.impl.ReportManagerReportBuilder;
import org.gcube.application.rsg.support.model.components.impl.CompiledReport;
@ -91,6 +93,8 @@ import org.gcube.portlets.user.reportgenerator.shared.SessionInfo;
import org.gcube.portlets.user.reportgenerator.shared.UserBean;
import org.gcube.portlets.user.reportgenerator.shared.VMEReportBean;
import org.gcube.portlets.user.reportgenerator.shared.VMETypeIdentifier;
import org.gcube.portlets.user.reportgenerator.shared.VmeExportResponse;
import org.gcube.portlets.user.reportgenerator.shared.VmeResponseEntry;
import org.gcube.portlets.widgets.exporter.shared.SaveReportFileException;
import org.gcube.portlets.widgets.exporter.shared.SaveReportFileExistException;
import org.gcube.portlets.widgets.exporter.shared.TypeExporter;
@ -1607,26 +1611,60 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
}
@Override
public void exportReportToRSG(Model model) {
public VmeExportResponse exportReportToRSG(VMETypeIdentifier refType, Model model) {
System.out.println(new ModelReader(model).toString());
RsgService rsgClient = new RsgClient(getRSGWSAddress());
//Use the RSG client to get a template for the report whose type is the last token (i.e. the corresponding class' 'simple name')
//appearing in the VME model class name as stored in the 'type' metadata
//If you're updating a 'report':
CompiledReport template = rsgClient.getTemplate(new ReportType(VMETypeIdentifier.Vme.getId()));
CompiledReport template = rsgClient.getTemplate(new ReportType(refType.getId()));
CompiledReport toSend = null;
try {
toSend = new ReportManagerReportBuilder().extract(template, model);
} catch (Exception e) {
e.printStackTrace();
}
//Actual RSG client interface exposes different methods (publish / publishDelta etc.) that need to be updated
rsgClient.update(toSend);
try {
//Actual RSG client interface exposes different methods (publish / publishDelta etc.) that need to be updated
Response res = null;
if (refType == VMETypeIdentifier.Vme) {
_log.info("Exporting VME Report");
res = rsgClient.update(toSend);
}
else {
_log.info("Exporting Ref type= " + refType.getId());
res = rsgClient.updateRef(toSend);
}
return getClientResponse(res);
} catch (RuntimeException ex) {
ex.printStackTrace();
return new VmeExportResponse(new VmeResponseEntry("RUNTIME_EXCEPTION", "Sorry, there was an error on the Server, please try again in few minutes or report an Issue."));
}
}
@Override
public VmeExportResponse deleteReportFromRSG(VMETypeIdentifier refType, String idToDelete) {
RsgService rsgClient = new RsgClient(getRSGWSAddress());
try {
Response res = null;
if (refType == VMETypeIdentifier.Vme) {
_log.info("Deleting VME Report id = " + idToDelete);
res = rsgClient.deleteById(new ReportType(refType.getId()), idToDelete);
}
else {
_log.info("Deleting VME Reference Report of Type " + refType + " having id = " + idToDelete);
res = rsgClient.deleteReferenceById(new ReportType(refType.getId()), idToDelete);
}
return getClientResponse(res);
} catch (RuntimeException ex) {
ex.printStackTrace();
return new VmeExportResponse(new VmeResponseEntry("RUNTIME_EXCEPTION", "Sorry, there was an error on the Server, we could not delete. Please try again in few minutes or report an Issue."));
}
}
/**
* this method look for a ReportsStoreGateway WS available in the infrastructure
* @return true if an instance of the ReportsStoreGateway is available in the infrastructure
@ -1659,6 +1697,18 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
}
private VmeExportResponse getClientResponse(Response rsgResponse) {
VmeExportResponse toReturn = new VmeExportResponse();
for (ResponseEntry entry : rsgResponse.getResponseMessageList()) {
String entryCode = entry.getResponseCode() == null ? "no-code" : entry.getResponseCode().toString();
String entryMessage = entry.getResponseMessage() == null ? "no response message" : entry.getResponseMessage();
toReturn.getResponseMessageList().add(new VmeResponseEntry(entryCode, entryMessage));
}
toReturn.setGloballySucceded(rsgResponse.isGloballySucceeded());
return toReturn;
}
}

View File

@ -0,0 +1,50 @@
package org.gcube.portlets.user.reportgenerator.shared;
import java.io.Serializable;
import java.util.ArrayList;
/**
* Simply wraps the Response clases of the RSG WS for sending them to the client
* @author Massimiliano Assante, ISTI-CNR
*
*/
@SuppressWarnings("serial")
public class VmeExportResponse implements Serializable {
private boolean globallySucceded;
private ArrayList<VmeResponseEntry> responseMessageList;
public VmeExportResponse() {
super();
responseMessageList = new ArrayList<VmeResponseEntry>();
}
public VmeExportResponse(VmeResponseEntry singleResponse) {
responseMessageList = new ArrayList<VmeResponseEntry>();
responseMessageList.add(singleResponse);
}
public VmeExportResponse(ArrayList<VmeResponseEntry> responseMessageList) {
super();
this.responseMessageList = responseMessageList;
}
public ArrayList<VmeResponseEntry> getResponseMessageList() {
if (responseMessageList == null)
responseMessageList = new ArrayList<VmeResponseEntry>();
return responseMessageList;
}
public void setResponseMessageList(ArrayList<VmeResponseEntry> responseMessageList) {
this.responseMessageList = responseMessageList;
}
public boolean isGloballySucceded() {
return globallySucceded;
}
public void setGloballySucceded(boolean globallySucceded) {
this.globallySucceded = globallySucceded;
}
}

View File

@ -0,0 +1,40 @@
package org.gcube.portlets.user.reportgenerator.shared;
import java.io.Serializable;
/**
* Simply wraps the ResponseEntry class of the RSG WS for sending them to the client
* @author Massimiliano Assante, ISTI-CNR
*
*/
@SuppressWarnings("serial")
public class VmeResponseEntry implements Serializable {
private String responseEntryCode;
private String responseMessage;
public VmeResponseEntry() {
super();
}
public VmeResponseEntry(String responseEntryCode, String responseMessage) {
super();
this.responseEntryCode = responseEntryCode;
this.responseMessage = responseMessage;
}
public String getResponseMessage() {
return responseMessage;
}
public void setResponseMessage(String responseMessage) {
this.responseMessage = responseMessage;
}
public String getResponseEntryCode() {
return responseEntryCode;
}
public void setResponseEntryCode(String responseEntryCode) {
this.responseEntryCode = responseEntryCode;
}
}

View File

@ -57,7 +57,6 @@
.optionDeleteVME {
background: url('images/deleteVME.png') 55% 25px no-repeat;
opacity: 0.5;
}
.exportPanel {