Skip to content

Commit

Permalink
EA-3236 ordering of teh fields and added Field types
Browse files Browse the repository at this point in the history
  • Loading branch information
SrishtiSingh-eu committed Aug 29, 2023
1 parent 6727430 commit 2cfb5a2
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,20 @@
import eu.europeana.api.record.model.Aggregation;
import eu.europeana.api.record.deserialization.ObjectReferenceConverter;
import eu.europeana.api.record.deserialization.LiteralStringConverter;
import eu.europeana.api.record.vocabulary.FieldTypes;

import java.util.List;

import static eu.europeana.api.record.vocabulary.RecordFields.ID;
import static eu.europeana.api.record.vocabulary.RecordFields.TYPE;

@Entity(useDiscriminator = false)
@JsonInclude(value = JsonInclude.Include.NON_EMPTY)
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonPropertyOrder({ID, TYPE})
public class AggregationImpl extends EdmEntityImpl implements Aggregation {

@JsonDeserialize(converter = LiteralStringConverter.class)
private Literal<String> type;
private Literal<String> type = new LiteralImpl<>(FieldTypes.Aggregation.getFieldType());

@JsonDeserialize(converter = LiteralStringConverter.class)
private Literal<String> isShownBy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
import eu.europeana.api.record.model.Entity;
import eu.europeana.api.record.deserialization.LiteralListConverter;

import static eu.europeana.api.record.vocabulary.RecordFields.ID;

import java.util.Map;

import static eu.europeana.api.record.vocabulary.RecordFields.*;

@JsonInclude(value = JsonInclude.Include.NON_EMPTY)
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonPropertyOrder({ID, TYPE, PREF_LABEL})
public abstract class EntityImpl implements Entity {

// ID of entity
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
package eu.europeana.api.record.impl;

import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import dev.morphia.annotations.Entity;
import eu.europeana.api.record.datatypes.Literal;
import eu.europeana.api.record.model.EuropeanaAggregation;
import eu.europeana.api.record.deserialization.LiteralStringConverter;

import static eu.europeana.api.record.vocabulary.RecordFields.*;

@Entity(useDiscriminator = false)
@JsonPropertyOrder({ID, TYPE})
public class EuropeanaAggregationImpl extends EdmEntityImpl implements EuropeanaAggregation {

// we need the type in the input to identify which proxy has Europeana aggregation OR
// figure out a way to identify this
@JsonDeserialize(converter = LiteralStringConverter.class)
private Literal<String> type;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,31 @@

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import dev.morphia.annotations.Entity;
import eu.europeana.api.record.datatypes.Literal;
import eu.europeana.api.record.model.EuropeanaAggregation;
import eu.europeana.api.record.model.Proxy;
import eu.europeana.api.record.deserialization.LiteralStringConverter;
import eu.europeana.api.record.deserialization.LiteralMapConverter;
import static eu.europeana.api.record.vocabulary.RecordFields.NONE;
import eu.europeana.api.record.vocabulary.FieldTypes;

import java.util.Collections;
import java.util.List;
import java.util.Map;

import static eu.europeana.api.record.vocabulary.RecordFields.*;
import static eu.europeana.api.record.vocabulary.RecordFields.PREF_LABEL;

// It is now possible to use @Entity everywhere. If a type is only for use as an embedded value, no @Id field is necessary.
@Entity(useDiscriminator = false)
@JsonInclude(value = JsonInclude.Include.NON_EMPTY)
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonPropertyOrder({ID, TYPE})
public class ProxyImpl extends EdmEntityImpl implements Proxy {

@JsonDeserialize(converter = LiteralStringConverter.class)
private Literal<String> type;
private Literal<String> type = new LiteralImpl<>(FieldTypes.Proxy.getFieldType());

@JsonDeserialize(converter = LiteralMapConverter.class)
private Map<String, List<Literal<String>>> title;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import static eu.europeana.api.record.vocabulary.RecordFields.*;

@JsonPropertyOrder({CONTEXT, ID, PROXIES, IS_AGGREGATED_BY, WEB_RESOURCES, AGENTS})
@Entity(value = "Record", useDiscriminator = false)
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(value = JsonInclude.Include.NON_EMPTY)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
package eu.europeana.api.record.impl;

import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import dev.morphia.annotations.Entity;
import eu.europeana.api.record.datatypes.Literal;
import eu.europeana.api.record.model.TechMetadata;
import eu.europeana.api.record.model.WebResource;
import eu.europeana.api.record.deserialization.LiteralStringConverter;
import eu.europeana.api.record.vocabulary.FieldTypes;

import static eu.europeana.api.record.vocabulary.RecordFields.*;

@Entity(useDiscriminator = false)
@JsonPropertyOrder({ID, TYPE})
public class WebResourceImpl extends EdmEntityImpl implements WebResource {

@JsonDeserialize(converter = LiteralStringConverter.class)
private Literal<String> type;
private Literal<String> type = new LiteralImpl<>(FieldTypes.WebResource.getFieldType());;

@JsonDeserialize(as = TechMetadataImpl.class)
private TechMetadataImpl techMetadata;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ public class AppConfigConstants {
public static final String BEAN_RECORD_DATA_STORE = "recordDataStore";
public static final String BEAN_RECORD_REPO = "recordRepo";
public static final String BEAN_RECORD_SERVICE = "recordService";
public static final String BEAN_RECORD_JSONLD_SERIALIZER = "recordJsonldSerializer";


public static final String BEAN_JSON_MAPPER = "recordJsonMapper";

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package eu.europeana.api.record.vocabulary;

public enum FieldTypes {
Proxy("Proxy"),
Aggregation("Aggregation"),
EuropeanaAggregation("EuropeanaAggregation"),
WebResource("WebResource");

private String fieldType;

public String getFieldType() {
return fieldType;
}


FieldTypes(String fieldType) {
this.fieldType = fieldType;

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
public interface RecordFields {

public static final String CONTEXT = "@context";
public static final String EDM_CONTEXT = "http://www.europeana.eu/schemas/context/edm.jsonld";
public static final String EDM_CONTEXT = "https://www.europeana.eu/schemas/context/edm.jsonld";

public static final String NON_LANGUAGE_TAGGED = "def";
public static final String NONE = "@none";
Expand All @@ -23,6 +23,12 @@ public interface RecordFields {
public static final String PROVIDED_CHO = "providedCHO";

public static final String AGGREGATION = "Aggregation";

// fields for display
public static final String AGGREGATIONS = "aggregations";
public static final String WEB_RESOURCES = "webResources";
public static final String AGENTS = "agents";
public static final String PROXIES = "proxies";
public static final String IS_AGGREGATED_BY = "isAggregatedBy";


Expand Down
6 changes: 6 additions & 0 deletions record-api-web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@
<version>1.0-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>

</dependencies>

<build>
Expand Down

0 comments on commit 2cfb5a2

Please sign in to comment.