Search in sources :

Example 1 with Query

use of org.cristalise.kernel.querying.Query in project kernel by cristal-ise.

the class DefaultResourceImportHandler method getCollections.

private CollectionArrayList getCollections(String name, Integer version, String xml) throws Exception {
    if (type == SCHEMA_RESOURCE) {
        return new Schema(name, version, null, xml).makeDescCollections();
    } else if (type == SCRIPT_RESOURCE) {
        return new Script(name, version, null, xml).makeDescCollections();
    } else if (type == QUERY_RESOURCE) {
        return new Query(name, version, null, xml).makeDescCollections();
    } else {
        DescriptionObject descObject = (DescriptionObject) Gateway.getMarshaller().unmarshall(xml);
        descObject.setVersion(version);
        return descObject.makeDescCollections();
    }
}
Also used : Script(org.cristalise.kernel.scripting.Script) Query(org.cristalise.kernel.querying.Query) Schema(org.cristalise.kernel.persistency.outcome.Schema) DescriptionObject(org.cristalise.kernel.utils.DescriptionObject)

Example 2 with Query

use of org.cristalise.kernel.querying.Query in project kernel by cristal-ise.

the class CastorXMLTest method testQueryParsing.

@Test
public void testQueryParsing() throws Exception {
    Query q = new Query(FileStringUtility.url2String(CastorXMLTest.class.getResource("/testQuery.xml")));
    assertEquals("TestQuery", q.getName());
    assertEquals(0, (int) q.getVersion());
    assertEquals("existdb:xquery", q.getLanguage());
    assertEquals(1, q.getParameters().size());
    assertEquals("uuid", q.getParameters().get(0).getName());
    assertEquals("java.lang.String", q.getParameters().get(0).getType().getName());
    assertTrue(q.getQuery().startsWith("\n<TRList>"));
    assertTrue(q.getQuery().endsWith("</TRList>\n    "));
}
Also used : Query(org.cristalise.kernel.querying.Query) MainTest(org.cristalise.kernel.test.process.MainTest) Test(org.junit.Test)

Example 3 with Query

use of org.cristalise.kernel.querying.Query in project kernel by cristal-ise.

the class Job method getQuery.

public Query getQuery() throws ObjectNotFoundException, InvalidDataException {
    if (hasQuery()) {
        Query query = getTransition().getQuery(actProps);
        query.setParemeterValues(itemPath.getUUID().toString(), getSchemaName(), actProps);
        return query;
    }
    return null;
}
Also used : Query(org.cristalise.kernel.querying.Query)

Example 4 with Query

use of org.cristalise.kernel.querying.Query in project kernel by cristal-ise.

the class CastorXMLUtility method marshall.

/**
 * Marshalls a mapped object to xml string. The mapping must be loaded before. See updateMapping().
 *
 * @param obj the object to be marshalled
 * @return the xml string of the marshalled object
 */
public String marshall(Object obj) throws IOException, MappingException, MarshalException, ValidationException {
    if (obj == null)
        return "<NULL/>";
    if (obj instanceof Outcome)
        return ((Outcome) obj).getData();
    StringWriter sWriter = new StringWriter();
    Marshaller marshaller = mappingContext.createMarshaller();
    marshaller.setWriter(sWriter);
    marshaller.setMarshalAsDocument(false);
    if (obj instanceof Query)
        marshaller.addProcessingInstruction(Result.PI_DISABLE_OUTPUT_ESCAPING, "");
    marshaller.marshal(obj);
    return sWriter.toString();
}
Also used : Marshaller(org.exolab.castor.xml.Marshaller) StringWriter(java.io.StringWriter) Query(org.cristalise.kernel.querying.Query) Outcome(org.cristalise.kernel.persistency.outcome.Outcome)

Aggregations

Query (org.cristalise.kernel.querying.Query)4 StringWriter (java.io.StringWriter)1 Outcome (org.cristalise.kernel.persistency.outcome.Outcome)1 Schema (org.cristalise.kernel.persistency.outcome.Schema)1 Script (org.cristalise.kernel.scripting.Script)1 MainTest (org.cristalise.kernel.test.process.MainTest)1 DescriptionObject (org.cristalise.kernel.utils.DescriptionObject)1 Marshaller (org.exolab.castor.xml.Marshaller)1 Test (org.junit.Test)1