77import java .util .Set ;
88
99import 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 ;
1012import edu .kit .datamanager .ro_crate .entities .AbstractEntity ;
1113import edu .kit .datamanager .ro_crate .entities .contextual .ContextualEntity ;
1214import edu .kit .datamanager .ro_crate .entities .data .DataEntity ;
15+ import edu .kit .datamanager .ro_crate .entities .data .DataSetEntity ;
1316import edu .kit .datamanager .ro_crate .entities .data .RootDataEntity ;
1417import edu .kit .datamanager .ro_crate .preview .CratePreview ;
1518import 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