Package uk.ac.bbsrc.tgac.miso.core.data

Examples of uk.ac.bbsrc.tgac.miso.core.data.Pool


  public void push(Pool pool) {
    if (enabled) {
      if (pool != null) {
        log.debug("Attempting to clone pool " + pool.getId());
        try {
          Pool clone = cloner.deepClone(pool);
          if (clone != null) {
            applyListeners(clone);
            if (pools.containsKey(pool.getId())) {
              log.debug("Not replacing Pool " + clone.getId() + ": Ready? " + clone.getReadyToRun());
            }
            else {
              pools.put(pool.getId(), clone);
              log.debug("Queued Pool " + clone.getId() + ": Ready? " + clone.getReadyToRun());
            }
          }
        }
        catch (Exception e) {
          e.printStackTrace();
View Full Code Here


  }

  public void pop(Pool pool) {
    if (enabled) {
      if (pool!= null) {
        Pool clone = pools.get(pool.getId());
        if (clone != null) {
          removeListeners(clone);
          clone = null;
          pools.remove(pool.getId());
          log.debug("Dequeued " + pool.getId());
View Full Code Here

    update(misoRequestManager.getPoolById(poolId));
  }

  private void update(Pool p) throws IOException {
    if (enabled) {
      Pool clone = pools.get(p.getId());
      if (clone == null) {
        log.debug("Update: no clone - pushing");
        //new run - add all PoolWatchers!
        for (User u : securityManager.listUsersByGroupName("PoolWatchers")) {
          p.addWatcher(u);
        }
        push(p);
      }
      else {
        log.debug("Update: got clone of " + clone.getId());
        //TODO EVIL EVIL EVIL FIX UPON PAIN OF DEATH
        if (clone.getReadyToRun()) {
          try {
            //fire event if pool has been saved initially to ready to run
            Method m = AbstractPool.class.getDeclaredMethod("firePoolReadyEvent");
            m.setAccessible(true);
            m.invoke(clone);
          }
          catch (Exception e) {
            log.error("Cannot fire pool ready event: " + e.getMessage());
            e.printStackTrace();
          }
        }
        else {
          log.debug("Updating Pool " + clone.getId() + " ...");

          //find any watchable setters on the clone and call the respective getter from the clone parent
          //i.e. clone.setFoo(parent.getFoo()); where @WatchableSetter Class.setFoo(T t);
          /*
          for (Method setter : clone.getClass().getMethods()) {
            if (setter.getAnnotation(WatchableSetter.class)) {
              try {
                Method getter = clone.getClass().getMethod(setter.getName().replaceFirst("set", "get"));
                setter.invoke(clone, getter.invoke(p));
              }
              catch (NoSuchMethodException e) {
                e.printStackTrace();
              }
              catch (InvocationTargetException e) {
                e.printStackTrace();
              }
              catch (IllegalAccessException e) {
                e.printStackTrace();
              }
            }
          }
          */
          //TODO the above will get rid of this necessity to call each method explicitly
          clone.setReadyToRun(p.getReadyToRun());
        }

        pop(clone);
        push(p);
      }
View Full Code Here

  }

  public void addWatcher(Pool pool, Long userId) throws IOException {
    User user = securityManager.getUserById(userId);
    if (user != null) {
      Pool clone = pools.get(pool.getId());
      if (clone == null) {
        pool.addWatcher(user);
        push(pool);
      }
      else {
        clone.addWatcher(user);
      }
    }
  }
View Full Code Here

  }

  public void removeWatcher(Pool pool, Long userId) throws IOException {
    User user = securityManager.getUserById(userId);
    if (user != null && pool.getWatchers().contains(user)) {
      Pool clone = pools.get(pool.getId());
      if (clone == null) {
        pool.removeWatcher(user);
        push(pool);
      }
      else {
        clone.removeWatcher(user);
      }
    }
  }
View Full Code Here

  @Override
  public boolean respondsTo(Event event) {
    if (event instanceof PoolEvent) {
      PoolEvent pe = (PoolEvent)event;
      Pool p = pe.getEventObject();
      if (pe.getEventType().equals(MisoEventType.POOL_READY) && p.getReadyToRun()) {
        return true;
      }
    }
    return false;
  }
View Full Code Here

  @Override
  public void generateResponse(Event event) {
    if (event instanceof PoolEvent) {
      PoolEvent pe = (PoolEvent)event;
      Pool p = pe.getEventObject();

      for (User user : p.getWatchers()) {
        log.info("Responding to " + user.getLoginName());

        Alert a = new DefaultAlert(user);
        //TODO change to p.getAlias() when added
        a.setAlertTitle("Pool " + p.getName() + "(" + p.getId() + ")");
        a.setAlertText("The following Pool is ready to run: "+p.getName()+" ("+event.getEventMessage()+"). Please view Pool " +p.getId() + " in MISO for more information");

        for (AlerterService as : alerterServices) {
          try {
            as.raiseAlert(a);
          }
View Full Code Here

      NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
      namedTemplate.update(POOL_QC_UPDATE, params);
    }

    if (this.cascadeType != null) {
      Pool l = poolQC.getPool();
      if (this.cascadeType.equals(CascadeType.PERSIST)) {
        if (l != null) poolDAO.save(l);
      }
      else if (this.cascadeType.equals(CascadeType.REMOVE)) {
        if (l != null) {
View Full Code Here

  public boolean remove(PoolQC qc) throws IOException {
    NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
    if (qc.isDeletable() &&
           (namedTemplate.update(POOL_QC_DELETE,
                                 new MapSqlParameterSource().addValue("qcId", qc.getId())) == 1)) {
      Pool l = qc.getPool();
      if (this.cascadeType.equals(CascadeType.PERSIST)) {
        if (l != null) poolDAO.save(l);
      }
      else if (this.cascadeType.equals(CascadeType.REMOVE)) {
        if (l != null) {
View Full Code Here

TOP

Related Classes of uk.ac.bbsrc.tgac.miso.core.data.Pool

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.