/**
   * Filters a single process instance.
   *
   * @param instance the process instance to filter
   * @return true if the whole process instance passes the filter, false if the process insstance
   *     should be discarded
   */
  protected boolean doFiltering(ProcessInstance instance) {

    // creating the artificial end task ate
    AuditTrailEntry ate = new AuditTrailEntryImpl();
    ate.setElement(eventName);
    ate.setType(eventType);
    // ate.setTimestamp(new Date(System.currentTimeMillis() + 100000)); //
    // future
    ate.setOriginator("Artificial (ProM)");
    // adding the new end ate at the last position
    try {
      instance.getAuditTrailEntryList().append(ate);
    } catch (IOException e) {
      Message.add("Fatal error in class " + this.getClass() + ":", Message.ERROR);
      return false;
    }
    return true;
  }
  /**
   * Constructor method.
   *
   * @param pi process instance to be stored.
   */
  public FilterPerWorkflowModelElementAndEvent(ProcessInstance pi, int numberSimilarPIs) {

    if (pi != null) {
      AuditTrailEntryListImpl ates = null;

      try {
        ates = new AuditTrailEntryListImpl();

        for (int i = 0; i < pi.getAuditTrailEntryList().size(); i++) {
          AuditTrailEntry ate = new AuditTrailEntryImpl();
          ate.setElement(pi.getAuditTrailEntryList().get(i).getElement());
          ate.setType(pi.getAuditTrailEntryList().get(i).getType());
          ates.append(ate);
        }
      } catch (IOException ioe) {
        System.err.println(
            "Could not create an AuditTrailEntryListImpl in constructor of the class org.processmining.exporting.log.util.FilterPerWorkflowModelElementAndEvent!");
      }

      if (pi.getAttributes().containsKey(IDENTIFIERS)) {
        processInstance = new ProcessInstanceImpl(pi.getProcess(), ates, pi.getModelReferences());
        processInstance.setDataAttributes(pi.getDataAttributes());
        processInstance.setName(pi.getName());
        processInstance.setDescription(pi.getDescription());

      } else {

        processInstance = new ProcessInstanceImpl(pi.getProcess(), ates, pi.getModelReferences());
        processInstance.setDataAttributes(new DataSection());
        processInstance.setName(pi.getName());
        processInstance.setDescription(pi.getDescription());
        addGroupedPiIdentifier(pi.getName());
      }

      setNumberSimilarPIs(Integer.toString(numberSimilarPIs));

    } else {
      throw new NullPointerException("pi equals null!");
    }
  }