* @return the collector created from the database definition
*/
public NetFlowCollector retrieve(int sessionID) throws DBException, UnknownHostException, SNMPException {
DeviceDAO deviceDAO;
NetFlowMatchCriteriaDAO criteriaDAO;
FlowOptionsDAO optionsDAO;
String name;
Device device;
PortsSelectorSNMP portsSNMP;
NetFlowSNMP netflowSNMP;
long pollInterval;
int ifIndex;
String ifDescr;
int direction;
int tableSize;
NetFlowMatchCriteria criteria;
FlowOptions options;
name = (String)(DBUtil.retrieveSingleAttributeWithPK(connection, RETRIEVE_DEVICE, sessionID));
deviceDAO = DAOFactory.getDeviceDAO();
device = deviceDAO.retrieveDevice(name, true);
deviceDAO.closeConnection();
pollInterval = ((Long)(DBUtil.retrieveSingleAttributeWithPK(connection, RETRIEVE_POLLINTERVAL, sessionID))).longValue();
ifDescr = (String)(DBUtil.retrieveSingleAttributeWithPK(connection, RETRIEVE_IFDESCR, sessionID));
direction = ((Integer)(DBUtil.retrieveSingleAttributeWithPK(connection, RETRIEVE_DIRECTION, sessionID))).intValue();
tableSize = ((Integer)(DBUtil.retrieveSingleAttributeWithPK(connection, RETRIEVE_TABLESIZE, sessionID))).intValue();
portsSNMP = new PortsSelectorSNMP(device);
/*
device.enumeratePorts();
ifIndex = -1;
for ( int i = 0 ; i < device.getPortsIndex().length ; i++ ) {
if ( device.getPortsDescr()[i].equals(ifDescr) ) {
ifIndex = device.getPortsIndex()[i];
}
}
*/
ifIndex = portsSNMP.getIfIndex(ifDescr);
criteriaDAO = DAOFactory.getNetFlowMatchCriteriaDAO(connection);
criteria = criteriaDAO.retrieve(sessionID);
optionsDAO = DAOFactory.getFlowOptionsDAO(connection);
options = optionsDAO.retrieve(sessionID);
netflowSNMP = new NetFlowSNMP(device);
return new NetFlowCollector(netflowSNMP, ifIndex, ifDescr, direction, tableSize, pollInterval, criteria, options);
}