Skip to content

Commit

Permalink
#3249: added title, journal and issue to related publication
Browse files Browse the repository at this point in the history
  • Loading branch information
ewolf47 committed Dec 4, 2023
1 parent 0117bc6 commit aa6391f
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ angular.module('metadatamanagementApp').config([
'source-reference': 'Referenz',
'abstract-source': 'Quelle',
'studySerieses': 'Studienreihen',
'annotations': 'Anmerkungen'
'annotations': 'Anmerkungen',
'title': 'Titel',
'issue': 'Ausgabe',
'journal': 'Fachzeitschrift'
},
'abstract': 'Abstract',
'title': '{{ title }}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ angular.module('metadatamanagementApp').config([
'source-reference': 'Reference',
'abstract-source': 'Source',
'studySerieses': 'Study Serieses',
'annotations': 'Annotations'
'annotations': 'Annotations',
'title': 'Title',
'issue': 'Issue',
'journal': 'Journal'
},
'abstract': 'Abstract',
'title': '{{ title }}',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,43 @@
'use strict';

angular.module('metadatamanagementApp')
.service('RelatedPublicationBuilderService', ['RelatedPublicationResource', 'CleanJSObjectService', 'RelatedPublicationIdBuilderService',
.service('RelatedPublicationBuilderService', ['RelatedPublicationResource', 'CleanJSObjectService',
'RelatedPublicationIdBuilderService', '$http', '$q',
function(RelatedPublicationResource, CleanJSObjectService,
RelatedPublicationIdBuilderService) {
var getRelatedPublications = function(relatedPublications) {
var relatedPublicationsObjArray = [];
RelatedPublicationIdBuilderService, $http, $q) {

const updatePublicationObj = function(publicationObj, doi) {
if (doi) {
return findByDOI(doi).then(function(data) {
publicationObj.journal = data.data["container-title"] ? data.data["container-title"] : null;
if (data.data.hasOwnProperty("journal-issue")){
publicationObj.issue = data.data["journal-issue"].issue ? data.data["journal-issue"].issue : null;
}
return new RelatedPublicationResource(CleanJSObjectService.removeEmptyJsonObjects(publicationObj));
});
} else {
return $q((resolve, reject) => {
resolve(new RelatedPublicationResource(CleanJSObjectService.removeEmptyJsonObjects(publicationObj)))
});
}
}

var getRelatedPublications = async function(relatedPublications) {
// var relatedPublicationsObjArray = [];
var promises = [];
for (var i = 0; i < relatedPublications.length; i++) {
var data = relatedPublications[i];
var doi = getPropertyByKeyPattern(data, /^DOI$/i);
var bibTexKey = getPropertyByKeyPattern(data, /^BibTeX Key$/i);
var relatedPublicationObj = {

var publicationObj = {
/* jshint -W069 */
id: bibTexKey ?
RelatedPublicationIdBuilderService.buildRelatedPublicationId(
bibTexKey) : undefined,
sourceReference:
getPropertyByKeyPattern(data, /^sourceReference.*$/i),
doi: getPropertyByKeyPattern(data, /^DOI$/i),
doi: doi,
title: getPropertyByKeyPattern(data, /^Titel$/i),
authors: getPropertyByKeyPattern(data, /^Autor.*$/i),
language: getPropertyByKeyPattern(data, /^Sprache$/i),
Expand All @@ -35,20 +56,40 @@ angular.module('metadatamanagementApp')
publicationAbstract: getPropertyByKeyPattern(data, /^Abstract$/i)
/* jshint +W069 */
};
var cleanedRelatedPublicationObject = CleanJSObjectService
.removeEmptyJsonObjects(relatedPublicationObj);
relatedPublicationsObjArray[i] =
new RelatedPublicationResource(cleanedRelatedPublicationObject);
}
return relatedPublicationsObjArray;
};
promises.push(updatePublicationObj(publicationObj, doi));
};

return await new Promise((resolve, reject) => {
$q.all(promises).then(results => {
resolve(results);
});
});
}

var getPropertyByKeyPattern = function(object, regex) {
return object[Object.keys(object).filter(function(key) {
return regex.test(key);
})[0]];
};

/**
* This function sends a request to http://doi.org/{doi}
* and returns the response as Promise.
* @param doi A DOI code, e.g. "10.5771/0038-6073-2023-2-173"
*/
var findByDOI = function(doi) {
return $http({
method: 'GET',
url: 'http://doi.org/' + doi,
headers: {
'Accept': 'application/json'
}
}).then(function(data) {
var response = angular.fromJson(data);
return response;
});
}

return {
getRelatedPublications: getRelatedPublications
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ angular.module('metadatamanagementApp')
previouslyUploadedPublicationIds = {};
JobLoggingService.start('related-publication');
ExcelReaderService.readFileAsync(file).then(
function(relatedPublications) {
objects = RelatedPublicationBuilderService
async function(relatedPublications) {
objects = await RelatedPublicationBuilderService
.getRelatedPublications(relatedPublications);
upload();
}, function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,26 @@
<span
class="md-secondary">{{$ctrl.options.authors}}</span>
</md-list-item>
<md-list-item ng-if="$ctrl.options.title">
<h5>{{'related-publication-management.detail.label.title' | translate }}:</h5>
<span
class="md-secondary">{{$ctrl.options.title}}</span>
</md-list-item>
<md-list-item ng-if="$ctrl.options.journal">
<h5>{{'related-publication-management.detail.label.journal' | translate }}:</h5>
<span
class="md-secondary">{{$ctrl.options.journal}}</span>
</md-list-item>
<md-list-item ng-if="$ctrl.options.year">
<h5>{{'related-publication-management.detail.label.year' | translate }}:</h5>
<span
class="md-secondary">{{$ctrl.options.year}}</span>
</md-list-item>
<md-list-item ng-if="$ctrl.options.issue">
<h5>{{'related-publication-management.detail.label.issue' | translate }}:</h5>
<span
class="md-secondary">{{$ctrl.options.issue}}</span>
</md-list-item>
<md-list-item ng-if="$ctrl.options.sourceReference">
<h5>{{'related-publication-management.detail.label.sourceReference' | translate }}:</h5>
<span
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,16 @@ public class RelatedPublication extends AbstractRdcDomainObject {
message = "related-publication-management.error.related-publication.annotations.size")
private I18nString annotations;

/**
* Name of journal
*/
private String journal;

/**
* Issue (Ausgabe) of journal
*/
private Integer issue;

/* Foreign Keys */
@Indexed
private List<@DataPackageExists String> dataPackageIds;
Expand Down
15 changes: 15 additions & 0 deletions src/main/resources/elasticsearch/related_publications/mapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,21 @@
"year": {
"type": "integer"
},
"journal": {
"type": "text",
"index": false,
"copy_to": "all",
"fields": {
"ngrams": {
"type": "text",
"analyzer": "ngrams",
"norms": false
}
}
},
"issue": {
"type": "integer"
},
"dataPackageIds": {
"type": "keyword",
"copy_to": "all"
Expand Down

0 comments on commit aa6391f

Please sign in to comment.