示例#1
0
  /**
   * Adds objects to the a bag for the matches against a set of identifiers.
   *
   * @param ids A collection of identifiers
   * @param bag The bag to add the objects to
   * @param type The type of this bag
   * @param extraFieldValue An extra value for disambiguation.
   * @param unmatchedIds An accumulator to store the failed matches.
   * @param acceptableIssues the list of issues that are OK to ignore.
   * @throws ClassNotFoundException if the type is not a valid class.
   * @throws InterMineException If something goes wrong building the bag.
   * @throws ObjectStoreException If there is a problem on the database level.
   */
  protected void addIdsToList(
      final Collection<? extends String> ids,
      final InterMineBag bag,
      final String type,
      final String extraFieldValue,
      final Set<String> unmatchedIds,
      final Collection<String> acceptableIssues)
      throws ClassNotFoundException, InterMineException, ObjectStoreException {
    final BagQueryResult result =
        runner.searchForBag(
            type,
            new ArrayList<String>(ids),
            extraFieldValue,
            acceptableIssues.contains(BagQueryResult.WILDCARD));
    bag.addIdsToBag(result.getMatches().keySet(), type);

    for (final String issueType : result.getIssues().keySet()) {
      if (acceptableIssues.contains(issueType)) {
        bag.addIdsToBag(result.getIssueIds(issueType), type);
      } else {
        unmatchedIds.addAll(result.getInputIdentifiersForIssue(issueType));
      }
    }
    unmatchedIds.addAll(result.getUnresolvedIdentifiers());
  }
示例#2
0
 protected InterMineBag createEmployeeList() throws Exception {
   ObjectStoreWriter osw = null;
   try {
     Profile superUser = im.getProfileManager().getSuperuserProfile();
     osw = ObjectStoreWriterFactory.getObjectStoreWriter("osw.unittest");
     Employee e1 = new Employee();
     e1.setName("Employee1");
     Employee e2 = new Employee();
     e2.setName("Employee2");
     Department d1 = new Department();
     d1.setName("department");
     Company company = new CompanyShadow();
     company.setName("company");
     Contractor contractor = new Contractor();
     contractor.setName("contractor");
     osw.store(contractor);
     company.addContractors(contractor);
     osw.store(company);
     d1.setCompany(company);
     osw.store(d1);
     e1.setDepartment(d1);
     e2.setDepartment(d1);
     osw.store(e1);
     osw.store(e2);
     InterMineBag list = superUser.createBag("employeeList", "Employee", "", im.getClassKeys());
     Collection<Integer> ids = new ArrayList<Integer>();
     ids.add(e1.getId());
     ids.add(e2.getId());
     list.addIdsToBag(ids, "Employee");
     return list;
   } finally {
     osw.close();
   }
 }
 private ActionForward createBagAndGoToBagDetails(
     ActionMapping mapping, InterMineBag imBag, List<Integer> bagList)
     throws ObjectStoreException {
   imBag.addIdsToBag(bagList, imBag.getType());
   return new ForwardParameters(mapping.findForward("bagDetails"))
       .addParameter("bagName", imBag.getName())
       .forward();
 }
示例#4
0
 protected InterMineBag createCompanyList() throws Exception {
   ObjectStoreWriter osw = null;
   try {
     osw = ObjectStoreWriterFactory.getObjectStoreWriter("osw.unittest");
     Profile superUser = im.getProfileManager().getSuperuserProfile();
     Company c1 = new CompanyShadow();
     c1.setName("CompanyA");
     Company c2 = new CompanyShadow();
     c2.setName("CompanyB");
     osw.store(c1);
     osw.store(c2);
     InterMineBag list = superUser.createBag("companyList", "Company", "", im.getClassKeys());
     Collection<Integer> ids = new ArrayList<Integer>();
     ids.add(c1.getId());
     ids.add(c2.getId());
     list.addIdsToBag(ids, "Company");
     return list;
   } finally {
     osw.close();
   }
 }