Appointments
Creating appointments
The following sample creates an appointment record.
Code Snippet
protected AppointmentRepository appointmentRepository; private String createAppointment() throws Exception { Date date = new Date(); AppointmentCreate appointment = new AppointmentCreate(); appointment.setSubject("Quarterly Meeting - Q2 2009"); appointment.setLocation("Build A-5"); appointment.setAssignedOn(date); appointment.setStartOn(date); appointment.setEndOn(date); appointment.setAllDay(true); appointment.setProjectUniqueKey("DISP_0003"); appointment.getAttendeeCreates().add(attendees); appointment.getResourceCreates().add(resources); appointment.getCategories().add(categories); return appointmentRepository.insertAppointment(appointment); } private List<AttendeeCreate> attendeeCreate() { List<AttendeeCreate> attendees = new List<AttendeeCreate>(); AttendeeCreate attendee1 = new AttendeeCreate(); attendee1.setUserUniqueKey("USER_1005"); attendee1.setAttendanceType(AttendanceType.WILL_ATTEND); AttendeeCreate attendee2 = new AttendeeCreate(); attendee2.setUserUniqueKey("USER_1013"); attendee2.setAttendanceType(AttendanceType.TENTATIVE); attendees.add(attendee1); attendees.add(attendee2); return attendees; } private List<AppointmentResourceCreate> appointmentResourceCreate() { List<AppointmentResourceCreate> appointmentResources = new List<AppointmentResourceCreate>(); AppointmentResourceCreate apptResource = new AppointmentResourceCreate(); //for this sample, it is assumed that for the Resource Type system lookup table, there is a table item with the unique key (or Tree position), "CRMA" (for Conference Room A) apptResource.setTypeUniqueKey("CRMA"); appointmentResources.add(apptResource); return appointmentResources; } private List<Category> categoryAdd() { List<Category> categories = new ListArray<Category>(); Category cat = new Category(); //the next two lines identify a category and then add the category to the appointment record cat.setUniqueKey("APPT_TRIA"); categories.add(cat); return categories; }
Updating appointments
The following sample updates an appointment record with given unique key.
Code Snippet
//for this sample, it is assumed that an appointment record already exists with a unique key String equal to uniqueKey protected AppointmentRepository appointmentRepository; public void test_updateAppointment() throws Exception { Date date = new Date(); AppointmentUpdate appointment = new AppointmentUpdate(); //use the setUniqueKey method to identify the target task record to update by its unique key appointment.setUserUniqueKey("user_1003"); appointment.setAssignedOn(date); appointment.setStartOn(date); appointment.setEndOn(date); appointment.setAllDay(true); appointment.setProjectUniqueKey("DISP_0003"); appointment.getAttendeeUpdates().add(attendees); appointmentRepository.updateAppointment(appointment); } private List<AttendeeUpdate> attendeeUpdate() { List<AttendeeUpdate> attendees = new List<AttendeeUpdate>(); AttendeeUpdate attendee1 = new AttendeeUpdate(); //identify which attendee to update by the record's unique key attendee1.setUniqueKey("ATTN_1001"); attendee1.setUserUniqueKey("USER_1005"); attendee1.setAttendanceType(AttendanceType.WILL_NOT_ATTEND); attendees.add(attendee1); return attendees; }
Reading appointments
The following sample reads an appointment record and returns the specified property values.
Code Snippet
protected AppointmentRepository appointmentRepository; private List<String> getPropertiesToRead() { List<String> props = new List<String>(); //the list of all available properties displays below but to increase efficiency in your searches, you can omit unnecessary properties from your application and those values will not be returned props.add("uniqueKey"); props.add("version"); props.add("subject"); props.add("categories"); props.add("createdOn"); props.add("createdBy"); props.add("modifiedBy"); props.add("modifiedOn"); props.add("location"); props.add("startOn"); props.add("endOn"); props.add("allDay"); props.add("project"); props.add("attendees"); props.add("resources"); props.add("categories"); return props; } private Appointment readAppointment() throws Exception { Appointment readAppointment = appointmentRepository.readAppointment(uniqueKey, getPropertiesToRead()); return readAppointment; }
Searching appointments
The following sample searches for one or more appointment records and returns the specified property values. For this sample, it is assumed there is one or more appointments already existing with a subject String field value equal to subject.
Code Snippet
protected AppointmentRepository appointmentRepository; private List<Appointment> test_readAppointmentsByCriteria() throws Exception { // Criterion for appointment searching StringFieldCriterion fieldCriterion = new StringFieldCriterion(); fieldCriterion.setComparator(StringComparator.EQUALS_ENFORCE_CASE); LegacySearchFieldPathExpression fieldPathExpression = new LegacySearchFieldPathExpression(); fieldPathExpression.setSearchKeyPath("subject"); fieldCriterion.setFieldPath(fieldPathExpression); fieldCriterion.getValue().add("Client meeting"); FieldSearchClause searchCriteria = new FieldSearchClause(); searchCriteria.setOperator(LogicOperator.AND); searchCriteria.getCriteria().add(fieldCriterion); appointments = appointmentRepository.readAappointmentsByCriteria(searchCriteria, 100, getPropertiesToRead()); } private List<String> getPropertiesToRead() { List<String> props = new List<String>(); //the list of all available properties displays below but to increase efficiency in your searches, you can omit unnecessary properties from your application and those values will not be returned props.add("uniqueKey"); props.add("version"); props.add("subject"); props.add("categories"); props.add("createdOn"); props.add("createdBy"); props.add("modifiedBy"); props.add("modifiedOn"); props.add("location"); props.add("startOn"); props.add("endOn"); props.add("allDay"); props.add("project"); props.add("attendees"); props.add("resources"); props.add("categories"); return props; }
Deleting appointments
The following sample deletes an existing appointment.
Code Snippet
//for this sample it is assumed that a appointment record exists with a unique key String equal to uniqueKey protected AppointmentRepository appointmentRepository; public void test_deleteAppointment() throws Exception { appointmentRepository.deleteAppointment(uniqueKey); }