@@ -231,25 +231,42 @@ def get_query_capability_uris_from_xml(self,capabilitiesxml,context):
231231 logger .debug ( f"{ rdfxml .xmlrdf_get_resource_uri (qcrtx )= } " )
232232 return qcs
233233
234- def get_factory_uri_from_xml (self ,factoriesxml ,resource_type ,context ):
235- logger .info ( f"get_factory_uri_from_xml { self = } { resource_type = } { factoriesxml = } " )
234+ def get_factory_uri_from_xml (self ,factoriesxml ,resource_type ,context , return_shapes = False ):
235+ logger .info ( f"get_factory_uri_from_xml { self = } { resource_type = } { factoriesxml = } { return_shapes = } " )
236236 if resource_type is None :
237237 raise Exception ( "You must provide a resource type" )
238238 # ensure we have a URI for the resource type
239239 resource_type_u = rdfxml .tag_to_uri (resource_type )
240240 # get list of [resourcetype,uri]
241241 qcs = self .get_factory_uris_from_xml (factoriesxml = factoriesxml ,context = context )
242+ result = None
242243 if resource_type_u .startswith ( 'http' ):
243244 # looking for a complete precise URI
244245 if resource_type_u in qcs :
245- return qcs [resource_type_u ]
246- raise Exception ( f"Factory for resource type { resource_type } not found" )
247- # didn't specify a URI - find the first match at the end of the resouce type
248- for k ,v in qcs .items ():
249- if k .endswith (resource_type ):
250- return v
251- raise Exception ( f"QFactory { resource_type } { resource_type_u } not found!" )
252-
246+ result = qcs [resource_type_u ]
247+ else :
248+ raise Exception ( f"Factory for resource type { resource_type } not found" )
249+ else :
250+ # didn't specify a URI - find the first match at the end of the resouce type
251+ for k ,v in qcs .items ():
252+ if k .endswith (resource_type ):
253+ result = v
254+ if result is None :
255+ raise Exception ( f"QFactory { resource_type } { resource_type_u } not found!" )
256+ if return_shapes :
257+ shapeuris = []
258+ # get the shapes from this factory capability
259+ # find the factory capability xml
260+ # print( f"{result=}" )
261+ fc_rs = rdfxml .xml_find_elements ( factoriesxml , f".//oslc:CreationFactory/oslc:creation[@rdf:resource='{ result } ']/../oslc:resourceShape" )
262+ # print( f"{fc_rs=}" )
263+ for rs in fc_rs :
264+ # collect the <oslc:resourceShape entries
265+ shapeuris .append (rdfxml .xmlrdf_get_resource_uri ( rs ) )
266+ # print( f"{shapeuris=}" )
267+ return result , shapeuris
268+ else :
269+ return result
253270 # returns a dictionary of resource type to factory URI
254271 # this is used when the XML doesn't have references off to other URLs (like GCM does)
255272 def get_factory_uris_from_xml (self ,factoriesxml ,context ):
0 commit comments