Example usage for org.apache.commons.lang StringUtils equalsIgnoreCase

List of usage examples for org.apache.commons.lang StringUtils equalsIgnoreCase

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils equalsIgnoreCase.

Prototype

public static boolean equalsIgnoreCase(String str1, String str2) 

Source Link

Document

Compares two Strings, returning true if they are equal ignoring the case.

Usage

From source file:eionet.meta.imp.VocabularyCSVImportHandler.java

/**
 * In this method, beans are generated (either created or updated) according to values in CSV file.
 *
 * @throws eionet.meta.service.ServiceException
 *             if there is the input is invalid
 *//* ww w.j  a va2 s  .  c o  m*/
public void generateUpdatedBeans() throws ServiceException {
    // content.
    CSVReader reader = new CSVReader(this.content);
    DateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd");

    try {
        String[] header = reader.readNext();

        // first check if headers contains fix columns
        String[] fixedHeaders = new String[VocabularyCSVOutputHelper.CONCEPT_ENTRIES_COUNT];
        VocabularyCSVOutputHelper.addFixedEntryHeaders(fixedHeaders);

        // compare if it has URI
        boolean isEqual = StringUtils.equalsIgnoreCase(header[VocabularyCSVOutputHelper.URI_INDEX],
                fixedHeaders[VocabularyCSVOutputHelper.URI_INDEX]);

        if (!isEqual) {
            reader.close();
            throw new ServiceException("Missing header! CSV file should start with header: '"
                    + fixedHeaders[VocabularyCSVOutputHelper.URI_INDEX] + "'");
        }

        List<String> fixedHeadersList = new ArrayList<String>(
                Arrays.asList(Arrays.copyOf(fixedHeaders, VocabularyCSVOutputHelper.CONCEPT_ENTRIES_COUNT)));
        // remove uri from header
        fixedHeadersList.remove(VocabularyCSVOutputHelper.URI_INDEX);
        Map<String, Integer> fixedHeaderIndices = new HashMap<String, Integer>();
        for (int i = VocabularyCSVOutputHelper.URI_INDEX + 1; i < header.length; i++) {
            String elementHeader = StringUtils.trimToNull(header[i]);
            if (StringUtils.isBlank(elementHeader)) {
                throw new ServiceException("Header for column (" + (i + 1) + ") is empty!");
            }

            int headerIndex = -1;
            boolean headerFound = false;
            for (headerIndex = 0; headerIndex < fixedHeadersList.size(); headerIndex++) {
                if (StringUtils.equalsIgnoreCase(elementHeader, fixedHeadersList.get(headerIndex))) {
                    headerFound = true;
                    break;
                }
            }

            // if it is a fixed header value (concept property), add to map and continue
            if (headerFound) {
                String headerValue = fixedHeadersList.remove(headerIndex);
                fixedHeaderIndices.put(headerValue, i);
                continue;
            }

            // it is not a concept attribute and but a data element identifier
            // if there is language appended, split it
            String[] tempStrArray = elementHeader.split("[@]");
            if (tempStrArray.length == 2) {
                elementHeader = tempStrArray[0];
            }

            // if bound elements do not contain header already, add it (if possible)
            if (!this.boundElementsIds.containsKey(elementHeader)) {
                // search for data element
                this.elementsFilter.setIdentifier(elementHeader);
                DataElementsResult elementsResult = this.dataService.searchDataElements(this.elementsFilter);
                // if there is one and only one element check if header and identifer exactly matches!
                if (elementsResult.getTotalResults() < 1) {
                    throw new ServiceException("Cannot find any data element for column: " + elementHeader
                            + ". Please bind element manually then upload CSV.");
                } else if (elementsResult.getTotalResults() > 1) {
                    throw new ServiceException("Cannot find single data element for column: " + elementHeader
                            + ". Search returns: " + elementsResult.getTotalResults()
                            + " elements. Please bind element manually then upload CSV.");
                } else {
                    DataElement elem = elementsResult.getDataElements().get(0);
                    if (StringUtils.equals(elementHeader, elem.getIdentifier())) {
                        // found it, add to list and map
                        this.boundElementsIds.put(elementHeader,
                                elementsResult.getDataElements().get(0).getId());
                        this.newBoundElement.add(elem);
                    } else {
                        throw new ServiceException("Found data element did not EXACTLY match with column: "
                                + elementHeader + ", found: " + elem.getIdentifier());
                    }
                }
            }
        } // end of for loop iterating on headers

        String[] lineParams;
        // first row is header so start from 2
        for (int rowNumber = 2; (lineParams = reader.readNext()) != null; rowNumber++) {
            if (lineParams.length != header.length) {
                StringBuilder message = new StringBuilder();
                message.append("Row (").append(rowNumber).append(") ");
                message.append("did not have same number of columns with header, it was skipped.");
                message.append(" It should have have same number of columns (empty or filled).");
                this.logMessages.add(message.toString());
                continue;
            }

            // do line processing
            String uri = lineParams[VocabularyCSVOutputHelper.URI_INDEX];
            if (StringUtils.isEmpty(uri)) {
                this.logMessages.add("Row (" + rowNumber + ") was skipped (Base URI was empty).");
                continue;
            } else if (StringUtils.startsWith(uri, "//")) {
                this.logMessages.add("Row (" + rowNumber
                        + ") was skipped (Concept was excluded by user from update operation).");
                continue;
            } else if (!StringUtils.startsWith(uri, this.folderContextRoot)) {
                this.logMessages
                        .add("Row (" + rowNumber + ") was skipped (Base URI did not match with Vocabulary).");
                continue;
            }

            String conceptIdentifier = uri.replace(this.folderContextRoot, "");
            if (StringUtils.contains(conceptIdentifier, "/") || !Util.isValidIdentifier(conceptIdentifier)) {
                this.logMessages.add("Row (" + rowNumber + ") did not contain a valid concept identifier.");
                continue;
            }

            // now we have a valid row
            Pair<VocabularyConcept, Boolean> foundConceptWithFlag = findOrCreateConcept(conceptIdentifier);

            // if vocabulary concept duplicated with another row, importer will ignore it not to repeat
            if (foundConceptWithFlag == null || foundConceptWithFlag.getRight()) {
                this.logMessages
                        .add("Row (" + rowNumber + ") duplicated with a previous concept, it was skipped.");
                continue;
            }

            VocabularyConcept lastFoundConcept = foundConceptWithFlag.getLeft();
            // vocabulary concept found or created
            this.toBeUpdatedConcepts.add(lastFoundConcept);

            Integer conceptPropertyIndex = null;
            // check label
            conceptPropertyIndex = fixedHeaderIndices.get(fixedHeaders[VocabularyCSVOutputHelper.LABEL_INDEX]);
            if (conceptPropertyIndex != null) {
                lastFoundConcept.setLabel(StringUtils.trimToNull(lineParams[conceptPropertyIndex]));
            }

            // check definition
            conceptPropertyIndex = fixedHeaderIndices
                    .get(fixedHeaders[VocabularyCSVOutputHelper.DEFINITION_INDEX]);
            if (conceptPropertyIndex != null) {
                lastFoundConcept.setDefinition(StringUtils.trimToNull(lineParams[conceptPropertyIndex]));
            }

            // check notation
            conceptPropertyIndex = fixedHeaderIndices
                    .get(fixedHeaders[VocabularyCSVOutputHelper.NOTATION_INDEX]);
            if (conceptPropertyIndex != null) {
                lastFoundConcept.setNotation(StringUtils.trimToNull(lineParams[conceptPropertyIndex]));
            }

            // TODO: update - with merging flexible csv import
            // check start date
            // ignore status and accepteddate changes

            // now it is time iterate on rest of the columns, here is the tricky part
            List<DataElement> elementsOfConcept = null;
            List<DataElement> elementsOfConceptByLang = null;
            String prevHeader = null;
            String prevLang = null;
            for (int k = VocabularyCSVOutputHelper.URI_INDEX + 1; k < lineParams.length; k++) {
                if (StringUtils.isEmpty(lineParams[k])) {
                    // value is empty, no need to proceed
                    continue;
                }

                if (fixedHeaderIndices.containsValue(k)) {
                    // concept property, already handled
                    continue;
                }

                String elementHeader = header[k];
                String lang = null;
                String[] tempStrArray = elementHeader.split("[@]");
                if (tempStrArray.length == 2) {
                    elementHeader = tempStrArray[0];
                    lang = tempStrArray[1];
                }

                if (!StringUtils.equals(elementHeader, prevHeader)) {
                    elementsOfConcept = getDataElementValuesByName(elementHeader,
                            lastFoundConcept.getElementAttributes());
                    if (elementsOfConcept == null) {
                        elementsOfConcept = new ArrayList<DataElement>();
                        lastFoundConcept.getElementAttributes().add(elementsOfConcept);
                    }
                }

                if (!StringUtils.equals(elementHeader, prevHeader) || !StringUtils.equals(lang, prevLang)) {
                    elementsOfConceptByLang = getDataElementValuesByNameAndLang(elementHeader, lang,
                            lastFoundConcept.getElementAttributes());
                }

                prevLang = lang;
                prevHeader = elementHeader;

                VocabularyConcept foundRelatedConcept = null;
                if (Util.isValidUri(lineParams[k])) {
                    foundRelatedConcept = findRelatedConcept(lineParams[k]);
                }

                // check for pre-existence of the VCE by attribute value or related concept id
                Integer relatedId = null;
                if (foundRelatedConcept != null) {
                    relatedId = foundRelatedConcept.getId();
                }
                boolean returnFromThisPoint = false;
                for (DataElement elemByLang : elementsOfConceptByLang) {
                    String elementValueByLang = elemByLang.getAttributeValue();
                    if (StringUtils.equals(lineParams[k], elementValueByLang)) {
                        // vocabulary concept element already in database, no need to continue, return
                        returnFromThisPoint = true;
                        break;
                    }

                    if (relatedId != null) {
                        Integer relatedConceptId = elemByLang.getRelatedConceptId();
                        if (relatedConceptId != null && relatedConceptId.intValue() == relatedId.intValue()) {
                            // vocabulary concept element already in database, no need to continue, return
                            returnFromThisPoint = true;
                            break;
                        }
                    }
                }
                // check if an existing VCE found or not
                if (returnFromThisPoint) {
                    continue;
                }

                // create VCE
                DataElement elem = new DataElement();
                elementsOfConcept.add(elem);
                elem.setAttributeLanguage(lang);
                elem.setIdentifier(elementHeader);
                elem.setId(this.boundElementsIds.get(elementHeader));
                // check if there is a found related concept
                if (foundRelatedConcept != null) {
                    elem.setRelatedConceptIdentifier(foundRelatedConcept.getIdentifier());
                    int id = foundRelatedConcept.getId();
                    elem.setRelatedConceptId(id);
                    elem.setAttributeValue(null);
                    if (id < 0) {
                        addToElementsReferringNotCreatedConcepts(id, elem);
                    }
                } else {
                    elem.setAttributeValue(lineParams[k]);
                    elem.setRelatedConceptId(null);
                }
            } // end of for loop iterating on rest of the columns (for data elements)
        } // end of row iterator (while loop on rows)
        processUnseenConceptsForRelatedElements();
    } catch (IOException e) {
        e.printStackTrace();
        throw new ServiceException(e.getMessage());
    } catch (RuntimeException e) {
        e.printStackTrace();
        throw new ServiceException(e.getMessage());
    } finally {
        try {
            reader.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

From source file:com.adobe.acs.commons.quickly.impl.QuicklyFilter.java

@SuppressWarnings("squid:S3923")
private boolean accepts(final HttpServletRequest request) {
    if (!StringUtils.equalsIgnoreCase("get", request.getMethod())) {
        // Only inject on GET requests
        return false;
    } else if (StringUtils.startsWithAny(request.getRequestURI(), REJECT_PATH_PREFIXES)) {
        return false;
    } else if (StringUtils.equals(request.getHeader("X-Requested-With"), "XMLHttpRequest")) {
        // Do not inject into XHR requests
        return false;
    } else if (StringUtils.endsWith(request.getHeader("Referer"), "/editor.html" + request.getRequestURI())) {
        // Do not apply to pages loaded in the TouchUI editor.html
        return false;
    } else if (StringUtils.endsWith(request.getHeader("Referer"), "/cf")) {
        // Do not apply to pages loaded in the Content Finder
        return false;
    }//  www  .ja  v  a2 s.c om
    return true;
}

From source file:hydrograph.ui.graph.action.PropagateDataAction.java

@Override
public void run() {
    boolean shouldsetContinuousSchemaPropagationFlagForNextConnectedComponents = true;
    Map<String, Schema> oldSchemaMap = new TreeMap<>();
    for (Link link : component.getTargetConnections()) {
        Schema previousComponentSchema = SubjobUtility.INSTANCE.getSchemaFromPreviousComponentSchema(component,
                link);/*  w  w  w.ja  va 2s.  c  o  m*/
        if (StringUtils.equalsIgnoreCase(component.getCategory(), Constants.STRAIGHTPULL)
                || StringUtils.equalsIgnoreCase(component.getComponentName(), Constants.FILTER)
                || StringUtils.equalsIgnoreCase(component.getComponentName(), Constants.UNIQUE_SEQUENCE)
                || StringUtils.equalsIgnoreCase(component.getComponentName(),
                        Constants.PARTITION_BY_EXPRESSION)) {

            if (StringUtils.equalsIgnoreCase(Constants.UNION_ALL, component.getComponentName())) {
                if (!SubjobUtility.INSTANCE.isUnionAllInputSchemaInSync(component)) {
                    component.getProperties().put(Constants.IS_UNION_ALL_COMPONENT_SYNC, Constants.FALSE);
                    ((ComponentEditPart) component.getComponentEditPart()).getFigure().repaint();
                    shouldsetContinuousSchemaPropagationFlagForNextConnectedComponents = false;
                    WidgetUtility.createMessageBox(Messages.INPUTS_SCHEMA_ARE_NOT_IN_SYNC, Constants.ERROR,
                            SWT.ICON_ERROR | SWT.OK);
                    break;
                } else {
                    component.getProperties().put(Constants.IS_UNION_ALL_COMPONENT_SYNC, Constants.TRUE);
                    ((ComponentEditPart) component.getComponentEditPart()).getFigure().repaint();
                }
            }
            Schema schema = (Schema) component.getProperties().get(Constants.SCHEMA_PROPERTY_NAME);
            if (schema == null)
                schema = new Schema();

            if (schema.getGridRow() == null) {
                List<GridRow> gridRows = new ArrayList<>();
                schema.setGridRow(gridRows);
            }
            schema.getGridRow().clear();
            if (previousComponentSchema != null && !previousComponentSchema.getGridRow().isEmpty()) {
                schema.getGridRow().addAll(SchemaSyncUtility.INSTANCE
                        .convertGridRowsSchemaToBasicSchemaGridRows(previousComponentSchema.getGridRow()));
            } else {
                shouldsetContinuousSchemaPropagationFlagForNextConnectedComponents = false;
            }
            component.getProperties().put(Constants.SCHEMA_PROPERTY_NAME, schema);
            ComponentFigure componentFigure = (ComponentFigure) ((ComponentEditPart) component
                    .getComponentEditPart()).getFigure();
            component.validateComponentProperties(false);
            componentFigure
                    .setPropertyStatus((String) (component.getProperties().get(Constants.VALIDITY_STATUS)));
            componentFigure.repaint();
            component.setContinuousSchemaPropogationAllow(true);
            if (StringUtils.equalsIgnoreCase(Constants.UNION_ALL, component.getComponentName()))
                break;
        } else if (component instanceof SubjobComponent) {
            Container container = (Container) component.getSubJobContainer().get(Constants.SUBJOB_CONTAINER);
            for (Component componentIterator : container.getUIComponentList()) {
                if (componentIterator instanceof InputSubjobComponent) {
                    SubjobUtility.INSTANCE.initializeSchemaMapForInputSubJobComponent(componentIterator,
                            component);
                    SubjobUtility.INSTANCE.setFlagForContinuousSchemaPropogation(componentIterator);
                    break;
                }

            }
            shouldsetContinuousSchemaPropagationFlagForNextConnectedComponents = !SubjobUtility.INSTANCE
                    .checkIfSubJobHasTransformOrUnionAllComponent(component);
            ((ComponentEditPart) component.getComponentEditPart()).getFigure().repaint();
            component.setContinuousSchemaPropogationAllow(true);
            break;
        } else if (StringUtils.equalsIgnoreCase(component.getComponentName(), Constants.JOIN)
                || StringUtils.equalsIgnoreCase(component.getComponentName(), Constants.LOOKUP)) {
            component.setContinuousSchemaPropogationAllow(true);
            shouldsetContinuousSchemaPropagationFlagForNextConnectedComponents = false;
        } else if (StringUtils.equalsIgnoreCase(component.getComponentName(), Constants.AGGREGATE)
                || StringUtils.equalsIgnoreCase(component.getComponentName(), Constants.CUMULATE)
                || StringUtils.equalsIgnoreCase(component.getComponentName(), Constants.GROUP_COMBINE)
                || StringUtils.equalsIgnoreCase(component.getComponentName(), Constants.NORMALIZE)
                || StringUtils.equalsIgnoreCase(component.getComponentName(), Constants.TRANSFORM)) {
            TransformMapping transformMapping;
            if (component.getProperties().get(Constants.OPERATION) == null) {
                transformMapping = new TransformMapping();
                if (StringUtils.equalsIgnoreCase(component.getComponentName(), Constants.NORMALIZE)) {
                    transformMapping.setExpression(true);
                    ExpressionEditorData expressionEditorData = new ExpressionEditorData("", "");
                    transformMapping.setExpressionEditorData(expressionEditorData);
                }
                component.getProperties().put(Constants.OPERATION, transformMapping);
            } else {
                transformMapping = (TransformMapping) component.getProperties().get(Constants.OPERATION);
            }
            OutputRecordCountUtility.INSTANCE.getPropagatedSchema(transformMapping, component);
            ComponentFigure componentFigure = (ComponentFigure) ((ComponentEditPart) component
                    .getComponentEditPart()).getFigure();
            if (transformMapping.isAllInputFieldsArePassthrough()) {
                Schema schema = (Schema) component.getProperties().get(Constants.SCHEMA_PROPERTY_NAME);
                if (schema == null) {
                    schema = initSchemaObject();
                }
                OutputRecordCountUtility.INSTANCE.addPassThroughFieldsToSchema(transformMapping, component,
                        schema);
                component.getProperties().put(Constants.SCHEMA_PROPERTY_NAME, schema);
                component.validateComponentProperties(false);
                componentFigure
                        .setPropertyStatus((String) (component.getProperties().get(Constants.VALIDITY_STATUS)));
            } else {
                component.setContinuousSchemaPropogationAllow(true);
                shouldsetContinuousSchemaPropagationFlagForNextConnectedComponents = false;
            }
            componentFigure.repaint();
        }
        oldSchemaMap.put(link.getTargetTerminal(), previousComponentSchema);
    }
    if (!StringUtils.equalsIgnoreCase(Constants.UNION_ALL, component.getComponentName())) {
        component.getProperties().put(Constants.PREVIOUS_COMPONENT_OLD_SCHEMA, oldSchemaMap);

    }
    if (shouldsetContinuousSchemaPropagationFlagForNextConnectedComponents) {
        SubjobUtility.INSTANCE.setFlagForContinuousSchemaPropogation(component);
    }
}

From source file:ch.admin.suis.msghandler.servlet.TriggerServlet.java

/**
 * Processes the incoming requests./*from w  ww. j  a  v  a2  s  .c  o  m*/
 *
 * @param request  An HTTP Request.
 * @param response The Response
 * @throws ServletException Something went wront in the servlet !
 * @throws IOException      Classical IO problems.
 */
private void doProcess(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    response.setStatus(HttpServletResponse.SC_OK);
    response.setContentType(TEXT);

    final String action = request.getParameter("action");

    try {
        if (StringUtils.equalsIgnoreCase(action, "send")) {
            dispatchSendRequest(request, response);
        } else if (StringUtils.equalsIgnoreCase(action, "receive")) {
            handleReceive(response);
        } else if (StringUtils.equalsIgnoreCase(action, "poll")) {
            handlePoll(response);
        } else {
            String msg = "No valid parameter found. Valid parameter: action={send,receive,poll}";
            LOG.warn(msg);
            response.getWriter().println(msg);
            response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
        }
    } catch (SchedulerException ex) {
        String msg = "cannot trigger an immediate job";
        LOG.fatal(msg, ex);
        response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
        throw new ServletException(msg, ex);
    }
}

From source file:com.glaf.core.db.DataServiceBean.java

/**
 * ????/*from w  ww.  j  a  va2s. c  om*/
 * 
 * @param sysData
 *            ?
 * @param loginContext
 *            
 * @param ipAddress
 *            IP?
 */
public void checkPermission(SysData sysData, LoginContext loginContext, String ipAddress) {
    boolean hasPermission = false;
    /**
     * ??????
     */
    if (!StringUtils.equals(sysData.getAccessType(), "PUB")) {
        /**
         * IP???
         */
        if (StringUtils.isNotEmpty(sysData.getAddressPerms())) {
            List<String> addressList = StringTools.split(sysData.getAddressPerms());
            for (String addr : addressList) {
                if (StringUtils.equals(ipAddress, addr)) {
                    hasPermission = true;
                }
                if (StringUtils.equals(ipAddress, "127.0.0.1")) {
                    hasPermission = true;
                }
                if (StringUtils.equals(ipAddress, "localhost")) {
                    hasPermission = true;
                }
                if (addr.endsWith("*")) {
                    String tmp = addr.substring(0, addr.indexOf("*"));
                    if (StringUtils.contains(ipAddress, tmp)) {
                        hasPermission = true;
                    }
                }
            }
            if (!hasPermission) {
                throw new RuntimeException("Permission denied.");
            }
        }

        /**
         * ???
         */
        if (StringUtils.isNotEmpty(sysData.getPerms())
                && !StringUtils.equalsIgnoreCase(sysData.getPerms(), "anyone")) {
            if (loginContext.hasSystemPermission() || loginContext.hasAdvancedPermission()) {
                hasPermission = true;
            }
            List<String> permissions = StringTools.split(sysData.getPerms());
            for (String perm : permissions) {
                if (loginContext.getPermissions().contains(perm)) {
                    hasPermission = true;
                }
                if (loginContext.getRoles().contains(perm)) {
                    hasPermission = true;
                }
                if (StringUtils.isNotEmpty(perm) && StringUtils.isNumeric(perm)) {
                    if (loginContext.getRoleIds().contains(Long.parseLong(perm))) {
                        hasPermission = true;
                    }
                }
            }
            if (!hasPermission) {
                throw new RuntimeException("Permission denied.");
            }
        }
    }
}

From source file:io.kamax.mxisd.session.SessionMananger.java

private boolean isLocal(ThreePid tpid) {
    if (!ThreePidMedium.Email.is(tpid.getMedium())) { // We can only handle E-mails for now
        return false;
    }//w  w w .ja  va2s. c  om

    String domain = tpid.getAddress().split("@")[1];
    return StringUtils.equalsIgnoreCase(cfg.getMatrixCfg().getDomain(), domain);
}

From source file:info.magnolia.cms.gui.controlx.list.ListModelIteratorImpl.java

/**
 * checks if there are more records in the current group
 *
 * @return true if not EOF/*from w  w  w.  ja v  a 2s. c  o m*/
 */
public boolean hasNextInGroup() {
    if (StringUtils.isEmpty(this.groupKey))
        return this.hasNext(); // no group key defined, its all one group
    else if (this.hasNext()) {
        if (this.current != null) {
            String currentValue = (String) this.getValue(this.groupKey, this.current);
            String nextValue = (String) this.getValue(this.groupKey, this.next);
            return StringUtils.equalsIgnoreCase(currentValue, nextValue);
        }
    } else {
        return false;
    }
    return true;
}

From source file:com.edgenius.wiki.PageTheme.java

public boolean equals(Object obj) {
    if (!(obj instanceof PageTheme))
        return false;

    return StringUtils.equalsIgnoreCase(((PageTheme) obj).getScope(), this.getScope());
}

From source file:com.sfs.whichdoctor.export.writer.RevenueAnalysisWriter.java

/**
 * Process the export.// w ww .j  a  va  2  s  .  c  o  m
 *
 * @param resultsVal the results
 * @param title the title
 * @param displayRef the display
 * @param preferencesRef the preferences
 *
 * @return the string
 */
public final String process(final Collection<Object> resultsVal, final Collection<String> title,
        final BuilderBean displayRef, final PreferencesBean preferencesRef) {

    StringBuffer export = new StringBuffer();

    Collection<Object> results = new ArrayList<Object>();
    BuilderBean display = new BuilderBean();
    PreferencesBean preferences = new PreferencesBean();

    if (resultsVal != null) {
        results = resultsVal;
    }
    if (displayRef != null) {
        display = displayRef;
    }
    if (preferencesRef != null) {
        preferences = preferencesRef;
    }

    String revenueType = preferences.getOption("export", "type");
    if (StringUtils.isBlank(revenueType)) {
        revenueType = "batchReference";
    }

    RevenueAnalysisBean revenueAnalysis = new RevenueAnalysisBean();
    /* Cast collection object to revenue analysis */
    for (Object objRevenueAnalysis : results) {
        revenueAnalysis = (RevenueAnalysisBean) objRevenueAnalysis;
    }

    export.append(this.getKeys().getString("EXPORT_PREFIX"));

    for (String titleLine : title) {
        export.append(this.getKeys().getString("HEADER_PREFIX"));
        export.append(" ");
        export.append(titleLine);
        export.append(this.getKeys().getString("HEADER_SUFFIX"));
    }

    export.append(this.getKeys().getString("HEADER_PREFIX"));
    export.append(" ");
    if (revenueType.compareTo("batchAnalysis") == 0) {
        export.append("Revenue Summary by Batch Number");
    }
    if (revenueType.compareTo("streamAnalysis") == 0) {
        export.append("Revenue Summary by Revenue Stream");
    }
    export.append(this.getKeys().getString("HEADER_SUFFIX"));

    export.append(this.getKeys().getString("LIST_BEGINNING"));
    export.append(this.getKeys().getString("ROW_BEGINNING"));

    StringBuffer header = new StringBuffer();
    for (String headerLine : display.getOrder()) {
        if (header.length() > 0) {
            header.append(this.getKeys().getString("ITEM_DIVIDER"));
        }
        header.append(this.getKeys().getString("HEADERITEM_PREFIX"));

        if (StringUtils.equalsIgnoreCase(headerLine, "GST Breakdown")) {
            header.append(this.getFormattedGSTBreakdownHeader(revenueAnalysis));
        } else {
            header.append(headerLine);
        }
        header.append(this.getKeys().getString("HEADERITEM_SUFFIX"));
    }
    export.append(header.toString());

    export.append(this.getKeys().getString("ROW_END"));

    for (RevenueBean revenue : revenueAnalysis.getRevenue()) {

        export.append(this.getKeys().getString("ROW_BEGINNING"));

        StringBuffer fieldValue = new StringBuffer();
        for (String fieldName : display.getOrder()) {
            String field = RevenueAnalysisFormatter.getField(revenue, fieldName, this.getType());

            if (StringUtils.equalsIgnoreCase(fieldName, "GST Breakdown")) {
                field = this.getFormattedGSTBreakdownField(revenue, this.getType());
            }

            if (fieldValue.length() > 0) {
                fieldValue.append(this.getKeys().getString("ITEM_DIVIDER"));
            }
            fieldValue.append(this.getKeys().getString("ITEM_PREFIX"));
            fieldValue.append(field);
            fieldValue.append(this.getKeys().getString("ITEM_SUFFIX"));
        }
        export.append(fieldValue.toString());

        export.append(this.getKeys().getString("ROW_END"));
    }
    export.append(this.getKeys().getString("LIST_END"));

    for (RevenueBean revenue : revenueAnalysis.getRevenue()) {

        HashMap<String, BuilderBean> sections = display.getSections();

        if (sections != null) {
            for (String sectionName : display.getSectionOrder()) {
                BuilderBean section = sections.get(sectionName);

                export.append(this.getKeys().getString("SECTION_PREFIX"));
                export.append(" ");
                if (revenueType.compareTo("batchAnalysis") == 0) {
                    export.append("Breakdown of payments for batch number: ");
                    export.append(revenue.getBatchNo());
                }
                if (revenueType.compareTo("streamAnalysis") == 0) {
                    export.append("Breakdown of payments for revenue stream: ");
                    export.append(revenue.getRevenueType());
                }
                export.append(this.getKeys().getString("SECTION_SUFFIX"));

                export.append(this.getKeys().getString("LIST_BEGINNING"));
                export.append(this.getKeys().getString("ROW_BEGINNING"));

                StringBuffer sectionHeader = new StringBuffer();
                for (String headerLine : section.getOrder()) {
                    if (sectionHeader.length() > 0) {
                        sectionHeader.append(this.getKeys().getString("ITEM_DIVIDER"));
                    }
                    sectionHeader.append(this.getKeys().getString("HEADERITEM_PREFIX"));
                    sectionHeader.append(headerLine);
                    sectionHeader.append(this.getKeys().getString("HEADERITEM_SUFFIX"));
                }
                export.append(sectionHeader.toString());

                export.append(this.getKeys().getString("ROW_END"));

                Collection<Object> receipts = RevenueAnalysisFormatter.getCollection(revenue, sectionName);

                export.append(getPaymentExportList(receipts, section, sectionName));

                export.append(this.getKeys().getString("LIST_END"));
            }
        }
    }
    export.append(this.getKeys().getString("EXPORT_SUFFIX"));

    return export.toString();
}

From source file:jenkins.plugins.office365connector.Office365ConnectorWebhookNotifier.java

public void sendBuildNotification(StepParameters stepParameters) {
    Card card;//from w  w  w .j  a v  a2s.c  o m
    if (StringUtils.isNotBlank(stepParameters.getMessage())) {
        card = createBuildMessageCard(stepParameters);
    } else if (StringUtils.equalsIgnoreCase(stepParameters.getStatus(), "started")) {
        card = createJobStartedCard();
    } else {
        card = createJobCompletedCard();
    }

    WebhookJobProperty property = (WebhookJobProperty) job.getProperty(WebhookJobProperty.class);
    if (property == null) {
        Webhook webhook = new Webhook(stepParameters.getWebhookUrl());
        executeWorker(webhook, card);
        return;
    }

    for (Webhook webhook : property.getWebhooks()) {
        executeWorker(webhook, card);
    }
}