/* * (non-Javadoc) * @see org.jasig.schedassist.RelationshipDao#forOwner(org.jasig.schedassist.model.IScheduleOwner) */ @Override public List<Relationship> forOwner(final IScheduleOwner owner) { final String ownerIdentifier = getIdentifyingAttribute(owner.getCalendarAccount()); List<OwnerDefinedRelationship> relationships = this.simpleJdbcTemplate.query( "select * from owner_adhoc_authz where owner_username = ?", new OwnerDefinedRelationshipRowMapper(), ownerIdentifier); List<Relationship> results = new ArrayList<Relationship>(); for (OwnerDefinedRelationship stored : relationships) { ICalendarAccount calendarUser = calendarAccountDao.getCalendarAccount( identifyingAttributeName, stored.getVisitorUsername()); if (null == calendarUser) { LOG.info("calendarAccount not found for owner in " + stored); continue; } try { IScheduleVisitor visitor = visitorDao.toVisitor(calendarUser); Relationship relationship = new Relationship(); relationship.setOwner(owner); relationship.setVisitor(visitor); relationship.setDescription(stored.getRelationship()); results.add(relationship); } catch (NotAVisitorException e) { LOG.info("calendarAccount found but not a visitor " + stored); } } return results; }
/** * @param visitorUsername * @param ownerUsername * @param startDate * @param endDate * @return * @throws CalendarAccountNotFoundException * @throws NotAVisitorException * @throws SchedulingException */ public VEvent createAvailableAppointment( String visitorUsername, String ownerUsername, Date startDate, Date endDate) throws CalendarAccountNotFoundException, NotAVisitorException, SchedulingException { ICalendarAccount visitorUser = calendarAccountDao.getCalendarAccount(visitorUsername); ICalendarAccount ownerUser = calendarAccountDao.getCalendarAccount(ownerUsername); IScheduleVisitor visitor = visitorDao.toVisitor(visitorUser); IScheduleOwner owner = ownerDao.locateOwner(ownerUser); if (null == owner) { throw new SchedulingException("owner not registered with Available"); } AvailableBlock block = availableScheduleDao.retrieveTargetBlock(owner, startDate); if (null == block) { throw new SchedulingException("owner does not have availability at " + startDate); } VEvent result = this.schedulingAssistantService.scheduleAppointment( visitor, owner, block, "test appointment created by WiscCal administrator"); return result; }