Source:
public void handleMessage(MinionIdentityDTO minionHandle) { LOG.info("Received heartbeat for Minion with id: at location: {}", minionHandle.getId(), minionHandle.getLocation()); OnmsMinion minion = minionDao.findById(minionHandle.getId()); if (minion == null) { minion = new OnmsMinion(); minion.setId(minionHandle.getId()); } String prevLocation = minion.getLocation(); String nextLocation = minionHandle.getLocation(); minion.setLocation(minionHandle.getLocation()); this.provision(minion, prevLocation, nextLocation); minion.setLastUpdated(new Date()); minionDao.saveOrUpdate(minion); if (prevLocation == null) { final EventBuilder eventBuilder = new EventBuilder(EventConstants.MONITORING_SYSTEM_ADDED_UEI, "Monitoring_System_Updates"); eventBuilder.addParam(EventConstants.PARAM_MONITORING_SYSTEM_TYPE, OnmsMonitoringSystem.TYPE_MINION); eventBuilder.addParam(EventConstants.PARAM_MONITORING_SYSTEM_ID, minionHandle.getId()); eventBuilder.addParam(EventConstants.PARAM_MONITORING_SYSTEM_LOCATION, nextLocation); try { m_eventProxy.send(eventBuilder.getEvent()); } catch (final EventProxyException e) { throw new DataAccessResourceFailureException("Unable to send event", e); } } else if (!prevLocation.equals(nextLocation)) { final EventBuilder eventBuilder = new EventBuilder(EventConstants.MONITORING_SYSTEM_LOCATION_CHANGED_UEI, "Monitoring_System_Updates"); eventBuilder.addParam(EventConstants.PARAM_MONITORING_SYSTEM_TYPE, OnmsMonitoringSystem.TYPE_MINION); eventBuilder.addParam(EventConstants.PARAM_MONITORING_SYSTEM_ID, minionHandle.getId()); eventBuilder.addParam(EventConstants.PARAM_MONITORING_SYSTEM_PREV_LOCATION, prevLocation); eventBuilder.addParam(EventConstants.PARAM_MONITORING_SYSTEM_LOCATION, nextLocation); try { m_eventProxy.send(eventBuilder.getEvent()); } catch (final EventProxyException e) { throw new DataAccessResourceFailureException("Unable to send event", e); } } }

Target:
public void handleMessage(MinionIdentityDTO minionHandle) { LOG.info("Received heartbeat for Minion with id: at location: {}", minionHandle.getId(), minionHandle.getLocation()); OnmsMinion minion = minionDao.findById(minionHandle.getId()); if (minion == null) { minion = new OnmsMinion(); minion.setId(minionHandle.getId()); minion.setLocation(null); } final String prevLocation = minion.getLocation(); final String nextLocation = minionHandle.getLocation(); minion.setLocation(minionHandle.getLocation()); this.provision(minion, prevLocation, nextLocation); minion.setLastUpdated(new Date()); minionDao.saveOrUpdate(minion); if (prevLocation == null) { final EventBuilder eventBuilder = new EventBuilder(EventConstants.MONITORING_SYSTEM_ADDED_UEI, "OpenNMS.Minion.Heartbeat"); eventBuilder.addParam(EventConstants.PARAM_MONITORING_SYSTEM_TYPE, OnmsMonitoringSystem.TYPE_MINION); eventBuilder.addParam(EventConstants.PARAM_MONITORING_SYSTEM_ID, minionHandle.getId()); eventBuilder.addParam(EventConstants.PARAM_MONITORING_SYSTEM_LOCATION, nextLocation); try { eventProxy.send(eventBuilder.getEvent()); } catch (final EventProxyException e) { throw new DataAccessResourceFailureException("Unable to send event", e); } } else if (!prevLocation.equals(nextLocation)) { final EventBuilder eventBuilder = new EventBuilder(EventConstants.MONITORING_SYSTEM_LOCATION_CHANGED_UEI, "OpenNMS.Minion.Heartbeat"); eventBuilder.addParam(EventConstants.PARAM_MONITORING_SYSTEM_TYPE, OnmsMonitoringSystem.TYPE_MINION); eventBuilder.addParam(EventConstants.PARAM_MONITORING_SYSTEM_ID, minionHandle.getId()); eventBuilder.addParam(EventConstants.PARAM_MONITORING_SYSTEM_PREV_LOCATION, prevLocation); eventBuilder.addParam(EventConstants.PARAM_MONITORING_SYSTEM_LOCATION, nextLocation); try { eventProxy.send(eventBuilder.getEvent()); } catch (final EventProxyException e) { throw new DataAccessResourceFailureException("Unable to send event", e); } } }