Skip to content
This repository has been archived by the owner on Feb 13, 2024. It is now read-only.

Commit

Permalink
Init tags from config
Browse files Browse the repository at this point in the history
Signed-off-by: Woerner Dominic (RBCH/PJ-IOT) <dominic.woerner2@ch.bosch.com>
  • Loading branch information
Woerner Dominic (RBCH/PJ-IOT) committed Jun 23, 2021
1 parent caf57c8 commit af2240e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,15 @@
*/
package org.hyperledger.bpa.config;

import io.micronaut.context.annotation.EachProperty;
import io.micronaut.context.annotation.Parameter;
import io.micronaut.context.annotation.ConfigurationProperties;
import lombok.Data;

@EachProperty("bpa.tags")
import java.util.List;

@Data
@ConfigurationProperties("bpa")
public class TagConfig {

/**
* Bean name
*/
private String name;
private List<String> tags;

public TagConfig(@Parameter String name) {
this.name = name;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class TagService {
TagRepository tagRepo;

@Inject
List<TagConfig> configuredTags;
TagConfig configuredTags;

public @Nullable TagAPI addTag(@NonNull String name) {
return addTag(name, Boolean.FALSE);
Expand Down Expand Up @@ -90,14 +90,16 @@ public void deleteTag(@NonNull UUID id) {
public void resetWriteOnlyTags() {
long deleted = tagRepo.deleteByIsReadOnly();
log.debug("Removed {} preconfigured tags", deleted);
if (configuredTags.getTags() != null) {
configuredTags.getTags().forEach(t -> {
try {
TagAPI tagAPI = addTag(t, Boolean.TRUE);
log.debug("Added preconfigured tag with name: {}", tagAPI.getName());
} catch (DataAccessException e) {
log.warn("Tag with name {} will not be added", t, e);
}
});
}

configuredTags.forEach(t -> {
try {
TagAPI tagAPI = addTag(t.getName(), Boolean.TRUE);
log.debug("Added preconfigured tag with name: {}", tagAPI.getName());
} catch (DataAccessException e) {
log.warn("Tag with name {} will not be added", t.getName(), e);
}
});
}
}
3 changes: 3 additions & 0 deletions backend/business-partner-agent/src/main/resources/schemas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ bpa:
restrictions:
- issuerDid: "${bpa.did.prefix}5mwQSWnRePrZ3oF67C4KqD"
label: "Commercial Register"
tags:
- "myInitTag"
- "myOtherInitTag"

0 comments on commit af2240e

Please sign in to comment.