Search in sources :

Example 16 with CapitalAssetSystem

use of org.kuali.kfs.integration.purap.CapitalAssetSystem in project cu-kfs by CU-CommunityApps.

the class PurchasingActionBase method updateCapitalAssetLocation.

protected void updateCapitalAssetLocation(HttpServletRequest request, PurchasingFormBase purchasingForm, PurchasingDocument document, String buildingCodeParam) {
    String buildingCode = request.getParameterValues(buildingCodeParam)[0];
    String campusCodeParam = buildingCodeParam.replace("buildingCode", "campusCode");
    String campusCode = request.getParameterValues(campusCodeParam)[0];
    Building locationBuilding = findBuilding(buildingCode, campusCode);
    CapitalAssetLocation location = null;
    boolean isNewLine = StringUtils.containsIgnoreCase(buildingCodeParam, "newPurchasingCapitalAssetLocationLine");
    if (isNewLine) {
        if (document.getCapitalAssetSystemType().getCapitalAssetSystemTypeCode().equals(PurapConstants.CapitalAssetSystemTypes.INDIVIDUAL)) {
            String locationCapitalAssetItemNumber = getCaptialAssetItemNumberFromParameter(buildingCodeParam);
            PurchasingCapitalAssetItem capitalAssetItem = document.getPurchasingCapitalAssetItems().get(Integer.parseInt(locationCapitalAssetItemNumber));
            location = capitalAssetItem.getPurchasingCapitalAssetSystem().getNewPurchasingCapitalAssetLocationLine();
        } else {
            location = purchasingForm.getNewPurchasingCapitalAssetLocationLine();
        }
    } else if (StringUtils.containsIgnoreCase(buildingCodeParam, "purchasingCapitalAssetLocationLine")) {
        String locationCapitalAssetLocationNumber = getCaptialAssetLocationNumberFromParameter(buildingCodeParam);
        if (document.getCapitalAssetSystemType().getCapitalAssetSystemTypeCode().equals(PurapConstants.CapitalAssetSystemTypes.INDIVIDUAL)) {
            String locationCapitalAssetItemNumber = getCaptialAssetItemNumberFromParameter(buildingCodeParam);
            PurchasingCapitalAssetItem capitalAssetItem = document.getPurchasingCapitalAssetItems().get(Integer.parseInt(locationCapitalAssetItemNumber));
            location = capitalAssetItem.getPurchasingCapitalAssetSystem().getCapitalAssetLocations().get(Integer.parseInt(locationCapitalAssetLocationNumber));
        }
    } else if (StringUtils.containsIgnoreCase(buildingCodeParam, "purchasingCapitalAssetSystem")) {
        String locationCapitalAssetLocationNumber = getCaptialAssetLocationNumberFromParameter(buildingCodeParam);
        if (document.getCapitalAssetSystemType().getCapitalAssetSystemTypeCode().equals(PurapConstants.CapitalAssetSystemTypes.INDIVIDUAL)) {
            String locationCapitalAssetItemNumber = getCaptialAssetItemNumberFromParameter(buildingCodeParam);
            PurchasingCapitalAssetItem capitalAssetItem = document.getPurchasingCapitalAssetItems().get(Integer.parseInt(locationCapitalAssetItemNumber));
            location = capitalAssetItem.getPurchasingCapitalAssetSystem().getCapitalAssetLocations().get(Integer.parseInt(locationCapitalAssetLocationNumber));
        } else {
            CapitalAssetSystem capitalAssetSystem = document.getPurchasingCapitalAssetSystems().get(0);
            location = capitalAssetSystem.getCapitalAssetLocations().get(Integer.parseInt(locationCapitalAssetLocationNumber));
        }
    }
    if (location != null) {
        location.templateBuilding(locationBuilding);
    }
    if (locationBuilding == null && !(isNewLine && buildingCode.isEmpty())) {
        // ignore scenario where isNewLine and it's empty as this is the default case; only validate new lines if
        // data exists
        GlobalVariables.getMessageMap().putError(buildingCodeParam, PurapKeyConstants.ERROR_CAPITAL_ASSET_LOCATION_BUILDING_CODE_INVALID);
    }
}
Also used : Building(org.kuali.kfs.sys.businessobject.Building) CapitalAssetLocation(org.kuali.kfs.integration.purap.CapitalAssetLocation) PurchasingCapitalAssetItem(org.kuali.kfs.module.purap.businessobject.PurchasingCapitalAssetItem) CapitalAssetSystem(org.kuali.kfs.integration.purap.CapitalAssetSystem)

Aggregations

CapitalAssetSystem (org.kuali.kfs.integration.purap.CapitalAssetSystem)16 PurchasingDocument (org.kuali.kfs.module.purap.document.PurchasingDocument)14 PurchasingCapitalAssetItem (org.kuali.kfs.module.purap.businessobject.PurchasingCapitalAssetItem)8 KualiRuleService (org.kuali.kfs.krad.service.KualiRuleService)4 CapitalAssetLocation (org.kuali.kfs.integration.purap.CapitalAssetLocation)3 ItemCapitalAsset (org.kuali.kfs.integration.purap.ItemCapitalAsset)2 AttributedAddPurchasingCapitalAssetLocationEvent (org.kuali.kfs.module.purap.document.validation.event.AttributedAddPurchasingCapitalAssetLocationEvent)2 AttributedAddPurchasingItemCapitalAssetEvent (org.kuali.kfs.module.purap.document.validation.event.AttributedAddPurchasingItemCapitalAssetEvent)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 BusinessObjectService (org.kuali.kfs.krad.service.BusinessObjectService)1 SequenceAccessorService (org.kuali.kfs.krad.service.SequenceAccessorService)1 PurApItem (org.kuali.kfs.module.purap.businessobject.PurApItem)1 PurchaseOrderCapitalAssetSystem (org.kuali.kfs.module.purap.businessobject.PurchaseOrderCapitalAssetSystem)1 PurchaseOrderItem (org.kuali.kfs.module.purap.businessobject.PurchaseOrderItem)1 PurchaseOrderSensitiveData (org.kuali.kfs.module.purap.businessobject.PurchaseOrderSensitiveData)1 PurchasingItemBase (org.kuali.kfs.module.purap.businessobject.PurchasingItemBase)1 RequisitionCapitalAssetItem (org.kuali.kfs.module.purap.businessobject.RequisitionCapitalAssetItem)1 RequisitionItem (org.kuali.kfs.module.purap.businessobject.RequisitionItem)1