Package intrade.entities

Examples of intrade.entities.MarketXML


        }
      }

      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();
View Full Code Here


        }
      }

      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);
        }
View Full Code Here

        }
      }

      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("Event");
        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(event))
View Full Code Here

        }
      }

      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("EventGroup");
        for (int i = 0; i < n.getLength(); i++) {
          Node nd = n.item(i);

          String group_id = nd.getAttributes().getNamedItem("id").getNodeValue();
View Full Code Here

      }
    }

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

    MarketXML m = null;
    Key k = KeyFactory.createKey(MarketXML.class.getSimpleName(), url);
    try {
      // Check if the file is fetched already

      resp.getWriter().println("Checking if URL is fetched: " + url);
      m = pm.getObjectById(MarketXML.class, k);
      resp.getWriter().println("It is fetched...");
      resp.getWriter().println("----------------------------------------------------");
      resp.getWriter().println("Current timestamp:" + DateFormat.getDateTimeInstance().format(m.getTimestamp()));
      resp.getWriter().println("Last retrieved:" + DateFormat.getDateTimeInstance().format(m.getLastretrieved()));
      resp.getWriter().println("----------------------------------------------------");
      Long last = m.getLastretrieved();

      // It is fetched. Refresh it.
      resp.getWriter().print("Refreshing...");
      resp.getWriter().flush();
      m.refresh();

      if (m.getLastretrieved() == last) {
        resp.getWriter().println(
            "Not enough time passed since last retrieval. Current limit is " + MarketXML.time_threshold_minutes
                + " minutes");
      } else {
        resp.getWriter().println("Got new copy");
      }
      resp.getWriter().println("----------------------------------------------------");
      resp.getWriter().println("New timestamp:" + DateFormat.getDateTimeInstance().format(m.getTimestamp()));
      resp.getWriter().println("New retrieval:" + DateFormat.getDateTimeInstance().format(m.getLastretrieved()));
      resp.getWriter().println("----------------------------------------------------");

    } catch (Exception e) {
      // URL not fetched before
      // Create object

      resp.getWriter().println("It is not fetched...fetching");
      resp.getWriter().flush();
      m = new MarketXML(url);

      System.out.println("Start fetching");

      m.fetch();

      resp.getWriter().println("New timestamp:" + DateFormat.getDateTimeInstance().format(m.getTimestamp()));
      resp.getWriter().println("Storing...");
      resp.getWriter().flush();
      pm.makePersistent(m);

    }

    pm.close();

    Document d = m.getXML();
    Queue queue = QueueFactory.getDefaultQueue();
    NodeList n = d.getElementsByTagName("EventClass");
    for (int i = 0; i < n.getLength(); i++) {

      Node nd = n.item(i);
View Full Code Here

TOP

Related Classes of intrade.entities.MarketXML

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.