Yaniv Dary has uploaded a new change for review.

Change subject: reports: added jar to allow query manipulation (#892306)
......................................................................

reports: added jar to allow query manipulation (#892306)

This class now allows developer to add locale in queries.

Bug-Url: https://bugzilla.redhat.com/892306

Change-Id: I6163ae46110ae8f64b40b1788945ff8345dce23d
Signed-off-by: Yaniv Dary <yd...@redhat.com>
---
A reports/jars/CustomOvirtReportsQueryManipulator/pom.xml
A 
reports/jars/CustomOvirtReportsQueryManipulator/src/main/java/org/ovirt/jasperreports/querymodifier/CustomOvirtReportsQueryManipulator.java
M reports/jars/ReportsPieChartTheme/pom.xml
M reports/jars/pom.xml
M server-customizations/WEB-INF/applicationContext.xml
5 files changed, 151 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-reports refs/changes/16/11116/1

diff --git a/reports/jars/CustomOvirtReportsQueryManipulator/pom.xml 
b/reports/jars/CustomOvirtReportsQueryManipulator/pom.xml
new file mode 100644
index 0000000..a5ca2b3
--- /dev/null
+++ b/reports/jars/CustomOvirtReportsQueryManipulator/pom.xml
@@ -0,0 +1,110 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>ovirt_engine_reports</groupId>
+    <artifactId>jars</artifactId>
+    <version>3.2.0</version>
+  </parent>
+
+  <groupId>ovirt_engine_reports</groupId>
+  <artifactId>CustomOvirtReportsQueryManipulator</artifactId>
+  <packaging>jar</packaging>
+  <version>3.2.0</version>
+  <name>CustomOvirtReportsQueryManipulator jar to support adding parameters to 
input controls</name>
+  <description>CustomOvirtReportsQueryManipulator jar to support adding 
parameters to input controls</description>
+
+  <properties>
+    <jasper.version>4.5.0</jasper.version>
+  </properties>
+  <dependencies>
+    <dependency>
+      <groupId>com.jaspersoft.jasperserver.api.engine</groupId>
+      <artifactId>jasperserver-api-engine</artifactId>
+      <version>${jasper.version}</version>
+      <scope>provided</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>mondrian</groupId>
+                    <artifactId>mondrian</artifactId>
+                </exclusion>
+            </exclusions>
+    </dependency>
+    <dependency>
+      <groupId>com.jaspersoft.jasperserver</groupId>
+      <artifactId>jasperserver-war-jar</artifactId>
+      <version>${jasper.version}</version>
+      <scope>provided</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>mondrian</groupId>
+                    <artifactId>mondrian</artifactId>
+                </exclusion>
+            </exclusions>
+    </dependency>
+  </dependencies>
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <artifactId>maven-compiler-plugin</artifactId>
+          <configuration>
+            <source>1.6</source>
+            <target>1.6</target>
+              <includes>
+                <include>**/*.java</include>
+              </includes>
+          </configuration>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+  <repositories>
+    <repository>
+      <id>central</id>
+      <name>maven repo1</name>
+      <layout>default</layout>
+      <url>http://repo1.maven.org/maven2</url>
+      <snapshots>
+        <enabled>false</enabled>
+      </snapshots>
+    </repository>
+    <repository>
+      <id>maven.search.repo</id>
+      <name>maven search repo</name>
+      <layout>default</layout>
+      <url>http://mvnsearch.org/maven2</url>
+      <snapshots>
+        <enabled>false</enabled>
+      </snapshots>
+    </repository>
+    <repository>
+      <id>jaspersoft</id>
+      <url>http://jasperreports.sourceforge.net/maven2</url>
+    </repository>
+    <repository>
+      <id>google.repo</id>
+      <name>google search repo</name>
+      <layout>default</layout>
+      
<url>https://services.boksa.de/maven/repositories/jasperreports-server-cp-4.5.0</url>
+      <snapshots>
+        <enabled>false</enabled>
+      </snapshots>
+    </repository>
+    </repositories>
+  <pluginRepositories>
+    <pluginRepository>
+      <id>central</id>
+      <name>Maven Plugin Repository</name>
+      <url>http://repo1.maven.org/maven2</url>
+      <layout>default</layout>
+      <snapshots>
+        <enabled>false</enabled>
+      </snapshots>
+      <releases>
+        <enabled>true</enabled>
+      </releases>
+    </pluginRepository>
+  </pluginRepositories>
+
+</project>
diff --git 
a/reports/jars/CustomOvirtReportsQueryManipulator/src/main/java/org/ovirt/jasperreports/querymodifier/CustomOvirtReportsQueryManipulator.java
 
b/reports/jars/CustomOvirtReportsQueryManipulator/src/main/java/org/ovirt/jasperreports/querymodifier/CustomOvirtReportsQueryManipulator.java
new file mode 100644
index 0000000..29a7ee5
--- /dev/null
+++ 
b/reports/jars/CustomOvirtReportsQueryManipulator/src/main/java/org/ovirt/jasperreports/querymodifier/CustomOvirtReportsQueryManipulator.java
@@ -0,0 +1,30 @@
+package org.ovirt.jasperreports.querymodifier;
+import java.util.Locale;
+import java.util.Map;
+
+import com.jaspersoft.jasperserver.api.engine.common.service.IQueryManipulator;
+import com.jaspersoft.jasperserver.war.common.JasperServerUtil;
+
+public class CustomOvirtReportsQueryManipulator implements IQueryManipulator {
+    public final static String USERLOCALE = "$P{userlocale}";
+
+    public IQueryManipulator cascading;
+
+    @SuppressWarnings("rawtypes")
+    @Override
+    public String updateQuery(String query, Map parameters) {
+        String cascadingQuery = cascading.updateQuery(query, parameters);
+        Locale locale = JasperServerUtil.getExecutionContext().getLocale();
+        String userLocale = locale.toString();
+        cascadingQuery = cascadingQuery.replace(USERLOCALE, "'" + userLocale + 
"'");
+        return cascadingQuery;
+    }
+
+    public IQueryManipulator getCascading() {
+        return cascading;
+    }
+
+    public void setCascading(IQueryManipulator cascading) {
+        this.cascading = cascading;
+    }
+}
diff --git a/reports/jars/ReportsPieChartTheme/pom.xml 
b/reports/jars/ReportsPieChartTheme/pom.xml
index e5b1b8f..8ef85d6 100644
--- a/reports/jars/ReportsPieChartTheme/pom.xml
+++ b/reports/jars/ReportsPieChartTheme/pom.xml
@@ -27,4 +27,4 @@
             </plugins>
        </pluginManagement>
   </build>
-</project> 
+</project>
diff --git a/reports/jars/pom.xml b/reports/jars/pom.xml
index e2910a4..ef08ee8 100644
--- a/reports/jars/pom.xml
+++ b/reports/jars/pom.xml
@@ -19,6 +19,7 @@
     <module>ReportsPieChartTheme</module>
     <module>ReportsLineBarChartTheme</module>
     <module>WebadminLineBarChartTheme</module>
+    <module>CustomOvirtReportsQueryManipulator</module>
   </modules>
 
 </project>
diff --git a/server-customizations/WEB-INF/applicationContext.xml 
b/server-customizations/WEB-INF/applicationContext.xml
index 86aef19..81e9016 100644
--- a/server-customizations/WEB-INF/applicationContext.xml
+++ b/server-customizations/WEB-INF/applicationContext.xml
@@ -552,9 +552,10 @@
         <property name="compiledReportsCache">
             <ref bean="${bean.engineService.compiledReportsCache}"/>
         </property>
-        <property name="queryManipulator">
+        <property name="queryManipulator" 
ref="CustomOvirtReportsQueryManipulator"/>
+        <!--property name="queryManipulator">
             <ref bean="CascadeQueryManipulator"/>
-        </property>
+        </property-->
         <property name="securityContextProvider" 
ref="${bean.securityContextProvider}"/>
         <property name="builtInParameterProviders" 
ref="builtInParameterProviders"/>
         <property name="reportParameterLabelKeyPrefix" 
value="net.sf.jasperreports.prompt.label."/>
@@ -568,6 +569,12 @@
         <property name="reportExecutionListenerFactories" 
ref="${bean.reportExecutionListenerFactories}"/>
     </bean>
 
+    <bean 
class="org.ovirt.jasperreports.querymodifier.CustomOvirtReportsQueryManipulator"
 id="CustomOvirtReportsQueryManipulator">
+    <property name ="cascading">
+        <ref bean="CascadeQueryManipulator"/>
+    </property>
+    </bean>
+
        <util:list id="reportExecutionListenerFactories">
                <ref local="localeContextReportExecutionListenerFactory"/>
                <ref local="securityContextReportExecutionListenerFactory"/>


--
To view, visit http://gerrit.ovirt.org/11116
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6163ae46110ae8f64b40b1788945ff8345dce23d
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-reports
Gerrit-Branch: master
Gerrit-Owner: Yaniv Dary <yd...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to