Search in sources :

Example 1 with CapitalAssetLocation

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

the class PurchasingActionBase method addCapitalAssetLocationByItem.

public ActionForward addCapitalAssetLocationByItem(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    PurchasingFormBase purchasingForm = (PurchasingFormBase) form;
    PurchasingDocument purDocument = (PurchasingDocument) purchasingForm.getDocument();
    CapitalAssetLocation location = purDocument.getPurchasingCapitalAssetItems().get(getSelectedLine(request)).getPurchasingCapitalAssetSystem().getNewPurchasingCapitalAssetLocationLine();
    boolean rulePassed = SpringContext.getBean(KualiRuleService.class).applyRules(new AttributedAddPurchasingCapitalAssetLocationEvent("", purDocument, location));
    if (rulePassed) {
        // get specific asset item and grab system as well and attach asset location
        PurchasingCapitalAssetItem assetItem = purDocument.getPurchasingCapitalAssetItems().get(getSelectedLine(request));
        CapitalAssetSystem system = assetItem.getPurchasingCapitalAssetSystem();
        location.setCapitalAssetSystemIdentifier(system.getCapitalAssetSystemIdentifier());
        system.getCapitalAssetLocations().add(location);
        // now reset the location as all the rules are passed successfully
        purDocument.getPurchasingCapitalAssetItems().get(getSelectedLine(request)).getPurchasingCapitalAssetSystem().resetNewPurchasingCapitalAssetLocationLine();
    }
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : KualiRuleService(org.kuali.kfs.krad.service.KualiRuleService) AttributedAddPurchasingCapitalAssetLocationEvent(org.kuali.kfs.module.purap.document.validation.event.AttributedAddPurchasingCapitalAssetLocationEvent) CapitalAssetLocation(org.kuali.kfs.integration.purap.CapitalAssetLocation) PurchasingCapitalAssetItem(org.kuali.kfs.module.purap.businessobject.PurchasingCapitalAssetItem) PurchasingDocument(org.kuali.kfs.module.purap.document.PurchasingDocument) CapitalAssetSystem(org.kuali.kfs.integration.purap.CapitalAssetSystem)

Example 2 with CapitalAssetLocation

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

the class PurchasingFormBase method getAndResetNewPurchasingCapitalAssetLocationLine.

public CapitalAssetLocation getAndResetNewPurchasingCapitalAssetLocationLine() {
    CapitalAssetLocation assetLocation = getNewPurchasingCapitalAssetLocationLine();
    setNewPurchasingCapitalAssetLocationLine(setupNewPurchasingCapitalAssetLocationLine());
    return assetLocation;
}
Also used : CapitalAssetLocation(org.kuali.kfs.integration.purap.CapitalAssetLocation)

Example 3 with CapitalAssetLocation

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

the class PurchasingActionBase method addCapitalAssetLocationByDocument.

public ActionForward addCapitalAssetLocationByDocument(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    PurchasingFormBase purchasingForm = (PurchasingFormBase) form;
    CapitalAssetLocation location = purchasingForm.getAndResetNewPurchasingCapitalAssetLocationLine();
    PurchasingDocument purDocument = (PurchasingDocument) purchasingForm.getDocument();
    boolean rulePassed = SpringContext.getBean(KualiRuleService.class).applyRules(new AttributedAddPurchasingCapitalAssetLocationEvent("", purDocument, location));
    rulePassed = rulePassed && SpringContext.getBean(PurchasingService.class).checkCapitalAssetLocation(location);
    if (rulePassed) {
        // get specific asset item and grab system as well and attach asset number
        CapitalAssetSystem system = purDocument.getPurchasingCapitalAssetSystems().get(getSelectedLine(request));
        location.setCapitalAssetSystemIdentifier(system.getCapitalAssetSystemIdentifier());
        system.getCapitalAssetLocations().add(location);
    }
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : KualiRuleService(org.kuali.kfs.krad.service.KualiRuleService) AttributedAddPurchasingCapitalAssetLocationEvent(org.kuali.kfs.module.purap.document.validation.event.AttributedAddPurchasingCapitalAssetLocationEvent) CapitalAssetLocation(org.kuali.kfs.integration.purap.CapitalAssetLocation) PurchasingDocument(org.kuali.kfs.module.purap.document.PurchasingDocument) PurchasingService(org.kuali.kfs.module.purap.document.service.PurchasingService) CapitalAssetSystem(org.kuali.kfs.integration.purap.CapitalAssetSystem)

Example 4 with CapitalAssetLocation

use of org.kuali.kfs.integration.purap.CapitalAssetLocation 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

CapitalAssetLocation (org.kuali.kfs.integration.purap.CapitalAssetLocation)4 CapitalAssetSystem (org.kuali.kfs.integration.purap.CapitalAssetSystem)3 KualiRuleService (org.kuali.kfs.krad.service.KualiRuleService)2 PurchasingCapitalAssetItem (org.kuali.kfs.module.purap.businessobject.PurchasingCapitalAssetItem)2 PurchasingDocument (org.kuali.kfs.module.purap.document.PurchasingDocument)2 AttributedAddPurchasingCapitalAssetLocationEvent (org.kuali.kfs.module.purap.document.validation.event.AttributedAddPurchasingCapitalAssetLocationEvent)2 PurchasingService (org.kuali.kfs.module.purap.document.service.PurchasingService)1 Building (org.kuali.kfs.sys.businessobject.Building)1