12374a619383ebbaa4812bb58563ea86380dd2f8
[public/netxms.git] / src / java / client / netxms-client / src / main / java / org / netxms / client / maps / configs / SingleDciConfig.java
1 /**
2 * NetXMS - open source network management system
3 * Copyright (C) 2003-2013 Victor Kirhenshtein
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19 package org.netxms.client.maps.configs;
20
21 import org.netxms.client.datacollection.DataCollectionObject;
22 import org.netxms.client.datacollection.DciValue;
23 import org.simpleframework.xml.Attribute;
24 import org.simpleframework.xml.Element;
25 import org.simpleframework.xml.Root;
26
27 /**
28 * DCI information for map line
29 */
30 @Root(name="dci")
31 public class SingleDciConfig
32 {
33 public static final int ITEM = DataCollectionObject.DCO_TYPE_ITEM;
34 public static final int TABLE = DataCollectionObject.DCO_TYPE_TABLE;
35
36 @Attribute
37 public long nodeId;
38
39 @Attribute
40 public long dciId;
41
42 @Element(required=false)
43 public int type;
44
45 @Element(required=false)
46 public String name;
47
48 @Element(required=false)
49 public String instance;
50
51 @Element(required=false)
52 public String column;
53
54 @Element(required=false)
55 public String formatString;
56
57
58 /**
59 * Default constructor
60 */
61 public SingleDciConfig()
62 {
63 nodeId = 0;
64 dciId = 0;
65 setType(ITEM);
66 name = ""; //$NON-NLS-1$
67 setInstance(""); //$NON-NLS-1$
68 setColumn(""); //$NON-NLS-1$
69 setFormatString("");//$NON-NLS-1$
70 }
71
72 /**
73 * Copy constructor
74 *
75 * @param src source object
76 */
77 public SingleDciConfig(SingleDciConfig src)
78 {
79 this.nodeId = src.nodeId;
80 this.dciId = src.dciId;
81 this.setType(src.getType());
82 this.name = src.name;
83 this.formatString = src.formatString;
84 this.setInstance(src.getInstance());
85 this.setColumn(src.getColumn());
86 }
87
88 /**
89 * Create DCI info from DciValue object
90 *
91 * @param dci
92 */
93 public SingleDciConfig(DciValue dci)
94 {
95 nodeId = dci.getNodeId();
96 dciId = dci.getId();
97 setType(dci.getDcObjectType());
98 name = dci.getDescription();
99 formatString = "";
100 setInstance(""); //$NON-NLS-1$
101 setColumn(""); //$NON-NLS-1$
102 }
103
104 /**
105 * Get DCI name. Always returns non-empty string.
106 * @return
107 */
108 public String getName()
109 {
110 return ((name != null) && !name.isEmpty()) ? name : ("[" + Long.toString(dciId) + "]"); //$NON-NLS-1$ //$NON-NLS-2$
111 }
112
113 /**
114 * @return the formatString
115 */
116 public String getFormatString()
117 {
118 return formatString == null ? "" : formatString;
119 }
120
121 /**
122 * @param formatString the formatString to set
123 */
124 public void setFormatString(String formatString)
125 {
126 this.formatString = formatString;
127 }
128
129 /**
130 * @return the instance
131 */
132 public String getInstance()
133 {
134 return instance;
135 }
136
137 /**
138 * @param instance the instance to set
139 */
140 public void setInstance(String instance)
141 {
142 this.instance = instance;
143 }
144
145 /**
146 * @return the column
147 */
148 public String getColumn()
149 {
150 return column;
151 }
152
153 /**
154 * @param column the column to set
155 */
156 public void setColumn(String column)
157 {
158 this.column = column;
159 }
160
161 /**
162 * @return the nodeId
163 */
164 public long getNodeId()
165 {
166 return nodeId;
167 }
168
169 /**
170 * @param nodeId the nodeId to set
171 */
172 public void setNodeId(long nodeId)
173 {
174 this.nodeId = nodeId;
175 }
176
177 /**
178 * @return the dciId
179 */
180 public long getDciId()
181 {
182 return dciId;
183 }
184
185 /**
186 * @param dciId the dciId to set
187 */
188 public void setDciId(long dciId)
189 {
190 this.dciId = dciId;
191 }
192
193 /**
194 * @param name the name to set
195 */
196 public void setName(String name)
197 {
198 this.name = name;
199 }
200
201 /**
202 * @return the type
203 */
204 public int getType()
205 {
206 return type;
207 }
208
209 /**
210 * @param type the type to set
211 */
212 public void setType(int type)
213 {
214 this.type = type;
215 }
216 }