Creating a Requirement

Once you have instantiated an OSLC client, you can use the CreateRequirement class to create a new requirement in DOORS Next.

Identifying the creation factory

The CreateRequirement class uses the URI of a creation factory for requesting the creation of a new artifact. Creation factories are declared by the service provider representing the DOORS Next project.

Filtering the creation factory for requirements

A service provider declares multiple creation factories, at minimum one to create requirements and another one to create requirement collections. To create requirements, filter the list of creation factories to retain only the ones declaring this property:

<oslc:resourceType rdf:resource=""/>

This can be done using the following APIs:

List<CreationFactory> creationFactories = OslcCore.Finder.forServices(serviceProvider)

Filtering the creation factory for a specific component

If the DOORS Next project has not enabled configuration management, only one creation factory for requirements will be declared by the service provider.

If configuration management is enabled, the DOORS Next project might be partitioned into multiple Components. When a service provider is requested, a configuration should be set as an oslc_config.context query parameter to indicate which configuration (and therefore which component) to use. In this case, the service provider response varies depending on the given configuration.

If a local configuration is used, only one creation factory for requirements will be declared, as the configuration refers to one unique component.

If a global configuration is used, a creation factory will be declared for each DOORS Next Component involved in the global configuration. To retrieve the creation factory for a specific component, filter the list of creation factories to retain the one declaring the following property, whose value is the component of interest:

<oslc_config:component rdf:resource="https://server/rm/cm/component/_vPSCUDGdEeyLa9w5e-sjzg"/>

This can be done using the following APIs:

CreationFactory creationFactory = OslcCore.Finder.forServices(serviceProvider)
	.predicate((factory) -> myComponentUri.equals(ResourceProperties.getURI(factory, OslcConfig.PROPERTY_COMPONENT)))

Using CreateRequirement request

The requirement is to be created in a DOORS Next folder. If the created requirement is to be used only in a specific module, you are recommended to use the Module.getAssetFolder() method to determine the default folder in which to create such artifact. The InsertRequirement class can be used to add a newly created requirement into a module.

	OslcClient client = OslcClients.jazzForm(new UsernamePasswordCredentials("myUser", "myPassword")).create();
	CreationFactory creationFactory = ...; // creation factory for requirements, as defined by a service provider
	requirement.setTitle("My Requirement ");
	requirement.setPrimaryText("<div xmlns=\"\">This is the text of requirement</b></div>");
	ResourceResponse<Void> response = new CreateRequirement(client, creationFactory.getCreation(), requirement).call();
	System.out.println("URI of the requirement: " + response.getHeaders().getFirst("Location"));

Related concepts

Related tasks
Creating an OSLC client
Using OSLC Configurations
Inserting a Requirement in a Module

Related reference
API Reference