Skip to content

Commit

Permalink
Enforce new target vocabulary
Browse files Browse the repository at this point in the history
  • Loading branch information
southeo committed Nov 6, 2023
1 parent 9297fca commit c6b89aa
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/main/java/eu/dissco/backend/domain/annotation/Target.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class Target {
@JsonProperty("ods:id")
private String odsId;
@JsonProperty("ods:type")
private String odsType;
private TargetType odsType;
@JsonProperty("oa:selector")
private Selector oaSelector;

Expand All @@ -26,7 +26,7 @@ public Target withOdsId(String odsId) {
return this;
}

public Target withOdsType(String odsType) {
public Target withOdsType(TargetType odsType) {
this.odsType = odsType;
return this;
}
Expand Down
21 changes: 21 additions & 0 deletions src/main/java/eu/dissco/backend/domain/annotation/TargetType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package eu.dissco.backend.domain.annotation;

import com.fasterxml.jackson.annotation.JsonProperty;

public enum TargetType {
@JsonProperty("AigitalSpecimen") DIGITAL_SPECIMEN("DigitalSpecimen"),
@JsonProperty("Annotation") ANNOTATION("Annotation"),
@JsonProperty("MediaObject") MEDIA_OBJECT("MediaObject");

private final String state;

private TargetType(String s) {
this.state = s;
}

@Override
public String toString() {
return this.state;
}

}
3 changes: 2 additions & 1 deletion src/test/java/eu/dissco/backend/utils/AnnotationUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import eu.dissco.backend.domain.annotation.Generator;
import eu.dissco.backend.domain.annotation.Motivation;
import eu.dissco.backend.domain.annotation.Target;
import eu.dissco.backend.domain.annotation.TargetType;
import eu.dissco.backend.domain.jsonapi.JsonApiData;
import eu.dissco.backend.domain.jsonapi.JsonApiLinks;
import eu.dissco.backend.domain.jsonapi.JsonApiLinksFull;
Expand Down Expand Up @@ -101,7 +102,7 @@ public static Target givenOaTarget(String targetId) {
return new Target()
.withOdsId(targetId)
.withSelector(givenSelector())
.withOdsType("digital_specimen");
.withOdsType(TargetType.DIGITAL_SPECIMEN);
}

public static FieldValueSelector givenSelector() {
Expand Down

0 comments on commit c6b89aa

Please sign in to comment.