Skip to content

Commit 22a8c33

Browse files
authored
Merge pull request #279 from kit-data-manager/development
Next Version (2.1.0-rc4)
2 parents 81491bf + 6a21367 commit 22a8c33

File tree

21 files changed

+1314
-95
lines changed

21 files changed

+1314
-95
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ jobs:
3838

3939
steps:
4040
- name: Checkout repository
41-
uses: actions/checkout@v4
41+
uses: actions/checkout@v5
4242

4343
# Initializes the CodeQL tools for scanning.
4444
- name: Initialize CodeQL
45-
uses: github/codeql-action/init@v3
45+
uses: github/codeql-action/init@v4
4646
with:
4747
languages: ${{ matrix.language }}
4848
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -56,7 +56,7 @@ jobs:
5656
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
5757
# If this step fails, then you should remove it and run the build manually (see below)
5858
- name: Autobuild
59-
uses: github/codeql-action/autobuild@v3
59+
uses: github/codeql-action/autobuild@v4
6060

6161
# Command-line programs to run using the OS shell.
6262
# See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
@@ -69,4 +69,4 @@ jobs:
6969
# ./location_of_script_within_repo/buildscript.sh
7070

7171
- name: Perform CodeQL Analysis
72-
uses: github/codeql-action/analyze@v3
72+
uses: github/codeql-action/analyze@v4

.github/workflows/gradle.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,21 @@ jobs:
2525
runs-on: ${{ matrix.os }}
2626

2727
steps:
28-
- uses: actions/checkout@v4
28+
- uses: actions/checkout@v5
2929
- name: Set up openJDK version
30-
uses: actions/setup-java@v4
30+
uses: actions/setup-java@v5
3131
with:
3232
java-version: ${{ matrix.jdk }}
3333
distribution: 'zulu'
3434
- name: Install Dependencies
3535
run: npm install -g ro-crate-html-js
3636
- name: Setup Gradle
37-
uses: gradle/actions/setup-gradle@v4
37+
uses: gradle/actions/setup-gradle@v5
3838
- name: Build and Test with Gradle
3939
run: ./gradlew -Dprofile=release build
4040
- name: Upload (test) reports as artifact on GitHub on manual runs
4141
if: github.event_name == 'workflow_dispatch'
42-
uses: actions/upload-artifact@v4
42+
uses: actions/upload-artifact@v5
4343
with:
4444
name: test-report ${{ matrix.os }} JDK ${{ matrix.jdk }}
4545
path: build/reports

.github/workflows/publishRelease.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ jobs:
88
publish:
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/checkout@v4
11+
- uses: actions/checkout@v5
1212
- name: Set up Java
13-
uses: actions/setup-java@v4
13+
uses: actions/setup-java@v5
1414
with:
1515
java-version: 21
1616
distribution: 'zulu' # openjdk

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
.classpath
2+
.project
3+
.settings
4+
.tmp
5+
16
### VSCode ###
27
.vscode/*
38
#!.vscode/settings.json

build.gradle

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,21 @@ plugins {
1313
// Publishing of JAR to Nexus instances (e.g., OSSRH)
1414
// https://github.com/gradle-nexus/publish-plugin
1515
id "io.github.gradle-nexus.publish-plugin" version "2.0.0"
16-
id "io.freefair.maven-publish-java" version "8.13.1"
16+
id "io.freefair.maven-publish-java" version "9.0.0"
1717
}
1818

19-
group 'edu.kit.datamanager'
19+
group = 'edu.kit.datamanager'
2020
description = "A library for easy creation and modification of valid RO-Crates."
2121

2222
println "Running gradle version: $gradle.gradleVersion"
2323
println "Building ${name} version: ${version}"
2424
println "JDK version: ${JavaVersion.current()}"
2525
println "Profile (system property): ${System.getProperty('profile')}"
2626

27-
sourceCompatibility = JavaVersion.VERSION_17
28-
targetCompatibility = JavaVersion.VERSION_17
27+
java {
28+
sourceCompatibility = JavaVersion.VERSION_17
29+
targetCompatibility = JavaVersion.VERSION_17
30+
}
2931

3032
if (JavaVersion.current() == JavaVersion.VERSION_17) {
3133
println "Setting encoding to UTF-8 manually"
@@ -38,12 +40,12 @@ repositories {
3840
}
3941

4042
ext {
41-
jacksonVersion = '2.19.0'
43+
jacksonVersion = '2.20.1'
4244
}
4345

4446
dependencies {
4547
// JUnit setup for testing
46-
testImplementation(platform("org.junit:junit-bom:5.13.0"))
48+
testImplementation(platform("org.junit:junit-bom:6.0.1"))
4749
testImplementation('org.junit.jupiter:junit-jupiter')
4850
testRuntimeOnly('org.junit.platform:junit-platform-launcher')
4951
// JSON object mapping / (de-)serialization
@@ -52,19 +54,19 @@ dependencies {
5254
// http client
5355
implementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.14'
5456
// common file system operations
55-
implementation group: 'commons-io', name: 'commons-io', version: '2.19.0'
57+
implementation group: 'commons-io', name: 'commons-io', version: '2.21.0'
5658
// read from and write to zip files
5759
implementation group: 'net.lingala.zip4j', name: 'zip4j', version: '2.11.5'
5860
// compare json documents in tests
59-
implementation 'com.github.fslev:json-compare:7.0'
61+
implementation 'com.github.fslev:json-compare:7.1'
6062
// url validator
61-
implementation group: 'commons-validator', name: 'commons-validator', version: '1.9.0'
63+
implementation group: 'commons-validator', name: 'commons-validator', version: '1.10.0'
6264
// logging
6365
implementation group: 'org.slf4j', name: 'slf4j-jdk14', version: '2.0.17'
6466
// JSON-LD, Zenodo mapping
65-
implementation group: 'com.apicatalog', name: 'titanium-json-ld', version: '1.6.0'
67+
implementation group: 'com.apicatalog', name: 'titanium-json-ld', version: '1.7.0'
6668
// metadata validation, profiles based on JSON schema
67-
implementation group: "com.networknt", name: "json-schema-validator", version: "1.5.7"
69+
implementation group: "com.networknt", name: "json-schema-validator", version: "1.5.9"
6870
implementation 'org.glassfish:jakarta.json:2.0.1'
6971
//JTE for template processing
7072
implementation('gg.jte:jte:3.2.1')
@@ -189,7 +191,7 @@ jacocoTestReport {
189191
}
190192

191193
jacoco {
192-
toolVersion = "0.8.13"
194+
toolVersion = "0.8.14"
193195
}
194196

195197
// maxParallelForks(2)

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

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

Lines changed: 59 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@
77
import java.util.Set;
88

99
import edu.kit.datamanager.ro_crate.context.CrateMetadataContext;
10+
import edu.kit.datamanager.ro_crate.hierarchy.HierarchyRecognitionConfig;
11+
import edu.kit.datamanager.ro_crate.hierarchy.HierarchyRecognitionResult;
1012
import edu.kit.datamanager.ro_crate.entities.AbstractEntity;
1113
import edu.kit.datamanager.ro_crate.entities.contextual.ContextualEntity;
1214
import edu.kit.datamanager.ro_crate.entities.data.DataEntity;
15+
import edu.kit.datamanager.ro_crate.entities.data.DataSetEntity;
1316
import edu.kit.datamanager.ro_crate.entities.data.RootDataEntity;
1417
import edu.kit.datamanager.ro_crate.preview.CratePreview;
1518
import edu.kit.datamanager.ro_crate.special.CrateVersion;
@@ -103,15 +106,27 @@ public interface Crate {
103106

104107
String getJsonMetadata();
105108

106-
DataEntity getDataEntityById(java.lang.String id);
109+
/**
110+
* Gets a data entity by its ID.
111+
* @param id the ID of the data entity
112+
* @return the DataEntity with the specified ID or null if not found
113+
*/
114+
DataEntity getDataEntityById(String id);
115+
116+
/**
117+
* Gets a data set entity by its ID.
118+
* @param id the ID of the data set entity
119+
* @return the DataSetEntity with the specified ID or empty if not found
120+
*/
121+
Optional<DataSetEntity> getDataSetById(String id);
107122

108123
Set<DataEntity> getAllDataEntities();
109124

110-
ContextualEntity getContextualEntityById(java.lang.String id);
125+
ContextualEntity getContextualEntityById(String id);
111126

112127
Set<ContextualEntity> getAllContextualEntities();
113128

114-
AbstractEntity getEntityById(java.lang.String id);
129+
AbstractEntity getEntityById(String id);
115130

116131
/**
117132
* Adds a data entity to the crate.
@@ -120,12 +135,31 @@ public interface Crate {
120135
*/
121136
void addDataEntity(DataEntity entity);
122137

138+
/**
139+
* Adds a data entity to the crate with a specified parent ID.
140+
* <p>
141+
* Consider using
142+
* @param entity the DataEntity to add to this crate.
143+
* @param parentId the ID of the parent entity. Must not be null.
144+
* @throws IllegalArgumentException if parentId is null or not found, or not a DataEntity.
145+
*/
146+
void addDataEntity(DataEntity entity, String parentId) throws IllegalArgumentException;
147+
123148
void addContextualEntity(ContextualEntity entity);
124149

125150
void deleteEntityById(String entityId);
126151

127152
void setUntrackedFiles(Collection<File> files);
128153

154+
/**
155+
* Unsafely adds a collection of entities to the crate.
156+
* <p>
157+
* WARNING: This method does not perform any checks and may lead to an inconsistent crate state.
158+
*
159+
* @param entities the collection of entities to add
160+
* @deprecated use individual add methods to ensure crate consistency. If you really need an unchecked method, consider creating a subclass or contact us at our issue tracker so we can discuss replacements before removal.
161+
*/
162+
@Deprecated(forRemoval = true)
129163
void addFromCollection(Collection<? extends AbstractEntity> entities);
130164

131165
void addItemFromDataCite(String locationUrl);
@@ -135,4 +169,26 @@ public interface Crate {
135169
void deleteUrlFromContext(String url);
136170

137171
Collection<File> getUntrackedFiles();
172+
173+
/**
174+
* Automatically recognizes hierarchical file structure from DataEntity IDs
175+
* and connects them using hasPart relationships.
176+
* <p>
177+
* WARNING: This will not change existing hasPart relationships.
178+
*
179+
* @param addInverseRelationships if true, also adds isPartOf relationships from child to parent
180+
* @return result object containing information about what was processed, as well as potential errors.
181+
*/
182+
HierarchyRecognitionResult createDataEntityFileStructure(boolean addInverseRelationships);
183+
184+
/**
185+
* Automatically recognizes hierarchical file structure from DataEntity IDs
186+
* and connects them using hasPart relationships with fine-grained configuration.
187+
* <p>
188+
* Note: Only processes IDs that appear to be relative file paths.
189+
*
190+
* @param config configuration object specifying how the recognition should behave
191+
* @return result object containing information about what was processed, as well as potential errors.
192+
*/
193+
HierarchyRecognitionResult createDataEntityFileStructure(HierarchyRecognitionConfig config);
138194
}

0 commit comments

Comments
 (0)