Skip to content

Commit

Permalink
Changed IdentifierType to an interface
Browse files Browse the repository at this point in the history
easier to use with Hibernate
  • Loading branch information
cgendreau committed Dec 23, 2024
1 parent a6b7782 commit 6bd0243
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,39 +1,26 @@
package ca.gc.aafc.dina.entity;

import ca.gc.aafc.dina.i18n.MultilingualTitle;
import ca.gc.aafc.dina.vocabulary.VocabularyElement;

import java.util.List;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.SuperBuilder;

@SuperBuilder
@Getter
public abstract class IdentifierType implements VocabularyElement, DinaEntity {
import ca.gc.aafc.dina.vocabulary.VocabularyElement;

public interface IdentifierType extends VocabularyElement, DinaEntity {

/**
* The key should not contain dot(.) See {@link VocabularyElement#getKey()}
* @param key
*/
@Setter
private String key;

private String name;

// usually a URI
private String term;

private MultilingualTitle multilingualTitle;
void setKey(String key);

/**
* The component (material-sample, project) where this identifier type is expected to be used.
*/
private List<String> dinaComponents;
List<String> getDinaComponents();

/**
* Like wikidata. A URI template where "$1" can be automatically replaced with the value
* assigned to the identifier.
*/
private String uriTemplate;
String getUriTemplate();

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ca.gc.aafc.dina.service;

import org.hibernate.annotations.Type;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.test.context.SpringBootTest;
Expand All @@ -11,6 +12,7 @@

import ca.gc.aafc.dina.TestDinaBaseApp;
import ca.gc.aafc.dina.entity.IdentifierType;
import ca.gc.aafc.dina.i18n.MultilingualTitle;
import ca.gc.aafc.dina.jpa.BaseDAO;
import ca.gc.aafc.dina.testsupport.PostgresTestContainerInitializer;
import ca.gc.aafc.dina.validation.IdentifierTypeValidator;
Expand Down Expand Up @@ -74,11 +76,23 @@ public IdentifierTypeValidator identifierTypeValidator(@Named("validationMessage
@Setter
@SuperBuilder
@Entity
static class TestIdentifierType extends IdentifierType {
static class TestIdentifierType implements IdentifierType {

@Id
private Integer id;
private UUID uuid;
private String key;

private String name;
private String term;

@Type(type = "jsonb")
private MultilingualTitle multilingualTitle;

@Type(type = "list-array")
private List<String> dinaComponents;

private String uriTemplate;
private String createdBy;
private OffsetDateTime createdOn;
}
Expand Down

0 comments on commit 6bd0243

Please sign in to comment.