Sfoglia il codice sorgente
fix richiesta firma direttore lavori per allegato A06feature/pannello-pratiche
marcoalderighi
2 anni fa
27 ha cambiato i file con 312 aggiunte e 167 eliminazioni
File binario non mostrato.
File binario non mostrato.
File binario non mostrato.
File binario non mostrato.
File binario non mostrato.
File binario non mostrato.
@ -1,156 +1,156 @@
|
||||
package it.nextmind.liferay.portos.advanced.operation.portlet; |
||||
|
||||
import com.liferay.portal.kernel.json.JSONFactoryUtil; |
||||
import com.liferay.portal.kernel.json.JSONObject; |
||||
import com.liferay.portal.kernel.log.Log; |
||||
import com.liferay.portal.kernel.log.LogFactoryUtil; |
||||
import com.liferay.portal.kernel.servlet.ServletResponseUtil; |
||||
import com.liferay.portal.kernel.upload.UploadPortletRequest; |
||||
import com.liferay.portal.kernel.util.ContentTypes; |
||||
import com.liferay.portal.kernel.util.GetterUtil; |
||||
import com.liferay.portal.kernel.util.ParamUtil; |
||||
import com.liferay.portal.kernel.util.StreamUtil; |
||||
import com.liferay.portal.kernel.util.StringPool; |
||||
import com.liferay.portal.kernel.util.Validator; |
||||
import com.liferay.portal.kernel.util.WebKeys; |
||||
import com.liferay.portal.theme.ThemeDisplay; |
||||
import com.liferay.portal.util.PortalUtil; |
||||
import com.liferay.util.bridges.mvc.MVCPortlet; |
||||
|
||||
import it.tref.liferay.portos.bo.report.builder.bean.ReportAvvisoBean; |
||||
import it.tref.liferay.portos.bo.report.builder.builder.ReportAvvisoBeanBuilder; |
||||
import it.tref.liferay.portos.report.html.core.HtmlToPdfEngine; |
||||
import it.tref.liferay.portos.report.jasper.core.provider.JasperPdfProvider; |
||||
import it.tref.liferay.portos.report.jasper.core.report.BeanReport; |
||||
import it.tref.liferay.portos.report.jasper.core.report.ReportInterface; |
||||
import it.tref.liferay.portos.report.odt.core.OdtToPdfEngine; |
||||
import it.tref.liferay.portos.report.shared.constants.ReportConstants; |
||||
import it.tref.liferay.portos.report.shared.constants.ReportConstants.ReportType; |
||||
import it.tref.liferay.portos.report.shared.dto.ReportDto; |
||||
import it.tref.liferay.portos.report.shared.dto.ReportResultDto; |
||||
import it.tref.liferay.portos.report.shared.util.ReportUtil; |
||||
import it.tref.liferay.portos.report.shared.util.VelocityUtil; |
||||
|
||||
import java.io.ByteArrayOutputStream; |
||||
import java.io.IOException; |
||||
import java.io.InputStream; |
||||
import java.util.HashMap; |
||||
|
||||
import javassist.ClassPool; |
||||
|
||||
import javax.portlet.PortletException; |
||||
import javax.portlet.ResourceRequest; |
||||
import javax.portlet.ResourceResponse; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
|
||||
public class TemplateTesterPortlet extends MVCPortlet { |
||||
|
||||
@Override |
||||
public void serveResource(ResourceRequest resourceRequest, |
||||
ResourceResponse resourceResponse) throws IOException, |
||||
PortletException { |
||||
|
||||
String resourceID = GetterUtil.getString(resourceRequest |
||||
.getResourceID()); |
||||
|
||||
if (resourceID.equals("templateTester")) { |
||||
_processTemplate(resourceRequest, resourceResponse); |
||||
} else { |
||||
super.serveResource(resourceRequest, resourceResponse); |
||||
} |
||||
} |
||||
|
||||
private void _processTemplate(ResourceRequest resourceRequest, |
||||
ResourceResponse resourceResponse){ |
||||
|
||||
HttpServletRequest request = PortalUtil |
||||
.getHttpServletRequest(resourceRequest); |
||||
HttpServletResponse response = PortalUtil |
||||
.getHttpServletResponse(resourceResponse); |
||||
|
||||
try { |
||||
|
||||
ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest |
||||
.getAttribute(WebKeys.THEME_DISPLAY); |
||||
|
||||
byte[] bytes = new byte[0]; |
||||
|
||||
UploadPortletRequest uploadPortletRequest = PortalUtil |
||||
.getUploadPortletRequest(resourceRequest); |
||||
|
||||
ReportAvvisoBean bean = ReportAvvisoBeanBuilder.build(avviso, parameters); |
||||
String resourcePath = getClass().getName().replaceAll("\\w+\\.", "../") |
||||
.replace(getClass().getSimpleName(), ReportConstants.PATH_LOGO_REGIONE); |
||||
parameters.put(ReportConstants.LOGO_REGIONE, getClass().getResource(resourcePath).getPath()); |
||||
ReportDto reportDto = new ReportDto(); |
||||
reportDto.setFileEntryIds(new long[] { fileEntryIdTemplate }); |
||||
reportDto.setFolderId(folderId); |
||||
reportDto.setFileName(fileName); |
||||
reportDto.setParameters(parameters); |
||||
reportDto.setShowNumberOfPage(true); |
||||
reportDto.setType(ReportConstants.ReportType.JRXML_TO_PDF.toString()); |
||||
ReportResultDto result = ReportUtil.generateReport(companyId, userId, reportDto, bean); |
||||
|
||||
String parametersJSON = ParamUtil.getString( |
||||
uploadPortletRequest, "parametersJSON"); |
||||
|
||||
HashMap<String, Object> params = new HashMap<String, Object>(); |
||||
if (Validator.isNotNull(parametersJSON)) { |
||||
params = (HashMap<String, Object>) JSONFactoryUtil |
||||
.looseDeserialize(parametersJSON); |
||||
} |
||||
|
||||
String objectJSON = ParamUtil.getString(uploadPortletRequest, |
||||
"objectJSON"); |
||||
|
||||
String fileNameTemplate = uploadPortletRequest |
||||
.getFileName("fileTemplate"); |
||||
|
||||
ReportInterface reportInterface = null; |
||||
|
||||
if (Validator.isNotNull(objectJSON)) { |
||||
|
||||
JSONObject jsonObject = JSONFactoryUtil |
||||
.createJSONObject(objectJSON); |
||||
|
||||
ClassPool pool = ClassPool.getDefault(); |
||||
|
||||
Class<?> clazz = makeClass(pool, jsonObject); |
||||
Object dataSource = clazz.newInstance(); |
||||
|
||||
reportInterface = new BeanReport(dataSource); |
||||
} |
||||
|
||||
if (Validator.isNotNull(fileNameTemplate)) { |
||||
|
||||
InputStream inputStream = null; |
||||
try { |
||||
inputStream = uploadPortletRequest |
||||
.getFileAsStream("fileTemplate"); |
||||
|
||||
JasperPdfProvider pdfProvider = new JasperPdfProvider(); |
||||
pdfProvider.doReport(inputStream, params, |
||||
reportInterface); |
||||
|
||||
bytes = pdfProvider.getBytes(); |
||||
} finally { |
||||
StreamUtil.cleanUp(inputStream); |
||||
} |
||||
} |
||||
|
||||
ServletResponseUtil.sendFile(request, response, "test.pdf", bytes, |
||||
ContentTypes.APPLICATION_PDF); |
||||
|
||||
} catch (Exception e) { |
||||
_log.error(e, e); |
||||
|
||||
ServletResponseUtil.sendFile(request, response, "test.html", e |
||||
.toString().getBytes(StringPool.UTF8), |
||||
ContentTypes.TEXT_HTML_UTF8); |
||||
} |
||||
|
||||
} |
||||
|
||||
private final static Log _log = LogFactoryUtil.getLog(TestPdf.class); |
||||
} |
||||
//package it.nextmind.liferay.portos.advanced.operation.portlet;
|
||||
//
|
||||
//import com.liferay.portal.kernel.json.JSONFactoryUtil;
|
||||
//import com.liferay.portal.kernel.json.JSONObject;
|
||||
//import com.liferay.portal.kernel.log.Log;
|
||||
//import com.liferay.portal.kernel.log.LogFactoryUtil;
|
||||
//import com.liferay.portal.kernel.servlet.ServletResponseUtil;
|
||||
//import com.liferay.portal.kernel.upload.UploadPortletRequest;
|
||||
//import com.liferay.portal.kernel.util.ContentTypes;
|
||||
//import com.liferay.portal.kernel.util.GetterUtil;
|
||||
//import com.liferay.portal.kernel.util.ParamUtil;
|
||||
//import com.liferay.portal.kernel.util.StreamUtil;
|
||||
//import com.liferay.portal.kernel.util.StringPool;
|
||||
//import com.liferay.portal.kernel.util.Validator;
|
||||
//import com.liferay.portal.kernel.util.WebKeys;
|
||||
//import com.liferay.portal.theme.ThemeDisplay;
|
||||
//import com.liferay.portal.util.PortalUtil;
|
||||
//import com.liferay.util.bridges.mvc.MVCPortlet;
|
||||
//
|
||||
//import it.tref.liferay.portos.bo.report.builder.bean.ReportAvvisoBean;
|
||||
//import it.tref.liferay.portos.bo.report.builder.builder.ReportAvvisoBeanBuilder;
|
||||
//import it.tref.liferay.portos.report.html.core.HtmlToPdfEngine;
|
||||
//import it.tref.liferay.portos.report.jasper.core.provider.JasperPdfProvider;
|
||||
//import it.tref.liferay.portos.report.jasper.core.report.BeanReport;
|
||||
//import it.tref.liferay.portos.report.jasper.core.report.ReportInterface;
|
||||
//import it.tref.liferay.portos.report.odt.core.OdtToPdfEngine;
|
||||
//import it.tref.liferay.portos.report.shared.constants.ReportConstants;
|
||||
//import it.tref.liferay.portos.report.shared.constants.ReportConstants.ReportType;
|
||||
//import it.tref.liferay.portos.report.shared.dto.ReportDto;
|
||||
//import it.tref.liferay.portos.report.shared.dto.ReportResultDto;
|
||||
//import it.tref.liferay.portos.report.shared.util.ReportUtil;
|
||||
//import it.tref.liferay.portos.report.shared.util.VelocityUtil;
|
||||
//
|
||||
//import java.io.ByteArrayOutputStream;
|
||||
//import java.io.IOException;
|
||||
//import java.io.InputStream;
|
||||
//import java.util.HashMap;
|
||||
//
|
||||
//import javassist.ClassPool;
|
||||
//
|
||||
//import javax.portlet.PortletException;
|
||||
//import javax.portlet.ResourceRequest;
|
||||
//import javax.portlet.ResourceResponse;
|
||||
//import javax.servlet.http.HttpServletRequest;
|
||||
//import javax.servlet.http.HttpServletResponse;
|
||||
//
|
||||
//public class TemplateTesterPortlet extends MVCPortlet {
|
||||
//
|
||||
// @Override
|
||||
// public void serveResource(ResourceRequest resourceRequest,
|
||||
// ResourceResponse resourceResponse) throws IOException,
|
||||
// PortletException {
|
||||
//
|
||||
// String resourceID = GetterUtil.getString(resourceRequest
|
||||
// .getResourceID());
|
||||
//
|
||||
// if (resourceID.equals("templateTester")) {
|
||||
// _processTemplate(resourceRequest, resourceResponse);
|
||||
// } else {
|
||||
// super.serveResource(resourceRequest, resourceResponse);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void _processTemplate(ResourceRequest resourceRequest,
|
||||
// ResourceResponse resourceResponse){
|
||||
//
|
||||
// HttpServletRequest request = PortalUtil
|
||||
// .getHttpServletRequest(resourceRequest);
|
||||
// HttpServletResponse response = PortalUtil
|
||||
// .getHttpServletResponse(resourceResponse);
|
||||
//
|
||||
// try {
|
||||
//
|
||||
// ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest
|
||||
// .getAttribute(WebKeys.THEME_DISPLAY);
|
||||
//
|
||||
// byte[] bytes = new byte[0];
|
||||
//
|
||||
// UploadPortletRequest uploadPortletRequest = PortalUtil
|
||||
// .getUploadPortletRequest(resourceRequest);
|
||||
//
|
||||
// ReportAvvisoBean bean = ReportAvvisoBeanBuilder.build(avviso, parameters);
|
||||
// String resourcePath = getClass().getName().replaceAll("\\w+\\.", "../")
|
||||
// .replace(getClass().getSimpleName(), ReportConstants.PATH_LOGO_REGIONE);
|
||||
// parameters.put(ReportConstants.LOGO_REGIONE, getClass().getResource(resourcePath).getPath());
|
||||
// ReportDto reportDto = new ReportDto();
|
||||
// reportDto.setFileEntryIds(new long[] { fileEntryIdTemplate });
|
||||
// reportDto.setFolderId(folderId);
|
||||
// reportDto.setFileName(fileName);
|
||||
// reportDto.setParameters(parameters);
|
||||
// reportDto.setShowNumberOfPage(true);
|
||||
// reportDto.setType(ReportConstants.ReportType.JRXML_TO_PDF.toString());
|
||||
// ReportResultDto result = ReportUtil.generateReport(companyId, userId, reportDto, bean);
|
||||
//
|
||||
// String parametersJSON = ParamUtil.getString(
|
||||
// uploadPortletRequest, "parametersJSON");
|
||||
//
|
||||
// HashMap<String, Object> params = new HashMap<String, Object>();
|
||||
// if (Validator.isNotNull(parametersJSON)) {
|
||||
// params = (HashMap<String, Object>) JSONFactoryUtil
|
||||
// .looseDeserialize(parametersJSON);
|
||||
// }
|
||||
//
|
||||
// String objectJSON = ParamUtil.getString(uploadPortletRequest,
|
||||
// "objectJSON");
|
||||
//
|
||||
// String fileNameTemplate = uploadPortletRequest
|
||||
// .getFileName("fileTemplate");
|
||||
//
|
||||
// ReportInterface reportInterface = null;
|
||||
//
|
||||
// if (Validator.isNotNull(objectJSON)) {
|
||||
//
|
||||
// JSONObject jsonObject = JSONFactoryUtil
|
||||
// .createJSONObject(objectJSON);
|
||||
//
|
||||
// ClassPool pool = ClassPool.getDefault();
|
||||
//
|
||||
// Class<?> clazz = makeClass(pool, jsonObject);
|
||||
// Object dataSource = clazz.newInstance();
|
||||
//
|
||||
// reportInterface = new BeanReport(dataSource);
|
||||
// }
|
||||
//
|
||||
// if (Validator.isNotNull(fileNameTemplate)) {
|
||||
//
|
||||
// InputStream inputStream = null;
|
||||
// try {
|
||||
// inputStream = uploadPortletRequest
|
||||
// .getFileAsStream("fileTemplate");
|
||||
//
|
||||
// JasperPdfProvider pdfProvider = new JasperPdfProvider();
|
||||
// pdfProvider.doReport(inputStream, params,
|
||||
// reportInterface);
|
||||
//
|
||||
// bytes = pdfProvider.getBytes();
|
||||
// } finally {
|
||||
// StreamUtil.cleanUp(inputStream);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// ServletResponseUtil.sendFile(request, response, "test.pdf", bytes,
|
||||
// ContentTypes.APPLICATION_PDF);
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
// _log.error(e, e);
|
||||
//
|
||||
// ServletResponseUtil.sendFile(request, response, "test.html", e
|
||||
// .toString().getBytes(StringPool.UTF8),
|
||||
// ContentTypes.TEXT_HTML_UTF8);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// private final static Log _log = LogFactoryUtil.getLog(TestPdf.class);
|
||||
//}
|
||||
|
File binario non mostrato.
File binario non mostrato.
File binario non mostrato.
File binario non mostrato.
File binario non mostrato.
File binario non mostrato.
File binario non mostrato.
File binario non mostrato.
File binario non mostrato.
Caricamento…
Reference in new issue