public String execute() throws Exception {
    // ---------------------------------------------------------------------
    // Get File Excel
    // ---------------------------------------------------------------------

    String path = selectionManager.getUploadFilePath();

    if (path != null && path != "") {
      fileExcel = new File(path);
    }

    // ---------------------------------------------------------------------
    // Validate selected OrganisationUnit
    // ---------------------------------------------------------------------

    organisationUnit = organisationUnitSelectionManager.getSelectedOrganisationUnit();

    if (organisationUnit == null) {
      return SUCCESS;
    }

    // ---------------------------------------------------------------------
    // Load and sort ImportReports
    // ---------------------------------------------------------------------

    importReports =
        new ArrayList<ImportReport>(importReportService.getImportReports(organisationUnit));

    return SUCCESS;
  }
Ejemplo n.º 2
0
  public String execute() throws Exception {
    // ---------------------------------------------------------------------
    // Get parent
    // ---------------------------------------------------------------------

    OrganisationUnit newParent;

    if (newParentOrganisationUnitId != null) {
      newParent =
          organisationUnitService.getOrganisationUnit(newParentOrganisationUnitId.intValue());
    } else {
      newParent = selectionManager.getRootOrganisationUnitsParent();
    }

    // ---------------------------------------------------------------------
    // Update unit to move
    // ---------------------------------------------------------------------

    OrganisationUnit unitToMove =
        organisationUnitService.getOrganisationUnit(organisationUnitToMoveId.intValue());

    unitToMove.setParent(newParent);

    organisationUnitService.updateOrganisationUnit(unitToMove);

    organisationUnitService.addOrganisationUnitHierarchy(new Date());

    return SUCCESS;
  }
  public String execute() throws Exception {
    String[] importItemIds = selectionManager.getListObject();

    if (importItemIds == null) {
      message = i18n.getString("choose_import_item");

      return ERROR;
    }

    OrganisationUnit organisationUnit =
        organisationUnitSelectionManager.getSelectedOrganisationUnit();

    if (organisationUnit != null) {
      Period period = periodGenericManager.getSelectedPeriod();

      Set<DataValue> oldDataValues = new HashSet<DataValue>();
      Set<DataValue> newDataValues = new HashSet<DataValue>();

      executeToImport(organisationUnit, period, importItemIds, oldDataValues, newDataValues);

      selectionManager.setOldDataValueList(oldDataValues);
      selectionManager.setNewDataValueList(newDataValues);
    }

    message = i18n.getString("import_successfully");

    return SUCCESS;
  }
  public String execute() throws Exception {
    try {
      OrganisationUnit unit = organisationUnitService.getOrganisationUnit(id);

      if (unit == null) {
        throw new RuntimeException("OrganisationUnit with id " + id + " doesn't exist");
      }

      selectedUnits = selectionManager.getSelectedOrganisationUnits();
      selectedUnits.remove(unit);
      selectionManager.setSelectedOrganisationUnits(selectedUnits);
    } catch (Exception e) {
      LOG.error(e.getMessage(), e);

      throw e;
    }

    return SUCCESS;
  }
  public String execute() {
    relationshipTypes =
        new ArrayList<RelationshipType>(relationshipTypeService.getAllRelationshipTypes());

    identifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes();

    attributes = patientAttributeService.getAllPatientAttributes();

    OrganisationUnit organisationUnit = selectionManager.getSelectedOrganisationUnit();
    healthWorkers = organisationUnit.getUsers();

    return SUCCESS;
  }
  public String execute() throws Exception {
    patientAttributes = patientAttributeService.getAllPatientAttributes();

    programs = programService.getProgramsByCurrentUser();

    organisationUnit = selectionManager.getSelectedOrganisationUnit();

    if (organisationUnit == null) {
      status = 1;
    }

    return SUCCESS;
  }
  public String execute() throws Exception {

    organisationUnit = organisationUnitSelectionManager.getSelectedOrganisationUnit();

    feature = featureService.get(organisationUnit);

    if (organisationUnit != null) {
      mapFile = selectionManager.getSelectedMapFile();
    }
    if (mapFile == null) {
      mapFile = new MapFile();
      mapFile.setMapFile("example.svg");
    }
    // TODO Auto-generated method stub
    return SUCCESS;
  }
Ejemplo n.º 8
0
  public String execute() throws Exception {
    UserCredentials currentUserCredentials =
        currentUserService.getCurrentUser() != null
            ? currentUserService.getCurrentUser().getUserCredentials()
            : null;

    // ---------------------------------------------------------------------
    // Prepare values
    // ---------------------------------------------------------------------

    if (email != null && email.trim().length() == 0) {
      email = null;
    }

    if (rawPassword != null && rawPassword.trim().length() == 0) {
      rawPassword = null;
    }

    // ---------------------------------------------------------------------
    // Update userCredentials and user
    // ---------------------------------------------------------------------

    Collection<OrganisationUnit> units =
        selectionTreeManager.getReloadedSelectedOrganisationUnits();

    User user = userService.getUser(id);
    user.setSurname(surname);
    user.setFirstName(firstName);
    user.setEmail(email);
    user.setPhoneNumber(phoneNumber);
    user.updateOrganisationUnits(new HashSet<OrganisationUnit>(units));

    UserCredentials userCredentials = userService.getUserCredentials(user);

    Set<UserAuthorityGroup> userAuthorityGroups = new HashSet<UserAuthorityGroup>();

    for (String id : selectedList) {
      UserAuthorityGroup group = userService.getUserAuthorityGroup(Integer.parseInt(id));

      if (currentUserCredentials != null && currentUserCredentials.canIssue(group)) {
        userAuthorityGroups.add(group);
      }
    }

    userCredentials.setUserAuthorityGroups(userAuthorityGroups);

    if (rawPassword != null) {
      userCredentials.setPassword(
          passwordManager.encodePassword(userCredentials.getUsername(), rawPassword));
    }

    if (jsonAttributeValues != null) {
      AttributeUtils.updateAttributeValuesFromJson(
          user.getAttributeValues(), jsonAttributeValues, attributeService);
    }

    userService.updateUserCredentials(userCredentials);
    userService.updateUser(user);

    if (currentUserService.getCurrentUser() == user) {
      selectionManager.setRootOrganisationUnits(units);
      selectionManager.setSelectedOrganisationUnits(units);

      selectionTreeManager.setRootOrganisationUnits(units);
      selectionTreeManager.setSelectedOrganisationUnits(units);
    }

    if (units.size() > 0) {
      selectionManager.setSelectedOrganisationUnits(units);
    }

    return SUCCESS;
  }
  public String execute() {
    unit = selectionManager.getSelectedOrganisationUnit();

    return SUCCESS;
  }
  public String execute() throws Exception {
    type = StringUtils.trimToNull(type);

    // ---------------------------------------------------------------------
    // Get group sets
    // ---------------------------------------------------------------------

    groupSets =
        new ArrayList<OrganisationUnitGroupSet>(
            organisationUnitGroupService.getCompulsoryOrganisationUnitGroupSets());

    Collections.sort(groupSets, IdentifiableObjectNameComparator.INSTANCE);

    // ---------------------------------------------------------------------
    // Assemble groups and get search result
    // ---------------------------------------------------------------------

    if (!skipSearch) {
      name = StringUtils.trimToNull(name);

      selectedOrganisationUnit = selectionManager.getSelectedOrganisationUnit();

      log.debug("Name: " + name + ", Orgunit: " + selectedOrganisationUnit + ", type: " + type);

      // -----------------------------------------------------------------
      // Set orgunit to null if root to avoid subquery and improve perf
      // -----------------------------------------------------------------

      selectedOrganisationUnit =
          selectedOrganisationUnit != null && selectedOrganisationUnit.getParent() == null
              ? null
              : selectedOrganisationUnit;

      Collection<OrganisationUnitGroup> groups = new HashSet<OrganisationUnitGroup>();

      for (Integer id : groupId) {
        if (id != ANY) {
          OrganisationUnitGroup group = organisationUnitGroupService.getOrganisationUnitGroup(id);
          groups.add(group);
        }
      }

      boolean limit = type == null; // Only limit for HTML view since browser is memory constrained

      organisationUnits =
          new ArrayList<OrganisationUnit>(
              organisationUnitService.getOrganisationUnitsByNameAndGroups(
                  name, groups, selectedOrganisationUnit, limit));

      limited =
          organisationUnits != null
              && organisationUnits.size() == OrganisationUnitService.MAX_LIMIT;

      Collections.sort(organisationUnits, IdentifiableObjectNameComparator.INSTANCE);

      if (type != null && !type.equalsIgnoreCase(DEFAULT_TYPE)) {
        grid = generateGrid();
      }
    }

    return type != null ? type : SUCCESS;
  }