diff --git a/entity-management-definitions/src/main/java/eu/europeana/entitymanagement/definitions/VocabularyFields.java b/entity-management-definitions/src/main/java/eu/europeana/entitymanagement/definitions/VocabularyFields.java deleted file mode 100644 index 4fb92e99..00000000 --- a/entity-management-definitions/src/main/java/eu/europeana/entitymanagement/definitions/VocabularyFields.java +++ /dev/null @@ -1,12 +0,0 @@ -package eu.europeana.entitymanagement.definitions; - -// Collection field names -public class VocabularyFields { - - private VocabularyFields() { - // private constructor to prevent instantiation - } - - public static final String URI = "uri"; - -} \ No newline at end of file diff --git a/entity-management-definitions/src/main/java/eu/europeana/entitymanagement/definitions/model/Organization.java b/entity-management-definitions/src/main/java/eu/europeana/entitymanagement/definitions/model/Organization.java index da32e1a8..c636b30a 100644 --- a/entity-management-definitions/src/main/java/eu/europeana/entitymanagement/definitions/model/Organization.java +++ b/entity-management-definitions/src/main/java/eu/europeana/entitymanagement/definitions/model/Organization.java @@ -274,7 +274,7 @@ public List getEuropeanaRole() { europeanaRole=new ArrayList<>(); for(String roleId : europeanaRoleIds) { Vocabulary vocab = new Vocabulary(); - vocab.setUri(roleId); + vocab.setId(roleId); europeanaRole.add(vocab); } } diff --git a/entity-management-definitions/src/main/java/eu/europeana/entitymanagement/definitions/model/Vocabulary.java b/entity-management-definitions/src/main/java/eu/europeana/entitymanagement/definitions/model/Vocabulary.java index 63de0161..73e61fff 100644 --- a/entity-management-definitions/src/main/java/eu/europeana/entitymanagement/definitions/model/Vocabulary.java +++ b/entity-management-definitions/src/main/java/eu/europeana/entitymanagement/definitions/model/Vocabulary.java @@ -15,6 +15,7 @@ import dev.morphia.annotations.Id; import dev.morphia.annotations.IndexOptions; import dev.morphia.annotations.Indexed; +import dev.morphia.annotations.Transient; import eu.europeana.entitymanagement.utils.VocabularyWatcher; @JsonIgnoreProperties(ignoreUnknown = true) @@ -26,12 +27,13 @@ */ public class Vocabulary { - private String type = "Vocabulary"; + @Transient + private String type = "Concept"; @Id @JsonIgnore private ObjectId dbId; @Indexed(options = @IndexOptions(unique = true)) - private String uri; + private String id; protected List inScheme; @@ -75,17 +77,17 @@ public Date getModified() { @Override public String toString() { - return String.format("Vocabulary.uri: %s", getUri()); + return String.format("Vocabulary.id: %s", getId()); } @JsonGetter - public String getUri() { - return uri; + public String getId() { + return id; } @JsonSetter - public void setUri(String vocabularyUri) { - this.uri = vocabularyUri; + public void setId(String id) { + this.id = id; } @JsonGetter(IN_SCHEME) diff --git a/entity-management-definitions/src/main/java/eu/europeana/entitymanagement/web/xml/model/XmlOrganizationImpl.java b/entity-management-definitions/src/main/java/eu/europeana/entitymanagement/web/xml/model/XmlOrganizationImpl.java index 7cbdc221..fd7114c8 100644 --- a/entity-management-definitions/src/main/java/eu/europeana/entitymanagement/web/xml/model/XmlOrganizationImpl.java +++ b/entity-management-definitions/src/main/java/eu/europeana/entitymanagement/web/xml/model/XmlOrganizationImpl.java @@ -113,7 +113,7 @@ public XmlOrganizationImpl(Organization organization) { List orgXmlRole= new ArrayList<>(); for(Vocabulary vocab : orgRole) { XmlConceptImpl xmlConcept = new XmlConceptImpl(); - xmlConcept.setAbout(vocab.getUri()); + xmlConcept.setAbout(vocab.getId()); xmlConcept.setPrefLabel(RdfXmlUtils.convertMapToXmlMultilingualString(vocab.getPrefLabel())); xmlConcept.setInScheme(RdfXmlUtils.convertToRdfResource(vocab.getInScheme())); orgXmlRole.add(xmlConcept); diff --git a/entity-management-mongo/src/main/java/eu/europeana/entitymanagement/mongo/repository/VocabularyRepository.java b/entity-management-mongo/src/main/java/eu/europeana/entitymanagement/mongo/repository/VocabularyRepository.java index a49537a3..1467277c 100644 --- a/entity-management-mongo/src/main/java/eu/europeana/entitymanagement/mongo/repository/VocabularyRepository.java +++ b/entity-management-mongo/src/main/java/eu/europeana/entitymanagement/mongo/repository/VocabularyRepository.java @@ -1,7 +1,6 @@ package eu.europeana.entitymanagement.mongo.repository; import static dev.morphia.query.experimental.filters.Filters.in; -import static eu.europeana.entitymanagement.definitions.VocabularyFields.URI; import java.util.ArrayList; import java.util.List; import javax.annotation.Resource; @@ -17,15 +16,17 @@ public class VocabularyRepository { @Resource(name = AppConfigConstants.BEAN_EM_DATA_STORE) Datastore datastore; + + private static final String ID = "id"; /** - * retrieve records by their URI/id - * @param vocabularyUris + * retrieve records by their id + * @param vocabularyIds * @return */ - public List findByUri(List vocabularyUris) { + public List findByUri(List vocabularyIds) { List filters = new ArrayList<>(); - filters.add(in(URI, vocabularyUris)); + filters.add(in(ID, vocabularyIds)); return datastore.find(Vocabulary.class) .filter(filters.toArray(Filter[]::new)) .iterator() diff --git a/entity-management-web/src/main/java/eu/europeana/entitymanagement/config/AppAutoconfig.java b/entity-management-web/src/main/java/eu/europeana/entitymanagement/config/AppAutoconfig.java index 7e063926..77b5bbbd 100644 --- a/entity-management-web/src/main/java/eu/europeana/entitymanagement/config/AppAutoconfig.java +++ b/entity-management-web/src/main/java/eu/europeana/entitymanagement/config/AppAutoconfig.java @@ -80,7 +80,7 @@ public void ensureDatabaseInitialization() throws ApplicationInitializationExcep for(XmlBaseEntityImpl xmlEntity : xmlEntities) { XmlConceptImpl xmlConcept = (XmlConceptImpl) xmlEntity; Vocabulary vocab = new Vocabulary(); - vocab.setUri(xmlConcept.getAbout()); + vocab.setId(xmlConcept.getAbout()); vocab.setInScheme(RdfXmlUtils.toStringList(xmlConcept.getInScheme())); vocab.setPrefLabel(RdfXmlUtils.toLanguageMap(xmlConcept.getPrefLabel())); roles.add(vocab); diff --git a/entity-management-web/src/test/java/eu/europeana/entitymanagement/web/UtilityTests.java b/entity-management-web/src/test/java/eu/europeana/entitymanagement/web/UtilityTests.java index 1744a725..6b4038c7 100644 --- a/entity-management-web/src/test/java/eu/europeana/entitymanagement/web/UtilityTests.java +++ b/entity-management-web/src/test/java/eu/europeana/entitymanagement/web/UtilityTests.java @@ -64,7 +64,7 @@ public void saveVocabulariesToMongo() throws Exception { XmlConceptImpl xmlConcept = (XmlConceptImpl) xmlEntity; Concept concept = xmlConcept.toEntityModel(); Vocabulary vocab = new Vocabulary(); - vocab.setUri(concept.getEntityId()); + vocab.setId(concept.getEntityId()); vocab.setInScheme(concept.getInScheme()); vocab.setPrefLabel(concept.getPrefLabel()); vocabularyRepo.save(vocab);