Skip to content

Package: ChannelInfoField

ChannelInfoField

nameinstructionbranchcomplexitylinemethod
ChannelInfoField(String, int, String)
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%
field()
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%
getOrDeriveId(StorableId, ChannelInfo)
M: 9 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
getOrDeriveId(StorableId, ChannelInfoCreator)
M: 9 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
getOrDeriveId(StorableId, KapuaId, String, String)
M: 22 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
static {...}
M: 59 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 6 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.datastore.internal.mediator;
14:
15: import org.eclipse.kapua.model.id.KapuaId;
16: import org.eclipse.kapua.service.datastore.internal.schema.ChannelInfoSchema;
17: import org.eclipse.kapua.service.datastore.model.ChannelInfo;
18: import org.eclipse.kapua.service.datastore.model.ChannelInfoCreator;
19: import org.eclipse.kapua.service.storable.model.id.StorableId;
20: import org.eclipse.kapua.service.storable.model.query.StorableField;
21:
22: /**
23: * This enumeration defines the fields names used in the {@link ChannelInfo} client schema
24: *
25: * @since 1.0.0
26: */
27: public enum ChannelInfoField implements StorableField {
28: /**
29: * Channel
30: *
31: * @since 1.0.0
32: */
33: CHANNEL(ChannelInfoSchema.CHANNEL_NAME),
34:
35: /**
36: * Client identifier
37: *
38: * @since 1.0.0
39: */
40: CLIENT_ID(ChannelInfoSchema.CHANNEL_CLIENT_ID),
41:
42: /**
43: * Scope id
44: *
45: * @since 1.0.0
46: */
47: SCOPE_ID(ChannelInfoSchema.CHANNEL_SCOPE_ID),
48:
49: /**
50: * Timestamp
51: *
52: * @since 1.0.0
53: */
54: TIMESTAMP(ChannelInfoSchema.CHANNEL_TIMESTAMP),
55:
56: /**
57: * Message identifier
58: *
59: * @since 1.0.0
60: */
61: MESSAGE_ID(ChannelInfoSchema.CHANNEL_MESSAGE_ID);
62:
63: private String field;
64:
65: private ChannelInfoField(String name) {
66: this.field = name;
67: }
68:
69: @Override
70: public String field() {
71: return field;
72: }
73:
74: /**
75: * Get the channel identifier (combining accountName clientId and c).<br>
76: * <b>If the id is null then it is generated</b>
77: *
78: * @param id
79: * @param scopeId
80: * @param clientId
81: * @param channel
82: * @return
83: */
84: private static String getOrDeriveId(StorableId id, KapuaId scopeId, String clientId, String channel) {
85:• if (id == null) {
86: return DatastoreUtils.getHashCode(scopeId.toCompactId(), clientId, channel);
87: } else {
88: return id.toString();
89: }
90: }
91:
92: /**
93: * Get the channel identifier getting parameters from the metricInfoCreator. Then it calls {@link ChannelInfoField#getOrDeriveId(StorableId id, KapuaId scopeId, String clientId, String channel)}
94: *
95: * @param id
96: * @param channelInfoCreator
97: * @return
98: */
99: public static String getOrDeriveId(StorableId id, ChannelInfoCreator channelInfoCreator) {
100: return getOrDeriveId(id,
101: channelInfoCreator.getScopeId(),
102: channelInfoCreator.getClientId(),
103: channelInfoCreator.getName());
104: }
105:
106: /**
107: * Get the channel identifier getting parameters from the channelInfo. Then it calls {@link ChannelInfoField#getOrDeriveId(StorableId id, KapuaId scopeId, String clientId, String channel)}
108: *
109: * @param id
110: * @param channelInfo
111: * @return
112: */
113: public static String getOrDeriveId(StorableId id, ChannelInfo channelInfo) {
114: return getOrDeriveId(id,
115: channelInfo.getScopeId(),
116: channelInfo.getClientId(),
117: channelInfo.getName());
118: }
119:
120: }