Example usage for org.apache.commons.lang3 StringUtils trim

List of usage examples for org.apache.commons.lang3 StringUtils trim

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils trim.

Prototype

public static String trim(final String str) 

Source Link

Document

Removes control characters (char <= 32) from both ends of this String, handling null by returning null .

The String is trimmed using String#trim() .

Usage

From source file:org.cgiar.ccafs.ap.action.reporting.activities.deliverables.DeliverableInformationReportingAction.java

@Override
public void prepare() throws Exception {
    activityID = Integer//from   w  w w .j a va  2s  . 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)));

    // TODO - Create an interceptor that verifies if the deliverable belongs to the activity identified by the value
    // received as parameter
    deliverable = deliverableManager.getDeliverable(deliverableID);
    deliverableTypes = deliverableTypeManager.getDeliverableTypes();
    deliverableSubTypes = deliverableTypeManager
            .getDeliverableSubTypesByType(deliverable.getType().getParent().getId());
    deliverableStatusList = deliverableStatusManager.getDeliverableStatus();
    deliverable.setMetadata(deliverableMetadataManager.getDeliverableMetadata(deliverableID));
    deliverable.setAccessDetails(deliverableAccessManager.getDeliverableAccessData(deliverableID));

    if (deliverable.isPublication()) {
        publication = publicationManager.getPublicationByDeliverableID(deliverableID);
    } else {
        publication = new Publication(-1);
    }

    // Create options for the yes/no radio buttons
    yesNoRadio = new LinkedHashMap<>();
    yesNoRadio.put(true, getText("reporting.activityDeliverables.yes"));
    yesNoRadio.put(false, getText("reporting.activityDeliverables.no"));

    // Create options for the not applicable radio buttons
    notApplicableRadio = new LinkedHashMap<>();
    notApplicableRadio.put("Yes", getText("reporting.activityDeliverables.yes"));
    notApplicableRadio.put("No", getText("reporting.activityDeliverables.no"));
    notApplicableRadio.put("Not applicable", getText("reporting.activityDeliverables.notApplicable"));

    // Create options for the access limit radio buttons
    accessLimitsRadio = new LinkedHashMap<>();
    accessLimitsRadio.put("inmediate", getText("reporting.deliverables.dataAccess.accessLimits.inmediate"));
    accessLimitsRadio.put("embargued", getText("reporting.deliverables.dataAccess.accessLimits.embargoed"));
    accessLimitsRadio.put("restricted", getText("reporting.deliverables.dataAccess.accessLimits.restricted"));

    metadataList = metadataManager.getMetadataList();
    metadataRequired = metadataManager.getRequiredMetadata(deliverable.getType().getId());

    // publication = new Publication();
    PublicationTheme[] publicationThemeListObjects = publicationThemeManager.getPublicationThemes();
    publicationThemeList = new TreeMap<>();

    for (PublicationTheme pubTheme : publicationThemeListObjects) {
        String themeName = getText("reporting.publications.Theme") + " " + pubTheme.getCode() + ": "
                + pubTheme.getName();
        publicationThemeList.put(String.valueOf(pubTheme.getId()), themeName);
    }

    publicationTypes = publicationTypeManager.getPublicationTypes();
    publicationAccessList = openAccessManager.getOpenAccessList();

    // Publication types which need an access type specification
    // ID = 1 - Journal paper
    publicationTypeAccessNeed = new int[1];
    publicationTypeAccessNeed[0] = publicationTypes[0].getId();

    // Remove the publication so it can be added again in the save method.
    if (this.getRequest().getMethod().equalsIgnoreCase("post")) {
        if (deliverable.isPublication()) {
            publication.setIsiPublication(false);
            publication.setNarsCoauthor(false);
            publication.setEarthSystemCoauthor(false);
            publication.setCcafsAcknowledge(false);
        }
    }

    previousDeliverableType = new DeliverableType(deliverable.getType().getId());
    previousDeliverableType.setName(deliverable.getType().getName());

    /* --------- Checking if the user can submit ------------- */
    Submission submission = submissionManager.getSubmission(getCurrentUser().getLeader(),
            getCurrentReportingLogframe(), APConstants.REPORTING_SECTION);

    canSubmit = (submission == null) ? true : false;
}

From source file:org.cgiar.ccafs.ap.action.reporting.activities.deliverables.DeliverableRankReportingAction.java

@Override
public void prepare() throws Exception {
    deliverableID = Integer/*w ww  .  j a  va  2 s. com*/
            .parseInt(StringUtils.trim(this.getRequest().getParameter(APConstants.DELIVERABLE_REQUEST_ID)));

    deliverable = deliverableManager.getDeliverable(deliverableID);
    deliverable.setTrafficLight(trafficLightManager.getDeliverableTrafficLight(deliverableID));
    deliverable.setScores(deliverableScoreManager.getDeliverableScores(deliverableID));

    // Create options for the yes/no radio buttons
    yesNoRadio = new LinkedHashMap<>();
    yesNoRadio.put(true, getText("reporting.activityDeliverables.yes"));
    yesNoRadio.put(false, getText("reporting.activityDeliverables.no"));

    /* --------- Checking if the user can submit ------------- */
    Submission submission = submissionManager.getSubmission(getCurrentUser().getLeader(),
            getCurrentReportingLogframe(), APConstants.REPORTING_SECTION);

    canSubmit = (submission == null) ? true : false;
}

From source file:org.cgiar.ccafs.ap.action.reporting.activities.DeliverablesListReportingAction.java

@Override
public void prepare() throws Exception {
    activityID = Integer/*from  w  w w.j av  a2  s  .com*/
            .parseInt(StringUtils.trim(this.getRequest().getParameter(APConstants.ACTIVITY_REQUEST_ID)));
    activity = activityManager.getSimpleActivity(activityID);

    LOG.info("There user {} is loading the list of deliverables for the activity {}",
            getCurrentUser().getEmail(), String.valueOf(activityID));

    activity.setDeliverables(deliverableManager.getDeliverablesByActivityID(activityID));

    // Only report the deliverables for the current year
    for (int c = 0; c < activity.getDeliverables().size(); c++) {
        if (activity.getDeliverables().get(c).getYear() != getCurrentReportingLogframe().getYear()) {
            activity.getDeliverables().remove(c);
            c--;
        }
    }

    /* --------- Checking if the user can submit ------------- */
    Submission submission = submissionManager.getSubmission(getCurrentUser().getLeader(),
            getCurrentReportingLogframe(), APConstants.REPORTING_SECTION);
    canSubmit = (submission == null) ? true : false;
}

From source file:org.cgiar.ccafs.ap.action.reporting.tlrpl.TLDeliverableOverviewReportingAction.java

@Override
public void prepare() {
    deliverableID = Integer/*from w w  w .  j av  a2  s. co  m*/
            .parseInt(StringUtils.trim(this.getRequest().getParameter(APConstants.DELIVERABLE_REQUEST_ID)));

    deliverable = deliverableManager.getDeliverable(deliverableID);
    activity = activityManager.getActivityByDeliverable(deliverableID);

    deliverable.setMetadata(deliverableMetadataManager.getDeliverableMetadata(deliverableID));
}

From source file:org.cgiar.ccafs.ap.action.summaries.projects.BudgetByMOGsSummaryAction.java

@Override
public void prepare() {
    int year = config.getPlanningCurrentYear();
    String strYear = StringUtils.trim(this.getRequest().getParameter(APConstants.YEAR_REQUEST));
    if (strYear != null) {
        year = Integer.parseInt(strYear);
    }//w w  w.ja  v  a 2s  .  com
    informationBudgetReportByMOG = projectManager.summaryGetInformationPOWB(year);
    informationBudgetReportByMOGDetail = projectManager.summaryGetInformationPOWBDetail(year);
}

From source file:org.cgiar.ccafs.ap.action.summaries.projects.BudgetPerPartnersSummaryAction.java

@Override
public String getFileName() {
    String strYear = StringUtils.trim(this.getRequest().getParameter(APConstants.YEAR_REQUEST));
    year = config.getPlanningCurrentYear();

    if (strYear != null) {
        year = Integer.parseInt(strYear);
    }/*  w ww  .java 2s . c om*/
    StringBuffer fileName = new StringBuffer();
    fileName.append("BudgetPerPartnersSummary");
    fileName.append(year + "-");
    fileName.append(new SimpleDateFormat("yyyyMMdd-HHmm").format(new Date()));
    fileName.append(".xlsx");

    return fileName.toString();

}

From source file:org.cgiar.ccafs.ap.action.summaries.projects.BudgetPerPartnersSummaryAction.java

@Override
public void prepare() {
    String strYear = StringUtils.trim(this.getRequest().getParameter(APConstants.YEAR_REQUEST));
    year = config.getPlanningCurrentYear();

    if (strYear != null) {
        year = Integer.parseInt(strYear);
    }//  w  w w.  jav  a  2 s . c  o m

    informationBudgetByPartners = this.projectManager.summaryGetProjectBudgetPerPartners(year);

}

From source file:org.cgiar.ccafs.ap.action.summaries.projects.ImpactPathwayContributionsSummaryAction.java

@Override
public void prepare() {

    String strYear = StringUtils.trim(this.getRequest().getParameter(APConstants.YEAR_REQUEST));
    int year = config.getPlanningCurrentYear();

    if (strYear != null) {
        year = Integer.parseInt(strYear);
    }//from w  w  w.  j  a v  a  2 s.  c  o m
    projectListMap = projectManager.summaryGetAllCCAFSOutcomes(year);
}

From source file:org.cgiar.ccafs.ap.action.summaries.projects.ProjectEvaluationSummaryAction.java

@Override
public void prepare() {

    projectId = Integer
            .parseInt(StringUtils.trim(this.getRequest().getParameter(APConstants.PROJECT_REQUEST_ID)));

}