18 require_once SQ_CORE_PACKAGE_PATH.
'/report/report.inc';
19 require_once SQ_CORE_PACKAGE_PATH.
'/interfaces/bridge/bridge.inc';
44 $this->_ser_attrs = TRUE;
45 parent::__construct($assetid);
58 if (!isset($this->_tmp[
'getAssetMapLinks'])) {
60 $am = $GLOBALS[
'SQ_SYSTEM']->am;
61 require_once SQ_INCLUDE_PATH.
'/general_occasional.inc';
63 $report_path = $this->data_path.
'/report.xml';
65 if (!is_file($report_path))
return Array();
68 $root =
new SimpleXMLElement($report_path, LIBXML_NOCDATA, TRUE);
69 }
catch (Exception $e) {
74 foreach ($root->asset as $result) {
75 if (is_null($result->attributes()->type_code)) {
81 'assetid' => (String) $result->attributes()->assetid,
82 'short_name' => (String) $result->attributes()->short_name,
83 'name' => (String) $result->attributes()->name,
85 'type_code' => (String) $result->attributes()->type_code,
86 'status' => (String) $result->attributes()->status,
88 'link_type' => SQ_LINK_TYPE_1,
90 'sort_order' => $sort_order,
99 $this->_tmp[
'getAssetMapLinks'] = $links;
103 return $this->_tmp[
'getAssetMapLinks'];
131 public function getLinks($assetid, $link_types, $type_code=
'', $strict_type_code=TRUE, $side_of_link=
'major', $sort_by=NULL, $dependant=NULL, $exclusive=NULL)
133 assert_equals($assetid, $this->
id,
'The Asset Statuses Report can only get its own links');
134 if ($dependant || $exclusive) {
138 if (!isset($this->_tmp[
'getLinks'])) {
140 $am = $GLOBALS[
'SQ_SYSTEM']->am;
141 require_once SQ_INCLUDE_PATH.
'/general_occasional.inc';
142 $report_path = $this->data_path.
'/report.xml';
143 if (!is_file($report_path))
return Array();
146 $root =
new SimpleXMLElement($report_path, LIBXML_NOCDATA, TRUE);
147 }
catch (Exception $e) {
153 foreach ($root->asset as $asset) {
154 if (is_null($asset->attributes()->type_code)) {
161 'majorid' => $this->
id,
162 'minorid' => (String) $asset->attributes()->assetid,
164 'link_type' => SQ_LINK_TYPE_1,
165 'minor_type_code' => (String) $asset->attributes()->type_code,
166 'sort_order' => $sort_order,
167 'is_dependant' =>
'0',
168 'is_exclusive' =>
'0',
175 $this->_tmp[
'getLinks'] = $links;
179 return $this->_tmp[
'getLinks'];
197 public function getParents($assetid, $type_code=
'', $strict_type_code=TRUE)
199 assert_equals($assetid, $this->
id,
'The Asset Statuses Report can only get its own links');
225 public function getChildren($assetid, $type_code=
'', $strict_type_code=TRUE, $dependant=NULL, $sort_by=NULL)
227 assert_equals($assetid, $this->
id,
'The Asset Statuses Report can only get its own links');
282 if (isset($this->_tmp[
'allowed_asset_map'])) {
283 return $this->_tmp[
'allowed_asset_map'];
286 $wanted_types = $this->
attr(
'types');
287 if (empty($wanted_types))
return Array();
289 $allowed_asset_map = Array();
290 foreach ($wanted_types as $allowed_parent_type => $inherit) {
291 if (trim($allowed_parent_type) ==
'') {
293 }
else if (!$inherit) {
294 $allowed_asset_map[$allowed_parent_type] = $allowed_parent_type;
296 $descendants = $GLOBALS[
'SQ_SYSTEM']->am->getTypeDescendants($allowed_parent_type, TRUE);
297 foreach ($descendants as $allowed_type) {
298 if (!isset($allowed_asset_map[$allowed_type])) {
299 $allowed_asset_map[$allowed_type] = $allowed_parent_type;
305 $this->_tmp[
'allowed_asset_map'] = $allowed_asset_map;
306 return $allowed_asset_map;
332 public function countLinks($assetid, $side_of_link=
'major', $link_types=0, $type_code=
'', $strict_type_code=TRUE, $ignore_linkid=0)
371 public function getAsset($shadowid, $type_code=
'', $mute_errors=FALSE)