예제 #1
0
 /* (non-Javadoc)
  * @see playground.johannes.synpop.processing.EpisodeTask#apply(playground.johannes.synpop.data.PlainEpisode)
  */
 @Override
 public void apply(Episode plan) {
   for (Attributable act : plan.getActivities()) {
     String type = act.getAttribute(CommonKeys.ACTIVITY_TYPE);
     if ("pickdrop".equalsIgnoreCase(type)) {
       act.setAttribute(CommonKeys.ACTIVITY_TYPE, ActivityTypes.MISC);
     } else if ("private".equalsIgnoreCase(type)) {
       act.setAttribute(CommonKeys.ACTIVITY_TYPE, ActivityTypes.MISC);
     } else if ("intown".equalsIgnoreCase(type)) {
       act.setAttribute(CommonKeys.ACTIVITY_TYPE, ActivityTypes.MISC);
     } else if ("outoftown".equalsIgnoreCase(type)) {
       act.setAttribute(CommonKeys.ACTIVITY_TYPE, ActivityTypes.MISC);
     } else if ("unknown".equalsIgnoreCase(type)) {
       act.setAttribute(CommonKeys.ACTIVITY_TYPE, ActivityTypes.MISC);
     }
   }
 }
예제 #2
0
  /*
   * (non-Javadoc)
   *
   * @see
   * playground.johannes.synpop.processing.EpisodeTask#apply(playground.johannes
   * .gsv.synPop.PlainEpisode)
   */
  @Override
  public void apply(Episode plan) {
    boolean hasVacations = false;
    for (Attributable act : plan.getActivities()) {
      if ("vacations".equalsIgnoreCase(act.getAttribute(CommonKeys.ACTIVITY_TYPE))) {
        hasVacations = true;
        break;
      }
    }

    if (hasVacations) {
      boolean isLong = false;

      Attributable first = plan.getLegs().get(0);
      Attributable last = plan.getLegs().get(plan.getLegs().size() - 1);

      String startStr = first.getAttribute(CommonKeys.LEG_START_TIME);
      String endStr = last.getAttribute(CommonKeys.LEG_END_TIME);

      if (startStr != null && endStr != null) {
        DateTime start = SplitPlanTask.formatter.parseDateTime(startStr);
        DateTime end = SplitPlanTask.formatter.parseDateTime(endStr);

        if (end.getDayOfYear() - start.getDayOfYear() > 3) {
          isLong = true;
        }
      }

      for (Attributable act : plan.getActivities()) {
        if ("vacations".equalsIgnoreCase(act.getAttribute(CommonKeys.ACTIVITY_TYPE))) {
          if (isLong) {
            act.setAttribute(CommonKeys.ACTIVITY_TYPE, "vacations_long");
          } else {
            act.setAttribute(CommonKeys.ACTIVITY_TYPE, "vacations_short");
          }
        }
      }
    }
  }