...
Code Block |
---|
boolean checkPlaceHold(org.osid.id.Id issueId, org.osid.id.Id agentId) throws org.osid.NotFoundException, org.osid.OperationFailedException, org.osid.PermissionDeniedException { org.osid.resource.ResourceAgentSession resourceAgentSession = resourceMgr.getResourceAgentSession(); // I'll assume the resourceId is the same as the personId org.osid.id.Id resourceId = resourceAgentSession.getResourceIdByAgent(agentId); org.osid.hold.IssueLookupSession issueLookupSession = holdMgr.getIssueLookupSession(); org.osid.hold.Issue issue = issueLookupSession.getIssue(issueId); // our local org data OrganizationHoldRecord record = (OrganizationHoldRecord) issue.getIssueRecord(organizationHoldRecordType); // could they have made this any more difficult! org.osid.personnel.AppointmentLookupSession appointmentLookupSession = personnelMgr.getAppointmentLookupSession(); appointmentLookupSession.useEffectiveAppointmentView(); org.osid.personnel.PositionLookupSession positionLookupSession = personnelMgr.getPositionLookupSession(); positionLookupSession.useEffectivePositionView(); // get the positions of an org - blasted there's no way to get a list of people in an org! try (org.osid.id.IdList orgIds = record.getOrgIdsWhoCanPlaceHold()) { while (orgIds.hasNext()) { org.osid.id.Id orgId = orgIds.getNextId(); try (org.osid.personnel.PositionList positions = positionLookupSession.getPositionsForOrganization(orgId)) { while (positions.hasNext()) { org.osid.personnel.Position position = positions.getNextPosition(); try (org.osid.personnel.AppintmentList appointments = appointmentLookupSession.getAppointmentsForPersonAndPosition(resourceId, position.getNextId()) { if (appointments.hasNext()) { return (true); } } } } } } return (false); } |
It may come as a shock but the product owner complains that it takes too long to create a hold. The application programmer complains that these APIs were designed to their requirements. They figure that if they can have a simple method:
Code Block |
---|
boolean isAgentInAnyOfTheseOrgs(agentId, orgIds) |
then they can optimize for this case in a single call.