-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for updating cache from local archive
- Loading branch information
jhpoelen
committed
Mar 20, 2020
1 parent
9b256f0
commit 6548204
Showing
6 changed files
with
112 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 0 additions & 17 deletions
17
src/main/java/org/globalbioticinteractions/elton/cmd/RegistryNameValidator.java
This file was deleted.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
src/main/java/org/globalbioticinteractions/elton/util/DatasetRegistrySingleDir.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.globalbioticinteractions.elton.util; | ||
|
||
import org.eol.globi.util.InputStreamFactory; | ||
import org.globalbioticinteractions.cache.CachePullThrough; | ||
import org.globalbioticinteractions.dataset.Dataset; | ||
import org.globalbioticinteractions.dataset.DatasetFinderException; | ||
import org.globalbioticinteractions.dataset.DatasetImpl; | ||
import org.globalbioticinteractions.dataset.DatasetRegistry; | ||
import org.globalbioticinteractions.dataset.DatasetWithCache; | ||
|
||
import java.net.URI; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
|
||
public class DatasetRegistrySingleDir implements DatasetRegistry { | ||
private final URI localArchiveDir; | ||
private final InputStreamFactory streamFactory; | ||
private final String cacheDir; | ||
|
||
public DatasetRegistrySingleDir(URI localArchiveDir, String cacheDir, InputStreamFactory streamFactory) { | ||
this.localArchiveDir = localArchiveDir; | ||
this.cacheDir = cacheDir; | ||
this.streamFactory = streamFactory; | ||
} | ||
|
||
@Override | ||
public Collection<String> findNamespaces() throws DatasetFinderException { | ||
return Collections.singletonList(DatasetRegistryUtil.NAMESPACE_LOCAL); | ||
} | ||
|
||
@Override | ||
public Dataset datasetFor(String namespace) throws DatasetFinderException { | ||
DatasetImpl local = new DatasetImpl(DatasetRegistryUtil.NAMESPACE_LOCAL, localArchiveDir, streamFactory); | ||
|
||
return new DatasetWithCache(local, | ||
new CachePullThrough(DatasetRegistryUtil.NAMESPACE_LOCAL, cacheDir, streamFactory)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/test/java/org/globalbioticinteractions/elton/cmd/DatasetRegistryFactoryImplTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package org.globalbioticinteractions.elton.cmd; | ||
|
||
import org.globalbioticinteractions.dataset.DatasetFinderException; | ||
import org.globalbioticinteractions.dataset.DatasetRegistry; | ||
import org.hamcrest.core.Is; | ||
import org.junit.Test; | ||
|
||
import java.net.URI; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
|
||
public class DatasetRegistryFactoryImplTest { | ||
|
||
@Test | ||
public void list() throws DatasetFinderException { | ||
List<DatasetRegistry> registries = new ArrayList<>(); | ||
Set<String> supportedRegistries = DatasetRegistryFactoryImpl.getSupportedRegistries(); | ||
for (String supportedRegistry : supportedRegistries) { | ||
DatasetRegistry registry = new DatasetRegistryFactoryImpl( | ||
URI.create("some:uri"), "someCacheDir", in -> in) | ||
.createRegistryByName(supportedRegistry); | ||
registries.add(registry); | ||
} | ||
assertThat(registries.size(), Is.is(supportedRegistries.size())); | ||
} | ||
|
||
} |