-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70 from DiSSCo/feature/iiif-er
Update EntityRelationship + IIIF mediaType
- Loading branch information
Showing
24 changed files
with
265 additions
and
84 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
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
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
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
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
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
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
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
47 changes: 47 additions & 0 deletions
47
src/main/java/eu/dissco/core/translator/terms/utils/EntityRelationshipUtils.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,47 @@ | ||
package eu.dissco.core.translator.terms.utils; | ||
|
||
import static eu.dissco.core.translator.domain.AgentRoleType.DATA_TRANSLATOR; | ||
import static eu.dissco.core.translator.schema.Agent.Type.SCHEMA_SOFTWARE_APPLICATION; | ||
import static eu.dissco.core.translator.terms.utils.AgentsUtils.addAgent; | ||
|
||
import eu.dissco.core.translator.domain.RelationshipType; | ||
import eu.dissco.core.translator.schema.EntityRelationship; | ||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
import java.time.Instant; | ||
import java.util.Date; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Slf4j | ||
public class EntityRelationshipUtils { | ||
|
||
private EntityRelationshipUtils() { | ||
// This is a Utility class | ||
} | ||
|
||
public static EntityRelationship addEntityRelationship( | ||
RelationshipType relationshipType, String relatedResource, String agentName, String agentId) { | ||
if (relatedResource == null) { | ||
log.warn("Related resource for type {} is null. Skipping entity relationship creation.", | ||
relationshipType.getName()); | ||
return null; | ||
} | ||
var entityRelationship = new EntityRelationship() | ||
.withType("ods:EntityRelationship") | ||
.withDwcRelationshipOfResource(relationshipType.getName()) | ||
.withDwcRelatedResourceID(relatedResource) | ||
.withDwcRelationshipEstablishedDate(Date.from(Instant.now())); | ||
entityRelationship.setOdsHasAgents( | ||
addAgent(entityRelationship.getOdsHasAgents(), agentName, agentId, DATA_TRANSLATOR, | ||
SCHEMA_SOFTWARE_APPLICATION)); | ||
if (relatedResource.startsWith("http")) { | ||
try { | ||
entityRelationship.setOdsRelatedResourceURI(new URI(relatedResource)); | ||
} catch (URISyntaxException e) { | ||
log.warn("Could not create URI for related resource: " + relatedResource); | ||
} | ||
} | ||
return entityRelationship; | ||
} | ||
|
||
} |
Oops, something went wrong.