18 require_once SQ_PACKAGES_PATH.
'/web_services/api/soap_api/soap_api.inc';
43 parent::__construct($assetid);
59 'AdvancedSearch' =>
'1',
86 $request_info = (Array) $request;
87 $search_asset_types = array_get_index($request_info,
'AssetTypes',
'');
88 $search_limit = array_get_index($request_info,
'Limit',
'');
89 $search_roots = array_get_index($request_info,
'RootIDs',
'');
90 $search_result_format = array_get_index($request_info,
'ResultFormat',
'');
91 $search_restrict_statuses = array_get_index($request_info,
'Statuses',
'');
92 $exclude_root_nodes = self::getBooleanIndex($request_info,
'ExcludeRootNodes', FALSE);
94 if (!is_array($search_restrict_statuses)) {
95 $search_restrict_statuses = Array ($search_restrict_statuses);
98 if (isset($search_asset_types->AssetType)) {
99 $search_asset_types = Array ($search_asset_types);
102 $final_types_array = Array();
103 foreach ($search_asset_types as $type_info)
105 $final_types_array[strtolower($type_info->AssetType)] = $type_info->Inherit;
108 if (!is_array($search_roots)) {
109 $search_roots = Array ($search_roots);
113 $installed = $GLOBALS[
'SQ_SYSTEM']->am->installed(
'search_manager');
115 $sm = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'search_manager');
116 $search_info = Array(
117 'limit' => $search_limit,
118 'asset_types' => $final_types_array,
119 'statuses' => $search_restrict_statuses,
120 'roots' => $search_roots,
123 $results = $sm->processBasicSearch($search_info, TRUE);
124 $final_result = Array();
125 if (!empty($results)) {
126 foreach ($results as $assetid => $info) {
127 if ($exclude_root_nodes) {
128 if (in_array($assetid, $search_roots)) {
129 unset($results[$assetid]);
133 if (!empty($search_result_format)) {
134 $final_result[] = self::formatAssetResult($assetid, $search_result_format);
136 $final_result[] = $assetid;
142 'BasicSearchResult' => $final_result,
146 throw new SoapFault(
'Server',
'Search Manager is not installed');
176 $request_info = (Array) $request;
177 $search_asset_types = array_get_index($request_info,
'AssetTypes',
'');
178 $exclude_words = array_get_index($request_info,
'ExcludeWords',
'');
179 $search_field_logic = array_get_index($request_info,
'FieldLogic',
'AND');
180 $search_word_logic = array_get_index($request_info,
'WordLogic',
'AND');
181 $search_limit = array_get_index($request_info,
'Limit',
'');
182 $search_result_format = array_get_index($request_info,
'ResultFormat',
'');
183 $search_roots = array_get_index($request_info,
'RootIDs',
'');
184 $root_logic = array_get_index($request_info,
'RootLogic',
'AND');
185 $search_restrict_statuses = array_get_index($request_info,
'Statuses',
'');
186 $search_fields = array_get_index($request_info,
'SearchFields',
'');
187 $exclude_root_nodes = self::getBooleanIndex($request_info,
'ExcludeRootNodes', FALSE);
189 if (!is_array($search_restrict_statuses)) {
190 $search_restrict_statuses = Array ($search_restrict_statuses);
193 $installed = $GLOBALS[
'SQ_SYSTEM']->am->installed(
'search_manager');
195 $sm = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'search_manager');
197 $field_name_count = 0;
198 $final_search_field = Array();
199 if (!empty($search_fields)) {
200 if (isset($search_fields->SearchTerm)) {
201 $search_fields = Array ($search_fields);
203 foreach ($search_fields as $field_info) {
204 $new_field_info = Array();
205 $new_field_info[
'word_logic'] = $field_info->WordLogic;
206 $new_field_info[
'words'] = $field_info->SearchTerm;
207 $new_field_info[
'data_sources'] = Array();
209 if (isset($field_info->DataSources->FieldType)) {
210 $field_info->DataSources = Array (
211 $field_info->DataSources,
215 foreach ($field_info->DataSources as $data_source) {
216 if ($data_source->FieldType ==
'Metadata') {
217 $data_source_new = Array (
218 'type' =>
'metadata',
220 'assetid' => $data_source->MetadataOption->MetadataFieldID,
223 }
else if ($data_source->FieldType ==
'Attribute') {
224 $data_source_new = Array (
225 'type' =>
'asset_attrib',
227 'asset_type' => $data_source->AttributeOption->AssetType,
228 'attrid' => $data_source->AttributeOption->AttributeID,
231 }
else if ($data_source->FieldType ==
'Standard') {
232 $data_source_new = Array (
233 'type' =>
'standard',
235 'field' => $data_source->StandardOption->FieldName,
238 }
else if ($data_source->FieldType ==
'IncludeAll') {
239 $data_source_new = Array (
240 'type' =>
'include_all',
241 'params' => Array (),
244 $new_field_info[
'data_sources'][] = $data_source_new;
248 if (!isset($new_field_info[
'name'])) {
249 $new_field_info[
'name'] =
'FieldName'.$field_name_count;
251 $final_search_field[
'fieldname'.$field_name_count] = $new_field_info;
256 if (isset($search_asset_types->AssetType)) {
257 $search_asset_types = Array ($search_asset_types);
259 $final_types_array = Array();
260 foreach ($search_asset_types as $type_info)
262 $final_types_array[strtolower($type_info->AssetType)] = $type_info->Inherit;
265 if (!is_array($search_roots)) {
266 $search_roots = Array ($search_roots);
269 $search_info = Array(
270 'asset_types' => $final_types_array,
271 'field_logic' => $search_field_logic,
272 'limit' => $search_limit,
273 'statuses' => $search_restrict_statuses,
274 'roots' => $search_roots,
275 'root_logic' => $root_logic,
276 'statuses' => $search_restrict_statuses,
277 'fields' => $final_search_field,
279 if (!empty($exclude_words)) {
280 if (!is_array($exclude_words)) {
281 $exclude_words = Array ($exclude_words);
283 $search_info[
'exclude'] = $exclude_words;
286 $results = $sm->processSearch($search_info, TRUE);
287 $final_result = Array();
288 if (!empty($results)) {
290 foreach ($results as $index => $asset_info) {
291 if ($exclude_root_nodes) {
292 if (in_array($asset_info[
'assetid'], $search_roots)) {
293 unset($results[$index]);
298 if (!empty($search_result_format)) {
299 $asset_print_formatted = self::formatAssetResult($asset_info[
'assetid'], $search_result_format);
301 $asset_print_formatted = $asset_info[
'assetid'];
304 $final_result[$i][
'AssetDisplay'] = $asset_print_formatted;
305 $final_result[$i][
'SearchScore'] = $asset_info[
'search_score'];
306 $final_result[$i][
'Source'] = $asset_info[
'source'];
312 'AdvancedSearchResult' => $final_result,
315 throw new SoapFault(
'Server',
'Search Manager is not installed');
337 $request_info = (Array) $request;
338 $reindex_assetid = array_get_index($request_info,
'AssetID',
'');
339 $reindex_components = array_get_index($request_info,
'IndexComponents',
'all');
341 if (!empty($reindex_assetid)) {
342 $reindex_asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($reindex_assetid);
343 if (empty($reindex_assetid)) {
344 throw new SoapFault(
'Server',
'There Is No Asset In The System With AssetID '.$reindex_assetid);
346 $installed = $GLOBALS[
'SQ_SYSTEM']->am->installed(
'search_manager');
348 $sm = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'search_manager');
349 $sm->reindexAsset($reindex_asset, Array($reindex_components));
352 'ReIndexResult' => TRUE,
355 throw new SoapFault(
'Server',
'Search Manager is not installed');
358 throw new SoapFault(
'Server',
'No Asset ID was found to reindex');
370 private static function formatAssetResult($assetid, $search_result_format)
372 $formatted_assets = Array();
373 require_once SQ_FUDGE_PATH.
'/general/text.inc';
374 $replacement_keywords = Array();
376 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid);
377 $tmp_format = $search_result_format;
378 $keywords = extract_keywords($search_result_format);
379 foreach ($keywords as $keyword) {
380 $replacement = $asset->getKeywordReplacement($keyword);
381 if ($replacement ==
'%'.$keyword.
'%') {
384 $replacement_keywords[$keyword] = $replacement;
387 $asset_result_print = replace_keywords($tmp_format, $replacement_keywords);
389 return $asset_result_print;
402 $obj_optional = self::getArgType(
'AssetObject', 0, 1);
403 $statuses = self::getArgType(
'AssetStatus', 0,
'unbounded');
404 $search_logic = self::getArgType(
'SearchLogicValue', 0, 1, TRUE);
405 $search_fields = self::getArgType(
'SearchField', 0,
'unbounded', TRUE);
406 $asset_types = self::getArgType(
'AssetTypes', 0,
'unbounded');
407 $root_nodes = self::getArgType(
'string', 0,
'unbounded', TRUE);
408 $search_result = self::getArgType(
'string', 0,
'unbounded', TRUE);
409 $advanced_search_result = self::getArgType(
'AdvancedResult', 0,
'unbounded', TRUE);
410 $exclude_words = self::getArgType(
'string', 0,
'unbounded', TRUE);
411 $index_component = self::getArgType(
'IndexComponent', 0, 1);
413 $complex_types = Array (
414 'BasicSearch' => Array (
415 'BasicSearch' => Array (
416 'AssetTypes' => $asset_types,
417 'Limit' => self::$string_non_optional,
418 'Statuses' => $statuses,
419 'RootIDs' => $root_nodes,
420 'ExcludeRootNodes' => self::$boolean_optional,
421 'ResultFormat' => self::$string_optional,
423 'BasicSearchResponse' => Array (
424 'BasicSearchResult' => $search_result,
427 'AdvancedSearch' => Array (
428 'AdvancedSearch' => Array (
429 'AssetTypes' => $asset_types,
430 'ExcludeWords' => $exclude_words,
431 'FieldLogic' => self::$string_optional,
432 'Limit' => self::$string_non_optional,
433 'ResultFormat' => self::$string_optional,
434 'RootIDs' => $root_nodes,
435 'RootLogic' => $search_logic,
436 'ExcludeRootNodes' => self::$boolean_optional,
437 'Statuses' => $statuses,
438 'SearchFields' => $search_fields,
440 'AdvancedSearchResponse' => Array (
441 'AdvancedSearchResult' => $advanced_search_result,
446 'AssetID' => self::$string_non_optional,
447 'IndexComponents' => $index_component,
449 'ReIndexResponse' => Array (
450 'ReIndexResult' => self::$boolean_non_optional,
456 $complex_types_available = parent::getComplexElements($complex_types);
458 return $complex_types_available;
471 $data_sources = self::getArgType(
'DataSource', 0,
'unbounded');
472 $metadata_option = self::getArgType(
'MetadataSearchOption', 0,
'unbounded');
473 $attribute_option = self::getArgType(
'AttributeSearchOption', 0,
'unbounded');
474 $standard_option = self::getArgType(
'StandardSearchOption', 0,
'unbounded');
475 $search_field_type = self::getArgType(
'SearchFieldType', 1, 1);
476 $assetType_optional = self::getArgType(
'AssetType', 0,
'unbounded');
477 $asset_type_inhr = Array (
478 'AssetType' => $assetType_optional,
479 'Inherit' => self::$string_non_optional,
482 $complex_types = Array (
483 'AdvancedSearch' => Array (
484 'SearchField' => Array (
485 'SearchTerm' => self::$string_non_optional,
486 'WordLogic' => self::$string_non_optional,
487 'DataSources' => $data_sources,
489 'DataSource' => Array (
490 'FieldType' => $search_field_type,
491 'MetadataOption' => $metadata_option,
492 'AttributeOption' => $attribute_option,
493 'StandardOption' => $standard_option,
495 'MetadataSearchOption' => Array (
496 'MetadataFieldID' => self::$string_optional,
498 'AttributeSearchOption' => Array (
499 'AssetType' => self::$string_optional,
500 'AttributeID' => self::$string_optional,
502 'StandardSearchOption' => Array (
503 'FieldName' => self::$string_optional,
506 'AdvancedResult' => Array (
507 'AssetDisplay' => self::$string_optional,
508 'SearchScore' => self::$string_optional,
509 'Source' => self::$string_optional,
511 'AssetTypes' => $asset_type_inhr,
513 'BasicSearch' => Array (
514 'AssetTypes' => $asset_type_inhr,
518 $complex_types_available = parent::getComplexElements($complex_types);
520 return $complex_types_available;
533 $asset_types_info = $GLOBALS[
'SQ_SYSTEM']->am->getAssetTypes(TRUE, TRUE);
534 $asset_types = Array();
535 foreach ($asset_types_info as $asset_type_info) {
536 $asset_types[] = $asset_type_info[
'type_code'];
539 $simple_restricted_types = Array (
540 'BasicSearch' => Array (
541 'AssetType' => Array (
542 'restriction_base' =>
'string',
543 'enumeration' => $asset_types,
545 'AssetStatus' => Array (
546 'restriction_base' =>
'string',
547 'enumeration' => Array (
548 '1',
'2',
'4',
'8',
'16',
'32',
'64',
'128',
'256',
551 'SearchLogicValue' => Array (
552 'restriction_base' =>
'string',
553 'enumeration' => Array (
559 'IndexComponent' => Array (
560 'restriction_base' =>
'string',
561 'enumeration' => Array (
562 'asset',
'metadata',
'all'
566 'AdvancedSearch'=> Array (
567 'SearchFieldType' => Array (
568 'restriction_base' =>
'string',
569 'enumeration' => Array (
570 'Metadata',
'Attribute',
'Standard',
'IncludeAll',
573 'AssetType' => Array (
574 'restriction_base' =>
'string',
575 'enumeration' => $asset_types,
580 $simple_restricted_types_available = parent::processSimpleRestrictedTypes($simple_restricted_types);
582 return $simple_restricted_types_available;