From 6552d2c5c4821b380eab9e2c63b33f319ef88c9c Mon Sep 17 00:00:00 2001 From: mariub Date: Wed, 21 Jan 2026 13:43:47 +0100 Subject: [PATCH 1/2] legger til feltene paymentDate og paidAmount i datatypen Payslip --- datatypes-examples.xml | 5 +++- datatypes.xsd | 5 +++- readme.md | 11 +++++--- .../marshalling/LocalDateXmlAdapter.java | 24 +++++++++++++++++ .../digipost/api/datatypes/types/Payslip.java | 26 +++++++++++++++++-- 5 files changed, 64 insertions(+), 7 deletions(-) create mode 100644 src/main/java/no/digipost/api/datatypes/marshalling/LocalDateXmlAdapter.java diff --git a/datatypes-examples.xml b/datatypes-examples.xml index 60dae2b5..9c93d169 100644 --- a/datatypes-examples.xml +++ b/datatypes-examples.xml @@ -150,7 +150,10 @@ - + + 2020-09-21 + 5000 + KB432788293NO diff --git a/datatypes.xsd b/datatypes.xsd index 27a5089a..18327e8c 100644 --- a/datatypes.xsd +++ b/datatypes.xsd @@ -206,7 +206,10 @@ - + + + + diff --git a/readme.md b/readme.md index df70766f..3140517a 100644 --- a/readme.md +++ b/readme.md @@ -458,14 +458,19 @@ For treating documents as Payslips. ### Fields -|Name|Type|Required|Description| -|----|----|--------|-----------| +| Name | Type | Required | Description | +|-------------|------------|----------|----------------------------------------| +| paymentDate | LocalDate | no | The date when the salary is paid out | +| netAmount | BigDecimal | no | Net salary, the actual amount paid out | ### XML ```xml - + + 2020-09-21 + 5000 + ``` ## PickupNotice diff --git a/src/main/java/no/digipost/api/datatypes/marshalling/LocalDateXmlAdapter.java b/src/main/java/no/digipost/api/datatypes/marshalling/LocalDateXmlAdapter.java new file mode 100644 index 00000000..6c7cb29d --- /dev/null +++ b/src/main/java/no/digipost/api/datatypes/marshalling/LocalDateXmlAdapter.java @@ -0,0 +1,24 @@ +package no.digipost.api.datatypes.marshalling; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; + +public class LocalDateXmlAdapter extends XmlAdapter { + @Override + public LocalDate unmarshal(String s) { + if (s == null) { + return null; + } + return LocalDate.from(DateTimeFormatter.ISO_LOCAL_DATE.parse(s)); + } + @Override + public String marshal(LocalDate v) { + if (v == null) { + return null; + } + return v.format(DateTimeFormatter.ISO_LOCAL_DATE); + } +} + diff --git a/src/main/java/no/digipost/api/datatypes/types/Payslip.java b/src/main/java/no/digipost/api/datatypes/types/Payslip.java index 9e78fde1..0ac3f0f1 100644 --- a/src/main/java/no/digipost/api/datatypes/types/Payslip.java +++ b/src/main/java/no/digipost/api/datatypes/types/Payslip.java @@ -1,16 +1,38 @@ package no.digipost.api.datatypes.types; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import lombok.AllArgsConstructor; +import lombok.NoArgsConstructor; import lombok.Value; +import lombok.With; import no.digipost.api.datatypes.DataType; import no.digipost.api.datatypes.documentation.Description; +import no.digipost.api.datatypes.marshalling.LocalDateXmlAdapter; -import javax.xml.bind.annotation.XmlRootElement; +import java.math.BigDecimal; +import java.time.LocalDate; @XmlRootElement @Value @AllArgsConstructor +@NoArgsConstructor(force = true) +@With @Description("For treating documents as Payslips.") public class Payslip implements DataType { - public static Payslip EXAMPLE = new Payslip(); + + @XmlElement(name = "payment-date") + @XmlJavaTypeAdapter(LocalDateXmlAdapter.class) + @Description("The date when the salary is paid out") + LocalDate paymentDate; + + @XmlElement(name = "net-amount") + @Description("Net salary, the actual amount received") + BigDecimal netAmount; + + + public static Payslip EXAMPLE = new Payslip( + LocalDate.parse("2025-01-01"), + new BigDecimal("42000.00")); } From fde94cc7bf0277842877cf9479f5fe26b5a27e62 Mon Sep 17 00:00:00 2001 From: mariub Date: Wed, 21 Jan 2026 14:42:51 +0100 Subject: [PATCH 2/2] =?UTF-8?q?endrer=20p=C3=A5=20workflow=20filen=20slik?= =?UTF-8?q?=20at=20den=20fungerer=20med=20n=C3=A5v=C3=A6rende=20maven=20se?= =?UTF-8?q?tup=20-=20bare=20at=20den=20supporter=20java=208=20ogs=C3=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 65 ++++++++++++++++++++----------------- pom.xml | 24 +++++++------- 2 files changed, 47 insertions(+), 42 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 97853aae..84de6293 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,12 +6,12 @@ jobs: build: strategy: matrix: - java: [ '8', '11', '17' ] + java: [ '8'] name: Build on Java ${{ matrix.java }} runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-java@v3 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1 with: distribution: temurin java-version: ${{ matrix.java }} @@ -20,36 +20,41 @@ jobs: run: mvn -B verify --no-transfer-progress --show-version - publishing_parameters: + publish: needs: build - name: Publishing parameters + name: Publish ${{ github.ref_name }} runs-on: ubuntu-latest - outputs: - is_release: ${{ steps.version.outputs.is_release }} - version: ${{ steps.version.outputs.version }} steps: - - name: Determine version - id: version + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - name: Set up Java + uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1 + with: + distribution: temurin + java-version: '8' + cache: "maven" + gpg-private-key: ${{ secrets.MAVEN_CENTRAL_SIGNING_KEY_PRIVATE }} + server-id: central + server-username: MAVEN_CENTRAL_TOKEN_USERNAME + server-password: MAVEN_CENTRAL_TOKEN_PASSWORD + gpg-passphrase: MAVEN_GPG_PASSPHRASE + - name: Activate Artifact Signing and Version Suffix run: | - if [[ $GITHUB_REF == *"tags"* ]]; then - is_release=true - version=${GITHUB_REF#refs/tags/} + profiles="build-sources-and-javadoc,deploy-to-maven-central" + if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then + profiles="$profiles,sign-artifacts" + version_suffix="" else - is_release=false - version=${GITHUB_REF#refs/heads/}-SNAPSHOT + version_suffix="-SNAPSHOT" fi - echo "is_release=${is_release//\//-}" >> $GITHUB_OUTPUT - echo "version=${version//\//-}" >> $GITHUB_OUTPUT - - - publish: - needs: publishing_parameters - name: Publish ${{ needs.publishing_parameters.outputs.version }} - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: digipost/action-maven-publish@v1 - with: - sonatype_secrets: ${{ secrets.sonatype_secrets }} - release_version: ${{ needs.publishing_parameters.outputs.version }} - perform_release: ${{ needs.publishing_parameters.outputs.is_release }} + echo "MAVEN_PROFILES=$profiles" >> $GITHUB_ENV + version="${GITHUB_REF_NAME}${version_suffix}" + echo "VERSION=$version" >> $GITHUB_ENV + - name: Set Maven version + run: mvn --batch-mode --no-transfer-progress versions:set -DnewVersion=${VERSION} + - name: Build and deploy to Maven Central + run: | + mvn --batch-mode --no-transfer-progress --activate-profiles ${MAVEN_PROFILES} deploy + env: + MAVEN_CENTRAL_TOKEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_TOKEN_USERNAME }} + MAVEN_CENTRAL_TOKEN_PASSWORD: ${{ secrets.MAVEN_CENTRAL_TOKEN_PASSWORD }} + MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_CENTRAL_SIGNING_KEY_PASSPHRASE }} diff --git a/pom.xml b/pom.xml index c8a38569..21e3408a 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ no.digipost digipost-open-super-pom - 13 + 14 digipost-data-types @@ -174,7 +174,7 @@ maven-clean-plugin - 3.2.0 + 3.5.0 maven-resources-plugin @@ -182,14 +182,14 @@ maven-compiler-plugin - 3.11.0 + 3.14.0 true maven-enforcer-plugin - 3.3.0 + 3.6.1 @@ -205,33 +205,33 @@ maven-surefire-plugin - 3.0.0 + 3.5.3 maven-dependency-plugin - 3.5.0 + 3.8.1 maven-jar-plugin - 3.3.0 + 3.4.2 maven-install-plugin - 3.1.1 + 3.1.4 maven-deploy-plugin - 3.1.1 + 3.1.4 org.codehaus.mojo versions-maven-plugin - 2.15.0 + 2.18.0 org.codehaus.mojo exec-maven-plugin - 3.1.0 + 3.5.1 com.github.siom79.japicmp @@ -260,7 +260,7 @@ - ${project.build.sourceDirectory} + ${project.build.sourceDirectory}/no/digipost/api/datatypes/types/ ${project.build.directory}/schemagen-work/lombok false