コード例 #1
0
  /**
   * Get all observation targets that are not in a given batch.
   *
   * @param batchId : the id of the batch to test for
   * @return
   * @throws DatabaseException
   * @throws ParseException
   */
  public List<ObservationTarget> getObservationTargetsNotInCurrentBatch(Database db, int batchId)
      throws DatabaseException, ParseException {
    List<ObservationTarget> result = new ArrayList<ObservationTarget>();
    List<ObservationTarget> targets = db.query(ObservationTarget.class).sortASC("name").find();

    for (ObservationTarget target : targets) {
      Query<MolgenisBatchEntity> q = db.query(MolgenisBatchEntity.class);
      q.addRules(new QueryRule(MolgenisBatchEntity.BATCH, Operator.EQUALS, batchId));
      q.addRules(new QueryRule(MolgenisBatchEntity.OBJECTID, Operator.EQUALS, target.getId()));
      List<MolgenisBatchEntity> l = q.find();
      if (l.size() == 0) {
        result.add(target);
      }
    }
    return result;
  }
コード例 #2
0
  /**
   * Get all observation targets that are not in any batch.
   *
   * @return
   * @throws DatabaseException
   * @throws ParseException
   */
  public List<ObservationTarget> getObservationTargetsNotInBatch(Database db)
      throws DatabaseException, ParseException {
    List<ObservationTarget> result = new ArrayList<ObservationTarget>();
    List<ObservationTarget> targets = db.query(ObservationTarget.class).sortASC("name").find();

    for (ObservationTarget target : targets) {
      List<MolgenisBatchEntity> l =
          db.query(MolgenisBatchEntity.class)
              .equals(MolgenisBatchEntity.OBJECTID, target.getId())
              .find();
      if (l.size() == 0) {
        result.add(target);
      }
    }
    return result;
  }
コード例 #3
0
  public void addToBatch(Database db, Integer batchId, List<Integer> targetIds)
      throws DatabaseException, ParseException, IOException {
    for (Integer targetId : targetIds) {
      ObservationTarget target = db.findById(ObservationTarget.class, targetId);

      // TODO: Danny use or loose
      /*List<OntologyTerm> terms = db.query(OntologyTerm.class).equals(OntologyTerm.NAME, target.getClass().toString()).find();*/

      //        	if (terms.size() != 1)
      //        		throw new DatabaseException("No OntologyTerm found for " +
      // target.getClass().toString());

      MolgenisBatchEntity entity = new MolgenisBatchEntity();
      //    		entity.setEntityType(terms.get(0));
      entity.setBatch(batchId);
      entity.setName(target.getName());
      entity.setObjectId(target.getId());
      db.add(entity);
    }
  }