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 TypeMethodDescriptionvoid
addSentinelState
(String stateId, String caption, Double value, String formattedValue) Adds a state to the event.static boolean
equals
(ISentinelEvent event, Object obj) Tests the equality between a ISentinelEvent and an object.boolean
long
getId()
Gets the resource id.long
Return 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.long
Return the timestamp in milliseconds when the action occurred.Gets a string representation of the updated resource.int
hashCode()
static int
hashCode
(ISentinelEvent event) Compute the hashcode of the given ISentinelEvent.void
setId
(long id) Sets the event unique id.void
setMonitorId
(long monitorId) Sets the id of the underlying monitor.void
setPreviousStatus
(Double previousStatus) Sets the previous state of the event.void
Sets the agent site.void
Sets the list of states reported through this event.void
Sets the current status.void
setTimestamp
(long timestamp) Sets the time of this event.void
setUpdatedResource
(Map<String, String> updatedResource) Sets the list of data that are reported as updated through this event.toString()
static String
toString
(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:IIdentifiable
Gets the resource id.- Specified by:
getId
in interfaceIIdentifiable
- Returns:
- the id
-
setId
public void setId(long id) Sets the event unique id. -
getSite
Description copied from interface:ISiteLocated
Gets the site where the element is located.- Specified by:
getSite
in interfaceISiteLocated
- Returns:
- the site
-
setSite
Sets the agent site. -
getMonitorId
public long getMonitorId()Description copied from interface:ISentinelEvent
Return the id of the monitor that produced the event.- Specified by:
getMonitorId
in 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:ISentinelEvent
Gets 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:
getUpdatedResource
in 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:ISentinelEvent
Return the timestamp in milliseconds when the action occurred.- Specified by:
getTimestamp
in 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:ISentinelEvent
Return the previous status of this event If null it means that the state has started.- Specified by:
getPreviousStatus
in interfaceISentinelEvent
- Returns:
- the previous status of the event
-
setPreviousStatus
Sets the previous state of the event. -
getStatus
Description copied from interface:ISentinelEvent
Return the status of this event If null it means that the state has ended.- Specified by:
getStatus
in interfaceISentinelEvent
- Returns:
- the status of the event
-
setStatus
Sets the current status. -
getStates
Description copied from interface:ISentinelEvent
Gets the state of the event.- Specified by:
getStates
in 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
-