Skip to content

Package: DeviceEventImpl

DeviceEventImpl

nameinstructionbranchcomplexitylinemethod
DeviceEventImpl()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
DeviceEventImpl(DeviceEvent)
M: 36 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 10 C: 0
0%
M: 1 C: 0
0%
DeviceEventImpl(KapuaId)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
getAction()
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getDeviceId()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getEventMessage()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getPosition()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getReceivedOn()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getResource()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getResponseCode()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getSentOn()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
setAction(KapuaMethod)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
setDeviceId(KapuaId)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
setEventMessage(String)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
setPosition(KapuaPosition)
M: 57 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 13 C: 0
0%
M: 1 C: 0
0%
setReceivedOn(Date)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
setResource(String)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
setResponseCode(KapuaResponseCode)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
setSentOn(Date)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2016, 2022 Eurotech and/or its affiliates and others
3: *
4: * This program and the accompanying materials are made
5: * available under the terms of the Eclipse Public License 2.0
6: * which is available at https://www.eclipse.org/legal/epl-2.0/
7: *
8: * SPDX-License-Identifier: EPL-2.0
9: *
10: * Contributors:
11: * Eurotech - initial API and implementation
12: *******************************************************************************/
13: package org.eclipse.kapua.service.device.registry.event.internal;
14:
15: import org.eclipse.kapua.commons.model.AbstractKapuaEntity;
16: import org.eclipse.kapua.commons.model.id.KapuaEid;
17: import org.eclipse.kapua.message.KapuaPosition;
18: import org.eclipse.kapua.message.internal.KapuaPositionImpl;
19: import org.eclipse.kapua.model.id.KapuaId;
20: import org.eclipse.kapua.service.device.management.message.KapuaMethod;
21: import org.eclipse.kapua.service.device.management.message.response.KapuaResponseCode;
22: import org.eclipse.kapua.service.device.registry.event.DeviceEvent;
23:
24: import javax.persistence.AttributeOverride;
25: import javax.persistence.AttributeOverrides;
26: import javax.persistence.Basic;
27: import javax.persistence.Column;
28: import javax.persistence.Embedded;
29: import javax.persistence.Entity;
30: import javax.persistence.EnumType;
31: import javax.persistence.Enumerated;
32: import javax.persistence.Lob;
33: import javax.persistence.Table;
34: import javax.persistence.Temporal;
35: import javax.persistence.TemporalType;
36: import java.util.Date;
37:
38: /**
39: * {@link DeviceEvent} implementation.
40: *
41: * @since 1.0.0
42: */
43: @Entity(name = "DeviceEvent")
44: @Table(name = "dvc_device_event")
45: public class DeviceEventImpl extends AbstractKapuaEntity implements DeviceEvent {
46:
47: private static final long serialVersionUID = 7142819355352738950L;
48:
49: @Embedded
50: @AttributeOverrides({
51: @AttributeOverride(name = "eid", column = @Column(name = "device_id", nullable = false, updatable = false))
52: })
53: private KapuaEid deviceId;
54:
55: @Temporal(TemporalType.TIMESTAMP)
56: @Column(name = "received_on", updatable = false, nullable = false)
57: private Date receivedOn;
58:
59: @Temporal(TemporalType.TIMESTAMP)
60: @Column(name = "sent_on", updatable = false)
61: private Date sentOn;
62:
63: @Embedded
64: @AttributeOverrides({
65: @AttributeOverride(name = "longitude", column = @Column(name = "pos_longitude", updatable = false)),
66: @AttributeOverride(name = "latitude", column = @Column(name = "pos_latitude", updatable = false)),
67: @AttributeOverride(name = "altitude", column = @Column(name = "pos_altitude", updatable = false)),
68: @AttributeOverride(name = "precision", column = @Column(name = "pos_precision", updatable = false)),
69: @AttributeOverride(name = "heading", column = @Column(name = "pos_heading", updatable = false)),
70: @AttributeOverride(name = "speed", column = @Column(name = "pos_speed", updatable = false)),
71: @AttributeOverride(name = "timestamp", column = @Column(name = "pos_timestamp", updatable = false)),
72: @AttributeOverride(name = "satellites", column = @Column(name = "pos_satellites", updatable = false)),
73: @AttributeOverride(name = "status", column = @Column(name = "pos_status", updatable = false))
74: })
75: private KapuaPositionImpl position;
76:
77: @Basic
78: @Column(name = "resource", updatable = false, nullable = false)
79: private String resource;
80:
81: @Enumerated(EnumType.STRING)
82: @Column(name = "action", updatable = false, nullable = false)
83: private KapuaMethod action;
84:
85: @Enumerated(EnumType.STRING)
86: @Column(name = "response_code", updatable = false, nullable = false)
87: private KapuaResponseCode responseCode;
88:
89: @Lob
90: @Column(name = "event_message", updatable = false, nullable = false)
91: private String eventMessage;
92:
93: /**
94: * Constructor
95: *
96: * @since 1.0.0
97: */
98: protected DeviceEventImpl() {
99: super();
100: }
101:
102: /**
103: * Constructor
104: *
105: * @param scopeId The scope {@link KapuaId} to set into the {@link DeviceEvent}
106: * @since 1.0.0
107: */
108: public DeviceEventImpl(KapuaId scopeId) {
109: super(scopeId);
110: }
111:
112: /**
113: * Clone constructor.
114: *
115: * @param deviceEvent
116: * @since 1.0.0
117: */
118: public DeviceEventImpl(DeviceEvent deviceEvent) {
119: super(deviceEvent);
120:
121: setDeviceId(deviceEvent.getDeviceId());
122: setReceivedOn(deviceEvent.getReceivedOn());
123: setSentOn(deviceEvent.getSentOn());
124: setPosition(deviceEvent.getPosition());
125: setResource(deviceEvent.getResource());
126: setAction(deviceEvent.getAction());
127: setResponseCode(deviceEvent.getResponseCode());
128: setEventMessage(deviceEvent.getEventMessage());
129: }
130:
131: @Override
132: public KapuaId getDeviceId() {
133: return deviceId;
134: }
135:
136: @Override
137: public void setDeviceId(KapuaId deviceId) {
138: this.deviceId = KapuaEid.parseKapuaId(deviceId);
139: }
140:
141: @Override
142: public Date getSentOn() {
143: return sentOn;
144: }
145:
146: @Override
147: public void setSentOn(Date sentOn) {
148: this.sentOn = sentOn;
149: }
150:
151: @Override
152: public Date getReceivedOn() {
153: return receivedOn;
154: }
155:
156: @Override
157: public void setReceivedOn(Date receivedOn) {
158: this.receivedOn = receivedOn;
159: }
160:
161: @Override
162: public KapuaPosition getPosition() {
163: return position;
164: }
165:
166: @Override
167: public void setPosition(KapuaPosition position) {
168:• if (position != null) {
169: this.position = new KapuaPositionImpl();
170:
171: this.position.setAltitude(position.getAltitude());
172: this.position.setHeading(position.getHeading());
173: this.position.setLatitude(position.getLatitude());
174: this.position.setLongitude(position.getLongitude());
175: this.position.setPrecision(position.getPrecision());
176: this.position.setSatellites(position.getSatellites());
177: this.position.setSpeed(position.getSpeed());
178: this.position.setStatus(position.getStatus());
179: this.position.setTimestamp(position.getTimestamp());
180: } else {
181: this.position = null;
182: }
183: }
184:
185: @Override
186: public String getResource() {
187: return resource;
188: }
189:
190: @Override
191: public void setResource(String resource) {
192: this.resource = resource;
193: }
194:
195: @Override
196: public KapuaMethod getAction() {
197: return action.normalizeAction();
198: }
199:
200: @Override
201: public void setAction(KapuaMethod action) {
202: this.action = action.normalizeAction();
203: }
204:
205: @Override
206: public KapuaResponseCode getResponseCode() {
207: return responseCode;
208: }
209:
210: @Override
211: public void setResponseCode(KapuaResponseCode responseCode) {
212: this.responseCode = responseCode;
213: }
214:
215: @Override
216: public String getEventMessage() {
217: return eventMessage;
218: }
219:
220: @Override
221: public void setEventMessage(String eventMessage) {
222: this.eventMessage = eventMessage;
223: }
224:
225: }