Skip to content

Commit

Permalink
#550 Added resolving of PersonIdentifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
Possommi committed Nov 4, 2024
1 parent d2a1f72 commit 6531eea
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package de.uni_jena.thunibib.his.api.v1.cs.psv;

import de.uni_jena.thunibib.his.api.v1.cs.sys.values.SysValue;

/**
* Path: <code>/api/v1/cs/psv/person/identifier
*
* At least one of these rights: RIGHT_CS_PSV_PERSON_VIEW_PERSON_IDENTIFIER
* */
public class PersonIdentifier extends SysValue {

public static String getValueParamaterName() {
return "identifierValue";
}

public static String getTypeParamaterName() {
return "typeUniquename";
}

public static String getPath() {
return "cs/psv/person/identifier";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import de.uni_jena.thunibib.HISinOneCommands;
import de.uni_jena.thunibib.his.api.client.HISInOneClient;
import de.uni_jena.thunibib.his.api.client.HISinOneClientFactory;
import de.uni_jena.thunibib.his.api.v1.cs.psv.PersonIdentifier;
import de.uni_jena.thunibib.his.api.v1.cs.sys.values.LanguageValue;
import de.uni_jena.thunibib.his.api.v1.cs.sys.values.PeerReviewedValue;
import de.uni_jena.thunibib.his.api.v1.cs.sys.values.PublicationAccessTypeValue;
Expand Down Expand Up @@ -165,7 +166,23 @@ public Source resolve(String href, String base) throws TransformerException {
* @return {@link SysValue}
*/
protected SysValue resolvePerson(String type, String value) {
return SysValue.UnresolvedSysValue;
Map<String, String> parameter = new HashMap<>();
parameter.put(PersonIdentifier.getTypeParamaterName(), type);
parameter.put(PersonIdentifier.getValueParamaterName(), value);

try (HISInOneClient hisClient = HISinOneClientFactory.create();
Response response = hisClient.post(PersonIdentifier.getPath(), null, parameter)) {

if (response.getStatusInfo().getFamily() != Response.Status.Family.SUCCESSFUL) {
logError(response, PersonIdentifier.getPath());
return SysValue.ErroneousSysValue;
}

SysValue sysValue = response.readEntity(Journal.class);
return sysValue;
} catch (Exception e) {
return SysValue.ErroneousSysValue;
}
}

protected SysValue resolveJournal(String fromValue) {
Expand All @@ -183,7 +200,7 @@ protected SysValue resolveJournal(String fromValue) {
Response response = hisClient.get(Journal.getPath() + "/" + hisId)) {

if (response.getStatusInfo().getFamily() != Response.Status.Family.SUCCESSFUL) {
logHISMessage(response);
logError(response, Journal.getPath());
return SysValue.ErroneousSysValue;
}
Journal journal = response.readEntity(Journal.class);
Expand Down Expand Up @@ -219,7 +236,7 @@ private SysValue resolvePublicationResourceType(String resourceTypeText) {
Response response = hisClient.get(PublicationResourceValue.getPath())) {

if (response.getStatusInfo().getFamily() != Response.Status.Family.SUCCESSFUL) {
logHISMessage(response);
logError(response, PublicationResourceValue.getPath());
return SysValue.ErroneousSysValue;
}

Expand Down Expand Up @@ -274,7 +291,7 @@ private SysValue resolvePublication(String mcrid) {
Response response = hisClient.get(Publication.getPath() + "/" + hisid)) {

if (response.getStatusInfo().getFamily() != Response.Status.Family.SUCCESSFUL) {
logHISMessage(response);
logError(response, Publication.getPath());
return SysValue.ErroneousSysValue;
}

Expand All @@ -297,7 +314,7 @@ private SysValue resolvePublisher(String value) {
Response response = hisClient.get(PublisherWrappedValue.getPath(), params)) {

if (response.getStatusInfo().getFamily() != Response.Status.Family.SUCCESSFUL) {
logHISMessage(response);
logError(response, PublisherWrappedValue.getPath());
return SysValue.ErroneousSysValue;
}

Expand Down Expand Up @@ -345,7 +362,7 @@ private SysValue createPublisher(String value) {
jsonObject.toString())) {

if (response.getStatusInfo().getFamily() != Response.Status.Family.SUCCESSFUL) {
logHISMessage(response);
logError(response, PublisherWrappedValue.getPath(PublisherWrappedValue.PathType.create));
return SysValue.ErroneousSysValue;
}

Expand All @@ -371,7 +388,7 @@ private SysValue resolvePeerReviewedType(String peerReviewedCategId) {
Response response = hisClient.get(PeerReviewedValue.getPath())) {

if (response.getStatusInfo().getFamily() != Response.Status.Family.SUCCESSFUL) {
logHISMessage(response);
logError(response, PeerReviewedValue.getPath());
return SysValue.ErroneousSysValue;
}

Expand Down Expand Up @@ -414,7 +431,7 @@ private SysValue resolvePublicationAccessType(String accessRightsCategId) {
Response response = hisClient.get(PublicationAccessTypeValue.getPath())) {

if (response.getStatusInfo().getFamily() != Response.Status.Family.SUCCESSFUL) {
logHISMessage(response);
logError(response, PublicationAccessTypeValue.getPath());
return SysValue.ErroneousSysValue;
}

Expand Down Expand Up @@ -462,7 +479,7 @@ private SysValue resolveResearchAreaKdsf(String areaCategId) {
Response response = hisClient.get(ResearchAreaKdsfValue.getPath())) {

if (response.getStatusInfo().getFamily() != Response.Status.Family.SUCCESSFUL) {
logHISMessage(response);
logError(response, ResearchAreaKdsfValue.getPath());
return SysValue.ErroneousSysValue;
}

Expand Down Expand Up @@ -500,7 +517,7 @@ private SysValue resolveIdentifierType(String identifierType) {
Response response = hisClient.get(GlobalIdentifierType.getPath())) {

if (response.getStatusInfo().getFamily() != Response.Status.Family.SUCCESSFUL) {
logHISMessage(response);
logError(response, GlobalIdentifierType.getPath());
return SysValue.ErroneousSysValue;
}

Expand Down Expand Up @@ -530,7 +547,7 @@ protected SysValue resolvePublicationType(String ubogenre, String hostGenre) {
Response response = hisClient.get(PublicationTypeValue.getPath())) {

if (response.getStatusInfo().getFamily() != Response.Status.Family.SUCCESSFUL) {
logHISMessage(response);
logError(response, PublicationTypeValue.getPath());
return SysValue.ErroneousSysValue;
}

Expand Down Expand Up @@ -572,11 +589,11 @@ private SysValue resolveDocumentType(String ubogenre, String hostGenre) {
Response articleResp = hisClient.get(DocumentType.getPath(DocumentType.PathType.article))) {

if (bookResp.getStatusInfo().getFamily() != Response.Status.Family.SUCCESSFUL) {
logHISMessage(bookResp);
logError(bookResp, DocumentType.getPath(DocumentType.PathType.book));
return SysValue.ErroneousSysValue;
}
if (articleResp.getStatusInfo().getFamily() != Response.Status.Family.SUCCESSFUL) {
logHISMessage(articleResp);
logError(articleResp, DocumentType.getPath(DocumentType.PathType.article));
return SysValue.ErroneousSysValue;
}

Expand Down Expand Up @@ -615,7 +632,7 @@ private SysValue resolveThesisType(String ubogenre) {
Response response = hisClient.get(QualificationThesisValue.getPath())) {

if (response.getStatusInfo().getFamily() != Response.Status.Family.SUCCESSFUL) {
logHISMessage(response);
logError(response, QualificationThesisValue.getPath());
return SysValue.ErroneousSysValue;
}

Expand Down Expand Up @@ -657,8 +674,9 @@ private SysValue resolveSubjectArea(String destatisId) {

try (HISInOneClient hisClient = HISinOneClientFactory.create();
Response response = hisClient.get(SubjectAreaValue.getPath())) {

if (response.getStatusInfo().getFamily() != Response.Status.Family.SUCCESSFUL) {
logHISMessage(response);
logError(response, SubjectAreaValue.getPath());
return SysValue.ErroneousSysValue;
}

Expand All @@ -683,10 +701,12 @@ protected SysValue resolveCreatorType(String value) {
return CREATOR_TYPE_MAP.get(value);
}

String path = "cs/sys/values/publicationCreatorTypeValue";
try (HISInOneClient hisClient = HISinOneClientFactory.create();
Response response = hisClient.get("cs/sys/values/publicationCreatorTypeValue")) {
Response response = hisClient.get(path)) {

if (response.getStatusInfo().getFamily() != Response.Status.Family.SUCCESSFUL) {
logHISMessage(response);
logError(response, path);
return SysValue.ErroneousSysValue;
}

Expand Down Expand Up @@ -720,8 +740,9 @@ protected SysValue resolveVisibility(String statusCategId) {

try (HISInOneClient hisClient = HISinOneClientFactory.create();
Response response = hisClient.get(VisibilityValue.getPath())) {

if (response.getStatusInfo().getFamily() != Response.Status.Family.SUCCESSFUL) {
logHISMessage(response);
logError(response, VisibilityValue.getPath());
return SysValue.ErroneousSysValue;
}

Expand Down Expand Up @@ -755,8 +776,9 @@ protected SysValue resolveState(String statusCategId) {

try (HISInOneClient hisClient = HISinOneClientFactory.create();
Response response = hisClient.get(PublicationState.getPath())) {

if (response.getStatusInfo().getFamily() != Response.Status.Family.SUCCESSFUL) {
logHISMessage(response);
logError(response, PublicationState.getPath());
return SysValue.ErroneousSysValue;
}

Expand Down Expand Up @@ -787,7 +809,7 @@ protected SysValue resolveLanguage(String rfc5646) {
try (HISInOneClient hisClient = HISinOneClientFactory.create();
Response response = hisClient.get(LanguageValue.getPath())) {
if (response.getStatusInfo().getFamily() != Response.Status.Family.SUCCESSFUL) {
logHISMessage(response);
logError(response, LanguageValue.getPath());
return SysValue.ErroneousSysValue;
}

Expand Down Expand Up @@ -856,7 +878,7 @@ protected boolean exists(String mcrid) {
*
* @param response the response
*/
protected final void logHISMessage(Response response) {
LOGGER.error("HISinOne api message: {}", response.readEntity(String.class));
public void logError(Response response, String endpoint) {
LOGGER.error("{}: {}", endpoint, response.readEntity(String.class));
}
}

0 comments on commit 6531eea

Please sign in to comment.