/** * Check if given capitalAssetNumber is an duplicate number in assetNumbers list. * * @param capitalAssetNumber * @param assetNumbers * @return */ protected boolean isAssetNumberDuplicate( Long candidateNumber, List<ItemCapitalAsset> assetNumbers) { for (ItemCapitalAsset existingNumber : assetNumbers) { if (existingNumber.getCapitalAssetNumber().equals(candidateNumber)) { return true; } } return false; }
/** * Get asset number list from ItemCapitalAsset list. * * @param itemCapitalAssets * @return */ protected List<ItemCapitalAsset> getAssetsFromItemCapitalAsset( List<ItemCapitalAsset> itemCapitalAssets) { List<ItemCapitalAsset> assetNumbers = new ArrayList<ItemCapitalAsset>(); for (ItemCapitalAsset asset : itemCapitalAssets) { if (asset.getCapitalAssetNumber() != null && !isAssetNumberDuplicate(asset.getCapitalAssetNumber(), assetNumbers)) { assetNumbers.add(asset); } } return assetNumbers; }
public List<Long> retrieveValidAssetNumberForLocking( Integer poId, String capitalAssetSystemTypeCode, PurApItem purApItem) { List<Long> capitalAssetNumbers = new ArrayList<Long>(); CapitalAssetSystem capitalAssetSystem = null; if (PurapConstants.CapitalAssetTabStrings.INDIVIDUAL_ASSETS.equalsIgnoreCase( capitalAssetSystemTypeCode)) { // If PurAp sets the CAMS as INDIVIDUAL system capitalAssetSystem = getCapitalAssetSystemForIndividual(poId, purApItem); } else if (PurapConstants.CapitalAssetTabStrings.ONE_SYSTEM.equalsIgnoreCase( capitalAssetSystemTypeCode)) { capitalAssetSystem = this.getPurchaseOrderService().retrieveCapitalAssetSystemForOneSystem(poId); } else if (PurapConstants.CapitalAssetTabStrings.MULTIPLE_SYSTEMS.equalsIgnoreCase( capitalAssetSystemTypeCode)) { List<CapitalAssetSystem> capitalAssetSystems = this.getPurchaseOrderService().retrieveCapitalAssetSystemsForMultipleSystem(poId); if (ObjectUtils.isNotNull(capitalAssetSystems) && !capitalAssetSystems.isEmpty()) { // PurAp doesn't support multiple system asset information for KFS3.0. It works as One // system. capitalAssetSystem = capitalAssetSystems.get(0); } } if (ObjectUtils.isNotNull(capitalAssetSystem) && capitalAssetSystem.getItemCapitalAssets() != null && !capitalAssetSystem.getItemCapitalAssets().isEmpty()) { for (ItemCapitalAsset itemCapitalAsset : capitalAssetSystem.getItemCapitalAssets()) { if (itemCapitalAsset.getCapitalAssetNumber() != null) { Map pKeys = new HashMap<String, Object>(); // Asset must be valid and capital active 'A','C','S','U' pKeys.put( CamsPropertyConstants.Asset.CAPITAL_ASSET_NUMBER, itemCapitalAsset.getCapitalAssetNumber()); Asset asset = (Asset) businessObjectService.findByPrimaryKey(Asset.class, pKeys); if (ObjectUtils.isNotNull(asset) && getAssetService().isCapitalAsset(asset) && !getAssetService().isAssetRetired(asset)) { capitalAssetNumbers.add(itemCapitalAsset.getCapitalAssetNumber()); } } } } return capitalAssetNumbers; }