Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ea 3748 debias case #373

Merged
merged 5 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@
public class ClientConfiguration {

protected static final String ANNOTATION_CLIENT_PROPERTIES_FILE = "/annotation-client.properties";
protected static final String PROP_ANNOTATION_API_KEY = "annotation.api.key";
protected static final String PROP_ANNOTATION_SERVICE_BASE_URI = "annotation.service.uri";
protected static final String PROP_ANNOTATION_ID_BASE_URI = "annotation.id.baseUrl";
protected static final String PROP_ANNOTATION_ITEM_DATA_ENDPOINT = "annotation.item.data.endpoint";
protected static final String PROP_ANNOTATION_CLIENT_API_ENDPOINT = "annotation.client.api.endpoint";
protected static final String PROP_AUTHORIZATION_HEADER_NAME = "annotation.header.name";
protected static final String PROP_REGULAR_AUTHORIZATION_HEADER_VALUE = "annotation.regular.authorization.value";
protected static final String PROP_ADMIN_ANNOTATION_HEADER_VALUE = "annotation.admin.authorization.value";

protected static final String PROP_OAUTH_SERVICE_URI = "oauth.service.uri";
protected static final String PROP_OAUTH_REQUEST_PARAMS_PREFIX = "oauth.token.request.params.";
public static final String PROP_ANNOTATION_API_KEY = "annotation.api.key";
public static final String PROP_ANNOTATION_SERVICE_BASE_URI = "annotation.service.uri";
public static final String PROP_ANNOTATION_ID_BASE_URI = "annotation.id.baseUrl";
public static final String PROP_ANNOTATION_ITEM_DATA_ENDPOINT = "annotation.item.data.endpoint";
public static final String PROP_ANNOTATION_CLIENT_API_ENDPOINT = "annotation.client.api.endpoint";

public static final String PROP_AUTHORIZATION_HEADER_NAME = "annotation.header.name";
public static final String PROP_REGULAR_AUTHORIZATION_HEADER_VALUE = "annotation.regular.authorization.value";
public static final String PROP_ADMIN_ANNOTATION_HEADER_VALUE = "annotation.admin.authorization.value";

public static final String PROP_OAUTH_SERVICE_URI = "oauth.service.uri";
public static final String PROP_OAUTH_REQUEST_PARAMS_PREFIX = "oauth.token.request.params.";

private static Properties properties = null;

Expand All @@ -44,6 +44,10 @@ public static synchronized ClientConfiguration getInstance() {
return singleton;
}

public ClientConfiguration(Properties properties) {
this.properties = properties;
}

/**
* Laizy loading of configuration properties
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
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.junit.jupiter.api.Test;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

import eu.europeana.annotation.definitions.model.Annotation;
import eu.europeana.annotation.definitions.model.vocabulary.WebAnnotationFields;

Expand Down Expand Up @@ -147,7 +150,7 @@ public void updateAnnotation() throws JsonParseException, IOException {
assertEquals( HttpStatus.OK, response.getStatusCode());
assertNotNull(response.getBody());
assertEquals(TAG_STANDARD_TEST_VALUE_BODY, updatedAnnotation.getBody().getValue());
assertEquals(get_TAG_STANDARD_TEST_VALUE_TARGET(), updatedAnnotation.getTarget().getHttpUri());
assertEquals(get_TAG_STANDARD_TEST_VALUE_TARGET(), updatedAnnotation.getTarget().get(0).getHttpUri());

//TODO: search annotation in solr and verify body and target values.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

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

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

import org.apache.stanbol.commons.exception.JsonParseException;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

import eu.europeana.annotation.definitions.model.Annotation;


Expand Down Expand Up @@ -69,7 +72,7 @@ public void updateAnnotation() throws JsonParseException, IOException {
assertEquals( HttpStatus.CREATED, response.getStatusCode());
assertNotNull(response.getBody());
assertEquals(TAG_STANDARD_TEST_VALUE_BODY, updatedAnnotation.getBody().getValue());
assertEquals(get_TAG_STANDARD_TEST_VALUE_TARGET(), updatedAnnotation.getTarget().getHttpUri());
assertEquals(get_TAG_STANDARD_TEST_VALUE_TARGET(), updatedAnnotation.getTarget().get(0).getHttpUri());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void createFullTextResource() throws IOException, JsonParseException, Ill
Annotation storedAnno = getApiProtocolClient().parseResponseBody(response);

assertTrue(storedAnno.getMotivation().equals(MotivationTypes.DESCRIBING.name().toLowerCase()));
assertTrue(storedAnno.getTarget().getSource() != null);
assertTrue(storedAnno.getTarget().get(0).getSource() != null);
assertEquals(storedAnno.getBody().getInternalType(), BodyInternalTypes.TEXT.name());

removeAnnotation(storedAnno.getIdentifier());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
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.junit.jupiter.api.Test;

import eu.europeana.annotation.client.config.ClientConfiguration;
import eu.europeana.annotation.definitions.model.Annotation;
import eu.europeana.annotation.definitions.model.body.GraphBody;
Expand Down Expand Up @@ -65,7 +68,7 @@ public void createGeoTag() throws IOException, JsonParseException, IllegalAccess
assertTrue(placeBody.getLatitude().equals("48.853415"));
assertNotNull(placeBody.getLongitude());
assertTrue(placeBody.getLongitude().equals("-102.348800"));
Target target = retrievedAnno.getTarget();
Target target = retrievedAnno.getTarget().get(0);
assertNotNull(target.getHttpUri());
assertTrue(target.getHttpUri().equals(ClientConfiguration.getInstance().getPropAnnotationItemDataEndpoint() + "/09102/_UEDIN_214"));
}
Expand Down Expand Up @@ -97,7 +100,7 @@ public void createTag() throws IOException, JsonParseException, IllegalAccessExc
TagBody tagBody = ((TagBody) retrievedAnno.getBody());
assertNotNull(tagBody.getValue());
assertTrue(tagBody.getValue().equals("trombone"));
Target target = retrievedAnno.getTarget();
Target target = retrievedAnno.getTarget().get(0);
assertNotNull(target.getHttpUri());
assertTrue(target.getHttpUri().equals(ClientConfiguration.getInstance().getPropAnnotationItemDataEndpoint() + "/000002/_UEDIN_214"));
}
Expand Down Expand Up @@ -125,7 +128,7 @@ public void createTagText() throws IOException, JsonParseException, IllegalAcces
TextBody textBody = ((TextBody) retrievedAnno.getBody());
assertNotNull(textBody.getValue());
assertTrue(textBody.getValue().equals("... this is the textual description of the item ..."));
Target target = retrievedAnno.getTarget();
Target target = retrievedAnno.getTarget().get(0);
assertNotNull(target.getSource());
assertTrue(target.getSource().equals("http://www.europeana1914-1918.eu/attachments/2020601/20841.235882.full.jpg"));
assertNotNull(target.getScope());
Expand All @@ -148,7 +151,7 @@ public void createLink() throws IOException, JsonParseException, IllegalAccessEx

// validate fields
assertTrue(retrievedAnno.getMotivation().equals(MotivationTypes.LINKING.name().toLowerCase()));
Target target = retrievedAnno.getTarget();
Target target = retrievedAnno.getTarget().get(0);
assertNotNull(target.getValues());
assertTrue(target.getValues().contains(ClientConfiguration.getInstance().getPropAnnotationItemDataEndpoint() + "/2020601/https___1914_1918_europeana_eu_contributions_19584"));
}
Expand All @@ -169,7 +172,7 @@ public void createSemanticLink() throws IOException, JsonParseException, Illegal

// validate fields
assertTrue(retrievedAnno.getMotivation().equals(MotivationTypes.LINKING.name().toLowerCase()));
Target target = retrievedAnno.getTarget();
Target target = retrievedAnno.getTarget().get(0);
assertNotNull(target.getHttpUri());
assertTrue(target.getHttpUri().equals(ClientConfiguration.getInstance().getPropAnnotationItemDataEndpoint() + "/2048410/item_I5DUPVW2Q5HT2OQFSVXV7VYODA5P32P6"));
}
Expand Down Expand Up @@ -198,7 +201,7 @@ public void createGraph() throws IOException, JsonParseException, IllegalAccessE
assertTrue(graphBody.getNode().getHttpUri().equals("https://www.wikidata.org/wiki/Q762"));
assertTrue(graphBody.getRelationName().equals("isSimilarTo"));
assertTrue(graphBody.getResourceUri().equals(ClientConfiguration.getInstance().getPropAnnotationItemDataEndpoint() + "/2048410/item_I5DUPVW2Q5HT2OQFSVXV7VYODA5P32P6"));
Target target = retrievedAnno.getTarget();
Target target = retrievedAnno.getTarget().get(0);
assertNotNull(target.getHttpUri());
assertTrue(target.getHttpUri().equals(ClientConfiguration.getInstance().getPropAnnotationItemDataEndpoint() + "/2048410/item_I5DUPVW2Q5HT2OQFSVXV7VYODA5P32P6"));
}
Expand Down Expand Up @@ -232,7 +235,7 @@ public void createSemanticTagSpecific() throws IOException, JsonParseException,
assertTrue(tagBody.getHttpUri().equals("http://sws.geonames.org/2988506"));
assertNotNull(tagBody.getLanguage());
assertTrue(tagBody.getLanguage().equals("en"));
Target target = retrievedAnno.getTarget();
Target target = retrievedAnno.getTarget().get(0);
assertNotNull(target.getHttpUri());
assertTrue(target.getHttpUri().equals(ClientConfiguration.getInstance().getPropAnnotationItemDataEndpoint() + "/09102/_UEDIN_214"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@

import java.io.IOException;
import java.util.Iterator;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.stanbol.commons.exception.JsonParseException;
import org.junit.jupiter.api.Disabled;

import eu.europeana.annotation.client.abstracts.BaseJsonLdApiTest;
import eu.europeana.annotation.definitions.model.Annotation;
import eu.europeana.annotation.definitions.model.vocabulary.MotivationTypes;
Expand Down Expand Up @@ -41,7 +43,7 @@ public void searchAnnotationsWithMultipleTargetsByEachTarget() throws JsonParseE
Annotation annotation = europeanaParser.parseAnnotation(null, annotationStr);
String resJson = "";
// List<Long> idList = new ArrayList<Long>();
Iterator<String> itr = annotation.getTarget().getValues().iterator();
Iterator<String> itr = annotation.getTarget().get(0).getValues().iterator();
while (itr.hasNext()) {
String target = itr.next();
String annotationStrRes = europeanaLdApi.searchLd(
Expand Down Expand Up @@ -75,7 +77,7 @@ public void searchAnnotationsWithMultipleTargetsByEachResearchId() throws JsonPa
, requestBody
);
Annotation annotation = europeanaParser.parseAnnotation(null, annotationStr);
Iterator<String> itr = annotation.getTarget().getResourceIds().iterator();
Iterator<String> itr = annotation.getTarget().get(0).getResourceIds().iterator();
while (itr.hasNext()) {
String resourceId = itr.next();
String annotationStrRes = europeanaLdApi.searchLd(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

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

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

import org.apache.stanbol.commons.exception.JsonParseException;
import org.junit.jupiter.api.Test;

import eu.europeana.annotation.client.config.ClientConfiguration;
import eu.europeana.annotation.definitions.model.Annotation;
import eu.europeana.annotation.definitions.model.body.GraphBody;
Expand Down Expand Up @@ -60,7 +63,7 @@ private void validateGraph(Annotation storedAnno) {
assertEquals(VALUE_BODY_LINK_RELATION, graphBody.getRelationName());
String VALUE_TARGET_LINK_SEMANTIC_URI = ClientConfiguration.getInstance().getPropAnnotationItemDataEndpoint() + "/2048410/item_I5DUPVW2Q5HT2OQFSVXV7VYODA5P32P6";
assertEquals(VALUE_TARGET_LINK_SEMANTIC_URI, graphBody.getResourceUri());
Target target = storedAnno.getTarget();
Target target = storedAnno.getTarget().get(0);
assertNotNull(target.getHttpUri());
assertEquals(VALUE_TARGET_LINK_SEMANTIC_URI, target.getHttpUri());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void searchLink() throws IOException, JsonParseException, IllegalAccessEx
*/
private void validateLink(Annotation storedAnno) {
assertTrue(storedAnno.getMotivation().equals(MotivationTypes.LINKING.name().toLowerCase()));
Target target = storedAnno.getTarget();
Target target = storedAnno.getTarget().get(0);
assertNotNull(target.getValues());
String VALUE_TARGET_LINK_URI = ClientConfiguration.getInstance().getPropAnnotationItemDataEndpoint() + "/2020601/https___1914_1918_europeana_eu_contributions_19584";
assertTrue(target.getValues().contains(VALUE_TARGET_LINK_URI));
Expand Down Expand Up @@ -77,7 +77,7 @@ public void searchSemanticLink() throws IOException, JsonParseException, Illegal
*/
private void validateSemanticLink(Annotation storedAnno) {
assertTrue(storedAnno.getMotivation().equals(MotivationTypes.LINKING.name().toLowerCase()));
Target target = storedAnno.getTarget();
Target target = storedAnno.getTarget().get(0);
assertNotNull(target.getHttpUri());
String VALUE_TARGET_LINK_SEMANTIC_URI = ClientConfiguration.getInstance().getPropAnnotationItemDataEndpoint() + "/2048410/item_I5DUPVW2Q5HT2OQFSVXV7VYODA5P32P6";
assertTrue(target.getHttpUri().equals(VALUE_TARGET_LINK_SEMANTIC_URI));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
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.junit.jupiter.api.Test;

import eu.europeana.annotation.client.config.ClientConfiguration;
import eu.europeana.annotation.definitions.model.Annotation;
import eu.europeana.annotation.definitions.model.body.impl.FullTextResourceBody;
Expand Down Expand Up @@ -61,7 +64,7 @@ private void validateSubtitle(Annotation storedAnno) {
FullTextResourceBody textBody = ((FullTextResourceBody) storedAnno.getBody());
assertNotNull(textBody.getValue());
assertTrue(textBody.getValue().contains("con il grande finale"));
Target target = storedAnno.getTarget();
Target target = storedAnno.getTarget().get(0);
assertNotNull(target.getSource());
assertTrue(target.getSource().equals("http://www.euscreen.eu/item.html?id=EUS_D61E8DF003E30114621A92ABDE846AD7"));
assertNotNull(target.getScope());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
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.junit.jupiter.api.Test;

import eu.europeana.annotation.client.config.ClientConfiguration;
import eu.europeana.annotation.definitions.model.Annotation;
import eu.europeana.annotation.definitions.model.body.TagBody;
Expand Down Expand Up @@ -64,7 +67,7 @@ private void validateSemanticTag(Annotation storedAnno) {
assertTrue(tagBody.getHttpUri().equals("http://www.geonames.org/2988507"));
assertNotNull(tagBody.getLanguage());
assertTrue(tagBody.getLanguage().equals("en"));
Target target = storedAnno.getTarget();
Target target = storedAnno.getTarget().get(0);
assertNotNull(target.getHttpUri());
assertTrue(target.getHttpUri().equals(ClientConfiguration.getInstance().getPropAnnotationItemDataEndpoint() + "/09102/_UEDIN_214"));
}
Expand Down Expand Up @@ -106,7 +109,7 @@ private void validateGeoTag(Annotation storedAnno) {
assertTrue(placeBody.getLatitude().equals("48.853415"));
assertNotNull(placeBody.getLongitude());
assertTrue(placeBody.getLongitude().equals("-102.348800"));
Target target = storedAnno.getTarget();
Target target = storedAnno.getTarget().get(0);
assertNotNull(target.getHttpUri());
assertTrue(target.getHttpUri().equals(ClientConfiguration.getInstance().getPropAnnotationItemDataEndpoint() + "/09102/_UEDIN_214"));
}
Expand Down Expand Up @@ -150,7 +153,7 @@ private void validateTag(Annotation storedAnno) {
TagBody tagBody = ((TagBody) storedAnno.getBody());
assertNotNull(tagBody.getValue());
assertTrue(tagBody.getValue().equals("trombone"));
Target target = storedAnno.getTarget();
Target target = storedAnno.getTarget().get(0);
assertNotNull(target.getHttpUri());
assertTrue(target.getHttpUri().equals(ClientConfiguration.getInstance().getPropAnnotationItemDataEndpoint() + "/000002/_UEDIN_214"));
}
Expand Down Expand Up @@ -197,7 +200,7 @@ private void validateSemanticTagSpecific(Annotation storedAnno) {
assertTrue(tagBody.getHttpUri().equals("http://sws.geonames.org/2988506"));
assertNotNull(tagBody.getLanguage());
assertTrue(tagBody.getLanguage().equals("en"));
Target target = storedAnno.getTarget();
Target target = storedAnno.getTarget().get(0);
assertNotNull(target.getHttpUri());
assertTrue(target.getHttpUri().equals(ClientConfiguration.getInstance().getPropAnnotationItemDataEndpoint() + "/09102/_UEDIN_214"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private void validateDescriptionBody(Annotation storedAnno) {
TextBody textBody = ((TextBody) storedAnno.getBody());
assertNotNull(textBody.getValue());
assertTrue(textBody.getValue().equals("... this is the textual description of the item ..."));
Target target = storedAnno.getTarget();
Target target = storedAnno.getTarget().get(0);
assertNotNull(target.getSource());
assertTrue(target.getSource()
.equals("http://www.europeana1914-1918.eu/attachments/2020601/20841.235882.full.jpg"));
Expand Down Expand Up @@ -123,7 +123,7 @@ private void validateTranscriptionBody(Annotation storedAnno) {
FullTextResourceBody textBody = ((FullTextResourceBody) storedAnno.getBody());
assertNotNull(textBody.getValue());
assertTrue(textBody.getValue().equals("... complete transcribed text in HTML ..."));
Target target = storedAnno.getTarget();
Target target = storedAnno.getTarget().get(0);
assertNotNull(target.getSource());
assertTrue(target.getSource()
.equals("http://www.europeana1914-1918.eu/attachments/2020601/20841.235882.full.jpg"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void createSemanticTagWebResource() throws IOException, JsonParseExceptio
addCreatedAnnotation(storedAnno);
log.info(storedAnno.getBody().getInternalType());
assertTrue(storedAnno.getMotivation().equals(MotivationTypes.TAGGING.name().toLowerCase()));
assertTrue(storedAnno.getTarget().getSource() != null);
assertTrue(storedAnno.getTarget().get(0).getSource() != null);
assertEquals(storedAnno.getBody().getInternalType(), BodyInternalTypes.SEMANTIC_TAG.name());
}

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

import java.util.Date;
import java.util.List;

import eu.europeana.annotation.definitions.model.agent.Agent;
import eu.europeana.annotation.definitions.model.body.Body;
Expand Down Expand Up @@ -28,10 +29,10 @@ public interface Annotation {

public abstract MotivationTypes getMotivationType();

public abstract void setTarget(Target target);

public abstract Target getTarget();
public abstract void setTarget(List<Target> target);

public abstract List<Target> getTarget();

public abstract void setBody(Body body);

public abstract Body getBody();
Expand Down
Loading
Loading