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

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

Introduction

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

Prototype

public static String right(String str, int len) 

Source Link

Document

Gets the rightmost len characters of a String.

Usage

From source file:org.kuali.kfs.module.cam.document.AssetGlobalMaintainableImpl.java

/**
 * @see org.kuali.rice.kns.maintenance.KualiGlobalMaintainableImpl#prepareForSave()
 *//*from   ww  w  .  java2 s  .  c  om*/
@Override
public void prepareForSave() {
    super.prepareForSave();
    AssetGlobal assetGlobal = (AssetGlobal) this.getBusinessObject();

    //we need to set the posting period and posting year from the value of the drop-down box...
    if (StringUtils.isNotBlank(assetGlobal.getUniversityFiscalPeriodName())) {
        assetGlobal.setFinancialDocumentPostingPeriodCode(
                StringUtils.left(assetGlobal.getUniversityFiscalPeriodName(), 2));
        assetGlobal.setFinancialDocumentPostingYear(
                new Integer(StringUtils.right(assetGlobal.getUniversityFiscalPeriodName(), 4)));
    }

    List<AssetGlobalDetail> assetSharedDetails = assetGlobal.getAssetSharedDetails();
    List<AssetGlobalDetail> newDetails = new ArrayList<AssetGlobalDetail>();
    AssetGlobalDetail newAssetGlobalDetail = null;
    if (!assetSharedDetails.isEmpty() && !assetSharedDetails.get(0).getAssetGlobalUniqueDetails().isEmpty()) {

        for (AssetGlobalDetail locationDetail : assetSharedDetails) {
            List<AssetGlobalDetail> assetGlobalUniqueDetails = locationDetail.getAssetGlobalUniqueDetails();

            for (AssetGlobalDetail detail : assetGlobalUniqueDetails) {
                // read from location and set it to detail
                if (ObjectUtils.isNotNull(locationDetail.getCampusCode())) {
                    detail.setCampusCode(locationDetail.getCampusCode().toUpperCase());
                } else {
                    detail.setCampusCode(locationDetail.getCampusCode());
                }
                if (ObjectUtils.isNotNull(locationDetail.getBuildingCode())) {
                    detail.setBuildingCode(locationDetail.getBuildingCode().toUpperCase());
                } else {
                    detail.setBuildingCode(locationDetail.getBuildingCode());
                }
                detail.setBuildingRoomNumber(locationDetail.getBuildingRoomNumber());
                detail.setBuildingSubRoomNumber(locationDetail.getBuildingSubRoomNumber());
                detail.setOffCampusName(locationDetail.getOffCampusName());
                detail.setOffCampusAddress(locationDetail.getOffCampusAddress());
                detail.setOffCampusCityName(locationDetail.getOffCampusCityName());
                detail.setOffCampusStateCode(locationDetail.getOffCampusStateCode());
                detail.setOffCampusCountryCode(locationDetail.getOffCampusCountryCode());
                detail.setOffCampusZipCode(locationDetail.getOffCampusZipCode());
                newDetails.add(detail);
            }
        }
    }

    if (assetGlobal.getCapitalAssetTypeCode() != null) {
        assetGlobal.refreshReferenceObject(CamsPropertyConstants.AssetGlobal.CAPITAL_ASSET_TYPE);
        AssetType capitalAssetType = assetGlobal.getCapitalAssetType();
        if (ObjectUtils.isNotNull(capitalAssetType)) {
            if (capitalAssetType.getDepreciableLifeLimit() != null
                    && capitalAssetType.getDepreciableLifeLimit().intValue() != 0) {
                assetGlobal.setCapitalAssetInServiceDate(
                        assetGlobal.getCreateDate() == null ? getDateTimeService().getCurrentSqlDate()
                                : assetGlobal.getCreateDate());
            } else {
                assetGlobal.setCapitalAssetInServiceDate(null);
            }
            computeDepreciationDate(assetGlobal);
            // CSU 6702 BEGIN
            doPeriod13Changes(assetGlobal);
            // CSU 6702 END
        }
    }
    assetGlobal.getAssetGlobalDetails().clear();
    assetGlobal.getAssetGlobalDetails().addAll(newDetails);
}

From source file:org.kuali.kfs.module.cam.document.AssetPaymentDocument.java

/**
 * @see org.kuali.kfs.sys.document.AccountingDocumentBase#prepareForSave(org.kuali.rice.krad.rule.event.KualiDocumentEvent)
 *///from   w w  w  . j av  a 2 s . com
@Override
public void prepareForSave(KualiDocumentEvent event) {
    // This method  prevents kuali from generating a
    // gl pending entry record.

    for (AssetPaymentAssetDetail assetDetail : this.getAssetPaymentAssetDetail()) {
        assetDetail.refreshReferenceObject(CamsPropertyConstants.AssetPaymentAssetDetail.ASSET);
        if (ObjectUtils.isNotNull(assetDetail.getAsset())
                && assetDetail.getAsset().getTotalCostAmount() != null) {
            assetDetail.setPreviousTotalCostAmount(assetDetail.getAsset().getTotalCostAmount());
        }
        // CSU 6702 BEGIN Inferred change 
        List<AssetPaymentDetail> apdList = assetDetail.getAssetPaymentDetails();
        for (AssetPaymentDetail apd : apdList) {
            String accountingPeriodCompositeString = getAccountingPeriodCompositeString();
            apd.setPostingYear(new Integer(StringUtils.right(accountingPeriodCompositeString, 4)));
            apd.setPostingPeriodCode(StringUtils.left(accountingPeriodCompositeString, 2));
        }
        // CSU 6702 END Inferred change            
    }
}

From source file:org.kuali.kfs.module.cam.document.AssetTransferDocument.java

/**
 * KSMI-6702 FY End change/*w  ww.j  av  a 2s  . com*/
 * @see org.kuali.kfs.sys.document.GeneralLedgerPostingDocumentBase#prepareForSave(org.kuali.rice.kns.rule.event.KualiDocumentEvent)
 */
@Override
public void prepareForSave(KualiDocumentEvent event) {
    super.prepareForSave(event);
    String accountingPeriodCompositeString = getAccountingPeriodCompositeString();
    setPostingYear(new Integer(StringUtils.right(accountingPeriodCompositeString, 4)));
    setPostingPeriodCode(StringUtils.left(accountingPeriodCompositeString, 2));
}

From source file:org.kuali.kfs.sys.document.LedgerPostingDocumentBase.java

/**
 * Set accountingPeriod based on incoming paramater.
 * @param accountingPeriodString in the form of [period][year]
 *//*  www  . jav  a 2 s. c om*/
public void setAccountingPeriodCompositeString(String accountingPeriodString) {
    if (StringUtils.isNotBlank(accountingPeriodString)) {
        String period = StringUtils.left(accountingPeriodString, 2);
        Integer year = new Integer(StringUtils.right(accountingPeriodString, 4));
        AccountingPeriod accountingPeriod = getAccountingPeriodService().getByPeriod(period, year);
        setAccountingPeriod(accountingPeriod);
    }
}

From source file:org.ngrinder.model.PerfTest.java

public void setProgressMessage(String progressMessage) {
    this.progressMessage = StringUtils.defaultIfEmpty(StringUtils.right(progressMessage, MAX_STRING_SIZE), "");
}

From source file:org.ngrinder.model.PerfTest.java

public void setTestComment(String testComment) {
    this.testComment = StringUtils.trimToEmpty(StringUtils.right(testComment, MAX_STRING_SIZE));
}

From source file:org.openhab.binding.miele.handler.MieleApplianceHandler.java

@Override
public void onApplianceStateChanged(String UID, DeviceClassObject dco) {

    String myUID = "hdm:ZigBee:" + (String) getThing().getConfiguration().getProperties().get(APPLIANCE_ID);
    String modelID = StringUtils.right(dco.DeviceClass, dco.DeviceClass.length()
            - new String("com.miele.xgw3000.gateway.hdm.deviceclasses.Miele").length());

    if (myUID.equals(UID)) {

        if (modelID.equals(this.modelID)) {
            for (JsonElement prop : dco.Properties.getAsJsonArray()) {
                try {
                    DeviceProperty dp = gson.fromJson(prop, DeviceProperty.class);
                    dp.Value = StringUtils.trim(dp.Value);
                    dp.Value = StringUtils.strip(dp.Value);

                    onAppliancePropertyChanged(UID, dp);
                } catch (Exception p) {
                    // Ignore - this is due to an unrecognized and not yet reverse-engineered array property
                }/* w w w.jav a  2 s  .co  m*/
            }

            for (JsonElement operation : dco.Operations.getAsJsonArray()) {
                try {
                    DeviceOperation devop = gson.fromJson(operation, DeviceOperation.class);
                    DeviceMetaData pmd = gson.fromJson(devop.Metadata, DeviceMetaData.class);
                } catch (Exception p) {
                    // Ignore - this is due to an unrecognized and not yet reverse-engineered array property
                }
            }
        }
    }
}

From source file:org.openhab.binding.miele.internal.discovery.MieleApplianceDiscoveryService.java

private void onApplianceAddedInternal(HomeDevice appliance) {
    ThingUID thingUID = getThingUID(appliance);
    if (thingUID != null) {
        ThingUID bridgeUID = mieleBridgeHandler.getThing().getUID();
        Map<String, Object> properties = new HashMap<>(2);
        properties.put(APPLIANCE_ID,/* w  w w . j  av  a2  s  .  c  o m*/
                StringUtils.right(appliance.UID, appliance.UID.length() - new String("hdm:ZigBee:").length()));
        for (JsonElement dc : appliance.DeviceClasses) {
            if (dc.getAsString().contains("com.miele.xgw3000.gateway.hdm.deviceclasses.Miele")
                    && !dc.getAsString().equals("com.miele.xgw3000.gateway.hdm.deviceclasses.MieleAppliance")) {
                properties.put(DEVICE_CLASS, StringUtils.right(dc.getAsString(), dc.getAsString().length()
                        - new String("com.miele.xgw3000.gateway.hdm.deviceclasses.Miele").length()));
                break;
            }
        }

        DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(thingUID).withProperties(properties)
                .withBridge(bridgeUID).withLabel((String) properties.get(DEVICE_CLASS)).build();

        thingDiscovered(discoveryResult);
    } else {
        logger.debug("Discovered an unsupported appliance of vendor '{}' with id {}", appliance.Vendor,
                appliance.UID);
    }
}

From source file:org.openhab.binding.miele.internal.discovery.MieleApplianceDiscoveryService.java

private ThingUID getThingUID(HomeDevice appliance) {
    ThingUID bridgeUID = mieleBridgeHandler.getThing().getUID();
    String modelID = null;//from w w  w .j av  a 2  s.  c o  m

    for (JsonElement dc : appliance.DeviceClasses) {
        if (dc.getAsString().contains("com.miele.xgw3000.gateway.hdm.deviceclasses.Miele")
                && !dc.getAsString().equals("com.miele.xgw3000.gateway.hdm.deviceclasses.MieleAppliance")) {
            modelID = StringUtils.right(dc.getAsString(), dc.getAsString().length()
                    - new String("com.miele.xgw3000.gateway.hdm.deviceclasses.Miele").length());
            break;
        }
    }

    if (modelID != null) {
        ThingTypeUID thingTypeUID = new ThingTypeUID(BINDING_ID,
                StringUtils.lowerCase(modelID.replaceAll("[^a-zA-Z0-9_]", "_")));

        if (getSupportedThingTypes().contains(thingTypeUID)) {
            ThingUID thingUID = new ThingUID(thingTypeUID, bridgeUID, getId(appliance));
            return thingUID;
        } else {
            return null;
        }
    } else {
        return null;
    }
}

From source file:org.openhab.binding.miele.internal.discovery.MieleApplianceDiscoveryService.java

private String getId(HomeDevice appliance) {
    return StringUtils.right(appliance.UID, appliance.UID.length() - new String("hdm:ZigBee:").length())
            .replaceAll("[^a-zA-Z0-9_]", "_");
}