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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations