Skip to content

Commit

Permalink
bring on trunk updates on What if Engine on merge 5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
gigavard committed Jun 24, 2016
1 parent ca5d110 commit 93d5d88
Show file tree
Hide file tree
Showing 12 changed files with 147 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
* @author Davide Zerbetto (davide.zerbetto@eng.it), Alberto Ghedin (alberto.ghedin@eng.it)
*/
package it.eng.spagobi.engines.whatif;

import it.eng.spago.security.IEngUserProfile;
import it.eng.spagobi.commons.constants.SpagoBIConstants;
import it.eng.spagobi.commons.utilities.StringUtilities;
Expand Down Expand Up @@ -139,6 +138,12 @@ public WhatIfEngineInstance(WhatIfTemplate template, Map env) {
modelConfig = new ModelConfig(pivotModel);
modelConfig.setScenario(template.getScenario());
modelConfig.setAliases(template.getAliases());
Map<String, String> map = template.getDefaultValues();

if (map != null) {
modelConfig.setSuppressEmpty(Boolean.valueOf(map.get(new String("BUTTON_HIDE_EMPTY"))));
modelConfig.setShowProperties(Boolean.valueOf(map.get(new String("BUTTON_SHOW_PROPERTIES"))));
}

// init artifact informations
if (!template.isStandAlone()) {
Expand All @@ -154,17 +159,19 @@ public WhatIfEngineInstance(WhatIfTemplate template, Map env) {
modelConfig.setLocker(locker);
logger.debug("Init the datatsource fro writing");
dataSourceForWriting = initDataSourceForWriting();
SpagoBIPivotModel sbiModel = (SpagoBIPivotModel) pivotModel;
if (template.getCrossNavigation() != null) {
modelConfig.setCrossNavigation(template.getCrossNavigation());
sbiModel.setCrossNavigation(template.getCrossNavigation());
}
if (template.getTargetsClickable() != null) {
sbiModel.setTargetsClickable(template.getTargetsClickable());
}

}

SpagoBIPivotModel sbiModel = (SpagoBIPivotModel) pivotModel;
if (template.getCrossNavigation() != null) {
modelConfig.setCrossNavigation(template.getCrossNavigation());
template.getCrossNavigation().setModelStatus(modelConfig.getStatus());
sbiModel.setCrossNavigation(template.getCrossNavigation());
}
if (template.getTargetsClickable() != null) {
sbiModel.setTargetsClickable(template.getTargetsClickable());
}

// init toolbar
modelConfig.setToolbarMenuButtons(template.getToolbarMenuButtons());
modelConfig.setToolbarVisibleButtons(template.getToolbarVisibleButtons());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;

import org.olap4j.CellSet;
import org.olap4j.CellSetAxis;
Expand All @@ -38,11 +39,11 @@
public class MemberResource extends AbstractWhatIfEngineService {

@GET
@Path("/drilldown/{axis}/{position}/{member}/{positionUniqueName}/{memberUniqueName}")
@Path("/drilldown/{axis}/{position}/{member}")
@Produces("text/html; charset=UTF-8")
public String drillDown(@javax.ws.rs.core.Context HttpServletRequest req, @PathParam("axis") int axisPos, @PathParam("position") int positionPos,
@PathParam("member") int memberPos, @PathParam("positionUniqueName") String positionUniqueName,
@PathParam("memberUniqueName") String memberUniqueName) {
@PathParam("member") int memberPos, @QueryParam("positionUniqueName") String positionUniqueName,
@QueryParam("memberUniqueName") String memberUniqueName) {

WhatIfEngineInstance ei = getWhatIfEngineInstance();
PivotModel model = ei.getPivotModel();
Expand Down Expand Up @@ -93,11 +94,11 @@ public String drillDown(@javax.ws.rs.core.Context HttpServletRequest req, @PathP
}

@GET
@Path("/drillup/{axis}/{position}/{member}/{positionUniqueName}/{memberUniqueName}")
@Path("/drillup/{axis}/{position}/{member}")
@Produces("text/html; charset=UTF-8")
public String drillUp(@javax.ws.rs.core.Context HttpServletRequest req, @PathParam("axis") int axisPos, @PathParam("position") int positionPos,
@PathParam("member") int memberPos, @PathParam("positionUniqueName") String positionUniqueName,
@PathParam("memberUniqueName") String memberUniqueName) {
@PathParam("member") int memberPos, @QueryParam("positionUniqueName") String positionUniqueName,
@QueryParam("memberUniqueName") String memberUniqueName) {

List<Member> m = null;
Member m2 = null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,41 +1,48 @@
/* SpagoBI, the Open Source Business Intelligence suite
* Copyright (C) 2012 Engineering Ingegneria Informatica S.p.A. - SpagoBI Competency Center
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0, without the "Incompatible With Secondary Licenses" notice.
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0, without the "Incompatible With Secondary Licenses" notice.
* 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.engines.whatif.crossnavigation;

import it.eng.spago.base.SourceBean;
import it.eng.spagobi.engines.whatif.template.WhatIfXMLTemplateParser;

import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;

import org.apache.log4j.Logger;

public class SpagoBICrossNavigationConfig {
private static transient Logger logger = Logger.getLogger(SpagoBICrossNavigationConfig.class);

private List<Target> targets = null;
public static final String ID = "cross_navigation_config";

public static final String ID = "cross_navigation_config";

private boolean buttonClicked;

private String modelStatus;

/**
* Constructor given the CROSS_NAVIGATION node of the xml document template.
* @param config: the CROSS_NAVIGATION node of the xml document template
*
* @param config
* : the CROSS_NAVIGATION node of the xml document template
*/
public SpagoBICrossNavigationConfig(SourceBean config) {
logger.debug("Configuration:\n" + config.toXML());
init(config);
}



public SpagoBICrossNavigationConfig() {
}

private void init(SourceBean node){
private void init(SourceBean node) {
String activated = (String) node.getAttribute(WhatIfXMLTemplateParser.TAG_DEFAULT);
if (activated != null && activated.equalsIgnoreCase(WhatIfXMLTemplateParser.TRUE))
this.setButtonClicked(true);
targets = new ArrayList<Target>();
List targetNodes = node.getAttributeAsList("TARGET");
if (targetNodes != null && !targetNodes.isEmpty()) {
Expand All @@ -47,7 +54,6 @@ private void init(SourceBean node){
}
}
}


public boolean isButtonClicked() {
return buttonClicked;
Expand All @@ -72,10 +78,5 @@ public List<Target> getTargets() {
public void setTargets(List<Target> targets) {
this.targets = targets;
}





}

Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/* SpagoBI, the Open Source Business Intelligence suite
* Copyright (C) 2012 Engineering Ingegneria Informatica S.p.A. - SpagoBI Competency Center
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0, without the "Incompatible With Secondary Licenses" notice.
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0, without the "Incompatible With Secondary Licenses" notice.
* 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.engines.whatif.crossnavigation;


import it.eng.spago.base.SourceBean;
import it.eng.spagobi.engines.whatif.template.WhatIfXMLTemplateParser;
import java.io.Serializable;
Expand All @@ -16,8 +15,8 @@
/*
* Target in cross navigation configuration
*/
public class Target implements Serializable{
public class Target implements Serializable {

private static final long serialVersionUID = -4036176618363112988L;
String documentLabel;
String customizedView;
Expand All @@ -30,19 +29,25 @@ public class Target implements Serializable{
public Target() {
}

public Target(SourceBean sb) {
public Target(SourceBean sb) {
documentLabel = (String) sb.getAttribute(WhatIfXMLTemplateParser.TAG_TG_DOCUMENT_LABEL);
customizedView = (String) sb.getAttribute(WhatIfXMLTemplateParser.TAG_TG_CUSTOMIZED_VIEW);
List list= sb.getAttributeAsList(WhatIfXMLTemplateParser.TAG_TG_TITLE);
customizedView = (String) sb.getAttribute(WhatIfXMLTemplateParser.TAG_TG_CUSTOMIZED_VIEW);
List list = sb.getAttributeAsList(WhatIfXMLTemplateParser.TAG_TG_TITLE);
targetCross = (String) sb.getAttribute(WhatIfXMLTemplateParser.TAG_TG_TARGET);
titleCross = (String) list.get(0);
Object titleObject = list.get(0);
if (titleObject instanceof String) {
titleCross = (String) list.get(0);
} else {
titleCross = ((SourceBean) list.get(0)).getCharacters();
}

if (customizedView != null && customizedView.trim().equals("")) {
customizedView = null;
}
SourceBean descrSB = (SourceBean) sb.getAttribute(WhatIfXMLTemplateParser.TAG_CN_DESCRIPTION);
description = descrSB.getCharacters();
SourceBean titleSB = (SourceBean) list.get(1);
title = (String) titleSB.getCharacters();
title = titleSB.getCharacters();
List parametersSB = sb.getAttributeAsList(WhatIfXMLTemplateParser.TAG_TN_PARAMETERS);
List parameterSB = ((SourceBean) parametersSB.get(0)).getAttributeAsList(WhatIfXMLTemplateParser.TAG_TN_PARAMETER);
boolean hasParameters = parameterSB != null && !parameterSB.isEmpty();
Expand All @@ -56,7 +61,7 @@ public Target(SourceBean sb) {
}
}
}

}

public String getDocumentLabel() {
Expand Down Expand Up @@ -114,6 +119,5 @@ public List<TargetParameter> getParameters() {
public void setParameters(List<TargetParameter> parameters) {
this.parameters = parameters;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.eyeq.pivot4j.ui.command.DrillDownCommand;
import com.fasterxml.jackson.annotation.JsonIgnore;


public class ModelConfig implements Serializable {

private static final long serialVersionUID = 2687163910212567575L;
Expand All @@ -48,7 +49,8 @@ public class ModelConfig implements Serializable {

private SpagoBICrossNavigationConfig crossNavigation;

public ModelConfig() {}
public ModelConfig() {
}

public ModelConfig(PivotModel pivotModel) {
drillType = DrillDownCommand.MODE_POSITION;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.util.List;
import java.util.Map;


/**
* @author Zerbetto Davide (davide.zerbetto@eng.it)
*/
Expand All @@ -35,6 +36,7 @@ public class WhatIfTemplate {
private Map<String, String> xmlaServerProperties;
private SpagoBICrossNavigationConfig crossNavigation;
List<TargetClickable> targetsClickable = new ArrayList<TargetClickable>();
private Map<String, String> defaultValues;

public WhatIfTemplate() {
properties = new HashMap<String, Object>();
Expand Down Expand Up @@ -185,4 +187,12 @@ public void setTargetsClickable(List<TargetClickable> targetsClickable) {
this.targetsClickable = targetsClickable;
}

public Map<String, String> getDefaultValues() {
return defaultValues;
}

public void setDefaultValues(Map<String, String> defaultValues) {
this.defaultValues = defaultValues;
}

}
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
/* SpagoBI, the Open Source Business Intelligence suite
* Copyright (C) 2012 Engineering Ingegneria Informatica S.p.A. - SpagoBI Competency Center
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0, without the "Incompatible With Secondary Licenses" notice.
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0, without the "Incompatible With Secondary Licenses" notice.
* 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.engines.whatif.template;

import it.eng.spago.base.SourceBean;

import java.util.HashMap;
import java.util.Map;

/**
* @author Zerbetto Davide (davide.zerbetto@eng.it)
*/
Expand All @@ -31,6 +30,7 @@ private WhatIfTemplateParser() {
parsers.put(SourceBean.class.getName(), new WhatIfXMLTemplateParser());
}

@Override
public WhatIfTemplate parse(Object template) {
WhatIfTemplate qbeTemplate;
IWhatIfTemplateParser parser;
Expand All @@ -39,9 +39,7 @@ public WhatIfTemplate parse(Object template) {

if (template != null) {
if (!parsers.containsKey(template.getClass().getName())) {
throw new WhatIfTemplateParseException(
"Impossible to parse template of type ["
+ template.getClass().getName() + "]");
throw new WhatIfTemplateParseException("Impossible to parse template of type [" + template.getClass().getName() + "]");
} else {
parser = parsers.get(template.getClass().getName());
qbeTemplate = parser.parse(template);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public class WhatIfHTMLRenderer extends HtmlRenderer {
// if the member stay in the columns this is the rowPosition of all the occurrence of the member.. Viceversa for the rows
private Map<Member, Integer> memberPositions;
private boolean showProperties = false;
private String styleInLabel;

public static transient Logger logger = Logger.getLogger(HtmlRenderer.class);

Expand Down Expand Up @@ -461,7 +462,7 @@ public void cellContent(RenderContext context, String label) {
getWriter().startElement("img", attributes);
getWriter().endElement("img");

getWriter().writeContent(label);
setColorInCell(label, attributes);
} else {
// TODO: OSMOSIT create member clickable
List<TargetClickable> targetsClickable = sbiModel.getTargetsClickable();
Expand All @@ -481,11 +482,11 @@ public void cellContent(RenderContext context, String label) {
}
} else {

getWriter().writeContent(label);
setColorInCell(label, attributes);
}
} else {

getWriter().writeContent(label);
setColorInCell(label, attributes);
}
// fine OSMOSIT create member clickable

Expand Down Expand Up @@ -565,4 +566,40 @@ public void setOddColumnStyleClass(String oddColumnStyleClass) {
this.oddColumnStyleClass = oddColumnStyleClass;
}

public String getStyleInLabel() {
return this.styleInLabel;
}

public void setStyleInLabel(String styleInLabel) {
this.styleInLabel = styleInLabel;
}

private String[] getCellContent(String label) {
String[] ss = label.split("style");
String number = ss[0].substring(1, ss[0].length() - 1);
String color = ss[1].substring(1);
ss[0] = number;
ss[1] = color;
return ss;
}

private void setColorInCell(String label, Map<String, String> attributes) {
int index = label.indexOf("style");
if (index != -1) {
String[] result = getCellContent(label);
label = result[0];
this.styleInLabel = result[1];
attributes.remove("src");
attributes.remove("onload");
attributes.remove("id");
attributes.put("class", "x-grid-cell-inner");
attributes.put("style", "background-color : " + this.styleInLabel);
getWriter().startElement("div", attributes);
getWriter().writeContent(label);
getWriter().endElement("div");
} else {
getWriter().writeContent(label);
}
}

}

0 comments on commit 93d5d88

Please sign in to comment.