Skip to content

Commit

Permalink
add missing commit from svn to git
Browse files Browse the repository at this point in the history
  • Loading branch information
alecones committed May 11, 2016
1 parent 9db7fff commit 4d54c2e
Show file tree
Hide file tree
Showing 55 changed files with 8,497 additions and 687 deletions.
45 changes: 45 additions & 0 deletions QbeCore/src/main/resources/template.jrxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!-- Created with Qbe - Free inquery and adhoc reporting tool of SpagoBI Platform -->
<!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">
<jasperReport
name="report"
columnCount="1"
printOrder="Vertical"
orientation="Portrait"
pageWidth="595"
pageHeight="842"
columnWidth="535"
columnSpacing="0"
leftMargin="30"
rightMargin="30"
topMargin="20"
bottomMargin="20"
whenNoDataType="NoPages"
isTitleNewPage="false"
isSummaryNewPage="false"
${pagination}>
<property name="ireport.scriptlethandling" value="0" />
<property name="ireport.encoding" value="ISO-8859-1" />
<import value="java.util.*" />
<import value="net.sf.jasperreports.engine.*" />
<import value="net.sf.jasperreports.engine.data.*" />

<queryString language="${lang}"><![CDATA[
${query}
]]></queryString>

${fields}

<pageHeader>
<band height="30" isSplitAllowed="true" >
</band>
</pageHeader>

${body}

<pageFooter>
<band height="30" isSplitAllowed="true" >
</band>
</pageFooter>

</jasperReport>
90 changes: 90 additions & 0 deletions QbeCore/src/main/resources/template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{
"qbeConf": {
"datamartsName": []
, "query": {}
}
, "fields": []
, "staticClosedFilters": [
{
"title": "",
"singleSelection": true,
"allowNoSelection": true,
"noSelectionText": "",
"height": 150,
"width": 300,
"filters": [
{
"text": "",
"leftOperandValue": "",
"operator": "",
"rightOperandValue": ""
},
{
"text": "",
"leftOperandValue": "",
"operator": "",
"rightOperandValue": ""
}
]
},
{
"title": "",
"singleSelection": false,
"height": 150,
"width": 300,
"filters": [
{
"text": "",
"leftOperandValue": "",
"operator": "",
"rightOperandValue": ""
},
{
"text": "",
"leftOperandValue": "",
"operator": "",
"rightOperandValue": ""
}
]
}
]
, "staticOpenFilters": [
{
"text": "",
"field": "",
"operator": "EQUALS TO",
"singleSelection": false,
"maxSelectedNumber": 3,
"height": 150,
"width": 300,
"query": {
"field": "",
"orderField": "",
"orderType": "ASC"
}
},
{
"text": "",
"field": "",
"height": 150,
"width": 300,
"operator": "EQUALS TO",
"singleSelection": true
}
]
, "dynamicFilters": [
{
"operator": "EQUALS TO",
"admissibleFields": [
{"field": "", "text": ""}
]
}
]
, "groupingVariables": [
{
"admissibleFields": [
{"field": "", "text": ""}
]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import it.eng.spagobi.utilities.DynamicClassLoader;
import it.eng.spagobi.utilities.ParametersDecoder;
import it.eng.spagobi.utilities.SpagoBIAccessUtils;
import it.eng.spagobi.utilities.assertion.Assert;
import it.eng.spagobi.utilities.callbacks.audit.AuditAccessUtils;

import java.io.ByteArrayInputStream;
Expand Down Expand Up @@ -59,6 +60,7 @@

import org.apache.log4j.Logger;
import org.eclipse.birt.report.IBirtConstants;
import org.eclipse.birt.report.engine.api.EXCELRenderOption;
import org.eclipse.birt.report.engine.api.HTMLActionHandler;
import org.eclipse.birt.report.engine.api.HTMLRenderOption;
import org.eclipse.birt.report.engine.api.HTMLServerImageHandler;
Expand Down Expand Up @@ -592,23 +594,14 @@ protected void runReport(HttpServletRequest request, HttpServletResponse respons
renderOption.setOutputFormat(RTF_FORMAT);
response.setContentType("application/rtf");
response.setHeader("Content-disposition", "inline; filename=" + templateFileName + ".rtf");
} else if (outputFormat != null && outputFormat.equalsIgnoreCase("xls")) {
renderOption = prepareHtmlRenderOption(servletContext, request);
// change emitter according to engine config.xml
SourceBean engineConfig = EnginConf.getInstance().getConfig();
String emitter = null;
if (engineConfig != null) {
SourceBean sourceBeanConf = (SourceBean) engineConfig.getAttribute("XLS_EMITTER");
if (sourceBeanConf != null) {
emitter = sourceBeanConf.getCharacters();
renderOption.setOption(IRenderOption.EMITTER_ID, emitter);
}
}
// render
renderOption.setOutputFormat("xls");
// renderOption.setOutputFileName(templateFileName + ".xls");
} else if (outputFormat != null && outputFormat.equalsIgnoreCase(IBirtConstants.EXCEL_RENDER_FORMAT)) {
renderOption = getExcelRenderOption("xls");
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-disposition", "inline; filename=" + templateFileName + ".xls");
} else if (outputFormat != null && outputFormat.equalsIgnoreCase("xlsx")) {
renderOption = getExcelRenderOption("xlsx");
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setHeader("Content-disposition", "inline; filename=" + templateFileName + ".xlsx");
}
// else if (outputFormat != null &&
// outputFormat.equalsIgnoreCase("xlsx")) {
Expand Down Expand Up @@ -691,6 +684,22 @@ else if (outputFormat != null && outputFormat.equalsIgnoreCase("ppt")) {

}

private IRenderOption getExcelRenderOption(String output) {
IRenderOption renderOption = new EXCELRenderOption();
// change emitter according to engine-config.xml
SourceBean engineConfig = EnginConf.getInstance().getConfig();
Assert.assertNotNull(engineConfig, "Could not find engine configuration file");
String attributeName = output.equalsIgnoreCase("xls") ? "XLS_EMITTER" : "XLSX_EMITTER";
SourceBean emitterConf = (SourceBean) engineConfig.getAttribute(attributeName);
Assert.assertNotNull(emitterConf, "Could not find Excel emitter configuration");
String emitterId = (String) emitterConf.getAttribute("id");
String outputFormat = (String) emitterConf.getAttribute("output_format");
logger.debug("Using emitter [" + emitterId + "] with output format [" + outputFormat + "] ...");
renderOption.setOption(IRenderOption.EMITTER_ID, emitterId);
renderOption.setOutputFormat(outputFormat);
return renderOption;
}

private Map getTaskContext(String userId, Map reportParams, HttpServletRequest request, String resourcePath, Map userProfileAttrs) throws IOException {
Map context = BirtUtility.getAppContext(request);

Expand Down
14 changes: 9 additions & 5 deletions SpagoBIBirtReportEngine/src/main/resources/engine-config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,14 @@
<SbiDocumentServiceProxy_URL>/services/SbiDocumentService</SbiDocumentServiceProxy_URL>
<MetamodelServiceProxy_URL>/services/MetamodelService</MetamodelServiceProxy_URL>

<!-- DEFAULt emitter -->
<!-- <XLS_EMITTER>org.eclipse.birt.report.engine.emitter.prototype.excel</XLS_EMITTER> -->
<!-- tribix emitter -->
<XLS_EMITTER>org.uguess.birt.report.engine.emitter.xls</XLS_EMITTER>
<!-- <CSV_EMITTER_ENCODING>UTF-8</CSV_EMITTER_ENCODING> -->
<!-- default XLS emitter -->
<!-- <XLS_EMITTER id="org.eclipse.birt.report.engine.emitter.prototype.excel" output_format="xls" /> -->
<!-- spudsoft XLS emitter -->
<XLS_EMITTER id="uk.co.spudsoft.birt.emitters.excel.XlsEmitter" output_format="xls_spudsoft" />

<!-- spudsoft XLSX emitter -->
<XLSX_EMITTER id="uk.co.spudsoft.birt.emitters.excel.XlsxEmitter" output_format="xlsx" />

<!-- <CSV_EMITTER_ENCODING>UTF-8</CSV_EMITTER_ENCODING> -->

</ENGINE-CONFIGURATION>
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,25 @@
* If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package it.eng.spagobi.behaviouralmodel.lov.bo;

import it.eng.spagobi.behaviouralmodel.analyticaldriver.bo.BIObjectParameter;
import it.eng.spagobi.commons.utilities.SpagoBIUtilities;
import it.eng.spagobi.commons.utilities.StringUtilities;
import it.eng.spagobi.utilities.exceptions.SpagoBIRuntimeException;
import it.eng.spagobi.utilities.objects.Couple;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.apache.log4j.Logger;

public abstract class AbstractLOV implements ILovDetail {

private static transient Logger logger = Logger.getLogger(AbstractLOV.class);

@Override
public boolean isSimpleLovType() {
return this.getLovType() == null || this.getLovType().equalsIgnoreCase("simple");
Expand Down Expand Up @@ -47,4 +57,79 @@ protected List<String> getTreeDescriptionColumns() {
}
}

public Map<String, String> getParametersNameToValueMap(List<BIObjectParameter> biObjectParameters) throws Exception {
Map<String, String> parameters = null;
Set<String> parameterNames = getParameterNames();
if (parameterNames != null && !parameterNames.isEmpty()) {
if (biObjectParameters != null && !biObjectParameters.isEmpty()) {
parameters = new HashMap<String, String>(parameterNames.size());
int numberOfParametersFound = 0;
for (BIObjectParameter objParam : biObjectParameters) {
if (parameterNames.contains(objParam.getParameter().getLabel())) {
logger.debug("Found parameter with name [" + objParam.getParameter().getLabel() + "], also used by the LOV.");
numberOfParametersFound++;
String parameterValue = null;
List<String> parameterValues = objParam.getParameterValues();
if (parameterValues != null && !parameterValues.isEmpty()) {
if (parameterValues.size() == 1) {
parameterValue = StringUtilities.getSingleValue(parameterValues.get(0), objParam.getParameter().getType());
} else {
// build the value as multivalue
parameterValue = StringUtilities.getMultiValue(SpagoBIUtilities.fromListToString(parameterValues, ","), objParam.getParameter()
.getType());
}
logger.debug("The parameter with name [" + objParam.getParameter().getLabel() + "] has value [" + parameterValue + "]");
parameters.put(objParam.getParameter().getLabel(), parameterValue);
} else {
logger.error("The parameter with name [" + objParam.getParameter().getLabel() + "] is null");
throw new SpagoBIRuntimeException("Impossible to retrieve all the parameters value for the LOV.");
}
}
}
if (numberOfParametersFound != parameterNames.size()) {
logger.error("The LOV needs " + parameterNames.size()
+ ", but the parameters from the document execution do not match all the LOV parameters.");
throw new SpagoBIRuntimeException("Impossible to retrieve all the parameters value for the LOV.");
}
} else {
logger.error("The LOV needs " + parameterNames.size() + ", but the set of parameter from the document execution is null or empty.");
throw new SpagoBIRuntimeException("Impossible to retrieve all the parameters value for the LOV.");
}
}
return parameters;
}

public Map<String, String> getParametersNameToTypeMap(List<BIObjectParameter> biObjectParameters) throws Exception {
Map<String, String> parameters = null;
Set<String> parameterNames = getParameterNames();
if (parameterNames != null && !parameterNames.isEmpty()) {
if (biObjectParameters != null && !biObjectParameters.isEmpty()) {
parameters = new HashMap<String, String>(parameterNames.size());
int numberOfParametersFound = 0;
for (BIObjectParameter objParam : biObjectParameters) {
if (parameterNames.contains(objParam.getParameter().getLabel())) {
String parameterType = objParam.getParameter().getType();
logger.debug("Found parameter with name [" + objParam.getParameter().getLabel() + "], also used by the LOV.");
numberOfParametersFound++;
if (parameterType != null) {
logger.debug("The parameter with name [" + objParam.getParameter().getLabel() + "] has value [" + parameterType + "]");
parameters.put(objParam.getParameter().getLabel(), parameterType);
} else {
logger.error("The parameter with name [" + objParam.getParameter().getLabel() + "] is null");
throw new SpagoBIRuntimeException("Impossible to retrieve all the parameters value for the LOV.");
}
}
}
if (numberOfParametersFound != parameterNames.size()) {
logger.error("The LOV needs " + parameterNames.size()
+ ", but the parameters from the document execution do not match all the LOV parameters.");
throw new SpagoBIRuntimeException("Impossible to retrieve all the parameters value for the LOV.");
}
} else {
logger.error("The LOV needs " + parameterNames.size() + ", but the set of parameter from the document execution is null or empty.");
throw new SpagoBIRuntimeException("Impossible to retrieve all the parameters value for the LOV.");
}
}
return parameters;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;

import org.apache.log4j.Logger;

Expand Down Expand Up @@ -266,8 +268,12 @@ public String getLovResult(IEngUserProfile profile, List<ObjParuse> dependencies
throws Exception {
// gets the dataset object informations
IDataSet dataset = DAOFactory.getDataSetDAO().loadDataSetById(new Integer(getDatasetId()));
Map parameters = new HashMap();
dataset.setParamsMap(parameters);
Map<String, String> params = getParametersNameToValueMap(BIObjectParameters);
if (params == null) {
dataset.setParamsMap(new HashMap<String, String>());
} else {
dataset.setParamsMap(params);
}
dataset.setUserProfileAttributes(UserProfileUtils.getProfileAttributes(profile));
dataset.loadData();
IDataStore ids = dataset.getDataStore();
Expand Down Expand Up @@ -425,4 +431,10 @@ public void setTreeLevelsColumns(List<Couple<String, String>> treeLevelsColumns)
this.treeLevelsColumns = treeLevelsColumns;
}

@Override
public Set<String> getParameterNames() throws Exception {
// Empty List because Profile Attributes are managed inside the Dataset logic
return new HashSet<String>();
}

}

0 comments on commit 4d54c2e

Please sign in to comment.