List of usage examples for org.apache.commons.lang3 StringUtils trim
public static String trim(final String str)
Removes control characters (char <= 32) from both ends of this String, handling null by returning null .
The String is trimmed using String#trim() .
From source file:org.cgiar.ccafs.ap.action.projects.ProjectHighListAction.java
@Override public void prepare() throws Exception { projectID = Integer//from w ww. ja v a 2 s .c o m .parseInt(StringUtils.trim(this.getRequest().getParameter(APConstants.PROJECT_REQUEST_ID))); project = projectManager.getProject(projectID); // Getting the Deliverables Main Types. allYears = project.getAllYears(); // Getting the List of Expected Deliverables List<ProjectHighligths> deliverables = deliverableManager.getHighLightsByProject(projectID); project.setHighlights(deliverables); // Initializing Section Statuses: this.initializeProjectSectionStatuses(project, this.getCycleName()); }
From source file:org.cgiar.ccafs.ap.action.projects.ProjectIPOtherContributionAction.java
@Override public void prepare() throws Exception { super.prepare(); projectID = Integer/*from ww w. j a v a 2s.com*/ .parseInt(StringUtils.trim(this.getRequest().getParameter(APConstants.PROJECT_REQUEST_ID))); // Getting the project information project = projectManager.getProject(projectID); crps = crpManager.getCRPsList(); // Getting the information for the IP Other Contribution project.setIpOtherContribution(ipOtherContributionManager.getIPOtherContributionByProjectId(projectID)); List<ProjecteOtherContributions> others = ipOtherContributionManager .getOtherContributionsByProjectId(projectID); project.setOtherContributions(others); if (project.getIpOtherContribution() == null) { project.setIpOtherContribution(new OtherContribution()); } // Getting the previous contributions. previousCRPContributions = new ArrayList<>(); previousCRPContributions.addAll(project.getIpOtherContribution().getCrpContributions()); this.regions = new HashMap<String, String>(); // Getting the information of the Regions program for the View List<IPProgram> regions = ipProgramManager.getProgramsByType(APConstants.REGION_PROGRAM_TYPE); for (IPProgram ipProgram : regions) { this.regions.put(String.valueOf(ipProgram.getId()), ipProgram.getComposedName()); } this.flagships = new HashMap<String, String>(); // Getting the information of the Flagships program for the View List<IPProgram> flagships = ipProgramManager.getProgramsByType(APConstants.FLAGSHIP_PROGRAM_TYPE); for (IPProgram ipProgram : flagships) { this.flagships.put(String.valueOf(ipProgram.getId()), ipProgram.getComposedName()); } this.otherIndicators = new HashMap<>(); List<IPIndicator> otherIndicators = ipIndicatorManager.getIndicatorsOtherContribution(projectID, 0); for (IPIndicator ipIndicator : otherIndicators) { this.otherIndicators.put(String.valueOf(ipIndicator.getId()), ipIndicator.getDescription()); } // Getting the Project lessons for this section. int evaluatingYear = 0; if (this.getCycleName().equals(APConstants.REPORTING_SECTION)) { evaluatingYear = this.getCurrentReportingYear(); } else { evaluatingYear = this.getCurrentPlanningYear(); } // Getting the Project lessons for this section. this.setProjectLessons(lessonManager.getProjectComponentLesson(projectID, this.getActionName(), evaluatingYear, this.getCycleName())); if (this.getCycleName().equals(APConstants.REPORTING_SECTION)) { this.setProjectLessonsPreview(lessonManager.getProjectComponentLesson(projectID, this.getActionName(), this.getCurrentReportingYear(), APConstants.PLANNING_SECTION)); } super.setHistory(historyManager.getProjectIPOtherContributionHistory(project.getId())); if (this.isHttpPost()) { project.getIpOtherContribution().getCrpContributions().clear(); } if (this.getRequest().getMethod().equalsIgnoreCase("post")) { // Clear out the list if it has some element if (project.getOtherContributions() != null) { project.getOtherContributions().clear(); } } // Initializing Section Statuses: this.initializeProjectSectionStatuses(project, this.getCycleName()); }
From source file:org.cgiar.ccafs.ap.action.projects.ProjectLeveragesAction.java
@Override public void prepare() throws Exception { super.prepare(); projectID = Integer// w w w .java 2 s . c o m .parseInt(StringUtils.trim(this.getRequest().getParameter(APConstants.PROJECT_REQUEST_ID))); project = projectManager.getProject(projectID); // Getting the list of all institutions this.allInstitutions = new HashMap<>(); List<Institution> allInstitutions = institutionManager.getAllInstitutions(); for (Institution institution : allInstitutions) { this.allInstitutions.put(String.valueOf(institution.getId()), institution.getComposedName()); } this.ipProgramFlagships = new HashMap<>(); // Getting the information of the Flagships program for the View List<IPProgram> ipProgramFlagships = ipProgramManager.getProgramsByType(APConstants.FLAGSHIP_PROGRAM_TYPE); for (IPProgram ipProgram : ipProgramFlagships) { this.ipProgramFlagships.put(String.valueOf(ipProgram.getId()), ipProgram.getComposedName()); } project.setLeverages(projectLeverageManager.getProjectLeverageProject(projectID)); if (project.getLeverages() != null) { leveragesPreview = projectLeverageManager.getProjectLeverageProject(projectID); // leverage.setMyInstitution(institutionManager.getInstitution(leverage.getInstitution())); if (this.getRequest().getMethod().equalsIgnoreCase("post")) { // Clear out the list if it has some element if (project.getLeverages() != null) { project.getLeverages().clear(); } } super.setHistory(historyManager.getProjectLeverage(project.getId())); } // Initializing Section Statuses: this.initializeProjectSectionStatuses(project, this.getCycleName()); }
From source file:org.cgiar.ccafs.ap.action.projects.ProjectLocationsAction.java
@Override public void prepare() throws Exception { // parseProjectID(); projectID = Integer/*from w w w . j a v a 2s . c om*/ .parseInt(StringUtils.trim(this.getRequest().getParameter(APConstants.PROJECT_REQUEST_ID))); project = projectManager.getProject(projectID); project.setLocations(locationManager.getProjectLocations(projectID)); previousLocations = new ArrayList<>(); previousLocations.addAll(project.getLocations()); previousLocationsSize = previousLocations.size(); locationTypes = locationTypeManager.getLocationTypes(); countries = locationManager.getAllCountries(); regions = locationManager.getAllRegions(); ccafsSites = locationManager.getLocationsByType(APConstants.LOCATION_TYPE_CCAFS_SITE); climateSmartVillages = locationManager.getLocationsByType(APConstants.LOCATION_TYPE_CLIMATE_SMART_VILLAGE); regionsSaved = new ArrayList<>(); countriesSaved = new ArrayList<>(); otherLocationsSaved = new ArrayList<>(); csvSaved = new ArrayList<>(); if (this.getRequest().getMethod().equalsIgnoreCase("post")) { // Clear out the list if it has some element if (project.getLocations() != null) { project.getLocations().clear(); } } int evaluatingYear = 0; if (this.getCycleName().equals(APConstants.REPORTING_SECTION)) { evaluatingYear = this.getCurrentReportingYear(); } else { evaluatingYear = this.getCurrentPlanningYear(); } // Getting the Project lessons for this section. this.setProjectLessons(lessonManager.getProjectComponentLesson(projectID, this.getActionName(), evaluatingYear, this.getCycleName())); if (this.getCycleName().equals(APConstants.REPORTING_SECTION)) { this.setProjectLessonsPreview(lessonManager.getProjectComponentLesson(projectID, this.getActionName(), this.getCurrentReportingYear(), APConstants.PLANNING_SECTION)); } super.setHistory(historyManager.getProjectLocationsHistory(project.getId())); // Initializing Section Statuses: this.initializeProjectSectionStatuses(project, this.getCycleName()); }
From source file:org.cgiar.ccafs.ap.action.projects.ProjectNextUsersAction.java
@Override public void prepare() throws Exception { super.prepare(); projectID = Integer//from www . ja va 2 s . co m .parseInt(StringUtils.trim(this.getRequest().getParameter(APConstants.PROJECT_REQUEST_ID))); project = projectManager.getProject(projectID); if (this.getRequest().getMethod().equalsIgnoreCase("post")) { // Clear out the list if it has some element if (project.getNextUsers() != null) { project.getNextUsers().clear(); } } project.setNextUsers(projectNextUserManager.getProjectNextUserProject(projectID)); nextUserPreview = project.getNextUsers(); // Getting the Project lessons for this section. this.setProjectLessons(lessonManager.getProjectComponentLesson(projectID, this.getActionName(), this.getCurrentPlanningYear(), this.getCycleName())); // Initializing Section Statuses: this.initializeProjectSectionStatuses(project, this.getCycleName()); // Getting the history for this section. super.setHistory(historyManager.getProjectNextUser(project.getId())); if (this.getRequest().getMethod().equalsIgnoreCase("post")) { // Clear out the list if it has some element if (project.getNextUsers() != null) { project.getNextUsers().clear(); } } }
From source file:org.cgiar.ccafs.ap.action.projects.ProjectOutcomesAction.java
@Override public void prepare() throws Exception { super.prepare(); currentPlanningYear = this.config.getPlanningCurrentYear(); midOutcomeYear = this.config.getMidOutcomeYear(); projectID = Integer/*from w ww .j a v a 2 s.c om*/ .parseInt(StringUtils.trim(this.getRequest().getParameter(APConstants.PROJECT_REQUEST_ID))); project = projectManager.getProject(projectID); // Load the project outcomes Map<String, ProjectOutcome> projectOutcomes = new HashMap<>(); for (int year = this.getCurrentPlanningYear() - 1; year <= midOutcomeYear; year++) { ProjectOutcome projectOutcome = projectOutcomeManager.getProjectOutcomeByYear(projectID, year); if (projectOutcome == null) { projectOutcome = new ProjectOutcome(-1); projectOutcome.setYear(year); } projectOutcomes.put(String.valueOf(year), projectOutcome); } project.setOutcomes(projectOutcomes); if (this.getCycleName().equals(APConstants.REPORTING_SECTION)) { this.setProjectLessonsPreview(lessonManager.getProjectComponentLesson(projectID, this.getActionName(), this.getCurrentReportingYear(), APConstants.PLANNING_SECTION)); } // Getting the Project lessons for this section. int evaluatingYear = 0; if (this.getCycleName().equals(APConstants.REPORTING_SECTION)) { evaluatingYear = this.getCurrentReportingYear(); } else { evaluatingYear = this.getCurrentPlanningYear(); } // Getting the Project lessons for this section. this.setProjectLessons(lessonManager.getProjectComponentLesson(projectID, this.getActionName(), evaluatingYear, this.getCycleName())); // Initializing Section Statuses: this.initializeProjectSectionStatuses(project, this.getCycleName()); // Getting the last history super.setHistory(historyManager.getProjectOutcomeHistory(project.getId())); }
From source file:org.cgiar.ccafs.ap.action.projects.ProjectOutputsAction.java
@Override public void prepare() throws Exception { projectID = Integer/*from w w w. j ava2 s .c om*/ .parseInt(StringUtils.trim(this.getRequest().getParameter(APConstants.PROJECT_REQUEST_ID))); // Getting the activity information project = projectManager.getProject(projectID); project.setOutputs(ipElementManager.getProjectOutputs(projectID)); // Remove the outputs duplicated Set<IPElement> outputsTemp = new HashSet<>(project.getOutputs()); project.getOutputs().clear(); project.getOutputs().addAll(outputsTemp); // if (!this.isHttpPost()) { // Get the project outputs from database project.setOutputsOverview(overviewManager.getProjectContributionOverviews(project)); previousOverviews = new ArrayList<>(); for (OutputOverview output : project.getOutputsOverview()) { previousOverviews.add(new OutputOverview(output.getId())); } } // save previous output overviews int evaluatingYear = 0; if (this.getCycleName().equals(APConstants.REPORTING_SECTION)) { evaluatingYear = this.getCurrentReportingYear(); } else { evaluatingYear = this.getCurrentPlanningYear(); } // Getting the Project lessons for this section. this.setProjectLessons(lessonManager.getProjectComponentLesson(projectID, this.getActionName(), evaluatingYear, this.getCycleName())); if (this.getRequest().getMethod().equalsIgnoreCase("post")) { // Clear out the list if it has some element if (project.getOutputsOverview() != null) { project.getOutputsOverview().clear(); } } // Initializing Section Statuses: this.initializeProjectSectionStatuses(project, this.getCycleName()); // Getting the history for this section. this.setHistory(historyManager.getProjectOutputsHistory(projectID)); }
From source file:org.cgiar.ccafs.ap.action.projects.ProjectPartnersAction.java
@Override public void prepare() throws Exception { super.prepare(); // Getting the project id from the URL parameter // It's assumed that the project parameter is ok. (@See ValidateProjectParameterInterceptor) projectID = Integer/*from w w w . j av a 2s.c o m*/ .parseInt(StringUtils.trim(this.getRequest().getParameter(APConstants.PROJECT_REQUEST_ID))); // Getting the project identified with the id parameter. project = projectManager.getProject(projectID); // Getting the list of all institutions allInstitutions = institutionManager.getAllInstitutions(); // Getting the list of all PPA institutions allPPAInstitutions = new ArrayList<>(); allPPAInstitutions.addAll(institutionManager.getAllPPAInstitutions()); // Getting all the countries countries = locationManager.getInstitutionCountries(); // Getting all partner types intitutionTypes = institutionManager.getAllInstitutionTypes(); // Getting all Project Leaders allUsers = userManager.getAllUsers(); int year = 0; if (this.isReportingCycle()) { year = config.getReportingCurrentYear(); } else { year = config.getPlanningCurrentYear(); } // Getting all the project partners. project.setProjectPartners(projectPartnerManager.getProjectPartners(project, year)); if (!project.getProjectPartners().isEmpty()) { overrall = project.getProjectPartners().get(0).getOverall(); } // Positioning project leader to be the first in the list. ProjectPartner leader = project.getLeader(); if (leader != null) { // First we remove the element from the array. project.getProjectPartners().remove(leader); // then we add it to the first position. project.getProjectPartners().add(0, leader); } // Getting the list of PPA Partners for this project this.projectPPAPartners = new ArrayList<ProjectPartner>(); for (ProjectPartner pp : project.getProjectPartners()) { if (pp.getInstitution().isPPA()) { this.projectPPAPartners.add(pp); } } // Populating the list of partner person types partnerPersonTypes = new HashMap<>(); partnerPersonTypes.put(APConstants.PROJECT_PARTNER_CP, this.getText("planning.projectPartners.types.CP")); if (this.hasProjectPermission("leader", projectID)) { partnerPersonTypes.put(APConstants.PROJECT_PARTNER_PL, this.getText("planning.projectPartners.types.PL")); } if (this.hasProjectPermission("coordinator", projectID)) { partnerPersonTypes.put(APConstants.PROJECT_PARTNER_PC, this.getText("planning.projectPartners.types.PC")); } // If the user is not admin or the project owner, we should keep some information previousProject = new Project(); previousProject.setId(project.getId()); previousProject.setProjectPartners(projectPartnerManager.getProjectPartners(project, year)); if (this.getRequest().getMethod().equalsIgnoreCase("post")) { // Clear out the list if it has some element // if (ActionContext.getContext().getName().equals("ppaPartners") && project.getPPAPartners() != null) { // project.getPPAPartners().clear(); // } if (ActionContext.getContext().getName().equals("partners") && project.getProjectPartners() != null) { project.getProjectPartners().clear(); } } // Getting the Project lessons for this section. int evaluatingYear = 0; if (this.getCycleName().equals(APConstants.REPORTING_SECTION)) { evaluatingYear = this.getCurrentReportingYear(); } else { evaluatingYear = this.getCurrentPlanningYear(); } // Getting the Project lessons for this section. this.setProjectLessons(lessonManager.getProjectComponentLesson(projectID, this.getActionName(), evaluatingYear, this.getCycleName())); if (this.getCycleName().equals(APConstants.REPORTING_SECTION)) { this.setProjectLessonsPreview(lessonManager.getProjectComponentLesson(projectID, this.getActionName(), this.getCurrentReportingYear(), APConstants.PLANNING_SECTION)); } // Initializing Section Statuses: this.initializeProjectSectionStatuses(project, this.getCycleName()); // Set History. super.setHistory(historyManager.getProjectPartnersHistory(project.getId())); }
From source file:org.cgiar.ccafs.ap.action.projects.ProjectSubmissionAction.java
@Override public void prepare() throws Exception { super.prepare(); try {//www . j a va2 s . c om projectID = Integer .parseInt(StringUtils.trim(this.getRequest().getParameter(APConstants.PROJECT_REQUEST_ID))); } catch (NumberFormatException e) { LOG.error("-- prepare() > There was an error parsing the project identifier '{}'.", projectID, e); projectID = -1; return; // Stop here and go to execute method. } int year = 0; if (this.isReportingCycle()) { year = config.getReportingCurrentYear(); } else { year = config.getPlanningCurrentYear(); } // Getting the project information. project = projectManager.getProject(projectID); project.setProjectPartners(partnerManager.getProjectPartners(project, year)); // Initializing Section Statuses: this.initializeProjectSectionStatuses(project, this.getCycleName()); }
From source file:org.cgiar.ccafs.ap.action.reporting.activities.deliverables.DeliverableDataReportingAction.java
@Override public void prepare() throws Exception { activityID = Integer/*from w w w . j a va 2 s . c o m*/ .parseInt(StringUtils.trim(this.getRequest().getParameter(APConstants.ACTIVITY_REQUEST_ID))); deliverableID = Integer .parseInt(StringUtils.trim(this.getRequest().getParameter(APConstants.DELIVERABLE_REQUEST_ID))); deliverable = deliverableManager.getDeliverable(deliverableID); deliverable.setFiles(deliverableFileManager.getDeliverableFiles(deliverable.getId())); filesUploaded = new ArrayList<>(); filesUploadedContentType = new ArrayList<>(); filesUploadedFileName = new ArrayList<>(); /* --------- Checking if the user can submit ------------- */ Submission submission = submissionManager.getSubmission(getCurrentUser().getLeader(), getCurrentReportingLogframe(), APConstants.REPORTING_SECTION); canSubmit = (submission == null) ? true : false; if (getRequest().getMethod().equalsIgnoreCase("post")) { // Clear out the list if it has some element if (deliverable.getFiles() != null) { deliverable.getFiles().clear(); } } }