/** * <p>addApplication</p> * * @param application a {@link org.opennms.netmgt.model.OnmsApplication} object. * @return a boolean. */ public boolean addApplication(OnmsApplication application) { return getApplications().add(application); }
/** * <p>removeApplication</p> * * @param application a {@link org.opennms.netmgt.model.OnmsApplication} object. * @return a boolean. */ public boolean removeApplication(OnmsApplication application) { return getApplications().remove(application); }
public ServiceEditModel(OnmsMonitoredService service, List<OnmsApplication> applications) { m_service = service; m_applications = applications; for (OnmsApplication application : service.getApplications()) { m_applications.remove(application); } m_sortedApplications = new ArrayList<OnmsApplication>(m_service.getApplications()); Collections.sort(m_sortedApplications); }
public ServiceEditModel(OnmsMonitoredService service, List<OnmsApplication> applications) { m_service = service; m_applications = applications; for (OnmsApplication application : service.getApplications()) { m_applications.remove(application); } m_sortedApplications = new ArrayList<OnmsApplication>(m_service.getApplications()); Collections.sort(m_sortedApplications); }
@Override public Set<OnmsMonitoredService> findByApplication(final OnmsApplication application) { final Set<OnmsMonitoredService> services = new HashSet<>(); for (final OnmsMonitoredService svc : findAll()) { if (svc.getApplications().contains(application)) { services.add(svc); } } return services; }
@Override public Set<OnmsMonitoredService> findByApplication(final OnmsApplication application) { final Set<OnmsMonitoredService> services = new HashSet<>(); for (final OnmsMonitoredService svc : findAll()) { if (svc.getApplications().contains(application)) { services.add(svc); } } return services; }
/** {@inheritDoc} */ @Override public List<OnmsApplication> findByMonitoredService(int id) { OnmsMonitoredService service = m_monitoredServiceDao.get(id); if (service == null) { throw new IllegalArgumentException("monitored service with " + "id of " + id + " could not be found"); } List<OnmsApplication> sortedApplications = new ArrayList<OnmsApplication>(service.getApplications()); Collections.sort(sortedApplications); return sortedApplications; }
/** {@inheritDoc} */ @Override public List<OnmsApplication> findByMonitoredService(int id) { OnmsMonitoredService service = m_monitoredServiceDao.get(id); if (service == null) { throw new IllegalArgumentException("monitored service with " + "id of " + id + " could not be found"); } List<OnmsApplication> sortedApplications = new ArrayList<OnmsApplication>(service.getApplications()); Collections.sort(sortedApplications); return sortedApplications; }
@Override public Collection<OnmsLocationSpecificStatus> getStatusChangesForApplicationBetween(final Date startDate, final Date endDate, final String applicationName) { final List<OnmsLocationSpecificStatus> statuses = new ArrayList<>(); for (final OnmsLocationSpecificStatus status : getStatusChangesBetween(startDate, endDate)) { for (final OnmsApplication app : status.getMonitoredService().getApplications()) { if (applicationName.equals(app.getName())) { statuses.add(status); break; } } } return statuses; }
@Override public Collection<OnmsLocationSpecificStatus> getStatusChangesForApplicationBetween(final Date startDate, final Date endDate, final String applicationName) { final List<OnmsLocationSpecificStatus> statuses = new ArrayList<>(); for (final OnmsLocationSpecificStatus status : getStatusChangesBetween(startDate, endDate)) { for (final OnmsApplication app : status.getMonitoredService().getApplications()) { if (applicationName.equals(app.getName())) { statuses.add(status); break; } } } return statuses; }
@Override public Collection<OnmsLocationSpecificStatus> getStatusChangesBetweenForApplications(final Date startDate, final Date endDate, final Collection<String> applicationNames) { final List<OnmsLocationSpecificStatus> statuses = new ArrayList<>(); for (final OnmsLocationSpecificStatus status : getStatusChangesBetween(startDate, endDate)) { boolean added = false; for (final OnmsApplication app : status.getMonitoredService().getApplications()) { for (final String applicationName : applicationNames) { if (applicationName.equals(app.getName())) { statuses.add(status); added = true; break; } } if (added) break; } } return statuses; }
@Override public Collection<OnmsLocationSpecificStatus> getStatusChangesBetweenForApplications(final Date startDate, final Date endDate, final Collection<String> applicationNames) { final List<OnmsLocationSpecificStatus> statuses = new ArrayList<>(); for (final OnmsLocationSpecificStatus status : getStatusChangesBetween(startDate, endDate)) { boolean added = false; for (final OnmsApplication app : status.getMonitoredService().getApplications()) { for (final String applicationName : applicationNames) { if (applicationName.equals(app.getName())) { statuses.add(status); added = true; break; } } if (added) break; } } return statuses; }
@Override public Collection<OnmsLocationMonitor> findByApplication(final OnmsApplication application) { /* * return findObjects(OnmsLocationMonitor.class, "select distinct l from OnmsLocationSpecificStatus as status " + "join status.monitoredService as m " + "join m.applications a " + "join status.locationMonitor as l " + "where a = ? and status.id in ( " + "select max(s.id) from OnmsLocationSpecificStatus as s " + "group by s.locationMonitor, s.monitoredService " + ")", application); */ final Set<OnmsLocationMonitor> monitors = new HashSet<>(); for (final OnmsLocationSpecificStatus stat : getAllMostRecentStatusChanges()) { if (stat.getMonitoredService().getApplications().contains(application)) { monitors.add(stat.getLocationMonitor()); } } return monitors; }
@Override public Collection<OnmsLocationMonitor> findByApplication(final OnmsApplication application) { /* * return findObjects(OnmsLocationMonitor.class, "select distinct l from OnmsLocationSpecificStatus as status " + "join status.monitoredService as m " + "join m.applications a " + "join status.locationMonitor as l " + "where a = ? and status.id in ( " + "select max(s.id) from OnmsLocationSpecificStatus as s " + "group by s.locationMonitor, s.monitoredService " + ")", application); */ final Set<OnmsLocationMonitor> monitors = new HashSet<>(); for (final OnmsLocationSpecificStatus stat : getAllMostRecentStatusChanges()) { if (stat.getMonitoredService().getApplications().contains(application)) { monitors.add(stat.getLocationMonitor()); } } return monitors; }
+ " could not be found"); if (service.getApplications().contains(application)) { throw new IllegalArgumentException("application with " + "id of " + id + service.getServiceName()); service.getApplications().add(application); + " could not be found"); if (!service.getApplications().contains(application)) { throw new IllegalArgumentException("application with " + "id of " + id + service.getServiceName()); service.getApplications().add(application);
+ " could not be found"); if (service.getApplications().contains(application)) { throw new IllegalArgumentException("application with " + "id of " + id + service.getServiceName()); service.getApplications().add(application); + " could not be found"); if (!service.getApplications().contains(application)) { throw new IllegalArgumentException("application with " + "id of " + id + service.getServiceName()); service.getApplications().add(application);
+ "could not be found"); if (service.getApplications().contains(application)) { throw new IllegalArgumentException("monitored service with " + "id of " + id + "could not be found"); if (!service.getApplications().contains(application)) { throw new IllegalArgumentException("monitored service with " + "id of " + id
+ "could not be found"); if (service.getApplications().contains(application)) { throw new IllegalArgumentException("monitored service with " + "id of " + id + "could not be found"); if (!service.getApplications().contains(application)) { throw new IllegalArgumentException("monitored service with " + "id of " + id
/** * <p>Constructor for PolledService.</p> * * @param monitoredService a {@link org.opennms.netmgt.model.OnmsMonitoredService} object. * @param monitorConfiguration a {@link java.util.Map} object. * @param pollModel a {@link org.opennms.netmgt.poller.remote.OnmsPollModel} object. */ public PolledService(final OnmsMonitoredService monitoredService, final Map<String,Object> monitorConfiguration, final OnmsPollModel pollModel) { m_serviceId = monitoredService.getId(); m_nodeId = monitoredService.getNodeId(); m_nodeLabel = monitoredService.getIpInterface().getNode().getLabel(); m_nodeLocation = monitoredService.getIpInterface().getNode().getLocation().getLocationName(); m_svcName = monitoredService.getServiceName(); m_address = monitoredService.getIpInterface().getIpAddress(); m_monitorConfiguration = monitorConfiguration; m_pollModel = pollModel; // Add all of the application names for the service to this object m_applications = monitoredService.getApplications().stream().map(OnmsApplication::getName).collect(Collectors.toSet()); }
/** * <p>Constructor for PolledService.</p> * * @param monitoredService a {@link org.opennms.netmgt.model.OnmsMonitoredService} object. * @param monitorConfiguration a {@link java.util.Map} object. * @param pollModel a {@link org.opennms.netmgt.poller.remote.OnmsPollModel} object. */ public PolledService(final OnmsMonitoredService monitoredService, final Map<String,Object> monitorConfiguration, final OnmsPollModel pollModel) { m_serviceId = monitoredService.getId(); m_nodeId = monitoredService.getNodeId(); m_nodeLabel = monitoredService.getIpInterface().getNode().getLabel(); m_nodeLocation = monitoredService.getIpInterface().getNode().getLocation().getLocationName(); m_svcName = monitoredService.getServiceName(); m_address = monitoredService.getIpInterface().getIpAddress(); m_monitorConfiguration = monitorConfiguration; m_pollModel = pollModel; // Add all of the application names for the service to this object m_applications = monitoredService.getApplications().stream().map(OnmsApplication::getName).collect(Collectors.toSet()); }