001/*
002 * The MIT License
003 * Copyright (c) 2012 Microsoft Corporation
004 *
005 * Permission is hereby granted, free of charge, to any person obtaining a copy
006 * of this software and associated documentation files (the "Software"), to deal
007 * in the Software without restriction, including without limitation the rights
008 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
009 * copies of the Software, and to permit persons to whom the Software is
010 * furnished to do so, subject to the following conditions:
011 *
012 * The above copyright notice and this permission notice shall be included in
013 * all copies or substantial portions of the Software.
014 *
015 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
016 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
017 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
018 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
019 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
020 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
021 * THE SOFTWARE.
022 */
023
024package microsoft.exchange.webservices.data.property.complex.availability;
025
026import microsoft.exchange.webservices.data.core.EwsServiceXmlReader;
027import microsoft.exchange.webservices.data.core.XmlElementNames;
028import microsoft.exchange.webservices.data.core.enumeration.property.ConflictType;
029import microsoft.exchange.webservices.data.core.enumeration.property.LegacyFreeBusyStatus;
030import microsoft.exchange.webservices.data.property.complex.ComplexProperty;
031
032/**
033 * Represents a conflict in a meeting time suggestion.
034 */
035public final class Conflict extends ComplexProperty {
036
037  /**
038   * The conflict type.
039   */
040  private ConflictType conflictType;
041
042  /**
043   * The number of members.
044   */
045  private int numberOfMembers;
046
047  /**
048   * The number of members available.
049   */
050  private int numberOfMembersAvailable;
051
052  /**
053   * The number of members with conflict.
054   */
055  private int numberOfMembersWithConflict;
056
057  /**
058   * The number of members with no data.
059   */
060  private int numberOfMembersWithNoData;
061
062  /**
063   * The free busy status.
064   */
065  private LegacyFreeBusyStatus freeBusyStatus;
066
067  /**
068   * Initializes a new instance of the Conflict class.
069   *
070   * @param conflictType the conflict type
071   */
072  protected Conflict(ConflictType conflictType) {
073    super();
074    this.conflictType = conflictType;
075  }
076
077  /**
078   * Tries to read element from XML.
079   *
080   * @param reader the reader
081   * @return True if appropriate element was read.
082   * @throws Exception the exception
083   */
084  @Override
085  public boolean tryReadElementFromXml(EwsServiceXmlReader reader)
086      throws Exception {
087    if (reader.getLocalName().equals(XmlElementNames.NumberOfMembers)) {
088      this.numberOfMembers = reader.readElementValue(Integer.class);
089      return true;
090    } else if (reader.getLocalName().equals(
091        XmlElementNames.NumberOfMembersAvailable)) {
092      this.numberOfMembersAvailable = reader
093          .readElementValue(Integer.class);
094      return true;
095    } else if (reader.getLocalName().equals(
096        XmlElementNames.NumberOfMembersWithConflict)) {
097      this.numberOfMembersWithConflict = reader
098          .readElementValue(Integer.class);
099      return true;
100    } else if (reader.getLocalName().equals(
101        XmlElementNames.NumberOfMembersWithNoData)) {
102      this.numberOfMembersWithNoData = reader
103          .readElementValue(Integer.class);
104      return true;
105    } else if (reader.getLocalName().equals(XmlElementNames.BusyType)) {
106      this.freeBusyStatus = reader
107          .readElementValue(LegacyFreeBusyStatus.class);
108      return true;
109    } else {
110      return false;
111    }
112  }
113
114  /**
115   * Gets the type of the conflict.
116   *
117   * @return the conflict type
118   */
119  public ConflictType getConflictType() {
120    return conflictType;
121  }
122
123  /**
124   * Gets the number of users, resources, and rooms in the conflicting group.
125   * The value of this property is only meaningful when ConflictType is equal
126   * to ConflictType.GroupConflict.
127   *
128   * @return the number of members
129   */
130  public int getNumberOfMembers() {
131    return numberOfMembers;
132  }
133
134  /**
135   * Gets the number of members who are available (whose status is Free) in
136   * the conflicting group. The value of this property is only meaningful when
137   * ConflictType is equal to ConflictType.GroupConflict.
138   *
139   * @return the number of members available
140   */
141  public int getNumberOfMembersAvailable() {
142    return numberOfMembersAvailable;
143  }
144
145  /**
146   * Gets the number of members who have a conflict (whose status is Busy, OOF
147   * or Tentative) in the conflicting group. The value of this property is
148   * only meaningful when ConflictType is equal to ConflictType.GroupConflict.
149   *
150   * @return the number of members with conflict
151   */
152  public int getNumberOfMembersWithConflict() {
153    return numberOfMembersWithConflict;
154  }
155
156  /**
157   * Gets the number of members who do not have published free/busy data in
158   * the conflicting group. The value of this property is only meaningful when
159   * ConflictType is equal to ConflictType.GroupConflict.
160   *
161   * @return the number of members with no data
162   */
163  public int getNumberOfMembersWithNoData() {
164    return numberOfMembersWithNoData;
165  }
166
167  /**
168   * Gets the free/busy status of the conflicting attendee. The value of this
169   * property is only meaningful when ConflictType is equal to
170   * ConflictType.IndividualAttendee.
171   *
172   * @return the free busy status
173   */
174  public LegacyFreeBusyStatus getFreeBusyStatus() {
175    return freeBusyStatus;
176  }
177
178}