### Quarkus Application Configuration (YAML) Source: https://github.com/openepcis/openepcis-snippet-service/blob/main/README.md Illustrative example of Quarkus application configuration using YAML, typically found in src/main/resources/application.yml. This section references a guide on configuration examples. ```yaml # Example YAML configuration for Quarkus # quarkus.http.port=8080 # quarkus.datasource.url=jdbc:h2:mem:test;DB_CLOSE_DELAY=-1 # quarkus.datasource.driverClass=org.h2.Driver # quarkus.datasource.username=sa # quarkus.datasource.password= ``` -------------------------------- ### Get Snippets API Request Example Source: https://github.com/openepcis/openepcis-snippet-service/blob/main/README.md Example HTTP GET request for the /snippet endpoint, optionally including a searchText query parameter to filter results. ```shell GET /snippet?searchText=CPI ``` -------------------------------- ### Java EPCIS Query Service Example Source: https://github.com/openepcis/openepcis-snippet-service/blob/main/src/main/resources/META-INF/resources/index.html This snippet demonstrates how to query an EPCIS repository using Java. It includes setting up the connection, constructing a query, and processing the results. Dependencies include the OpenEPCIS client library. ```Java import org.openepcis.client.EPCISClient; import org.openepcis.client.EPCISQueryClient; import org.openepcis.model.epcis.v2.EPCISDocumentType; public class EPCISQueryExample { public static void main(String[] args) { // Replace with your EPCIS repository URL String epcisRepositoryUrl = "http://localhost:8080/epcis"; EPCISQueryClient queryClient = new EPCISQueryClient(epcisRepositoryUrl); try { // Example query: Get all events String query = "SELECT ?event WHERE { ?event a epcis:Event . };"; EPCISDocumentType results = queryClient.query(query); // Process the results if (results != null && results.getEPCISBody() != null && results.getEPCISBody().getEventList() != null) { results.getEPCISBody().getEventList().forEach(event -> { System.out.println("Found Event: " + event.getType()); // Further processing of the event }); } else { System.out.println("No events found or an error occurred."); } } catch (Exception e) { System.err.println("Error querying EPCIS repository: " + e.getMessage()); e.printStackTrace(); } } } ``` -------------------------------- ### Shell Snippet: Running OpenEPCIS Service Source: https://github.com/openepcis/openepcis-snippet-service/blob/main/src/main/resources/META-INF/resources/index.html This shell command demonstrates how to run the OpenEPCIS snippet service. It likely involves executing a Java JAR file, potentially with specific configurations or arguments to start the service. ```Shell java -jar openepcis-snippet-service-1.0.0.jar --server.port=8080 ``` -------------------------------- ### Java Snippet Service Example Source: https://github.com/openepcis/openepcis-snippet-service/blob/main/src/main/resources/META-INF/resources/index.html Demonstrates a basic Java implementation for a snippet service, likely used for executing or managing code snippets within the OpenEECS system. This example may involve core service logic and data handling. ```Java package org.openepcis.snippet; import org.openepcis.snippet.api.SnippetService; import org.openepcis.snippet.api.SnippetExecutionException; public class DefaultSnippetService implements SnippetService { @Override public String executeSnippet(String snippetId, String inputData) throws SnippetExecutionException { // Placeholder for actual snippet execution logic System.out.println("Executing snippet: " + snippetId + " with input: " + inputData); // In a real implementation, this would involve retrieving the snippet code, // setting up the execution environment, and running the code. // For demonstration, we'll return a simple success message. return "Snippet " + snippetId + " executed successfully."; } @Override public String getSnippet(String snippetId) { // Placeholder for retrieving snippet code System.out.println("Retrieving snippet: " + snippetId); // In a real implementation, this would fetch the snippet's source code from a storage. // For demonstration, we'll return a dummy snippet. return "// Dummy snippet code for " + snippetId + "\npublic void run() { System.out.println(\"Hello from snippet!\"); }"; } @Override public boolean registerSnippet(String snippetId, String snippetCode) { // Placeholder for registering a new snippet System.out.println("Registering snippet: " + snippetId + "\nCode: " + snippetCode); // In a real implementation, this would store the snippet code in a persistent storage. // For demonstration, we'll assume successful registration. return true; } @Override public boolean unregisterSnippet(String snippetId) { // Placeholder for unregistering a snippet System.out.println("Unregistering snippet: " + snippetId); // In a real implementation, this would remove the snippet from storage. // For demonstration, we'll assume successful unregistration. return true; } } ``` -------------------------------- ### Quarkus Application Configuration Example Source: https://github.com/openepcis/openepcis-snippet-service/blob/main/src/main/resources/META-INF/resources/index.html This snippet shows a typical configuration file for a Quarkus application using YAML format. It allows developers to set various application properties, including server ports and profiles. ```YAML quarkus: http: port: 8080 # Add other configurations here ``` -------------------------------- ### Quarkus REST Resource Example Source: https://github.com/openepcis/openepcis-snippet-service/blob/main/src/main/resources/META-INF/resources/index.html This snippet demonstrates a basic REST endpoint in a Quarkus application, typically defined using JAX-RS annotations. It's designed for creating web services and handling HTTP requests. ```Java import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; import jakarta.ws.rs.Produces; import jakarta.ws.rs.core.MediaType; @Path("/hello") public class GreetingResource { @GET @Produces(MediaType.TEXT_PLAIN) public String hello() { return "Hello from Quarkus!"; } } ``` -------------------------------- ### Save Snippet API Request Example Source: https://github.com/openepcis/openepcis-snippet-service/blob/main/README.md Example JSON payload for the POST /snippet API endpoint, representing a schema snippet for a CPI EPC URI. ```json { "$id": "https://openepcis.github.io/openepcis-event-sentry/json-schema-epcis-snippets/epc-uri-cpi-0.1.0.json", "$schema": "http://json-schema.org/draft-07/schema#", "description": "Specifies value for the epcList, childEPCs, inputEPCList, outputEPCList, or parentID field, expressed as a Component / Part Identifier (CPI) in EPC URI (URN) format, relevant for automotive and technical industries.", "title": "CPI EPC URI", "definitions": { "epc-uri-cpi": { "type": "string", "pattern": "^urn:epc:id:cpi:((\d{6}\.(\%2[3dfDF]|\%3[0-9]|\%4[1-9A-Fa-f]|\%5[0-9Aa]|[0-9A-Z-]){1,24})|(\d{7}\.(\%2[3dfDF]|\%3[0-9]|\%4[1-9A-Fa-f]|\%5[0-9Aa]|[0-9A-Z-]){1,23})|(\d{8}\.(\%2[3dfDF]|\%3[0-9]|\%4[1-9A-Fa-f]|\%5[0-9Aa]|[0-9A-Z-]){1,22})|(\d{9}\.(\%2[3dfDF]|\%3[0-9]|\%4[1-9A-Fa-f]|\%5[0-9Aa]|[0-9A-Z-]){1,21})|(\d{10}\.(\%2[3dfDF]|\%3[0-9]|\%4[1-9A-Fa-f]|\%5[0-9Aa]|[0-9A-Z-]){1,20})|(\d{11}\.(\%2[3dfDF]|\%3[0-9]|\%4[1-9A-Fa-f]|\%5[0-9Aa]|[0-9A-Z-]){1,19})|(\d{12}\.(\%2[3dfDF]|\%3[0-9]|\%4[1-9A-Fa-f]|\%5[0-9Aa]|[0-9A-Z-]){1,18}))\.[\d]{1,12}$" } } } ``` -------------------------------- ### Create Native Executable for OpenEPCIS Snippet Service Source: https://github.com/openepcis/openepcis-snippet-service/blob/main/README.md Maven command to create a native executable for the Quarkus application using GraalVM. An option to use a container for the build is also provided. ```shell mvn package -Dnative ``` ```shell mvn package -Dnative -Dquarkus.native.container-build=true ``` -------------------------------- ### Java EPCIS Data Processing Source: https://github.com/openepcis/openepcis-snippet-service/blob/main/src/main/resources/META-INF/resources/index.html This snippet demonstrates core functionalities for processing EPCIS data using Java. It includes examples of parsing, validating, and transforming EPCIS events. ```Java package org.openepcis.snippet; import org.openepcis.model.EPCISDocument; import org.openepcis.model.ObjectEvent; import org.openepcis.parser.api.EPCISParser; import org.openepcis.validation.api.EPCISValidator; import java.io.InputStream; public class EpcisProcessor { /** * Parses and validates an EPCIS document from an input stream. * @param inputStream The input stream containing the EPCIS data. * @return The parsed EPCISDocument object. * @throws Exception If parsing or validation fails. */ public EPCISDocument processEpcisData(InputStream inputStream) throws Exception { // Parse the EPCIS document EPCISDocument document = EPCISParser.parse(inputStream); // Validate the EPCIS document EPCISValidator.validate(document); // Example: Accessing an ObjectEvent if (!document.getEvents().isEmpty() && document.getEvents().get(0) instanceof ObjectEvent) { ObjectEvent objectEvent = (ObjectEvent) document.getEvents().get(0); System.out.println("Processing Object Event with EPC: " + objectEvent.getObject().get(0).getValue()); } return document; } // Add more methods for specific EPCIS event types or operations } ```