Package com.sun.star.wizards.db

Examples of com.sun.star.wizards.db.QueryMetaData$QueryType


        // check the attributes
        assertEquals("application/xml", gr.getOutputFormat());
        assertEquals("urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0", gr.getOutputSchema());

        // the query
        QueryType query = (QueryType) gr.getQuery();
        List<QName> expected = new ArrayList<QName>();
        String rimNamespace = "urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0";
        expected.add(new QName(rimNamespace, "Service"));
        expected.add(new QName(rimNamespace, "Classification"));
        expected.add(new QName(rimNamespace, "Association"));
        assertEquals(expected, query.getTypeNames());

        // the element set name
        ElementSetNameType esn = query.getElementSetName();
        expected.clear();
        expected.add(new QName(rimNamespace, "Service"));
        assertEquals(expected, esn.getTypeNames());
        assertEquals(ElementSetType.BRIEF, esn.getValue());
       
        // the sort by properties
        SortBy[] sorts = query.getSortBy();
        assertEquals(2, sorts.length);
        assertEquals("rim:foo", sorts[0].getPropertyName().getPropertyName());
        assertEquals(SortOrder.ASCENDING, sorts[0].getSortOrder());
        assertEquals("rim:bar", sorts[1].getPropertyName().getPropertyName());
        assertEquals(SortOrder.DESCENDING, sorts[1].getSortOrder());
View Full Code Here


        assertEquals(new Integer(1), gr.getStartPosition());
        assertEquals(new Integer(5), gr.getMaxRecords());
        assertEquals(ResultType.RESULTS, gr.getResultType());

        // the query
        QueryType query = (QueryType) gr.getQuery();
        List<QName> expected = new ArrayList<QName>();
        expected.add(new QName("http://www.opengis.net/cat/csw/2.0.2", "Record"));
        assertEquals(expected, query.getTypeNames());

        // the element names
        List<QName> names = query.getElementName();
        assertEquals(2, names.size());
        assertEquals(new QName("http://purl.org/dc/terms/", "abstract"), names.get(0));
        assertEquals(new QName("http://purl.org/dc/elements/1.1/", "title"), names.get(1));

        // The filter
        QueryConstraintType constraint = query.getConstraint();
        assertEquals("1.1.0", constraint.getVersion());
        Filter filter = CQL.toFilter("AnyText like '%polution%'");
        assertEquals(filter, constraint.getFilter());
    }
View Full Code Here

                kvp.put("distributedSearch", dst);
            }
        }

        // parse the query
        QueryType query = readQuery(kvp, request);
        kvp.put("query", query);

        return super.read(request, kvp, rawKvp);
    }
View Full Code Here

        return super.read(request, kvp, rawKvp);
    }

    private QueryType readQuery(Map kvp, Object request) throws Exception {
        Csw20Factory factory = Csw20Factory.eINSTANCE;
        QueryType query = factory.createQueryType();

        // parse the type names
        String typeNamesString = (String) kvp.get("typeNames");
        if(typeNamesString == null) {
            throw new ServiceException("Mandatory parameter typeNames is missing", ServiceException.MISSING_PARAMETER_VALUE, "typeNames");
        }
        NamespaceSupport namespaces = (NamespaceSupport) kvp.get("namespace");
        if (namespaces == null) {
            // by spec, "NAMSPACE, If not included, all qualified names are in default namespace"
            String outputSchema = (String) kvp.get("outputSchema");
            if (outputSchema == null || descriptors.get(outputSchema) == null) {
                outputSchema = CSW.NAMESPACE;
            }
            namespaces = descriptors.get( outputSchema).getNamespaceSupport();
        }
        List<QName> typeNames = resolver.parseQNames(typeNamesString, namespaces);
        query.setTypeNames(typeNames);
       
        // handle the element set
        ElementSetType elementSet = (ElementSetType) kvp.remove("ELEMENTSETNAME");
        if (elementSet != null) {
            ElementSetNameType esn = Csw20Factory.eINSTANCE.createElementSetNameType();
            esn.setValue(elementSet);
            esn.setTypeNames(typeNames);
            query.setElementSetName(esn);
        }
       
        // and the element names
        String elementNamesString = (String) kvp.remove("ELEMENTNAME");
        if(elementNamesString != null) {
            List<QName> elementNames = resolver.parseQNames(elementNamesString, namespaces);
            query.getElementName().addAll(elementNames);
        }

        // the filter
        if (kvp.get(CONSTRAINT) != null) {
            query.setConstraint(factory.createQueryConstraintType());
            Object language = kvp.get(CONSTRAINTLANGUAGE);
            String constraint = (String) kvp.get(CONSTRAINT);
            if (CQL_TEXT.equals(language) || language == null) {
                Filter filter = null;
                try {
                    filter = CQL.toFilter(constraint);
                } catch (Exception e) {
                    ServiceException se = new ServiceException("Invalid CQL expression: " + constraint,
                            ServiceException.INVALID_PARAMETER_VALUE, CONSTRAINT);
                    se.initCause(e);
                    throw se;
                }
                query.getConstraint().setCqlText(constraint);
                query.getConstraint().setFilter(filter);
            } else if (FILTER.equals(language)) {
                try {
                    Parser parser = new Parser(new OGCConfiguration());
                    parser.setFailOnValidationError(true);
                    parser.setValidating(true);
                    parser.getNamespaces().declarePrefix("ogc", OGC.NAMESPACE);
                    Filter filter = (Filter) parser.parse(new StringReader(constraint));
                    query.getConstraint().setFilter(filter);
                    query.getConstraint().setVersion("1.1.0");
                } catch(Exception e) {
                    ServiceException se = new ServiceException("Invalid FILTER 1.1 expression: " + constraint,
                            ServiceException.INVALID_PARAMETER_VALUE, CONSTRAINT);
                    se.initCause(e);
                    throw se;
                }
            } else {
                throw new ServiceException("Invalid constraint language: " + language
                        + ", valid values are " + CQL_TEXT + " and " + FILTER,
                        ServiceException.INVALID_PARAMETER_VALUE, CONSTRAINTLANGUAGE);
            }
        }
       
        // check if we have to sort the request
        if(kvp.get("SORTBY") != null) {
            query.setSortBy((SortBy[]) kvp.get("SORTBY"));
        }

        return query;
    }
View Full Code Here

        assertNotNull(gr.getDistributedSearch());
        assertEquals(new Integer(10), gr.getDistributedSearch().getHopCount());
        assertEquals("http://www.geoserver.org", gr.getResponseHandler());

        // now onto the query
        QueryType query = (QueryType) gr.getQuery();
        assertEquals("AnyText like '%pollution%'", query.getConstraint().getCqlText());
        assertEquals(2, query.getTypeNames().size());
        assertEquals(new QName("http://www.opengis.net/cat/csw/2.0.2", "Record"), query
                .getTypeNames().get(0));
        assertEquals(new QName("urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0", "RegistryPackage"),
                query.getTypeNames().get(1));
        assertEquals(2, query.getElementName().size());
        assertEquals(2, query.getElementName().size());
    }
View Full Code Here

        // basic checks
        assertEquals("CSW", gr.getService());
        assertEquals("2.0.2", gr.getVersion());

        // now onto the query
        QueryType query = (QueryType) gr.getQuery();
       
        // checking the filter is structured as expected, with the proper namespace support
        Filter filter = query.getConstraint().getFilter();
        assertTrue(filter instanceof Not);
        Filter negated = ((Not) filter).getFilter();
        assertTrue(negated instanceof PropertyIsEqualTo);
        PropertyName pname = (PropertyName) ((PropertyIsEqualTo) negated).getExpression1();
        assertEquals("dc:title", pname.getPropertyName());
       
        assertEquals("1.1.0", query.getConstraint().getVersion());
        assertEquals(1, query.getTypeNames().size());
        assertEquals(new QName("http://www.opengis.net/cat/csw/2.0.2", "Record"), query
                .getTypeNames().get(0));
        assertEquals(ElementSetType.BRIEF, query.getElementSetName().getValue());
    }
View Full Code Here

        // check the attributes
        assertEquals("application/xml", gr.getOutputFormat());
        assertEquals("urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0", gr.getOutputSchema());

        // the query
        QueryType query = (QueryType) gr.getQuery();
        List<QName> expected = new ArrayList<QName>();
        String rimNamespace = "urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0";
        expected.add(new QName(rimNamespace, "Service"));
        expected.add(new QName(rimNamespace, "Classification"));
        expected.add(new QName(rimNamespace, "Association"));
        assertEquals(expected, query.getTypeNames());

        // the element set name
        ElementSetNameType esn = query.getElementSetName();
        expected.clear();
        expected.add(new QName(rimNamespace, "Service"));
        assertEquals(expected, esn.getTypeNames());
        assertEquals(ElementSetType.BRIEF, esn.getValue());
    }
View Full Code Here

        Date timestamp = new Date();

        try {
            // build the queries           
          RecordDescriptor outputRd = getRecordDescriptor(request);
            QueryType cswQuery = (QueryType) request.getQuery();
            List<Query> queries = toGtQueries(outputRd, cswQuery, request);
            // see how many records we have to return
            int maxRecords;
            if(request.getMaxRecords() == null) {
                maxRecords = 10;
View Full Code Here

    @Override
    protected void setProperty(EObject eObject, String property, Object value, boolean lax) {
        super.setProperty(eObject, property, value, lax);
        if (!lax) {
            if ("typeNames".equalsIgnoreCase(property)) {
                QueryType q = (QueryType)eObject;
               
                //turn into list of qname
                List qNames = new ArrayList();
                for (Object s : q.getTypeNames()) {
                    try {
                        qNames.add(new XSQNameBinding(namespaceContext).parse(null, s));
                    }
                    catch (Exception e) {
                        throw new RuntimeException(e);
                    }
                }
                q.getTypeNames().clear();
                q.getTypeNames().addAll(qNames);
            }
        }
    }
View Full Code Here

       
        LockFeatureType lf = (LockFeatureType) parse();
        assertNotNull(lf);
       
        assertEquals(1, lf.getAbstractQueryExpression().size());
        QueryType q = (QueryType) lf.getAbstractQueryExpression().get(0);
       
        assertTrue(q.getTypeNames().contains(new QName("http://www.someserver.com/myns", "InWaterA_1M")));
        Id f = (Id) q.getFilter();
        assertEquals(5, f.getIDs().size());
    }
View Full Code Here

TOP

Related Classes of com.sun.star.wizards.db.QueryMetaData$QueryType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.