use of org.kuali.kfs.krad.service.SequenceAccessorService in project cu-kfs by CU-CommunityApps.
the class PayeeACHAccountExtractServiceImplTest method createMockSequenceAccessorService.
private SequenceAccessorService createMockSequenceAccessorService() throws Exception {
SequenceAccessorService sequenceAccessorService = mock(SequenceAccessorService.class);
when(sequenceAccessorService.getNextAvailableSequenceNumber(PdpConstants.ACH_ACCOUNT_IDENTIFIER_SEQUENCE_NAME)).then((invocation) -> Long.valueOf(achAccountIdCounter.incrementAndGet()));
return sequenceAccessorService;
}
use of org.kuali.kfs.krad.service.SequenceAccessorService in project cu-kfs by CU-CommunityApps.
the class CuRequisitionDocument method prepareForSave.
/**
* Overridden to also pre-populate note IDs on unsaved notes lacking attachments,
* to avoid persistence problems with note extended attributes. This is necessary
* because of the OJB behavior of trying to persist the 1-1 reference object
* prior to the parent object, which can interfere with saving auto-generated
* notes (like "copied from document" notes).
*
* @see org.kuali.kfs.module.purap.document.PurchasingDocumentBase#prepareForSave(org.kuali.kfs.krad.rules.rule.event.KualiDocumentEvent)
*/
@Override
public void prepareForSave(KualiDocumentEvent event) {
super.prepareForSave(event);
SequenceAccessorService sequenceAccessorService = SpringContext.getBean(SequenceAccessorService.class);
for (Note note : getNotes()) {
if (note.getNoteIdentifier() == null && ObjectUtils.isNull(note.getAttachment())) {
// Pre-populate IDs on unsaved notes without attachments, as well as their extended attributes.
Long newNoteId = sequenceAccessorService.getNextAvailableSequenceNumber(CUKFSConstants.NOTE_SEQUENCE_NAME);
note.setNoteIdentifier(newNoteId);
((NoteExtendedAttribute) note.getExtension()).setNoteIdentifier(newNoteId);
}
}
}
use of org.kuali.kfs.krad.service.SequenceAccessorService in project cu-kfs by CU-CommunityApps.
the class IdentityManagementRoleDocument method prepareForSave.
@Override
public void prepareForSave() {
SequenceAccessorService sas = getSequenceAccessorService();
String roleId;
if (StringUtils.isBlank(getRoleId())) {
Long nextSeq = sas.getNextAvailableSequenceNumber(KimConstants.SequenceNames.KRIM_ROLE_ID_S, this.getClass());
roleId = nextSeq.toString();
setRoleId(roleId);
} else {
roleId = getRoleId();
}
if (getPermissions() != null) {
String rolePermissionId;
for (KimDocumentRolePermission permission : getPermissions()) {
permission.setRoleId(roleId);
permission.setDocumentNumber(getDocumentNumber());
if (StringUtils.isBlank(permission.getRolePermissionId())) {
Long nextSeq = sas.getNextAvailableSequenceNumber(KimConstants.SequenceNames.KRIM_ROLE_PERM_ID_S, KimDocumentRolePermission.class);
rolePermissionId = nextSeq.toString();
permission.setRolePermissionId(rolePermissionId);
}
}
}
if (getResponsibilities() != null) {
String roleResponsibilityId;
for (KimDocumentRoleResponsibility responsibility : getResponsibilities()) {
if (StringUtils.isBlank(responsibility.getRoleResponsibilityId())) {
Long nextSeq = sas.getNextAvailableSequenceNumber(KimConstants.SequenceNames.KRIM_ROLE_RSP_ID_S, KimDocumentRoleResponsibility.class);
roleResponsibilityId = nextSeq.toString();
responsibility.setRoleResponsibilityId(roleResponsibilityId);
}
responsibility.setRoleId(roleId);
if (!getResponsibilityInternalService().areActionsAtAssignmentLevelById(responsibility.getResponsibilityId())) {
if (StringUtils.isBlank(responsibility.getRoleRspActions().get(0).getRoleResponsibilityActionId())) {
Long nextSeq = sas.getNextAvailableSequenceNumber(KimConstants.SequenceNames.KRIM_ROLE_RSP_ACTN_ID_S, KimDocumentRoleResponsibilityAction.class);
String roleResponsibilityActionId = nextSeq.toString();
responsibility.getRoleRspActions().get(0).setRoleResponsibilityActionId(roleResponsibilityActionId);
}
responsibility.getRoleRspActions().get(0).setRoleMemberId("*");
responsibility.getRoleRspActions().get(0).setDocumentNumber(getDocumentNumber());
}
}
}
if (getModifiedMembers() != null) {
String roleMemberId;
String roleResponsibilityActionId;
for (KimDocumentRoleMember member : getModifiedMembers()) {
member.setDocumentNumber(getDocumentNumber());
member.setRoleId(roleId);
if (StringUtils.isBlank(member.getRoleMemberId())) {
Long nextSeq = sas.getNextAvailableSequenceNumber(KimConstants.SequenceNames.KRIM_ROLE_MBR_ID_S, KimDocumentRoleMember.class);
roleMemberId = nextSeq.toString();
member.setRoleMemberId(roleMemberId);
}
for (KimDocumentRoleQualifier qualifier : member.getQualifiers()) {
qualifier.setDocumentNumber(getDocumentNumber());
qualifier.setRoleMemberId(member.getRoleMemberId());
qualifier.setKimTypId(getKimType().getId());
}
for (KimDocumentRoleResponsibilityAction roleRespAction : member.getRoleRspActions()) {
if (StringUtils.isBlank(roleRespAction.getRoleResponsibilityActionId())) {
Long nextSeq = sas.getNextAvailableSequenceNumber(KimConstants.SequenceNames.KRIM_ROLE_RSP_ACTN_ID_S, KimDocumentRoleResponsibilityAction.class);
roleResponsibilityActionId = nextSeq.toString();
roleRespAction.setRoleResponsibilityActionId(roleResponsibilityActionId);
}
roleRespAction.setRoleMemberId(member.getRoleMemberId());
roleRespAction.setDocumentNumber(getDocumentNumber());
if (!StringUtils.equals(roleRespAction.getRoleResponsibilityId(), "*")) {
for (KimDocumentRoleResponsibility responsibility : getResponsibilities()) {
if (StringUtils.equals(roleRespAction.getKimResponsibility().getId(), responsibility.getResponsibilityId())) {
roleRespAction.setRoleResponsibilityId(responsibility.getRoleResponsibilityId());
}
}
}
}
}
}
if (getDelegationMembers() != null) {
for (RoleDocumentDelegationMember delegationMember : getDelegationMembers()) {
delegationMember.setDocumentNumber(getDocumentNumber());
addDelegationMemberToDelegation(delegationMember);
}
for (RoleDocumentDelegation delegation : getDelegations()) {
delegation.setDocumentNumber(getDocumentNumber());
delegation.setKimTypeId(getKimType().getId());
List<RoleDocumentDelegationMember> membersToRemove = new AutoPopulatingList<>(RoleDocumentDelegationMember.class);
for (RoleDocumentDelegationMember member : delegation.getMembers()) {
if (delegation.getDelegationId().equals(member.getDelegationId()) && delegation.getDelegationTypeCode().equals(member.getDelegationTypeCode())) {
for (RoleDocumentDelegationMemberQualifier qualifier : member.getQualifiers()) {
qualifier.setKimTypId(getKimType().getId());
qualifier.setDocumentNumber(getDocumentNumber());
}
} else {
membersToRemove.add(member);
}
}
if (!membersToRemove.isEmpty()) {
for (RoleDocumentDelegationMember member : membersToRemove) {
delegation.getMembers().remove(member);
}
}
delegation.setRoleId(roleId);
}
}
}
use of org.kuali.kfs.krad.service.SequenceAccessorService in project cu-kfs by CU-CommunityApps.
the class IdentityManagementRoleDocument method initializeDocumentForNewRole.
public void initializeDocumentForNewRole() {
if (StringUtils.isBlank(this.roleId)) {
SequenceAccessorService sas = getSequenceAccessorService();
Long nextSeq = sas.getNextAvailableSequenceNumber(KimConstants.SequenceNames.KRIM_ROLE_ID_S, this.getClass());
this.roleId = nextSeq.toString();
}
if (StringUtils.isBlank(this.roleTypeId)) {
this.roleTypeId = "1";
}
}
use of org.kuali.kfs.krad.service.SequenceAccessorService in project cu-kfs by CU-CommunityApps.
the class IdentityManagementRoleDocument method addMember.
public void addMember(KimDocumentRoleMember member) {
SequenceAccessorService sas = getSequenceAccessorService();
Long nextSeq = sas.getNextAvailableSequenceNumber(KimConstants.SequenceNames.KRIM_ROLE_MBR_ID_S, KimDocumentRoleMember.class);
String roleMemberId = nextSeq.toString();
member.setRoleMemberId(roleMemberId);
setupMemberRspActions(member);
getModifiedMembers().add(member);
}
Aggregations