Skip to content

Commit

Permalink
add dependencies for --prov-mode of [preston review]
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorrit Poelen committed Dec 24, 2024
1 parent 8f51cc5 commit d059ef5
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 13 deletions.
55 changes: 43 additions & 12 deletions src/main/java/org/globalbioticinteractions/elton/cmd/CmdReview.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.globalbioticinteractions.elton.Elton;
import org.globalbioticinteractions.elton.store.AccessLogger;
import org.globalbioticinteractions.elton.store.ActivityListener;
import org.globalbioticinteractions.elton.store.LocalPathToHashIRI;
import org.globalbioticinteractions.elton.util.DatasetRegistryUtil;
import org.globalbioticinteractions.elton.util.NodeFactoryNull;
import org.globalbioticinteractions.elton.util.ProgressCursorFactory;
Expand Down Expand Up @@ -111,20 +112,34 @@ public void doRun() {

InputStreamFactory factory = createInputStreamFactory();

ActivityListener dereferenceListener =
ActivityListener activityListener =
getEnableProvMode()
? getActivityListenerWithProv()
: new AccessLogger(DatasetRegistryUtil.NAMESPACE_LOCAL, getProvDir());

PrintStream dataOut = getDataSink(getStdout());



for (URI localNamespace : localNamespaces) {

DatasetRegistryUtil.ResourceServiceListening resourceServiceLocalAndRemote
= new DatasetRegistryUtil.ResourceServiceListening(
getActivityIdFactory(),
activityListener,
getActivityContext(),
new ResourceServiceLocalAndRemote(factory, new File(getDataDir())),
new LocalPathToHashIRI(new File(getDataDir()))
);


DatasetRegistry registryLocal = DatasetRegistryUtil.forLocalDir(
localNamespace,
new ResourceServiceLocalAndRemote(factory, new File(getDataDir())),
resourceServiceLocalAndRemote,
getContentPathFactory(),
getDataDir(),
getProvDir(),
dereferenceListener,
activityListener,
getActivityContext(),
getActivityIdFactory()
);
Expand All @@ -137,7 +152,12 @@ public void doRun() {
);
}

reviewCachedOrRemote(remoteNamespaces, factory, dataOut);
reviewCachedOrRemote(
remoteNamespaces,
factory,
dataOut,
activityListener
);

} catch (StudyImporterException e) {
throw new RuntimeException(e);
Expand All @@ -151,16 +171,27 @@ public String getDescription() {

private void reviewCachedOrRemote(List<String> namespaces,
InputStreamFactory inputStreamFactory,
PrintStream dataOut) throws StudyImporterException {
PrintStream dataOut, ActivityListener activityListener) throws StudyImporterException {
for (String namespace : namespaces) {

DatasetRegistryUtil.ResourceServiceListening resourceServiceLocal
= new DatasetRegistryUtil.ResourceServiceListening(
getActivityIdFactory(),
activityListener,
getActivityContext(),
new ResourceServiceLocal(inputStreamFactory),
new LocalPathToHashIRI(new File(getDataDir()))
);

DatasetRegistry registry = DatasetRegistryUtil.forCache(
getDataDir(),
getProvDir(),
resourceServiceLocal,
getContentPathFactory(),
getProvenancePathFactory()
);
review(namespace,
DatasetRegistryUtil.forCache(
getDataDir(),
getProvDir(),
new ResourceServiceLocal(inputStreamFactory),
getContentPathFactory(),
getProvenancePathFactory()
),
registry,
inputStreamFactory,
shouldSkipHeader(),
dataOut
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ private static DatasetRegistry forCacheOrLocalDir(String dataDir,
return registry;
}

private static class ResourceServiceListening implements ResourceService {
public static class ResourceServiceListening implements ResourceService {
private final Supplier<IRI> activityIdFactory;
private final ActivityListener activityListener;
private final ActivityContext ctx;
Expand Down

0 comments on commit d059ef5

Please sign in to comment.