...
The application programmer scratches his head, and looks to see how he can figure out who belongs to what organization. He looks to the Personnel OSID to answer this question and sees that Persons are related to Organizations via Appointments . The application programmer has an Agent, not a Person.
and Positions. Dismayed at the ever-growing number of service calls to perform this seemingly simple task, writes the following logic in the applicationbizarre complexity of the situation, shovels out the following code:
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); osid.personnel.OrganizationList orgs = record.getOrgsWhoCanPlaceHold(); // 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); } |