Skip to content

Commit

Permalink
#550 Unified resolving of lockVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
Possommi committed Nov 4, 2024
1 parent f94ea60 commit 2b31002
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public Source resolve(String href, String base) throws TransformerException {
case journal -> Mode.resolve.equals(mode) ? resolveJournal(fromValue) : createJournal(fromValue);
case language -> resolveLanguage(fromValue);
case peerReviewed -> resolvePeerReviewedType(fromValue);
case publication -> resolvePublicationLockVersion(fromValue);
case publication -> resolvePublication(fromValue);
case publicationAccessType -> resolvePublicationAccessType(fromValue);
case publicationResource -> resolvePublicationResourceType(fromValue);
case publicationType -> resolvePublicationType(fromValue, hostGenre);
Expand Down Expand Up @@ -266,11 +266,24 @@ private SysValue resolvePublicationResourceType(String resourceTypeText) {
}

/**
* Resolves the {@link SysValue} with id in HISinOne of the given mycoreobject id.
*
* @param hisid the HIS id of a publication
* @return
* @param mcrid the mcrid of a publication
*
* @return a {@link SysValue} with for the publication of the given mycoreobject id or {@link SysValue#UnresolvedSysValue}
*/
private SysValue resolvePublicationLockVersion(String hisid) {
private SysValue resolvePublication(String mcrid) {
if (!exists(mcrid)) {
LOGGER.warn("{} does not exist", mcrid);
return SysValue.UnresolvedSysValue;
}

MCRObject mcrObject = MCRMetadataManager.retrieveMCRObject(MCRObjectID.getInstance(mcrid));
if (mcrObject.getService().getFlags(HISInOneServiceFlag.getName()).size() == 0) {
return SysValue.UnresolvedSysValue;
}

String hisid = mcrObject.getService().getFlags(HISInOneServiceFlag.getName()).get(0);
try (HISInOneClient hisClient = HISinOneClientFactory.create();
Response response = hisClient.get(Publication.getPath() + "/" + hisid)) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@
<xsl:value-of select="fn:document(concat('hisinone:resolve:lockVersion:journal:', //mycoreobject/@ID))"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="fn:document(concat('hisinone:resolve:lockVersion:publication:', $hisid))"/>
<xsl:value-of select="fn:document(concat('hisinone:resolve:lockVersion:publication:', //mycoreobject/@ID))"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
Expand Down

0 comments on commit 2b31002

Please sign in to comment.