session.save(myCustomer);
tx.commit();
myHandler.debugInfo(".. added to the database with id: "+myCustomer.getId());
}
tx = session.beginTransaction();
activeSession = new MerchantSession();
activeSession.setCustomer(myCustomer);
session.save(activeSession);
tx.commit();
session.close();
myHandler.debugInfo("Started session for customer "+activeSession.getCustomer().getName()+".");
}
return "";
} else if (COMMAND_MERCHANT_STOPSESSION.equals(commandName)) {
if (activeSession == null) {
printMerchantWarning("No merchant session active. Start session first.");
} else {
Session session = HibernateUtil.getSessionFactory().openSession();
Transaction tx = session.beginTransaction();
activeSession.setSessionEnd(new Date());
session.update(activeSession);
tx.commit();
session.close();
myHandler.debugInfo("Stopped session for customer "+activeSession.getCustomer().getName()+".");
printMerchantWarning("Finished session for customer "+activeSession.getCustomer().getName()+".");
myHandler.doCommand("mercview "+activeSession.getId());
activeSession = null;
}
return "";
} else if (COMMAND_MERCHANT_VIEWSESSION.equals(commandName) || COMMAND_MERCHANT_VIEWSESSION_DETAILS.equals(commandName)) {
Session session = HibernateUtil.getSessionFactory().openSession();
MerchantSessionHibernateDAO mercDAO = new MerchantSessionHibernateDAO();
mercDAO.setSession(session);
MerchantSession viewMS;
try {
Transaction tx = session.beginTransaction();
viewMS = mercDAO.findById(new Integer(commandMatcher.group(1)), false);
tx.commit();
if (COMMAND_MERCHANT_VIEWSESSION.equals(commandName))