Skip to content

Commit

Permalink
Database (#5)
Browse files Browse the repository at this point in the history
* clean whitespaces & use requiredArgsConstructor

* only deploy to alpha

* adjust postgres db

* adjust local config

* remove hikari schema

* adjust base-url locally

* trigger on push if branch is named november

* fix small bugs & rename entity class

* upgrade adapter-common library

* add alpha deployment for fintlabs

* only deploy to alpha

* change image-name

* upgrade FINT version

* adjust dependencies & add java object sourceCompatibility

* change base-url to alpha

* deploy to beta

* Add mapping to links and change database identificator

* Improve empty value handeling

* remove links

* include rogfk in beta deployment

* add rogfk to kustomize beta

* only set beskrivelseGyldighetsPeriode if not null

* remove rogfk from beta

* returns exception if you put resource that does not excist in database

---------

Co-authored-by: Hknots <hknots99@gmail.com>
Co-authored-by: Trond Magnus Sevre <trond@fintlabs.no>
  • Loading branch information
3 people authored Dec 17, 2024
1 parent 9920e3b commit cb4a31f
Show file tree
Hide file tree
Showing 25 changed files with 404 additions and 45 deletions.
15 changes: 12 additions & 3 deletions .github/workflows/CD.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
name: CD

on:
repository_dispatch:
types: [trigger-cd]
# repository_dispatch:
# types: [trigger-cd]
push:
branches:
- november

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
IMAGE_NAME: ${{ github.repository }}-database

jobs:
build-and-push:
Expand Down Expand Up @@ -58,9 +61,15 @@ jobs:
# - viken-no
# - visma-com
cluster:
<<<<<<< HEAD
# - aks-api-fint-2022-02-08
- aks-beta-fint-2021-11-23
- aks-alpha-fint-2021-11-18
=======
# - aks-alpha-fint-2021-11-18
- aks-beta-fint-2021-11-23
- aks-api-fint-2022-02-08
>>>>>>> main
# - aks-pwf-fint-2021-10-20

steps:
Expand Down
29 changes: 15 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
plugins {
id 'org.springframework.boot' version '2.7.11'
id 'org.springframework.boot' version '3.2.0'
id 'io.spring.dependency-management' version '1.1.0'
id 'java'
id 'groovy'
}

group = 'no.fintlabs'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '17'
java {
sourceCompatibility = JavaVersion.VERSION_17
}

configurations {
compileOnly {
Expand All @@ -20,36 +22,35 @@ jar {
}

repositories {
mavenCentral()
repositories {
maven {
url "https://repo.fintlabs.no/releases"
}
}
mavenLocal()
maven {
url "https://repo.fintlabs.no/releases"
}
mavenCentral()
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-webflux'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'

implementation 'io.netty:netty-resolver-dns-native-macos:4.1.86.Final:osx-aarch_64'

implementation 'no.fintlabs:fint-core-infra-models:1.1.1'
implementation 'no.fintlabs:fint-core-infra-models:2.0.0-rc-12'
implementation 'no.fintlabs:fint-core-adapter-common:0.1.2'
implementation "no.fint:fint-personvern-resource-model-java:${apiVersion}"
implementation "no.fint:fint-felles-resource-model-java:${apiVersion}"
implementation 'no.fint:fint-event-model:3.0.2'
implementation 'no.fint:fint-model-resource:0.4.1'
implementation 'no.fintlabs:fint-core-adapter-common:0.1.6-rc-3'
implementation 'org.postgresql:postgresql'
implementation 'no.fintlabs:fint-metamodell-model-java:1.1.0'

runtimeOnly 'org.springframework.boot:spring-boot-actuator'
testImplementation 'org.springframework.boot:spring-boot-starter-test'

runtimeOnly 'org.spockframework:spock-spring:2.1-groovy-3.0'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
runtimeOnly 'org.spockframework:spock-spring:2.1-groovy-3.0'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.spockframework:spock-core:2.1-groovy-3.0'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
Expand Down
12 changes: 12 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: '3.7'
services:
postgres:
image: postgres
container_name: my_postgres
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: fint-personvern-kodeverk-adapter
ports:
- "5432:5432"
restart: unless-stopped
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
apiVersion=3.13.10
apiVersion=3.18.1-rc-4
28 changes: 28 additions & 0 deletions kustomize/overlays/alpha/fintlabs-no/flais.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: fintlabs.no/v1alpha1
kind: Application
metadata:
name: fint-personvern-kodeverk-adapter
namespace: fintlabs-no
labels:
app.kubernetes.io/name: fint-personvern-kodeverk-adapter
app.kubernetes.io/instance: fint-personvern-kodeverk-adapter_fintlabs_no
app.kubernetes.io/version: latest
app.kubernetes.io/component: adapter
app.kubernetes.io/part-of: fint-core
fintlabs.no/team: core
fintlabs.no/org-id: fintlabs.no
spec:
orgId: fintlabs.no
image: ghcr.io/fintlabs/fint-personvern-kodeverk-adapter-database:latest
env:
- name: fint.adapter.base-url
value: https://alpha.felleskomponent.no
onePassword:
itemPath: vaults/aks-alpha-vault/items/fint-personvern-kodeverk-adapter
resources:
limits:
memory: 512Mi
cpu: 500m
requests:
memory: 256Mi
cpu: 250m
10 changes: 9 additions & 1 deletion kustomize/overlays/alpha/fintlabs-no/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
<<<<<<< HEAD
resources:
- ../../../base
patches:
- path: flais.yaml

=======
namespace: fintlabs-no
resources:
- ../../../base
Expand All @@ -13,4 +20,5 @@ commonLabels:
app.kubernetes.io/component: backend
app.kubernetes.io/part-of: fint-core
fintlabs.no/team: core
fintlabs.no/org-id: fintlabs.no
fintlabs.no/org-id: fintlabs.no
>>>>>>> main
28 changes: 28 additions & 0 deletions kustomize/overlays/beta/fintlabs-no/flais.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: fintlabs.no/v1alpha1
kind: Application
metadata:
name: fint-personvern-kodeverk-adapter
namespace: fintlabs-no
labels:
app.kubernetes.io/name: fint-personvern-kodeverk-adapter
app.kubernetes.io/instance: fint-personvern-kodeverk-adapter_fintlabs_no
app.kubernetes.io/version: latest
app.kubernetes.io/component: adapter
app.kubernetes.io/part-of: fint-core
fintlabs.no/team: core
fintlabs.no/org-id: fintlabs.no
spec:
orgId: fintlabs.no
image: ghcr.io/fintlabs/fint-personvern-kodeverk-adapter-database:latest
env:
- name: fint.adapter.base-url
value: https://beta.felleskomponent.no
onePassword:
itemPath: vaults/aks-beta-vault/items/fint-personvern-kodeverk-adapter
resources:
limits:
memory: 512Mi
cpu: 500m
requests:
memory: 256Mi
cpu: 250m
9 changes: 7 additions & 2 deletions kustomize/overlays/beta/fintlabs-no/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: fintlabs-no
resources:
- ../../../base
<<<<<<< HEAD
patches:
- path: flais.yaml

=======
patchesStrategicMerge:
- config-map.yaml
- one-password.yaml
Expand All @@ -13,4 +17,5 @@ commonLabels:
app.kubernetes.io/component: backend
app.kubernetes.io/part-of: fint-core
fintlabs.no/team: core
fintlabs.no/org-id: fintlabs.no
fintlabs.no/org-id: fintlabs.no
>>>>>>> main
28 changes: 28 additions & 0 deletions kustomize/overlays/beta/rogfk-no/flais.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: fintlabs.no/v1alpha1
kind: Application
metadata:
name: fint-personvern-kodeverk-adapter
namespace: rogfk-no
labels:
app.kubernetes.io/name: fint-personvern-kodeverk-adapter
app.kubernetes.io/instance: fint-personvern-kodeverk-adapter_rogfk_no
app.kubernetes.io/version: latest
app.kubernetes.io/component: adapter
app.kubernetes.io/part-of: fint-core
fintlabs.no/team: core
fintlabs.no/org-id: rogfk.no
spec:
orgId: rogfk.no
image: ghcr.io/fintlabs/fint-personvern-kodeverk-adapter-database:latest
env:
- name: fint.adapter.base-url
value: https://beta.felleskomponent.no
onePassword:
itemPath: vaults/aks-beta-vault/items/fint-personvern-kodeverk-adapter
resources:
limits:
memory: 512Mi
cpu: 500m
requests:
memory: 256Mi
cpu: 250m
10 changes: 9 additions & 1 deletion kustomize/overlays/beta/rogfk-no/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
<<<<<<< HEAD
resources:
- ../../../base
patches:
- path: flais.yaml

=======
namespace: rogfk-no
resources:
- ../../../base
Expand All @@ -13,4 +20,5 @@ commonLabels:
app.kubernetes.io/component: backend
app.kubernetes.io/part-of: fint-core
fintlabs.no/team: core
fintlabs.no/org-id: rogfk-no
fintlabs.no/org-id: rogfk-no
>>>>>>> main
7 changes: 7 additions & 0 deletions src/main/java/no/fintlabs/NotInDataBaseException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package no.fintlabs;

public class NotInDataBaseException extends RuntimeException {
public NotInDataBaseException(String message) {
super(message);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package no.fintlabs.model.behandlingsgrunnlag;

import jakarta.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
import no.fint.model.resource.personvern.kodeverk.BehandlingsgrunnlagResource;
import no.fint.model.resource.personvern.samtykke.SamtykkeResource;
import no.fintlabs.adapter.config.AdapterProperties;
import no.fintlabs.adapter.datasync.ResourcePublisher;
import no.fintlabs.adapter.datasync.ResourceRepository;
Expand All @@ -11,7 +11,6 @@
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;

@Slf4j
@Service
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
package no.fintlabs.model.behandlingsgrunnlag;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import no.fint.model.resource.personvern.kodeverk.BehandlingsgrunnlagResource;
import no.fintlabs.adapter.events.WriteableResourceRepository;
import no.fintlabs.adapter.models.RequestFintEvent;
import no.fintlabs.adapter.models.event.RequestFintEvent;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

@Slf4j
@Repository
@RequiredArgsConstructor
public class BehandlingsgrunnlagRepository implements WriteableResourceRepository<BehandlingsgrunnlagResource> {

private final BehandlingsgrunnlagResources behandlingsgrunnlagJpaRepository;

public BehandlingsgrunnlagRepository(BehandlingsgrunnlagResources behandlingsgrunnlagJpaRepository) {
this.behandlingsgrunnlagJpaRepository = behandlingsgrunnlagJpaRepository;
}

@Override
public List<BehandlingsgrunnlagResource> getResources() {
return behandlingsgrunnlagJpaRepository.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import no.fintlabs.adapter.config.AdapterProperties;
import no.fintlabs.adapter.datasync.ResourceSubscriber;
import no.fintlabs.adapter.models.AdapterCapability;
import no.fintlabs.adapter.models.SyncPageEntry;
import no.fintlabs.adapter.models.sync.SyncPageEntry;
import no.fintlabs.adapter.validator.ValidatorService;
import org.springframework.stereotype.Service;
import org.springframework.web.reactive.function.client.WebClient;
Expand All @@ -14,7 +14,7 @@
@Service
public class BehandlingsgrunnlagSubscriber extends ResourceSubscriber<BehandlingsgrunnlagResource, BehandlingsgrunnlagPublisher> {

protected BehandlingsgrunnlagSubscriber(WebClient webClient, AdapterProperties props, BehandlingsgrunnlagPublisher publisher, ValidatorService<BehandlingsgrunnlagResource> validatorService) {
protected BehandlingsgrunnlagSubscriber(WebClient webClient, AdapterProperties props, BehandlingsgrunnlagPublisher publisher, ValidatorService validatorService) {
super(webClient, props, publisher, validatorService);
}

Expand All @@ -25,8 +25,9 @@ protected AdapterCapability getCapability() {
}

@Override
protected SyncPageEntry<BehandlingsgrunnlagResource> createSyncPageEntry(BehandlingsgrunnlagResource resource) {
protected SyncPageEntry createSyncPageEntry(BehandlingsgrunnlagResource resource) {
String identificationValue = resource.getSystemId().getIdentifikatorverdi();
return SyncPageEntry.of(identificationValue, resource);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package no.fintlabs.model.personopplysning;

import no.fintlabs.model.personopplysning.model.PersonopplysningEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface PersonopplysningJpaRepository extends JpaRepository<PersonopplysningEntity, String> {
}
Loading

0 comments on commit cb4a31f

Please sign in to comment.