Search in sources :

Example 1 with AssetLocation

use of org.kuali.kfs.module.cam.businessobject.AssetLocation in project cu-kfs by CU-CommunityApps.

the class CuAssetLookupableHelperServiceImpl method excludeBlankOffCampusLocations.

protected List<? extends BusinessObject> excludeBlankOffCampusLocations(List<? extends BusinessObject> results) {
    List<Asset> resultsModified = new ArrayList<Asset>();
    int count = 0;
    LOG.info("Asset count: " + results.size());
    for (BusinessObject boAsset : results) {
        Asset asset;
        if (boAsset instanceof Asset) {
            count++;
            boolean remove = false;
            asset = (Asset) boAsset;
            List<AssetLocation> locs = asset.getAssetLocations();
            if (locs.isEmpty()) {
                resultsModified.add(asset);
            }
            LOG.info("Asset location counts: " + locs.size());
            for (AssetLocation assetLoc : locs) {
                if (StringUtils.equalsIgnoreCase(assetLoc.getAssetLocationTypeCode(), "O")) {
                    remove |= StringUtils.isBlank(assetLoc.getAssetLocationStreetAddress());
                }
            }
            if (!remove) {
                resultsModified.add(asset);
            } else {
                LOG.info("Removing asset: " + asset.getCapitalAssetNumber());
            }
        } else {
            break;
        }
    }
    LOG.info("Assets reviewed: " + count);
    LOG.info("Results returned: " + resultsModified.size());
    return resultsModified;
}
Also used : AssetLocation(org.kuali.kfs.module.cam.businessobject.AssetLocation) ArrayList(java.util.ArrayList) Asset(org.kuali.kfs.module.cam.businessobject.Asset) BusinessObject(org.kuali.rice.krad.bo.BusinessObject)

Aggregations

ArrayList (java.util.ArrayList)1 Asset (org.kuali.kfs.module.cam.businessobject.Asset)1 AssetLocation (org.kuali.kfs.module.cam.businessobject.AssetLocation)1 BusinessObject (org.kuali.rice.krad.bo.BusinessObject)1