Skip to content

Commit

Permalink
EA-3236 add other functionality like datsource, repository, controlle…
Browse files Browse the repository at this point in the history
…r and application. Also added interfaces
  • Loading branch information
SrishtiSingh-eu committed Aug 9, 2023
1 parent 6a844a1 commit 130793d
Show file tree
Hide file tree
Showing 51 changed files with 1,541 additions and 251 deletions.
11 changes: 9 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<modules>
<module>record-api-definitions</module>
<module>record-api-impl</module>
<module>record-api-mongo</module>
<module>record-api-web</module>
</modules>

<parent>
Expand Down Expand Up @@ -52,18 +54,23 @@
<!-- Exclude POJOs code duplication analysis -->
<sonar.cpd.exclusions>**/model/**/*</sonar.cpd.exclusions>
<api.commons.version>0.3.21</api.commons.version>
<jackson.version>2.11.4</jackson.version>
<jackson.version>2.15.2</jackson.version>
<!-- Spring Boot 3 is based on Spring Framework 6.0 and Jakarta EE 9. A-->
<spring-boot.version>3.1.2</spring-boot.version>
<spring-framework.version>6.0.11</spring-framework.version>

<surefire.version>3.1.2</surefire.version>
<swagger.version>3.0.0</swagger.version>
<morphia.version>2.1.4</morphia.version>
<!-- See if we can move to the latest version 2.4, alot of methods are deprecated though-->
<morphia.version>2.3.7</morphia.version>
<git-code-format.version>3.1</git-code-format.version>
<git-commit-id.version>5.0.0</git-commit-id.version>
<failsafe.version>3.0.0-M5</failsafe.version>
<jacoco-plugin.version>0.8.7</jacoco-plugin.version>
<pmd-plugin.version>3.21.0</pmd-plugin.version>
<spotbugs-plugin.version>4.7.3.5</spotbugs-plugin.version>
<sonar-plugin.version>3.7.0.1746</sonar-plugin.version>
<apache.commomLang3.version>3.13.0</apache.commomLang3.version>
</properties>

<!-- Set asm version to be used by maven-pmd-plugin -->
Expand Down
1 change: 1 addition & 0 deletions record-api-definitions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@
<maven.compiler.target>${java.version}</maven.compiler.target>
</properties>


</project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
public interface Literal<T> {

T getValue();

void setValue(T value);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package eu.europeana.api.record.model;

public interface Agent {

String getType();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package eu.europeana.api.record.model;

import eu.europeana.api.record.datatypes.Literal;
import eu.europeana.api.record.datatypes.ObjectReference;

import java.util.List;

public interface Aggregation {

Literal<String> getType();

Literal<String> getIsShownBy();

List<ObjectReference> getHasViews();

void setType(Literal<String> type);

void setIsShownBy(Literal<String> isShownBy);

void setHasViews(List<ObjectReference> hasViews);

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

public interface EdmEntity {

String getAbout();

void setAbout(String about);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package eu.europeana.api.record.model;

import eu.europeana.api.record.datatypes.Literal;

import java.util.Map;

public interface Entity {

String getAbout();

void setAbout(String about);

Literal<String> getPrefLabel(String language);

void setPrefLabel(Map<String, Literal<String>> prefLabel);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package eu.europeana.api.record.model;

import eu.europeana.api.record.datatypes.Literal;

public interface EuropeanaAggregation {

Literal<String> getType();

void setType(Literal<String> type);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package eu.europeana.api.record.model;

public interface ProvidedCHO {

String getType();

void setType(String type);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package eu.europeana.api.record.model;

import eu.europeana.api.record.datatypes.Literal;

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

public interface Proxy {

Literal<String> getType();

EuropeanaAggregation getProxyIn();

Literal<String> getProxyFor();

Literal<String> getTitle(String language);

Literal<String> getCreator(String language);

Literal<String> getAlternative(String language);

Literal<String> getDescription(String language);

Literal<String> getIdentifier(String language);

List<Literal<String>> getTitles();

List<Literal<String>> getAlternatives();

List<Literal<String>> getCreators();

List<Literal<String>> getIdentifiers();

List<Literal<String>> getDescriptions();

void setType(Literal<String> type);

void setTitle(Map<String, List<Literal<String>>> title);

void setAlternative(Map<String, List<Literal<String>>> alternative);

void setDescription(Map<String, List<Literal<String>>> description);

void setCreator(Map<String, List<Literal<String>>> creator);

void setIdentifier(Map<String, List<Literal<String>>> identifier);

void setProxyIn(EuropeanaAggregation proxyIn);

void setProxyFor(Literal<String> proxyFor);

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

public interface TechMetadata {

Long getFileByteSize();

void setFileByteSize(Long fileByteSize);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package eu.europeana.api.record.model;

import eu.europeana.api.record.datatypes.Literal;

public interface WebResource {

Literal<String> getType();

void setType(Literal<String> type);

TechMetadata getTechMetadata();

void setTechMetadata(TechMetadata techMetadata);
}
29 changes: 29 additions & 0 deletions record-api-impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,35 @@
<artifactId>record-api-definitions</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson.version}</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>


<!-- For Morphia annotations for now-->
<dependency>
<groupId>dev.morphia.morphia</groupId>
<artifactId>morphia-core</artifactId>
<version>${morphia.version}</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-mongodb -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<version>4.1.2</version>
</dependency>


</dependencies>

</project>
99 changes: 99 additions & 0 deletions record-api-impl/src/main/java/eu/europeana/api/record/Record.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package eu.europeana.api.record;

import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import dev.morphia.annotations.Entity;
import dev.morphia.annotations.Id;
import eu.europeana.api.record.impl.*;
import eu.europeana.api.record.model.*;

import java.util.List;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;

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

@Entity
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(value = JsonInclude.Include.NON_EMPTY)
// TODO add custom validators later once we know field validations
public class Record {

@Id
private String id;

// @JsonDeserialize(as = ProvidedCHOImpl.class)
// private ProvidedCHO providedCHO;

@JsonDeserialize(contentAs = ProxyImpl.class)
private List<? extends Proxy> proxies;

@JsonDeserialize(as = AggregationImpl.class)
private Aggregation aggregation;

@JsonDeserialize(contentAs = WebResourceImpl.class)
private List<? extends WebResource> webResources;

@JsonDeserialize(contentAs = AgentImpl.class)
private List<? extends Agent> agents;

protected Record() {}


@JsonGetter(CONTEXT)
public String getContext() {
return EDM_CONTEXT;
}

@JsonGetter(ID)
public String getId() {
return id;
}

@JsonSetter(ID)
public void setId(String id) {
this.id = id;
}

// public ProvidedCHO getProvidedCHO() {
// return providedCHO;
// }
//
// public void setProvidedCHO(ProvidedCHO providedCHO) {
// this.providedCHO = providedCHO;
// }

public List<? extends Proxy> getProxies() {
return proxies;
}

public void setProxies(List<? extends Proxy> proxies) {
this.proxies = proxies;
}

public Aggregation getAggregation() {
return aggregation;
}

public void setAggregation(Aggregation aggregation) {
this.aggregation = aggregation;
}

public List<? extends WebResource> getWebResources() {
return webResources;
}

public void setWebResources(List<? extends WebResource> webResources) {
this.webResources = webResources;
}

public List<? extends Agent> getAgents() {
return agents;
}

public void setAgents(List<? extends Agent> agents) {
this.agents = agents;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package eu.europeana.api.record.codec;

import eu.europeana.api.record.datatypes.Literal;
import eu.europeana.api.record.impl.LiteralImpl;
import org.bson.BsonReader;
import org.bson.BsonWriter;
import org.bson.codecs.Codec;
import org.bson.codecs.DecoderContext;
import org.bson.codecs.EncoderContext;

public class LiteralCodec implements Codec<Literal> {

// @Override
// public void encode(final BsonWriter writer, final Literal<String> value, final EncoderContext encoderContext) {
// writer.writeString(value.getValue());
// }

@Override
public void encode(BsonWriter bsonWriter, Literal literal, EncoderContext encoderContext) {
bsonWriter.writeString(String.valueOf(literal.getValue()));

}

@Override
public Class<Literal> getEncoderClass() {
return Literal.class;
}

@Override
public Literal<String> decode(final BsonReader reader, final DecoderContext decoderContext) {
Literal<String> literal = new LiteralImpl<>();
literal.setValue(reader.readString());
return literal;
}

}
Loading

0 comments on commit 130793d

Please sign in to comment.