Skip to content

Commit

Permalink
Merge pull request #372 from europeana/EA-3647_switch_to_mongo6
Browse files Browse the repository at this point in the history
Ea 3647 switch to mongo6
  • Loading branch information
gsergiu authored Mar 21, 2024
2 parents 513b160 + 19a65f0 commit 455b165
Show file tree
Hide file tree
Showing 39 changed files with 320 additions and 297 deletions.
14 changes: 0 additions & 14 deletions annotation-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${version.log4j2}</version>
</dependency>

<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${version.log4j2}</version>
</dependency>

<dependency>
Expand All @@ -52,17 +50,11 @@
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
<!--
<version>${version.org.junit.jupiter}</version>
-->
</dependency>
<!-- https://mvnrepository.com/artifact/org.junit.platform/junit-platform launcher -->
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<!--
<version>${version.junit-platform}</version>
-->
<scope>test</scope>
</dependency>

Expand All @@ -88,17 +80,11 @@
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<!--
<version>${version.spring}</version>
-->
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<!--
<version>${version.spring}</version>
-->
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
package eu.europeana.annotation.client;

import java.io.IOException;

import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.stanbol.commons.exception.JsonParseException;

import eu.europeana.annotation.client.config.ClientConfiguration;
import eu.europeana.annotation.client.connection.AnnotationApiConnection;
import eu.europeana.annotation.client.exception.TechnicalRuntimeException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import java.util.List;

import eu.europeana.annotation.definitions.model.impl.AnnotationDeletion;

public interface WebAnnotationAuxilaryMethodsApi {

public List<String> getDeleted(String motivation, String from, String to, int page, int limit);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import java.util.List;
import java.util.concurrent.ExecutionException;
import org.apache.stanbol.commons.exception.JsonParseException;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@
import static eu.europeana.annotation.definitions.model.vocabulary.WebAnnotationFields.RESP_OPERATION_REPORT_FIELD;
import static eu.europeana.annotation.definitions.model.vocabulary.WebAnnotationFields.RESP_OPERATION_REPORT_SUCCESSCOUNT_FIELD;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import org.apache.commons.lang3.StringUtils;
import org.apache.stanbol.commons.exception.JsonParseException;
import org.codehaus.jettison.json.JSONObject;
Expand All @@ -28,7 +26,6 @@
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import eu.europeana.annotation.client.integration.webanno.BaseWebAnnotationTest;
import eu.europeana.annotation.config.AnnotationConfiguration;
import eu.europeana.annotation.definitions.model.Annotation;

/**
Expand Down Expand Up @@ -146,7 +143,7 @@ public void viaBatchUploadTest() throws Exception {
// get response body properties
JSONObject jsonObj = new JSONObject(uploadResponse.getBody());
Integer total = (Integer) jsonObj.get(BATCH_TOTAL_FIELD);
assertEquals(new Integer(1), total);
assertEquals(Integer.valueOf(1), total);

}

Expand Down Expand Up @@ -254,9 +251,8 @@ private String replaceIdentifiers(String template, String varPrefix) throws IOEx
* @param jsonStr JSON string
*/
private void jsonPrettyPrint(String jsonStr) {
JsonParser parser = new JsonParser();
Gson gson = new GsonBuilder().setPrettyPrinting().create();
JsonElement el = parser.parse(jsonStr);
JsonElement el = JsonParser.parseString(jsonStr);
log.debug(gson.toJson(el));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import org.apache.stanbol.commons.exception.JsonParseException;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.springframework.http.ResponseEntity;
import eu.europeana.annotation.client.WhitelistJsonApiImpl;
import eu.europeana.annotation.client.integration.webanno.BaseWebAnnotationTest;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
package eu.europeana.annotation.client.integration.webanno.describing;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.IOException;
import java.lang.reflect.InvocationTargetException;

import org.apache.stanbol.commons.exception.JsonParseException;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

import eu.europeana.annotation.client.integration.webanno.BaseWebAnnotationTest;
import eu.europeana.annotation.definitions.model.Annotation;
import eu.europeana.annotation.definitions.model.vocabulary.MotivationTypes;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package eu.europeana.annotation.client.integration.webanno.link;

import java.io.IOException;
import org.apache.stanbol.commons.exception.JsonParseException;
import org.junit.jupiter.api.Test;
import org.springframework.http.ResponseEntity;
import eu.europeana.annotation.client.integration.webanno.BaseWebAnnotationTest;
import eu.europeana.annotation.definitions.model.Annotation;
import eu.europeana.annotation.definitions.model.vocabulary.MotivationTypes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.stanbol.commons.exception.JsonParseException;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.http.ResponseEntity;
Expand Down
6 changes: 0 additions & 6 deletions annotation-mongo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,6 @@
-->
</dependency>

<!-- <dependency> -->
<!-- <groupId>org.springframework.data</groupId> -->
<!-- <artifactId>spring-data-mongodb</artifactId> -->
<!-- <version>3.3.4</version> -->
<!-- </dependency> -->

</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
import java.util.stream.Collectors;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.mongodb.morphia.Datastore;
import org.mongodb.morphia.Morphia;
import org.mongodb.morphia.mapping.Mapper;
import org.mongodb.morphia.query.Query;
import org.mongodb.morphia.query.UpdateOperations;
import com.mongodb.BasicDBObject;
import com.mongodb.BulkWriteError;
import com.mongodb.BulkWriteException;
import com.mongodb.BulkWriteOperation;
import com.mongodb.BulkWriteResult;
import com.mongodb.DBCollection;
import com.mongodb.DBObject;
import dev.morphia.Datastore;
import dev.morphia.Morphia;
import dev.morphia.mapping.Mapper;
import dev.morphia.query.Query;
import dev.morphia.query.UpdateOperations;
import eu.europeana.annotation.definitions.model.Annotation;
import eu.europeana.annotation.definitions.model.vocabulary.WebAnnotationFields;
import eu.europeana.annotation.mongo.batch.BulkOperationMode;
Expand Down Expand Up @@ -217,7 +217,7 @@ public void copyAnnotations(List<? extends Annotation> existingAnnos, String sou
ops.add(new BasicDBObject("$match", query.getQueryObject()));
ops.add(new BasicDBObject("$out", targetCollection));
DBCollection source = getDatastore().getDB().getCollection(sourceCollection);
source.aggregate(ops);
source.aggregate(ops, getDefaultAggregationOptions());

}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package eu.europeana.annotation.mongo.dao;

import java.io.Serializable;
import org.mongodb.morphia.Datastore;
import dev.morphia.Datastore;
import eu.europeana.annotation.mongo.model.internal.PersistentApiWriteLock;
import eu.europeana.api.commons.nosql.dao.impl.NosqlDaoImpl;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package eu.europeana.annotation.mongo.dao;

import java.io.Serializable;
import org.mongodb.morphia.Datastore;
import dev.morphia.Datastore;
import eu.europeana.annotation.mongo.model.internal.PersistentModerationRecord;
import eu.europeana.api.commons.nosql.dao.impl.NosqlDaoImpl;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package eu.europeana.annotation.mongo.dao;

import java.io.Serializable;
import org.mongodb.morphia.Datastore;
import dev.morphia.Datastore;
import eu.europeana.annotation.mongo.model.internal.PersistentStatusLog;
import eu.europeana.api.commons.nosql.dao.impl.NosqlDaoImpl;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package eu.europeana.annotation.mongo.dao;

import java.io.Serializable;
import org.mongodb.morphia.Datastore;
import dev.morphia.Datastore;
import eu.europeana.annotation.mongo.model.internal.PersistentWhitelistEntry;
import eu.europeana.api.commons.nosql.dao.impl.NosqlDaoImpl;

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

import java.util.Date;
import org.bson.types.ObjectId;
import org.mongodb.morphia.annotations.Embedded;
import org.mongodb.morphia.annotations.Entity;
import org.mongodb.morphia.annotations.Field;
import org.mongodb.morphia.annotations.Id;
import org.mongodb.morphia.annotations.Index;
import org.mongodb.morphia.annotations.Indexes;
import org.mongodb.morphia.annotations.Property;
import dev.morphia.annotations.Embedded;
import dev.morphia.annotations.Entity;
import dev.morphia.annotations.Field;
import dev.morphia.annotations.Id;
import dev.morphia.annotations.Index;
import dev.morphia.annotations.Indexes;
import dev.morphia.annotations.Property;
import eu.europeana.annotation.config.AnnotationConfiguration;
import eu.europeana.annotation.definitions.model.agent.Agent;
import eu.europeana.annotation.definitions.model.body.Body;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package eu.europeana.annotation.mongo.model;

import java.util.Date;

import org.bson.types.ObjectId;
import org.mongodb.morphia.annotations.Entity;
import org.mongodb.morphia.annotations.Id;

import dev.morphia.annotations.Entity;
import dev.morphia.annotations.Id;
import eu.europeana.annotation.mongo.model.internal.PersistentApiWriteLock;
import eu.europeana.annotation.mongo.model.internal.PersistentObject;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import java.util.Date;
import java.util.List;
import org.bson.types.ObjectId;
import org.mongodb.morphia.annotations.Entity;
import org.mongodb.morphia.annotations.Field;
import org.mongodb.morphia.annotations.Id;
import org.mongodb.morphia.annotations.Index;
import org.mongodb.morphia.annotations.Indexes;
import dev.morphia.annotations.Entity;
import dev.morphia.annotations.Field;
import dev.morphia.annotations.Id;
import dev.morphia.annotations.Index;
import dev.morphia.annotations.Indexes;
import eu.europeana.annotation.definitions.model.moderation.Summary;
import eu.europeana.annotation.definitions.model.moderation.Vote;
import eu.europeana.annotation.definitions.model.moderation.impl.BaseSummary;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package eu.europeana.annotation.mongo.model;

import org.bson.types.ObjectId;
import org.mongodb.morphia.annotations.Entity;
import org.mongodb.morphia.annotations.Id;
import dev.morphia.annotations.Entity;
import dev.morphia.annotations.Id;
import eu.europeana.annotation.mongo.model.internal.PersistentObject;
import eu.europeana.annotation.mongo.model.internal.PersistentStatusLog;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package eu.europeana.annotation.mongo.model;

import java.util.Date;

import org.bson.types.ObjectId;
import org.mongodb.morphia.annotations.Entity;
import org.mongodb.morphia.annotations.Id;

import dev.morphia.annotations.Entity;
import dev.morphia.annotations.Id;
import eu.europeana.annotation.mongo.model.internal.PersistentObject;
import eu.europeana.annotation.mongo.model.internal.PersistentWhitelistEntry;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package eu.europeana.annotation.mongo.model.internal;

import org.mongodb.morphia.annotations.Entity;
import org.mongodb.morphia.annotations.Id;
import dev.morphia.annotations.Entity;
import dev.morphia.annotations.Id;
import eu.europeana.annotation.definitions.model.vocabulary.WebAnnotationFields;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package eu.europeana.annotation.mongo.model.shape;

import org.mongodb.morphia.annotations.Embedded;

import dev.morphia.annotations.Embedded;
import eu.europeana.annotation.definitions.model.selector.shape.impl.PointImpl;

@Embedded
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.bson.types.ObjectId;
import org.mongodb.morphia.query.Criteria;
import org.mongodb.morphia.query.CriteriaContainer;
import org.mongodb.morphia.query.FindOptions;
import org.mongodb.morphia.query.Query;
import org.mongodb.morphia.query.QueryResults;
import org.mongodb.morphia.query.UpdateOperations;
import org.mongodb.morphia.query.UpdateResults;
import dev.morphia.query.Criteria;
import dev.morphia.query.CriteriaContainer;
import dev.morphia.query.FindOptions;
import dev.morphia.query.Query;
import dev.morphia.query.QueryResults;
import dev.morphia.query.UpdateOperations;
import dev.morphia.query.UpdateResults;
import eu.europeana.annotation.definitions.exception.AnnotationValidationException;
import eu.europeana.annotation.definitions.model.Annotation;
import eu.europeana.annotation.definitions.model.body.PlaceBody;
Expand Down Expand Up @@ -197,7 +197,7 @@ public List<? extends Annotation> getAnnotationListByResourceId(String resourceI
* @param multiple
* @return evaluated list
*/
protected List<? extends Annotation> filterAnnotationListByTarget(String target, boolean multiple) {
protected List<Annotation> filterAnnotationListByTarget(String target, boolean multiple) {
Query<PersistentAnnotation> query = getAnnotationDao().createQuery();
if (StringUtils.isNotEmpty(target)) {
if (multiple)
Expand All @@ -208,8 +208,8 @@ protected List<? extends Annotation> filterAnnotationListByTarget(String target,
target);
}
query.filter(PersistentAnnotation.FIELD_DISABLED, null);
QueryResults<? extends PersistentAnnotation> results = getAnnotationDao().find(query);
return results.asList();
QueryResults<PersistentAnnotation> results = getAnnotationDao().find(query);
return asList(results);
}

/**
Expand All @@ -234,7 +234,7 @@ protected List<? extends Annotation> filterAnnotationListByResourceId(String res

query.filter(PersistentAnnotation.FIELD_DISABLED, null);
QueryResults<? extends PersistentAnnotation> results = getAnnotationDao().find(query);
return results.asList();
return asList(results);
}

@Override
Expand Down
Loading

0 comments on commit 455b165

Please sign in to comment.