ELM-Python-Client icon indicating copy to clipboard operation
ELM-Python-Client copied to clipboard

RM Update artifact with a custom attribute

Open rafaelrmontes opened this issue 2 years ago • 5 comments

Hi, I was able to update the primary text using update artifact for a Requirement Artifact, and I'm looking to find out how to search the tags for a custom attributes, I saw the print out of the tags, but nothing comes familiar in the available tags when "print(f"{ET.tostring(theartifact_x)=}\n")" after

now get the artifact content and its etag

theartifact_x, etag = c.execute_get_rdf_xml(theartifact_u, return_etag=True, intent="Retrieve the artifact")

is the there a specific resource I need to sub-navigate to find out the custom attributes? Thank you

rafaelrmontes avatar Dec 13 '23 00:12 rafaelrmontes

The custom attributes won't be in the rdf unless they have a value on the artifact you're retrieving.

barny avatar Dec 13 '23 08:12 barny

is th

The custom attributes won't be in the rdf unless they have a value on the artifact you're retrieving.

is there any parameter in the get_rdf can be pass to obtain the tags for custom attributes?

rafaelrmontes avatar Dec 13 '23 15:12 rafaelrmontes

There's nothing special needed in get_rdf but note you won't see the attribute in the rdf unless you give the attribute a value on the artifact you're getting the rdf for, so give your attribute a value on an artifact, then get the rdf for that artifact and you'll see the value.

If you give the attribute a URI then that URI will be used as the tag for the value.

barny avatar Dec 21 '23 12:12 barny

Thank you for your response, in the Attribute definition of the project, the fields are blank that means that I need to assign an uri following a standard, then use it in the theartifact_u right? Thank you!

rafaelrmontes avatar Jan 30 '24 17:01 rafaelrmontes

Apologies I haven't got back to you earlier. When you assign your custom attribute a URI then the URI is used as the XML tag for a value of that attribute in the RDF.

If a custom attribute has a value on an artifact then there will be a tag in the RDF.

For example if myAtt has a URI http://me.com/at/atts/myAtt then when the attribute has a value in the rdf there will be a tag like

<f2:myAtt>this is a custom attribute</f2:myAtt>

where the namespace f2 is automatically created as xmlns:f2="http://me.com/atts/"

If you don't assign a URI to the attribute you get something which appears more random but which can be found in the shapes, for example rt:AD_746qMAyGEe-t-Jenc0Ir8wthis attribute doesn't have a URI yet</rt:AD_746qMAyGEe-t-Jenc0Ir8w>

But as you can see, with the URI it gets a lot easier to locate a custom attribute, for example using xpath something like (not tested):

attvalue_x = theartifact_x.find( ".//{http://me.com/atts/}myAtt" ) attvalue = attvalue_x.text() if attvalue_x else None

If using oslcquery note that it caches typesystem for 7 days so won't pick up recent changes; use -W to clear the cache.

barny avatar May 07 '24 15:05 barny