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