use of org.kuali.kfs.kim.impl.identity.principal.Principal in project cu-kfs by CU-CommunityApps.
the class PrincipalNameHandlingLookupableHelperService method buildCriteriaWithMatchableConvertedPrincipalValues.
default Optional<Map<String, String>> buildCriteriaWithMatchableConvertedPrincipalValues(Map<String, String> fieldValues) {
Map<String, String> newFieldValues = new HashMap<>(fieldValues);
Map<String, String> fieldMappings = getMappingsFromPrincipalNameFieldsToPrincipalIdFields();
IdentityService identityService = getIdentityService();
boolean allPrincipalNamesHaveMatches = true;
for (Map.Entry<String, String> fieldMapping : fieldMappings.entrySet()) {
String principalNameField = fieldMapping.getKey();
String principalIdField = fieldMapping.getValue();
if (fieldValues.containsKey(principalNameField)) {
String principalName = newFieldValues.remove(principalNameField);
if (StringUtils.isNotBlank(principalName)) {
Principal principal = identityService.getPrincipalByPrincipalName(principalName);
if (ObjectUtils.isNotNull(principal)) {
newFieldValues.put(principalIdField, principal.getPrincipalId());
} else {
allPrincipalNamesHaveMatches = false;
}
}
}
}
return allPrincipalNamesHaveMatches ? Optional.of(newFieldValues) : Optional.empty();
}
use of org.kuali.kfs.kim.impl.identity.principal.Principal in project cu-kfs by CU-CommunityApps.
the class CuAssetLookupableHelperServiceImpl method getSearchResultsHelper.
@Override
protected List<? extends BusinessObject> getSearchResultsHelper(Map<String, String> fieldValues, boolean unbounded) {
// perform the lookup on the asset representative first
String principalName = fieldValues.get(CamsPropertyConstants.Asset.REP_USER_AUTH_ID);
if (StringUtils.isNotBlank(principalName)) {
Principal principal = KimApiServiceLocator.getIdentityService().getPrincipalByPrincipalName(principalName);
if (principal == null) {
return Collections.EMPTY_LIST;
}
// place the universal ID into the fieldValues map and remove the dummy attribute
fieldValues.put(CamsPropertyConstants.Asset.REPRESENTATIVE_UNIVERSAL_IDENTIFIER, principal.getPrincipalId());
fieldValues.remove(CamsPropertyConstants.Asset.REP_USER_AUTH_ID);
}
List<? extends BusinessObject> results;
if (StringUtils.isNotBlank(fieldValues.get(CuCamsPropertyConstants.Asset.ASSET_LOCATION_TYPE_CODE))) {
unbounded = true;
results = excludeBlankOffCampusLocations(super.getSearchResultsHelper(fieldValues, unbounded));
} else {
results = super.getSearchResultsHelper(fieldValues, unbounded);
}
return results;
}
use of org.kuali.kfs.kim.impl.identity.principal.Principal in project cu-kfs by CU-CommunityApps.
the class TransactionRowBuilder method checkForEntityAndAccountAndOrgExistence.
/**
* Helper method for checking if entity, account, and org objects exist
* for the current tax source row. Certain statistics will be updated
* accordingly if one or more of these objects cannot not be found.
* The initiator's principal name will also be returned, if found.
*
* @param initiatorPrincipalId The document initiator's principal ID; may be blank.
* @param chartCode The chart code; may be blank.
* @param accountNumber The account number; may be blank.
* @param summary The object encapsulating the tax-type-specific summary info.
* @return The initiator's principal name, or null if a principal name could not be found.
*/
String checkForEntityAndAccountAndOrgExistence(String initiatorPrincipalId, String chartCode, String accountNumber, T summary) {
Account account;
EntityName entityName;
Principal principal;
// Check for null entity name info.
entityName = (StringUtils.isNotBlank(initiatorPrincipalId)) ? identityService.getDefaultNamesForPrincipalId(initiatorPrincipalId) : null;
if (entityName == null) {
numNoEntityName++;
}
// Check for null account or null org.
account = (StringUtils.isNotBlank(chartCode) && StringUtils.isNotBlank(accountNumber)) ? accountService.getByPrimaryIdWithCaching(chartCode, accountNumber) : null;
if (account != null) {
if (organizationService.getByPrimaryIdWithCaching(chartCode, account.getOrganizationCode()) == null) {
numNoOrg++;
}
} else {
numNoAccount++;
}
// Return the initiator's principal name, if found.
principal = (StringUtils.isNotBlank(initiatorPrincipalId)) ? identityService.getPrincipal(initiatorPrincipalId) : null;
return (principal != null && entityName != null) ? principal.getPrincipalName() : null;
}
use of org.kuali.kfs.kim.impl.identity.principal.Principal in project cu-kfs by CU-CommunityApps.
the class KualiAccountLookupableHelperServiceImpl method getSearchResults.
/**
* Overridden to changed the "closed" parameter to an "active" parameter.
*/
@Override
public List<? extends BusinessObject> getSearchResults(Map<String, String> parameters) {
if (parameters.containsKey(KFSPropertyConstants.CLOSED)) {
final String closedValue = parameters.get(KFSPropertyConstants.CLOSED);
if (closedValue != null && closedValue.length() != 0) {
if ("Y1T".contains(closedValue)) {
parameters.put(KFSPropertyConstants.ACTIVE, "N");
} else if ("N0F".contains(closedValue)) {
parameters.put(KFSPropertyConstants.ACTIVE, "Y");
}
}
parameters.remove(KFSPropertyConstants.CLOSED);
}
if (parameters.containsKey(KFSPropertyConstants.ACCOUNT_FISCAL_OFFICER_USER + ".principalName")) {
String foPrincipalName = parameters.get(KFSPropertyConstants.ACCOUNT_FISCAL_OFFICER_USER + ".principalName");
if (StringUtils.isNotBlank(foPrincipalName)) {
String foPrincipalId = KimApiServiceLocator.getIdentityService().getPrincipalByPrincipalName(foPrincipalName).getPrincipalId();
parameters.put(KFSPropertyConstants.ACCOUNT_FISCAL_OFFICER_SYSTEM_IDENTIFIER, foPrincipalId);
parameters.remove(KFSPropertyConstants.ACCOUNT_FISCAL_OFFICER_USER + ".principalName");
}
}
if (parameters.containsKey(KFSPropertyConstants.ACCOUNT_SUPERVISORY_USER + ".principalName")) {
String superPrincipalName = parameters.get(KFSPropertyConstants.ACCOUNT_SUPERVISORY_USER + ".principalName");
if (StringUtils.isNotBlank(superPrincipalName)) {
/*
* CU Customization KFSPTS-23120 investigate NPE
* Moved the principalByPrincipalName to a variable to more clearly see what aspect is causing the NPE
*/
try {
Principal principalByPrincipalName = KimApiServiceLocator.getIdentityService().getPrincipalByPrincipalName(superPrincipalName);
String superPrincipalId = principalByPrincipalName.getPrincipalId();
parameters.put(KFSPropertyConstants.ACCOUNTS_SUPERVISORY_SYSTEMS_IDENTIFIER, superPrincipalId);
} catch (NullPointerException npe) {
LOG.error("getSearchResults, got an NPE trying to get the super principle ID for superPrincipalName: " + superPrincipalName, npe);
throw npe;
}
parameters.remove(KFSPropertyConstants.ACCOUNT_SUPERVISORY_USER + ".principalName");
}
}
if (parameters.containsKey(KFSPropertyConstants.ACCOUNT_MANAGER_USER + ".principalName")) {
String mgrPrincipalName = parameters.get(KFSPropertyConstants.ACCOUNT_MANAGER_USER + ".principalName");
if (StringUtils.isNotBlank(mgrPrincipalName)) {
String foPrincipalId = KimApiServiceLocator.getIdentityService().getPrincipalByPrincipalName(mgrPrincipalName).getPrincipalId();
parameters.put(KFSPropertyConstants.ACCOUNT_MANAGER_SYSTEM_IDENTIFIER, foPrincipalId);
parameters.remove(KFSPropertyConstants.ACCOUNT_MANAGER_USER + ".principalName");
}
}
return super.getSearchResults(parameters);
}
use of org.kuali.kfs.kim.impl.identity.principal.Principal in project cu-kfs by CU-CommunityApps.
the class OrgReviewRoleServiceImpl method getDelegationMembersToSave.
protected List<KfsKimDocDelegateMember> getDelegationMembersToSave(OrgReviewRole orr) {
KfsKimDocDelegateMember delegationMember = null;
if (orr.isEdit() && StringUtils.isNotBlank(orr.getDelegationMemberId())) {
delegationMember = new KfsKimDocDelegateMember(KimApiServiceLocator.getRoleService().getDelegationMemberById(orr.getDelegationMemberId()));
}
if (delegationMember == null) {
delegationMember = new KfsKimDocDelegateMember();
if (StringUtils.isNotEmpty(orr.getRoleMemberRoleNamespaceCode()) && StringUtils.isNotEmpty(orr.getRoleMemberRoleName())) {
String roleId = KimApiServiceLocator.getRoleService().getRoleIdByNamespaceCodeAndName(orr.getRoleMemberRoleNamespaceCode(), orr.getRoleMemberRoleName());
delegationMember.setMemberId(roleId);
delegationMember.setType(MemberType.ROLE);
} else if (StringUtils.isNotEmpty(orr.getGroupMemberGroupNamespaceCode()) && StringUtils.isNotEmpty(orr.getGroupMemberGroupName())) {
Group groupInfo = KimApiServiceLocator.getGroupService().getGroupByNamespaceCodeAndName(orr.getGroupMemberGroupNamespaceCode(), orr.getGroupMemberGroupName());
delegationMember.setMemberId(groupInfo.getId());
delegationMember.setType(MemberType.GROUP);
} else if (StringUtils.isNotEmpty(orr.getPrincipalMemberPrincipalName())) {
Principal principal = KimApiServiceLocator.getIdentityService().getPrincipalByPrincipalName(orr.getPrincipalMemberPrincipalName());
delegationMember.setMemberId(principal.getPrincipalId());
delegationMember.setType(MemberType.PRINCIPAL);
}
}
delegationMember.setDelegationType(DelegationType.fromCode(orr.getDelegationTypeCode()));
delegationMember.setAttributes(getAttributes(orr, orr.getKimTypeId()));
if (orr.getActiveFromDate() != null) {
delegationMember.setActiveFromDate(new DateTime(orr.getActiveFromDate()));
}
if (orr.getActiveToDate() != null) {
delegationMember.setActiveToDate(new DateTime(orr.getActiveToDate()));
}
delegationMember.setRoleMemberId(orr.getRoleMemberId());
return Collections.singletonList(delegationMember);
}
Aggregations