Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KFSPTS-31812 fix asset global doc when asset representative is not set or is non Cornell person #1609

Merged
merged 3 commits into from
May 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
package edu.cornell.kfs.module.cam.document.service.impl;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.kuali.kfs.krad.util.ObjectUtils;
import org.kuali.kfs.module.cam.CamsConstants;
import org.kuali.kfs.module.cam.businessobject.Asset;
import org.kuali.kfs.module.cam.businessobject.AssetGlobal;
import org.kuali.kfs.module.cam.businessobject.AssetGlobalDetail;
import org.kuali.kfs.module.cam.businessobject.AssetLocation;
import org.kuali.kfs.module.cam.document.service.impl.AssetGlobalServiceImpl;

import edu.cornell.kfs.module.cam.businessobject.AssetExtension;

public class CuAssetGlobalServiceImpl extends AssetGlobalServiceImpl {
private static final Logger LOG = LogManager.getLogger();

// KFSUPGRADE-535
// if we need to implement service rate ind, then it can be populated from detail to assetext too.
Expand All @@ -19,5 +25,46 @@ protected Asset setupAsset(final AssetGlobal assetGlobal, final AssetGlobalDetai
return asset;

}

/*
* This method is overridden to prevent an NPE when the Asset Representative is null
* when FINP-11058 is is brought into our over lay we should be able to remove this override
*/
@Override
protected void setupAssetLocationOffCampus(final AssetGlobalDetail assetGlobalDetail, final Asset asset) {
// We are not checking if it already exists since on a new asset it can't
final AssetLocation offCampusAssetLocation = new AssetLocation();
offCampusAssetLocation.setCapitalAssetNumber(asset.getCapitalAssetNumber());
offCampusAssetLocation.setAssetLocationTypeCode(CamsConstants.AssetLocationTypeCode.OFF_CAMPUS);
asset.getAssetLocations().add(offCampusAssetLocation);

// Set the location fields either way
offCampusAssetLocation.setAssetLocationContactName(assetGlobalDetail.getOffCampusName());
offCampusAssetLocation.setAssetLocationContactIdentifier(assetGlobalDetail.getRepresentativeUniversalIdentifier());
processAssetLocationInstitutionName(assetGlobalDetail, offCampusAssetLocation);
offCampusAssetLocation.setAssetLocationStreetAddress(assetGlobalDetail.getOffCampusAddress());
offCampusAssetLocation.setAssetLocationCityName(assetGlobalDetail.getOffCampusCityName());
offCampusAssetLocation.setAssetLocationStateCode(assetGlobalDetail.getOffCampusStateCode());
offCampusAssetLocation.setAssetLocationCountryCode(assetGlobalDetail.getOffCampusCountryCode());
offCampusAssetLocation.setAssetLocationZipCode(assetGlobalDetail.getOffCampusZipCode());

// There is no phone number field on Asset Global... odd...
offCampusAssetLocation.setAssetLocationPhoneNumber(null);
}

/*
* CU-Customization
* The asset representative might not be a Cornell person, so we need to handle this situation
* KualiCo jira FINP-11058 should address this bug
*/
private void processAssetLocationInstitutionName(final AssetGlobalDetail assetGlobalDetail,
final AssetLocation offCampusAssetLocation) {
if (ObjectUtils.isNotNull(assetGlobalDetail.getAssetRepresentative())) {
cah292 marked this conversation as resolved.
Show resolved Hide resolved
offCampusAssetLocation.setAssetLocationInstitutionName(
assetGlobalDetail.getAssetRepresentative().getPrimaryDepartmentCode());
} else {
LOG.info("processAssetLocationInstitutionName, the asset representative is not set, unable to set asset location institution name");
}
}

}