Once you have instantiated an OSLC client, you can use the CreateRequirement class to create a new requirement in DOORS Next.
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.
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="http://open-services.net/ns/rm#Requirement"/>
This can be done using the following APIs:
List<CreationFactory> creationFactories = OslcCore.Finder.forServices(serviceProvider) .domain(URI.create(OslcRm.DOMAIN)) .resourceType(URI.create(OslcRm.TYPE_REQUIREMENT)) .findAll()
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) .domain(URI.create(OslcRm.DOMAIN)) .resourceType(URI.create(OslcRm.TYPE_REQUIREMENT)) .predicate((factory) -> myComponentUri.equals(ResourceProperties.getURI(factory, OslcConfig.PROPERTY_COMPONENT))) .findFirst()
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=\"http://www.w3.org/1999/xhtml\">This is the text of requirement</b></div>"); requirement.setParentFolder(folderUri); requirement.setInstanceShape(creationFactory.getResourceShapes()[0]); ResourceResponse<Void> response = new CreateRequirement(client, creationFactory.getCreation(), requirement).call(); System.out.println("URI of the requirement: " + response.getHeaders().getFirst("Location"));
Creating an OSLC client
Using OSLC Configurations
Inserting a Requirement in a Module