Skip to content

Commit

Permalink
jasperreport query executers - local + remote..remote for jaspersorft…
Browse files Browse the repository at this point in the history
… studio integration..
  • Loading branch information
katkav committed Mar 12, 2015
1 parent 46b9eee commit 19ba11e
Show file tree
Hide file tree
Showing 18 changed files with 1,112 additions and 342 deletions.
12 changes: 12 additions & 0 deletions gui/admin-gui/pom.xml
Expand Up @@ -340,6 +340,18 @@
<version>3.2-SNAPSHOT</version>
<!-- <scope>runtime,compile</scope> -->
</dependency>
<dependency>
<groupId>com.evolveum.midpoint.model</groupId>
<artifactId>report-ds-impl</artifactId>
<version>3.2-SNAPSHOT</version>
<scope>runtime</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.evolveum.midpoint.infra</groupId>
<artifactId>common</artifactId>
Expand Down
Expand Up @@ -16,6 +16,8 @@

package com.evolveum.midpoint.prism.query;

import javax.xml.namespace.QName;

import org.w3c.dom.Element;

import com.evolveum.midpoint.prism.Objectable;
Expand All @@ -24,6 +26,7 @@
import com.evolveum.midpoint.prism.parser.QueryConvertor;
import com.evolveum.midpoint.prism.xnode.MapXNode;
import com.evolveum.midpoint.prism.xnode.XNode;
import com.evolveum.midpoint.util.DOMUtil;
import com.evolveum.midpoint.util.QNameUtil;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.prism.xml.ns._public.query_3.PagingType;
Expand All @@ -40,6 +43,40 @@
*/
public class QueryJaxbConvertor {

public static ObjectQuery createTypeObjectQuery(QueryType queryType, PrismContext prismContext) throws SchemaException{
if (queryType == null){
return null;
}

if (queryType.getFilter() == null){
return null;
}

if (queryType.getFilter().containsFilterClause()){
MapXNode mapXnode = queryType.getFilter().getFilterClauseXNode();
QName type = mapXnode.getParsedPrimitiveValue(QueryConvertor.KEY_FILTER_TYPE_TYPE, DOMUtil.XSD_QNAME);
if (type == null){
throw new SchemaException("Query does not countain type filter. Cannot by parse.");
}

Class clazz = prismContext.getSchemaRegistry().determineCompileTimeClass(type);
if (clazz == null){
PrismObjectDefinition objDef = prismContext.getSchemaRegistry().findObjectDefinitionByType(type);
if (objDef != null){
clazz = objDef.getCompileTimeClass();
}
}

if (clazz == null){
throw new SchemaException("Type defined in query is not valid. " + type);
}

return createObjectQuery(clazz, queryType, prismContext);

}
return null;
}

public static <O extends Objectable> ObjectQuery createObjectQuery(Class<O> clazz, QueryType queryType, PrismContext prismContext)
throws SchemaException {
if (queryType == null) {
Expand Down Expand Up @@ -82,18 +119,23 @@ public static <O extends Objectable> ObjectQuery createObjectQueryInternal(Class
return createObjectQueryInternal(objDef, filterType, pagingType, prismContext);
}

private static boolean isNotEmpty(SearchFilterType filterType, PagingType pagingType){
boolean filterNotEmpty = filterType != null && filterType.containsFilterClause();
if (!filterNotEmpty && pagingType == null) {
return false;
}
return true;
}

public static <O extends Objectable> ObjectQuery createObjectQueryInternal(PrismObjectDefinition<O> objDef, SearchFilterType filterType, PagingType pagingType, PrismContext prismContext)
throws SchemaException {

boolean filterNotEmpty = filterType != null && filterType.containsFilterClause();
if (!filterNotEmpty && pagingType == null) {
return null;
}


try {
ObjectQuery query = new ObjectQuery();

if (filterNotEmpty) {
if (isNotEmpty(filterType, pagingType)) {
MapXNode rootFilter = filterType.getFilterClauseXNode();
ObjectFilter filter = QueryConvertor.parseFilter(rootFilter, objDef);
query.setFilter(filter);
Expand Down Expand Up @@ -125,5 +167,7 @@ public static QueryType createQueryType(ObjectQuery query, PrismContext prismCon
return queryType;

}



}
179 changes: 179 additions & 0 deletions infra/schema/src/main/resources/xml/ns/public/report/report-3.wsdl
Expand Up @@ -38,6 +38,8 @@
schemaLocation="http://midpoint.evolveum.com/xml/ns/public/common/common-3"/>
<xsd:import namespace="http://midpoint.evolveum.com/xml/ns/public/common/api-types-3"
schemaLocation="http://midpoint.evolveum.com/xml/ns/public/common/api-types-3"/>
<xsd:import namespace="http://prism.evolveum.com/xml/ns/public/query-3"
schemaLocation="http://prism.evolveum.com/xml/ns/public/query-3"/>


<xsd:complexType name="ProcessReportType">
Expand All @@ -59,6 +61,121 @@
</xsd:sequence>
</xsd:complexType>
<xsd:element name="processReportResponse" type="tns:ProcessReportResponseType"/>

<!-- <xsd:complexType name="ParseQueryType"> -->
<!-- <xsd:sequence> -->
<!-- <xsd:element name="query" type="xsd:string"/> -->
<!-- <xsd:element name="parameters" type="c:ParamsType"/> -->
<!-- </xsd:sequence> -->
<!-- </xsd:complexType> -->
<!-- <xsd:element name="parseQuery" type="tns:ParseQueryType" /> -->

<!-- <xsd:complexType name="ParseQueryResponseType"> -->
<!-- <xsd:sequence> -->
<!-- <xsd:element name="parsedQuery" type="q:QueryType"> -->
<!-- <xsd:annotation> -->
<!-- <xsd:documentation> -->
<!-- parsedQuery -->
<!-- </xsd:documentation> -->
<!-- </xsd:annotation> -->
<!-- </xsd:element> -->
<!-- </xsd:sequence> -->
<!-- </xsd:complexType> -->
<!-- <xsd:element name="parseQueryResponse" type="tns:ParseQueryResponseType"/> -->


<xsd:complexType name="SearchObjectsType">
<xsd:annotation>
<xsd:documentation>
A request for searchObjects operation.
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>

<xsd:element name="query" type="xsd:string" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Search criteria. If not specified, all objects of a given type are returned.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="parameters" type="c:ParamsType"/>
<xsd:element name="options" type="apit:SelectorQualifiedGetOptionsType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Options influencing the retrieval and processing of objects.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="searchObjects" type="tns:SearchObjectsType"/>

<xsd:complexType name="SearchObjectsResponseType">
<xsd:annotation>
<xsd:documentation>
A response from searchObjects operation.
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="objectList" type="apit:ObjectListType">
<xsd:annotation>
<xsd:documentation>
List of objects that match given criteria.
</xsd:documentation>
</xsd:annotation>
</xsd:element>

</xsd:sequence>
</xsd:complexType>
<xsd:element name="searchObjectsResponse" type="tns:SearchObjectsResponseType"/>

<xsd:complexType name="EvaluateScriptType">
<xsd:annotation>
<xsd:documentation>
A request for searchObjects operation.
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>

<xsd:element name="script" type="xsd:string" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Script to evaluate
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="parameters" type="c:ParamsType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Parameters needed for script evaluation
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="evaluateScript" type="tns:EvaluateScriptType"/>

<xsd:complexType name="EvaluateScriptResponseType">
<xsd:annotation>
<xsd:documentation>
A response from searchObjects operation.
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="objectList" type="apit:ObjectListType">
<xsd:annotation>
<xsd:documentation>
List of objects that match given criteria.
</xsd:documentation>
</xsd:annotation>
</xsd:element>

</xsd:sequence>
</xsd:complexType>
<xsd:element name="evaluateScriptResponse" type="tns:EvaluateScriptResponseType"/>


</xsd:schema>
</types>

Expand All @@ -69,12 +186,47 @@
<part element="tns:processReportResponse" name="parameters"/>
</message>

<!-- <message name="parseQuery"> -->
<!-- <part element="tns:parseQuery" name="parameters"/> -->
<!-- </message> -->
<!-- <message name="parseQueryResponse"> -->
<!-- <part element="tns:parseQueryResponse" name="parameters"/> -->
<!-- </message> -->

<message name="searchObjects">
<part element="tns:searchObjects" name="parameters"/>
</message>
<message name="searchObjectsResponse">
<part element="tns:searchObjectsResponse" name="parameters"/>
</message>

<message name="evaluateScript">
<part element="tns:evaluateScript" name="parameters"/>
</message>
<message name="evaluateScriptResponse">
<part element="tns:evaluateScriptResponse" name="parameters"/>
</message>

<portType name="reportPortType">
<operation name="processReport">
<input message="tns:processReport"/>
<output message="tns:processReportResponse"/>
</operation>
<!-- <operation name="parseQuery"> -->
<!-- <input message="tns:parseQuery"/> -->
<!-- <output message="tns:parseQueryResponse"/> -->
<!-- </operation> -->
<operation name="searchObjects">
<input message="tns:searchObjects"/>
<output message="tns:searchObjectsResponse"/>
</operation>
<operation name="evaluateScript">
<input message="tns:evaluateScript"/>
<output message="tns:evaluateScriptResponse"/>
</operation>
</portType>


<binding name="reportBinding" type="tns:reportPortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="processReport">
Expand All @@ -86,6 +238,33 @@
<soap:body use="literal"/>
</output>
</operation>
<!-- <operation name="parseQuery"> -->
<!-- <soap:operation name="parseQuery"/> -->
<!-- <input> -->
<!-- <soap:body use="literal"/> -->
<!-- </input> -->
<!-- <output name="parseQueryResponse"> -->
<!-- <soap:body use="literal"/> -->
<!-- </output> -->
<!-- </operation> -->
<operation name="searchObjects">
<soap:operation name="searchObjects"/>
<input>
<soap:body use="literal"/>
</input>
<output name="searchObjectsResponse">
<soap:body use="literal"/>
</output>
</operation>
<operation name="evaluateScript">
<soap:operation name="evaluateScript"/>
<input>
<soap:body use="literal"/>
</input>
<output name="evaluateScriptResponse">
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="reportWebService">
<port name="reportPort"
Expand Down
@@ -0,0 +1,32 @@
package com.evolveum.midpoint.report.api;

import java.util.Collection;
import java.util.Map;

import javax.xml.namespace.QName;

import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.schema.GetOperationOptions;
import com.evolveum.midpoint.schema.SelectorOptions;
import com.evolveum.midpoint.util.exception.CommunicationException;
import com.evolveum.midpoint.util.exception.ConfigurationException;
import com.evolveum.midpoint.util.exception.ExpressionEvaluationException;
import com.evolveum.midpoint.util.exception.ObjectNotFoundException;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.exception.SecurityViolationException;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;

public interface ReportService {

public static final String PARAMETER_REPORT_SERVICE = "reportService";

public ObjectQuery parseQuery(String query, Map<QName, Object> parameters) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException;

public Collection<PrismObject<? extends ObjectType>> searchObjects(ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException;

public Collection<PrismObject<? extends ObjectType>> evaluateScript(String script, Map<QName, Object> parameters) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException;



}
26 changes: 26 additions & 0 deletions model/report-ds-impl/pom.xml
Expand Up @@ -138,4 +138,30 @@
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<executions>
<execution>
<id>bundle-manifest</id>
<phase>process-classes</phase>
<goals>
<goal>manifest</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

0 comments on commit 19ba11e

Please sign in to comment.