Package nexj.core.persistence

Examples of nexj.core.persistence.Query$OperatorFactory


      try
      {
         uowArray[1] = m_context.beginTransaction(false);
         assertTrue(list.size() > 0); // need at least one to place lock on

         Query query = Query.createRead(getMetadata().getMetaclass("Contact"),
                                        null, Pair.attribute("").eq(list.get(0)),
                                        null, -1, 0, true, Query.SEC_NONE, m_context);

         query.setTimeout(nTimeout); // ensure query will terminate eventually
         query.read();
         fail(); // LockTimeoutException expected
      }
      catch (LockTimeoutException e) // exception expected == pass
      {
      }
View Full Code Here


   }

   public void testMatch() throws Exception
   {
      Pair attributes = parse("(firstName (addresses city))");
      Query query = Query.createRead(getMetadata().getMetaclass("Contact"), attributes,
         parse("(and (match? (@ addresses city) \"Toronto\" 0.0) (= classCode \"CON\"))"),
         parse("(((@ addresses city) . #t) ((@) . #t))"), -1, 0, false, Query.SEC_NONE, m_context);
      AssertUtil.assertEquals(getURL("readCollectionWhere.xml"), query.read(), attributes);

      query = Query.createRead(getMetadata().getMetaclass("Contact"), attributes,
         parse("(and (match? (@ addresses city) '(and \"Toronto\" \"abc\") 0.0) (= classCode \"CON\"))"),
         null, -1, 0, false, Query.SEC_NONE, m_context);
      assertEquals(0, query.read().size());

      query = Query.createRead(getMetadata().getMetaclass("Contact"), attributes,
         parse("(and (match? (@ addresses city) \"Toronto'\" 0.0) (= classCode \"CON\"))"),
         parse("(((@ addresses city) . #t) ((@) . #t))"), -1, 0, false, Query.SEC_NONE, m_context);
      query.read(); // test escape of quotes

      query = Query.createRead(getMetadata().getMetaclass("Contact"), attributes,
         parse("(and (match? (@ addresses city) '(like? \"Toront\") 0.0) (= classCode \"CON\"))"),
         parse("(((@ addresses city) . #t) ((@) . #t))"), -1, 0, false, Query.SEC_NONE, m_context);
      AssertUtil.assertEquals(getURL("readCollectionWhere.xml"), query.read(), attributes);

      query = Query.createRead(getMetadata().getMetaclass("Contact"), attributes,
         parse("(and (match? (@ addresses city) '(and \"Toronto\" (not \"Hill\")) 0.0) (= classCode \"CON\"))"),
         parse("(((@ addresses city) . #t) ((@) . #t))"), -1, 0, false, Query.SEC_NONE, m_context);
      AssertUtil.assertEquals(getURL("readCollectionWhere.xml"), query.read(), attributes);

      query = Query.createRead(getMetadata().getMetaclass("Contact"), attributes,
         parse("(and (match? (@ addresses city) '(or \"Toronto\" \"abc\") 0.0) (= classCode \"CON\"))"),
         parse("(((@ addresses city) . #t) ((@) . #t))"), -1, 0, false, Query.SEC_NONE, m_context);
      AssertUtil.assertEquals(getURL("readCollectionWhere.xml"), query.read(), attributes);

      query = Query.createRead(getMetadata().getMetaclass("Contact"), attributes,
         parse("(and (match? (@ addresses city) '(* (1.0 \"Toronto\") (0.0 \"Toronto\")) 0.0) (= classCode \"CON\"))"),
         parse("(((@ addresses city) . #t) ((@) . #t))"), -1, 0, false, Query.SEC_NONE, m_context);
      AssertUtil.assertEquals(getURL("readCollectionWhere.xml"), query.read(), attributes);
   }
View Full Code Here

      try
      {
         uowArray[1] = m_context.beginTransaction(false);
         assertTrue(list.size() > 0); // need at least one to place lock on

         Query query = Query.createRead(getMetadata().getMetaclass("Contact"),
                                        null, Pair.attribute("").eq(list.get(0)),
                                        null, -1, 0, true, Query.SEC_NONE, m_context);

         query.setTimeout(1); // test applications specified query timeout
         query.read();
         fail(); // QueryTimeoutException expected
      }
      catch (QueryTimeoutException e) // exception expected == pass
      {
      }
View Full Code Here

      assertEquals(Primitive.createInteger(2), m_context.getMachine().getGlobalEnvironment().getVariable(Symbol.define("update-count")));
      assertEquals(Primitive.createInteger(2), m_context.getMachine().getGlobalEnvironment().getVariable(Symbol.define("commit-count")));

      Pair attributes = parse("(firstName lastName type (addresses type country city street code) (user name) (primaryAddress type))");
      Pair orderBy = parse("((firstName . #t)(lastName . #t)((@ addresses) . #t))");
      Query query = Query.createRead(getMetadata().getMetaclass("Contact"),
         attributes, parse("(= classCode \"CON\")"), orderBy, -1, 0, false, Query.SEC_NONE, m_context);
      list = query.read();

      AssertUtil.assertEquals(getURL("update.xml"), list, attributes);

      for (Iterator itr = list.iterator(); itr.hasNext();)
      {
         ((Instance)itr.next()).setValue("firstName", "");
      }

      commit();

      for (Iterator itr = list.iterator(); itr.hasNext();)
      {
         ((Instance)itr.next()).setValue("type", null);
      }

      commit();
      reset();

      query = Query.createRead(getMetadata().getMetaclass("Contact"),
         attributes, parse("(= classCode \"CON\")"), orderBy,
         -1, 0, false, Query.SEC_NONE, m_context);
      list = query.read();

      AssertUtil.assertEquals(getURL("updateNull.xml"), list, attributes);

      m_context.setSecure(false);

      query = Query.createRead(getMetadata().getMetaclass("SysRule"), parse("(action)"),
         null, parse("(((@) . #t))"), 1, 0, false, Query.SEC_NONE, m_context);
      list = query.read();

      char[] charArray = new char[20000];

      Arrays.fill(charArray, 'a');

      String sCLOB = new String(charArray);

      list.getInstance(0).setValue("action", sCLOB);

      commit();
      reset();

      assertEquals(sCLOB, query.read().getInstance(0).getValue("action"));
   }
View Full Code Here

      assertEquals(Primitive.ZERO_INTEGER, contact.getValue("businessAddressCount"));
   }

   public void testConcurrentResultSets()
   {
      Query query = Query.createRead(getMetadata().getMetaclass("Contact"), parse("(firstName)"),
                                     null, null, -1, 0, false, Query.SEC_NONE, m_context);
      Cursor cursor1 = query.openCursor();
      Cursor cursor2 = query.openCursor();

      assertTrue(cursor2.next(-1).size() > 0);
      assertTrue(cursor1.next(-1).size() > 0);
      cursor1.close();
      cursor2.close();
View Full Code Here

      assertEquals(Primitive.ZERO_INTEGER, m_context.getMachine().getGlobalEnvironment().getVariable(Symbol.define("update-count")));
      assertEquals(Primitive.ZERO_INTEGER, m_context.getMachine().getGlobalEnvironment().getVariable(Symbol.define("commit-count")));

      Pair attributes = parse("(firstName lastName (addresses country city street code) (user name))");
      Query query = Query.createRead(getMetadata().getMetaclass("Contact"),
         attributes, parse("(= classCode \"CON\")"),
         parse("((firstName . #t)(lastName . #t)((@ addresses) . #t))"),
         -1, 0, false, Query.SEC_NONE, m_context);
      AssertUtil.assertEquals(getURL("delete.xml"), query.read(), attributes);

      list = Query.createRead(getMetadata().getMetaclass("User"), parse("(ugassocs)"),
         parse("(= name \"jsmith\")"), null, -1, 0, false, Query.SEC_NONE, m_context).read();

      assertEquals(1, list.size());
View Full Code Here

      m_context.getUnitOfWork().setLocking(true);

      Pair attributes = parse("(fullName (addresses type city))");
      Pair where = parse("(= classCode \"CON\")");
      Pair orderBy = parse("(((@) . #t)((@ addresses) . #t))");
      Query query = Query.createRead(getMetadata().getMetaclass("Contact"),
         attributes, where, orderBy, -1, 0, false, Query.SEC_NONE, m_context);
      InstanceList list = query.read();

      assertEquals(5, list.size());

      for (int i = 0; i != list.size(); ++i)
      {
View Full Code Here

   public void testWorkflowLoop()
   {
      Metaclass workflowClass = getMetadata().getMetaclass(Metadata.WORKFLOW_CLASS_NAME);
      InstanceList workflowList;
      Instance contact, workflow;
      Query query = Query.createRead(getMetadata().getMetaclass("Contact"),
         parse("((addresses country state city))"),
         parse("(and (= lastName \"Test\") (= firstName \"Joe\"))"),
         null,
         -1, 0, false, Query.SEC_NONE, m_context);
      InstanceList resultList = query.read();

      assertEquals(1, resultList.size());
      contact = resultList.getInstance(0);

      workflowList = (InstanceList)workflowClass.invoke("forInstance",
View Full Code Here

      Metaclass contact = Repository.getMetadata().getMetaclass("XJContact");
      Pair attributes = (Pair)parse("(fullName (addresses country city) type (image mimeData mimeType))");
      Object where = parse("(and (like? firstName \"V*\") (= lastName \"Iordanov\") (= entityType 0n))");
      Pair orderBy = (Pair)parse("((firstName . #t)(lastName . #t)((@) . #t))");

      Query query = Query.createRead(contact, attributes, where, orderBy, 10, 0, false, Query.SEC_NONE, m_context);

      InstanceList list = query.read();
     
      for (int i = 0; i < list.size(); ++i)
      {
         s_logger.dump("fullName[" + i + "] = \"" + list.getInstance(i).getValue("fullName") + "\"");
      }
     
      Metaclass address = Repository.getMetadata().getMetaclass("XJAddress");
      attributes = (Pair)parse("(country city)");
      where = new Pair(Symbol.EQ, new Pair (parse("(@@ XJContact addresses)"), new Pair(new OID(new Object[]{"12345678901234567890123456789012"}))));

      query = Query.createRead(address, attributes, where, null, 10, 0, false, Query.SEC_NONE, m_context);
      query.read();
     
      Metaclass xjobj = Repository.getMetadata().getMetaclass("XJJObj");
      attributes = (Pair)parse("(mimeType mimeData)");
      where = new Pair(Symbol.EQ, new Pair (parse("(@@ XJContact image)"), new Pair(new OID(new Object[]{"78B14B58F66611CEBB8500AA0020A75A"}))));
      query = Query.createRead(xjobj, attributes, where, null, 1, 0, false, Query.SEC_NONE, m_context);
      list = query.read();
     
      if (list.size() == 1)
      {
         s_logger.debug("mime = " + list.getInstance(0).getValue("mimeType"));
        
View Full Code Here

TOP

Related Classes of nexj.core.persistence.Query$OperatorFactory

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.