protected void onShowGui() {
}
private void saveData(Command c) {
try {
UsageData item = new UsageData();
Timestamp ts = new java.sql.Timestamp(
Integer.parseInt(c.getProperty("event.date.year")) - 1900,
Integer.parseInt(c.getProperty("event.date.month")) - 1,
Integer.parseInt(c.getProperty("event.date.day")),
Integer.parseInt(c.getProperty("event.time.hour")),
Integer.parseInt(c.getProperty("event.time.minute")),
Integer.parseInt(c.getProperty("event.time.second")),
0);
item.setDateTime(ts);
item.setObjName(c.getProperty("event.object.name"));
item.setObjProtocol(c.getProperty("event.object.protocol"));
item.setObjAddress(c.getProperty("event.object.address"));
item.setUuid(c.getProperty("event.object.uuid"));
//search for all objects behaviors changes
Pattern pat = Pattern.compile("^current\\.object\\.behavior\\.(.*)");
for (Entry<Object, Object> entry : c.getProperties().entrySet()) {
String key = (String) entry.getKey();
Matcher fits = pat.matcher(key);
if (fits.find() && !fits.group(1).equals("data")) { //exclude unwanted behaviors
UsageData item2 = item.clone();
item2.setObjBehavior(fits.group(1));
item2.setObjValue((String) entry.getValue());
if (isRunning() && em != null) {
if (!em.getTransaction().isActive()) {
em.getTransaction().begin();
}