Skip to content

Commit 0ab3f3c

Browse files
committed
Merged with remote dev
2 parents 37ca46d + fe1bb10 commit 0ab3f3c

File tree

22 files changed

+351
-243
lines changed

22 files changed

+351
-243
lines changed

.github/workflows/gradle.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,6 @@ jobs:
2626
runs-on: ${{ matrix.os }}
2727

2828
steps:
29-
- name: Debug trigger conditions
30-
run: |
31-
echo "github.event_name=${{ github.event_name }}"
32-
echo "github.event.pull_request.head.repo.full_name=${{ github.event.pull_request.head.repo.full_name }}"
33-
echo "github.event.pull_request.base.repo.full_name=${{ github.event.pull_request.base.repo.full_name }}"
34-
echo "github.event.action=${{ github.event.action }}"
3529
- uses: actions/checkout@v4
3630
- name: Set up openJDK version
3731
uses: actions/setup-java@v4

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ For StaticPreview, the constuctor is a bit different, such that it looks as foll
182182
File pathToMainPreviewHtml = new File("localPath");
183183
File pathToAdditionalFiles = new File("localFolder");
184184
RoCrate roCrate = new RoCrateBuilder("name", "description", "datePublished", "licenseIdentifier")
185-
.setPreview(new StaticPreview(pathToMainPreviewHtml, pathToAdditionalFiles)
185+
.setPreview(new StaticPreview(pathToMainPreviewHtml, pathToAdditionalFiles))
186186
.build();
187187
```
188188

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ ext {
4343

4444
dependencies {
4545
// JUnit setup for testing
46-
testImplementation(platform("org.junit:junit-bom:5.12.1"))
46+
testImplementation(platform("org.junit:junit-bom:5.12.2"))
4747
testImplementation('org.junit.jupiter:junit-jupiter')
4848
testRuntimeOnly('org.junit.platform:junit-platform-launcher')
4949
// JSON object mapping / (de-)serialization
@@ -52,7 +52,7 @@ dependencies {
5252
// http client
5353
implementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.14'
5454
// common file system operations
55-
implementation group: 'commons-io', name: 'commons-io', version: '2.18.0'
55+
implementation group: 'commons-io', name: 'commons-io', version: '2.19.0'
5656
// read from and write to zip files
5757
implementation group: 'net.lingala.zip4j', name: 'zip4j', version: '2.11.5'
5858
// compare json documents in tests

ro-crate-preview.html

Lines changed: 0 additions & 130 deletions
This file was deleted.

src/main/java/edu/kit/datamanager/ro_crate/Crate.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.io.File;
44
import java.util.Collection;
5+
import java.util.Map;
56
import java.util.Optional;
67
import java.util.Set;
78

@@ -51,6 +52,25 @@ public interface Crate {
5152

5253
void setMetadataContext(CrateMetadataContext metadataContext);
5354

55+
/**
56+
* Get the value of a key from the metadata context.
57+
* @param key the key to be searched
58+
* @return the value of the key, null if not found
59+
*/
60+
String getMetadataContextValueOf(String key);
61+
62+
/**
63+
* Get an immutable collection of the keys in the metadata context.
64+
* @return the keys in the metadata context
65+
*/
66+
Set<String> getMetadataContextKeys();
67+
68+
/**
69+
* Get an immutable map of the context.
70+
* @return an immutable map containing the context key-value pairs
71+
*/
72+
Map<String, String> getMetadataContextPairs();
73+
5474
RootDataEntity getRootDataEntity();
5575

5676
void setRootDataEntity(RootDataEntity rootDataEntity);

src/main/java/edu/kit/datamanager/ro_crate/RoCrate.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,20 @@ public void setMetadataContext(CrateMetadataContext metadataContext) {
7171
}
7272

7373
@Override
74+
public String getMetadataContextValueOf(String key) {
75+
return this.metadataContext.getValueOf(key);
76+
}
77+
78+
@Override
79+
public Set<String> getMetadataContextKeys() {
80+
return this.metadataContext.getKeys();
81+
}
82+
83+
@Override
84+
public Map<String, String> getMetadataContextPairs() {
85+
return this.metadataContext.getPairs();
86+
}
87+
7488
public ContextualEntity getJsonDescriptor() {
7589
return jsonDescriptor;
7690
}

src/main/java/edu/kit/datamanager/ro_crate/context/CrateMetadataContext.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
import edu.kit.datamanager.ro_crate.entities.AbstractEntity;
66

7+
import java.util.Map;
8+
import java.util.Set;
9+
710
/**
811
* Interface for the metadata context.
912
* Most often in an ROCrate this is the default context,
@@ -22,6 +25,25 @@ public interface CrateMetadataContext {
2225

2326
void addToContext(String key, String value);
2427

28+
/**
29+
* Get the value of a key from the context.
30+
* @param key the key to be searched
31+
* @return the value of the key, null if not found
32+
*/
33+
String getValueOf(String key);
34+
35+
/**
36+
* Get an immutable collection of the keys in the metadata context.
37+
* @return the keys in the metadata context
38+
*/
39+
Set<String> getKeys();
40+
41+
/**
42+
* Get an immutable map of the context.
43+
* @return an immutable map containing the context key-value pairs
44+
*/
45+
Map<String, String> getPairs();
46+
2547
void deleteValuePairFromContext(String key);
2648

2749
void deleteUrlFromContext(String url);

src/main/java/edu/kit/datamanager/ro_crate/context/RoCrateMetadataContext.java

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class RoCrateMetadataContext implements CrateMetadataContext {
3131
protected static final String DEFAULT_CONTEXT_LOCATION = "default_context/version1.1.json";
3232
protected static JsonNode defaultContext = null;
3333

34-
protected final Set<String> url = new HashSet<>();
34+
protected final Set<String> urls = new HashSet<>();
3535
protected final HashMap<String, String> contextMap = new HashMap<>();
3636
// we need to keep the ones that are no coming from url
3737
// for the final representation
@@ -89,7 +89,7 @@ public ObjectNode getContextJsonEntity() {
8989
ArrayNode array = objectMapper.createArrayNode();
9090
ObjectNode jsonNode = objectMapper.createObjectNode();
9191
ObjectNode finalNode = objectMapper.createObjectNode();
92-
for (String e : url) {
92+
for (String e : urls) {
9393
array.add(e);
9494
}
9595
for (Map.Entry<String, String> s : other.entrySet()) {
@@ -156,7 +156,7 @@ public boolean checkEntity(AbstractEntity entity) {
156156

157157
@Override
158158
public void addToContextFromUrl(String url) {
159-
this.url.add(url);
159+
this.urls.add(url);
160160

161161
ObjectMapper objectMapper = MyObjectMapper.getMapper();
162162

@@ -200,6 +200,29 @@ public void addToContext(String key, String value) {
200200
this.other.put(key, value);
201201
}
202202

203+
@Override
204+
public String getValueOf(String key) {
205+
return Optional.ofNullable(this.contextMap.get(key))
206+
.orElseGet(() -> this.other.get(key));
207+
}
208+
209+
@Override
210+
public Set<String> getKeys() {
211+
List<String> merged = new ArrayList<>();
212+
merged.addAll(this.contextMap.keySet());
213+
merged.addAll(this.other.keySet());
214+
return Set.copyOf(merged);
215+
}
216+
217+
@Override
218+
public Map<String, String> getPairs() {
219+
Map<String, String> merged = new HashMap<>();
220+
merged.putAll(this.contextMap);
221+
merged.putAll(this.other);
222+
return Map.copyOf(merged);
223+
}
224+
225+
203226
@Override
204227
public void deleteValuePairFromContext(String key) {
205228
this.contextMap.remove(key);
@@ -208,7 +231,7 @@ public void deleteValuePairFromContext(String key) {
208231

209232
@Override
210233
public void deleteUrlFromContext(String url) {
211-
this.url.remove(url);
234+
this.urls.remove(url);
212235
}
213236

214237
}

0 commit comments

Comments
 (0)