Skip to content

Commit 055db6a

Browse files
committed
nearly have resource update of Questions working :-)
1 parent cbd09c8 commit 055db6a

5 files changed

Lines changed: 8117 additions & 23 deletions

File tree

elmclient/_rm.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,34 +1079,37 @@ def _load_type_from_resource_shape(self, el, supershape=None):
10791079
if property_title_x is None:
10801080
burp
10811081
property_title = property_title_x.text
1082-
# print( f"Loading {property_title}" )
1082+
print( f"Loading prop {property_title}" )
10831083
# propuri = rdfxml.xml_find_element( el, 'oslc:propertyDefinition').get( "{%s}resource" % rdfxml.RDF_DEFAULT_PREFIX["rdf"])
10841084
propuri = rdfxml.xmlrdf_get_resource_uri( el, 'oslc:propertyDefinition')
1085-
# print( f"{propuri=}" )
1085+
print( f"{propuri=}" )
10861086
# prefer range over valueType (doesn't nmatter for rm but does for qm which has both in a property definition)
10871087
proptype = rdfxml.xmlrdf_get_resource_uri( el,'oslc:range' )
10881088
if proptype is None:
10891089
proptype = rdfxml.xmlrdf_get_resource_uri(el,'oslc:valueType' )
1090-
# print( f"{proptype=}" )
1090+
print( f"{proptype=}" )
10911091
# lookup the codec, if there is one
10921092
propcodec = valueTypeToCodec.get( proptype )
1093-
# print( f"{propcodec=}" )
1093+
print( f"{propcodec=}" )
10941094

1095-
if self.is_known_property_uri( propuri ):
1096-
logger.debug( f"ALREADY KNOWN" )
1097-
# print( f"ALREADY KNOWN" )
1098-
continue
1099-
11001095
# work out if multivalued
11011096
mvtext_x = rdfxml.xmlrdf_get_resource_uri( el, "oslc:occurs" )
11021097
isMultiValued = mvtext_x=="http://open-services.net/ns/core#Zero-or-many"
11031098
# print( f"{property_title} {isMultiValued=} {mvtext_x=}" )
1099+
1100+
self.register_property( property_title, propuri, isMultiValued=isMultiValued, shape_uri=uri, typeCodec=propcodec )
1101+
1102+
if self.is_known_property_uri( propuri ):
1103+
logger.debug( f"ALREADY KNOWN" )
1104+
print( f"ALREADY KNOWN" )
1105+
continue
1106+
11041107

11051108
# get the property definition
11061109
# all links have a Reference oslc:representation
11071110
# true links have <oslc:range rdf:resource="http://open-services.net/ns/core#Resource"/>
11081111
if rdfxml.xml_find_element( el, "oslc:representation[@rdf:resource='http://open-services.net/ns/core#Reference']") is not None and ( rdfxml.xml_find_element( el, "oslc:range[@rdf:resource='http://open-services.net/ns/core#Resource']" ) is not None or rdfxml.xml_find_element( el, "oslc:valueType[@rdf:resource='http://open-services.net/ns/core#Resource']" ) is not None):
1109-
# print( f"Ref {propuri=}" )
1112+
print( f"Ref {propuri=}" )
11101113
if propuri is not None:
11111114
# print( f"Ref1 {propuri=}" )
11121115
if propcodec is None: # don't override if the codec is already set!
@@ -1127,15 +1130,15 @@ def _load_type_from_resource_shape(self, el, supershape=None):
11271130
# print( f"Defining linktype {name}.{property_title} {propuri=} {uri=} +++++++++++++++++++++++++++++++++++++++" )
11281131
self.register_linktype( property_title, propuri, label, inverselabel=inverselabel, rdfuri=rdfuri, typeCodec=propcodec, isMultiValued=isMultiValued )
11291132
if True:
1130-
logger.info( f"Defining property {name}.{property_title} {propuri=} +++++++++++++++++++++++++++++++++++++++" )
1131-
# print( f"Defining property {name}.{property_title} {propuri=} {uri=} +++++++++++++++++++++++++++++++++++++++" )
1133+
logger.info( f"Defining property {name}.{property_title} {propuri=} {propcodec=} +++++++++++++++++++++++++++++++++++++++" )
1134+
print( f"Defining property {name}.{property_title} {propuri=} {uri=} {propcodec=} +++++++++++++++++++++++++++++++++++++++" )
11321135
# self.register_property(property_title,propuri, shape_uri=uri)
11331136

11341137
# if property_title=="Residual POHS":
11351138
# print( ET.tostring( el ) )
11361139
# need to work out the codec
11371140

1138-
self.register_property( property_title, propuri, isMultiValued=isMultiValued, shape_uri=uri )
1141+
# too late self.register_property( property_title, propuri, isMultiValued=isMultiValued, shape_uri=uri )
11391142
# load the attribute definitions
11401143
n += 1
11411144
for range_el in rdfxml.xml_find_elements(el, 'oslc:range'):

elmclient/_typesystem.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ def is_known_linktype_uri( self, uri ):
179179

180180
def register_shape( self, shape_name, shape_uri, *, rdfuri=None, shape_formats=None ):
181181
logger.info( f"register_shape {shape_name=} {shape_uri=}" )
182+
print( f"register_shape {shape_name=} {shape_uri=}" )
182183
shape_uri = self.normalise_uri( shape_uri)
183184
if shape_uri in self.shapes:
184185
raise Exception( f"Shape {shape_uri} already defined!" )
@@ -221,7 +222,7 @@ def is_known_property_uri( self, property_uri, *, raiseifnotfound=True ):
221222
# def register_property( self, property_name, property_uri, *, property_value_type=None, shape_uri=None, altname = None, do_not_overwrite=True, property_definition_uri=None, isMultiValued=False, typeCodec=None ):
222223
def register_property( self, property_name, property_uri, *, shape_uri=None, property_value_type=None, altname = None, do_not_overwrite=True, property_definition_uri=None, isMultiValued=False, typeCodec=None ):
223224
logger.info( f"register_property {property_name=} {property_uri=} {isMultiValued=} {typeCodec=}" )
224-
# print( f"register_property {property_name=} {property_uri=} {isMultiValued=} {typeCodec=}" )
225+
print( f"register_property {property_name=} {property_uri=} {isMultiValued=} {typeCodec=}" )
225226
if property_uri in self.properties:
226227
# print( f"Already defined {self.properties[property_uri]=}" )
227228
# burp

0 commit comments

Comments
 (0)