Skip to content

Commit

Permalink
IN PROGRESS - issue SPAGOBI-1756: Version additional functionalities
Browse files Browse the repository at this point in the history
https://www.spagoworld.org/jira/browse/SPAGOBI-1756

git-svn-id: svn://svn.forge.objectweb.org/svnroot/spagobi/V_4.x/Server/trunk@22916 99afaf0d-6903-0410-885a-c66a8bbb5f81
  • Loading branch information
aghedin committed Jun 5, 2014
1 parent 1622b36 commit f866a12
Showing 12 changed files with 84 additions and 53 deletions.
2 changes: 1 addition & 1 deletion SpagoBIWhatIfEngine/WebContent/WEB-INF/resources/tpl.xml
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@
</STANDALONE>


<SCENARIO name="scenario" editCube="Sales_Edit">
<SCENARIO name="scenario" editCube="Sales_Edit" initialVersion="0">
<MEASURE>Store Sales</MEASURE>
<MEASURE>Store Cost</MEASURE>
<VARIABLE name="var" value="5"/>
3 changes: 2 additions & 1 deletion SpagoBIWhatIfEngine/WebContent/js/spagobi/locale/en.js
Original file line number Diff line number Diff line change
@@ -130,4 +130,5 @@ Sbi.locale.ln['sbi.olap.execution.menu.addToToolbar'] = 'Add to toolbar';
//===================================================================
Sbi.locale.ln['sbi.olap.toolbar.versionmanagerwindow.version.no.cancel.all'] = 'You can\'t delete all the versions';
Sbi.locale.ln['sbi.olap.toolbar.versionmanagerwindow.version.no.cancel.current'] = 'You can\'t delete the current versions';
Sbi.locale.ln['sbi.olap.toolbar.versionmanagerwindow.version.title'] = 'Select the version to delete';>>>>>>> .r22906
Sbi.locale.ln['sbi.olap.toolbar.versionmanagerwindow.version.title'] = 'Select the version to delete';
Sbi.locale.ln['sbi.olap.toolbar.versionmanagerwindow.version.select.warning'] = 'Warning: this operation could take some minutes. You can continue your navigation but you can not save modifications untill the operation is finished. This can also make the navigation slower.';
3 changes: 2 additions & 1 deletion SpagoBIWhatIfEngine/WebContent/js/spagobi/locale/it.js
Original file line number Diff line number Diff line change
@@ -129,4 +129,5 @@ Sbi.locale.ln['sbi.olap.execution.menu.addToToolbar'] = 'Add to toolbar';
//===================================================================
Sbi.locale.ln['sbi.olap.toolbar.versionmanagerwindow.version.no.cancel.all'] = 'Non è possibile cancellare tutte le versioni';
Sbi.locale.ln['sbi.olap.toolbar.versionmanagerwindow.version.no.cancel.current'] = 'Non è possibile cancellare la versione attuale';
Sbi.locale.ln['sbi.olap.toolbar.versionmanagerwindow.version.title'] = 'Selezionare le version da cancellare';>>>>>>> .r22906
Sbi.locale.ln['sbi.olap.toolbar.versionmanagerwindow.version.title'] = 'Selezionare le version da cancellare';
Sbi.locale.ln['sbi.olap.toolbar.versionmanagerwindow.version.select.warning'] = 'Attenzione: questa operazione potrebbe impiegare qualche minuto. Fino a che non è compare il messaggio che notifica la fine non sarà possibile salvare eventuali modifiche e la navigazione potrebbe risultare piu lenta.';
Original file line number Diff line number Diff line change
@@ -18,9 +18,12 @@ Ext.define('Sbi.olap.toolbar.VersionManagerWindow', {
extend: 'Ext.window.Window',

config:{
height: 200,
width: 400,
height: 400,
width: 300,
actualVersion: null,
style: "background-color: transparent",
bodyStyle: "background-color: transparent",
autoScroll: true,
title: LN("sbi.olap.toolbar.versionmanagerwindow.version.title")
},

@@ -73,6 +76,7 @@ Ext.define('Sbi.olap.toolbar.VersionManagerWindow', {
}
}, {
text: LN('sbi.common.select'),
tooltip: LN('sbi.olap.toolbar.versionmanagerwindow.version.select.warning'),
handler: function(){
var selected = thisPanel.grid.getSelectionModel( ).getSelection();
var itemsToDelete = "";
Original file line number Diff line number Diff line change
@@ -129,11 +129,9 @@ public WhatIfEngineInstance(WhatIfTemplate template, Map env) {
modelConfig = new ModelConfig();
modelConfig.setScenario(template.getScenario());
modelConfig.setAliases(template.getAliases());
//modelConfig.setToolbarVisibleButtons(template.getToolbarVisibleButtons());
//modelConfig.setToolbarMenuButtons(template.getToolbarMenuButtons());


// init artifact informations

if(!template.isStandAlone()){
Integer artifactVersionID = getArtifactVersionId(getEnv());
modelConfig.setArtifactVersionID(artifactVersionID);
Original file line number Diff line number Diff line change
@@ -18,7 +18,6 @@

import it.eng.spagobi.engines.whatif.WhatIfEngineInstance;
import it.eng.spagobi.engines.whatif.common.AbstractWhatIfEngineService;
import it.eng.spagobi.engines.whatif.cube.CubeUtilities;
import it.eng.spagobi.engines.whatif.exception.WhatIfPersistingTransformationException;
import it.eng.spagobi.engines.whatif.model.SpagoBICellSetWrapper;
import it.eng.spagobi.engines.whatif.model.SpagoBICellWrapper;
@@ -53,7 +52,6 @@
import org.apache.log4j.Logger;
import org.json.JSONObject;
import org.olap4j.OlapDataSource;
import org.olap4j.metadata.Member;

import com.eyeq.pivot4j.PivotModel;
import com.eyeq.pivot4j.export.poi.ExcelExporter;
@@ -157,6 +155,10 @@ public String persistTransformations(){
throw new SpagoBIRuntimeException("Error opening connection to datasource "+dataSource.getLabel(), e);
}
try {

//check if a version has been selected in the cube
((SpagoBIPivotModel)ei.getPivotModel()).getActualVersionSlicer(ei.getModelConfig());

//Persisting the pending modifications
modelWrapper.persistTransformations(connection);
} catch (WhatIfPersistingTransformationException e) {
Original file line number Diff line number Diff line change
@@ -15,7 +15,6 @@
import it.eng.spagobi.writeback4j.WriteBackEditConfig;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -39,9 +38,6 @@ public class ModelConfig implements Serializable {
private String status;
private String locker;

// private List<String> toolbarVisibleButtons =new ArrayList<String>();
// private List<String> toolbarMenuButtons;


private List<String> toolbarVisibleButtons;
private List<String> toolbarMenuButtons;
@@ -109,6 +105,9 @@ public void setDimensionHierarchy(String dimensionUniqueName, String hierarchyUn
}

public Integer getActualVersion() {
if(actualVersion==null && scenario!=null && scenario.getWritebackEditConfig()!=null ){
return scenario.getWritebackEditConfig().getInitialVersion();
}
return actualVersion;
}

Original file line number Diff line number Diff line change
@@ -10,22 +10,29 @@

package it.eng.spagobi.engines.whatif.model;

import it.eng.spagobi.engines.whatif.cube.CubeUtilities;
import it.eng.spagobi.engines.whatif.exception.WhatIfPersistingTransformationException;
import it.eng.spagobi.engines.whatif.model.transform.CellTransformation;
import it.eng.spagobi.engines.whatif.model.transform.CellTransformationsAnalyzer;
import it.eng.spagobi.engines.whatif.model.transform.CellTransformationsStack;
import it.eng.spagobi.engines.whatif.model.transform.algorithm.AllocationAlgorithm;
import it.eng.spagobi.utilities.engines.SpagoBIEngineRuntimeException;
import it.eng.spagobi.utilities.exceptions.SpagoBIEngineRestServiceRuntimeException;

import java.sql.Connection;
import java.util.Iterator;
import java.util.List;

import org.apache.log4j.Logger;
import org.olap4j.Cell;
import org.olap4j.CellSet;
import org.olap4j.OlapDataSource;
import org.olap4j.metadata.Cube;
import org.olap4j.metadata.Hierarchy;
import org.olap4j.metadata.Member;

import com.eyeq.pivot4j.impl.PivotModelImpl;
import com.eyeq.pivot4j.transform.ChangeSlicer;

public class SpagoBIPivotModel extends PivotModelImpl {
public static transient Logger auditlogger = Logger.getLogger("audit.stack");
@@ -157,6 +164,33 @@ public void logErrorTransformations(CellTransformationsStack remaningTransformat
auditlogger.info("Error persisting the these modifications "+ remaningTransformations.toString());
}


public Integer getActualVersionSlicer(ModelConfig modelConfig){
logger.debug("IN");

// get cube
Cube cube = getCube();

Hierarchy hierarchy = CubeUtilities.getVersionHierarchy(cube, modelConfig);

ChangeSlicer ph = getTransform(ChangeSlicer.class);
List<Member> slicers = ph.getSlicer(hierarchy);

if(slicers == null || slicers.size()==0){
logger.error( "No version slicer deifined in the mdx query");
throw new SpagoBIEngineRestServiceRuntimeException("versionresource.getactualversion.no.slicer.error", getLocale(), "No version in the mdx query");
}

String slicerValue = slicers.get(0).getName();

if(slicerValue == null){
logger.error( "No version slicer deifined in the mdx query");
throw new SpagoBIEngineRestServiceRuntimeException("versionresource.getactualversion.no.slicer.error", getLocale(), "No version in the mdx query");
}

logger.debug("The actual version is "+slicerValue);
logger.debug("OUT");
return new Integer(slicerValue);
}


}
Original file line number Diff line number Diff line change
@@ -42,6 +42,7 @@ public class WhatIfXMLTemplateParser implements IWhatIfTemplateParser {
public final static String MEASURE_TAG = "MEASURE";
public final static String WRITEBACK_TAG = "WRITEBACK";
public final static String EDIT_CUBE_ATTRIBUTE = "editCube";
public final static String INITIAL_VERSION_ATTRIBUTE = "initialVersion";
public static String PROP_PARAMETER_NAME = "name";
public static String PROP_PARAMETER_ALIAS = "as";
public static String SCENARIO_VARIABLES_TAG = "SCENARIO_VARIABLES";
@@ -263,6 +264,7 @@ private static void initWriteBackConf(SourceBean scenarioSB, SbiScenario scenari
logger.error("In the writeback is enabled you must specify a cube to edit. Remove the "+WRITEBACK_TAG+" tag or specify a value for the attribute "+EDIT_CUBE_ATTRIBUTE );
throw new SpagoBIEngineRuntimeException("In the writeback is enabled you must specify a cube to edit. Remove the "+WRITEBACK_TAG+" tag or specify a value for the attribute "+EDIT_CUBE_ATTRIBUTE);
}

List<SourceBean> editableMeasuresBeans = (List<SourceBean>)scenarioSB.getAttributeAsList(WhatIfXMLTemplateParser.MEASURE_TAG);
if(editableMeasuresBeans!=null && editableMeasuresBeans.size()>0 ){
List<String> editableMeasures = new ArrayList<String>();
@@ -272,6 +274,17 @@ private static void initWriteBackConf(SourceBean scenarioSB, SbiScenario scenari
writeBackConfig.setEditableMeasures(editableMeasures);
logger.debug(TAG_SCENARIO + ":the editable measures are "+editableMeasures);
}

String initialVersion = (String)scenarioSB.getAttribute(WhatIfXMLTemplateParser.INITIAL_VERSION_ATTRIBUTE);
if(initialVersion!=null && initialVersion.length()>0){
try {
writeBackConfig.setInitialVersion(new Integer(initialVersion));
logger.error("The inital version is "+initialVersion);
} catch (Throwable e) {
logger.error("Error loading the inital version from the template "+initialVersion);
}
}

writeBackConfig.setEditCubeName(editCube);
logger.debug(TAG_SCENARIO + ":the edit cube is "+editCube);
scenario.setWritebackEditConfig(writeBackConfig);
Original file line number Diff line number Diff line change
@@ -7,10 +7,7 @@
package it.eng.spagobi.engines.whatif.version;

import it.eng.spagobi.engines.whatif.WhatIfEngineInstance;
import it.eng.spagobi.tools.dataset.common.datastore.IDataStore;
import it.eng.spagobi.tools.datasource.bo.IDataSource;
import it.eng.spagobi.utilities.engines.SpagoBIEngineException;
import it.eng.spagobi.writeback4j.ISchemaRetriver;
import it.eng.spagobi.writeback4j.sql.SqlInsertStatement;
import it.eng.spagobi.writeback4j.sql.SqlQueryStatement;
import it.eng.spagobi.writeback4j.sql.SqlUpdateStatement;
@@ -50,15 +47,11 @@ public VersionDAO( WhatIfEngineInstance instance){

}

public Integer getLastVersion(Connection connection, Integer lastVersion) throws SpagoBIEngineException, NumberFormatException{
public Integer getLastVersion(Connection connection) throws SpagoBIEngineException, NumberFormatException{
logger.debug("IN");
logger.debug("get Last version");

ISchemaRetriver retriver = instance.getWriteBackManager().getRetriver();

if(lastVersion!=null){
return lastVersion;
}
Integer lastVersion;

try {
String sqlQuery = "select MAX("+getVersionColumnName()+") as "+getVersionColumnName()+" from "+editCubeTableName;
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@ public PivotModel persistNewVersionProcedure(){
}

public PivotModel persistNewVersionProcedure(Integer newVersion){
Integer actualVersion = getActualVersionSlicer();
Integer actualVersion = ((SpagoBIPivotModel)instance.getPivotModel()).getActualVersionSlicer(instance.getModelConfig());
return persistNewVersionProcedure(actualVersion, newVersion);
}

@@ -75,7 +75,7 @@ public PivotModel persistNewVersionProcedure(Integer version, Integer newVersion

if(newVersion == null){
logger.debug("Get last version");
newVersion = versionDAO.getLastVersion(connection, instance.getModelConfig().getActualVersion());
newVersion = versionDAO.getLastVersion(connection);
newVersion = newVersion+1;
logger.debug("Tne new version is "+newVersion);
}
@@ -148,33 +148,6 @@ private void setNextVersionSlicer(Integer version){
logger.debug("Slicer is set");
}

private Integer getActualVersionSlicer(){
logger.debug("IN");

// get cube
Cube cube = instance.getPivotModel().getCube();

Hierarchy hierarchy = CubeUtilities.getVersionHierarchy(cube, instance.getModelConfig());

ChangeSlicer ph = instance.getPivotModel().getTransform(ChangeSlicer.class);
List<Member> slicers = ph.getSlicer(hierarchy);

if(slicers == null || slicers.size()==0){
logger.error( "No version slicer deifined in the mdx query");
throw new SpagoBIEngineRestServiceRuntimeException("versionresource.getactualversion.no.slicer.error", instance.getLocale(), "No version in the mdx query");
}

String slicerValue = slicers.get(0).getName();

if(slicerValue == null){
logger.error( "No version slicer deifined in the mdx query");
throw new SpagoBIEngineRestServiceRuntimeException("versionresource.getactualversion.no.slicer.error", instance.getLocale(), "No version in the mdx query");
}

logger.debug("The actual version is "+slicerValue);
logger.debug("OUT");
return new Integer(slicerValue);
}



Original file line number Diff line number Diff line change
@@ -24,6 +24,8 @@ public class WriteBackEditConfig implements Serializable {

private List<String> editableMeasures;

private Integer initalVersion;

public String getEditCubeName() {
return editCubeName;
}
@@ -40,5 +42,16 @@ public void setEditableMeasures(List<String> editableMeasures) {
this.editableMeasures = editableMeasures;
}

public Integer getInitialVersion() {
if(initalVersion==null){
return 0;
}
return initalVersion;
}

public void setInitialVersion(Integer defaultVersion) {
this.initalVersion = defaultVersion;
}


}

0 comments on commit f866a12

Please sign in to comment.