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

@ -311,7 +311,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
fromBasket = getReportFromBasket(zippedTemplate, zipPath, zipFilename);
zipToExtract = zipPath + zipFilename;
}
_log.info("\n\n** zipToExtract: " + zipToExtract);
if (bi.getFolderItemType() == FolderItemType.REPORT || bi.getFolderItemType() == FolderItemType.REPORT_TEMPLATE) {
@ -352,7 +352,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
// changes the template name model
toReturn.setTemplateName(templateName);
File toDelete = new File(fileToRead); //to delete the file extracted from the workspace
File toDelete1 = new File( myUtil.getTemplatePath(templateName, getVreName(), getUsername()));
@ -831,7 +831,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
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) {
Workspace root = null;
@ -910,16 +910,19 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
String templateName = newname;
boolean isUpdate = false;
if (templateName.endsWith("d4sR") ) {
if (toSaveIn.exists(templateName)) {
_log.warn("Item exists already, deleting and creating new one");
toSaveIn.removeChild(toSaveIn.find(templateName));
_log.warn("Item exists already, updating");
//toSaveIn.removeChild(toSaveIn.find(templateName));
isUpdate = true;
}
}
if (toSaveIn.exists(templateName + ".d4sR")) {
_log.warn("Item exists already, deleting and creating new one");
toSaveIn.removeChild(toSaveIn.find(templateName + ".d4sR"));
_log.warn("Item exists already, updating");
//toSaveIn.removeChild(toSaveIn.find(templateName + ".d4sR"));
isUpdate = true;
}
//remove the template extension
@ -927,17 +930,21 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
if (! templateToInsert.endsWith(".d4sR"))
templateToInsert+=".d4sR";
Calendar dateCreated = Calendar.getInstance();
dateCreated.setTime(model.getDateCreated());
Report rep = null;
if (isUpdate) {
rep = (Report) toSaveIn.find(templateName);
getWorkspaceArea().updateItem(rep.getId(), isZip);
} else { //is new
Calendar dateCreated = Calendar.getInstance();
dateCreated.setTime(model.getDateCreated());
Calendar lastEdit = Calendar.getInstance();
lastEdit.setTime(model.getLastEdit());
Calendar lastEdit = Calendar.getInstance();
lastEdit.setTime(model.getLastEdit());
Report rep = toSaveIn.createReportItem(templateToInsert, templateToInsert, dateCreated, lastEdit,
model.getAuthor(), model.getLastEditBy(), templateToInsert, model.getSections().size(), "no-status", isZip);
rep = toSaveIn.createReportItem(templateToInsert, templateToInsert, dateCreated, lastEdit,
model.getAuthor(), model.getLastEditBy(), templateToInsert, model.getSections().size(), "no-status", isZip);
}
//Report rep = toSaveIn.createReportItem(templateToInsert, templateToInsert, isZip);
storeReportItemIDInSession(rep.getId());
if (toSaveIn.getType() == WorkspaceItemType.SHARED_FOLDER) {