Skip to content

Commit

Permalink
Merge remote-tracking branch 'trunk'
Browse files Browse the repository at this point in the history
  • Loading branch information
fabrizyo committed Oct 16, 2015
2 parents 2723954 + 8909037 commit be8e387
Show file tree
Hide file tree
Showing 16 changed files with 395 additions and 251 deletions.
20 changes: 18 additions & 2 deletions ChefCookbooks/installation.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
#!/bin/bash
#SpagoBI VM installation script
#SpagoBI Chef installation script
set -e
set -x

sudo chef-client -o 'recipe[spagobi::1.0.2_install]'
#install chef 12 client
wget https://opscode-omnibus-packages.s3.amazonaws.com/ubuntu/10.04/x86_64/chef_12.5.1-1_amd64.deb
sudo dpkg -i chef_12.5.1-1_amd64.deb
rm -f chef_12.5.1-1_amd64.deb

#download recipes
sudo apt-get update -q
sudo apt-get -y install unzip
wget https://github.com/SpagoBILabs/SpagoBI/releases/download/fiware-v5.1-1feb2d97af/chef-cookbooks.zip
unzip chef-cookbooks.zip
rm -f chef-cookbooks.zip

#install spagobi
sudo chef-client -z -o 'recipe[spagobi::1.0.2_install]'
rm -rf cookbooks
15 changes: 15 additions & 0 deletions ChefCookbooks/spagobi/templates/default/spagobi.erb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,21 @@ stop() {
fi

<%= node['spagobi']['home_dir'] %><%= node['spagobi']['server_dir'] %>bin/shutdown.sh

echo -n "Stopping spagobi"
start=`date +%s`
end=`date +%s`
while ( ps aux | grep -q [j]ava.*SpagoBI.* ) && [ $((end-start)) -lt 300 ]; do
echo -n "."
sleep 2
end=`date +%s`
done
echo
if ps aux | grep -q [j]ava.*SpagoBI.*; then
echo "spagobi didn't stop correctly"
exit 2
fi

### Now, delete the lock file ###
rm -f $LOCK_FILE
echo "spagobi server stopped."
Expand Down
46 changes: 36 additions & 10 deletions ChefCookbooks/verification.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,40 @@
#!/bin/bash
#SpagoBI VM verification script
#SpagoBI remote verification script

set -e
ssh ubuntu@$IP <<-'ENDSSH'
set -e
# log into the VM and check the SpagoBI service
ssh ubuntu@$IP /etc/init.d/spagobi status
if [ "$?" -ne "0" ]; then
echo "Service is not running"
exit 1
fi
# check the service
if ! service spagobi status; then
exit 1
fi
#check if SpagoBI is running
curl -s -S http://$IP:8080/SpagoBI/servlet/AdapterHTTP?PAGE=LoginPage\&NEW_SESSION=TRUE > /dev/null
#checking the process with ps
echo -n "Verifying SpagoBI"
start=`date +%s`
while ( ! ps aux | grep -q [j]ava.*SpagoBI.* ) && [ $((`date +%s`-$start)) -lt 10 ]; do
echo -n "."
sleep 2
done
if ! ps aux | grep -q [j]ava.*SpagoBI.*; then
echo
echo "Process is not running"
exit 2
fi
URL=http://localhost:8080/SpagoBI/servlet/AdapterHTTP?PAGE=LoginPage\&NEW_SESSION=TRUE
#check the web application
start=`date +%s`
while ( ! curl -s -S --max-time 20 $URL &> /dev/null ) && [ $((`date +%s`-$start)) -lt 360 ]; do
echo -n "."
sleep 2
done
echo
if ! curl -s -S --max-time 5 $URL &> /dev/null; then
echo "Web application is not running"
exit 3
fi
echo "SpagoBI is correctly running"
exit 0
ENDSSH
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/* 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.chart.services;

import it.eng.spago.base.SourceBean;
import it.eng.spagobi.commons.bo.UserProfile;
import it.eng.spagobi.commons.utilities.StringUtilities;
import it.eng.spagobi.engines.chart.ChartEngineInstance;
import it.eng.spagobi.services.proxy.DataSetServiceProxy;
import it.eng.spagobi.tools.dataset.bo.AbstractDataSet;
import it.eng.spagobi.tools.dataset.bo.IDataSet;
import it.eng.spagobi.tools.dataset.common.behaviour.UserProfileUtils;
import it.eng.spagobi.tools.dataset.common.datastore.IDataStore;
Expand All @@ -29,14 +29,14 @@
import com.jamonapi.Monitor;
import com.jamonapi.MonitorFactory;


/**
* @author Antonella Giachino (antonella.giachino@eng.it)
*/
@SuppressWarnings("serial")
public class GetChartDataAction extends AbstractChartEngineAction {

public static final String SERVICE_NAME = "EXECUTE_DATASET";

// request parameters
public static String DATASET_LABEL = "ds_label";
public static String USER_ID = "userId";
Expand All @@ -45,83 +45,92 @@ public class GetChartDataAction extends AbstractChartEngineAction {
public static String START = "start";
public static String LIMIT = "limit";
public static String ROWS_LIMIT = "ds_rowsLimit";

// logger component
private static Logger logger = Logger.getLogger(GetChartDataAction.class);


@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void service(SourceBean request, SourceBean response) {

String dataSetLabel;
String user;

String callback;
String locale;
Integer start;
Integer limit;
Integer rowsLimit;
Integer rowsLimit;

IDataSet dataSet;
IDataStore dataStore;

logger.debug("IN");
Monitor monitor =MonitorFactory.start("SpagoBI_Chart.GetChartDataAction.service");
Monitor monitor = MonitorFactory.start("SpagoBI_Chart.GetChartDataAction.service");

try {
super.service(request,response);
super.service(request, response);
ChartEngineInstance chartEngineInstance = getChartEngineInstance();
dataSetLabel = getAttributeAsString( DATASET_LABEL );
logger.debug("Parameter [" + DATASET_LABEL + "] is equals to [" + dataSetLabel + "]");
Assert.assertTrue(!StringUtilities.isEmpty( dataSetLabel ), "Parameter [" + DATASET_LABEL + "] cannot be null or empty");
callback = getAttributeAsString( CALLBACK );

dataSetLabel = getAttributeAsString(DATASET_LABEL);
logger.debug("Parameter [" + DATASET_LABEL + "] is equals to [" + dataSetLabel + "]");
Assert.assertTrue(!StringUtilities.isEmpty(dataSetLabel), "Parameter [" + DATASET_LABEL + "] cannot be null or empty");

callback = getAttributeAsString(CALLBACK);
logger.debug("Parameter [" + CALLBACK + "] is equals to [" + callback + "]");
locale = getAttributeAsString( LOCALE );

locale = getAttributeAsString(LOCALE);
logger.debug("Parameter [" + LOCALE + "] is equals to [" + locale + "]");
rowsLimit = (getAttributeAsInteger( ROWS_LIMIT ) == null) ? -1 : getAttributeAsInteger( ROWS_LIMIT );

rowsLimit = (getAttributeAsInteger(ROWS_LIMIT) == null) ? -1 : getAttributeAsInteger(ROWS_LIMIT);
logger.debug("Parameter [" + ROWS_LIMIT + "] is equals to [" + rowsLimit + "]");
start = (getAttributeAsInteger( START ) == null) ? 0 : getAttributeAsInteger( START );

start = (getAttributeAsInteger(START) == null) ? 0 : getAttributeAsInteger(START);
logger.debug("Parameter [" + START + "] is equals to [" + start + "]");
limit = (getAttributeAsInteger( LIMIT ) == null) ? -1 : getAttributeAsInteger( LIMIT );

limit = (getAttributeAsInteger(LIMIT) == null) ? -1 : getAttributeAsInteger(LIMIT);
logger.debug("Parameter [" + LIMIT + "] is equals to [" + limit + "]");


dataSet = null;
try {
dataSet = chartEngineInstance.getDataSet();
} catch(Throwable t) {
} catch (Throwable t) {
throw new SpagoBIServiceException("Impossible to find a dataset whose label is [" + dataSetLabel + "]", t);
}
Assert.assertNotNull(dataSet, "Impossible to find a dataset whose label is [" + dataSetLabel + "]");
Map params = chartEngineInstance.getAnalyticalDrivers();
params.put(LOCALE, locale);
dataSet.setParamsMap(params);
dataSet.setUserProfileAttributes(UserProfileUtils.getProfileAttributes( (UserProfile) this.getEnv().get(EngineConstants.ENV_USER_PROFILE)));

UserProfile userProfile = (UserProfile) this.getEnv().get(EngineConstants.ENV_USER_PROFILE);
dataSet.setUserProfileAttributes(UserProfileUtils.getProfileAttributes(userProfile));
if (dataSet instanceof AbstractDataSet) {
AbstractDataSet ads = (AbstractDataSet) dataSet;
ads.setUserProfile(userProfile);
}

Monitor monitorLD = MonitorFactory.start("SpagoBI_Chart.GetChartDataAction.service.LoadData");

dataSet.loadData(start, limit, rowsLimit);

monitorLD.stop();
dataStore = dataSet.getDataStore();
Assert.assertNotNull(dataStore, "The dataStore returned by loadData method of the class [" + dataSet.getClass().getName()+ "] cannot be null");
Assert.assertNotNull(dataStore, "The dataStore returned by loadData method of the class [" + dataSet.getClass().getName() + "] cannot be null");

JSONObject results = new JSONObject();
try {
JSONDataWriter writer = new JSONDataWriter();

Object resultNumber = dataStore.getMetaData().getProperty("resultNumber");
if(resultNumber == null) dataStore.getMetaData().setProperty("resultNumber", new Integer((int)dataStore.getRecordsCount()));
JSONObject dataSetJSON = (JSONObject)writer.write(dataStore);
if (resultNumber == null)
dataStore.getMetaData().setProperty("resultNumber", new Integer((int) dataStore.getRecordsCount()));
JSONObject dataSetJSON = (JSONObject) writer.write(dataStore);
results = dataSetJSON;
} catch (Throwable e) {
throw new SpagoBIServiceException("Impossible to serialize datastore", e);
}

try {
writeBackToClient( new JSONSuccess( results, callback ) );
writeBackToClient(new JSONSuccess(results, callback));
} catch (IOException e) {
throw new SpagoBIServiceException("Impossible to write back the responce to the client", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import it.eng.spagobi.commons.utilities.StringUtilities;
import it.eng.spagobi.engines.console.ConsoleEngineInstance;
import it.eng.spagobi.services.proxy.DataSetServiceProxy;
import it.eng.spagobi.tools.dataset.bo.AbstractDataSet;
import it.eng.spagobi.tools.dataset.bo.IDataSet;
import it.eng.spagobi.tools.dataset.bo.RESTDataSet;
import it.eng.spagobi.tools.dataset.common.behaviour.UserProfileUtils;
Expand All @@ -33,6 +34,7 @@
/**
* @author Antonella Giachino (antonella.giachino@eng.it)
*/
@SuppressWarnings("serial")
public class GetConsoleDataAction extends AbstractConsoleEngineAction {

public static final String SERVICE_NAME = "EXECUTE_DATASET";
Expand All @@ -52,11 +54,11 @@ public class GetConsoleDataAction extends AbstractConsoleEngineAction {
// logger component
private static Logger logger = Logger.getLogger(GetConsoleDataAction.class);

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void service(SourceBean request, SourceBean response) {

String dataSetLabel;
String user;
String callback;
String locale;
Integer start;
Expand Down Expand Up @@ -110,7 +112,14 @@ public void service(SourceBean request, SourceBean response) {
Map params = consoleEngineInstance.getAnalyticalDrivers();
params.put(LOCALE, locale);
dataSet.setParamsMap(params);
dataSet.setUserProfileAttributes(UserProfileUtils.getProfileAttributes((UserProfile) this.getEnv().get(EngineConstants.ENV_USER_PROFILE)));

UserProfile userProfile = (UserProfile) this.getEnv().get(EngineConstants.ENV_USER_PROFILE);
dataSet.setUserProfileAttributes(UserProfileUtils.getProfileAttributes(userProfile));
if (dataSet instanceof AbstractDataSet) {
AbstractDataSet ads = (AbstractDataSet) dataSet;
ads.setUserProfile(userProfile);
}

// gets the max number of rows for the table
// String strRowLimit = ConsoleEngineConfig.getInstance().getProperty("CONSOLE-TABLE-ROWS-LIMIT");
// rowsLimit = (strRowLimit == null)? -1 : Integer.parseInt(strRowLimit);
Expand Down
45 changes: 23 additions & 22 deletions SpagoBIProject/.classpath
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="test"/>
<classpathentry combineaccessrules="false" kind="src" path="/SpagoBIUtils"/>
<classpathentry combineaccessrules="false" kind="src" path="/SpagoBIUtilsJSON"/>
<classpathentry kind="lib" path="/SpagoBIUtils/lib/commonj-twm.jar"/>
<classpathentry kind="lib" path="/SpagoBIUtils/lib/foo-commonj.jar"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry combineaccessrules="false" kind="src" path="/SpagoBIDAO"/>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v7.0">
<attributes>
<attribute name="owner.project.facets" value="jst.web;#system#"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes>
<attribute name="owner.project.facets" value="java"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="web-content/WEB-INF/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="test"/>
<classpathentry combineaccessrules="false" kind="src" path="/SpagoBIUtils"/>
<classpathentry combineaccessrules="false" kind="src" path="/SpagoBIUtilsJSON"/>
<classpathentry kind="lib" path="/SpagoBIUtils/lib/commonj-twm.jar"/>
<classpathentry kind="lib" path="/SpagoBIUtils/lib/foo-commonj.jar"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry combineaccessrules="false" kind="src" path="/SpagoBIDAO"/>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v7.0">
<attributes>
<attribute name="owner.project.facets" value="jst.web;#system#"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes>
<attribute name="owner.project.facets" value="java"/>
</attributes>
</classpathentry>
<classpathentry combineaccessrules="false" kind="src" path="/SpagoBIOAuth2SecurityProvider"/>
<classpathentry kind="output" path="web-content/WEB-INF/classes"/>
</classpath>
1 change: 1 addition & 0 deletions SpagoBIProject/.project
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<project>SpagoBIUtilsJSON</project>
<project>QbeCore</project>
<project>SpagoBIDAO</project>
<project>SpagoBIOAuth2SecurityProvider</project>
</projects>
<buildSpec>
<buildCommand>
Expand Down

0 comments on commit be8e387

Please sign in to comment.