Example usage for org.apache.commons.lang WordUtils capitalizeFully

List of usage examples for org.apache.commons.lang WordUtils capitalizeFully

Introduction

In this page you can find the example usage for org.apache.commons.lang WordUtils capitalizeFully.

Prototype

public static String capitalizeFully(String str) 

Source Link

Document

Converts all the whitespace separated words in a String into capitalized words, that is each word is made up of a titlecase character and then a series of lowercase characters.

Usage

From source file:com.redsqirl.CanvasModal.java

public void changeTitle() {

    logger.info("changeTitle");
    String error = null;//from   www .j  a  v a2  s  .c  o  m
    try {
        DataFlowElement dfe = canvasBean.getDf().getElement(canvasBean.getIdElement(idGroup));
        if (dfe != null) {
            setCanvasTitle(
                    WordUtils.capitalizeFully(dfe.getName().replace("_", " ")) + ": " + dfe.getComponentId());
        } else {
            logger.error("Element is null!");
            error = getMessageResources("msg_error_oops");
        }
    } catch (Exception e) {
        error = e.getMessage();
        logger.error(e, e);
    }

    displayErrorMessage(error, "CHANGETITLE");
}

From source file:com.sfs.whichdoctor.dao.onlineapplication.BasicTrainingOnlineApplicationHandler.java

/**
 * Load the qualification details from the XML application.
 *
 * @param root the root of the XML application
 * @param guid the guid/*w w  w  .  ja  v a2s. co m*/
 * @param recordId the record id
 * @return the qualification bean
 */
private QualificationBean loadQualificationDetails(final Element root, final int guid, final String recordId) {

    QualificationBean qlf = new QualificationBean();

    qlf.setReferenceGUID(guid);
    qlf.setQualificationType("Undergraduate");
    qlf.setQualificationSubType("Basic Medical Qualification");

    List<?> records = root.getChildren("educationrecord");
    for (Object obj : records) {
        // Get the qualification record
        Element record = (Element) obj;

        String recordNumber = "";
        try {
            recordNumber = record.getChildText("recordnumber").trim();
        } catch (Exception e) {
            dataLogger.error("Error parsing recordnumber: " + e.getMessage());
        }

        if (StringUtils.equalsIgnoreCase(recordNumber, recordId)) {
            try {
                qlf.setQualification(record.getChildText("qualifications").trim());
            } catch (Exception e) {
                dataLogger.error("Error parsing qualifications: " + e.getMessage());
            }
            try {
                qlf.setInstitution(record.getChildText("Institution").trim());
            } catch (Exception e) {
                dataLogger.error("Error parsing Institution: " + e.getMessage());
            }
            try {
                qlf.setCountry(WordUtils.capitalizeFully(record.getChildText("Country").trim()));
            } catch (Exception e) {
                dataLogger.error("Error parsing Country: " + e.getMessage());
                qlf.setCountry("New Zealand");
            }
            try {
                qlf.setYear(Integer.parseInt(record.getChildText("year").trim()));
            } catch (Exception e) {
                dataLogger.error("Error parsing year: " + e.getMessage());
            }
        }
    }

    if (StringUtils.isBlank(qlf.getQualification())) {
        // This is not a valid qualification
        qlf = null;
    }

    return qlf;
}

From source file:com.redsqirl.workflow.server.ActionManager.java

public Map<String, Map<String, String[]>> getRelativeHelp(File curPath,
        Map<String, Map<String, String[]>> absoluteHelp) {
    if (curPath == null) {
        return absoluteHelp;
    }//from  w  ww .j  a  va 2  s .  c  om

    logger.debug("Load help " + curPath.getPath());
    Map<String, Map<String, String[]>> ans = new LinkedHashMap<String, Map<String, String[]>>();
    Iterator<String> helpit = absoluteHelp.keySet().iterator();
    while (helpit.hasNext()) {
        String key = helpit.next();
        try {

            // logger.info("getRelativeHelp " + key);

            Map<String, String[]> out = new LinkedHashMap<String, String[]>();

            Map<String, String[]> aux = absoluteHelp.get(key);
            Iterator<String> it = aux.keySet().iterator();
            while (it.hasNext()) {
                String action = it.next();

                out.put(action,
                        new String[] { action, WordUtils.capitalizeFully(action.replace("_", " ")),
                                LocalFileSystem.relativize(curPath, aux.get(action)[0]),
                                LocalFileSystem.relativize(curPath, aux.get(action)[1]) });
            }

            ans.put(key, out);

        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            logger.error("Error Getting relative paths for Help");
        }
    }
    return ans;
}

From source file:com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource.java

@Override
protected void retrieve(@CheckForNull SCMSourceCriteria criteria, @NonNull SCMHeadObserver observer,
        @CheckForNull SCMHeadEvent<?> event, @NonNull TaskListener listener)
        throws IOException, InterruptedException {
    try (BitbucketSCMSourceRequest request = new BitbucketSCMSourceContext(criteria, observer)
            .withTraits(traits).newRequest(this, listener)) {
        StandardCredentials scanCredentials = credentials();
        if (scanCredentials == null) {
            listener.getLogger().format("Connecting to %s with no credentials, anonymous access%n",
                    getServerUrl());//from  www. ja va 2 s . c o m
        } else {
            listener.getLogger().format("Connecting to %s using %s%n", getServerUrl(),
                    CredentialsNameProvider.name(scanCredentials));
        }
        // this has the side-effect of ensuring that repository type is always populated.
        listener.getLogger().format("Repository type: %s%n",
                WordUtils.capitalizeFully(getRepositoryType().name()));

        // populate the request with its data sources
        if (request.isFetchPRs()) {
            request.setPullRequests(new LazyIterable<BitbucketPullRequest>() {
                @Override
                protected Iterable<BitbucketPullRequest> create() {
                    try {
                        return (Iterable<BitbucketPullRequest>) buildBitbucketClient().getPullRequests();
                    } catch (IOException | InterruptedException e) {
                        throw new BitbucketSCMSource.WrappedException(e);
                    }
                }
            });
        }
        if (request.isFetchBranches()) {
            request.setBranches(new LazyIterable<BitbucketBranch>() {
                @Override
                protected Iterable<BitbucketBranch> create() {
                    try {
                        return (Iterable<BitbucketBranch>) buildBitbucketClient().getBranches();
                    } catch (IOException | InterruptedException e) {
                        throw new BitbucketSCMSource.WrappedException(e);
                    }
                }
            });
        }
        if (request.isFetchTags()) {
            request.setTags(new LazyIterable<BitbucketBranch>() {
                @Override
                protected Iterable<BitbucketBranch> create() {
                    try {
                        return (Iterable<BitbucketBranch>) buildBitbucketClient().getTags();
                    } catch (IOException | InterruptedException e) {
                        throw new BitbucketSCMSource.WrappedException(e);
                    }
                }
            });
        }

        // now server the request
        if (request.isFetchBranches() && !request.isComplete()) {
            // Search branches
            retrieveBranches(request);
        }
        if (request.isFetchPRs() && !request.isComplete()) {
            // Search pull requests
            retrievePullRequests(request);
        }
        if (request.isFetchTags() && !request.isComplete()) {
            // Search tags
            retrieveTags(request);
        }
    } catch (WrappedException e) {
        e.unwrap();
    }
}

From source file:ca.unbsj.cbakerlab.owlexprmanager.ClassExpressionTreeGenerator.java

private String getSimpleName(String name) {
    String newName = Pattern.compile("[^\\w-]").matcher(name).replaceAll(" ");
    if (!newName.equals(name)) {
        newName = WordUtils.capitalizeFully(newName);
        newName = Pattern.compile("\\s+").matcher(newName).replaceAll("");
    }//from ww w .j  av a  2  s .  co  m
    return newName;
}

From source file:com.sfs.whichdoctor.dao.onlineapplication.BasicTrainingOnlineApplicationHandler.java

/**
 * Load the address details from the XML application.
 *
 * @param root the root of the XML application
 * @param guid the guid// w  ww  .  ja  va2s  .c om
 * @return the address bean
 */
private AddressBean loadAddressDetails(final Element root, final int guid) {
    AddressBean address = new AddressBean();

    Element pd = root.getChild("personaldetails");

    address.setReferenceGUID(guid);
    address.setContactClass("Home");
    address.setContactType("Postal");
    address.setPrimary(true);

    try {
        address.setAddressField(pd.getChildText("streetaddress1").trim());
    } catch (Exception e) {
        dataLogger.error("Error parsing streetaddress1: " + e.getMessage());
    }
    try {
        address.setAddressField(pd.getChildText("streetaddress2").trim());
    } catch (Exception e) {
        dataLogger.error("Error parsing streetaddress2: " + e.getMessage());
    }
    try {
        address.setAddressField(pd.getChildText("streetaddress3").trim());
    } catch (Exception e) {
        dataLogger.error("Error parsing streetaddress3: " + e.getMessage());
    }
    try {
        address.setAddressField(pd.getChildText("streetaddress4").trim());
    } catch (Exception e) {
        dataLogger.error("Error parsing streetaddress4: " + e.getMessage());
    }
    try {
        address.setAddressField(pd.getChildText("suburb").trim());
    } catch (Exception e) {
        dataLogger.error("Error parsing suburb: " + e.getMessage());
    }
    try {
        address.setState(pd.getChildText("state").trim());
    } catch (Exception e) {
        dataLogger.error("Error parsing state: " + e.getMessage());
    }
    try {
        String country = pd.getChildText("countryid");
        address.setCountry(WordUtils.capitalizeFully(country).trim());
    } catch (Exception e) {
        dataLogger.error("Error parsing countryid: " + e.getMessage());
    }
    try {
        address.setPostCode(pd.getChildText("postcode").trim());
    } catch (Exception e) {
        dataLogger.error("Error parsing postcode: " + e.getMessage());
    }

    address.setState(this.addressDAO.getState(address.getCity(), address.getCountry()));

    if (StringUtils.isBlank(address.getAddressField(0))) {
        // The address is not valid, return null
        address = null;
    }

    return address;
}

From source file:com.sfs.whichdoctor.dao.AddressVerificationDAOImpl.java

/**
 * Capitalise the supplied field if all caps.
 *
 * @param s the string/* w w  w.  j  a v  a  2  s .c o m*/
 * @return the string
 */
private static String capitalise(final String s) {
    String value = s;
    if (StringUtils.isNotBlank(s) && isAllUpper(s)) {
        value = WordUtils.capitalizeFully(s);
    }
    return value;
}

From source file:com.all.login.view.NewAccountFormPanel.java

private void capitalizeText(JTextField field) {
    field.setText(WordUtils.capitalizeFully(field.getText()));
}

From source file:com.redsqirl.workflow.server.Workflow.java

public String generateHelp(String wfName, String description, Map<String, DFEOutput> inputs,
        Map<String, DFEOutput> outputs, DataFlowCoordinatorVariables vars) throws RemoteException {
    String help = "<h1>" + WordUtils.capitalizeFully(wfName.replace("_", " ")) + "</h1>";
    Collection<DataFlowCoordinatorVariable> varList = vars.getVariables();
    if (description != null && !description.isEmpty()) {
        help += "<p>" + description + "</p>";
    }//from   w w w  . ja  va2  s. com

    help += "<p>" + wfName + " takes ";
    if (inputs.isEmpty()) {
        help += "no inputs";
    } else {
        help += inputs.size() + " input";
        if (inputs.size() > 1) {
            help += "s";
        }
    }
    if (varList.isEmpty()) {
        help += " and ";
    } else {
        help += ", ";
    }
    if (outputs.isEmpty()) {
        help += "no outputs";
    } else {
        help += inputs.size() + " output";
        if (outputs.size() > 1) {
            help += "s";
        }
    }
    if (!varList.isEmpty()) {
        help += " and " + varList.size() + " variable";
        if (varList.size() > 1) {
            help += "s";
        }
    }
    help += ".</p>";

    String tableCellStyle = " style='border: 1px solid;   border-collapse: collapse;' ";
    if (!inputs.isEmpty()) {
        help += "<h2>Inputs</h2>";
        for (Entry<String, DFEOutput> input : inputs.entrySet()) {
            help += "<h3>" + input.getKey() + "</h3>";
            help += input.getKey() + " is a <b>" + input.getValue().getTypeName() + "</b> dataset.";
            FieldList fl = input.getValue().getFields();
            if (fl != null && !fl.getFieldNames().isEmpty()) {
                help += "<table" + tableCellStyle + ">";
                help += "<tr><td" + tableCellStyle + ">Field Name</td><td" + tableCellStyle + ">Type</td><td"
                        + tableCellStyle + ">Description</td></tr>";
                for (String fieldName : fl.getFieldNames()) {
                    help += "<tr><td" + tableCellStyle + ">" + fieldName + "</td><td" + tableCellStyle + ">"
                            + fl.getFieldType(fieldName) + "</td><td" + tableCellStyle + "></td></tr>";
                }
                help += "</table>";
            }
        }
    }

    if (!outputs.isEmpty()) {
        help += "<h2>Outputs</h2>";
        for (Entry<String, DFEOutput> output : outputs.entrySet()) {
            help += "<h3>" + output.getKey() + "</h3>";
            help += output.getKey() + " is a <b>" + output.getValue().getTypeName() + "</b> dataset.";
            FieldList fl = output.getValue().getFields();
            if (fl != null && !fl.getFieldNames().isEmpty()) {
                help += "<table" + tableCellStyle + ">";
                help += "<tr><td" + tableCellStyle + ">Field Name</td><td" + tableCellStyle + ">Type</td><td"
                        + tableCellStyle + ">Description</td></tr>";
                for (String fieldName : fl.getFieldNames()) {
                    help += "<tr><td" + tableCellStyle + ">" + fieldName + "</td><td" + tableCellStyle + ">"
                            + fl.getFieldType(fieldName) + "</td><td" + tableCellStyle + "></td></tr>";
                }
                help += "</table>";
            }
        }
    }

    if (!varList.isEmpty()) {
        help += "<h2>Variables</h2>";
        help += "<table" + tableCellStyle + ">";
        help += "<tr><td" + tableCellStyle + ">Variable Name</td><td" + tableCellStyle
                + ">Default Value</td><td" + tableCellStyle + ">Description</td></tr>";
        for (DataFlowCoordinatorVariable varCur : varList) {
            help += "<tr><td" + tableCellStyle + ">" + varCur.getKey() + "</td><td" + tableCellStyle + ">"
                    + varCur.getValue() + "</td><td" + tableCellStyle + ">" + varCur.getDescription()
                    + "</td></tr>";
        }
        help += "</table>";
    }

    return help;
}

From source file:com.redsqirl.CanvasBean.java

private Object[] getOutputStatus(String wfName, DataFlowElement dfe, String groupId, boolean checkRuningstatus,
        Map<String, String> inverseIdMap) throws RemoteException {

    logger.info("getOutputStatus");

    String outputType = null;/*from   ww  w.j a  va 2 s  .co m*/
    String pathExistsStr = null;
    String runningStatus = null;
    StringBuffer tooltip = new StringBuffer();
    String errorOut = null;
    String[][] arrows = null;
    String externalLink = null;
    boolean isSchedule = false;

    if (dfe != null && dfe.getDFEOutput() != null) {
        String elementName = dfe.getName();
        String tooltipeName1 = elementName.startsWith(">")
                ? elementName.substring(elementName.lastIndexOf(">") + 1)
                : elementName;
        String tooltipName = WordUtils.capitalizeFully(tooltipeName1.replace('_', ' '));
        tooltip.append("<center><span style='font-size:15px;'>" + tooltipName + ": " + dfe.getComponentId()
                + "</span></center><br/>");

        HttpSession session = (HttpSession) FacesContext.getCurrentInstance().getExternalContext()
                .getSession(false);
        String user = (String) session.getAttribute("username");

        String module = "";
        if (dfe.getName() != null && dfe.getName().startsWith(">")) {
            module += RedSqirlModel.getModelAndSW(dfe.getName())[0];
        } else {
            PackageManager pcm = new PackageManager();
            module += pcm.getPackageOfAction(user, dfe.getName());
        }
        if (!module.isEmpty()) {
            tooltip.append("Module: " + module + "<br/>");
        }

        String comment = dfe.getComment();
        if (comment != null && !comment.isEmpty()) {
            tooltip.append("<br/><i>" + comment + "</i><br/>");
        }

        try {
            errorOut = dfe.checkEntry(wfName);
            if (errorOut == null) {
                errorOut = dfe.updateOut();
            }
        } catch (Exception e) {
            logger.error(e, e);
            errorOut = "Unexpected program error while checking this action.";
        }

        if (errorOut != null) {
            tooltip.append("<br/><b>Error:</b><br/><span style='word-wrap:break-word;'>"
                    + errorOut.replaceAll("\n", "<br/>") + "</span><br/>");
        }

        boolean pathExists = false;
        String stateCur = null;
        boolean curPathExist = false;

        for (Entry<String, DFEOutput> e : dfe.getDFEOutput().entrySet()) {
            String pathTypeCur = e.getValue().getPathType().toString();
            curPathExist = "W".equals(workflowType) && PathType.REAL.toString().equalsIgnoreCase(pathTypeCur)
                    && e.getValue().isPathExist();
            stateCur = e.getValue().getSavingState().toString();

            logger.info("path: " + e.getValue().getPath());

            //Arcs regarding path calculations
            {
                pathExists |= curPathExist;
                if (stateCur != null) {
                    if (outputType == null) {
                        outputType = stateCur;
                    } else if (outputType.equalsIgnoreCase(SavingState.BUFFERED.toString())
                            && stateCur.equalsIgnoreCase(SavingState.RECORDED.toString())) {
                        outputType = stateCur;
                    } else if (outputType.equalsIgnoreCase(SavingState.TEMPORARY.toString())
                            && (stateCur.equalsIgnoreCase(SavingState.RECORDED.toString())
                                    || stateCur.equalsIgnoreCase(SavingState.BUFFERED.toString()))) {
                        outputType = stateCur;
                    }
                }
            }

            {
                tooltip.append("<br/>");
                if (!e.getKey().isEmpty()) {
                    tooltip.append("Output Name: " + e.getKey() + "<br/>");
                } else {
                    tooltip.append("<span style='font-size:14px;'>&nbsp;Output " + "</span><br/>");
                }
            }
            tooltip.append("Output Type: " + e.getValue().getTypeName() + "<br/>");

            if ("W".equals(workflowType)) {
                if (!PathType.REAL.toString().equalsIgnoreCase(pathTypeCur)) {
                    tooltip.append("Output Path: " + e.getValue().getPath() + "<br/>");
                } else {
                    if (curPathExist) {
                        tooltip.append("Output Path: <span style='color:#008B8B'>" + e.getValue().getPath()
                                + "</span><br/>");
                    } else {
                        tooltip.append("Output Path: <span style='color:#d2691e'>" + e.getValue().getPath()
                                + "</span><br/>");
                    }
                }

                tooltip.append("Output State: ");
                if (SavingState.RECORDED.toString().equalsIgnoreCase(stateCur)) {
                    tooltip.append("<span style='color:#f08080'>");
                } else if (SavingState.BUFFERED.toString().equalsIgnoreCase(stateCur)) {
                    tooltip.append("<span style='color:#4682b4'>");
                } else if (SavingState.TEMPORARY.toString().equalsIgnoreCase(stateCur)) {
                    tooltip.append("<span style='color:#800080'>");
                }
                tooltip.append(stateCur + "</span><br/>");

                if (!PathType.REAL.toString().equalsIgnoreCase(pathTypeCur)) {
                    CoordinatorTimeConstraint ctcCur = e.getValue().getFrequency();
                    if (ctcCur.getUnit() != null) {
                        String frequencyStr = "Every " + ctcCur.getFrequency() + " "
                                + ctcCur.getUnit().toString().toLowerCase();
                        tooltip.append("Frequency: " + frequencyStr + "<br/>");
                        if (PathType.MATERIALIZED.toString().equalsIgnoreCase(pathTypeCur)) {
                            tooltip.append(
                                    "Number of dataset: " + e.getValue().getNumberMaterializedPath() + "<br/>");
                        }
                    }
                }
            }

            if (e.getValue().getFields() != null && e.getValue().getFields().getFieldNames() != null
                    && !e.getValue().getFields().getFieldNames().isEmpty()) {
                tooltip.append("<br/>");
                tooltip.append("<table style='border:1px solid;width:100%;'>");
                if (e.getKey() != null) {
                    tooltip.append("<tr><td colspan='1'>" + e.getKey() + "</td></tr>");
                }
                tooltip.append("<tr><td></td><td> Fields </td><td> Type </td></tr>");
                int row = 0;
                int index = 1;
                for (String name : e.getValue().getFields().getFieldNames()) {
                    if ((row % 2) == 0) {
                        tooltip.append("<tr class='odd-row'>");
                    } else {
                        tooltip.append("<tr>");
                    }
                    tooltip.append("<td>" + index + "</td>");
                    tooltip.append("<td style='max-width:200px;word-wrap:break-word;'>" + name + "</td>");
                    tooltip.append("<td>" + e.getValue().getFields().getFieldType(name) + "</td></tr>");
                    row++;
                    index++;
                }
                tooltip.append("</table>");
                tooltip.append("<br/>");
            }

            DFEOutput dfeOut = e.getValue();
            String link = null;
            try {
                link = ((DFELinkOutput) dfeOut).getLink();
            } catch (Exception exc) {
                //logger.error("");
            }
            if (link != null) {
                externalLink = link;
            }

        }

        arrows = new String[dfe.getAllOutputComponent().size()][];
        int i = 0;

        Iterator<String> outIt = dfe.getOutputComponent().keySet().iterator();
        while (outIt.hasNext()) {
            String outName = outIt.next();
            Iterator<DataFlowElement> outElIt = dfe.getOutputComponent().get(outName).iterator();
            while (outElIt.hasNext()) {
                arrows[i] = getArrowType(inverseIdMap.get(dfe.getComponentId()),
                        inverseIdMap.get(outElIt.next().getComponentId()), outName);
                ++i;
            }
        }

        if (!dfe.getDFEOutput().isEmpty()) {
            pathExistsStr = String.valueOf(pathExists);
        }

        if (checkRuningstatus) {
            try {
                runningStatus = getDf().getRunningStatus(dfe.getComponentId());
            } catch (Exception e1) {
                logger.warn("Error getting the status: " + e1.getMessage(), e1);
            }
        }

        //logger.info("element " + dfe.getComponentId());
        //logger.info("state " + outputType);
        //logger.info("pathExists " + String.valueOf(pathExistsStr));

        isSchedule = df.isSchedule();

    }
    logger.info("output status result " + groupId + " - " + outputType + " - " + pathExistsStr + " - "
            + runningStatus);

    return new Object[] { groupId, outputType, pathExistsStr, runningStatus, tooltip.toString(),
            Boolean.toString(errorOut == null), arrows, externalLink, isSchedule };
}