Skip to content

Commit addd09c

Browse files
committedJan 23, 2023
Added examples dn_simple_createartifact.py and dn_simple_updateartifact.py
1 parent 78882c0 commit addd09c

40 files changed

+2474
-3394
lines changed
 

‎.bumpversion.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.13.2
2+
current_version = 0.14.0
33
commit = True
44
tag = True
55

‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
SPDX-License-Identifier: MIT
1010

11-
version="0.13.2"
11+
version="0.14.0"
1212

1313

1414
Introduction

‎elmclient/__meta__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
app = 'elmoslcquery'
1111
description = 'Commandline OSLC query for ELM'
12-
version = '0.13.2'
12+
version = '0.14.0'
1313
license = 'MIT'
1414
author_name = 'Ian Barnard'
1515
author_mail = 'ian.barnard@uk.ibm.com'

‎elmclient/_app.py

+27-10
Original file line numberDiff line numberDiff line change
@@ -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):

‎elmclient/_project.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,10 @@ def get_query_capability_uris(self,resource_type=None,context=None):
134134
resource_type = resource_type or context.default_query_resource
135135
return self.app.get_query_capability_uris_from_xml(capabilitiesxml=context.get_services_xml(), context=context)
136136

137-
def get_factory_uri(self,resource_type=None,context=None):
137+
def get_factory_uri(self,resource_type=None,context=None, return_shapes=False):
138138
context = context or self
139139
resource_type = resource_type or context.default_query_resource
140-
return self.app.get_factory_uri_from_xml(factoriesxml=context.get_services_xml(), resource_type=resource_type,context=context)
140+
return self.app.get_factory_uri_from_xml(factoriesxml=context.get_services_xml(), resource_type=resource_type,context=context, return_shapes=return_shapes)
141141

142142
def load_type_from_resource_shape(self, el):
143143
raise Exception( "This must be provided by the inheriting class!" )

0 commit comments

Comments
 (0)