/** @param args */
  public static void main(String[] args) {
    XFactoryBufferedImpl factory = new XFactoryBufferedImpl();

    XLog log = factory.createLog();
    XTrace trace = factory.createTrace();
    XEvent event1 = factory.createEvent();
    XEvent event2 = factory.createEvent();
    XEvent event3 = (XEvent) event2.clone();

    System.out.println("Event 3 and event 2 are equal: " + event3.equals(event2));

    trace.add(event1);
    trace.add(event2);
    log.add(trace);

    XLog log2 = (XLog) log.clone();

    System.out.println("Log 1 and log 2 are equal: " + log.equals(log2));

    trace.remove(event1);

    System.out.println("This log should start with 1 events");
    doTest(log);

    System.out.println("This log should start with 2 event");
    doTest(log2);
  }
  @Plugin(
      name = "Add End Artificial Events",
      parameterLabels = {"Log"},
      returnLabels = {"Altered log"},
      returnTypes = {XLog.class},
      userAccessible = true,
      help = "Adds an artificial  end task to every trace in the log file")
  @UITopiaVariant(
      affiliation = "Department of Computer Science University of Pisa",
      author = "R.Guanciale,G.Spagnolo et al.",
      email = "*****@*****.**",
      pack = "PetriNetReplayAnalysis")
  public XLog addEvents(PluginContext context, XLog oldLog) {

    context.getFutureResult(0).setLabel(XConceptExtension.instance().extractName(oldLog));

    context.getProgress().setMinimum(0);
    context.getProgress().setMaximum(oldLog.size());
    context.getProgress().setIndeterminate(false);
    context.getProgress().setValue(0);

    XAttributeMap logattlist = copyAttMap(oldLog.getAttributes());
    XLog newLog = new XLogImpl(logattlist);
    for (int i = 0; i < oldLog.size(); i++) {
      XTrace oldTrace = oldLog.get(i);
      XTrace newTrace = new XTraceImpl(copyAttMap(oldTrace.getAttributes()));
      for (int j = 0; j < oldTrace.size(); j++) {
        XEvent oldEvent = oldTrace.get(j);
        XEvent newEvent = new XEventImpl(copyAttMap(oldEvent.getAttributes()));
        newTrace.add(newEvent);
      }

      Date time = new Date();
      try {
        time =
            ((XAttributeTimestampImpl)
                    oldTrace.get(oldTrace.size() - 1).getAttributes().get("time:timestamp"))
                .getValue();
        time.setTime(time.getTime() + 1);
      } catch (Exception ex) {
      }

      newTrace.add(makeEvent("ArtificialEnd", time));

      newLog.add(newTrace);
      context.getProgress().inc();
    }
    return newLog;
  }