package com.cin.ejb.statisticsejb;
import java.util.logging.Level;
import javax.ejb.Stateless;
import com.cin.dto.GenericRequest;
import com.cin.dto.GenericResponse;
import com.cin.ejb.transactionejb.TransactionRemote;
import com.cin.exceptions.PersistenceException;
import com.cin.jndi.lookup.EJBLookup;
import com.cin.log.EventLogger;
import com.cin.service.StatisticsService;
/**
* Session Bean implementation class StatisticsEJB
*/
@Stateless(mappedName = "StatisticsEJB")
public class StatisticsEJB implements StatisticsEJBRemote {
static StatisticsService aStatsService;
/**
* Default constructor.
*/
public StatisticsEJB() {
}
static TransactionRemote aRemote;
static {
try {
aRemote = EJBLookup.getInstance().getTransactionEJB();
}
catch(Exception pException) {
EventLogger.getInstance().log(Level.SEVERE, pException.getMessage());
}
aStatsService = new StatisticsService();
}
public GenericResponse calculateAverageWeeklyWage(GenericRequest pRequest) {
GenericResponse aResponse = new GenericResponse();
try {
aResponse = aStatsService.calculateWeeklyWage(pRequest.getStatistics());
aResponse.setResponseStatus(true);
}
catch(PersistenceException pException) {
aResponse.setErrorMessage(pException.getMessage());
}
return aResponse;
}
public GenericResponse calculateAverageIncome(GenericRequest pRequest) {
GenericResponse aResponse = new GenericResponse();
try {
aResponse = aStatsService.calculateAverageIncome(pRequest.getStatistics());
}
catch(PersistenceException pException) {
aResponse.setErrorMessage(pException.getMessage());
}
return aResponse;
}
}