use of edu.cornell.kfs.sys.businessobject.UserProcurementProfile in project cu-kfs by CU-CommunityApps.
the class UserFavoriteAccountServiceImpl method getFavoriteAccount.
/**
* get user's primary favorite account
*/
public FavoriteAccount getFavoriteAccount(String principalId) {
Map<String, String> fieldValues = new HashMap<String, String>();
fieldValues.put("principalId", principalId);
List<UserProcurementProfile> userProfiles = (List<UserProcurementProfile>) businessObjectService.findMatching(UserProcurementProfile.class, fieldValues);
if (CollectionUtils.isNotEmpty(userProfiles) && CollectionUtils.isNotEmpty(userProfiles.get(0).getFavoriteAccounts())) {
for (FavoriteAccount account : userProfiles.get(0).getFavoriteAccounts()) {
if (account.getPrimaryInd()) {
return account;
}
}
}
return null;
}
use of edu.cornell.kfs.sys.businessobject.UserProcurementProfile in project cu-kfs by CU-CommunityApps.
the class UserProcurementProfileMaintainableImpl method saveBusinessObject.
@Override
public void saveBusinessObject() {
// TODO Auto-generated method stub
if (StringUtils.equals(getMaintenanceAction(), KRADConstants.MAINTENANCE_EDIT_ACTION)) {
Map<String, Object> pkMap = new HashMap<String, Object>();
pkMap.put("userProfileId", ((UserProcurementProfile) getBusinessObject()).getUserProfileId());
UserProcurementProfile userProfile = (UserProcurementProfile) getBusinessObjectService().findByPrimaryKey(UserProcurementProfile.class, pkMap);
List<FavoriteAccount> deletedAccounts = new ArrayList<FavoriteAccount>();
if (ObjectUtils.isNotNull(userProfile) && CollectionUtils.isNotEmpty(userProfile.getFavoriteAccounts())) {
for (FavoriteAccount account : userProfile.getFavoriteAccounts()) {
boolean accountFound = false;
if (CollectionUtils.isNotEmpty(((UserProcurementProfile) getBusinessObject()).getFavoriteAccounts())) {
for (FavoriteAccount account1 : ((UserProcurementProfile) getBusinessObject()).getFavoriteAccounts()) {
if (account1.getAccountLineIdentifier() != null && account.getAccountLineIdentifier().equals(account1.getAccountLineIdentifier())) {
accountFound = true;
break;
}
}
}
if (!accountFound) {
deletedAccounts.add(account);
}
}
if (CollectionUtils.isNotEmpty(deletedAccounts)) {
getBusinessObjectService().delete(deletedAccounts);
}
}
}
super.saveBusinessObject();
}
Aggregations