2 * Copyright 2016-2017, CMCC Technologies Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 var AlarmConds = function () {
20 parseActiveConds2JSon: function (conds) {
21 return this.parseConds2JSon(conds, 1);
23 parseHistoryConds2JSon: function (conds) {
24 return this.parseConds2JSon(conds, 2);
29 * 每个条件都是一个对象,包含2个属性:type和data。type表示条件的类型,data是一个数组,每项都表示一个条件。
35 * locationId : 'lId1',
37 * isSelf : true //是否分组,true表示只包含自己,false表示分组
45 * severity : 1 //1表示严重,2表示主要,3表示次要,4表示警告
53 * ackState : 1 //1表示已确认,2表示未确认
59 * type : 'FilterState',
61 * filterState : 1 //1表示可见,0表示不可见
69 * alarmType : 1 //0表示通信告警,1表示处理错误告警,2表示服务质量告警,3表示设备告警,4表示环境告警,5表示网管系统告警,6表示完整性告警,7表示可用性告警,8表示物理攻击告警,9表示安全攻击告警,10表示时限告警
75 * type : 'ProbableCause',
84 * type : 'RaisedTime',
86 * mode : 0, //0表示区间,1表示最近
87 * start : 1399429229000, //mode为0时,表示开始时间,mode为1时,表示时间的毫秒值
88 * end : 1399515601000 //mode为0时,表示结束时间,mode为1时,表示时间的毫秒值
96 * mode : 0, //0表示区间,1表示最近
97 * start : 1399429229000, //mode为0时,表示开始时间,mode为1时,表示时间的毫秒值
98 * end : 1399515601000 //mode为0时,表示结束时间,mode为1时,表示时间的毫秒值
104 * type : 'ClearedTime',
106 * mode : 0, //0表示区间,1表示最近
107 * start : 1399429229000, //mode为0时,表示开始时间,mode为1时,表示时间的毫秒值
108 * end : 1399515601000 //mode为0时,表示结束时间,mode为1时,表示时间的毫秒值
124 * moc : 'moc' //支持前缀匹配,如:'moc%'
132 * neIp : '10.74.165.57'
137 parseConds2JSon: function (conds, ruleType) {
139 Position: function (cond) {
141 if (cond.type === "Position" && cond.data.length > 0) {
142 condStr = "<NewPositionCond OwnerType='Position' value='" + cond.data[0].locationId + "#" + cond.data[0].oid + "#" + cond.data[0].isSelf;
143 for (var i = 1; i < cond.data.length; i++) {
144 condStr += "∷" + cond.data[i].locationId + "#" + cond.data[i].oid + "#" + cond.data[i].isSelf;
150 Severity: function (cond) {
152 if (cond.type === "Severity" && cond.data.length > 0) {
153 condStr = "<PerceivedSeverity value='" + cond.data[0].severity;
154 for (var i = 1; i < cond.data.length; i++) {
155 condStr += "," + cond.data[i].severity;
161 AckState: function (cond) {
163 if (cond.type === "AckState" && cond.data.length > 0) {
164 condStr = "<AckState value='" + cond.data[0].ackState;
165 for (var i = 1; i < cond.data.length; i++) {
166 condStr += "," + cond.data[i].ackState;
172 FilterState: function (cond) {
174 if (cond.type === "FilterState" && cond.data.length > 0) {
175 condStr = "<FilterState value='" + cond.data[0].filterState;
176 for (var i = 1; i < cond.data.length; i++) {
177 condStr += "," + cond.data[i].filterState;
183 AlarmType: function (cond) {
185 if (cond.type === "AlarmType" && cond.data.length > 0) {
186 condStr = "<AlarmType value='" + cond.data[0].alarmType;
187 for (var i = 1; i < cond.data.length; i++) {
188 condStr += "," + cond.data[i].alarmType;
194 ProbableCause: function (cond) {
196 if (cond.type === "ProbableCause" && cond.data.length > 0) {
197 condStr = "<ProbableCause value='" + cond.data[0].systemType + "#" + cond.data[0].code;
198 for (var i = 1; i < cond.data.length; i++) {
199 condStr += "," + cond.data[i].systemType + "#" + cond.data[i].code;
205 RaisedTime: function (cond) {
207 if (cond.type === "RaisedTime" && cond.data.length === 1) {
208 condStr = "<RaisedTime model='" + cond.data[0].mode + "' start='" + cond.data[0].start + "' end= '" + cond.data[0].end + "' queryTimeZone='' condTimeZone='' />";
212 AckTime: function (cond) {
214 if (cond.type === "AckTime" && cond.data.length === 1) {
215 condStr = "<AckTime model='" + cond.data[0].mode + "' start='" + cond.data[0].start + "' end= '" + cond.data[0].end + "' queryTimeZone='' condTimeZone='' />";
219 ClearedTime: function (cond) {
221 if (cond.type === "ClearedTime" && cond.data.length === 1) {
222 condStr = "<ClearedTime model='" + cond.data[0].mode + "' start='" + cond.data[0].start + "' end= '" + cond.data[0].end + "' queryTimeZone='' condTimeZone='' />";
226 AlarmId: function (cond) {
228 if (cond.type === "AlarmId" && cond.data.length === 1) {
229 condStr = "<IDString value='" + cond.data[0].id + "'/>";
233 Moc: function (cond) {
235 if (cond.type === "Moc" && cond.data.length === 1) {
236 condStr = "<Moc Moc='" + cond.data[0].moc + "' SELECT_MODEL='false' MocSelf='true' />";
240 NeIp: function (cond) {
242 if (cond.type === "NeIp" && cond.data.length === 1) {
243 condStr = "<NeIp value='" + cond.data[0].neIp + "' />";
255 createTime: d.getTime(),
266 var condStr = "<CompoundCond>";
267 for (var i = 0; i < conds.length; i++) {
268 condStr += parser[conds[i].type](conds[i]);
270 JSonObj.rule.ruleData = condStr + "</CompoundCond>";
271 //return JSON.stringify(JSonObj);