@@ -119,3 +119,35 @@ def eitem_event_builder(event, sender_app, obj=None, **kwargs):
119119 record = kwargs ["record" ]
120120 event .update (dict (eitem_pid = record ["pid" ], document_pid = record .get ("document_pid" )))
121121 return event
122+
123+
124+ def get_eitems_for_document_by_creator (document_pid , creator , case_insensitive = False ):
125+ """Find eitems by document pid and creator.
126+
127+ :param document_pid: The PID of the document of the eitems to search for.
128+ :param creator: The creator to filter eitems by.
129+ :param case_insensitive: Whether the creator match should be case insensitive.
130+ """
131+ eitem_search = current_app_ils .eitem_search_cls ()
132+ creator_match = eitem_search .search_by_document_pid (
133+ document_pid = document_pid
134+ ).filter (
135+ "term" ,
136+ created_by__value = {"term" : creator , "case_insensitive" : case_insensitive },
137+ )
138+
139+ return creator_match
140+
141+
142+ def get_eitems_for_document_by_source (document_pid , source , case_insensitive = False ):
143+ """Find eitems by document pid and source.
144+
145+ :param document_pid: The PID of the document of the eitems to search for.
146+ :param source: The source to filter eitems by.
147+ :param case_insensitive: Whether the source match should be case insensitive.
148+ """
149+ eitem_search = current_app_ils .eitem_search_cls ()
150+ source_match = eitem_search .search_by_document_pid (
151+ document_pid = document_pid
152+ ).filter ("term" , source = {"value" : source , "case_insensitive" : case_insensitive })
153+ return source_match
0 commit comments