コード例 #1
0
 public List<PointOfContactBean> findPointOfContactsBySampleId(String sampleId)
     throws PointOfContactException {
   try {
     CaNanoLabApplicationService appService =
         (CaNanoLabApplicationService) ApplicationServiceProvider.getApplicationService();
     DetachedCriteria crit =
         DetachedCriteria.forClass(Sample.class)
             .add(Property.forName("id").eq(new Long(sampleId)));
     crit.setFetchMode("primaryPointOfContact", FetchMode.JOIN);
     crit.setFetchMode("primaryPointOfContact.organization", FetchMode.JOIN);
     crit.setFetchMode("otherPointOfContactCollection", FetchMode.JOIN);
     crit.setFetchMode("otherPointOfContactCollection.organization", FetchMode.JOIN);
     crit.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY);
     List results = appService.query(crit);
     List<PointOfContactBean> pointOfContactCollection = new ArrayList<PointOfContactBean>();
     for (int i = 0; i < results.size(); i++) {
       Sample particle = (Sample) results.get(i);
       PointOfContact primaryPOC = particle.getPrimaryPointOfContact();
       Collection<PointOfContact> otherPOCs = particle.getOtherPointOfContactCollection();
       pointOfContactCollection.add(new PointOfContactBean(primaryPOC));
       for (PointOfContact poc : otherPOCs) {
         pointOfContactCollection.add(new PointOfContactBean(poc));
       }
     }
     return pointOfContactCollection;
   } catch (Exception e) {
     String err = "Problem finding all PointOfContact collections with the given sample ID.";
     logger.error(err, e);
     throw new PointOfContactException(err, e);
   }
 }