private PrivateStudyLocal getPrivateStudy(
     StudyLocal study, int type, PrivatePatientLocal privPat, boolean includeSeries)
     throws FinderException, CreateException {
   Collection col = privStudyHome.findByStudyIuid(type, study.getStudyIuid());
   PrivateStudyLocal privStudy;
   if (col.isEmpty()) {
     if (privPat == null) {
       privPat = getPrivatePatient(study.getPatient(), type, false);
     }
     privStudy = privStudyHome.create(type, study.getAttributes(true), privPat);
   } else {
     privStudy = (PrivateStudyLocal) col.iterator().next();
   }
   if (includeSeries) {
     for (Iterator iter = study.getSeries().iterator(); iter.hasNext(); ) {
       getPrivateSeries(
           (SeriesLocal) iter.next(), type, privStudy, true); // move also all instances
     }
   }
   return privStudy;
 }
 /**
  * @throws FinderException
  * @ejb.interface-method
  */
 public Collection deletePrivateStudy(long study_pk) throws RemoteException, FinderException {
   try {
     PrivateStudyLocal study = privStudyHome.findByPrimaryKey(new Long(study_pk));
     ArrayList files = null;
     PrivatePatientLocal pat = study.getPatient();
     study.remove();
     if (pat.getStudies().isEmpty()) {
       pat.remove();
     }
     return files;
   } catch (EJBException e) {
     throw new RemoteException(e.getMessage());
   } catch (RemoveException e) {
     throw new RemoteException(e.getMessage());
   }
 }