@@ -547,9 +547,11 @@ def items(self, headers_, json_post_data, args, collection='metadata:main'):
547547 query_parser = None
548548 sortby = None
549549 limit = None
550+ ids = []
550551 bbox = []
551552 facets_requested = False
552553 collections = []
554+ cql_ops_list = []
553555
554556 if collection not in self .get_all_collections ():
555557 msg = 'Invalid collection'
@@ -644,7 +646,6 @@ def items(self, headers_, json_post_data, args, collection='metadata:main'):
644646 query_parser = parse_ecql
645647
646648 elif json_post_data is not None :
647-
648649 if 'limit' in json_post_data :
649650 limit = json_post_data .pop ('limit' )
650651 if 'sortby' in json_post_data :
@@ -653,23 +654,36 @@ def items(self, headers_, json_post_data, args, collection='metadata:main'):
653654 collections = json_post_data .pop ('collections' )
654655 if 'bbox' in json_post_data :
655656 bbox = json_post_data .pop ('bbox' )
657+ if 'ids' in json_post_data :
658+ ids = json_post_data .pop ('ids' )
656659 if not json_post_data :
657660 LOGGER .debug ('No CQL specified, only query parameters' )
658661 json_post_data = {}
662+
659663 if not json_post_data and collections and collections != ['metadata:main' ]:
660- json_post_data = {'op' : 'eq' , 'args' : [{'property' : 'parentidentifier' }, collections [0 ]]}
661- if bbox :
662- json_post_data = {
663- 'op' : 'and' ,
664- 'args' : [{
665- 'op' : 's_intersects' ,
666- 'args' : [
667- {'property' : 'geometry2' },
668- {'bbox' : [bbox ]}
669- ]},
670- json_post_data
671- ]
672- }
664+ cql_ops_list .append ({'op' : 'eq' , 'args' : [{'property' : 'parentidentifier' }, collections [0 ]]})
665+ if bbox :
666+ cql_ops_list .append ({
667+ 'op' : 's_intersects' ,
668+ 'args' : [
669+ {'property' : 'geometry' },
670+ {'bbox' : [bbox ]}
671+ ]}
672+ )
673+
674+ if ids :
675+ cql_ops_list .append ({
676+ 'op' : 'in' ,
677+ 'args' : [{'property' : 'identifier' }, ids ]
678+ })
679+
680+ if len (cql_ops_list ) > 1 :
681+ json_post_data = {
682+ 'op' : 'and' ,
683+ 'args' : cql_ops_list
684+ }
685+ elif len (cql_ops_list ) == 1 :
686+ json_post_data = cql_ops_list [0 ]
673687
674688 cql_query = json_post_data
675689 LOGGER .debug ('Detected CQL JSON; ignoring all other query predicates' )
0 commit comments