Package org.objectweb.speedo.pobjects.odis

Examples of org.objectweb.speedo.pobjects.odis.Competition


    return LOG_NAME + ".rt.odis.TestTrackpoint";
  }

  private void createCompetition(){
    //create the competition
    Competition competition = new Competition(competitionId++);
    //create trackpoints
    Trackpoint trackpoint1 = new Trackpoint(trackpointId++);
    Trackpoint trackpoint2 = new Trackpoint(trackpointId++);
    Trackpoint trackpoint3 = new Trackpoint(trackpointId++);
    Trackpoint trackpoint4 = new Trackpoint(trackpointId++);
   
    competition.addTrackpoint(trackpoint1);
    competition.addTrackpoint(trackpoint2);
    competition.addTrackpoint(trackpoint3);
    competition.addTrackpoint(trackpoint4);
   
    PersistenceManager pm = pmf.getPersistenceManager();
    //store the graph defined above in the datastore
    pm.currentTransaction().begin();
    //make persistent the competition
View Full Code Here


  }
 
  public void testGetTrackpoints() {
    logger.log(BasicLevel.DEBUG, "**************testGetTrackpoints***********");
    //create the competition
    Competition competition = new Competition(1);
    //create trackpoints
    Trackpoint trackpoint1 = new Trackpoint(1);
    Trackpoint trackpoint2 = new Trackpoint(2);
    Trackpoint trackpoint3 = new Trackpoint(3);
    Trackpoint trackpoint4 = new Trackpoint(4);
   
    competition.addTrackpoint(trackpoint1);
    competition.addTrackpoint(trackpoint2);
    competition.addTrackpoint(trackpoint3);
    competition.addTrackpoint(trackpoint4);
   
    PersistenceManager pm = pmf.getPersistenceManager();
    //store the graph defined above in the datastore
    pm.currentTransaction().begin();
    //make persistent the competition
    // all the references reachable from this object will be made persistent
        pm.makePersistent(competition);
        pm.currentTransaction().commit();
       
        //get the id of competition
        Object idCompetition = pm.getObjectId(competition);
       
        Competition copyCompetition = (Competition) pm.getObjectById(idCompetition, true);
        //print the trackpoints
        Collection collection = copyCompetition.getTrackpoints();
        Iterator it = collection.iterator();
        logger.log(BasicLevel.DEBUG, "Collection length=" + collection.size());
        while(it.hasNext()){
          Trackpoint tp = (Trackpoint) it.next();
          logger.log(BasicLevel.DEBUG, "Trackpoint[id_order=" + tp.getId_order() + ",id_competition=" + tp.getId_competition() + "]");
View Full Code Here

    createCompetition();
    createCompetition();
   
    PersistenceManager pm = pmf.getPersistenceManager();
    int idCompetition = 3;
    Competition comp = null;
   
    /* create query */
    Query qCompetition = pm.newQuery(Competition.class);
    qCompetition.setFilter("(id == " + idCompetition + ")");
    /* get the answer */
    Collection col = (Collection) qCompetition.execute();
    /* pass through the answer: should be at most one */
    Iterator it = col.iterator();
    if (it.hasNext()) {
      /* get the competition */
      comp = (Competition) it.next();
      logger.log(BasicLevel.DEBUG, "competition:" + comp.getId() + ", tp=" + comp.getTrackpoints().toString() );
    } else {
      logger.log(BasicLevel.DEBUG, "Competition with id "+ idCompetition + " unfound.");
      /* close persistence context */
      qCompetition.closeAll();
      return;
    }
    qCompetition.closeAll();
   
    Iterator    itExtent  = null;
    Iterator itTp = null;
     
    Extent extent = pm.getExtent(Competition.class, false);
    itExtent = extent.iterator();
    while(itExtent.hasNext()) {
      comp =  (Competition)itExtent.next();
      logger.log(BasicLevel.DEBUG, "Competition: id=" + comp.getId() + ", tps=" + comp.getTrackpoints().toString());
      itTp = comp.getTrackpoints().iterator();
      while(itTp.hasNext()){
        Trackpoint tp = (Trackpoint) itTp.next();
        logger.log(BasicLevel.DEBUG, "Trackpoint: id_order=" + tp.getId_order() + ", id_competition=" + tp.getId_competition() );
      }
     
View Full Code Here

TOP

Related Classes of org.objectweb.speedo.pobjects.odis.Competition

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.