Skip to content

Package: DeviceManagementOperationImpl

DeviceManagementOperationImpl

nameinstructionbranchcomplexitylinemethod
DeviceManagementOperationImpl()
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%
DeviceManagementOperationImpl(DeviceManagementOperation)
M: 40 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 11 C: 0
0%
M: 1 C: 0
0%
DeviceManagementOperationImpl(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%
getAppId()
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%
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%
getEndedOn()
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%
getInputProperties()
M: 11 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
getLog()
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%
getOperationId()
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%
getStartedOn()
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%
getStatus()
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%
setAppId(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%
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%
setEndedOn(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%
setInputProperties(List)
M: 25 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 6 C: 0
0%
M: 1 C: 0
0%
setLog(String)
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%
setOperationId(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%
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%
setStartedOn(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%
setStatus(NotifyStatus)
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) 2017, 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.management.registry.operation.internal;
14:
15: import com.google.common.base.Strings;
16: import org.eclipse.kapua.KapuaException;
17: import org.eclipse.kapua.commons.model.AbstractKapuaUpdatableEntity;
18: import org.eclipse.kapua.commons.model.id.KapuaEid;
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.notification.NotifyStatus;
22: import org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperation;
23: import org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperationProperty;
24:
25: import javax.persistence.AttributeOverride;
26: import javax.persistence.AttributeOverrides;
27: import javax.persistence.Basic;
28: import javax.persistence.CollectionTable;
29: import javax.persistence.Column;
30: import javax.persistence.ElementCollection;
31: import javax.persistence.Embedded;
32: import javax.persistence.Entity;
33: import javax.persistence.EnumType;
34: import javax.persistence.Enumerated;
35: import javax.persistence.JoinColumn;
36: import javax.persistence.Table;
37: import javax.persistence.Temporal;
38: import javax.persistence.TemporalType;
39: import java.util.ArrayList;
40: import java.util.Date;
41: import java.util.List;
42:
43: @Entity(name = "DeviceManagementOperation")
44: @Table(name = "dvcm_device_management_operation")
45: public class DeviceManagementOperationImpl extends AbstractKapuaUpdatableEntity implements DeviceManagementOperation {
46:
47: @Temporal(TemporalType.TIMESTAMP)
48: @Column(name = "started_on", nullable = false, updatable = false)
49: private Date startedOn;
50:
51: @Temporal(TemporalType.TIMESTAMP)
52: @Column(name = "ended_on")
53: private Date endedOn;
54:
55: @Embedded
56: @AttributeOverrides({
57: @AttributeOverride(name = "eid", column = @Column(name = "device_id", nullable = false, updatable = false))
58: })
59: private KapuaEid deviceId;
60:
61: @Embedded
62: @AttributeOverrides({
63: @AttributeOverride(name = "eid", column = @Column(name = "operation_id", nullable = false, updatable = false))
64: })
65: private KapuaEid operationId;
66:
67: @Basic
68: @Column(name = "app_id", nullable = false, updatable = false)
69: private String appId;
70:
71: @Enumerated(EnumType.STRING)
72: @Column(name = "action", nullable = false, updatable = false)
73: private KapuaMethod action;
74:
75: @Basic
76: @Column(name = "resource", nullable = false, updatable = false)
77: private String resource;
78:
79: @Enumerated(EnumType.STRING)
80: @Column(name = "status", nullable = false, updatable = true)
81: private NotifyStatus status;
82:
83: @ElementCollection
84: @CollectionTable(name = "dvcm_device_management_operation_input_property", joinColumns = @JoinColumn(name = "operation_id", referencedColumnName = "id"))
85: private List<DeviceManagementOperationPropertyImpl> inputProperties;
86:
87: @Basic
88: @Column(name = "log", nullable = true, updatable = true)
89: private String log;
90:
91: /**
92: * Constructor.
93: *
94: * @since 1.0.0
95: */
96: protected DeviceManagementOperationImpl() {
97: super();
98: }
99:
100: /**
101: * Constructor.
102: *
103: * @param scopeId
104: * @since 1.0.0
105: */
106: public DeviceManagementOperationImpl(KapuaId scopeId) {
107: super(scopeId);
108: }
109:
110: /**
111: * Clone constructor.
112: *
113: * @param deviceManagementOperation
114: * @throws KapuaException
115: * @since 1.1.0
116: */
117: public DeviceManagementOperationImpl(DeviceManagementOperation deviceManagementOperation) throws KapuaException {
118: super(deviceManagementOperation);
119:
120: setStartedOn(deviceManagementOperation.getStartedOn());
121: setEndedOn(deviceManagementOperation.getEndedOn());
122: setDeviceId(deviceManagementOperation.getDeviceId());
123: setOperationId(deviceManagementOperation.getOperationId());
124: setAppId(deviceManagementOperation.getAppId());
125: setAction(deviceManagementOperation.getAction());
126: setResource(deviceManagementOperation.getResource());
127: setStatus(deviceManagementOperation.getStatus());
128: setInputProperties(deviceManagementOperation.getInputProperties());
129: }
130:
131: @Override
132: public Date getStartedOn() {
133: return startedOn;
134: }
135:
136: @Override
137: public void setStartedOn(Date startedOn) {
138: this.startedOn = startedOn;
139: }
140:
141: @Override
142: public Date getEndedOn() {
143: return endedOn;
144: }
145:
146: @Override
147: public void setEndedOn(Date endedOn) {
148: this.endedOn = endedOn;
149: }
150:
151: @Override
152: public KapuaId getDeviceId() {
153: return deviceId;
154: }
155:
156: @Override
157: public void setDeviceId(KapuaId deviceId) {
158: this.deviceId = KapuaEid.parseKapuaId(deviceId);
159: }
160:
161: @Override
162: public KapuaId getOperationId() {
163: return operationId;
164: }
165:
166: @Override
167: public void setOperationId(KapuaId operationId) {
168: this.operationId = KapuaEid.parseKapuaId(operationId);
169: }
170:
171: @Override
172: public String getAppId() {
173: return appId;
174: }
175:
176: @Override
177: public void setAppId(String appId) {
178: this.appId = appId;
179: }
180:
181: @Override
182: public KapuaMethod getAction() {
183: return action.normalizeAction();
184: }
185:
186: @Override
187: public void setAction(KapuaMethod action) {
188: this.action = action.normalizeAction();
189: }
190:
191: @Override
192: public String getResource() {
193: return resource;
194: }
195:
196: @Override
197: public void setResource(String resource) {
198: this.resource = resource;
199: }
200:
201: @Override
202: public NotifyStatus getStatus() {
203: return status;
204: }
205:
206: @Override
207: public void setStatus(NotifyStatus status) {
208: this.status = status;
209: }
210:
211: @Override
212: public List<DeviceManagementOperationPropertyImpl> getInputProperties() {
213:• if (inputProperties == null) {
214: inputProperties = new ArrayList<>();
215: }
216:
217: return inputProperties;
218: }
219:
220: @Override
221: public void setInputProperties(List<DeviceManagementOperationProperty> inputProperties) {
222: this.inputProperties = new ArrayList<>();
223:• if (inputProperties != null) {
224:• for (DeviceManagementOperationProperty sp : inputProperties) {
225: this.inputProperties.add(DeviceManagementOperationPropertyImpl.parse(sp));
226: }
227: }
228: }
229:
230: @Override
231: public String getLog() {
232: // Setting to empty if null to avoid checking for null and empty when using this value.
233: return Strings.nullToEmpty(log);
234: }
235:
236: @Override
237: public void setLog(String log) {
238: // Setting to null to avoid storing empty string in database
239: this.log = Strings.emptyToNull(log);
240: }
241: }