public void run() {
    int i = 0;

    ((ClientSession) clientSession).beginTransaction();
    while (getKeepRunning()) {
      i++;
      if (i > getMaximumLoops()) {
        pleaseStop();
      } else {
        try {
          if (shouldCreateEmployee(i)) {
            ((ClientSession) clientSession).getSequencing().getNextValue(Employee.class);
          } else {
            ((ClientSession) clientSession).getSequencing().getNextValue(SmallProject.class);
          }
          if (fifoOut != null) {
            fifoOut.insertTail(new Integer(i));
          }

          //			    System.out.println(getName() + " " + i);
          if ((i == (getMaximumLoops() / 2)) && (fifoIn != null)) {
            //    			    System.out.println(getName() + " " +  i + " Waiting");
            while ((fifoIn.removeHead() == null) && getKeepRunning()) {
              try {
                sleep(100);
              } catch (java.lang.InterruptedException e) {
              }
            }
          }
        } catch (Exception e) {
          pleaseStop();
          setErrorOccurred(true);
          setTestException(e);
        }
      }
    }
    if (!anErrorOccurred()) {
      try {
        ((ClientSession) clientSession).commitTransaction();
      } catch (Exception e) {
        pleaseStop();
        setErrorOccurred(true);
        setTestException(e);
      }
    } else {
      ((ClientSession) clientSession).rollbackTransaction();
    }

    // Cleanup before leaving...
    //	this.server.serverSession.releaseClientSession(this.clientSession);
    this.session = null;
    this.server = null;

    if (fifoOut != null) {
      fifoOut.insertTail(new Integer(-1));
    }
  }
Esempio n. 2
0
 /**
  * Change the item
  *
  * @param old
  * @param sNewName
  * @return new album
  */
 public Album changeAlbumName(Album old, String sNewName) throws JajukException {
   // check there is actually a change
   if (old.getName2().equals(sNewName)) {
     return old;
   }
   Album newItem = registerAlbum(sNewName);
   // re apply old properties from old item
   newItem.cloneProperties(old);
   // update tracks
   for (Track track : TrackManager.getInstance().getTracks()) {
     if (track.getAlbum().equals(old)) {
       TrackManager.getInstance().changeTrackAlbum(track, sNewName, null);
     }
   }
   // if current track album name is changed, notify it
   if (FIFO.getInstance().getCurrentFile() != null
       && FIFO.getInstance().getCurrentFile().getTrack().getAlbum().equals(old)) {
     ObservationManager.notify(new Event(EventSubject.EVENT_ALBUM_CHANGED));
   }
   return newItem;
 }