Examples of PersistenceManager


Examples of javax.jdo.PersistenceManager

     */
    private void delete(String assertion, Query query,
            String singleStringQuery, Object parameters,
            long expectedNrOfDeletedObjects) {
        boolean positive = expectedNrOfDeletedObjects >= 0;
        PersistenceManager pm = getPM();
        Transaction tx = pm.currentTransaction();
        tx.begin();
        try {
            try {
                long nr;
                if (parameters == null) {
View Full Code Here

Examples of javax.jdo.PersistenceManager

        BatchTestRunner.run(NonCorrelatedSubqueries.class);
    }

    /** */
    public void testPositive() throws Exception {
        PersistenceManager pm = getPM();
        runTestSubqueries01(pm);
        runTestSubqueries02(pm);
    }
View Full Code Here

Examples of javax.jdo.PersistenceManager

        BatchTestRunner.run(CorrelatedSubqueriesWithParameters.class);
    }

    /** */
    public void testPositive() throws Exception {
        PersistenceManager pm = getPM();
        runTestSubqueries01(pm);
        runTestSubqueries02(pm);
        runTestSubqueries03(pm);
    }
View Full Code Here

Examples of javax.jdo.PersistenceManager

        BatchTestRunner.run(UnmodifiedSubqueryInstance.class);
    }

    /** */
    public void testPositive() throws Exception {
        PersistenceManager pm = getPM();
        runTestUnmodifiedSubquery(pm);
        runTestDifferentPM(pm);
    }
View Full Code Here

Examples of javax.jdo.PersistenceManager

        String singleStringJDOQL =
            "SELECT FROM " + Employee.class.getName() + " WHERE this.weeklyhours > " +
            "(SELECT AVG(e.weeklyhours) FROM " + Employee.class.getName() + " e)";

        // create subquery instance using different pm
        PersistenceManager newPM =
            pm.getPersistenceManagerFactory().getPersistenceManager();
        Query sub = newPM.newQuery(Employee.class);
        sub.setResult("avg(this.weeklyhours)");

        Query apiQuery = pm.newQuery(Employee.class);
        apiQuery.setFilter("this.weeklyhours> averageWeeklyhours");
        apiQuery.addSubquery(sub, "double averageWeeklyhours", null);
View Full Code Here

Examples of javax.jdo.PersistenceManager

      // First get the expired contracts that have not been archived yet
      // Get the prices and archive them
      query = "SELECT FROM " + Contract.class.getName() + " WHERE expiryDate>0 && archived==false ORDER BY expiryDate";
      print(query);
      PersistenceManager pm = PMF.get().getPersistenceManager();
      Query q = pm.newQuery(query);
      Queue queue = QueueFactory.getDefaultQueue();
      @SuppressWarnings("unchecked")
      List<Contract> results = (List<Contract>) q.execute();
      print("Putting in queue for processing " + results.size() + " contracts.");
      for (Contract c : results) {
        String contractid = c.getId();
        // print("Adding contract "+contractid+
        // " in the queue. Will not archive.");
        queue.add(Builder.withUrl("/processContractClosingPrices").param("contract", contractid).param("archive", "y")
            .param("time_threshold_minutes", threshold.toString()).method(TaskOptions.Method.GET));
        queue.add(Builder.withUrl("/processContractTrades").param("contract", contractid)
            .param("time_threshold_minutes", "1").method(TaskOptions.Method.GET));
      }
      pm.close();

      // Now get the remaining active contracts (that have not been
      // archived yet)
      // Do no archive yet.

      long now = (new Date()).getTime();
      query = "SELECT FROM " + Contract.class.getName() + " WHERE laststoredCSV<" + (now - Contract.time_threshold())
          + " && expiryDate==0 && archived==false  ORDER BY laststoredCSV";
      print(query);
      pm = PMF.get().getPersistenceManager();
      q = pm.newQuery(query);

      @SuppressWarnings("unchecked")
      List<Contract> results_remaining = (List<Contract>) q.execute();

      print("Putting in queue for processing " + results_remaining.size() + " contracts.");
      for (Contract c : results_remaining) {
        String contractid = c.getId();
        // print("Adding contract "+contractid+
        // " in the queue. Will not archive.");
        queue.add(Builder.withUrl("/processContractClosingPrices").param("contract", contractid).param("archive", "n")
            .param("time_threshold_minutes", threshold.toString()).method(TaskOptions.Method.GET));
        queue.add(Builder.withUrl("/processContractTrades").param("contract", contractid)
            .param("time_threshold_minutes", "1").method(TaskOptions.Method.GET));
      }
      pm.close();

      print("Done!");

    } catch (com.google.apphosting.api.DeadlineExceededException e) {
      print("Reached execution time limit. Press refresh to continue.");
View Full Code Here

Examples of javax.jdo.PersistenceManager

    doGet(req, resp);
  }

  public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {

    PersistenceManager pm = null;
    try {
      this.r = resp;

      resp.setContentType("text/plain");

      String t = req.getParameter("time_threshold_minutes");
      if (t != null) {
        try {
          int i = Integer.parseInt(t);
          ProcessEventClass.time_threshold_minutes = i;
        } catch (Exception e) {
          ;
        }
      }

      String eventclass = req.getParameter("eventclass");
      if (eventclass != null) {
        resp.getWriter().println("Processing event class " + eventclass);
      } else {
        resp.getWriter().println("No class specified");
        return;
      }
      String u = req.getParameter("url");
      if (u != null) {
        try {
          URL param = new URL(u);
          url = param.toString();
        } catch (Exception e) {

        }
      }

      pm = PMF.get().getPersistenceManager();

      MarketXML m = null;
      try {
        m = pm.getObjectById(MarketXML.class, MarketXML.generateKeyFromID(url));
      } catch (Exception e) {
        m = null;
      }
      if (m != null) {
        //System.out.println(m.getURL());
        Document d = m.getXML();
        NodeList n = d.getElementsByTagName("EventClass");
        for (int i = 0; i < n.getLength(); i++) {
          Node nd = n.item(i);
          String event_id = nd.getAttributes().getNamedItem("id").getNodeValue();

          if (!event_id.equals(eventclass)) {
            continue;
          }
          storeEventClass(nd);
        }
      } else {
        // ... no results ...
      }

      pm.close();

    } catch (com.google.apphosting.api.DeadlineExceededException e) {
      print("Reached execution time limit. Press refresh to continue.");

    } finally {
      if (pm != null && !pm.isClosed()) {
        pm.close();
      }
    }

  }
View Full Code Here

Examples of javax.jdo.PersistenceManager

  }

  private long lastRetrieved_eventclass(String event_id) {

    EventClass eventclass = null;
    PersistenceManager pm = PMF.get().getPersistenceManager();
    try {
      eventclass = pm.getObjectById(EventClass.class, EventClass.generateKeyFromID(event_id));
    } catch (Exception e) {
      eventclass = null;
    }
    pm.close();
    return (eventclass == null) ? 0 : eventclass.getLastretrieved();
  }
View Full Code Here

Examples of javax.jdo.PersistenceManager

    EventClass ec = new EventClass(eventclass_id, event_name, event_displayorder);
    ec.setLastretrieved(now);
    print("Storing:" + ec.toString());

    PersistenceManager pm = PMF.get().getPersistenceManager();
    pm.makePersistent(ec);
    pm.close();

    return;

  }
View Full Code Here

Examples of javax.jdo.PersistenceManager

  private HttpServletResponse  r;

  public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {

    PersistenceManager pm = null;
    try {
      this.r = resp;

      resp.setContentType("text/plain");

      String t = req.getParameter("time_threshold_minutes");
      if (t != null) {
        try {
          int i = Integer.parseInt(t);
          StoreContracts.time_threshold_minutes = i;
        } catch (Exception e) {
          ;
        }
      }

      String eventclass = req.getParameter("eventclass");

      if (eventclass != null) {
        resp.getWriter().println("Processing class " + eventclass);
      }

      String eventgroup = req.getParameter("eventgroup");
      if (eventgroup != null) {
        resp.getWriter().println("Processing group " + eventgroup);
      }
      // Do not process the financial contracts for Dow Jones. We do not need
      // prediction markets for financial events. They are too many in any case and add needless load
      if (eventgroup.equals("4409")) { // 4409 is the Dow Jones code on Intrade
        resp.getWriter().println("We skip the Dow Jones contracts.");
        return;
      }

      String u = req.getParameter("url");
      if (u != null) {
        try {
          URL param = new URL(u);
          url = param.toString();
        } catch (Exception e) {

        }
      }

      pm = PMF.get().getPersistenceManager();

      MarketXML m = null;
      try {
        m = pm.getObjectById(MarketXML.class, MarketXML.generateKeyFromID(url));
      } catch (Exception e) {
        m = null;
      }
      if (m != null) {
        System.out.println(m.getURL());
        Document d = m.getXML();
        NodeList n = d.getElementsByTagName("EventClass");
        for (int i = 0; i < n.getLength(); i++) {
          Node nd = n.item(i);
          storeEventClasses(nd, eventclass, eventgroup);
        }
      } else {
        // ... no results ...
      }

      pm.close();

    } catch (com.google.apphosting.api.DeadlineExceededException e) {
      print("Reached execution time limit. Press refresh to continue.");

    } finally {
      if (pm != null && !pm.isClosed()) {
        pm.close();
      }
    }

  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.