Search in sources :

Example 6 with LocationInfo

use of org.opennms.features.poller.remote.gwt.client.location.LocationInfo in project opennms by OpenNMS.

the class LocationDataServiceIT method testLocationInfo.

@Test
public void testLocationInfo() throws Exception {
    m_pollerBackEnd.reportResult(m_rduMonitor1.getId(), m_localhostHttpService.getId(), getAvailable(new Date(now() - days(20) - hours(3))));
    m_pollerBackEnd.reportResult(m_rduMonitor1.getId(), m_localhostHttpService.getId(), getDown(new Date(now() - days(20) - hours(2))));
    m_pollerBackEnd.reportResult(m_rduMonitor1.getId(), m_localhostHttpService.getId(), getAvailable(new Date(now() - days(20) - hours(1))));
    m_pollerBackEnd.reportResult(m_rduMonitor1.getId(), m_googleHttpService.getId(), getDown(new Date(now() - days(20) - hours(4))));
    LocationInfo li = m_locationDataService.getLocationInfo("RDU");
    assertNotNull(li);
    assertEquals("RDU", li.getName());
    // Down because one of the services is down.
    assertEquals(Status.DOWN, li.getStatusDetails().getStatus());
}
Also used : Date(java.util.Date) LocationInfo(org.opennms.features.poller.remote.gwt.client.location.LocationInfo) Test(org.junit.Test)

Example 7 with LocationInfo

use of org.opennms.features.poller.remote.gwt.client.location.LocationInfo in project opennms by OpenNMS.

the class LocationBroadcastProcessor method handleEventParm.

private void handleEventParm(final String name, final String value) {
    if (name.equals(EventConstants.PARM_LOCATION_MONITOR_ID)) {
        final LocationInfo info = m_locationDataService.getLocationInfoForMonitor(Integer.valueOf(value));
        m_eventHandler.sendEvent(new LocationUpdatedRemoteEvent(info));
        for (final ApplicationInfo applicationInfo : m_locationDataService.getApplicationsForLocation(info)) {
            m_eventHandler.sendEvent(new ApplicationUpdatedRemoteEvent(applicationInfo));
        }
    }
}
Also used : ApplicationInfo(org.opennms.features.poller.remote.gwt.client.ApplicationInfo) LocationUpdatedRemoteEvent(org.opennms.features.poller.remote.gwt.client.remoteevents.LocationUpdatedRemoteEvent) ApplicationUpdatedRemoteEvent(org.opennms.features.poller.remote.gwt.client.remoteevents.ApplicationUpdatedRemoteEvent) LocationInfo(org.opennms.features.poller.remote.gwt.client.location.LocationInfo)

Example 8 with LocationInfo

use of org.opennms.features.poller.remote.gwt.client.location.LocationInfo in project opennms by OpenNMS.

the class DefaultLocationManager method updateLocation.

/**
 * {@inheritDoc}
 *
 * Invoked by the {@link LocationUpdatedRemoteEvent} and
 * {@link LocationsUpdatedRemoteEvent} events.
 */
@Override
public void updateLocation(final LocationInfo newLocation) {
    if (newLocation != null) {
        LocationInfo oldLocation = m_dataManager.getLocation(newLocation.getName());
        // Update the location information in the model
        m_dataManager.updateLocation(newLocation);
        m_view.updateApplicationNames(m_dataManager.getAllApplicationNames());
        placeMarker(newLocation);
        if (m_updated) {
            // Update the icon/caption in the LHN
            if (oldLocation == null || (m_selectedVisibleFilter.matches(newLocation) != m_selectedVisibleFilter.matches(oldLocation)) || (oldLocation.getStatus() != newLocation.getStatus())) {
                m_view.updateLocationList(getLocationsForLocationPanel());
            }
            m_eventBus.fireEvent(new LocationsUpdatedEvent());
        }
    }
}
Also used : LocationsUpdatedEvent(org.opennms.features.poller.remote.gwt.client.events.LocationsUpdatedEvent) LocationInfo(org.opennms.features.poller.remote.gwt.client.location.LocationInfo)

Example 9 with LocationInfo

use of org.opennms.features.poller.remote.gwt.client.location.LocationInfo in project opennms by OpenNMS.

the class DefaultLocationManager method getLocationsForLocationPanel.

/**
 * TODO: Figure out if this public function is necessary or if we can get
 * by just responding to incoming events.
 *
 * @return a {@link java.util.ArrayList} object.
 */
public List<LocationInfo> getLocationsForLocationPanel() {
    // Use an ArrayList so that it has good random-access efficiency
    // since the pageable lists use get() to fetch based on index.
    final List<LocationInfo> visibleLocations = m_dataManager.getMatchingLocations(m_selectedVisibleFilter);
    GWTBounds mapBounds = m_view.getMapBounds();
    final ArrayList<LocationInfo> inBounds = new ArrayList<>();
    for (final LocationInfo location : visibleLocations) {
        final GWTMarkerState markerState = location.getMarkerState();
        if (markerState.isWithinBounds(mapBounds)) {
            inBounds.add(location);
        }
    }
    // TODO: this should use the current filter set eventually, for now
    // sort by priority, then name
    // for now, LocationInfo is Comparable and has a natural sort ordering
    // based on status, priority, and name
    Collections.sort(inBounds, new Comparator<LocationInfo>() {

        @Override
        public int compare(LocationInfo o1, LocationInfo o2) {
            return o1.compareTo(o2);
        }
    });
    return inBounds;
}
Also used : ArrayList(java.util.ArrayList) LocationInfo(org.opennms.features.poller.remote.gwt.client.location.LocationInfo)

Example 10 with LocationInfo

use of org.opennms.features.poller.remote.gwt.client.location.LocationInfo in project opennms by OpenNMS.

the class PageableLocationList method onItemClickHandler.

/**
 * {@inheritDoc}
 */
@Override
public void onItemClickHandler(final ClickEvent event) {
    final Cell cell = getCellForEvent(event);
    LocationInfo location = m_locations.get(cell.getRowIndex() + (getCurrentPageIndex() * getTotalListItemsPerPage()));
    fireEvent(new LocationPanelSelectEvent(location.getName()));
}
Also used : LocationPanelSelectEvent(org.opennms.features.poller.remote.gwt.client.events.LocationPanelSelectEvent) Cell(com.google.gwt.user.client.ui.HTMLTable.Cell) LocationInfo(org.opennms.features.poller.remote.gwt.client.location.LocationInfo)

Aggregations

LocationInfo (org.opennms.features.poller.remote.gwt.client.location.LocationInfo)18 Test (org.junit.Test)5 LocationUpdatedRemoteEvent (org.opennms.features.poller.remote.gwt.client.remoteevents.LocationUpdatedRemoteEvent)5 ArrayList (java.util.ArrayList)4 ApplicationUpdatedRemoteEvent (org.opennms.features.poller.remote.gwt.client.remoteevents.ApplicationUpdatedRemoteEvent)4 HashSet (java.util.HashSet)3 LocationsUpdatedRemoteEvent (org.opennms.features.poller.remote.gwt.client.remoteevents.LocationsUpdatedRemoteEvent)3 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 ApplicationInfo (org.opennms.features.poller.remote.gwt.client.ApplicationInfo)2 UpdateCompleteRemoteEvent (org.opennms.features.poller.remote.gwt.client.remoteevents.UpdateCompleteRemoteEvent)2 OnmsMonitoringLocation (org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation)2 Transactional (org.springframework.transaction.annotation.Transactional)2 Cell (com.google.gwt.user.client.ui.HTMLTable.Cell)1 Date (java.util.Date)1 Map (java.util.Map)1 TreeSet (java.util.TreeSet)1 GWTLatLng (org.opennms.features.poller.remote.gwt.client.GWTLatLng)1 GWTMarkerState (org.opennms.features.poller.remote.gwt.client.GWTMarkerState)1 StatusDetails (org.opennms.features.poller.remote.gwt.client.StatusDetails)1