Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/test-jazz_net.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ mvn -B exec:java -Dexec.mainClass="org.eclipse.lyo.samples.client.EWMSample" -De
-user ${JAZZ_NET_USERNAME} -password \"${JAZZ_NET_PASSWORD}\" \
-project \"${JAZZ_NET_PROJECT_NAME}\" --basic"

# ERM
# # ERM
mvn -B exec:java -Dexec.mainClass="org.eclipse.lyo.samples.client.ERMSample" -Dexec.args="-url https://jazz.net/${JAZZ_NET_PROJECT_ID}-rm/ \
-user ${JAZZ_NET_USERNAME} -password \"${JAZZ_NET_PASSWORD}\" \
-project \"smarx721 Project (Requirements Management)\" --basic"
Expand Down
10 changes: 6 additions & 4 deletions lyo-client-samples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,8 @@
<artifactId>httpclient</artifactId>
</dependency>
<dependency>
<!-- legacy, not planned for BOM -->
<groupId>org.eclipse.lyo.clients</groupId>
<artifactId>oslc-java-client-resources</artifactId>
<version>${v.lyo}</version>
<groupId>org.eclipse.lyo</groupId>
<artifactId>oslc-domains</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.lyo.server</groupId>
Expand All @@ -266,6 +264,10 @@
<artifactId>slf4j-reload4j</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@
import org.apache.http.ssl.SSLContextBuilder;
import org.eclipse.lyo.client.OSLCConstants;
import org.eclipse.lyo.client.OslcClient;
import org.eclipse.lyo.client.oslc.resources.ChangeRequest;
import org.eclipse.lyo.client.query.OslcQuery;
import org.eclipse.lyo.client.query.OslcQueryParameters;
import org.eclipse.lyo.client.query.OslcQueryResult;
import org.eclipse.lyo.oslc.domains.Oslc_cmVocabularyConstants;
import org.eclipse.lyo.oslc.domains.cm.ChangeRequest;
import org.glassfish.jersey.apache.connector.ApacheConnectorProvider;
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
Expand Down Expand Up @@ -118,11 +119,15 @@ public static void main(String[] args) throws ParseException {
// STEP 3: Get the Query Capabilities and Creation Factory URLs so that we can run some
// OSLC queries
String queryCapability = client.lookupQueryCapability(
serviceProviderUrl, OSLCConstants.OSLC_CM_V2, OSLCConstants.CM_CHANGE_REQUEST_TYPE);
serviceProviderUrl,
Oslc_cmVocabularyConstants.CHANGE_MANAGEMENT_VOCAB_NAMSPACE,
Oslc_cmVocabularyConstants.TYPE_CHANGEREQUEST);
System.out.println("queryCapability: " + queryCapability);

String creationFactory = client.lookupCreationFactory(
serviceProviderUrl, OSLCConstants.OSLC_CM_V2, OSLCConstants.CM_CHANGE_REQUEST_TYPE);
serviceProviderUrl,
Oslc_cmVocabularyConstants.CHANGE_MANAGEMENT_VOCAB_NAMSPACE,
Oslc_cmVocabularyConstants.TYPE_CHANGEREQUEST);
System.out.println("creationFactory: " + creationFactory);

// SCENARIO A: Run a query for all ChangeRequests
Expand All @@ -148,7 +153,7 @@ public static void main(String[] args) throws ParseException {
// SCENARIO C: ChangeRequest creation and update
ChangeRequest newChangeRequest = new ChangeRequest();
newChangeRequest.setTitle("Update database schema");
newChangeRequest.setTitle("Need to update the database schema to reflect the data model changes");
newChangeRequest.setDescription("Need to update the database schema to reflect the data model changes");

rawResponse = client.createResource(creationFactory, newChangeRequest, OSLCConstants.CT_RDF);
int statusCode = rawResponse.getStatus();
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@
import org.eclipse.lyo.client.OslcClient;
import org.eclipse.lyo.client.RootServicesHelper;
import org.eclipse.lyo.client.exception.RootServicesException;
import org.eclipse.lyo.client.oslc.resources.TestCase;
import org.eclipse.lyo.client.oslc.resources.TestResult;
import org.eclipse.lyo.client.query.OslcQuery;
import org.eclipse.lyo.client.query.OslcQueryParameters;
import org.eclipse.lyo.client.query.OslcQueryResult;
import org.eclipse.lyo.oslc.domains.Oslc_qmVocabularyConstants;
import org.eclipse.lyo.oslc.domains.qm.TestCase;
import org.eclipse.lyo.oslc.domains.qm.TestResult;
import org.eclipse.lyo.oslc4j.core.model.Link;
import org.eclipse.lyo.oslc4j.core.model.OslcMediaType;
import org.glassfish.jersey.apache.connector.ApacheClientProperties;
Expand Down Expand Up @@ -135,15 +136,19 @@ public static void main(String[] args) throws ParseException {

// STEP 4: Get the URL of the OSLC ChangeManagement service from the rootservices
// document
String catalogUrl = new RootServicesHelper(webContextUrl, OSLCConstants.OSLC_QM_V2, client).getCatalogUrl();
String catalogUrl = new RootServicesHelper(
webContextUrl, Oslc_qmVocabularyConstants.QUALITY_MANAGEMENT_NAMSPACE, client)
.getCatalogUrl();
logger.info("Using %s catalog URI".formatted(catalogUrl));

// STEP 5: Find the OSLC Service Provider for the project area we want to work with
String serviceProviderUrl = client.lookupServiceProviderUrl(catalogUrl, projectArea);

// STEP 6: Get the Query Capabilities URL so that we can run some OSLC queries
String queryCapability = client.lookupQueryCapability(
serviceProviderUrl, OSLCConstants.OSLC_QM_V2, OSLCConstants.QM_TEST_RESULT_QUERY);
serviceProviderUrl,
Oslc_qmVocabularyConstants.QUALITY_MANAGEMENT_NAMSPACE,
Oslc_qmVocabularyConstants.TYPE_TESTRESULT);

// SCENARIO A: Run a query for all TestResults with a status of passed with OSLC paging
// of 10 items per
Expand All @@ -154,7 +159,7 @@ public static void main(String[] args) throws ParseException {

System.out.println("Running query: " + query.getQueryUrl());
OslcQueryResult result = query.submit();
result.setMemberProperty(OSLCConstants.OSLC_QM_V2 + "testResult");
result.setMemberProperty(Oslc_qmVocabularyConstants.QUALITY_MANAGEMENT_NAMSPACE + "testResult");

boolean processAsJavaObjects = true;
processPagedQueryResults(result, client, processAsJavaObjects);
Expand All @@ -170,7 +175,7 @@ public static void main(String[] args) throws ParseException {
OslcQuery query2 = new OslcQuery(client, queryCapability, queryParams2);

OslcQueryResult result2 = query2.submit();
result2.setMemberProperty(OSLCConstants.OSLC_QM_V2 + "testResult");
result2.setMemberProperty(Oslc_qmVocabularyConstants.QUALITY_MANAGEMENT_NAMSPACE + "testResult");
Response rawResponse = result2.getRawResponse();
processRawResponse(rawResponse);

Expand All @@ -184,7 +189,9 @@ public static void main(String[] args) throws ParseException {

// Get the Creation Factory URL for test cases so that we can create a test case
String testcaseCreation = client.lookupCreationFactory(
serviceProviderUrl, OSLCConstants.OSLC_QM_V2, testcase.getRdfTypes()[0].toString());
serviceProviderUrl,
Oslc_qmVocabularyConstants.QUALITY_MANAGEMENT_NAMSPACE,
Oslc_qmVocabularyConstants.TYPE_TESTCASE);

// Create the test case
Response creationResponse =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.io.InputStreamReader;
import java.net.URI;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import javax.xml.namespace.QName;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.cli.CommandLine;
Expand All @@ -43,27 +44,32 @@
import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
import org.apache.http.ssl.SSLContextBuilder;
import org.eclipse.lyo.client.JEEFormAuthenticator;
import org.eclipse.lyo.client.OSLCConstants;
import org.eclipse.lyo.client.OslcClient;
import org.eclipse.lyo.client.RootServicesHelper;
import org.eclipse.lyo.client.exception.RootServicesException;
import org.eclipse.lyo.client.oslc.resources.ChangeRequest;
import org.eclipse.lyo.client.query.OslcQuery;
import org.eclipse.lyo.client.query.OslcQueryParameters;
import org.eclipse.lyo.client.query.OslcQueryResult;
import org.eclipse.lyo.oslc.domains.Oslc_cmVocabularyConstants;
import org.eclipse.lyo.oslc.domains.cm.ChangeRequest;
import org.eclipse.lyo.oslc.domains.cm.Defect;
import org.eclipse.lyo.oslc4j.core.model.AllowedValues;
import org.eclipse.lyo.oslc4j.core.model.CreationFactory;
import org.eclipse.lyo.oslc4j.core.model.Link;
import org.eclipse.lyo.oslc4j.core.model.OslcMediaType;
import org.eclipse.lyo.oslc4j.core.model.Property;
import org.eclipse.lyo.oslc4j.core.model.ResourceShape;
import org.eclipse.lyo.oslc4j.provider.jena.AbstractOslcRdfXmlProvider;
import org.eclipse.lyo.oslc4j.provider.jena.JenaModelHelper;
import org.eclipse.lyo.samples.client.resources.JazzChangeRequest;
import org.glassfish.jersey.apache.connector.ApacheClientProperties;
import org.glassfish.jersey.apache.connector.ApacheConnectorProvider;
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
import org.glassfish.jersey.logging.LoggingFeature;
import org.glassfish.jersey.media.multipart.MultiPartFeature;
import org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException;
import org.slf4j.bridge.SLF4JBridgeHandler;

/**
* Samples of logging in to IBM Enterprise Workflow Manager and running OSLC operations
Expand All @@ -85,6 +91,8 @@ public class EWMSample {
*/
public static void main(String[] args) throws ParseException {

SLF4JBridgeHandler.install();

Options options = new Options();

options.addOption("url", true, "url");
Expand Down Expand Up @@ -163,14 +171,23 @@ public static void main(String[] args) throws ParseException {
log.info("Using JAS (Forms) authentication");
}

if (log.isTraceEnabled()) {
var clientLogger = java.util.logging.Logger.getLogger("");
clientLogger.setLevel(Level.FINEST);
clientBuilder.register(
new LoggingFeature(clientLogger, Level.INFO, LoggingFeature.Verbosity.PAYLOAD_ANY, null));
}

// STEP 3: Create a new OslcClient
log.debug("STEP 3: Create a new OslcClient");
OslcClient client = new OslcClient(clientBuilder);

// STEP 4: Get the URL of the OSLC ChangeManagement service from the rootservices
// document
log.debug("STEP 4: Get the URL of the OSLC ChangeManagement service from the rootservices" + " document");
String catalogUrl = new RootServicesHelper(webContextUrl, OSLCConstants.OSLC_CM_V2, client).getCatalogUrl();
String catalogUrl = new RootServicesHelper(
webContextUrl, Oslc_cmVocabularyConstants.CHANGE_MANAGEMENT_VOCAB_NAMSPACE, client)
.getCatalogUrl();

// STEP 5: Find the OSLC Service Provider for the project area we want to work with
log.debug("STEP 5: Find the OSLC Service Provider for the project area we want to work" + " with");
Expand All @@ -179,7 +196,9 @@ public static void main(String[] args) throws ParseException {
// STEP 6: Get the Query Capabilities URL so that we can run some OSLC queries
log.debug("STEP 6: Get the Query Capabilities URL so that we can run some OSLC queries");
String queryCapability = client.lookupQueryCapability(
serviceProviderUrl, OSLCConstants.OSLC_CM_V2, OSLCConstants.CM_CHANGE_REQUEST_TYPE);
serviceProviderUrl,
Oslc_cmVocabularyConstants.CHANGE_MANAGEMENT_VOCAB_NAMSPACE,
Oslc_cmVocabularyConstants.TYPE_CHANGEREQUEST);

// SCENARIO A: Run a query for all open ChangeRequests with OSLC paging of 10 items per
// page turned on and list the members of the result
Expand Down Expand Up @@ -209,20 +228,36 @@ public static void main(String[] args) throws ParseException {
rawResponse.close();

// SCENARIO C: EWM task creation and update
ChangeRequest task = new ChangeRequest();
var task = new JazzChangeRequest();
task.setTitle("Implement accessibility in Pet Store application");
task.setDescription("Image elements must provide a description in the 'alt' attribute for"
+ " consumption by screen readers.");
task.addTestedByTestCase(new Link(
new URI("http://qmprovider/testcase/1"), "Accessibility verification using a screen reader"));
task.addDctermsType("task");
// task.getExtendedProperties()
// .put(new QName(DctermsDomainConstants.DUBLIN_CORE_NAMSPACE, "type"), Set.of("Task"));

task.setDctermsTypes(new String[] {"Task"});

// TODO: clean up when https://github.com/eclipse-lyo/lyo/issues/783 is fixed
// task.getExtendedProperties()
// .put(
// new QName(Oslc_cmVocabularyConstants.CHANGE_MANAGEMENT_VOCAB_NAMSPACE,
// "testedByTestCase"),
// // new URI("http://qmprovider/testcase/1")
// Set.of(new Link(
// new URI("http://qmprovider/testcase/1"),
// "Accessibility verification using a screen reader")));

task.setTestedByTestCases(new Link[] {
new Link(new URI("http://qmprovider/testcase/1"), "Accessibility verification using a screen reader")
});

// Get the Creation Factory URL for task change requests so that we can create one
CreationFactory taskCreation = client.lookupCreationFactoryResource(
serviceProviderUrl,
OSLCConstants.OSLC_CM_V2,
task.getRdfTypes()[0].toString(),
OSLCConstants.OSLC_CM_V2 + "task");
Oslc_cmVocabularyConstants.CHANGE_MANAGEMENT_VOCAB_NAMSPACE,
Oslc_cmVocabularyConstants.TYPE_CHANGEREQUEST,
// not capital Task - this is a usage, not a type
Oslc_cmVocabularyConstants.CHANGE_MANAGEMENT_VOCAB_NAMSPACE + "task");
String factoryUrl = taskCreation.getCreation().toString();

// Determine what to use for the Filed Against attribute by requesting the resource
Expand All @@ -240,6 +275,15 @@ public static void main(String[] args) throws ParseException {
AllowedValues allowedValues = allowedValuesResponse.readEntity(AllowedValues.class);
Object[] values = allowedValues.getValues().toArray();
task.getExtendedProperties().put(new QName(RTC_NAMESPACE, RTC_FILED_AGAINST), (URI) values[0]);
} else {
log.warn("RTC_FILED_AGAINST was not found in the shape for the creation factory for tasks");
}

if (log.isDebugEnabled()) {
var model = JenaModelHelper.createJenaModel(new Object[] {task});
model.write(System.out, "RDFXML");

System.out.println();
}

// Create the change request
Expand All @@ -255,7 +299,7 @@ public static void main(String[] args) throws ParseException {
System.out.println("Task created at location " + changeRequestLocation);

// Get the change request from the service provider and update its title property
task = client.getResource(changeRequestLocation).readEntity(ChangeRequest.class);
task = client.getResource(changeRequestLocation).readEntity(JazzChangeRequest.class);
task.setTitle(task.getTitle() + " (updated)");

// Create a partial update URL so that only the title will be updated.
Expand All @@ -269,19 +313,21 @@ public static void main(String[] args) throws ParseException {
updateResponse.readEntity(String.class);

// SCENARIO D: RTC defect creation
ChangeRequest defect = new ChangeRequest();
Defect defect = new Defect();
defect.setTitle("Error logging in");
defect.setDescription(
"An error occurred when I tried to log in with a user ID that contained the '@'" + " symbol.");
defect.addTestedByTestCase(new Link(new URI("http://qmprovider/testcase/3"), "Global Verifcation Test"));
defect.addDctermsType("defect");
defect.getExtendedProperties()
.put(
new QName(Oslc_cmVocabularyConstants.CHANGE_MANAGEMENT_VOCAB_NAMSPACE, "testedByTestCase"),
new URI("http://qmprovider/testcase/3"));

// Get the Creation Factory URL for change requests so that we can create one
CreationFactory defectCreation = client.lookupCreationFactoryResource(
serviceProviderUrl,
OSLCConstants.OSLC_CM_V2,
defect.getRdfTypes()[0].toString(),
OSLCConstants.OSLC_CM_V2 + "defect");
Oslc_cmVocabularyConstants.CHANGE_MANAGEMENT_VOCAB_NAMSPACE,
Oslc_cmVocabularyConstants.TYPE_DEFECT,
Oslc_cmVocabularyConstants.CHANGE_MANAGEMENT_VOCAB_NAMSPACE + Oslc_cmVocabularyConstants.DEFECT);
factoryUrl = defectCreation.getCreation().toString();

// Determine what to use for the Filed Against attribute by requesting the resource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@
import org.apache.http.HttpStatus;
import org.eclipse.lyo.client.OSLCConstants;
import org.eclipse.lyo.client.OslcClient;
import org.eclipse.lyo.client.oslc.resources.Requirement;
import org.eclipse.lyo.client.query.OslcQuery;
import org.eclipse.lyo.client.query.OslcQueryParameters;
import org.eclipse.lyo.client.query.OslcQueryResult;
import org.eclipse.lyo.oslc.domains.Oslc_rmVocabularyConstants;
import org.eclipse.lyo.oslc.domains.rm.Requirement;

/**
* Samples of accessing a generic Requirements Management provider and running OSLC operations.
Expand Down Expand Up @@ -87,10 +88,14 @@ public static void main(String[] args) throws ParseException {
// STEP 3: Get the Query Capabilities and Creation Factory URLs so that we can run some
// OSLC queries
String queryCapability = client.lookupQueryCapability(
serviceProviderUrl, OSLCConstants.OSLC_RM_V2, OSLCConstants.RM_REQUIREMENT_TYPE);
serviceProviderUrl,
Oslc_rmVocabularyConstants.REQUIREMENTS_MANAGEMENT_VOCABULARY_NAMSPACE,
Oslc_rmVocabularyConstants.TYPE_REQUIREMENT);

String creationFactory = client.lookupCreationFactory(
serviceProviderUrl, OSLCConstants.OSLC_RM_V2, OSLCConstants.RM_REQUIREMENT_TYPE);
serviceProviderUrl,
Oslc_rmVocabularyConstants.REQUIREMENTS_MANAGEMENT_VOCABULARY_NAMSPACE,
Oslc_rmVocabularyConstants.TYPE_REQUIREMENT);

// SCENARIO A: Run a query for all Requirements

Expand All @@ -115,7 +120,7 @@ public static void main(String[] args) throws ParseException {
// SCENARIO C: Requirement creation and update
Requirement newRequirement = new Requirement();
newRequirement.setTitle("Database schema needs new attributes");
newRequirement.setTitle("The data model needs to support new attributes");
newRequirement.setDescription("The data model needs to support new attributes");

rawResponse = client.createResource(creationFactory, newRequirement, OSLCConstants.CT_RDF);
int statusCode = rawResponse.getStatus();
Expand Down
Loading