/* (non-Javadoc) * @see edu.duke.cabig.c3pr.domain.Organization#equals(java.lang.Object) */ @Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (getClass() != obj.getClass()) return false; final HealthcareSite other = (HealthcareSite) obj; if (getPrimaryIdentifier() == null) { if (other.getPrimaryIdentifier() != null) return false; } else if (!getPrimaryIdentifier().equals(other.getPrimaryIdentifier())) return false; return true; }
/** * Gets the planned notifications for the list of sites that are passed in. This method access the * db using a new session from the hibernate session factory. * * @param hcsList the hcs list * @return the planned notifications */ public List<PlannedNotification> getPlannedNotifications(List<HealthcareSite> hcsList) { List<PlannedNotification> result; List<String> nciCodeList = new ArrayList<String>(); for (HealthcareSite hcs : hcsList) { if (hcs != null) { nciCodeList.add(hcs.getPrimaryIdentifier()); } } SessionFactory sessionFactory = (SessionFactory) applicationContext.getBean("sessionFactory"); Session session = sessionFactory.openSession(sessionFactory.getCurrentSession().connection()); session.setFlushMode(FlushMode.MANUAL); result = new ArrayList<PlannedNotification>(); try { Query query = session .createQuery( "select p from PlannedNotification p, HealthcareSite o, Identifier i where p = any elements(o.plannedNotificationsInternal) and " + "i = any elements(o.identifiersAssignedToOrganization) and i.primaryIndicator = 'true' and " + "i.value in (:nciCodeList)") .setParameterList("nciCodeList", nciCodeList); result = query.list(); } catch (DataAccessResourceFailureException e) { log.error(e.getMessage()); } catch (IllegalStateException e) { e.printStackTrace(); } catch (HibernateException e) { log.error(e.getMessage()); } catch (Exception e) { log.error(e.getMessage()); } finally { session.close(); } return result; }