All Downloads are FREE. Search and download functionalities are using the official Maven repository.

microsoft.exchange.webservices.data.AvailabilityOptions Maven / Gradle / Ivy

Go to download

The source came from http://archive.msdn.microsoft.com/ewsjavaapi Support for Maven has been added.

The newest version!
/**************************************************************************
 * copyright file="AvailabilityOptions.java" company="Microsoft"
 *     Copyright (c) Microsoft Corporation.  All rights reserved.
 * 
 * Defines the AvailabilityOptions.java.
 **************************************************************************/

package microsoft.exchange.webservices.data;

import java.util.Date;

/**
 *Represents the options of a GetAvailability request.
 */
public final class AvailabilityOptions {

	/** The merged free busy interval. */
	private int mergedFreeBusyInterval = 30;

	/** The requested free busy view. */
	private FreeBusyViewType requestedFreeBusyView = FreeBusyViewType.Detailed;

	/** The good suggestion threshold. */
	private int goodSuggestionThreshold = 25;

	/** The maximum suggestions per day. */
	private int maximumSuggestionsPerDay = 10;

	/** The maximum non work hours suggestions per day. */
	private int maximumNonWorkHoursSuggestionsPerDay = 0;

	/** The meeting duration. */
	private int meetingDuration = 60;

	/** The minimum suggestion quality. */
	private SuggestionQuality minimumSuggestionQuality = SuggestionQuality.Fair;

	/** The detailed suggestions window. */
	private TimeWindow detailedSuggestionsWindow;

	/** The current meeting time. */
	private Date currentMeetingTime;

	/** The global object id. */
	private String globalObjectId;

	/**
	 * Validates this instance against the specified time window.
	 * 
	 * @param timeWindow
	 *            the time window
	 * @throws Exception
	 *             the exception
	 */
	protected void validate(long timeWindow) throws Exception {
		if (this.mergedFreeBusyInterval > timeWindow) {
			throw new IllegalArgumentException(String.format("%s,%s",
					Strings.MergedFreeBusyIntervalMustBeSmallerThanTimeWindow,
					"MergedFreeBusyInterval"));
		}

		EwsUtilities.validateParamAllowNull(this.detailedSuggestionsWindow,
				"DetailedSuggestionsWindow");
	}

	/**
	 * Writes to XML.
	 * 
	 * @param writer
	 *            the writer
	 * @param request
	 *            the request
	 * @throws Exception
	 *             the exception
	 */
	protected void writeToXml(EwsServiceXmlWriter writer,
			GetUserAvailabilityRequest request) throws Exception {
		if (request.isFreeBusyViewRequested()) {
			writer.writeStartElement(XmlNamespace.Types,
					XmlElementNames.FreeBusyViewOptions);

			request.getTimeWindow().writeToXmlUnscopedDatesOnly(writer,
					XmlElementNames.TimeWindow);

			writer.writeElementValue(XmlNamespace.Types,
					XmlElementNames.MergedFreeBusyIntervalInMinutes,
					this.mergedFreeBusyInterval);

			writer.writeElementValue(XmlNamespace.Types,
					XmlElementNames.RequestedView, this.requestedFreeBusyView);

			writer.writeEndElement(); // FreeBusyViewOptions
		}

		if (request.isSuggestionsViewRequested()) {
			writer.writeStartElement(XmlNamespace.Types,
					XmlElementNames.SuggestionsViewOptions);

			writer
					.writeElementValue(XmlNamespace.Types,
							XmlElementNames.GoodThreshold,
							this.goodSuggestionThreshold);

			writer.writeElementValue(XmlNamespace.Types,
					XmlElementNames.MaximumResultsByDay,
					this.maximumSuggestionsPerDay);

			writer.writeElementValue(XmlNamespace.Types,
					XmlElementNames.MaximumNonWorkHourResultsByDay,
					this.maximumNonWorkHoursSuggestionsPerDay);

			writer.writeElementValue(XmlNamespace.Types,
					XmlElementNames.MeetingDurationInMinutes,
					this.meetingDuration);

			writer.writeElementValue(XmlNamespace.Types,
					XmlElementNames.MinimumSuggestionQuality,
					this.minimumSuggestionQuality);

			TimeWindow timeWindowToSerialize = 
				this.detailedSuggestionsWindow == null ? request
					.getTimeWindow() :
					 this.detailedSuggestionsWindow;

			timeWindowToSerialize.writeToXmlUnscopedDatesOnly(writer,
					XmlElementNames.DetailedSuggestionsWindow);

			if (this.currentMeetingTime != null) {
				writer.writeElementValue(XmlNamespace.Types,
						XmlElementNames.CurrentMeetingTime,
						this.currentMeetingTime);
			}

			writer.writeElementValue(XmlNamespace.Types,
					XmlElementNames.GlobalObjectId, this.globalObjectId);

			writer.writeEndElement(); // SuggestionsViewOptions
		}
	}

	/**
	 * Initializes a new instance of the AvailabilityOptions class.
	 */
	public AvailabilityOptions() {
	}

	/**
	 * Gets the time difference between two successive slots in a
	 * FreeBusyMerged view. MergedFreeBusyInterval must be between 5 and 1440.
	 * The default value is 30.
	 * 
	 * @return the merged free busy interval
	 */
	public int getMergedFreeBusyInterval() {
		return this.mergedFreeBusyInterval;
	}

	/**
	 * Sets the merged free busy interval.
	 * 
	 * @param value
	 *            the new merged free busy interval
	 */
	public void setMergedFreeBusyInterval(int value) {
		if (value < 5 || value > 1440) {
			throw new IllegalArgumentException(String.format("%s,%s,%s,%s",
					Strings.InvalidPropertyValueNotInRange,
					"MergedFreeBusyInterval", 5, 1440));
		}

		this.mergedFreeBusyInterval = value;
	}

	/**
	 * Gets  the requested type of free/busy view. The default value is
	 * FreeBusyViewType.Detailed.
	 * 
	 * @return the requested free busy view
	 */
	public FreeBusyViewType getRequestedFreeBusyView() {
		return this.requestedFreeBusyView;
	}

	/**
	 * Sets the requested free busy view.
	 * 
	 * @param value
	 *            the new requested free busy view
	 */
	public void setRequestedFreeBusyView(FreeBusyViewType value) {
		this.requestedFreeBusyView = value;
	}

	/**
	 * Gets  the percentage of attendees that must have the time period
	 * open for the time period to qualify as a good suggested meeting time.
	 * GoodSuggestionThreshold must be between 1 and 49. The default value is
	 * 25.
	 * 
	 * @return the good suggestion threshold
	 */
	public int getGoodSuggestionThreshold() {
		return this.goodSuggestionThreshold;
	}

	/**
	 * Sets the good suggestion threshold.
	 * 
	 * @param value
	 *            the new good suggestion threshold
	 */
	public void setGoodSuggestionThreshold(int value) {
		if (value < 1 || value > 49) {
			throw new IllegalArgumentException(String.format(
					Strings.InvalidPropertyValueNotInRange,
					"GoodSuggestionThreshold", 1, 49));
		}

		this.goodSuggestionThreshold = value;
	}

	/**
	 * Gets the number of suggested meeting times that should be
	 * returned per day. MaximumSuggestionsPerDay must be between 0 and 48. The
	 * default value is 10.
	 * 
	 * @return the maximum suggestions per day
	 */
	public int getMaximumSuggestionsPerDay() {
		return this.maximumSuggestionsPerDay;
	}

	/**
	 * Sets the maximum suggestions per day.
	 * 
	 * @param value
	 *            the new maximum suggestions per day
	 */
	public void setMaximumSuggestionsPerDay(int value) {
		if (value < 0 || value > 48) {
			throw new IllegalArgumentException(String.format("%s,%s,%s,%s",
					Strings.InvalidPropertyValueNotInRange,
					"MaximumSuggestionsPerDay", 0, 48));
		}

		this.maximumSuggestionsPerDay = value;
	}

	/**
	 * Gets the number of suggested meeting times outside regular
	 * working hours per day. MaximumNonWorkHoursSuggestionsPerDay must be
	 * between 0 and 48. The default value is 0.
	 * 
	 * @return the maximum non work hours suggestions per day
	 */
	public int getMaximumNonWorkHoursSuggestionsPerDay() {
		return this.maximumNonWorkHoursSuggestionsPerDay;
	}

	/**
	 * Sets the maximum non work hours suggestions per day.
	 * 
	 * @param value
	 *            the new maximum non work hours suggestions per day
	 */
	public void setMaximumNonWorkHoursSuggestionsPerDay(int value) {
		if (value < 0 || value > 48) {
			throw new IllegalArgumentException(String.format(
					Strings.InvalidPropertyValueNotInRange,
					"MaximumNonWorkHoursSuggestionsPerDay", 0, 48));
		}

		this.maximumNonWorkHoursSuggestionsPerDay = value;
	}

	/**
	 * Gets  the duration, in minutes, of the meeting for which to obtain
	 * suggestions. MeetingDuration must be between 30 and 1440. The default
	 * value is 60.
	 * 
	 * @return the meeting duration
	 */
	public int getMeetingDuration() {
		return this.meetingDuration;
	}

	/**
	 * Sets the meeting duration.
	 * 
	 * @param value
	 *            the new meeting duration
	 */
	public void setMeetingDuration(int value) {
		if (value < 30 || value > 1440) {
			throw new IllegalArgumentException(String.format("%s,%s,%s,%s",
					Strings.InvalidPropertyValueNotInRange, "MeetingDuration",
					30, 1440));
		}

		this.meetingDuration = value;
	}

	/**
	 * Gets the minimum quality of suggestions that should be returned.
	 * The default is SuggestionQuality.Fair.
	 * 
	 * @return the minimum suggestion quality
	 */
	public SuggestionQuality getMinimumSuggestionQuality() {
		return this.minimumSuggestionQuality;
	}

	/**
	 * Sets the minimum suggestion quality.
	 * 
	 * @param value
	 *            the new minimum suggestion quality
	 */
	public void setMinimumSuggestionQuality(SuggestionQuality value) {
		this.minimumSuggestionQuality = value;
	}

	/**
	 * Gets the time window for which detailed information about
	 * suggested meeting times should be returned.
	 * 
	 * @return the detailed suggestions window
	 */
	public TimeWindow getDetailedSuggestionsWindow() {
		return this.detailedSuggestionsWindow;
	}

	/**
	 * Sets the detailed suggestions window.
	 * 
	 * @param value
	 *            the new detailed suggestions window
	 */
	public void setDetailedSuggestionsWindow(TimeWindow value) {
		this.detailedSuggestionsWindow = value;
	}

	/**
	 * Gets the start time of a meeting that you want to update with the
	 * suggested meeting times.
	 * 
	 * @return the current meeting time
	 */
	public Date getCurrentMeetingTime() {
		return this.currentMeetingTime;
	}

	/**
	 * Sets the current meeting time.
	 * 
	 * @param value
	 *            the new current meeting time
	 */
	public void setCurrentMeetingTime(Date value) {
		this.currentMeetingTime = value;
	}

	/**
	 * Gets the global object Id of a meeting that will be modified
	 * based on the data returned by GetUserAvailability.
	 * 
	 * @return the global object id
	 */
	public String getGlobalObjectId() {
		return this.globalObjectId;
	}

	/**
	 * Sets the global object id.
	 * 
	 * @param value
	 *            the new global object id
	 */
	public void setGlobalObjectId(String value) {
		this.globalObjectId = value;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy