Search in sources :

Example 1 with PersonService

use of org.kuali.rice.kim.api.identity.PersonService in project cu-kfs by CU-CommunityApps.

the class EzraServiceImpl method createProjectDirectors.

private List<ProposalProjectDirector> createProjectDirectors(String projectId, EzraProject project) {
    List<ProposalProjectDirector> projDirs = new ArrayList<ProposalProjectDirector>();
    Investigator investigator = (Investigator) businessObjectService.findBySinglePrimaryKey(Investigator.class, project.getProjectDirectorId());
    if (investigator != null) {
        PersonService ps = SpringContext.getBean(PersonService.class);
        if (investigator.getNetId() != null) {
            Person director = ps.getPersonByPrincipalName(investigator.getNetId());
            if (director != null) {
                Map primaryKeys = new HashMap();
                primaryKeys.put("principalId", director.getPrincipalId());
                primaryKeys.put("proposalNumber", projectId);
                ProposalProjectDirector ppd = (ProposalProjectDirector) businessObjectService.findByPrimaryKey(ProposalProjectDirector.class, primaryKeys);
                if (ObjectUtils.isNull(ppd)) {
                    ppd = new ProposalProjectDirector();
                }
                // else {
                // ppd.setVersionNumber(ppd.getVersionNumber());
                // }
                ppd.setPrincipalId(director.getPrincipalId());
                ppd.setProposalNumber(project.getProjectId());
                ppd.setProposalPrimaryProjectDirectorIndicator(true);
                ppd.setActive(true);
                KimApiServiceLocator.getRoleService().assignPrincipalToRole(director.getPrincipalId(), "KFS-SYS", "Contracts & Grants Project Director", new HashMap<String, String>());
                projDirs.add(ppd);
            } else {
                LOG.error("PI: " + investigator.getNetId() + " for award :" + projectId + " is not in kfs");
            }
        } else {
            LOG.error("PI netId for award :" + projectId + " is null");
        }
    } else {
        LOG.error("Null PI: " + project.getProjectDirectorId());
    }
    Map fieldValues = new HashMap();
    fieldValues.put("projectId", projectId.toString());
    fieldValues.put("investigatorRole", "CO");
    List<ProjectInvestigator> pis = (List<ProjectInvestigator>) businessObjectService.findMatching(ProjectInvestigator.class, fieldValues);
    for (ProjectInvestigator pi : pis) {
        if (pi.getInvestigatorId() != null) {
            Investigator inv = (Investigator) businessObjectService.findBySinglePrimaryKey(Investigator.class, pi.getInvestigatorId());
            if (inv != null) {
                PersonService ps = SpringContext.getBean(PersonService.class);
                if (inv.getNetId() != null) {
                    Person director = ps.getPersonByPrincipalName(inv.getNetId());
                    if (director != null) {
                        Map primaryKeys = new HashMap();
                        primaryKeys.put("principalId", director.getPrincipalId());
                        primaryKeys.put("proposalNumber", projectId);
                        ProposalProjectDirector ppd = (ProposalProjectDirector) businessObjectService.findByPrimaryKey(ProposalProjectDirector.class, primaryKeys);
                        if (ObjectUtils.isNull(ppd)) {
                            ppd = new ProposalProjectDirector();
                        }
                        ppd.setPrincipalId(director.getPrincipalId());
                        ppd.setProposalNumber(project.getProjectId());
                        ppd.setProposalPrimaryProjectDirectorIndicator(false);
                        ppd.setActive(true);
                        KimApiServiceLocator.getRoleService().assignPrincipalToRole(director.getPrincipalId(), "KFS-SYS", "Contracts & Grants Project Director", new HashMap<String, String>());
                        // check to make sure that this project director is not already in the list.
                        for (ProposalProjectDirector projDir : projDirs) {
                            if (projDir.getPrincipalId().equals(ppd.getPrincipalId()))
                                continue;
                        }
                        projDirs.add(ppd);
                    } else {
                        LOG.error("Investigator: " + investigator.getNetId() + " is for award :" + projectId + " is not in kfs");
                    }
                } else {
                    LOG.error("Invesigator netId for award :" + projectId + " is null");
                }
            } else {
                LOG.error("Null investigator: " + pi.getInvestigatorId());
            }
        } else {
            LOG.error("Null investigator id: ");
        }
    }
    return projDirs;
}
Also used : HashMap(java.util.HashMap) PersonService(org.kuali.rice.kim.api.identity.PersonService) ArrayList(java.util.ArrayList) ProposalProjectDirector(org.kuali.kfs.module.cg.businessobject.ProposalProjectDirector) Investigator(edu.cornell.kfs.module.ezra.businessobject.Investigator) ProjectInvestigator(edu.cornell.kfs.module.ezra.businessobject.ProjectInvestigator) ArrayList(java.util.ArrayList) List(java.util.List) ProjectInvestigator(edu.cornell.kfs.module.ezra.businessobject.ProjectInvestigator) Person(org.kuali.rice.kim.api.identity.Person) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with PersonService

use of org.kuali.rice.kim.api.identity.PersonService in project cu-kfs by CU-CommunityApps.

the class PayeeACHAccountExtractServiceImplTest method createMockPersonService.

private PersonService createMockPersonService() throws Exception {
    PersonService personService = EasyMock.createMock(PersonServiceImpl.class);
    EasyMock.expect(personService.getPersonByPrincipalName(TEST_PRINCIPALNAME)).andStubReturn(createTestUser());
    EasyMock.expect(personService.getPersonByPrincipalName(TEST_ALT_PRINCIPALNAME)).andStubReturn(createAlternateTestUser());
    EasyMock.expect(personService.getPersonByPrincipalName(KFSConstants.SYSTEM_USER)).andStubReturn(createSystemUser());
    EasyMock.expect(personService.getPersonByPrincipalName(EasyMock.and(EasyMock.not(EasyMock.eq(TEST_PRINCIPALNAME)), EasyMock.and(EasyMock.not(EasyMock.eq(TEST_ALT_PRINCIPALNAME)), EasyMock.not(EasyMock.eq(KFSConstants.SYSTEM_USER)))))).andStubReturn(null);
    EasyMock.replay(personService);
    return personService;
}
Also used : PersonService(org.kuali.rice.kim.api.identity.PersonService)

Example 3 with PersonService

use of org.kuali.rice.kim.api.identity.PersonService in project cu-kfs by CU-CommunityApps.

the class CreateAccountingDocumentServiceImplTest method buildMockPersonService.

private PersonService buildMockPersonService() throws Exception {
    PersonService personService = EasyMock.createMock(PersonService.class);
    Person systemUser = MockPersonUtil.createMockPerson(UserNameFixture.kfs);
    EasyMock.expect(personService.getPersonByPrincipalName(KFSConstants.SYSTEM_USER)).andStubReturn(systemUser);
    EasyMock.replay(personService);
    return personService;
}
Also used : PersonService(org.kuali.rice.kim.api.identity.PersonService) AdHocRoutePerson(org.kuali.kfs.krad.bo.AdHocRoutePerson) Person(org.kuali.rice.kim.api.identity.Person)

Example 4 with PersonService

use of org.kuali.rice.kim.api.identity.PersonService in project cu-kfs by CU-CommunityApps.

the class CuPurchaseOrderAmendmentDocument method getAllPriorApprovers.

public Set<Person> getAllPriorApprovers() throws WorkflowException {
    PersonService personService = KimApiServiceLocator.getPersonService();
    List<ActionTaken> actionsTaken = this.getFinancialSystemDocumentHeader().getWorkflowDocument().getActionsTaken();
    Set<String> principalIds = new HashSet<String>();
    Set<Person> persons = new HashSet<Person>();
    for (ActionTaken actionTaken : actionsTaken) {
        if (KewApiConstants.ACTION_TAKEN_APPROVED_CD.equals(actionTaken.getActionTaken().getCode())) {
            String principalId = actionTaken.getPrincipalId();
            if (!principalIds.contains(principalId)) {
                principalIds.add(principalId);
                persons.add(personService.getPerson(principalId));
            }
        }
    }
    return persons;
}
Also used : PersonService(org.kuali.rice.kim.api.identity.PersonService) ActionTaken(org.kuali.rice.kew.api.action.ActionTaken) Person(org.kuali.rice.kim.api.identity.Person) HashSet(java.util.HashSet)

Aggregations

PersonService (org.kuali.rice.kim.api.identity.PersonService)4 Person (org.kuali.rice.kim.api.identity.Person)3 Investigator (edu.cornell.kfs.module.ezra.businessobject.Investigator)1 ProjectInvestigator (edu.cornell.kfs.module.ezra.businessobject.ProjectInvestigator)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 AdHocRoutePerson (org.kuali.kfs.krad.bo.AdHocRoutePerson)1 ProposalProjectDirector (org.kuali.kfs.module.cg.businessobject.ProposalProjectDirector)1 ActionTaken (org.kuali.rice.kew.api.action.ActionTaken)1