Skip to content

Package: ServiceConfigImpl

ServiceConfigImpl

nameinstructionbranchcomplexitylinemethod
ServiceConfigImpl()
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%
ServiceConfigImpl(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%
getConfigurations()
M: 8 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
getPid()
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%
setConfigurations(Properties)
M: 10 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
setPid(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%

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.commons.configuration;
14:
15: import org.eclipse.kapua.KapuaException;
16: import org.eclipse.kapua.commons.model.AbstractKapuaUpdatableEntity;
17: import org.eclipse.kapua.commons.util.PropertiesUtils;
18: import org.eclipse.kapua.model.id.KapuaId;
19:
20: import javax.persistence.Basic;
21: import javax.persistence.Column;
22: import javax.persistence.Entity;
23: import javax.persistence.Table;
24: import javax.xml.bind.annotation.XmlAccessType;
25: import javax.xml.bind.annotation.XmlAccessorType;
26: import javax.xml.bind.annotation.XmlElement;
27: import javax.xml.bind.annotation.XmlRootElement;
28: import javax.xml.bind.annotation.XmlTransient;
29: import javax.xml.bind.annotation.XmlType;
30: import java.io.IOException;
31: import java.util.Properties;
32:
33: @XmlRootElement
34: @XmlAccessorType(XmlAccessType.FIELD)
35: @XmlType(propOrder = {"pid", "configurations"})
36: @Entity(name = "ServiceConfig")
37: @Table(name = "sys_configuration")
38: /**
39: * {@link ServiceConfig} implementation.
40: *
41: * @since 1.0.0
42: */
43: public class ServiceConfigImpl extends AbstractKapuaUpdatableEntity implements ServiceConfig {
44:
45: private static final long serialVersionUID = 8699765898092343484L;
46:
47: @XmlElement(name = "pid")
48: @Basic
49: @Column(name = "pid")
50: private String pid;
51:
52: @XmlTransient
53: @Basic
54: @Column(name = "configurations")
55: protected String configurations;
56:
57: /**
58: * Constructor.
59: *
60: * @since 1.0.0
61: */
62: public ServiceConfigImpl() {
63: super();
64: }
65:
66: /**
67: * Constructor.
68: *
69: * @param scopeId The scope {@link KapuaId} to set into the {@link ServiceConfig}
70: * @since 1.0.0
71: */
72: public ServiceConfigImpl(KapuaId scopeId) {
73: super(scopeId);
74: }
75:
76: @Override
77: public String getPid() {
78: return pid;
79: }
80:
81: @Override
82: public void setPid(String pid) {
83: this.pid = pid;
84: }
85:
86: @Override
87: public Properties getConfigurations() throws KapuaException {
88: try {
89: return PropertiesUtils.readPropertiesFromString(configurations);
90: } catch (IOException e) {
91: throw KapuaException.internalError(e);
92: }
93: }
94:
95: @Override
96: public void setConfigurations(Properties properties) throws KapuaException {
97: try {
98: configurations = PropertiesUtils.writePropertiesToString(properties);
99: } catch (IOException e) {
100: throw KapuaException.internalError(e);
101: }
102: }
103: }