Search in sources :

Example 1 with UserProcurementProfile

use of edu.cornell.kfs.sys.businessobject.UserProcurementProfile in project cu-kfs by CU-CommunityApps.

the class UserProcurementProfileRule method processCustomRouteDocumentBusinessRules.

@Override
protected boolean processCustomRouteDocumentBusinessRules(MaintenanceDocument document) {
    boolean valid = super.processCustomRouteDocumentBusinessRules(document);
    UserProcurementProfile userProcurementProfile = (UserProcurementProfile) document.getNewMaintainableObject().getBusinessObject();
    if (CollectionUtils.isNotEmpty(userProcurementProfile.getFavoriteAccounts())) {
        valid &= getUserProcurementProfileValidationService().validateAccounts(userProcurementProfile.getFavoriteAccounts());
    }
    if (StringUtils.equalsIgnoreCase(KRADConstants.MAINTENANCE_NEW_ACTION, document.getNewMaintainableObject().getMaintenanceAction()) || StringUtils.equalsIgnoreCase(KRADConstants.MAINTENANCE_COPY_ACTION, document.getNewMaintainableObject().getMaintenanceAction())) {
        valid &= !getUserProcurementProfileValidationService().validateUserProfileExist(((UserProcurementProfile) document.getNewMaintainableObject().getBusinessObject()).getPrincipalId());
    }
    if (valid && StringUtils.equalsIgnoreCase(KRADConstants.MAINTENANCE_COPY_ACTION, document.getNewMaintainableObject().getMaintenanceAction())) {
        resetAccountId((UserProcurementProfile) document.getNewMaintainableObject().getBusinessObject());
    }
    return valid;
}
Also used : UserProcurementProfile(edu.cornell.kfs.sys.businessobject.UserProcurementProfile)

Example 2 with UserProcurementProfile

use of edu.cornell.kfs.sys.businessobject.UserProcurementProfile in project cu-kfs by CU-CommunityApps.

the class UserProcurementProfileAuthorizer method getDocumentActions.

@Override
public Set<String> getDocumentActions(Document document, Person user, Set<String> documentActions) {
    Set<String> documentActions1 = super.getDocumentActions(document, user, documentActions);
    if (documentActions1.contains(KRADConstants.KUALI_ACTION_CAN_EDIT) && !documentActions1.contains(KRADConstants.KUALI_ACTION_CAN_SAVE)) {
        documentActions1.add(KRADConstants.KUALI_ACTION_CAN_SAVE);
    }
    if (documentActions1.contains(KRADConstants.KUALI_ACTION_CAN_BLANKET_APPROVE)) {
        documentActions1.remove(KRADConstants.KUALI_ACTION_CAN_BLANKET_APPROVE);
    }
    if (documentActions1.contains(KRADConstants.KUALI_ACTION_CAN_EDIT)) {
        MaintenanceDocumentBase maintDoc = (MaintenanceDocumentBase) document;
        if (StringUtils.equals(maintDoc.getNewMaintainableObject().getMaintenanceAction(), KRADConstants.MAINTENANCE_EDIT_ACTION) || StringUtils.equals(maintDoc.getNewMaintainableObject().getMaintenanceAction(), KRADConstants.MAINTENANCE_COPY_ACTION)) {
            boolean hasRole = SpringContext.getBean(UserProcurementProfileValidationService.class).canMaintainUserProcurementProfile();
            UserProcurementProfile userProfile = (UserProcurementProfile) maintDoc.getNewMaintainableObject().getBusinessObject();
            if (!hasRole && (!StringUtils.equals(userProfile.getPrincipalId(), GlobalVariables.getUserSession().getPrincipalId()) || StringUtils.equals(maintDoc.getNewMaintainableObject().getMaintenanceAction(), KRADConstants.MAINTENANCE_COPY_ACTION))) {
                throw new AuthorizationException(user.getName(), maintDoc.getNewMaintainableObject().getMaintenanceAction(), " UserProcurementProfile");
            }
        }
    }
    return documentActions1;
}
Also used : AuthorizationException(org.kuali.kfs.krad.exception.AuthorizationException) MaintenanceDocumentBase(org.kuali.kfs.kns.document.MaintenanceDocumentBase) UserProcurementProfile(edu.cornell.kfs.sys.businessobject.UserProcurementProfile) UserProcurementProfileValidationService(edu.cornell.kfs.sys.service.UserProcurementProfileValidationService)

Example 3 with UserProcurementProfile

use of edu.cornell.kfs.sys.businessobject.UserProcurementProfile in project cu-kfs by CU-CommunityApps.

the class UserProcurementProfileLookupableHelperServiceImpl method buildUserProfile.

private UserProcurementProfile buildUserProfile(UserProcurementProfile userProfile, FavoriteAccount account) {
    UserProcurementProfile profile = (UserProcurementProfile) ObjectUtils.deepCopy(userProfile);
    profile.setResultAccount(account);
    return profile;
}
Also used : UserProcurementProfile(edu.cornell.kfs.sys.businessobject.UserProcurementProfile)

Example 4 with UserProcurementProfile

use of edu.cornell.kfs.sys.businessobject.UserProcurementProfile in project cu-kfs by CU-CommunityApps.

the class UserProcurementProfileLookupableHelperServiceImpl method getSearchResultsNoAcctCriteria.

private List<PersistableBusinessObject> getSearchResultsNoAcctCriteria(List<PersistableBusinessObject> searchResults) {
    List<PersistableBusinessObject> returnResults = new ArrayList<PersistableBusinessObject>();
    for (PersistableBusinessObject pbo : searchResults) {
        UserProcurementProfile userProfile = (UserProcurementProfile) pbo;
        if (CollectionUtils.isEmpty(userProfile.getFavoriteAccounts())) {
            userProfile.setResultAccount(new FavoriteAccount());
            returnResults.add(userProfile);
        } else {
            for (FavoriteAccount account : userProfile.getFavoriteAccounts()) {
                returnResults.add(buildUserProfile(userProfile, account));
            }
        }
    }
    sortList(returnResults);
    return returnResults;
}
Also used : PersistableBusinessObject(org.kuali.kfs.krad.bo.PersistableBusinessObject) FavoriteAccount(edu.cornell.kfs.sys.businessobject.FavoriteAccount) ArrayList(java.util.ArrayList) UserProcurementProfile(edu.cornell.kfs.sys.businessobject.UserProcurementProfile)

Example 5 with UserProcurementProfile

use of edu.cornell.kfs.sys.businessobject.UserProcurementProfile in project cu-kfs by CU-CommunityApps.

the class FavoriteAccountValuesFinder method getUserFavoriteAccounts.

/*
     * get user favoriteacounts with primary account sorted first
     */
private List<FavoriteAccount> getUserFavoriteAccounts() {
    Map<String, Object> fieldValues = new HashMap<String, Object>();
    fieldValues.put("principalId", GlobalVariables.getUserSession().getPrincipalId());
    List<UserProcurementProfile> userProfiles = (List<UserProcurementProfile>) SpringContext.getBean(BusinessObjectService.class).findMatching(UserProcurementProfile.class, fieldValues);
    if (CollectionUtils.isNotEmpty(userProfiles)) {
        UserProcurementProfile userProfile = userProfiles.get(0);
        fieldValues = new HashMap<String, Object>();
        fieldValues.put("userProfileId", userProfile.getUserProfileId());
        // retrieve from db for sorting purpose.
        return (List<FavoriteAccount>) SpringContext.getBean(BusinessObjectService.class).findMatchingOrderBy(FavoriteAccount.class, fieldValues, "primaryInd", false);
    }
    return null;
}
Also used : FavoriteAccount(edu.cornell.kfs.sys.businessobject.FavoriteAccount) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) 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