Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorrit Poelen committed Dec 18, 2024
1 parent 4e14a2d commit c008712
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ protected void doRun() {
new ActivityListener() {

@Override
public void onStarted(IRI parentActivityId, UUID activityId, IRI request) {
public void onStarted(IRI parentActivityId, IRI activityId, IRI request) {

}

@Override
public void onCompleted(IRI parentActivityId, UUID activityId, IRI request, IRI response, URI localPathOfResponseData) {
public void onCompleted(IRI parentActivityId, IRI activityId, IRI request, IRI response, URI localPathOfResponseData) {

}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.globalbioticinteractions.elton.cmd;

import bio.guoda.preston.RefNodeFactory;
import bio.guoda.preston.cmd.ActivityContext;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.rdf.api.IRI;
Expand Down Expand Up @@ -114,10 +115,10 @@ public String getDescription() {
return null;
}
},
new Supplier<UUID>() {
new Supplier<IRI>() {
@Override
public UUID get() {
return UUID.randomUUID();
public IRI get() {
return RefNodeFactory.toIRI(UUID.randomUUID());
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ public AccessLogger(String namespace, String provDir) {
}

@Override
public void onStarted(IRI parentActivityId, UUID activityId, IRI request) {
public void onStarted(IRI parentActivityId, IRI activityId, IRI request) {

}

@Override
public void onCompleted(IRI parentActivityId, UUID activityId, IRI request, IRI response, URI localPathOfResponseData) {
public void onCompleted(IRI parentActivityId, IRI activityId, IRI request, IRI response, URI localPathOfResponseData) {
try {
ContentProvenance contentProvenanceWithNamespace
= new ContentProvenance(this.namespace,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@
import org.apache.commons.rdf.api.IRI;

import java.net.URI;
import java.util.UUID;

public interface ActivityListener {

void onStarted(
IRI parentActivityId,
UUID activityId,
IRI activityId,
IRI request
);

void onCompleted(
IRI parentActivityId,
UUID activityId,
IRI activityId,
IRI request,
IRI response,
URI localPathOfResponseData
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ public ActivityProxy(List<ActivityListener> listeners) {
}

@Override
public void onStarted(IRI parentActivityId, UUID activityId, IRI request) {
public void onStarted(IRI parentActivityId, IRI activityId, IRI request) {

}

@Override
public void onCompleted(IRI parentActivityId, UUID activityId, IRI request, IRI response, URI localPathOfResponseData) {
public void onCompleted(IRI parentActivityId, IRI activityId, IRI request, IRI response, URI localPathOfResponseData) {
listeners.forEach(l -> l.onCompleted(parentActivityId, activityId, request, response, localPathOfResponseData));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.util.UUID;
import java.util.function.Supplier;

public class CachePullThroughPrestonStore extends CachePullThrough {
Expand All @@ -27,7 +26,7 @@ public class CachePullThroughPrestonStore extends CachePullThrough {
private final ResourceService resourceService;
private final String dataDir;
private final ActivityContext ctx;
private final Supplier<UUID> uuidFactory;
private final Supplier<IRI> iriFactory;

private ActivityListener dereferenceListener;

Expand All @@ -38,7 +37,7 @@ public CachePullThroughPrestonStore(String namespace,
String provDir,
ActivityListener dereferenceListener,
ActivityContext ctx,
Supplier<UUID> uuidFactory) {
Supplier<IRI> iriFactory) {
super(namespace,
resourceServiceLocal,
contentPathFactory,
Expand All @@ -50,7 +49,7 @@ public CachePullThroughPrestonStore(String namespace,
this.resourceService = resourceServiceLocal;
this.dereferenceListener = dereferenceListener;
this.ctx = ctx;
this.uuidFactory = uuidFactory;
this.iriFactory = iriFactory;
}

@Override
Expand All @@ -76,7 +75,7 @@ public InputStream retrieve(URI resourceURI) throws IOException {
try {
IRI request = RefNodeFactory.toIRI(resourceURI);
IRI parentActivityId = ctx.getActivity();
UUID activityId = uuidFactory.get();
IRI activityId = iriFactory.get();

dereferenceListener.onStarted(
parentActivityId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ public ProvLogger(StatementListener listener) {
}

@Override
public void onStarted(IRI parentActivityId, UUID activityId, IRI request) {
public void onStarted(IRI parentActivityId, IRI activityId, IRI request) {

}

@Override
public void onCompleted(IRI parentActivityId, UUID activityId, IRI request, IRI response, URI localPathOfResponseData) {
public void onCompleted(IRI parentActivityId, IRI activityId, IRI request, IRI response, URI localPathOfResponseData) {
if (listener != null) {
ActivityUtil.emitDownloadActivity(
request,
Expand All @@ -36,7 +36,7 @@ public void emit(Quad quad) {
listener.on(quad);
}
},
Optional.of(RefNodeFactory.toIRI(activityId))
Optional.of(activityId)
);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.globalbioticinteractions.elton.util;

import bio.guoda.preston.RefNodeFactory;
import bio.guoda.preston.cmd.ActivityContext;
import org.apache.commons.rdf.api.IRI;
import org.eol.globi.service.ResourceService;
Expand Down Expand Up @@ -78,10 +79,10 @@ public String getDescription() {
return null;
}
},
new Supplier<UUID>() {
new Supplier<IRI>() {
@Override
public UUID get() {
return UUID.randomUUID();
public IRI get() {
return RefNodeFactory.toIRI(UUID.randomUUID());
}
}
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.globalbioticinteractions.elton.cmd;

import org.apache.commons.rdf.api.IRI;
import org.globalbioticinteractions.dataset.DatasetRegistryException;
import org.globalbioticinteractions.dataset.DatasetRegistry;
import org.globalbioticinteractions.dataset.DatasetRegistryException;
import org.globalbioticinteractions.elton.store.ActivityListener;
import org.hamcrest.core.Is;
import org.junit.Test;
Expand All @@ -11,7 +11,6 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.UUID;

import static org.hamcrest.MatcherAssert.assertThat;

Expand All @@ -30,12 +29,12 @@ public void list() throws DatasetRegistryException {
new ActivityListener() {

@Override
public void onStarted(IRI parentActivityId, UUID activityId, IRI request) {
public void onStarted(IRI parentActivityId, IRI activityId, IRI request) {

}

@Override
public void onCompleted(IRI parentActivityId, UUID activityId, IRI request, IRI response, URI localPathOfResponseData) {
public void onCompleted(IRI parentActivityId, IRI activityId, IRI request, IRI response, URI localPathOfResponseData) {

}
}).createRegistryByName(supportedRegistry);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void testCreatProvDirIfNotExists() throws IOException {
String namespace = "some/namespace";
new AccessLogger(namespace, provDir).onCompleted(
RefNodeFactory.toIRI(UUID.randomUUID()),
UUID.randomUUID(),
RefNodeFactory.toIRI(UUID.randomUUID()),
RefNodeFactory.toIRI("some:request"),
RefNodeFactory.toIRI("some:response"),
URI.create("foo/bar")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,20 @@ public Literal get() {
}

@Override
public void onStarted(IRI parentActivitiyId, UUID activityId, IRI request) {
IRI downloadActivity = RefNodeFactory.toIRI(activityId);
listener.on(RefNodeFactory.toStatement(downloadActivity, downloadActivity, RefNodeConstants.IS_A, RefNodeConstants.GENERATION));
listener.on(RefNodeFactory.toStatement(downloadActivity, downloadActivity, RefNodeConstants.WAS_INFORMED_BY, parentActivitiyId));
listener.on(RefNodeFactory.toStatement(downloadActivity, downloadActivity, RefNodeConstants.STARTED_AT_TIME, clock.get()));
public void onStarted(IRI parentActivitiyId, IRI activityId, IRI request) {
listener.on(RefNodeFactory.toStatement(activityId, activityId, RefNodeConstants.IS_A, RefNodeConstants.GENERATION));
listener.on(RefNodeFactory.toStatement(activityId, activityId, RefNodeConstants.WAS_INFORMED_BY, parentActivitiyId));
listener.on(RefNodeFactory.toStatement(activityId, activityId, RefNodeConstants.STARTED_AT_TIME, clock.get()));
}

@Override
public void onCompleted(IRI parentActivityId, UUID activityId, IRI request, IRI response, URI localPathOfResponseData) {
BlankNodeOrIRI downloadActivity = RefNodeFactory.toIRI(activityId);
listener.on(RefNodeFactory.toStatement(downloadActivity, response, RefNodeConstants.WAS_GENERATED_BY, downloadActivity));
listener.on(RefNodeFactory.toStatement(downloadActivity, response, RefNodeConstants.QUALIFIED_GENERATION, downloadActivity));
listener.on(RefNodeFactory.toStatement(downloadActivity, downloadActivity, RefNodeConstants.GENERATED_AT_TIME, clock.get()));
listener.on(RefNodeFactory.toStatement(downloadActivity, downloadActivity, RefNodeConstants.IS_A, RefNodeConstants.GENERATION));
listener.on(RefNodeFactory.toStatement(downloadActivity, downloadActivity, RefNodeConstants.USED, request));
listener.on(RefNodeFactory.toStatement(downloadActivity, request, RefNodeConstants.HAS_VERSION, response));
listener.on(RefNodeFactory.toStatement(downloadActivity, downloadActivity, RefNodeConstants.ENDED_AT_TIME, clock.get()));
public void onCompleted(IRI parentActivityId, IRI activityId, IRI request, IRI response, URI localPathOfResponseData) {
listener.on(RefNodeFactory.toStatement(activityId, response, RefNodeConstants.WAS_GENERATED_BY, activityId));
listener.on(RefNodeFactory.toStatement(activityId, response, RefNodeConstants.QUALIFIED_GENERATION, activityId));
listener.on(RefNodeFactory.toStatement(activityId, activityId, RefNodeConstants.GENERATED_AT_TIME, clock.get()));
listener.on(RefNodeFactory.toStatement(activityId, activityId, RefNodeConstants.IS_A, RefNodeConstants.GENERATION));
listener.on(RefNodeFactory.toStatement(activityId, activityId, RefNodeConstants.USED, request));
listener.on(RefNodeFactory.toStatement(activityId, request, RefNodeConstants.HAS_VERSION, response));
listener.on(RefNodeFactory.toStatement(activityId, activityId, RefNodeConstants.ENDED_AT_TIME, clock.get()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ public IRI getActivity() {
public String getDescription() {
return null;
}
}, new Supplier<UUID>() {
}, new Supplier<IRI>() {
@Override
public UUID get() {
return UUID.randomUUID();
public IRI get() {
return RefNodeFactory.toIRI(UUID.randomUUID());
}
}
);
Expand Down Expand Up @@ -188,11 +188,11 @@ public String getDescription() {
}
};

Supplier<UUID> uuidFactory = new Supplier<UUID>() {
Supplier<IRI> uuidFactory = new Supplier<IRI>() {

@Override
public UUID get() {
return UUID.fromString("e4fe8c5c-1455-46c6-bcfe-f11a065978aa");
public IRI get() {
return RefNodeFactory.toIRI(UUID.fromString("e4fe8c5c-1455-46c6-bcfe-f11a065978aa"));
}
};

Expand Down

0 comments on commit c008712

Please sign in to comment.