Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
administration
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OZG-Cloud
app
administration
Commits
a416f3f6
Commit
a416f3f6
authored
1 year ago
by
Lukas Malte Monnerjahn
Browse files
Options
Downloads
Patches
Plain Diff
OZG-5058 feedback migration
parent
cde95d68
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/de/ozgcloud/admin/migration/M001_CreateEmptyPostfachIfMissing.java
+6
-35
6 additions, 35 deletions
...ud/admin/migration/M001_CreateEmptyPostfachIfMissing.java
src/main/resources/application.yaml
+0
-1
0 additions, 1 deletion
src/main/resources/application.yaml
with
6 additions
and
36 deletions
src/main/java/de/ozgcloud/admin/migration/M001_CreateEmptyPostfachIfMissing.java
+
6
−
35
View file @
a416f3f6
...
...
@@ -3,53 +3,24 @@ package de.ozgcloud.admin.migration;
import
io.mongock.api.annotations.ChangeUnit
;
import
io.mongock.api.annotations.Execution
;
import
io.mongock.api.annotations.RollbackExecution
;
import
org.bson.Document
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.data.mongodb.core.query.Update
;
@ChangeUnit
(
id
=
"2024-02-20 17:00:00 OZG-4948-OZG-5058"
,
order
=
"M001"
,
author
=
"lmonnerjahn"
,
runAlways
=
true
)
public
class
M001_CreateEmptyPostfachIfMissing
{
// NOSONAR
private
static
final
String
SETTINGS_COLLECTION
=
"settings"
;
static
final
String
SETTINGS_COLLECTION
=
"settings"
;
static
final
String
TYPE_NAME_KEY
=
"name"
;
static
final
String
TYPE_NAME_POSTFACH_VALUE
=
"Postfach"
;
public
static
final
String
SETTINGS_KEY
=
"settings"
;
public
static
final
String
POSTFACH_ABSENDER_KEY
=
"absender"
;
public
static
final
String
POSTFACH_SIGNATUR_KEY
=
"signatur"
;
public
static
final
String
ABSENDER_NAME_KEY
=
"name"
;
public
static
final
String
ABSENDER_ANSCHRIFT_KEY
=
"anschrift"
;
public
static
final
String
ABSENDER_DIENST_KEY
=
"dienst"
;
public
static
final
String
ABSENDER_MANDANT_KEY
=
"mandant"
;
public
static
final
String
ABSENDER_GEMEINDESCHLUESSEL_KEY
=
"gemeindeschluessel"
;
public
static
final
String
SIGNATUR_TEXT_KEY
=
"text"
;
@Execution
public
void
doMigration
(
MongoTemplate
template
)
{
var
criteria
=
Criteria
.
where
(
TYPE_NAME_KEY
).
is
(
TYPE_NAME_POSTFACH_VALUE
);
var
query
=
new
Query
(
criteria
);
if
(
template
.
find
(
query
,
Document
.
class
,
SETTINGS_COLLECTION
).
isEmpty
())
{
template
.
save
(
emptyPostfachSetting
(),
SETTINGS_COLLECTION
);
}
}
private
Document
emptyPostfachSetting
(){
var
setting
=
new
Document
();
var
postfach
=
new
Document
();
var
absender
=
new
Document
();
var
signatur
=
new
Document
();
signatur
.
put
(
SIGNATUR_TEXT_KEY
,
""
);
absender
.
put
(
ABSENDER_NAME_KEY
,
""
);
absender
.
put
(
ABSENDER_ANSCHRIFT_KEY
,
""
);
absender
.
put
(
ABSENDER_DIENST_KEY
,
""
);
absender
.
put
(
ABSENDER_MANDANT_KEY
,
""
);
absender
.
put
(
ABSENDER_GEMEINDESCHLUESSEL_KEY
,
""
);
postfach
.
put
(
POSTFACH_ABSENDER_KEY
,
absender
);
postfach
.
put
(
POSTFACH_SIGNATUR_KEY
,
signatur
);
setting
.
put
(
TYPE_NAME_KEY
,
TYPE_NAME_POSTFACH_VALUE
);
setting
.
put
(
SETTINGS_KEY
,
postfach
);
return
setting
;
var
query
=
Query
.
query
(
Criteria
.
where
(
TYPE_NAME_KEY
).
is
(
TYPE_NAME_POSTFACH_VALUE
));
var
update
=
new
Update
();
update
.
setOnInsert
(
TYPE_NAME_KEY
,
TYPE_NAME_POSTFACH_VALUE
);
template
.
upsert
(
query
,
update
,
SETTINGS_COLLECTION
);
}
@RollbackExecution
...
...
This diff is collapsed.
Click to expand it.
src/main/resources/application.yaml
+
0
−
1
View file @
a416f3f6
...
...
@@ -54,7 +54,6 @@ mongock:
migration-scan-package
:
-
de.ozgcloud.admin.migration
enabled
:
true
# try out if this works
transactionEnabled
:
true
spring
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment