Esempio n. 1
0
  public void addSubscriber() {
    try {
      if (program.getListEditing() == null) {
        throw new RuntimeException(
            "List is not set yet but you still manage to come to this page? Notify your admin immediately! =)");
      }

      subService.subscribe(program.getListEditingId(), this.getFieldValues());
      FacesMessenger.setFacesMessage(
          program.getFormName(), FacesMessage.SEVERITY_FATAL, "Subscriber added!", null);
      // How to redirect to List editing panel?
      program.refresh();

    } catch (EJBException ex) { // Transaction did not go through
      // Throwable cause = ex.getCause();
      FacesMessenger.setFacesMessage(
          formName, FacesMessage.SEVERITY_ERROR, "Error with transaction", ex.getMessage());
    } catch (EntityNotFoundException ex) {
      FacesMessenger.setFacesMessage(formName, FacesMessage.SEVERITY_ERROR, ex.getMessage(), "");
    } catch (IncompleteDataException ex) {
      FacesMessenger.setFacesMessage(formName, FacesMessage.SEVERITY_ERROR, ex.getMessage(), "");
    } catch (DataValidationException ex) {
      FacesMessenger.setFacesMessage(formName, FacesMessage.SEVERITY_ERROR, ex.getMessage(), "");
    } catch (RelationshipExistsException ex) {
      FacesMessenger.setFacesMessage(
          formName, FacesMessage.SEVERITY_ERROR, "Subscriber already exist in this list", "");
    } catch (Exception ex) {
      FacesMessenger.setFacesMessage(
          formName, FacesMessage.SEVERITY_ERROR, ex.getClass().getSimpleName(), ex.getMessage());
    }
  }
  @RequestMapping(value = "/create-category", method = RequestMethod.POST)
  public String createCategory(
      Model model,
      @ModelAttribute("category") @Valid Category category,
      Errors errors,
      @RequestParam("name") String name,
      @RequestParam("description") String description) {

    model.addAttribute("title", "Create Category");

    Category newCategory =
        new Category(HtmlUtils.htmlEscape(name), HtmlUtils.htmlEscape(description));

    if (errors.hasErrors()) {
      model.addAttribute("category", category);
      return "create-category";
    }

    /*
     * What to do if there is no error
     * We need a DAO and Service to add category into the database
     */
    try {
      categoryService.createCategory(newCategory);
      model.addAttribute(
          "success",
          "<div class=\"info\">Succesfully Created <p> <a href='manage-category.html'>Go back to Management Page</a></div>"); // Add success message
      category.setName(""); // Reset form field
      category.setDescription(""); // Reset form field
    } catch (EJBException e) {
      model.addAttribute("error", e.getMessage());
    }

    return "create-category";
  }
 /**
  * @throws FinderException
  * @ejb.interface-method
  */
 public void deletePrivateFile(long file_pk) throws RemoteException {
   try {
     privFileHome.remove(new Long(file_pk));
   } catch (EJBException e) {
     throw new RemoteException(e.getMessage());
   } catch (RemoveException e) {
     throw new RemoteException(e.getMessage());
   }
 }
 /** @ejb.interface-method */
 public void deletePrivatePatient(long patient_pk) throws RemoteException {
   try {
     privPatHome.remove(new Long(patient_pk));
   } catch (EJBException e) {
     throw new RemoteException(e.getMessage());
   } catch (RemoveException e) {
     throw new RemoteException(e.getMessage());
   }
 }
 public String reset() {
   if (this.installed) {
     try {
       throw new EJBException("Desinstalação não foi implementada!");
     } catch (EJBException e) {
       Logger.getGlobal().fine(e.getMessage());
     }
   }
   return "setup";
 }
  /**
   * Delete a list of instances, i.e., move them to trash bin
   *
   * @ejb.interface-method
   * @param iuids A list of instance uid
   * @param cascading True to delete the series/study if there's no instance/series
   * @return a collection of Dataset containing the actuall detetion information per study
   * @throws RemoteException
   */
  public Collection moveInstancesToTrash(String[] iuids, boolean cascading) throws RemoteException {
    try {
      // These instances may belong to multiple studies,
      // although mostly they should be the same study
      Map mapStudies = new HashMap();
      for (int i = 0; i < iuids.length; i++) {
        InstanceLocal instance = instHome.findBySopIuid(iuids[i]);
        SeriesLocal series = instance.getSeries();
        StudyLocal study = series.getStudy();
        if (!mapStudies.containsKey(study)) mapStudies.put(study, new HashMap());
        Map mapSeries = (Map) mapStudies.get(study);
        if (!mapSeries.containsKey(series)) mapSeries.put(series, new ArrayList());
        Collection colInstances = (Collection) mapSeries.get(series);
        colInstances.add(instance);
      }

      List dss = new ArrayList();
      Iterator iter = mapStudies.keySet().iterator();
      while (iter.hasNext()) {
        StudyLocal study = (StudyLocal) iter.next();
        dss.add(getStudyMgtDataset(study, (Map) mapStudies.get(study)));
        Iterator iter2 = ((Map) mapStudies.get(study)).keySet().iterator();
        while (iter2.hasNext()) {
          SeriesLocal series = (SeriesLocal) iter2.next();
          List instances = (List) ((Map) mapStudies.get(study)).get(series);
          for (int i = 0; i < instances.size(); i++) {
            // Delete the instance now, i.e., move to trash bin,
            // becoming private instance
            getPrivateInstance((InstanceLocal) instances.get(i), DELETED, null);
            ((InstanceLocal) instances.get(i)).remove();
          }
          if (series.getInstances().size() == 0 && cascading) {
            // Delete the series too since there's no instance left
            getPrivateSeries(series, DELETED, null, false);
            series.remove();
          } else UpdateDerivedFieldsUtils.updateDerivedFieldsOf(series);
        }
        if (study.getSeries().size() == 0 && cascading) {
          // Delete the study too since there's no series left
          getPrivateStudy(study, DELETED, null, false);
          study.remove();
        } else UpdateDerivedFieldsUtils.updateDerivedFieldsOf(study);
      }

      return dss;
    } catch (CreateException e) {
      throw new RemoteException(e.getMessage());
    } catch (EJBException e) {
      throw new RemoteException(e.getMessage());
    } catch (FinderException e) {
      throw new RemoteException(e.getMessage());
    } catch (RemoveException e) {
      throw new RemoteException(e.getMessage());
    }
  }
 /** @ejb.interface-method */
 public Dataset moveStudyToTrash(String iuid) throws RemoteException {
   try {
     StudyLocal study = studyHome.findByStudyIuid(iuid);
     if (study != null) return moveStudyToTrash(study.getPk().longValue());
     else return null;
   } catch (EJBException e) {
     throw new RemoteException(e.getMessage());
   } catch (FinderException e) {
     throw new RemoteException(e.getMessage());
   }
 }
 /**
  * @throws FinderException
  * @ejb.interface-method
  */
 public void deletePrivateFiles(Collection fileDTOs) throws RemoteException {
   try {
     for (Iterator iter = fileDTOs.iterator(); iter.hasNext(); ) {
       privFileHome.remove(new Long(((FileDTO) iter.next()).getPk()));
     }
   } catch (EJBException e) {
     throw new RemoteException(e.getMessage());
   } catch (RemoveException e) {
     throw new RemoteException(e.getMessage());
   }
 }
 public String setup() {
   checkInstallation();
   if (!this.installed) {
     try {
       facade.create(Comprador.createCompradorBB());
     } catch (EJBException e) {
       Logger.getGlobal().fine(e.getMessage());
     }
     try {
       facade.create(Comprador.createCompradorBEC());
     } catch (EJBException e) {
       Logger.getGlobal().fine(e.getMessage());
     }
     try {
       facade.create(Comprador.createCompradorComprasNet());
     } catch (EJBException e) {
       Logger.getGlobal().fine(e.getMessage());
     }
   }
   checkInstallation();
   return "setup";
 }
 /** @ejb.interface-method */
 public void deleteAll(int privateType) throws RemoteException {
   try {
     Collection c = privPatHome.findByPrivateType(privateType);
     for (Iterator iter = c.iterator(); iter.hasNext(); ) {
       privPatHome.remove(((PrivatePatientLocal) iter.next()).getPk());
     }
   } catch (EJBException e) {
     throw new RemoteException(e.getMessage());
   } catch (RemoveException e) {
     throw new RemoteException(e.getMessage());
   } catch (FinderException e) {
     throw new RemoteException(e.getMessage());
   }
 }
 /**
  * @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());
   }
 }
Esempio n. 12
0
  public void loadListFields() {
    try {
      long listId = program.getListEditingId();
      // to improve performance
      // no! it's necessary else there will be nullpointerexception :p
      if (listId <= 0) {
        return;
      }
      List<SubscriptionListField> fieldList = subService.getFieldsForSubscriptionList(listId);
      this.program.setFieldList(fieldList);

    } catch (EJBException ex) {
      FacesMessenger.setFacesMessage(
          program.getFormName(), FacesMessage.SEVERITY_ERROR, ex.getMessage(), null);
    }
  }
 /** @ejb.interface-method */
 public Dataset moveStudyToTrash(long study_pk) throws RemoteException {
   try {
     StudyLocal study = studyHome.findByPrimaryKey(new Long(study_pk));
     Dataset ds = getStudyMgtDataset(study, null);
     getPrivateStudy(study, DELETED, null, true);
     study.remove();
     return ds;
   } catch (CreateException e) {
     throw new RemoteException(e.getMessage());
   } catch (EJBException e) {
     throw new RemoteException(e.getMessage());
   } catch (FinderException e) {
     throw new RemoteException(e.getMessage());
   } catch (RemoveException e) {
     throw new RemoteException(e.getMessage());
   }
 }
 /**
  * @throws FinderException
  * @ejb.interface-method
  */
 public void deletePrivateSeries(long series_pk) throws RemoteException, FinderException {
   try {
     PrivateSeriesLocal series = privSeriesHome.findByPrimaryKey(new Long(series_pk));
     PrivateStudyLocal study = series.getStudy();
     series.remove();
     if (study.getSeries().isEmpty()) {
       PrivatePatientLocal pat = study.getPatient();
       study.remove();
       if (pat.getStudies().isEmpty()) {
         pat.remove();
       }
     }
   } catch (EJBException e) {
     throw new RemoteException(e.getMessage());
   } catch (RemoveException e) {
     throw new RemoteException(e.getMessage());
   }
 }
Esempio n. 15
0
 public String delete() {
   if (name.equalsIgnoreCase("default")) {
     setErrorMessage("Builtin profile 'Default' can not be deleted.");
     return null;
   }
   try {
     Ejb.lookupDeviceProfileBean().findByPrimaryKey(name).remove();
     setDeleted();
     return "deleted";
   } catch (RemoveException ex) {
     setErrorMessage(ex.getMessage());
   } catch (EJBException ex) {
     setErrorMessage(ex.getMessage());
   } catch (FinderException ex) {
     setErrorMessage(ex.getMessage());
   }
   return null;
 }
 /** @ejb.interface-method */
 public Dataset moveSeriesToTrash(long series_pk) throws RemoteException {
   try {
     SeriesLocal series = seriesHome.findByPrimaryKey(new Long(series_pk));
     StudyLocal study = series.getStudy();
     Map mapSeries = new HashMap();
     mapSeries.put(series, series.getInstances());
     Dataset ds = getStudyMgtDataset(series.getStudy(), mapSeries);
     getPrivateSeries(series, DELETED, null, true);
     series.remove();
     UpdateDerivedFieldsUtils.updateDerivedFieldsOf(study);
     return ds;
   } catch (CreateException e) {
     throw new RemoteException(e.getMessage());
   } catch (EJBException e) {
     throw new RemoteException(e.getMessage());
   } catch (FinderException e) {
     throw new RemoteException(e.getMessage());
   } catch (RemoveException e) {
     throw new RemoteException(e.getMessage());
   }
 }
Esempio n. 17
0
  public void loadSubscribers() {
    try {
      SubscriptionList listEditing = getListEditing();
      if (listEditing == null) return;
      // Load the maximum # of subscribers depending on the page
      // If list has 101, SUBSCRIBERS_PER_PAGE = 100 and page = 2,
      // load subscriber # (2-1)*100=100 to # (2)*100=200.
      int pageNum = getPage();
      Map<Long, Map<String, String>> accounts =
          subService.getSubscriberValuesMap(
              listEditing.getOBJECTID(), pageNum * SUBSCRIBERS_PER_PAGE, SUBSCRIBERS_PER_PAGE);

      program.setSubscriberTable(accounts);

    } catch (EJBException ex) {
      FacesMessenger.setFacesMessage(
          formName, FacesMessage.SEVERITY_ERROR, "Error with transaction", ex.getMessage());
    } catch (Exception ex) {
      FacesMessenger.setFacesMessage(
          formName, FacesMessage.SEVERITY_ERROR, ex.getClass().getSimpleName(), ex.getMessage());
    }
  }
 /** @ejb.interface-method */
 public Collection movePatientToTrash(long pat_pk) throws RemoteException {
   try {
     PatientLocal patient = patHome.findByPrimaryKey(new Long(pat_pk));
     Collection col = patient.getStudies();
     Collection result = new ArrayList();
     for (Iterator iter = col.iterator(); iter.hasNext(); ) {
       result.add(getStudyMgtDataset((StudyLocal) iter.next(), null));
     }
     Dataset ds = patient.getAttributes(true);
     getPrivatePatient(patient, DELETED, true);
     patient.remove();
     if (result.isEmpty()) result.add(ds);
     return result;
   } catch (CreateException e) {
     throw new RemoteException(e.getMessage());
   } catch (EJBException e) {
     throw new RemoteException(e.getMessage());
   } catch (FinderException e) {
     throw new RemoteException(e.getMessage());
   } catch (RemoveException e) {
     throw new RemoteException(e.getMessage());
   }
 }
 /** @ejb.interface-method */
 public Dataset moveInstanceToTrash(long instance_pk) throws RemoteException {
   try {
     InstanceLocal instance = instHome.findByPrimaryKey(new Long(instance_pk));
     Collection colInstance = new ArrayList();
     colInstance.add(instance);
     SeriesLocal series = instance.getSeries();
     Map mapSeries = new HashMap();
     mapSeries.put(series, colInstance);
     Dataset ds = getStudyMgtDataset(series.getStudy(), mapSeries);
     getPrivateInstance(instance, DELETED, null);
     instance.remove();
     UpdateDerivedFieldsUtils.updateDerivedFieldsOf(series);
     UpdateDerivedFieldsUtils.updateDerivedFieldsOf(series.getStudy());
     return ds;
   } catch (CreateException e) {
     throw new RemoteException(e.getMessage());
   } catch (EJBException e) {
     throw new RemoteException(e.getMessage());
   } catch (FinderException e) {
     throw new RemoteException(e.getMessage());
   } catch (RemoveException e) {
     throw new RemoteException(e.getMessage());
   }
 }