Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • aou/aou-backend
1 result
Select Git revision
Show changes
Commits on Source (2)
Showing
with 288 additions and 129 deletions
......@@ -9,12 +9,12 @@
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of the
* License, or (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-2.0.html>.
......@@ -33,6 +33,7 @@ import java.util.Set;
import java.util.stream.Collectors;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -360,8 +361,12 @@ public class StructureService extends AouResourceService<Structure> {
LocalDate validUntil = null;
if (!item.isNull(JSON_FILE_FIELD_VALID_UNTIL)) {
Integer year = item.getInt(JSON_FILE_FIELD_VALID_UNTIL);
validUntil = LocalDate.of(year, 12, 31);
try {
Integer year = item.getInt(JSON_FILE_FIELD_VALID_UNTIL);
validUntil = LocalDate.of(year, 12, 31);
} catch (JSONException e) {
validUntil = LocalDate.parse(item.getString(JSON_FILE_FIELD_VALID_UNTIL));
}
}
this.createStructure(resId, parentId, status, cnStructC, cStruct, name, acronym, dewey, validUntil, sortValue);
......
......@@ -268,13 +268,13 @@
{
"id": "43",
"parentId": "30",
"status": "ACTIVE",
"status": "HISTORICAL",
"cStruct": "161",
"cnStructC": "512",
"name": "D\u00e9partement de biologie mol\u00e9culaire",
"acronym": null,
"dewey": "570",
"validUntil": null,
"validUntil": "2020",
"lft": "37",
"rght": "38",
"sortValue": 190
......@@ -324,13 +324,13 @@
{
"id": "46",
"parentId": "30",
"status": "ACTIVE",
"status": "HISTORICAL",
"cStruct": "165",
"cnStructC": "347",
"name": "D\u00e9partement de biologie cellulaire",
"acronym": null,
"dewey": "570",
"validUntil": null,
"validUntil": "2020",
"lft": "45",
"rght": "46",
"sortValue": 230
......@@ -688,13 +688,13 @@
{
"id": "202",
"parentId": "201",
"status": "ACTIVE",
"status": "HISTORICAL",
"cStruct": "22A92",
"cnStructC": "15602",
"name": "Unit\u00e9 des internistes g\u00e9n\u00e9ralistes et p\u00e9diatres",
"acronym": null,
"dewey": "613",
"validUntil": null,
"validUntil": "2020",
"lft": "97",
"rght": "98",
"sortValue": 490
......@@ -2112,5 +2112,65 @@
"lft": "302",
"rght": "303",
"sortValue": 1500
},
{
"id": "2cf4110a-abc2-4313-a3cf-77ad940393bb",
"parentId": "11",
"status": "ACTIVE",
"cStruct": "16120",
"cnStructC": "0CR",
"name": "Service des Relations Internationales & Partenariats",
"acronym": "SRIP",
"dewey": "320",
"validUntil": null,
"sortValue": 1510
},
{
"id": "3eb925bf-9188-464b-a497-86ee1d993031",
"parentId": "1",
"status": "ACTIVE",
"cStruct": "0M3",
"cnStructC": "16423",
"name": "Centre Maurice Chalumeau en sciences des sexualités",
"acronym": null,
"dewey": "306.7",
"validUntil": null,
"sortValue": 2620
},
{
"id": "7daed2ee-1311-4824-9df9-2e51260a966a",
"parentId": "30",
"status": "ACTIVE",
"cStruct": "16484",
"cnStructC": "168",
"name": "Département de biologie moléculaire et cellulaire",
"acronym": "MOCEL",
"dewey": "570",
"validUntil": null,
"sortValue": 240
},
{
"id": "8c5189d4-0ec1-424f-82f8-924b0d97c05d",
"parentId": "1",
"status": "HISTORICAL",
"cStruct": "0D4",
"cnStructC": "1401",
"name": "Centre universitaire d'écologie humaine et sciences de l'environnement",
"acronym": "CUEH",
"dewey": "333.7-333.9",
"validUntil": "2009",
"sortValue": 2195
},
{
"id": "f1b73ff3-6e14-4dab-95fa-f3eb13e955f9",
"parentId": "11",
"status": "ACTIVE",
"cStruct": "0C42",
"cnStructC": "10080",
"name": "Centre pour la formation continue et à distance",
"acronym": null,
"dewey": "374",
"validUntil": null,
"sortValue": 1475
}
]
......@@ -296,7 +296,7 @@ public class AouConstants {
public static final String DOCUMENT_FILE_TYPE_BOOK_CHAPTER_SUBMITTED_VERSION = "Book chapter (Submitted version)";
public static final String DOCUMENT_FILE_TYPE_ENCYCLOPEDIA_ENTRY_SUBMITTED_VERSION = "Encyclopedia entry (Submitted version)";
public static final String[] SUBMITTED_VERSION_DOCUMENT_FILE_TYPES = {
private static final String[] SUBMITTED_VERSION_DOCUMENT_FILE_TYPES = {
DOCUMENT_FILE_TYPE_ARTICLE_SUBMITTED_VERSION,
DOCUMENT_FILE_TYPE_PROCEEDINGS_SUBMITTED_VERSION,
DOCUMENT_FILE_TYPE_PROCEEDINGS_CHAPTER_SUBMITTED_VERSION,
......@@ -305,6 +305,10 @@ public class AouConstants {
DOCUMENT_FILE_TYPE_ENCYCLOPEDIA_ENTRY_SUBMITTED_VERSION
};
public static String[] getSubmittedVersionDocumentFileTypes() {
return SUBMITTED_VERSION_DOCUMENT_FILE_TYPES.clone();
}
// Document file versions
public static final String DOCUMENT_PUBLISHED_VERSION_EN = "Published version";
public static final String DOCUMENT_ACCEPTED_VERSION_EN = "Accepted version";
......@@ -413,6 +417,8 @@ public class AouConstants {
public static final String INDEX_FIELD_CONTRIBUTORS_CN_INDIVIDU = "contributors.cnIndividu";
public static final String INDEX_FIELD_EMBARGO_END_DATES = "embargoEndDates";
public static final String INDEX_FIELD_HTML_META_HEADERS = "htmlMetaHeaders";
public static final String INDEX_FIELD_STRUCTURES_WITH_PARENT = "structuresWithParentsNames";
public static final String INDEX_FIELD_TITLE = "title";
public static final String INDEX_FIELD_ALIAS_UNIGE_DIRECTORS = "unigeDirector";
public static final String INDEX_FIELD_ALIAS_GLOBAL_SEARCH = "globalSearch";
......@@ -507,91 +513,107 @@ public class AouConstants {
public static final String TEMPORARY_TEST_DATA_LABEL = "[Temporary Test Data] ";
public static final String NO_REPLY_PREFIX = "noreply-";
public static final String TEST_RES_ID = "test";
public static final String TEST_DEPOSIT_JSON_FORM_DATA_TEMPLATE = "{\n"
+ " \"contributors\": {\n"
+ " \"contributors\": [\n"
+ " {\n"
+ " \"contributor\": {\n"
+ " \"cnIndividu\": \"12345\",\n"
+ " \"email\": \"john.doe@example.com\",\n"
+ " \"firstname\": \"John\",\n"
+ " \"institution\": \"unige\",\n"
+ " \"lastname\": \"Doe\",\n"
+ " \"orcid\": \"1234-1234-1234-1234\",\n"
+ " \"role\": \"author\"\n"
+ " }\n"
+ " }\n"
+ " ]\n"
+ " },\n"
+ " \"description\": {\n"
+ " \"languages\": [ {\n"
+ " \"language\" : \"ENG\"\n"
+ " }],\n"
+ " \"dates\": [{\n"
+ " \"date\": \"24.07.2009\",\n"
+ " \"type\": \"PUBLICATION\"\n"
+ " }],\n"
+ " \"container\": {\n"
+ " \"identifiers\": {\n"
+ " \"issn\": \"0028-0836\"\n"
+ " },\n"
+ " \"issue\": \"8\",\n"
+ " \"title\": \"Nature\"\n"
+ " },\n"
+ " \"collections\": [{\n"
+ " \"name\": \"Collection1\"\n"
+ " }, {\n"
+ " \"name\": \"Collection2\",\n"
+ " \"number\": \"888\"\n"
+ " }"
+ " ]\n"
+ " },\n"
+ " \"type\": {\n"
+ " \"subsubtype\": \"A1-LETTRE\",\n"
+ " \"subtype\": \"A1\",\n"
+ " \"title\": {\"lang\": \"FRA\", \"text\" : \"%s\"},\n"
+ " \"type\": \"ARTICLE\"\n"
+ " }\n"
+ "}";
public static final String STRUCTURE_JSON_V2_0 = "\"academicStructures\": [\n"
+ " {\n"
+ " \"code\": \"%s\",\n"
+ " \"oldCode\": \"%s\",\n"
+ " \"name\": \"%s\"\n"
+ " }\n"
+ " ],";
public static final String TEST_DEPOSIT_JSON_FORM_DATA_TEMPLATE = """
{
"contributors": {
"contributors": [
{
"contributor": {
"cnIndividu": "12345",
"email": "john.doe@example.com",
"firstname": "John",
"institution": "unige",
"lastname": "Doe",
"orcid": "1234-1234-1234-1234",
"role": "author"
}
}
]
},
"description": {
"languages": [{
"language" : "ENG"
}],
"dates": [{
"date": "24.07.2009",
"type": "PUBLICATION"
}],
"container": {
"identifiers": {
"issn": "0028-0836"
},
"issue": "8",
"title": "Nature"
},
"collections": [
{
"name": "Collection1"
},
{
"name": "Collection2",
"number": "888"
}
]
},
"type": {
"subsubtype": "A1-LETTRE",
"subtype": "A1",
"title": { "lang": "FRA", "text" : "%s"},
"type": "ARTICLE"
}
}"
""";
public static final String STRUCTURE_JSON_V2_0 = """
"academicStructures": [
{
"code": "%s",
"oldCode": "%s",
"name": "%s"
}
],
""";
public static final String STRUCTURE_JSON_V2_1 = "\"academicStructures\": [\"%s\"],";
public static final String RESEARCH_GROUP_JSON = "\"groups\": [\n"
+ " {\n"
+ " \"code\": \"%s\",\n"
+ " \"name\": \"%s\"\n"
+ " }\n"
+ " ],";
public static final String RESEARCH_GROUP_JSON = """
"groups": [
{
"code": "%s",
"name": "%s"
}
],
""";
public static final String TEST_DEPOSIT_TITLE = "Test deposit";
public static final String TEST_DEPOSIT_JSON_FORM_DATA = String.format(TEST_DEPOSIT_JSON_FORM_DATA_TEMPLATE, TEST_DEPOSIT_TITLE);
public static final String TEST_DEPOSIT_XML_METADATA_TEMPLATE_2_3 = "<deposit_doc xmlns=\"https://archive-ouverte.unige.ch/deposit/v2.3\">"
+ " <type>Diplôme</type>"
+ " <subtype>Thèse</subtype>"
+ " <title>%s</title>"
+ " <languages><language>eng</language></languages>"
+ " <pages>"
+ " <paging>p. 12345 -67</paging>"
+ " </pages>"
+ "</deposit_doc>";
public static final String TEST_DEPOSIT_XML_METADATA_TEMPLATE_2_4 = "<deposit_doc xmlns=\"https://archive-ouverte.unige.ch/deposit/v2.4\">"
+ " <type>Diplôme</type>"
+ " <subtype>Thèse</subtype>"
+ " <title>%s</title>"
+ " <languages><language>eng</language></languages>"
+ " <pages>"
+ " <paging>p. 12345 -67</paging>"
+ " </pages>"
+ "</deposit_doc>";
public static final String TEST_DEPOSIT_XML_METADATA_TEMPLATE_2_3 = """
<deposit_doc xmlns="https://archive-ouverte.unige.ch/deposit/v2.3">
<type>Diplôme</type>
<subtype>Thèse</subtype>
<title>%s</title>
<languages>
<language>eng</language>
</languages>
<pages>
<paging>p. 12345 -67</paging>
</pages>
</deposit_doc>
""";
public static final String TEST_DEPOSIT_XML_METADATA_TEMPLATE_2_4 = """
<deposit_doc xmlns="https://archive-ouverte.unige.ch/deposit/v2.4">
<type>Diplôme</type>
<subtype>Thèse</subtype>
<title>%s</title>
<languages>
<language>eng</language>
</languages>
<pages>
<paging>p. 12345 -67</paging>
</pages>
</deposit_doc>
""";
// Exception error message
public static final String BAD_SEARCH_REQUEST = "Bad search request";
......
......@@ -60,7 +60,7 @@ public class PublicationIndexEntry extends IndexMetadata implements OAIRecord {
@JsonIgnore
public String getTitle() {
return this.getMetadata().get("title").toString();
return this.getMetadata().get(AouConstants.INDEX_FIELD_TITLE).toString();
}
@JsonIgnore
......@@ -106,10 +106,9 @@ public class PublicationIndexEntry extends IndexMetadata implements OAIRecord {
public List<String> getContributorsCnIndividus() {
if (this.getMetadata().containsKey(AouConstants.INDEX_FIELD_CONTRIBUTORS)) {
List<Map<String, String>> propContributors = (List<Map<String, String>>) this.getMetadata().get(AouConstants.INDEX_FIELD_CONTRIBUTORS);
List<String> listCnIndividu = propContributors.stream()
return propContributors.stream()
.filter(m -> m.containsKey(AouConstants.INDEX_FIELD_ALIAS_CN_INDIVIDU))
.map(m -> m.get(AouConstants.INDEX_FIELD_ALIAS_CN_INDIVIDU)).toList();
return listCnIndividu;
}
return new ArrayList<>();
}
......@@ -181,8 +180,7 @@ public class PublicationIndexEntry extends IndexMetadata implements OAIRecord {
return creation;
} else {
return OffsetDateTime.parse(
(String) this.getMetadata(updateFile.split(SolidifyConstants.REGEX_FIELD_PATH_SEP))
).toInstant()
(String) this.getMetadata(updateFile.split(SolidifyConstants.REGEX_FIELD_PATH_SEP))).toInstant()
.atOffset(ZoneOffset.UTC)
.withNano(0);
}
......@@ -195,8 +193,7 @@ public class PublicationIndexEntry extends IndexMetadata implements OAIRecord {
return validationDate;
} else {
return OffsetDateTime.parse(
(String) this.getMetadata(updateFile.split(SolidifyConstants.REGEX_FIELD_PATH_SEP))
).toInstant()
(String) this.getMetadata(updateFile.split(SolidifyConstants.REGEX_FIELD_PATH_SEP))).toInstant()
.atOffset(ZoneOffset.UTC)
.withNano(0);
}
......@@ -209,8 +206,7 @@ public class PublicationIndexEntry extends IndexMetadata implements OAIRecord {
return lastIndexation;
} else {
return OffsetDateTime.parse(
(String) this.getMetadata(lastIndexationDateStr.split(SolidifyConstants.REGEX_FIELD_PATH_SEP))
).toInstant()
(String) this.getMetadata(lastIndexationDateStr.split(SolidifyConstants.REGEX_FIELD_PATH_SEP))).toInstant()
.atOffset(ZoneOffset.UTC)
.withNano(0);
}
......@@ -218,8 +214,8 @@ public class PublicationIndexEntry extends IndexMetadata implements OAIRecord {
@JsonIgnore
public String getContainerTitle() {
if (this.getMetadata("container", "title") != null) {
return this.getMetadata("container", "title").toString();
if (this.getMetadata("container", AouConstants.INDEX_FIELD_TITLE) != null) {
return this.getMetadata("container", AouConstants.INDEX_FIELD_TITLE).toString();
}
return null;
}
......
......@@ -474,6 +474,7 @@
<xs:complexType>
<xs:all>
<xs:element ref="diffusion" minOccurs="0"/>
<xs:element ref="structures" minOccurs="0"/>
</xs:all>
</xs:complexType>
</xs:element>
......@@ -489,4 +490,19 @@
</xs:simpleType>
</xs:element>
<xs:element name="structures">
<xs:complexType>
<xs:sequence>
<xs:element ref="structure" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="structure">
<xs:simpleType>
<xs:restriction base="xs:string" />
</xs:simpleType>
</xs:element>
</xs:schema>
......@@ -669,17 +669,32 @@
</marc:datafield>
</xsl:for-each>
<!-- 928 - Stuctures academiques -->
<!-- 928 - Structures academiques -->
<xsl:for-each select="aou_deposit:academic_structures/aou_deposit:academic_structure[aou_deposit:name!='']">
<marc:datafield tag="928" ind1=" " ind2=" ">
<xsl:variable name="structure_position">
<xsl:value-of select="position()"/>
</xsl:variable>
<marc:subfield code="a">
<xsl:value-of select="./aou_deposit:name"/>
</marc:subfield>
<marc:subfield code="b">
<xsl:value-of select="(../../aou_deposit:additionalMetadata/aou_deposit:structures/aou_deposit:structure)[position()=$structure_position]"/>
</marc:subfield>
<marc:subfield code="c">
<xsl:value-of select="./aou_deposit:code"/>
</marc:subfield>
</marc:datafield>
</xsl:for-each>
<!-- 929 - Structures -->
<xsl:for-each select="aou_deposit:additionalMetadata/aou_deposit:structures/aou_deposit:structure">
<marc:datafield tag="929" ind1=" " ind2=" ">
<marc:subfield code="a">
<xsl:value-of select="."/>
</marc:subfield>
</marc:datafield>
</xsl:for-each>
<!-- 980 - Type du document -->
<marc:datafield tag="980" ind1=" " ind2=" ">
......
......@@ -696,18 +696,24 @@
</marc:datafield>
</xsl:for-each>
<!-- 928 - Stuctures academiques -->
<!-- 928 - Structures academiques -->
<xsl:for-each select="aou_deposit:academic_structures/aou_deposit:academic_structure[aou_deposit:name!='']">
<marc:datafield tag="928" ind1=" " ind2=" ">
<xsl:variable name="structure_position">
<xsl:value-of select="position()"/>
</xsl:variable>
<marc:subfield code="a">
<xsl:value-of select="./aou_deposit:name"/>
</marc:subfield>
<marc:subfield code="b">
<xsl:value-of select="(../../aou_deposit:additionalMetadata/aou_deposit:structures/aou_deposit:structure)[position()=$structure_position]"/>
</marc:subfield>
<marc:subfield code="c">
<xsl:value-of select="./aou_deposit:code"/>
</marc:subfield>
</marc:datafield>
</xsl:for-each>
<!-- 980 - Type du document -->
<marc:datafield tag="980" ind1=" " ind2=" ">
<!-- Temporaire jusqu'à la correction C4 -> L4 dans interface de consultation -->
......
......@@ -558,6 +558,10 @@ p.intro {
<tr><td class="key">Abstract</td><td class="value"><i><xsl:value-of select="@lang"/></i> : <xsl:value-of select="."/></td></tr>
</xsl:template>
<xsl:template match="aou_deposit:keyword" xmlns:aou_deposit="https://archive-ouverte.unige.ch/deposit/v2.4">
<tr><td class="key">Keyword</td><td class="value"><xsl:value-of select="."/></td></tr>
</xsl:template>
<xsl:template match="aou_deposit:publisher_version_url" xmlns:aou_deposit="https://archive-ouverte.unige.ch/deposit/v2.4">
<tr><td class="key">Publisher</td><td class="value"><xsl:value-of select="."/></td></tr>
</xsl:template>
......@@ -570,6 +574,18 @@ p.intro {
<tr><td class="key">Structure</td><td class="value"><xsl:value-of select="./aou_deposit:name"/> (<i><xsl:value-of select="./aou_deposit:code"/></i>)</td></tr>
</xsl:template>
<xsl:template match="aou_deposit:structure" xmlns:aou_deposit="https://archive-ouverte.unige.ch/deposit/v2.4">
<tr><td class="key">Structure with parent structure(s)</td><td class="value"><xsl:value-of select="."/></td></tr>
</xsl:template>
<xsl:template match="aou_deposit:group" xmlns:aou_deposit="https://archive-ouverte.unige.ch/deposit/v2.4">
<tr><td class="key">Group</td><td class="value"><xsl:value-of select="./aou_deposit:name"/> (<i><xsl:value-of select="./aou_deposit:resId"/></i>)</td></tr>
</xsl:template>
<xsl:template match="aou_deposit:diffusion" xmlns:aou_deposit="https://archive-ouverte.unige.ch/deposit/v2.4">
<tr><td class="key">Diffusion</td><td class="value"><xsl:value-of select="."/></td></tr>
</xsl:template>
<xsl:template match="aou_deposit:file" xmlns:aou_deposit="https://archive-ouverte.unige.ch/deposit/v2.4">
<xsl:choose>
<xsl:when test="contains(./aou_deposit:type,'Published')">
......
......@@ -66,8 +66,14 @@ import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import javax.xml.parsers.ParserConfigurationException;
import jakarta.xml.bind.JAXB;
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.Marshaller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest;
......@@ -76,11 +82,6 @@ import org.springframework.stereotype.Service;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
import jakarta.xml.bind.JAXB;
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.Marshaller;
import ch.unige.solidify.SolidifyConstants;
import ch.unige.solidify.exception.SolidifyProcessingException;
import ch.unige.solidify.exception.SolidifyRestException;
......@@ -996,7 +997,7 @@ public class CommonMetadataService extends AouService implements OAIMetadataServ
fulltextVersions.add(fulltextVersion);
}
//Check if file is principal
// Check if file is principal
if (!hasPrincipalFile && this.isPrincipalFile(publicationSubtypeId, metadataFile)) {
hasPrincipalFile = true;
break;
......@@ -1058,8 +1059,7 @@ public class CommonMetadataService extends AouService implements OAIMetadataServ
|| metadataFile.getType().equals(AouConstants.DOCUMENT_FILE_TYPE_ARTICLE)
|| metadataFile.getType().equals(AouConstants.DOCUMENT_FILE_TYPE_BOOK)
|| metadataFile.getType().equals(AouConstants.DOCUMENT_FILE_TYPE_BOOK_CHAPTER)
|| metadataFile.getType().equals(AouConstants.DOCUMENT_FILE_TYPE_PROCEEDINGS_CHAPTER)
);
|| metadataFile.getType().equals(AouConstants.DOCUMENT_FILE_TYPE_PROCEEDINGS_CHAPTER));
}
private void fillEmbargoEndDates(Object depositDoc, DepositDocAdapter depositDocAdapter, Map<String, Object> properties) {
......@@ -1090,9 +1090,10 @@ public class CommonMetadataService extends AouService implements OAIMetadataServ
Map<String, List<String>> accessLevelByTypes = new HashMap<>();
// Discard files that must not be considered to compute access level
List<MetadataFile> files = depositDocAdapter.getFiles(depositDoc).stream().filter(f ->
!f.getType().equals(AouConstants.DOCUMENT_FILE_TYPE_IMPRIMATUR_VALUE)
&& !f.getType().equals(DOCUMENT_FILE_TYPE_PUBLICATION_MODE_VALUE)).collect(Collectors.toList());
List<MetadataFile> files = depositDocAdapter.getFiles(depositDoc).stream()
.filter(f -> !f.getType().equals(AouConstants.DOCUMENT_FILE_TYPE_IMPRIMATUR_VALUE)
&& !f.getType().equals(DOCUMENT_FILE_TYPE_PUBLICATION_MODE_VALUE))
.collect(Collectors.toList());
// compute a Map with a list of access levels for each type of file
for (MetadataFile metadataFile : files) {
......@@ -1161,8 +1162,9 @@ public class CommonMetadataService extends AouService implements OAIMetadataServ
List<MetadataFile> principalFiles = this.getPrincipalFiles(depositDoc, depositDocAdapter);
// Remove Preprints and Submitted version from principal files used to compute Open Access value
List<MetadataFile> cleanedPrincipalFiles = principalFiles.stream()
.filter(mf -> !mf.getType().equals(DOCUMENT_FILE_TYPE_PREPRINT) && Arrays.stream(AouConstants.SUBMITTED_VERSION_DOCUMENT_FILE_TYPES)
.noneMatch(type -> type.equals(mf.getType()))).collect(Collectors.toList());
.filter(mf -> !mf.getType().equals(DOCUMENT_FILE_TYPE_PREPRINT) && Arrays.stream(AouConstants.getSubmittedVersionDocumentFileTypes())
.noneMatch(type -> type.equals(mf.getType())))
.toList();
// Any file with current access public ?
if (cleanedPrincipalFiles.stream().anyMatch(mf -> mf.getCurrentAccessLevel().equals(DocumentFile.AccessLevel.PUBLIC.metadataValue()))) {
......@@ -1435,8 +1437,7 @@ public class CommonMetadataService extends AouService implements OAIMetadataServ
private void fillCitationFirstPage(Map<String, String> htmlHeadersMap, Object depositDoc, DepositDocAdapter depositDocAdapter) {
if (this.isArticleOrJournal(depositDoc, depositDocAdapter)
|| this.isChapitreLivreOrContributionDict(depositDoc, depositDocAdapter)
|| this.isChapitreActesOrPresentationOrPoster(depositDoc, depositDocAdapter)
) {
|| this.isChapitreActesOrPresentationOrPoster(depositDoc, depositDocAdapter)) {
String firstPage = null;
String other = depositDocAdapter.getPagingOther(depositDoc);
if (!StringTool.isNullOrEmpty(other)) {
......@@ -1463,8 +1464,7 @@ public class CommonMetadataService extends AouService implements OAIMetadataServ
}
}
private void fillCitationDissertationInstitution(Map<String, String> htmlHeadersMap, Object depositDoc, DepositDocAdapter
depositDocAdapter) {
private void fillCitationDissertationInstitution(Map<String, String> htmlHeadersMap, Object depositDoc, DepositDocAdapter depositDocAdapter) {
if (AouConstants.DEPOSIT_TYPE_DIPLOME_NAME.equals(depositDocAdapter.getType(depositDoc))) {
this.putIfNotNull(htmlHeadersMap, "citation_dissertation_institution", AouConstants.UNIVERSITY_OF_GENEVA_FR);
}
......@@ -1488,8 +1488,7 @@ public class CommonMetadataService extends AouService implements OAIMetadataServ
List<MetadataFile> files = depositDocAdapter.getFiles(depositDoc);
List<MetadataFile> publicFiles = files.stream().filter(f -> !f.getType().equals(AouConstants.DOCUMENT_FILE_TYPE_VIGNETTE)
&& DocumentFile.AccessLevel.fromMetadataValue(f.getAccessLevel()) == DocumentFile.AccessLevel.PUBLIC
&& !this.getCurrentDiffusion(f).equals(AouConstants.EMBARGOED_ACCESS_TEXT)
).collect(Collectors.toList());
&& !this.getCurrentDiffusion(f).equals(AouConstants.EMBARGOED_ACCESS_TEXT)).collect(Collectors.toList());
List<String> pdfUrls = new ArrayList<>();
for (MetadataFile file : publicFiles) {
......@@ -1533,8 +1532,7 @@ public class CommonMetadataService extends AouService implements OAIMetadataServ
if (AouConstants.DEPOSIT_TYPE_RAPPORT_NAME.equals(depositDocAdapter.getType(depositDoc))
|| this.isLivreOrOuvrageCollectifOrActesConference(depositDoc, depositDocAdapter)
|| this.isChapitreLivreOrContributionDict(depositDoc, depositDocAdapter)
|| this.isChapitreActesOrPresentationOrPoster(depositDoc, depositDocAdapter)
) {
|| this.isChapitreActesOrPresentationOrPoster(depositDoc, depositDocAdapter)) {
String publisherName = depositDocAdapter.getPublisherName(depositDoc);
if (!StringTool.isNullOrEmpty(publisherName)) {
this.putIfNotNull(htmlHeadersMap, "citation_publisher", publisherName);
......
......@@ -32,17 +32,18 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBElement;
import jakarta.xml.bind.Marshaller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ch.unige.solidify.exception.SolidifyRuntimeException;
import ch.unige.solidify.util.StringTool;
......@@ -849,6 +850,23 @@ public class DepositDocV2Adapter implements DepositDocAdapter {
depositDoc.getAdditionalMetadata().setDiffusion(additionalMetadata.get(AouConstants.INDEX_FIELD_DIFFUSION).toString());
}
// Structures with parent name
if (additionalMetadata.containsKey(AouConstants.INDEX_FIELD_STRUCTURES_WITH_PARENT)) {
this.ensureStructuresExists(depositDoc);
for (List<String> structure : (List<List<String>>) additionalMetadata.get(AouConstants.INDEX_FIELD_STRUCTURES_WITH_PARENT)) {
StringBuilder sb = new StringBuilder();
for (String structureItem : structure) {
if (sb.isEmpty()) {
sb.append(structureItem);
} else {
sb.insert(0, " / ");
sb.insert(0, structureItem);
}
}
depositDoc.getAdditionalMetadata().getStructures().getStructure().add(sb.toString());
}
}
// Contributors' ORCID
if (additionalMetadata.containsKey(AouConstants.INDEX_FIELD_CONTRIBUTORS) && !((List) additionalMetadata.get(
AouConstants.INDEX_FIELD_CONTRIBUTORS)).isEmpty()) {
......@@ -875,6 +893,13 @@ public class DepositDocV2Adapter implements DepositDocAdapter {
}
}
private void ensureStructuresExists(DepositDoc depositDoc) {
this.ensureAdditionalMetadataExists(depositDoc);
if (depositDoc.getAdditionalMetadata().getStructures() == null) {
depositDoc.getAdditionalMetadata().setStructures(this.factory.createStructures());
}
}
@Override
public String serializeDepositDocToXml(Object depositDocObject) {
try {
......
......@@ -171,7 +171,7 @@ spring.jmx.default-domain=${aou.application.name)-${aou.env}
# spring.profiles.include=person-search-rock, client-backend, storage-file, orcid, email-service, index-elasticsearch
# Storage
ou.storage.url=file://${aou.home}/storage
aou.storage.url=file://${aou.home}/storage
aou.thesisNfsSharePath=file:///${aou.home}/thesis
......