Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor onboarding-sdk-product setting java 17 #32

Merged
merged 7 commits into from
Nov 3, 2023
Merged
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
31 changes: 0 additions & 31 deletions .github/workflows/release_onboarding_sdk.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
name: Release onboarding sdk

on:
pull_request:
branches:
- develop
types: [ closed ]
paths:
- 'onboarding-sdk/**/src/**'

workflow_dispatch:

permissions:
packages: write
contents: write

jobs:
setup:
name: Release
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -31,28 +22,6 @@ jobs:
java-version: '17'
cache: maven

- name: Set patch
run: |
mvn build-helper:parse-version versions:set -pl onboarding-sdk -DnewVersion='${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.nextIncrementalVersion}'
mvn versions:commit -f onboarding-sdk/pom.xml
shell: bash

- name: Get Version
run: |
echo "VERSION=$(mvn -pl onboarding-sdk help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
echo "🆙 Bump Version to ${VERSION}"
shell: bash

- name: Push New Version
shell: bash
run: |
echo "${VERSION}"
git ls-files ./onboarding-sdk | grep 'pom.xml' | xargs git add
git config --global user.email "[email protected]"
git config --global user.name "selfcare-github-bot"
git commit -m "Bump onboarding SDK to version ${VERSION}" || exit 0
git push origin ${{ github.ref_name}}

- name: Build with Maven
run: mvn -B package -f onboarding-sdk/pom.xml
shell: bash
Expand Down
4 changes: 1 addition & 3 deletions onboarding-sdk/onboarding-sdk-azure-storage/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@
<parent>
<groupId>it.pagopa.selfcare</groupId>
<artifactId>onboarding-sdk</artifactId>
<version>0.0.4</version>
<version>0.1.0</version>
</parent>

<artifactId>onboarding-sdk-azure-storage</artifactId>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<azure-storage-blob-version>12.24.0</azure-storage-blob-version>
</properties>
Expand Down
2 changes: 1 addition & 1 deletion onboarding-sdk/onboarding-sdk-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>it.pagopa.selfcare</groupId>
<artifactId>onboarding-sdk</artifactId>
<version>0.0.4</version>
<version>0.1.0</version>
</parent>
<artifactId>onboarding-sdk-common</artifactId>
<name>onboarding-sdk-common</name>
Expand Down
133 changes: 21 additions & 112 deletions onboarding-sdk/onboarding-sdk-product/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

This library has been developed to provide a set of Java utility classes to simplify the work of handle **Selfcare Product** as string.

Selfcare Products is a collection of PagoPA products available for use by institutions. Each product contains specific information, such as its status, admitted role, or a filepath template for building contract necessary for selfcare business logic.

The Onboarding SDK Product offers a set of classes designed for managing this collection of records using a file.

## Installation

To use this library in your projects, you can add the dependency to your pom.xml if you're using Maven:
Expand All @@ -23,117 +27,7 @@ dependencies {
```
## Product JSON Schema

Product string which are used by ProductService must follow a specific schema:

```
{
"type" : "record",
"name" : "Product",
"namespace" : "it.pagopa.selfcare.product.entity",
"fields" : [ {
"name" : "id",
"type" : [ "string" ]
}, {
"name" : "logo",
"type" : [ "string" ]
}, {
"name" : "depictImageUrl",
"type" : [ "string" ]
}, {
"name" : "title",
"type" : [ "string" ]
}, {
"name" : "logoBgColor",
"type" : [ "string" ]
}, {
"name" : "description",
"type" : [ "string" ]
}, {
"name" : "urlPublic",
"type" : [ "string" ]
}, {
"name" : "urlBO",
"type" : [ "string" ]
}, {
"name" : "createdAt",
"type" : [ "string" ]
}, {
"name" : "createdBy",
"type" : [ "string" ]
}, {
"name" : "modifiedAt",
"type" : [ "string" ]
}, {
"name" : "modifiedBy",
"type" : [ "string" ]
}, {
"name" : "roleManagementURL",
"type" : [ "null", "string" ]
}, {
"name" : "contractTemplateUpdatedAt",
"type" : [ "string" ]
}, {
"name" : "contractTemplatePath",
"type" : [ "string" ]
}, {
"name" : "contractTemplateVersion",
"type" : [ "string" ]
}, {
"name" : "institutionContractMappings",
"type" : [ "null", {
"type" : "map",
"values" : {
"type" : "record",
"name" : "ContractStorage",
"fields" : [ {
"name" : "contractTemplateUpdatedAt",
"type" : [ "null", "string" ]
}, {
"name" : "contractTemplatePath",
"type" : [ "null", "string" ]
}, {
"name" : "contractTemplateVersion",
"type" : [ "null", "string" ]
} ]
}
} ]
}, {
"name" : "enabled",
"type" : "boolean"
}, {
"name" : "delegable",
"type" : ["null","boolean"]
}, {
"name" : "status",
"type" : [ "string" ]
}, {
"name" : "parentId",
"type" : [ "null", "string" ]
}, {
"name" : "identityTokenAudience",
"type" : [ "string" ]
}, {
"name" : "backOfficeEnvironmentConfigurations",
"type" : [ "null", {
"type" : "map",
"values" : {
"type" : "record",
"name" : "BackOfficeConfigurations",
"fields" : [ {
"name" : "url",
"type" : [ "null", "string" ]
}, {
"name" : "identityTokenAudience",
"type" : [ "null", "string" ]
} ]
}
} ]
}, {
"name" : "parent",
"type" : [ "null", "Product" ]
} ]
}
```
Product string which are used by ProductService must follow a specific schema, look at src/main/schema folder.

## Usage

Expand All @@ -151,4 +45,19 @@ public class Main {
final Product product = productService.getProductIsValid(productId);
}
}
```
```

Generally, you load product json string from an azure storage container, this example use onboading-sdk-azure-storage, and inject the product service in the context of Quarkus or Spring (replace @ApplicationScoped with @Bean).

```java script
@ApplicationScoped
public ProductService productService(AzureStorageConfig azureStorageConfig){
AzureBlobClient azureBlobClient = new AzureBlobClientDefault(azureStorageConfig.connectionStringProduct(), azureStorageConfig.containerProduct());
String productJsonString = azureBlobClient.getFileAsText(azureStorageConfig.productFilepath());
try {
return new ProductServiceDefault(productJsonString, objectMapper());
} catch (JsonProcessingException e) {
throw new IllegalArgumentException("Found an issue when trying to serialize product json string!!");
}
}
```
18 changes: 16 additions & 2 deletions onboarding-sdk/onboarding-sdk-product/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
<parent>
<groupId>it.pagopa.selfcare</groupId>
<artifactId>onboarding-sdk</artifactId>
<version>0.0.4</version>
<version>0.1.0</version>
</parent>
<artifactId>onboarding-sdk-product</artifactId>
<name>onboarding-sdk-product</name>

<properties>
<jackson.version>2.15.2</jackson.version>
<junit-jupiter.version>5.7.2</junit-jupiter.version>
</properties>

<dependencies>
Expand All @@ -25,7 +26,20 @@
<dependency>
<groupId>it.pagopa.selfcare</groupId>
<artifactId>onboarding-sdk-common</artifactId>
<version>0.0.1</version>
<version>${parent.version}</version>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>

</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
import java.util.Map;

public interface ProductService {
List<Product> getProducts(boolean rootOnly);
public List<Product> getProducts(boolean rootOnly, boolean valid) ;

void validateRoleMappings(Map<PartyRole, ? extends ProductRoleInfo> roleMappings);

Product getProduct(String id, InstitutionType institutionType);
Product getProduct(String productId);

Product getProductIsValid(String id);
void fillContractTemplatePathAndVersion(Product product, InstitutionType institutionType);

Product getProductIsValid(String productId);
}
Loading
Loading