fixed bug when opening reports created with reports modeler

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/reports@84608 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2013-10-29 18:17:47 +00:00
parent 58c22e49f4
commit 9dea2bb6d8
1 changed files with 22 additions and 15 deletions

View File

@ -831,7 +831,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
return d4Session.getAttribute(CURRENT_REPORT_ID_ATTRIBUTE).toString(); return d4Session.getAttribute(CURRENT_REPORT_ID_ATTRIBUTE).toString();
} }
/** /**
* used to save the report in the same folder * * used to save the report in the same folder
*/ */
public void saveReport(Model toSave) { public void saveReport(Model toSave) {
Workspace root = null; Workspace root = null;
@ -910,16 +910,19 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
String templateName = newname; String templateName = newname;
boolean isUpdate = false;
if (templateName.endsWith("d4sR") ) { if (templateName.endsWith("d4sR") ) {
if (toSaveIn.exists(templateName)) { if (toSaveIn.exists(templateName)) {
_log.warn("Item exists already, deleting and creating new one"); _log.warn("Item exists already, updating");
toSaveIn.removeChild(toSaveIn.find(templateName)); //toSaveIn.removeChild(toSaveIn.find(templateName));
isUpdate = true;
} }
} }
if (toSaveIn.exists(templateName + ".d4sR")) { if (toSaveIn.exists(templateName + ".d4sR")) {
_log.warn("Item exists already, deleting and creating new one"); _log.warn("Item exists already, updating");
toSaveIn.removeChild(toSaveIn.find(templateName + ".d4sR")); //toSaveIn.removeChild(toSaveIn.find(templateName + ".d4sR"));
isUpdate = true;
} }
//remove the template extension //remove the template extension
@ -927,17 +930,21 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
if (! templateToInsert.endsWith(".d4sR")) if (! templateToInsert.endsWith(".d4sR"))
templateToInsert+=".d4sR"; templateToInsert+=".d4sR";
Report rep = null;
if (isUpdate) {
rep = (Report) toSaveIn.find(templateName);
getWorkspaceArea().updateItem(rep.getId(), isZip);
} else { //is new
Calendar dateCreated = Calendar.getInstance(); Calendar dateCreated = Calendar.getInstance();
dateCreated.setTime(model.getDateCreated()); dateCreated.setTime(model.getDateCreated());
Calendar lastEdit = Calendar.getInstance(); Calendar lastEdit = Calendar.getInstance();
lastEdit.setTime(model.getLastEdit()); lastEdit.setTime(model.getLastEdit());
Report rep = toSaveIn.createReportItem(templateToInsert, templateToInsert, dateCreated, lastEdit, rep = toSaveIn.createReportItem(templateToInsert, templateToInsert, dateCreated, lastEdit,
model.getAuthor(), model.getLastEditBy(), templateToInsert, model.getSections().size(), "no-status", isZip); model.getAuthor(), model.getLastEditBy(), templateToInsert, model.getSections().size(), "no-status", isZip);
}
//Report rep = toSaveIn.createReportItem(templateToInsert, templateToInsert, isZip);
storeReportItemIDInSession(rep.getId()); storeReportItemIDInSession(rep.getId());
if (toSaveIn.getType() == WorkspaceItemType.SHARED_FOLDER) { if (toSaveIn.getType() == WorkspaceItemType.SHARED_FOLDER) {