Exemplo n.º 1
0
    @Override
    public void editItem(Object[] items) {
      try {
        String projName = (String) items[0];
        int projID =
            MedSavantClient.ProjectManager.getProjectID(
                LoginController.getInstance().getSessionID(), projName);

        // Check for existing unpublished changes to this project.
        if (ProjectController.getInstance().promptForUnpublished()) {
          try {
            // Get lock.
            if (MedSavantClient.SettingsManager.getDBLock(
                LoginController.getInstance().getSessionID())) {
              try {
                ProjectWizard wiz =
                    new ProjectWizard(
                        projID,
                        projName,
                        MedSavantClient.PatientManager.getCustomPatientFields(
                            LoginController.getInstance().getSessionID(), projID),
                        MedSavantClient.ProjectManager.getProjectDetails(
                            LoginController.getInstance().getSessionID(), projID));
                wiz.setVisible(true);

              } finally {
                try {
                  MedSavantClient.SettingsManager.releaseDBLock(
                      LoginController.getInstance().getSessionID());
                } catch (Exception ex1) {
                  LOG.error("Error releasing database lock.", ex1);
                }
              }
            } else {
              DialogUtils.displayMessage(
                  "Cannot Modify Project",
                  "The database is currently locked.\nTo unlock, see the Projects page in the Administration section.");
            }
          } catch (Exception ex) {
            ClientMiscUtils.reportError("Error getting database lock: %s", ex);
          }
        }
      } catch (Exception ex) {
        ClientMiscUtils.reportError("Error checking for changes: %s", ex);
      }
    }
Exemplo n.º 2
0
 @Override
 public void addItems() {
   try {
     new ProjectWizard().setVisible(true);
   } catch (Exception ex) {
     ClientMiscUtils.reportError("Unable to launch project wizard: %s", ex);
   }
 }
    private void setIndividuals() throws SQLException, RemoteException {
      try {

        setCohorts();

        List<Object[]> tmpIndividuals =
            MedSavantClient.PatientManager.getBasicPatientInfo(
                LoginController.getSessionID(),
                ProjectController.getInstance().getCurrentProjectID(),
                Integer.MAX_VALUE);
        List<Object[]> updatedIndividuals = new ArrayList<Object[]>();

        for (Object[] row : tmpIndividuals) {
          row[INDEX_OF_GENDER] = ClientMiscUtils.genderToString((Integer) row[INDEX_OF_GENDER]);

          String s;
          Object o = row[INDEX_OF_AFFECTED];
          if (o instanceof Boolean) {
            Boolean b = (Boolean) o;
            s = b ? "Yes" : "No";
          } else if (o instanceof Integer) {
            Integer i = (Integer) o;
            s = (i > 0) ? "Yes" : "No";
          } else {
            s = "Unknown";
          }
          row[INDEX_OF_AFFECTED] = s;
          /*Boolean b = (Boolean) row[INDEX_OF_AFFECTED];
          String s = b ? "Yes" : "No";
          row[INDEX_OF_AFFECTED] = s;*/

          List<String> cohorts = hospitalIDToCohortMap.get((String) row[INDEX_OF_HOSPITAL_ID]);

          String cohortString = "";
          if (cohorts != null) {
            cohortString = StringUtils.join(cohorts.toArray(), ", ");
          }

          row = ArrayUtils.addAll(row, new String[] {cohortString});

          updatedIndividuals.add(row);
        }

        individuals = updatedIndividuals;

      } catch (SessionExpiredException e) {
        MedSavantExceptionHandler.handleSessionExpiredException(e);
      }
    }
Exemplo n.º 4
0
 public Icon getIcon() {
   if (isLeaf) {
     String ext = ClientMiscUtils.getExtension(url);
     try {
       File f = File.createTempFile("savant_icon.", "." + ext);
       Icon i = getFileSystemView().getSystemIcon(f);
       f.delete();
       return i;
     } catch (IOException ex) {
       return null;
     }
   } else {
     return getFileSystemView().getSystemIcon(DirectorySettings.getMedSavantDirectory());
   }
 }
Exemplo n.º 5
0
 private void removeDatabase(
     String address, int port, String database, String username, char[] password) {
   if (DialogUtils.askYesNo(
           "Confirm",
           "<html>Are you sure you want to remove <i>%s</i>?<br>This operation cannot be undone.",
           database)
       == DialogUtils.YES) {
     try {
       MedSavantClient.initializeRegistry(address, port + "");
       MedSavantClient.SetupManager.removeDatabase(address, port, database, username, password);
       setVisible(false);
       DialogUtils.displayMessage(
           "Database Removed",
           String.format("<html>Database <i>%s</i> successfully removed.</html>", database));
     } catch (Exception ex) {
       ClientMiscUtils.reportError("Database could not be removed: %s", ex);
     }
   }
 }
Exemplo n.º 6
0
    @Override
    public void deleteItems(List<Object[]> items) {
      int nameIndex = 0;
      int keyIndex = 0;

      int result;

      if (items.size() == 1) {
        String name = (String) items.get(0)[nameIndex];
        result =
            DialogUtils.askYesNo(
                "Confirm",
                "<html>Are you sure you want to remove <i>%s</i>?<br>This cannot be undone.</html>",
                name);
      } else {
        result =
            DialogUtils.askYesNo(
                "Confirm",
                "<html>Are you sure you want to remove these %d projects?<br>This cannot be undone.</html>",
                items.size());
      }

      if (result == DialogUtils.YES) {
        for (Object[] v : items) {
          String projectName = (String) v[keyIndex];
          controller.removeProject(projectName);
        }

        try {
          if (controller.getProjectNames().length == 0) {
            LoginController.getInstance().logout();
          }
          DialogUtils.displayMessage("Successfully removed " + items.size() + " project(s)");
        } catch (Exception ex) {
          ClientMiscUtils.reportError("Unable to get updated project list: %s.", ex);
        }
      }
    }