Search in sources :

Example 1 with CapitalAssetEditable

use of org.kuali.kfs.fp.document.CapitalAssetEditable in project cu-kfs by CU-CommunityApps.

the class CapitalAssetInformationActionBase method copy.

/**
 * Overridden to guarantee that form of copied document is set to whatever the entry mode of the document is
 *
 * @see org.kuali.rice.kns.web.struts.action.KualiTransactionalDocumentActionBase#copy(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 */
@Override
public ActionForward copy(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    CapitalAccountingLinesFormBase capitalAccountingLinesFormBase = (CapitalAccountingLinesFormBase) form;
    ;
    CapitalAccountingLinesDocumentBase caldb = (CapitalAccountingLinesDocumentBase) capitalAccountingLinesFormBase.getFinancialDocument();
    List<CapitalAccountingLines> capitalAccountingLines = caldb.getCapitalAccountingLines();
    List<CapitalAccountingLines> copiedCapitalAccountingLines = new ArrayList<>();
    for (CapitalAccountingLines capitalAccountingLine : capitalAccountingLines) {
        copiedCapitalAccountingLines.add(capitalAccountingLine);
    }
    capitalAccountingLines.clear();
    ActionForward forward = super.copy(mapping, form, request, response);
    caldb.setCapitalAccountingLines(copiedCapitalAccountingLines);
    // if the copied document has capital asset collection, remove the collection
    KualiAccountingDocumentFormBase kualiAccountingDocumentFormBase = (KualiAccountingDocumentFormBase) form;
    AccountingDocument document = kualiAccountingDocumentFormBase.getFinancialDocument();
    if (document instanceof CapitalAssetEditable) {
        CapitalAssetEditable capitalAssetEditable = (CapitalAssetEditable) document;
        List<CapitalAssetInformation> capitalAssets = capitalAssetEditable.getCapitalAssetInformation();
        for (CapitalAssetInformation capitalAsset : capitalAssets) {
            Long capitalAssetNumber = capitalAsset.getCapitalAssetNumber();
            resetCapitalAssetInfo(capitalAsset);
            // because resetCapitalAssetInfo cleared the value.
            if (KFSConstants.CapitalAssets.CAPITAL_ASSET_MODIFY_ACTION_INDICATOR.equalsIgnoreCase(capitalAsset.getCapitalAssetActionIndicator())) {
                capitalAsset.setCapitalAssetNumber(capitalAssetNumber);
            }
            capitalAsset.setCapitalAssetProcessedIndicator(false);
        }
    }
    // setup the initial next sequence number column..
    KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form;
    setupIntialNextCapitalAssetLineNumber(kualiDocumentFormBase);
    checkCapitalAccountingLinesSelected(capitalAccountingLinesFormBase);
    return forward;
}
Also used : CapitalAssetInformation(org.kuali.kfs.fp.businessobject.CapitalAssetInformation) ArrayList(java.util.ArrayList) CapitalAccountingLinesDocumentBase(org.kuali.kfs.fp.document.CapitalAccountingLinesDocumentBase) ActionForward(org.apache.struts.action.ActionForward) CapitalAssetEditable(org.kuali.kfs.fp.document.CapitalAssetEditable) CapitalAccountingLines(org.kuali.kfs.fp.businessobject.CapitalAccountingLines) KualiDocumentFormBase(org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase) AccountingDocument(org.kuali.kfs.sys.document.AccountingDocument) KualiAccountingDocumentFormBase(org.kuali.kfs.sys.web.struts.KualiAccountingDocumentFormBase)

Example 2 with CapitalAssetEditable

use of org.kuali.kfs.fp.document.CapitalAssetEditable 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 CapitalAssetEditable

use of org.kuali.kfs.fp.document.CapitalAssetEditable in project cu-kfs by CU-CommunityApps.

the class CapitalAssetInformationActionBase method getCurrentCapitalAssetInformationObject.

/**
 * get the capital asset information object currently associated with the document
 */
protected List<CapitalAssetInformation> getCurrentCapitalAssetInformationObject(KualiAccountingDocumentFormBase kualiAccountingDocumentFormBase) {
    LOG.debug("getCurrentCapitalAssetInformationObject() - start");
    CapitalAssetInformationDocumentBase capitalAssetInformationDocumentBase = (CapitalAssetInformationDocumentBase) kualiAccountingDocumentFormBase.getFinancialDocument();
    if (!(capitalAssetInformationDocumentBase instanceof CapitalAssetEditable)) {
        return null;
    }
    List<CapitalAssetInformation> capitalAssetInformation = capitalAssetInformationDocumentBase.getCapitalAssetInformation();
    return capitalAssetInformation;
}
Also used : CapitalAssetInformation(org.kuali.kfs.fp.businessobject.CapitalAssetInformation) CapitalAssetInformationDocumentBase(org.kuali.kfs.fp.document.CapitalAssetInformationDocumentBase) CapitalAssetEditable(org.kuali.kfs.fp.document.CapitalAssetEditable)

Aggregations

CapitalAssetInformation (org.kuali.kfs.fp.businessobject.CapitalAssetInformation)3 CapitalAssetEditable (org.kuali.kfs.fp.document.CapitalAssetEditable)3 CapitalAssetInformationDetailExtendedAttribute (edu.cornell.kfs.fp.businessobject.CapitalAssetInformationDetailExtendedAttribute)1 ArrayList (java.util.ArrayList)1 ActionForward (org.apache.struts.action.ActionForward)1 CapitalAccountingLines (org.kuali.kfs.fp.businessobject.CapitalAccountingLines)1 CapitalAssetInformationDetail (org.kuali.kfs.fp.businessobject.CapitalAssetInformationDetail)1 CapitalAccountingLinesDocumentBase (org.kuali.kfs.fp.document.CapitalAccountingLinesDocumentBase)1 CapitalAssetInformationDocumentBase (org.kuali.kfs.fp.document.CapitalAssetInformationDocumentBase)1 KualiDocumentFormBase (org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase)1 AssetType (org.kuali.kfs.module.cam.businessobject.AssetType)1 Building (org.kuali.kfs.sys.businessobject.Building)1 Room (org.kuali.kfs.sys.businessobject.Room)1 AccountingDocument (org.kuali.kfs.sys.document.AccountingDocument)1 KualiAccountingDocumentFormBase (org.kuali.kfs.sys.web.struts.KualiAccountingDocumentFormBase)1 Campus (org.kuali.rice.location.api.campus.Campus)1