Search in sources :

Example 6 with UserProcurementProfile

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;
}
Also used : FavoriteAccount(edu.cornell.kfs.sys.businessobject.FavoriteAccount) HashMap(java.util.HashMap) List(java.util.List) UserProcurementProfile(edu.cornell.kfs.sys.businessobject.UserProcurementProfile)

Example 7 with UserProcurementProfile

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();
}
Also used : FavoriteAccount(edu.cornell.kfs.sys.businessobject.FavoriteAccount) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) UserProcurementProfile(edu.cornell.kfs.sys.businessobject.UserProcurementProfile)

Aggregations

UserProcurementProfile (edu.cornell.kfs.sys.businessobject.UserProcurementProfile)7 FavoriteAccount (edu.cornell.kfs.sys.businessobject.FavoriteAccount)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 List (java.util.List)2 UserProcurementProfileValidationService (edu.cornell.kfs.sys.service.UserProcurementProfileValidationService)1 MaintenanceDocumentBase (org.kuali.kfs.kns.document.MaintenanceDocumentBase)1 PersistableBusinessObject (org.kuali.kfs.krad.bo.PersistableBusinessObject)1 AuthorizationException (org.kuali.kfs.krad.exception.AuthorizationException)1