Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RM Update artifact with a custom attribute #55

Open
rafaelrmontes opened this issue Dec 13, 2023 · 5 comments
Open

RM Update artifact with a custom attribute #55

rafaelrmontes opened this issue Dec 13, 2023 · 5 comments

Comments

@rafaelrmontes
Copy link

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

@barny
Copy link
Member

barny commented Dec 13, 2023

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

@rafaelrmontes
Copy link
Author

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?

@barny
Copy link
Member

barny commented Dec 21, 2023

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.

@rafaelrmontes
Copy link
Author

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!

@barny
Copy link
Member

barny commented May 7, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants