Beispiel #1
0
  /**
   * Check if this Activity is updated more recently than an other Activity.
   *
   * @param other the other
   * @return true, if is newer than
   */
  public boolean isNewerThan(final Activity other) {
    DateTime updatedThis = null;
    if (getStatus() != null && getStatus().getUpdated() != null) {
      updatedThis = new DateTime(getStatus().getUpdated());
    }
    DateTime updatedOther = null;
    if (other.getStatus() != null && other.getStatus().getUpdated() != null) {
      updatedOther = new DateTime(other.getStatus().getUpdated());
    }

    if (updatedOther == null) {
      // take this as newest
      return true;
    } else if (updatedThis == null) {
      // take other as newest
      return false;
    } else if (updatedThis.isAfter(updatedOther)) {
      // take this as newest
      return true;
    } else {
      // take other as newest
      return false;
    }
  }
Beispiel #2
0
  /**
   * Synchronize two activities. The newest activity will be merged into a clone of the oldest
   * activity.
   *
   * @param a the a
   * @param b the b
   * @return the activity
   */
  public static Activity sync(final Activity a, final Activity b) {
    Activity clone;
    if (a.isNewerThan(b)) {
      clone = b.clone();
      clone.merge(a);
    } else {
      clone = a.clone();
      clone.merge(b);
    }

    return clone;
  }
Beispiel #3
0
  /* (non-Javadoc)
   * @see java.lang.Object#clone()
   */
  @Override
  public Activity clone() {
    final Activity clone = new Activity();

    clone.summary = summary;
    clone.description = description;
    clone.agent = agent;
    if (constraints != null) {
      clone.constraints = constraints.clone();
    }
    if (status != null) {
      clone.status = status.clone();
    }

    return clone;
  }