Search in sources :

Example 1 with Building

use of org.kuali.kfs.sys.businessobject.Building in project cu-kfs by CU-CommunityApps.

the class PurchasingActionBase method updateDeliveryBuilding.

protected void updateDeliveryBuilding(HttpServletRequest request, PurchasingDocument document) {
    String buildingCode = request.getParameter("document.deliveryBuildingCode");
    String campusCode = request.getParameter("document.deliveryCampusCode");
    Building deliveryBuilding = findBuilding(buildingCode, campusCode);
    if (deliveryBuilding != null) {
        document.setDeliveryBuildingName(deliveryBuilding.getBuildingName());
        document.setDeliveryBuildingLine1Address(deliveryBuilding.getBuildingStreetAddress());
        document.setDeliveryBuildingLine2Address("");
        document.setDeliveryBuildingRoomNumber("");
        document.setDeliveryCityName(deliveryBuilding.getBuildingAddressCityName());
        document.setDeliveryStateCode(deliveryBuilding.getBuildingAddressStateCode());
        document.setDeliveryPostalCode(deliveryBuilding.getBuildingAddressZipCode());
        document.setDeliveryCountryCode(deliveryBuilding.getBuildingAddressCountryCode());
    } else {
        clearDeliveryBuildingInfo(document, false);
        GlobalVariables.getMessageMap().putError("document.deliveryBuildingCode", PurapKeyConstants.ERROR_DELIVERY_BUILDING_CODE_INVALID);
    }
}
Also used : Building(org.kuali.kfs.sys.businessobject.Building)

Example 2 with Building

use of org.kuali.kfs.sys.businessobject.Building in project cu-kfs by CU-CommunityApps.

the class CuCapitalAssetManagementModuleServiceImpl method validateAssetTagLocationLines.

protected boolean validateAssetTagLocationLines(CapitalAssetInformation capitalAssetInformation, int capitalAssetIndex, AccountingDocument accountingDocument) {
    boolean valid = true;
    CapitalAssetEditable capitalAssetEditable = (CapitalAssetEditable) accountingDocument;
    List<CapitalAssetInformation> capitalAssets = capitalAssetEditable.getCapitalAssetInformation();
    List<CapitalAssetInformationDetail> capitalAssetInformationDetails = capitalAssetInformation.getCapitalAssetInformationDetails();
    int index = 0;
    for (CapitalAssetInformationDetail dtl : capitalAssetInformationDetails) {
        CapitalAssetInformationDetailExtendedAttribute capDetailExt = (CapitalAssetInformationDetailExtendedAttribute) dtl.getExtension();
        String assetLocationCityName = capDetailExt.getAssetLocationCityName();
        String assetLocationCountryCode = capDetailExt.getAssetLocationCountryCode();
        String assetLocationStateCode = capDetailExt.getAssetLocationStateCode();
        String assetLocationStreetAddress = capDetailExt.getAssetLocationStreetAddress();
        String assetLocationZipCode = capDetailExt.getAssetLocationZipCode();
        // We have to explicitly call this DD service to upper case each field. This may not be the best place and maybe form
        // populate is a better place but we CAMS team don't own FP document. This is the best we can do for now.
        businessObjectDictionaryService.performForceUppercase(dtl);
        String errorPathPrefix = KFSPropertyConstants.DOCUMENT + "." + KFSPropertyConstants.CAPITAL_ASSET_INFORMATION + "[" + capitalAssetIndex + "]." + KFSPropertyConstants.CAPITAL_ASSET_INFORMATION_DETAILS;
        if (StringUtils.isNotBlank(dtl.getCampusCode())) {
            Campus campus = campusService.getCampus(dtl.getCampusCode());
            if (ObjectUtils.isNull(campus)) {
                valid = false;
                String label = this.getDataDictionaryService().getAttributeLabel(Campus.class, KFSPropertyConstants.CODE);
                GlobalVariables.getMessageMap().putErrorWithoutFullErrorPath(errorPathPrefix + "[" + index + "]" + "." + KFSPropertyConstants.CAMPUS_CODE, KFSKeyConstants.ERROR_EXISTENCE, label);
            }
        }
        Map<String, String> params;
        if (StringUtils.isNotBlank(dtl.getCampusCode()) && StringUtils.isNotBlank(dtl.getBuildingCode()) && StringUtils.isBlank(assetLocationCityName) && StringUtils.isBlank(assetLocationStateCode) && StringUtils.isBlank(assetLocationCountryCode) && StringUtils.isBlank(assetLocationStreetAddress) && StringUtils.isBlank(assetLocationZipCode)) {
            params = new HashMap<String, String>();
            params.put(KFSPropertyConstants.CAMPUS_CODE, dtl.getCampusCode());
            params.put(KFSPropertyConstants.BUILDING_CODE, dtl.getBuildingCode());
            Building building = businessObjectService.findByPrimaryKey(Building.class, params);
            // Check if building is valid
            if (ObjectUtils.isNull(building)) {
                valid = false;
                GlobalVariables.getMessageMap().putErrorWithoutFullErrorPath(errorPathPrefix + "[" + index + "]" + "." + KFSPropertyConstants.BUILDING_CODE, CamsKeyConstants.AssetLocationGlobal.ERROR_INVALID_BUILDING_CODE, dtl.getBuildingCode(), dtl.getCampusCode());
            }
        }
        AssetType assetType = getAssetType(capitalAssetInformation.getCapitalAssetTypeCode());
        if (StringUtils.isBlank(assetLocationCityName) && StringUtils.isBlank(assetLocationStateCode) && StringUtils.isBlank(assetLocationCountryCode) && StringUtils.isBlank(assetLocationStreetAddress) && StringUtils.isBlank(assetLocationZipCode)) {
            // If building was specified but was not required for this asset type display an error
            if (StringUtils.isNotBlank(dtl.getBuildingCode()) && ObjectUtils.isNotNull(assetType) && !assetType.isMovingIndicator() && !assetType.isRequiredBuildingIndicator()) {
                valid = false;
                String label = this.getDataDictionaryService().getAttributeLabel(Building.class, KFSPropertyConstants.BUILDING_CODE);
                GlobalVariables.getMessageMap().putErrorWithoutFullErrorPath(errorPathPrefix + "[" + index + "]" + "." + KFSPropertyConstants.BUILDING_CODE, CamsKeyConstants.AssetLocation.ERROR_ASSET_LOCATION_BUILDING_NONMOVEABLE, label);
            }
            if (StringUtils.isNotBlank(dtl.getCampusCode()) && StringUtils.isNotBlank(dtl.getBuildingCode()) && StringUtils.isNotBlank(dtl.getBuildingRoomNumber())) {
                params = new HashMap<>();
                params.put(KFSPropertyConstants.CAMPUS_CODE, dtl.getCampusCode());
                params.put(KFSPropertyConstants.BUILDING_CODE, dtl.getBuildingCode());
                params.put(KFSPropertyConstants.BUILDING_ROOM_NUMBER, dtl.getBuildingRoomNumber());
                Room room = businessObjectService.findByPrimaryKey(Room.class, params);
                // Check if room is valid
                if (ObjectUtils.isNull(room)) {
                    valid = false;
                    GlobalVariables.getMessageMap().putErrorWithoutFullErrorPath(errorPathPrefix + "[" + index + "]" + "." + KFSPropertyConstants.BUILDING_ROOM_NUMBER, CamsKeyConstants.AssetLocationGlobal.ERROR_INVALID_ROOM_NUMBER, dtl.getBuildingRoomNumber(), dtl.getBuildingCode(), dtl.getCampusCode());
                }
            }
            // If room was specified but was not required for this asset type display an error
            if (StringUtils.isNotBlank(dtl.getBuildingRoomNumber()) && ObjectUtils.isNotNull(assetType) && !assetType.isMovingIndicator()) {
                valid = false;
                String label = this.getDataDictionaryService().getAttributeLabel(Room.class, KFSPropertyConstants.BUILDING_ROOM_NUMBER);
                GlobalVariables.getMessageMap().putErrorWithoutFullErrorPath(errorPathPrefix + "[" + index + "]" + "." + KFSPropertyConstants.BUILDING_ROOM_NUMBER, CamsKeyConstants.AssetLocation.ERROR_ASSET_LOCATION_ROOM_NUMBER_NONMOVEABLE, label);
            }
        }
        index++;
    }
    return valid;
}
Also used : CapitalAssetInformation(org.kuali.kfs.fp.businessobject.CapitalAssetInformation) Building(org.kuali.kfs.sys.businessobject.Building) Campus(org.kuali.rice.location.api.campus.Campus) CapitalAssetInformationDetail(org.kuali.kfs.fp.businessobject.CapitalAssetInformationDetail) CapitalAssetEditable(org.kuali.kfs.fp.document.CapitalAssetEditable) AssetType(org.kuali.kfs.module.cam.businessobject.AssetType) CapitalAssetInformationDetailExtendedAttribute(edu.cornell.kfs.fp.businessobject.CapitalAssetInformationDetailExtendedAttribute) Room(org.kuali.kfs.sys.businessobject.Room)

Example 3 with Building

use of org.kuali.kfs.sys.businessobject.Building in project cu-kfs by CU-CommunityApps.

the class PurchasingActionBase method findBuilding.

private Building findBuilding(String buildingCode, String campusCode) {
    Building building = new Building();
    building.setCampusCode(campusCode);
    building.setBuildingCode(buildingCode.toUpperCase());
    Map<String, String> keys = SpringContext.getBean(PersistenceService.class).getPrimaryKeyFieldValues(building);
    building = SpringContext.getBean(BusinessObjectService.class).findByPrimaryKey(Building.class, keys);
    return building;
}
Also used : Building(org.kuali.kfs.sys.businessobject.Building) PersistenceService(org.kuali.kfs.krad.service.PersistenceService)

Example 4 with Building

use of org.kuali.kfs.sys.businessobject.Building 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

Building (org.kuali.kfs.sys.businessobject.Building)4 CapitalAssetInformationDetailExtendedAttribute (edu.cornell.kfs.fp.businessobject.CapitalAssetInformationDetailExtendedAttribute)1 CapitalAssetInformation (org.kuali.kfs.fp.businessobject.CapitalAssetInformation)1 CapitalAssetInformationDetail (org.kuali.kfs.fp.businessobject.CapitalAssetInformationDetail)1 CapitalAssetEditable (org.kuali.kfs.fp.document.CapitalAssetEditable)1 CapitalAssetLocation (org.kuali.kfs.integration.purap.CapitalAssetLocation)1 CapitalAssetSystem (org.kuali.kfs.integration.purap.CapitalAssetSystem)1 PersistenceService (org.kuali.kfs.krad.service.PersistenceService)1 AssetType (org.kuali.kfs.module.cam.businessobject.AssetType)1 PurchasingCapitalAssetItem (org.kuali.kfs.module.purap.businessobject.PurchasingCapitalAssetItem)1 Room (org.kuali.kfs.sys.businessobject.Room)1 Campus (org.kuali.rice.location.api.campus.Campus)1