Package com.qfs.snl.dtos
Class EventDto
java.lang.Object
com.qfs.snl.dtos.EventDto
- All Implemented Interfaces:
ISentinelEvent,ILocatedResource,ISiteLocated,IIdentifiable,Serializable
The data transfer object for an event.
- Author:
- ActiveViam
- See Also:
-
Field Summary
Fields inherited from interface com.qfs.snl.persistence.IIdentifiable
NO_ID -
Constructor Summary
ConstructorsConstructorDescriptionEventDto()Constructor.EventDto(long id, String site, long monitorId, Map<String, String> updatedResource, long timestamp, Double previousStatus, Double status, List<StateDto> states) Full constructor.EventDto(long monitorId, String site, Map<String, String> updatedResource, long timestamp, Double previousStatus, Double status, List<StateDto> states) Constructor for unpersisted event.EventDto(ISentinelEvent event) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSentinelState(String stateId, String caption, Double value, String formattedValue) Adds a state to the event.static booleanequals(ISentinelEvent event, Object obj) Tests the equality between a ISentinelEvent and an object.booleanlonggetId()Gets the resource id.longReturn the id of the monitor that produced the event.Return the previous status of this event If null it means that the state has started.getSite()Gets the site where the element is located.List<? extends ISentinelState> Gets the state of the event.Return the status of this event If null it means that the state has ended.longReturn the timestamp in milliseconds when the action occurred.Gets a string representation of the updated resource.inthashCode()static inthashCode(ISentinelEvent event) Compute the hashcode of the given ISentinelEvent.voidsetId(long id) Sets the event unique id.voidsetMonitorId(long monitorId) Sets the id of the underlying monitor.voidsetPreviousStatus(Double previousStatus) Sets the previous state of the event.voidSets the agent site.voidSets the list of states reported through this event.voidSets the current status.voidsetTimestamp(long timestamp) Sets the time of this event.voidsetUpdatedResource(Map<String, String> updatedResource) Sets the list of data that are reported as updated through this event.toString()static StringtoString(ISentinelEvent event) Generates String representation of the given ISentinelEvent.
-
Constructor Details
-
EventDto
public EventDto(long monitorId, String site, Map<String, String> updatedResource, long timestamp, Double previousStatus, Double status, List<StateDto> states) Constructor for unpersisted event.This does not include the event id since it is not yet defined.
- Parameters:
monitorId- id of the related monitorsite- the site where the event livesupdatedResource- the concerned resourcetimestamp- datetime (in ms) of the eventpreviousStatus- the preivous current monitoring statusstatus- current monitoring statusstates- states of the monitoring at the time of the timestamp
-
EventDto
public EventDto(long id, String site, long monitorId, Map<String, String> updatedResource, long timestamp, Double previousStatus, Double status, List<StateDto> states) Full constructor.- Parameters:
id- unique id of the eventsite- the site where the event livesmonitorId- id of the related monitorupdatedResource- the concerned resourcetimestamp- datetime (in ms) of the eventpreviousStatus- the preivous current monitoring statusstatus- current monitoring statusstates- states of the monitoring at the time of the timestamp
-
EventDto
Constructor.- Parameters:
event- ISentinelEvent used to generate this Dto.
-
EventDto
public EventDto()Constructor.
-
-
Method Details
-
getId
public long getId()Description copied from interface:IIdentifiableGets the resource id.- Specified by:
getIdin interfaceIIdentifiable- Returns:
- the id
-
setId
public void setId(long id) Sets the event unique id. -
getSite
Description copied from interface:ISiteLocatedGets the site where the element is located.- Specified by:
getSitein interfaceISiteLocated- Returns:
- the site
-
setSite
Sets the agent site. -
getMonitorId
public long getMonitorId()Description copied from interface:ISentinelEventReturn the id of the monitor that produced the event.- Specified by:
getMonitorIdin interfaceISentinelEvent- Returns:
- the id of the monitor
-
setMonitorId
public void setMonitorId(long monitorId) Sets the id of the underlying monitor. -
getUpdatedResource
Description copied from interface:ISentinelEventGets a string representation of the updated resource.This does support a null value. It will be considered as a valid representation, meaning that all event with a null resource are considered as updates on the same resource.
- Specified by:
getUpdatedResourcein interfaceISentinelEvent- Returns:
- the updated resource
-
setUpdatedResource
Sets the list of data that are reported as updated through this event. -
getTimestamp
public long getTimestamp()Description copied from interface:ISentinelEventReturn the timestamp in milliseconds when the action occurred.- Specified by:
getTimestampin interfaceISentinelEvent- Returns:
- the timestamp in milliseconds
-
setTimestamp
public void setTimestamp(long timestamp) Sets the time of this event.- Parameters:
timestamp- date time in milliseconds
-
getPreviousStatus
Description copied from interface:ISentinelEventReturn the previous status of this event If null it means that the state has started.- Specified by:
getPreviousStatusin interfaceISentinelEvent- Returns:
- the previous status of the event
-
setPreviousStatus
Sets the previous state of the event. -
getStatus
Description copied from interface:ISentinelEventReturn the status of this event If null it means that the state has ended.- Specified by:
getStatusin interfaceISentinelEvent- Returns:
- the status of the event
-
setStatus
Sets the current status. -
getStates
Description copied from interface:ISentinelEventGets the state of the event.- Specified by:
getStatesin interfaceISentinelEvent- Returns:
- the list of states representing the event state
-
setStates
Sets the list of states reported through this event. -
addSentinelState
Adds a state to the event.- Parameters:
stateId- list of states unique idcaption- list of captionvalue- raw valueformattedValue- formatted value
-
hashCode
public int hashCode()Cache the hashcode for performance reasons, as this object is supposed to be immutable
-
hashCode
Compute the hashcode of the given ISentinelEvent.- Parameters:
event- an ActiveMonitor event- Returns:
- the hashcode for the given object
-
equals
-
equals
Tests the equality between a ISentinelEvent and an object.Two events are equals if they concern the same monitor (id + site) and the same resource, at the same time. They must represent the same transition resulting in the same states.
This is consistent for an append-only resource.- Parameters:
event- the reference eventobj- the object to test- Returns:
- true for equality
-
toString
-
toString
Generates String representation of the given ISentinelEvent.- Parameters:
event- ISentinelEvent to describe- Returns:
- string representation of the given event
-