It's all about the answers!

Ask a question

List artifact attributes of a project in Doors Next using OSLC query or Rest API


Root 07 (212) | asked Apr 17 '23, 9:03 a.m.
edited Apr 18 '23, 3:47 a.m.

 I need to read all attributes that i have in a project in Doors Next. Then write a new URI for each attribute.

What i have achieved so far is to read all projects that I have in the server and then select a project and return its name. I want then to read the attributes of the selected project.
The code below is working fine until the point of reading attributes where it returns nothing, can you help me figure out how to read the attributes of the selected project.

// Send a new GET request to retrieve all attributes of the selected project
                             HttpGet projectAreaDoc = new HttpGet(serviceProviderUrl);
                             projectAreaDoc.addHeader("Accept", "application/xml");
                             projectAreaDoc.addHeader("OSLC-Core-Version", "2.0");
                             HttpResponse projectAreaResponse = HttpUtils.sendGetForSecureDocument(
                                     server, projectAreaDoc, login, password, HttpClient, JTS_Server);
                             
                             InputSource source2 = new InputSource(projectAreaResponse.getEntity().getContent());
                     
                             // Define the XPath evaluation environment for the project area document
                            XPath xpath3 = factory.newXPath();
                            xpath3.setNamespaceContext(new NamespaceContextMap(new String[] {
                                         "oslc_rm", "http://open-services.net/xmlns/rm/1.0/",
                                         "dcterms", "http://purl.org/dc/terms/",
                                         "oslc", "http://open-services.net/ns/core#",
                                         "rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
                                 }));
                     
                                 // Parse the response body to retrieve all attributes of the selected project
                                 NodeList propertyNodes = (NodeList) xpath3.evaluate("/oslc_rm:properties/*", source2, XPathConstants.NODESET);
                                 int propertyCount = propertyNodes.getLength();
                                 System.out.println(">> Attributes of the selected project area:");
                                 for (int i = 0; i < propertyCount; i++) {
                                     Node propertyNode = propertyNodes.item(i);
                                     String propertyName = propertyNode.getNodeName();
                                     String propertyValue = propertyNode.getTextContent();
                                     System.out.println(">> \t" + propertyName + ": " + propertyValue);
                                 }


Comments
David Honey commented Apr 17 '23, 9:30 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
I think it would be easier for forum contributors to respond if you stated what HTTP reequests you are making rather than expect them to reverse engineer that from your code. For each request, provide the request URI, headers and for PUT/POST the request body, and then what response did you get including headers and response body.

It's also unclear what you mean by:
Then write a new URI for each attribute.
If you mean you want to change the RDF external URI of artifact attributes, you should consider this very carefully to achieve compatible evolution of your DOOR Next type system. Remember that DOORS Next has a versioned type system. You can only change such properties of an artifact attribute in the context of a stream. Earlier baselines will continue to use the state of the type system that applied at the time the baseline was created.


Root 07 commented Apr 18 '23, 3:54 a.m.

Thank you for your response. I have edited the code.

By writing a new URI for each attribute, I mean in our server we have a lot of migrated projects from DOORS to DOORS Next that don't have the data model well set. I mean all attributes and attribute types are missing URIs which causing us problems with import/export. Therefore we decided to create a script to add all URIs for the selected project. Now do you think this is possible using Rest API or OSLC query ? 
Hint: In the service catalog, I don't find "oslc_rm:properties" 

2 answers



permanent link
Ralph Schoon (63.3k33646) | answered Apr 20 '23, 5:41 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Apr 20 '23, 5:41 a.m.


 As far as I can tell, there is no project administration/type system administration API available. We toyed around with the apis to automate delivering the type system or importing it, which might a feasible approach to distribute a fixed/consolidated type system. See https://rsjazz.wordpress.com/2019/03/07/type-system-manager-part-2/ . You would have to manage the changes using the tool. Obviously this is something that you should experiment with on a test server until you are confident what you try to do is working.   


Comments
David Honey commented Apr 20 '23, 6:14 a.m. | edited Apr 20 '23, 6:15 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

I couldn't find any OSLC query cabilitities declared for artifact attributes in DN.
Also, when defining RDF URIs, you should try to reuse public vovabulary terms where possible, such as those from Dublin Core, W3C, OSLC etc, rather than inventing your own. If you do start using your own namespace for vocabulary terms, best practice is to make them readable - see https://jazz.net/wiki/bin/view/LinkedData/PublishRdfVocabularies. So deciding what URIs to use is something that has to be done manually.

What would make better sense is to define your type system in one place, get it to the desired state, and then use type export and import in DN to copy that to other project areas and components.


Ralph Schoon commented Apr 20 '23, 6:25 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

My understanding is, that OSLC only supports querying instances of requirements and other domain objects. You would see the attributes that have values. You can -  sort of - find the attributes in the creation factories, but this is no API to e.g. modify the URI or create a new attribute etc.


Root 07 commented Apr 24 '23, 7:27 a.m.

Thank you for your answering. Can you provide more details on how to find the attributes in the creation factory? That would be very appreciated.


Ralph Schoon commented Apr 24 '23, 7:42 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Consider to get the rootservices document, follow OSLC  and discover and GET the creation factory that defines all available attributes. 


David Honey commented Apr 24 '23, 5:21 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Can you provide more details on how to find the attributes in the creation factory? That would be very appreciated.

See https://docs.oasis-open-projects.org/oslc-op/core/v3.0/os/discovery.html#creationFactoryShape


Root 07 commented May 04 '23, 10:58 a.m.

Hello again, 

to Is there any other easy way to list the attributes that I have inside a project area?
I need to do that in a automated way or in other words using a script. Is this possible using Javascript ? 
Thank you in advance.
p.s. I wasn't able to use Creation Factory to list the attributes.


Ralph Schoon commented May 05 '23, 2:28 a.m. | edited May 05 '23, 2:37 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Sorry, I meant the resource shape, not the creation factory https://docs.oasis-open-projects.org/oslc-op/core/v3.0/os/resource-shape.html . For OSLC, that is best I can do. I do not know about the JavaScript API. 

showing 5 of 7 show 2 more comments

permanent link
Ian Barnard (2.0k613) | answered May 05 '23, 7:08 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
You may find it simplest to do the process of adding URIs manually and very carefully to ensure consistency where there needs to be consistency and also differentiation where there needs to be differentiation.

Attributes aren't directly exposed in the OSLC API. What is exposed are the shapes (i.e. artifact types) and using these you can find the OSLC properties of each shape which is basically the attributes.


HOWEVER I don't believe it's possible to modify these - but you could at least report them

Manage the typesystem carefully - the best way to ensure consistency across components is to NEVER edit the types in a project component but to have a single central definition of your typesystem in a single component (which is used only for the typesystem) which you very carefully manage changes to, then import these central definitions into each component.


As it says in that article: "Ensure that each type system element (all artifacts, attributes, attribute data types, attribute data type values, and link types) in each type system has an associated URI"

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.