2 * NetXMS - open source network management system
3 * Copyright (C) 2003-2013 Victor Kirhenshtein
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.
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.
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.
19 package org
.netxms
.client
.datacollection
;
21 import java
.util
.ArrayList
;
22 import java
.util
.List
;
23 import java
.util
.UUID
;
24 import org
.netxms
.base
.NXCPCodes
;
25 import org
.netxms
.base
.NXCPMessage
;
30 public class DciSummaryTable
32 public static final int SUMMARY_TABLE_TABLE_VALUE
= 0x0002;
36 private String menuPath
;
39 private String nodeFilter
;
40 private List
<DciSummaryTableColumn
> columns
;
41 private String tableDciName
;
44 * Create new empty summary table object
46 * @param menuPath The menu path
47 * @param title The title
48 * @param isSingleValue if table is single value DCI
50 public DciSummaryTable(String menuPath
, String title
, boolean isSingleValue
)
53 guid
= UUID
.randomUUID();
54 this.menuPath
= menuPath
;
56 flags
= isSingleValue ?
0 : SUMMARY_TABLE_TABLE_VALUE
;
58 columns
= new ArrayList
<DciSummaryTableColumn
>();
63 * Create full object from NXCP message.
65 * @param msg message with object from the server
67 public DciSummaryTable(NXCPMessage msg
)
69 id
= msg
.getFieldAsInt32(NXCPCodes
.VID_SUMMARY_TABLE_ID
);
70 guid
= msg
.getFieldAsUUID(NXCPCodes
.VID_GUID
);
71 menuPath
= msg
.getFieldAsString(NXCPCodes
.VID_MENU_PATH
);
72 title
= msg
.getFieldAsString(NXCPCodes
.VID_TITLE
);
73 flags
= msg
.getFieldAsInt32(NXCPCodes
.VID_FLAGS
);
74 nodeFilter
= msg
.getFieldAsString(NXCPCodes
.VID_FILTER
);
75 tableDciName
= msg
.getFieldAsString(NXCPCodes
.VID_DCI_NAME
);
77 String s
= msg
.getFieldAsString(NXCPCodes
.VID_COLUMNS
);
78 if ((s
!= null
) && (s
.length() > 0))
80 String
[] parts
= s
.split("\\^\\~\\^");
81 columns
= new ArrayList
<DciSummaryTableColumn
>(parts
.length
);
82 for(int i
= 0; i
< parts
.length
; i
++)
84 String
[] data
= parts
[i
].split("\\^\\#\\^");
87 columns
.add(new DciSummaryTableColumn(data
[0], data
[1], 0, ";"));
89 else if (data
.length
>= 3)
94 flags
= Integer
.parseInt(data
[2]);
96 catch(NumberFormatException e
)
100 columns
.add(new DciSummaryTableColumn(data
[0], data
[1], flags
, (data
.length
> 3) ? data
[3] : ";"));
106 columns
= new ArrayList
<DciSummaryTableColumn
>(0);
111 * Fill NXCP message with object data
113 * @param msg NXCP message
115 public void fillMessage(NXCPMessage msg
)
117 msg
.setFieldInt32(NXCPCodes
.VID_SUMMARY_TABLE_ID
, id
);
118 msg
.setField(NXCPCodes
.VID_GUID
, guid
);
119 msg
.setField(NXCPCodes
.VID_MENU_PATH
, menuPath
);
120 msg
.setField(NXCPCodes
.VID_TITLE
, title
);
121 msg
.setFieldInt32(NXCPCodes
.VID_FLAGS
, flags
);
122 msg
.setField(NXCPCodes
.VID_FILTER
, nodeFilter
);
123 msg
.setField(NXCPCodes
.VID_DCI_NAME
, tableDciName
);
125 StringBuilder sb
= new StringBuilder();
126 for(DciSummaryTableColumn c
: columns
)
130 sb
.append(c
.getName());
132 sb
.append(c
.getDciName());
134 sb
.append(c
.getFlags());
136 sb
.append(c
.getSeparator());
138 msg
.setField(NXCPCodes
.VID_COLUMNS
, sb
.toString());
150 * @param id the id to set
152 public void setId(int id
)
160 public UUID
getGuid()
166 * @return the menuPath
168 public String
getMenuPath()
174 * @param menuPath the menuPath to set
176 public void setMenuPath(String menuPath
)
178 this.menuPath
= menuPath
;
184 public String
getTitle()
190 * @param title the title to set
192 public void setTitle(String title
)
200 public int getFlags()
206 * @param flags the flags to set
208 public void setFlags(int flags
)
214 * @return the nodeFilter
216 public String
getNodeFilter()
222 * @param nodeFilter the nodeFilter to set
224 public void setNodeFilter(String nodeFilter
)
226 this.nodeFilter
= nodeFilter
;
230 * @return the columns
232 public List
<DciSummaryTableColumn
> getColumns()
238 * Check if table is single value or table value
240 * @return true if single value
242 public boolean isSingleValue()
244 return (flags
& SUMMARY_TABLE_TABLE_VALUE
) > 0 ? false
: true
;
248 * Return table dci name
249 * @return table dci name if set
251 public String
getTableDciName()
258 * @param name of table DCI
260 public void setTableDciName(String name
)