UserDeleteObsolete.php
4.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<?php
/**
* @class UserDeleteObsolete
* @version $Id: UserDeleteObsolete.php 1808 2013-09-24 13:09:42Z elena $
*
*/
class UserDeleteObsolete {
private $dataset, $vi, $Mgr;
private $ws_deleted;
function __construct() {
$this->ws_deleted = array();
}
public function setVI($vi) {
$this->vi = $vi;
$this->dataset = strtolower($vi);
}
public function deleteDerived() {
$msg = '<b>WS (Derived) Params:</b><br/>';
// derived parameters
$this->Mgr = new DerivedParamMgr('derivedParam');
// get params
$wsParams = $this->Mgr->contentDom->getElementsByTagName('param');
if ($wsParams->length == 0) {
return array('success' => true, 'msg' => 'No parameters');
}
foreach ($wsParams as $param) {
$id = $param->getAttribute('xml:id');
$name = $param->getAttribute('name');
$expression = $param->getAttribute('buildchain');
if (strpos(strtolower($expression), $this->dataset)) {
$msg .= 'deleted name:<b>'.$name.'</b>; expression: '.$expression.'<br/>';
$obj = new stdClass();
$obj->leaf = true;
$obj->id = $id;
$this->Mgr->deleteObject($obj);
// error_log( 'For INFO : DELETED '.$expression,1,email);
$this->ws_deleted[] = $name;
}
}
$msg .= ' ok<br/>';
return array('success' => true, 'msg' => $msg);
}
public function deleteConditions() {
$msg = '<b>Conditions:</b><br/>';
// conditons
$this->Mgr = new RequestMgr('condition');
$conditions = $this->Mgr->contentDom->getElementsByTagName('condition');
if ($conditions->length == 0) {
return array('success' => true, 'msg' => 'No conditions');
}
foreach ($conditions as $item) {
$id = $item->getAttribute('xml:id');
$name = $item->getAttribute('name');
$expression = strtolower($this->Mgr->getObject($id)->expression);
if (strpos($expression, $this->dataset)) {
$obj = new stdClass();
$obj->leaf = true;
$obj->id = $id;
$this->Mgr->deleteObject($obj);
$msg .= 'deleted name:<b>'.$obj->name.'</b>; expression:'.$expression.'<br/>';
}
}
$msg .= ' ok<br/>';
return array('success' => true, 'msg' => $msg);
}
public function deleteRequests() {
$msg = '<b>Requests:</b><br/>';
// requests
$this->Mgr = new RequestMgr('request');
$requests = $this->Mgr->contentDom->getElementsByTagName('request');
if (count($requests) == 0) {
return array('success' => true, 'msg' => 'No requests');
}
foreach ($requests as $item) {
$id = $item->getAttribute('xml:id');
$name = $item->getAttribute('name');
$objplot = $this->Mgr->getObject($id);
$obj = new stdClass();
$obj->leaf = true;
$obj->id = $id;
foreach ($objplot->children as $panel) {
foreach ($panel->children as $param) {
$parID = strtolower($param->name);
if ($this->ws_deleted && substr($parId,0,3) == "ws_") {
if (array_search($this->ws_deleted, $parId)) {
$this->Mgr->deleteObject($obj);
$msg .= 'request deleted '.$name.'<br/>';
continue 3;
}
}
if (strpos($parID, $this->dataset)) {
$this->Mgr->deleteObject($obj);
$msg .= 'request deleted '.$name.'<br/>';
continue 3;
}
}
}
}
$msg .= ' ok<br/>';
return array('success' => true, 'msg' => $msg);
}
public function deleteAliases() {
$msg = '<b>Aliases:</b><br/>';
$this->Mgr = new AliasMgr();
$aliases = $this->Mgr->contentDom->getElementsByTagName('alias');
foreach ($aliases as $alias) {
$id = $alias->getAttribute('xml:id');
$name = $alias->getAttribute('name');
if (strpos(strtolower($id), $this->dataset)) {
$obj = new stdClass();
$obj->leaf = true;
$obj->id = $id;
$this->Mgr->deleteObject($obj);
$msg .= 'alias deleted '.$name.'<br/>';
}
}
return array('success' => true, 'msg' => $msg);
}
public function deleteInTree() {
$msg = '<b>Dataset in RemoteParams:</b><br/>';
$this->Mgr = new ParamMgr();
$xp = new domxpath($this->Mgr->xmlDom);
$nodeToDelete = $xp->query("//dataset[@name='".$this->vi."']");
if ($nodeToDelete->length > 0) {
$instrNode = $nodeToDelete->item(0)->parentNode;
$instrNode->removeChild($nodeToDelete->item(0));
if (!$instrNode->hasChildNodes()) {
$missionNode = $instrNode->parentNode;
$missionNode->removeChild($instrNode);
if (!$missionNode->hasChildNodes()) {
$datacenterNode = $missionNode->parentNode;
$datacenterNode->removeChild($missionNode);
}
}
$this->Mgr->xmlDom->save($this->Mgr->xmlName);
$msg .= 'dataset deleted '.$this->vi.'<br/>';
}
return array('success' => true, 'msg' => $msg);
}
}
?>