Search in sources :

Example 6 with SequenceAccessorService

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;
}
Also used : SequenceAccessorService(org.kuali.kfs.krad.service.SequenceAccessorService)

Example 7 with 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);
        }
    }
}
Also used : SequenceAccessorService(org.kuali.kfs.krad.service.SequenceAccessorService) NoteExtendedAttribute(edu.cornell.kfs.sys.businessobject.NoteExtendedAttribute) Note(org.kuali.kfs.krad.bo.Note)

Example 8 with SequenceAccessorService

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);
        }
    }
}
Also used : KimDocumentRolePermission(org.kuali.kfs.kim.bo.ui.KimDocumentRolePermission) KimDocumentRoleMember(org.kuali.kfs.kim.bo.ui.KimDocumentRoleMember) RoleDocumentDelegation(org.kuali.kfs.kim.bo.ui.RoleDocumentDelegation) RoleDocumentDelegationMemberQualifier(org.kuali.kfs.kim.bo.ui.RoleDocumentDelegationMemberQualifier) KimDocumentRoleQualifier(org.kuali.kfs.kim.bo.ui.KimDocumentRoleQualifier) KimDocumentRoleResponsibilityAction(org.kuali.kfs.kim.bo.ui.KimDocumentRoleResponsibilityAction) SequenceAccessorService(org.kuali.kfs.krad.service.SequenceAccessorService) KimDocumentRoleResponsibility(org.kuali.kfs.kim.bo.ui.KimDocumentRoleResponsibility) RoleDocumentDelegationMember(org.kuali.kfs.kim.bo.ui.RoleDocumentDelegationMember) AutoPopulatingList(org.springframework.util.AutoPopulatingList)

Example 9 with SequenceAccessorService

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";
    }
}
Also used : SequenceAccessorService(org.kuali.kfs.krad.service.SequenceAccessorService)

Example 10 with SequenceAccessorService

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);
}
Also used : SequenceAccessorService(org.kuali.kfs.krad.service.SequenceAccessorService)

Aggregations

SequenceAccessorService (org.kuali.kfs.krad.service.SequenceAccessorService)11 ArrayList (java.util.ArrayList)3 List (java.util.List)3 PurchaseOrderItem (org.kuali.kfs.module.purap.businessobject.PurchaseOrderItem)2 SecurityGroup (edu.cornell.kfs.ksr.businessobject.SecurityGroup)1 SecurityGroupTab (edu.cornell.kfs.ksr.businessobject.SecurityGroupTab)1 NoteExtendedAttribute (edu.cornell.kfs.sys.businessobject.NoteExtendedAttribute)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 CapitalAssetSystem (org.kuali.kfs.integration.purap.CapitalAssetSystem)1 KimAttributeField (org.kuali.kfs.kim.api.type.KimAttributeField)1 GroupDocumentMember (org.kuali.kfs.kim.bo.ui.GroupDocumentMember)1 GroupDocumentQualifier (org.kuali.kfs.kim.bo.ui.GroupDocumentQualifier)1 KimDocumentRoleMember (org.kuali.kfs.kim.bo.ui.KimDocumentRoleMember)1 KimDocumentRolePermission (org.kuali.kfs.kim.bo.ui.KimDocumentRolePermission)1 KimDocumentRoleQualifier (org.kuali.kfs.kim.bo.ui.KimDocumentRoleQualifier)1 KimDocumentRoleResponsibility (org.kuali.kfs.kim.bo.ui.KimDocumentRoleResponsibility)1 KimDocumentRoleResponsibilityAction (org.kuali.kfs.kim.bo.ui.KimDocumentRoleResponsibilityAction)1 RoleDocumentDelegation (org.kuali.kfs.kim.bo.ui.RoleDocumentDelegation)1 RoleDocumentDelegationMember (org.kuali.kfs.kim.bo.ui.RoleDocumentDelegationMember)1