Package org.exist.xquery

Examples of org.exist.xquery.XQueryContext


      final long start = System.currentTimeMillis();
        final CompiledXQuery expr = (CompiledXQuery)expression;
      final Subject preserveSubject = brokerPool.getSubject();
      DBBroker broker = null;
      Sequence result;
      final XQueryContext context = expr.getContext();
        try {
        broker = brokerPool.get(user);

        //context.setBackwardsCompatibility(xpathCompatible);
        context.setStaticallyKnownDocuments(docs);
            if (lockedDocuments != null)
                {context.setProtectedDocs(lockedDocuments);}
            setupContext(null, context);
//        checkPragmas(context);
           
        final XQuery xquery = broker.getXQueryService();
        result = xquery.execute(expr, contextSet, properties);
View Full Code Here


    } else if (!isBefore && !TriggerStatePerThread.verifyUniqueTriggerPerThreadBeforeFinish(this, src)) {
      return null;
    }
    TriggerStatePerThread.setTransaction(transaction);
   
    final XQueryContext context = service.newContext(AccessContext.TRIGGER);
        if (query instanceof DBSource) {
            context.setModuleLoadPath(XmldbURI.EMBEDDED_SERVER_URI_PREFIX + ((DBSource)query).getDocumentPath().removeLastSegment().toString());
        }

        CompiledXQuery compiledQuery;
        try {
          //compile the XQuery
          compiledQuery = service.compile(context, query);

          //declare user defined parameters as external variables
          for(final Iterator itUserVarName = userDefinedVariables.keySet().iterator(); itUserVarName.hasNext();) {
            final String varName = (String)itUserVarName.next();
            final String varValue = userDefinedVariables.getProperty(varName);
         
            context.declareVariable(bindingPrefix + varName, new StringValue(varValue));
          }
         
          //reset & prepareForExecution for execution
          compiledQuery.reset();

          context.getWatchDog().reset();

            //do any preparation before execution
            context.prepareForExecution();

          return compiledQuery;
        } catch(final XPathException e) {
            LOG.warn(e.getMessage());
        TriggerStatePerThread.setTriggerRunningState(TriggerStatePerThread.NO_TRIGGER_RUNNING, this, null);
View Full Code Here

   
    if (compiledQuery == null) {return;}
   
    ProcessMonitor pm = null;
   
    final XQueryContext context = compiledQuery.getContext();
        //execute the XQuery
        try {
         
        final UserDefinedFunction function = context.resolveFunction(functionName, urls.length);
        if (function != null) {
          final List<Expression> args = new ArrayList<Expression>(urls.length);
          for (int i = 0; i < urls.length; i++)
            args.add(new LiteralValue(context, new AnyURIValue(urls[i])));
         
          pm = broker.getBrokerPool().getProcessMonitor();
         
              context.getProfiler().traceQueryStart();
              pm.queryStarted(context.getWatchDog());
             
              final FunctionCall call = new FunctionCall(context, function);
              call.setArguments(args);
              call.analyze(new AnalyzeContextInfo());
          call.eval(NodeSet.EMPTY_SET);
        }
        } catch(final XPathException e) {
        TriggerStatePerThread.setTriggerRunningState(TriggerStatePerThread.NO_TRIGGER_RUNNING, this, null);
        TriggerStatePerThread.setTransaction(null);
          throw new TriggerException(PEPARE_EXCEIPTION_MESSAGE, e);
        } finally {
          if (pm != null) {
            context.getProfiler().traceQueryEnd(context);
            pm.queryCompleted(context.getWatchDog());
          }
        compiledQuery.reset();
        context.reset();
        }

        if (!isBefore) {
          TriggerStatePerThread.setTriggerRunningState(TriggerStatePerThread.NO_TRIGGER_RUNNING, this, null);
          TriggerStatePerThread.setTransaction(null);
View Full Code Here

    /**
     * Test of eval method, of class PermissionsFunctions.
     */
    @Test
    public void intToOctal() throws XPathException {
       final XQueryContext mckContext = EasyMock.createMock(XQueryContext.class);

       final BaseConversionFunctions baseConversionFunctions = new BaseConversionFunctions(mckContext, BaseConversionFunctions.FNS_INT_TO_OCTAL);
       Sequence args[] = {
           new IntegerValue(511)
       };
View Full Code Here

       assertEquals("0777", result.itemAt(0).toString());
    }
   
    @Test
    public void octalToInt() throws XPathException {
       final XQueryContext mckContext = EasyMock.createMock(XQueryContext.class);

       final BaseConversionFunctions baseConversionFunctions = new BaseConversionFunctions(mckContext, BaseConversionFunctions.FNS_OCTAL_TO_INT);
       Sequence args[] = {
           new StringValue("0777")
       };
View Full Code Here

TOP

Related Classes of org.exist.xquery.XQueryContext

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.