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

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

Introduction

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

Prototype

public static boolean contains(String str, String searchStr) 

Source Link

Document

Checks if String contains a search String, handling null.

Usage

From source file:com.primovision.lutransport.core.util.TollCompanyTagUploadUtil.java

private static void setCellValueFeeFormat(Workbook wb, Cell cell, Object oneCellValue, String vendor) {
    CellStyle style = wb.createCellStyle();
    style.setDataFormat(wb.createDataFormat().getFormat("$#,#0.00"));
    cell.setCellStyle(style);/*from w w w  .  j  av a  2  s.  com*/

    if (oneCellValue == null) {
        cell.setCellValue(Double.parseDouble("0.0"));
        return;
    }

    String feeStr = StringUtils.replace(oneCellValue.toString(), "$", StringUtils.EMPTY);
    feeStr = StringUtils.trimToEmpty(feeStr);
    feeStr = feeStr.replaceAll("\\p{javaSpaceChar}", StringUtils.EMPTY);
    if (StringUtils.isEmpty(feeStr)) {
        cell.setCellValue(Double.parseDouble("0.0"));
        return;
    }

    if (StringUtils.contains(vendor, TOLL_COMPANY_EZ_PASS_PA)
            || StringUtils.contains(vendor, TOLL_COMPANY_IPASS)
            || StringUtils.contains(vendor, TOLL_COMPANY_SUN_PASS)) {
        if (StringUtils.startsWith(feeStr, "-")) {
            feeStr = StringUtils.substring(feeStr, 1);
        } else {
            feeStr = "-" + feeStr;
        }
    }

    cell.setCellValue(Double.parseDouble(feeStr));
}

From source file:com.snaplogic.snaps.firstdata.Create.java

/**
 * @param method//from w  w w  .  j av a 2s.  c o  m
 * @return SnapType
 */
private SnapType getDataTypes(String type) {
    if (StringUtils.contains(type, INT)) {
        return SnapType.INTEGER;
    } else if (StringUtils.containsIgnoreCase(type, Float.class.getSimpleName())
            || StringUtils.containsIgnoreCase(type, Long.class.getSimpleName())
            || StringUtils.containsIgnoreCase(type, Double.class.getSimpleName())) {
        return SnapType.NUMBER;
    } else if (StringUtils.containsIgnoreCase(type, Calendar.class.getName())) {
        return SnapType.DATETIME;
    } else
        return SnapType.STRING;
}

From source file:au.edu.anu.portal.portlets.tweetal.servlet.TweetalServlet.java

private JSONObject getStatusJSON(Twitter twitter, Status status) throws TwitterException {
    JSONObject result = new JSONObject();

    result.put("tweetId", Long.toString(status.getId()));
    result.put("isOwnTweet", status.getUser().getId() == twitter.getId());
    result.put("createdAt", status.getCreatedAt().toString());
    result.put("screenName", status.getUser().getScreenName());
    result.put("name", status.getUser().getName());
    result.put("profileImageURL", status.getUser().getProfileImageURL().toString());

    String statusText = status.getText();

    // escape html to prevent XSS attack
    statusText = StringEscapeUtils.escapeHtml(statusText);

    result.put("statusText", statusText);

    // if this tweet addresses the current user
    result.put("isMentionedMe", StringUtils.contains(statusText, "@" + twitter.getScreenName()));

    // replace links with link tags
    statusText = replaceLinks(statusText);
    // replace @username with link to the user page
    statusText = replaceUserReference(statusText);
    // replace #hashtag with link
    statusText = replaceHashTag(statusText);

    result.put("statusTextFormatted", statusText);

    return result;
}

From source file:edu.ku.brc.specify.datamodel.DataModelObjBase.java

public void removeReference(FormDataObjIFace ref, String fieldName, final boolean doOtherSide) {
    if (ref == null) {
        return;//  w ww  . j a v  a 2  s .  c  o m
    }

    // Note that this method uses local members for the parent data object the field name.
    // This is because they may need to be adjusted when using '.' notation.
    String fldName = fieldName;
    FormDataObjIFace parentDataObject = this;

    // Check for DOT notation for setting a child
    // If so then we need to walk the list finding the 'true' parent of the last
    // item in the hierarchy list, and the let it continue with the 'adjusted' parent and 
    // the 'real' field name (the name after the last '.')
    if (StringUtils.contains(fldName, '.')) {
        // Get the list of data objects to walk and 
        // create a new list without the last member
        String[] fieldNames = StringUtils.split(fldName, '.');
        String[] parentPath = new String[fieldNames.length - 1];
        for (int i = 0; i < parentPath.length; i++) {
            parentPath[i] = fieldNames[i];
        }
        // Now go get the 'true' parent of the incoming reference by walk the hierarchy
        DataObjectGettable getter = DataObjectGettableFactory.get(getClass().getName(),
                FormHelper.DATA_OBJ_GETTER);
        Object[] values = UIHelper.getFieldValues(parentPath, this, getter);
        parentDataObject = (FormDataObjIFace) values[parentPath.length - 1];

        // Set the field name to the last item in the original list
        fldName = fieldNames[fieldNames.length - 1];
    }

    DBTableInfo tblInfo = DBTableIdMgr.getInstance().getInfoById(parentDataObject.getTableId());
    if (tblInfo != null) {
        DBRelationshipInfo rel = tblInfo.getRelationshipByName(fldName);
        if (rel != null) {
            Boolean isJavaCollection = isJavaCollection(parentDataObject, fldName);
            if (isJavaCollection != null) {
                if (isJavaCollection) {
                    String otherSide = rel.getOtherSide();
                    removeFromCollection(parentDataObject, fldName, ref);
                    if (StringUtils.isNotEmpty(otherSide) && doOtherSide) {
                        Boolean isOtherSideCollection = isJavaCollection(ref, otherSide);
                        if (isOtherSideCollection != null && isOtherSideCollection) {
                            removeFromCollection(ref, otherSide, parentDataObject);
                        }
                        // rods 06/11/08 - this keeps deleting attachments from working
                        // rods 08/21/08 - This is needed when removing CollectionObjects from Projects
                        else {
                            DataObjectSettable setter = DataObjectSettableFactory.get(ref.getClass().getName(),
                                    FormHelper.DATA_OBJ_SETTER);
                            setter.setFieldValue(ref, otherSide, null);
                        }
                    }

                } else {
                    DataObjectSettable setter = DataObjectSettableFactory.get(ref.getClass().getName(),
                            FormHelper.DATA_OBJ_SETTER);
                    setter.setFieldValue(parentDataObject, fldName, null);
                    // in this case, the Collection may not be loaded
                    // calling removeFromCollection() could trigger a LazyInstantiationException
                    String otherSide = rel.getOtherSide();
                    try {
                        removeFromCollection(ref, otherSide, this);
                    } catch (org.hibernate.LazyInitializationException ex) {
                        //ignore 
                        log.info(ex);
                    }
                }
            }
        }
    }
}

From source file:com.rsmart.kuali.kfs.fp.batch.service.impl.DisbursementVoucherDocumentBatchServiceImpl.java

/**
 * Populates fields on the disbursement voucher document and performs validation
 * /*from   ww  w  . j  av a2 s . c o  m*/
 * @param disbursementVoucherDocument disbursement voucher document to populate
 * @param batchDisbursementVoucherDocument batch dv document to pull values from
 * @param batchDefault contains default values to use if value in feed is empty
 * @param MessageMap MessageMap for adding encountered errors
 */
protected void populateDisbursementVoucherFields(DisbursementVoucherDocument disbursementVoucherDocument,
        BatchDisbursementVoucherDocument batchDisbursementVoucherDocument,
        DisbursementVoucherBatchDefault batchDefault, MessageMap MessageMap) {
    disbursementVoucherDocument.getDocumentHeader().setDocumentDescription(kualiConfigurationService
            .getPropertyValueAsString(FPKeyConstants.MESSAGE_DV_BATCH_DOCUMENT_DESCRIPTION));

    // populate fields of document from batch instance
    disbursementVoucherDocument.getDocumentHeader()
            .setExplanation(batchDisbursementVoucherDocument.getDocumentHeader().getExplanation());
    disbursementVoucherDocument.getDocumentHeader().setOrganizationDocumentNumber(
            batchDisbursementVoucherDocument.getDocumentHeader().getOrganizationDocumentNumber());
    disbursementVoucherDocument
            .setDisbVchrContactPersonName(batchDisbursementVoucherDocument.getDisbVchrContactPersonName());
    disbursementVoucherDocument
            .setDisbVchrContactPhoneNumber(batchDisbursementVoucherDocument.getDisbVchrContactPhoneNumber());
    disbursementVoucherDocument
            .setDisbVchrContactEmailId(batchDisbursementVoucherDocument.getDisbVchrContactEmailId());
    disbursementVoucherDocument
            .setDisbursementVoucherDueDate(batchDisbursementVoucherDocument.getDisbursementVoucherDueDate());
    disbursementVoucherDocument
            .setDisbVchrAttachmentCode(batchDisbursementVoucherDocument.isDisbVchrAttachmentCode());
    disbursementVoucherDocument
            .setDisbVchrSpecialHandlingCode(batchDisbursementVoucherDocument.isDisbVchrSpecialHandlingCode());
    disbursementVoucherDocument
            .setDisbVchrCheckTotalAmount(batchDisbursementVoucherDocument.getDisbVchrCheckTotalAmount());
    disbursementVoucherDocument.setDisbursementVoucherDocumentationLocationCode(
            batchDisbursementVoucherDocument.getDisbursementVoucherDocumentationLocationCode());
    disbursementVoucherDocument
            .setDisbVchrPaymentMethodCode(batchDisbursementVoucherDocument.getDisbVchrPaymentMethodCode());
    disbursementVoucherDocument.setCampusCode(batchDisbursementVoucherDocument.getCampusCode());
    disbursementVoucherDocument
            .setDisbVchrCheckStubText(batchDisbursementVoucherDocument.getDisbVchrCheckStubText());
    disbursementVoucherDocument.setDisbVchrBankCode(batchDisbursementVoucherDocument.getDisbVchrBankCode());

    disbursementVoucherDocument.getDvPayeeDetail()
            .setDocumentNumber(disbursementVoucherDocument.getDocumentNumber());
    disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrPaymentReasonCode(
            batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPaymentReasonCode());

    String payeeTypeCode = batchDisbursementVoucherDocument.getDvPayeeDetail()
            .getDisbursementVoucherPayeeTypeCode();
    String payeeIdNumber = batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeIdNumber();
    if (KFSConstants.PaymentPayeeTypes.VENDOR.equals(payeeTypeCode)) {
        if (StringUtils.contains(payeeIdNumber, "-")) {
            VendorDetail vendorDetail = vendorService.getVendorDetail(payeeIdNumber);
            if (vendorDetail != null) {
                VendorAddress vendorAddress = vendorService.getVendorDefaultAddress(
                        vendorDetail.getVendorHeaderGeneratedIdentifier(),
                        vendorDetail.getVendorDetailAssignedIdentifier(),
                        VendorConstants.AddressTypes.PURCHASE_ORDER,
                        disbursementVoucherDocument.getCampusCode());
                if (vendorAddress == null) {
                    vendorAddress = vendorService.getVendorDefaultAddress(
                            vendorDetail.getVendorHeaderGeneratedIdentifier(),
                            vendorDetail.getVendorDetailAssignedIdentifier(),
                            VendorConstants.AddressTypes.REMIT, disbursementVoucherDocument.getCampusCode());
                }
                if (vendorAddress != null) {
                    disbursementVoucherDocument.templateVendor(vendorDetail, vendorAddress);
                }
            } else {
                batchFeedHelperService.addExistenceError(KFSPropertyConstants.DISB_VCHR_PAYEE_ID_NUMBER,
                        payeeIdNumber, MessageMap);
            }
        } else {
            batchFeedHelperService.addExistenceError(KFSPropertyConstants.DISB_VCHR_PAYEE_ID_NUMBER,
                    payeeIdNumber, MessageMap);
        }
    } else if (KFSConstants.PaymentPayeeTypes.EMPLOYEE.equals(payeeTypeCode)) {
        Person person = personService.getPersonByEmployeeId(payeeIdNumber);
        if (person != null) {
            disbursementVoucherDocument.templateEmployee(person);
        } else {
            batchFeedHelperService.addExistenceError(KFSPropertyConstants.DISB_VCHR_PAYEE_ID_NUMBER,
                    payeeIdNumber, MessageMap);
        }
    }

    // override payee details with values from feed if given (not blank)
    if (StringUtils
            .isNotBlank(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeLine1Addr())) {
        disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrPayeeLine1Addr(
                batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeLine1Addr());
    }
    if (StringUtils
            .isNotBlank(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeLine2Addr())) {
        disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrPayeeLine2Addr(
                batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeLine2Addr());
    }
    if (StringUtils
            .isNotBlank(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeCityName())) {
        disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrPayeeCityName(
                batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeCityName());
    }
    if (StringUtils
            .isNotBlank(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeStateCode())) {
        disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrPayeeStateCode(
                batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeStateCode());
    }
    if (StringUtils.isNotBlank(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeZipCode())) {
        disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrPayeeZipCode(
                batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeZipCode());
    }
    if (StringUtils
            .isNotBlank(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeCountryCode())) {
        disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrPayeeCountryCode(
                batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeCountryCode());
    }

    // set special handling fields
    disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrSpecialHandlingPersonName(
            batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrSpecialHandlingPersonName());
    disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrSpecialHandlingLine1Addr(
            batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrSpecialHandlingLine1Addr());
    disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrSpecialHandlingLine2Addr(
            batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrSpecialHandlingLine2Addr());
    disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrSpecialHandlingCityName(
            batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrSpecialHandlingCityName());
    disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrSpecialHandlingZipCode(
            batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrSpecialHandlingZipCode());
    disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrSpecialHandlingStateCode(
            batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrSpecialHandlingStateCode());
    disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrSpecialHandlingCountryCode(
            batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrSpecialHandlingCountryCode());

    disbursementVoucherDocument
            .setDvNonResidentAlienTax(batchDisbursementVoucherDocument.getDvNonResidentAlienTax());
    disbursementVoucherDocument.getDvNonResidentAlienTax()
            .setDocumentNumber(disbursementVoucherDocument.getDocumentNumber());

    /* UPGRADE-911
    disbursementVoucherDocument.setDvWireTransfer(batchDisbursementVoucherDocument.getDvWireTransfer());
    disbursementVoucherDocument.getDvWireTransfer().setDocumentNumber(disbursementVoucherDocument.getDocumentNumber());
    */

    // set defaults
    if (batchDefault != null) {
        if (StringUtils.isBlank(disbursementVoucherDocument.getDisbVchrContactPersonName())) {
            disbursementVoucherDocument
                    .setDisbVchrContactPersonName(batchDefault.getDisbVchrContactPersonName());
        }
        if (StringUtils.isBlank(disbursementVoucherDocument.getDisbVchrContactPhoneNumber())) {
            disbursementVoucherDocument
                    .setDisbVchrContactPhoneNumber(batchDefault.getDisbVchrContactPhoneNumber());
        }
        if (StringUtils.isBlank(disbursementVoucherDocument.getDisbVchrContactEmailId())) {
            disbursementVoucherDocument.setDisbVchrContactEmailId(batchDefault.getDisbVchrContactEmailId());
        }
        if (StringUtils.isBlank(disbursementVoucherDocument.getCampusCode())) {
            disbursementVoucherDocument.setCampusCode(batchDefault.getCampusCode());
        }
        if (StringUtils.isBlank(disbursementVoucherDocument.getDisbVchrPaymentMethodCode())) {
            disbursementVoucherDocument
                    .setDisbVchrPaymentMethodCode(batchDefault.getDisbVchrPaymentMethodCode());
        }
        if (StringUtils
                .isBlank(disbursementVoucherDocument.getDisbursementVoucherDocumentationLocationCode())) {
            disbursementVoucherDocument.setDisbursementVoucherDocumentationLocationCode(
                    batchDefault.getDisbursementVoucherDocumentationLocationCode());
        }
        if (StringUtils.isBlank(disbursementVoucherDocument.getDisbVchrBankCode())) {
            disbursementVoucherDocument.setDisbVchrBankCode(batchDefault.getDisbVchrBankCode());
        }
    }

    // set accounting
    for (Iterator iterator = batchDisbursementVoucherDocument.getSourceAccountingLines().iterator(); iterator
            .hasNext();) {
        SourceAccountingLine batchAccountingLine = (SourceAccountingLine) iterator.next();

        SourceAccountingLine accountingLine = new SourceAccountingLine();
        accountingLine.setChartOfAccountsCode(batchAccountingLine.getChartOfAccountsCode());
        accountingLine.setAccountNumber(batchAccountingLine.getAccountNumber());

        if (StringUtils.isNotBlank(batchAccountingLine.getSubAccountNumber())) {
            accountingLine.setSubAccountNumber(batchAccountingLine.getSubAccountNumber());
        }
        accountingLine.setFinancialObjectCode(batchAccountingLine.getFinancialObjectCode());
        if (StringUtils.isNotBlank(batchAccountingLine.getFinancialSubObjectCode())) {
            accountingLine.setFinancialSubObjectCode(batchAccountingLine.getFinancialSubObjectCode());
        }
        if (StringUtils.isNotBlank(batchAccountingLine.getProjectCode())) {
            accountingLine.setProjectCode(batchAccountingLine.getProjectCode());
        }

        accountingLine.setOrganizationReferenceId(batchAccountingLine.getOrganizationReferenceId());
        accountingLine
                .setFinancialDocumentLineDescription(batchAccountingLine.getFinancialDocumentLineDescription());
        accountingLine.setAmount(batchAccountingLine.getAmount());

        // set accounting defaults
        if (batchDefault != null) {
            if (StringUtils.isBlank(accountingLine.getChartOfAccountsCode())) {
                accountingLine.setChartOfAccountsCode(batchDefault.getChartOfAccountsCode());
            }
            if (StringUtils.isBlank(accountingLine.getAccountNumber())) {
                accountingLine.setAccountNumber(batchDefault.getAccountNumber());
            }
            if (StringUtils.isBlank(accountingLine.getFinancialObjectCode())) {
                accountingLine.setFinancialObjectCode(batchDefault.getFinancialObjectCode());
            }
            if (StringUtils.isBlank(accountingLine.getFinancialDocumentLineDescription())) {
                accountingLine.setFinancialDocumentLineDescription(
                        batchDefault.getFinancialDocumentLineDescription());
            }
        }

        accountingLine.setPostingYear(disbursementVoucherDocument.getPostingYear());
        accountingLine.setDocumentNumber(disbursementVoucherDocument.getDocumentNumber());
        disbursementVoucherDocument.addSourceAccountingLine(accountingLine);
    }

    // set notes
    for (Iterator iterator = batchDisbursementVoucherDocument.getNotes().iterator(); iterator.hasNext();) {
        Note note = (Note) iterator.next();
        note.setRemoteObjectIdentifier(disbursementVoucherDocument.getObjectId());
        note.setAuthorUniversalIdentifier(batchFeedHelperService.getSystemUser().getPrincipalId());
        note.setNoteTypeCode(KFSConstants.NoteTypeEnum.BUSINESS_OBJECT_NOTE_TYPE.getCode());
        note.setNotePostedTimestampToCurrent();

        disbursementVoucherDocument.addNote(note);
    }
}

From source file:edu.ku.brc.specify.datamodel.busrules.BaseTreeBusRules.java

@SuppressWarnings("unchecked")
@Override//from   ww  w  . j a  va 2 s. c o  m
public void afterFillForm(final Object dataObj) {
    // This is a little weak and cheesey, but it gets the job done.
    // Because both the Tree and Definition want/need to share Business Rules.
    String viewName = formViewObj.getView().getName();
    if (StringUtils.contains(viewName, "TreeDef")) {
        if (formViewObj.getAltView().getMode() != CreationMode.EDIT) {
            // when we're not in edit mode, we don't need to setup any listeners since the user can't change anything
            //log.debug("form is not in edit mode: no special listeners will be attached");
            return;
        }

        if (!StringUtils.contains(viewName, "TreeDefItem")) {
            return;
        }

        final I nodeInForm = (I) formViewObj.getDataObj();
        //disable FullName -related fields if TreeDefItem is used by nodes in the tree
        //NOTE: Can remove the edit restriction. Tree rebuilds now update fullname fields. Need to add tree rebuild after fullname def edits.
        if (nodeInForm != null && nodeInForm.getTreeDef() != null) {
            //               boolean canNOTEditFullNameFlds = nodeInForm.hasTreeEntries();
            //               if (canNOTEditFullNameFlds)
            //               {
            //                  ValTextField ftCtrl = (ValTextField )formViewObj.getControlByName("textAfter");
            //                  if (ftCtrl != null)
            //                  {
            //                     ftCtrl.setEnabled(false);
            //                  }
            //                  ftCtrl = (ValTextField )formViewObj.getControlByName("textBefore");
            //                  if (ftCtrl != null)
            //                  {
            //                     ftCtrl.setEnabled(false);
            //                  }
            //                  ftCtrl = (ValTextField )formViewObj.getControlByName("fullNameSeparator");
            //                  if (ftCtrl != null)
            //                  {
            //                     ftCtrl.setEnabled(false);
            //                  }
            //                  ValCheckBox ftBox = (ValCheckBox )formViewObj.getControlByName("isInFullName");
            //                  if (ftBox != null)
            //                  {
            //                     ftBox.setEnabled(false);
            //                  }
            //               }

            if (!viewName.endsWith("TreeDefItem")) {
                return;
            }

            //disabling editing of name and rank for standard levels.
            List<TreeDefItemStandardEntry> stds = nodeInForm.getTreeDef().getStandardLevels();
            TreeDefItemStandardEntry stdLevel = null;
            for (TreeDefItemStandardEntry std : stds) {
                //if (std.getTitle().equals(nodeInForm.getName()) && std.getRank() == nodeInForm.getRankId())
                if (std.getRank() == nodeInForm.getRankId()) {
                    stdLevel = std;
                    break;
                }
            }
            if (stdLevel != null) {
                ValTextField nameCtrl = (ValTextField) formViewObj.getControlByName("name");
                Component rankCtrl = formViewObj.getControlByName("rankId");
                if (nameCtrl != null) {
                    nameCtrl.setEnabled(false);
                }
                if (rankCtrl != null) {
                    rankCtrl.setEnabled(false);
                }
                if (nodeInForm.getTreeDef().isRequiredLevel(stdLevel.getRank())) {
                    Component enforcedCtrl = formViewObj.getControlByName("isEnforced");
                    if (enforcedCtrl != null) {
                        enforcedCtrl.setEnabled(false);
                    }
                }
            }
        }
        return;
    }

    final T nodeInForm = (T) formViewObj.getDataObj();

    if (formViewObj.getAltView().getMode() != CreationMode.EDIT) {
        if (nodeInForm != null) {
            //XXX this MAY be necessary due to a bug with TextFieldFromPickListTable??
            // TextFieldFromPickListTable.setValue() does nothing because of a null adapter member.
            Component comp = formViewObj.getControlByName("definitionItem");
            if (comp instanceof JTextField) {
                ((JTextField) comp).setText(nodeInForm.getDefinitionItem().getName());
            }
        }
    } else {
        processedRules = false;
        GetSetValueIFace parentField = (GetSetValueIFace) formViewObj.getControlByName("parent");
        Component comp = formViewObj.getControlByName("definitionItem");
        if (comp instanceof ValComboBox) {
            final ValComboBox rankComboBox = (ValComboBox) comp;

            if (parentField instanceof ValComboBoxFromQuery) {
                final ValComboBoxFromQuery parentCBX = (ValComboBoxFromQuery) parentField;
                if (parentCBX != null && rankComboBox != null && nodeInForm != null) {
                    parentCBX.registerQueryBuilder(new TreeableSearchQueryBuilder(nodeInForm, rankComboBox,
                            TreeableSearchQueryBuilder.PARENT));
                }
            }

            if (nodeInForm != null && nodeInForm.getDefinitionItem() != null) {
                // log.debug("node in form already has a set rank: forcing a call to
                // adjustRankComboBoxModel()");
                UIValidator.setIgnoreAllValidation(this, true);
                adjustRankComboBoxModel(parentField, rankComboBox, nodeInForm);
                UIValidator.setIgnoreAllValidation(this, false);
            }

            // TODO: the form system MUST require the accepted parent widget to be present if
            // the
            // isAccepted checkbox is present
            final JCheckBox acceptedCheckBox = (JCheckBox) formViewObj.getControlByName("isAccepted");
            final ValComboBoxFromQuery acceptedParentWidget = (ValComboBoxFromQuery) formViewObj
                    .getControlByName("acceptedParent");
            if (canAccessSynonymy(nodeInForm)) {
                if (acceptedCheckBox != null && acceptedParentWidget != null) {
                    if (acceptedCheckBox.isSelected() && nodeInForm != null
                            && nodeInForm.getDefinition() != null) {
                        // disable if necessary
                        boolean canSynonymize = nodeInForm.getDefinition().getSynonymizedLevel() <= nodeInForm
                                .getRankId() && nodeInForm.getDescendantCount() == 0;
                        acceptedCheckBox.setEnabled(canSynonymize);
                    }
                    acceptedParentWidget
                            .setEnabled(!acceptedCheckBox.isSelected() && acceptedCheckBox.isEnabled());
                    if (acceptedCheckBox.isSelected()) {
                        acceptedParentWidget.setValue(null, null);
                    }

                    if (nodeInForm != null && acceptedParentWidget != null && rankComboBox != null) {
                        acceptedParentWidget.registerQueryBuilder(new TreeableSearchQueryBuilder(nodeInForm,
                                rankComboBox, TreeableSearchQueryBuilder.ACCEPTED_PARENT));
                    }
                }
            } else {
                if (acceptedCheckBox != null) {
                    acceptedCheckBox.setEnabled(false);
                }
                if (acceptedParentWidget != null) {
                    acceptedParentWidget.setEnabled(false);
                }
            }

            if (parentField instanceof ValComboBoxFromQuery) {
                parentChanged(formViewObj, (ValComboBoxFromQuery) parentField, rankComboBox, acceptedCheckBox,
                        acceptedParentWidget);
            }
        }
    }
}

From source file:info.magnolia.importexport.DataTransporter.java

/**
 *
 * @param path path to encode/*from   ww  w .ja v  a2s. c om*/
 * @param separator "." (dot) or "/", it will be not encoded if found
 * @param enc charset
 * @return the path encoded
 */
public static String encodePath(String path, String separator, String enc) {
    StringBuilder pathEncoded = new StringBuilder();
    try {
        if (!StringUtils.contains(path, separator)) {
            return URLEncoder.encode(path, enc);
        }
        for (int i = 0; i < path.length(); i++) {
            String ch = String.valueOf(path.charAt(i));
            if (separator.equals(ch)) {
                pathEncoded.append(ch);
            } else {
                pathEncoded.append(URLEncoder.encode(ch, enc));
            }
        }
    } catch (UnsupportedEncodingException e) {
        return path;
    }
    return pathEncoded.toString();
}

From source file:com.tacitknowledge.maven.plugin.crx.CRXPackageInstallerPlugin.java

private boolean isVersionable(final Cookie[] cookies, String path, HttpClient client)
        throws HttpException, IOException, MojoExecutionException {
    GetMethod definitionCall = new GetMethod(crxPath + "/browser/definition.jsp?Path=" + path);
    definitionCall.setFollowRedirects(false);

    getLog().info("Getting definitions for node : " + path);
    getLog().info(crxPath + "/browser/definition.jsp?Path=" + path);

    int status = client.executeMethod(definitionCall);

    if (status == HttpStatus.SC_OK) {
        getLog().info("Successfully retrieved node definition.");
    } else {//w  ww.j  a v  a2  s  .co  m
        logResponseDetails(definitionCall);
        throw new MojoExecutionException("Getting definitions for node " + path + " failed, response="
                + HttpStatus.getStatusText(status));
    }

    String response = definitionCall.getResponseBodyAsString().toLowerCase();

    return StringUtils.contains(response, "mix:versionable");
}

From source file:edu.ku.brc.af.ui.db.TextFieldWithQuery.java

/**
 * Adds the field name with the table abbrev if it doesn't already have one.
 * @param abbrev the table abbrev/*  w  w  w.java2  s  . co  m*/
 * @param fld the field name
 * @param selectSB the StringBuilder to add it to 
 */
protected void addTblAbbrev(final String abbrev, final String fld, final StringBuilder selectSB) {
    if (!StringUtils.contains(fld, '.')) {
        selectSB.append(tableInfo.getAbbrev());
        selectSB.append("."); //$NON-NLS-1$
    }
    selectSB.append(fld.trim());
}

From source file:com.vmware.veei.qe.devcenter.SampleExchangeTest.java

/**
 * Returns a list of URLs of the Sample Exchange links.
 *//* w w w .  jav a 2 s .  c om*/
@DataProvider
public Object[][] getSampleExchangeUrls() {
    List<Object[]> data = new ArrayList<Object[]>();
    // #action : Navigates to main Sample Exchange pages.
    driver.get(baseUrl + SAMPLE_CODE_URL);

    // Gets all the links under Sample page span.
    List<WebElement> elements = driver
            .findElements(By.cssSelector("#search-results-list .title-list li .title"));

    // We have to put this in a temporary list, since any further action on the Web driver
    // will make the references to the WebElement unusable.
    for (WebElement element : elements) {
        // Avoiding other URL
        if (!StringUtils.contains(element.getAttribute("href"), "/user?id")) {
            data.add(new Object[] { element.getAttribute("href").trim() });
        }
    }
    return data.toArray(new Object[][] {});
}