Skip to content

Commit

Permalink
KFSPTS-31812 fix asset global doc when asset representative is not se…
Browse files Browse the repository at this point in the history
…t or is non Cornell person (#1609)
  • Loading branch information
jhulslander committed May 24, 2024
1 parent a2adbeb commit 08333f0
Showing 1 changed file with 47 additions and 0 deletions.
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())) {
offCampusAssetLocation.setAssetLocationInstitutionName(
assetGlobalDetail.getAssetRepresentative().getPrimaryDepartmentCode());
} else {
LOG.info("processAssetLocationInstitutionName, the asset representative is not set, unable to set asset location institution name");
}
}

}

0 comments on commit 08333f0

Please sign in to comment.