f563001625f852a5dafbef1eb4d1ff0d12ec079c
[public/netxms.git] / src / java / netxms-client / src / main / java / org / netxms / client / objects / Condition.java
1 /**
2 * NetXMS - open source network management system
3 * Copyright (C) 2003-2010 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.objects;
20
21 import java.util.ArrayList;
22 import java.util.List;
23
24 import org.netxms.base.NXCPCodes;
25 import org.netxms.base.NXCPMessage;
26 import org.netxms.client.NXCSession;
27 import org.netxms.client.datacollection.ConditionDciInfo;
28
29 /**
30 * Condition object
31 *
32 */
33 public class Condition extends GenericObject
34 {
35 private String script;
36 private int activationEvent;
37 private int deactivationEvent;
38 private long eventSourceObject;
39 private int activeStatus;
40 private int inactiveStatus;
41 private List<ConditionDciInfo> dciList;
42
43 /**
44 * @param msg
45 * @param session
46 */
47 public Condition(NXCPMessage msg, NXCSession session)
48 {
49 super(msg, session);
50
51 script = msg.getVariableAsString(NXCPCodes.VID_SCRIPT);
52 activationEvent = msg.getVariableAsInteger(NXCPCodes.VID_ACTIVATION_EVENT);
53 deactivationEvent = msg.getVariableAsInteger(NXCPCodes.VID_DEACTIVATION_EVENT);
54 eventSourceObject = msg.getVariableAsInt64(NXCPCodes.VID_SOURCE_OBJECT);
55 activeStatus = msg.getVariableAsInteger(NXCPCodes.VID_ACTIVE_STATUS);
56 inactiveStatus = msg.getVariableAsInteger(NXCPCodes.VID_INACTIVE_STATUS);
57
58 int count = msg.getVariableAsInteger(NXCPCodes.VID_NUM_ITEMS);
59 dciList = new ArrayList<ConditionDciInfo>(count);
60
61 long varId = NXCPCodes.VID_DCI_LIST_BASE;
62 for(int i = 0; i < count; i++)
63 {
64 dciList.add(new ConditionDciInfo(msg, varId));
65 varId += 10;
66 }
67 }
68
69 /* (non-Javadoc)
70 * @see org.netxms.client.NXCObject#getObjectClassName()
71 */
72 @Override
73 public String getObjectClassName()
74 {
75 return "Condition";
76 }
77
78 /**
79 * @return the script
80 */
81 public String getScript()
82 {
83 return script;
84 }
85
86 /**
87 * @return the activationEvent
88 */
89 public int getActivationEvent()
90 {
91 return activationEvent;
92 }
93
94 /**
95 * @return the deactivationEvent
96 */
97 public int getDeactivationEvent()
98 {
99 return deactivationEvent;
100 }
101
102 /**
103 * @return the eventSourceObject
104 */
105 public long getEventSourceObject()
106 {
107 return eventSourceObject;
108 }
109
110 /**
111 * @return the activeStatus
112 */
113 public int getActiveStatus()
114 {
115 return activeStatus;
116 }
117
118 /**
119 * @return the inactiveStatus
120 */
121 public int getInactiveStatus()
122 {
123 return inactiveStatus;
124 }
125
126 /**
127 * @return the dciList
128 */
129 public List<ConditionDciInfo> getDciList()
130 {
131 return dciList;
132 }
133 }