// Path: src/main/java/org/droolsfiddle/websocket/CustomDroolsEvent.java
// public class CustomDroolsEvent {
// 
//   private String action;
// 
//   private String type;
//   private String id;
//   private java.lang.Object object;
//   private List<String> from;
// 
//   public CustomDroolsEvent(String action) {
//     this.action = action;
//     this.from = new ArrayList<String>();
//   }
// 
//   public String getId() {
//     return id;
//   }
// 
//   public void setId(String id) {
//     this.id = id;
//   }
// 
//   public String getAction() {
//     return action;
//   }
// 
//   public void setAction(String action) {
//     this.action = action;
//   }
// 
//   public String getType() { return type; }
// 
//   public void setType(String type) { this.type = type; }
// 
//   public Object getObject() {
//     return object;
//   }
// 
//   public void setObject(Object object) {
//     this.object = object;
//   }
// 
//   public List<String> getFrom() {
//     return from;
//   }
// 
//   public void setFrom(List<String> from) {
//     this.from = from;
//   }
// 
//   public void addFrom(String from) {
//     this.from.add(from);
//   }
// 
//   public CustomDroolsEvent map(ObjectInsertedEvent iEvent) {
//     setId(Integer.toString(iEvent.getObject().hashCode()));
//     setObject(iEvent.getObject());
//     setType(iEvent.getKieRuntime().getObject(iEvent.getFactHandle()).getClass().getSimpleName());
// 
//     if (iEvent.getRule() != null) {
//       addFrom(iEvent.getRule().getName());
//     }
//     return this;
//   }
// 
//   public CustomDroolsEvent map(ObjectUpdatedEvent iEvent) {
//     setId(Integer.toString(iEvent.getObject().hashCode()));
//     setObject(iEvent.getObject());
//     setType(iEvent.getKieRuntime().getObject(iEvent.getFactHandle()).getClass().getSimpleName());
//     if (iEvent.getRule() != null) {
//       addFrom(iEvent.getRule().getName());
//     }
//     return this;
//   }
// 
//   public CustomDroolsEvent map(ObjectDeletedEvent iEvent) {
//     setId(Integer.toString(iEvent.getOldObject().hashCode()));
//     setObject(iEvent.getOldObject());
//     if (iEvent.getRule() != null) {
//       addFrom(iEvent.getRule().getName());
//     }
//     return this;
//   }
// 
//   public CustomDroolsEvent map(BeforeMatchFiredEvent iEvent) {
//     setObject(iEvent.getMatch().getRule().getName());
//     for (Object o : iEvent.getMatch().getObjects()) {
//       addFrom(Integer.toString(o.hashCode()));
//     }
//     return this;
//   }
// 
//   public CustomDroolsEvent map(FactDTO iFactType) {
//     setObject(iFactType);
//     return this;
//   }
// 
//   public CustomDroolsEvent map(RuleDTO iRule) {
//     setObject(iRule);
//     return this;
//   }
// 
// 
// }
// 
// Path: src/main/java/org/droolsfiddle/websocket/WebSocketUtil.java
// public class WebSocketUtil {
// 
//   static private Logger logger = Logger.getLogger(WebSocketUtil.class);
// 
//   static public void sendToWebSocket(Session iSession, String iData) {
//     try {
//     	logger.debug("session  "+ iSession);
//     	logger.debug("session getBasicRemote "+ iSession.getBasicRemote());
//       iSession.getBasicRemote().sendText(iData);
//     } catch (IOException e2) {
//       logger.error("Websocket error",e2);
//     }
//   }
// }


import com.fasterxml.jackson.databind.ObjectMapper;
import org.droolsfiddle.websocket.CustomDroolsEvent;
import org.droolsfiddle.websocket.WebSocketUtil;
import org.kie.api.event.rule.*;
import javax.websocket.Session;
import java.io.IOException;

/*   Copyright 2016 Drools Fiddle

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/

package org.droolsfiddle.websocket.audit;



/**
 * Created by jvipret on 23/07/2016.
 */
public class CustomDebugAgendaEventListener extends DebugAgendaEventListener {

  private Session wsSession;
  private ObjectMapper mapper = new ObjectMapper();


  public CustomDebugAgendaEventListener(Session iSession) {
    super();
    wsSession = iSession;
  }


  public void matchCancelled(MatchCancelledEvent event) {
    super.matchCancelled(event);
  }

  public void matchCreated(MatchCreatedEvent event) {
    super.matchCreated(event);
  }

  public void afterMatchFired(AfterMatchFiredEvent event) {
    super.afterMatchFired(event);
  }

  public void agendaGroupPopped(AgendaGroupPoppedEvent event) {
    super.agendaGroupPopped(event);
  }

  public void agendaGroupPushed(AgendaGroupPushedEvent event) {
    super.agendaGroupPushed(event);
  }

  public void beforeMatchFired(BeforeMatchFiredEvent event) {
    super.beforeMatchFired(event);

// Path: src/main/java/org/droolsfiddle/websocket/CustomDroolsEvent.java
// public class CustomDroolsEvent {
// 
//   private String action;
// 
//   private String type;
//   private String id;
//   private java.lang.Object object;
//   private List<String> from;
// 
//   public CustomDroolsEvent(String action) {
//     this.action = action;
//     this.from = new ArrayList<String>();
//   }
// 
//   public String getId() {
//     return id;
//   }
// 
//   public void setId(String id) {
//     this.id = id;
//   }
// 
//   public String getAction() {
//     return action;
//   }
// 
//   public void setAction(String action) {
//     this.action = action;
//   }
// 
//   public String getType() { return type; }
// 
//   public void setType(String type) { this.type = type; }
// 
//   public Object getObject() {
//     return object;
//   }
// 
//   public void setObject(Object object) {
//     this.object = object;
//   }
// 
//   public List<String> getFrom() {
//     return from;
//   }
// 
//   public void setFrom(List<String> from) {
//     this.from = from;
//   }
// 
//   public void addFrom(String from) {
//     this.from.add(from);
//   }
// 
//   public CustomDroolsEvent map(ObjectInsertedEvent iEvent) {
//     setId(Integer.toString(iEvent.getObject().hashCode()));
//     setObject(iEvent.getObject());
//     setType(iEvent.getKieRuntime().getObject(iEvent.getFactHandle()).getClass().getSimpleName());
// 
//     if (iEvent.getRule() != null) {
//       addFrom(iEvent.getRule().getName());
//     }
//     return this;
//   }
// 
//   public CustomDroolsEvent map(ObjectUpdatedEvent iEvent) {
//     setId(Integer.toString(iEvent.getObject().hashCode()));
//     setObject(iEvent.getObject());
//     setType(iEvent.getKieRuntime().getObject(iEvent.getFactHandle()).getClass().getSimpleName());
//     if (iEvent.getRule() != null) {
//       addFrom(iEvent.getRule().getName());
//     }
//     return this;
//   }
// 
//   public CustomDroolsEvent map(ObjectDeletedEvent iEvent) {
//     setId(Integer.toString(iEvent.getOldObject().hashCode()));
//     setObject(iEvent.getOldObject());
//     if (iEvent.getRule() != null) {
//       addFrom(iEvent.getRule().getName());
//     }
//     return this;
//   }
// 
//   public CustomDroolsEvent map(BeforeMatchFiredEvent iEvent) {
//     setObject(iEvent.getMatch().getRule().getName());
//     for (Object o : iEvent.getMatch().getObjects()) {
//       addFrom(Integer.toString(o.hashCode()));
//     }
//     return this;
//   }
// 
//   public CustomDroolsEvent map(FactDTO iFactType) {
//     setObject(iFactType);
//     return this;
//   }
// 
//   public CustomDroolsEvent map(RuleDTO iRule) {
//     setObject(iRule);
//     return this;
//   }
// 
// 
// }
// 
// Path: src/main/java/org/droolsfiddle/websocket/WebSocketUtil.java
// public class WebSocketUtil {
// 
//   static private Logger logger = Logger.getLogger(WebSocketUtil.class);
// 
//   static public void sendToWebSocket(Session iSession, String iData) {
//     try {
//     	logger.debug("session  "+ iSession);
//     	logger.debug("session getBasicRemote "+ iSession.getBasicRemote());
//       iSession.getBasicRemote().sendText(iData);
//     } catch (IOException e2) {
//       logger.error("Websocket error",e2);
//     }
//   }
// }


// Path: src/main/java/org/droolsfiddle/websocket/audit/CustomDebugAgendaEventListener.java
import com.fasterxml.jackson.databind.ObjectMapper;
import org.droolsfiddle.websocket.CustomDroolsEvent;
import org.droolsfiddle.websocket.WebSocketUtil;
import org.kie.api.event.rule.*;
import javax.websocket.Session;
import java.io.IOException;

/*   Copyright 2016 Drools Fiddle

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/

package org.droolsfiddle.websocket.audit;



/**
 * Created by jvipret on 23/07/2016.
 */
public class CustomDebugAgendaEventListener extends DebugAgendaEventListener {

  private Session wsSession;
  private ObjectMapper mapper = new ObjectMapper();


  public CustomDebugAgendaEventListener(Session iSession) {
    super();
    wsSession = iSession;
  }


  public void matchCancelled(MatchCancelledEvent event) {
    super.matchCancelled(event);
  }

  public void matchCreated(MatchCreatedEvent event) {
    super.matchCreated(event);
  }

  public void afterMatchFired(AfterMatchFiredEvent event) {
    super.afterMatchFired(event);
  }

  public void agendaGroupPopped(AgendaGroupPoppedEvent event) {
    super.agendaGroupPopped(event);
  }

  public void agendaGroupPushed(AgendaGroupPushedEvent event) {
    super.agendaGroupPushed(event);
  }

  public void beforeMatchFired(BeforeMatchFiredEvent event) {
    super.beforeMatchFired(event);

    try{
