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
  • 0.0.3-maintenance
  • 1.0-maintenance
  • 2.0-maintenance
  • AOU-1412_Add_checksum_of_DataFile_when_importing_in_Fedora
  • HBO-test-jenkins-library
  • HCA-PortingSolidify-3.2
  • HCA-PortingSolidify-3.5
  • adf-1418-do-not-index-certain-files
  • adf-1464-job-clean-download-files
  • adf-1867-list-publications-stats
  • adf-763-1127-improve-license-mapping-during-imports
  • adf-907-notifications-mark-as-read
  • adf-956-add-imprimatur-and-mode-de-diffussion-for-thesis
  • adf-956-new-document-types-imprimatur-and-mode-de-diffusion
  • adf-979-add-depositor-in-notifications-email
  • adf-squash-commits-jb
  • adf-validator-name
  • aou-1512_fix_coherence_orders_for_indexed_structures
  • contributors-with-names
  • jbc-bibliography-tmpl
  • jbc-csl-correctionsDD
  • jbc-update-coverpage
  • master
  • remove-not-neccessary-ExtendWith-annotations
  • rod-refactor-fedora-storage-get-datastream-index
  • rodn-113-indexing-service
  • rodn-1136-author-can-send-in-validation
  • rodn-1253-fix-validator-comments-notifications
  • rodn-1634-bibliography-add-sort-by-validation-date
  • rodn-1829-scheduled-task-to-export-to-orcid
  • rodn-833-add-validation-rules-before-submit
  • rodn-access-contributor-by-orcid-old
  • rodn-finalize-swiss-library-exports-task
  • rodn-fix-IT
  • rodn-improve-access-it
  • rodn-index-contributors-without-director
  • rodn-index-fix-indexing-with-large-fulltext
  • rodn-index-subtype-code
  • rodn-language-refactoring
  • rodn-merge-users-it
  • rodn-orcid-export-master-with-other-id
  • rodn-orcid-solidify-webhooks
  • rodn-prevent-hibernate-circular-exception
  • rodn-refactor-labels
  • rodn-search-accent-insensitive
  • rodn-shared-reference-to-collection-debug
  • rodn-solidify-3.5
  • rodn-solidify-es-8
  • rodn-use-index-to-find-validable-publications
  • rodn-use-solidify-global-banner
  • unit-test-bibtex-escaper
  • aou-0.0.1
  • aou-0.0.2
  • aou-0.0.3
  • aou-0.0.3-patch1
  • aou-0.0.4
  • aou-0.0.5
  • aou-1.0.0
  • aou-1.0.1
  • aou-1.0.10
  • aou-1.0.11
  • aou-1.0.12
  • aou-1.0.13
  • aou-1.0.14
  • aou-1.0.15
  • aou-1.0.16
  • aou-1.0.17
  • aou-1.0.18
  • aou-1.0.19
  • aou-1.0.2
  • aou-1.0.20
  • aou-1.0.21
  • aou-1.0.3
  • aou-1.0.4
  • aou-1.0.5
  • aou-1.0.6
  • aou-1.0.7
  • aou-1.0.8
  • aou-1.0.9
  • aou-1.1.0
  • aou-2.0.0
  • aou-2.0.0-RC1
  • aou-2.0.0-RC2
  • aou-2.0.0-RC3
  • aou-2.0.1
  • aou-2.0.10
  • aou-2.0.11
  • aou-2.0.12
  • aou-2.0.13
  • aou-2.0.14
  • aou-2.0.15
  • aou-2.0.16
  • aou-2.0.17
  • aou-2.0.18
  • aou-2.0.19
  • aou-2.0.2
  • aou-2.0.20
  • aou-2.0.21
  • aou-2.0.22
  • aou-2.0.23
  • aou-2.0.24
  • aou-2.0.25
  • aou-2.0.26
  • aou-2.0.27
  • aou-2.0.28
  • aou-2.0.29
  • aou-2.0.3
  • aou-2.0.30
  • aou-2.0.31
  • aou-2.0.32
  • aou-2.0.33
  • aou-2.0.34
  • aou-2.0.4
  • aou-2.0.5
  • aou-2.0.6
  • aou-2.0.7
  • aou-2.0.8
  • aou-2.0.9
  • aou-2.1.0
  • aou-2.1.1
  • aou-2.1.10
  • aou-2.1.11
  • aou-2.1.12
  • aou-2.1.13
  • aou-2.1.14
  • aou-2.1.15
  • aou-2.1.16
  • aou-2.1.17
  • aou-2.1.18
  • aou-2.1.19
  • aou-2.1.2
  • aou-2.1.20
  • aou-2.1.21
  • aou-2.1.22
  • aou-2.1.23
  • aou-2.1.24
  • aou-2.1.25
  • aou-2.1.26
  • aou-2.1.27
  • aou-2.1.28
  • aou-2.1.29
  • aou-2.1.3
  • aou-2.1.30
  • aou-2.1.31
  • aou-2.1.32
  • aou-2.1.33
  • aou-2.1.4
  • aou-2.1.5
  • aou-2.1.6
  • aou-2.1.7
  • aou-2.1.8
151 results

Target

Select target project
  • aou/aou-backend
1 result
Select Git revision
  • 0.0.3-maintenance
  • 1.0-maintenance
  • 2.0-maintenance
  • AOU-1412_Add_checksum_of_DataFile_when_importing_in_Fedora
  • HBO-test-jenkins-library
  • HCA-PortingSolidify-3.2
  • HCA-PortingSolidify-3.5
  • adf-1418-do-not-index-certain-files
  • adf-1464-job-clean-download-files
  • adf-1867-list-publications-stats
  • adf-763-1127-improve-license-mapping-during-imports
  • adf-907-notifications-mark-as-read
  • adf-956-add-imprimatur-and-mode-de-diffussion-for-thesis
  • adf-956-new-document-types-imprimatur-and-mode-de-diffusion
  • adf-979-add-depositor-in-notifications-email
  • adf-squash-commits-jb
  • adf-validator-name
  • aou-1512_fix_coherence_orders_for_indexed_structures
  • contributors-with-names
  • jbc-bibliography-tmpl
  • jbc-csl-correctionsDD
  • jbc-update-coverpage
  • master
  • remove-not-neccessary-ExtendWith-annotations
  • rod-refactor-fedora-storage-get-datastream-index
  • rodn-113-indexing-service
  • rodn-1136-author-can-send-in-validation
  • rodn-1253-fix-validator-comments-notifications
  • rodn-1634-bibliography-add-sort-by-validation-date
  • rodn-1829-scheduled-task-to-export-to-orcid
  • rodn-833-add-validation-rules-before-submit
  • rodn-access-contributor-by-orcid-old
  • rodn-finalize-swiss-library-exports-task
  • rodn-fix-IT
  • rodn-improve-access-it
  • rodn-index-contributors-without-director
  • rodn-index-fix-indexing-with-large-fulltext
  • rodn-index-subtype-code
  • rodn-language-refactoring
  • rodn-merge-users-it
  • rodn-orcid-export-master-with-other-id
  • rodn-orcid-solidify-webhooks
  • rodn-prevent-hibernate-circular-exception
  • rodn-refactor-labels
  • rodn-search-accent-insensitive
  • rodn-shared-reference-to-collection-debug
  • rodn-solidify-3.5
  • rodn-solidify-es-8
  • rodn-use-index-to-find-validable-publications
  • rodn-use-solidify-global-banner
  • unit-test-bibtex-escaper
  • aou-0.0.1
  • aou-0.0.2
  • aou-0.0.3
  • aou-0.0.3-patch1
  • aou-0.0.4
  • aou-0.0.5
  • aou-1.0.0
  • aou-1.0.1
  • aou-1.0.10
  • aou-1.0.11
  • aou-1.0.12
  • aou-1.0.13
  • aou-1.0.14
  • aou-1.0.15
  • aou-1.0.16
  • aou-1.0.17
  • aou-1.0.18
  • aou-1.0.19
  • aou-1.0.2
  • aou-1.0.20
  • aou-1.0.21
  • aou-1.0.3
  • aou-1.0.4
  • aou-1.0.5
  • aou-1.0.6
  • aou-1.0.7
  • aou-1.0.8
  • aou-1.0.9
  • aou-1.1.0
  • aou-2.0.0
  • aou-2.0.0-RC1
  • aou-2.0.0-RC2
  • aou-2.0.0-RC3
  • aou-2.0.1
  • aou-2.0.10
  • aou-2.0.11
  • aou-2.0.12
  • aou-2.0.13
  • aou-2.0.14
  • aou-2.0.15
  • aou-2.0.16
  • aou-2.0.17
  • aou-2.0.18
  • aou-2.0.19
  • aou-2.0.2
  • aou-2.0.20
  • aou-2.0.21
  • aou-2.0.22
  • aou-2.0.23
  • aou-2.0.24
  • aou-2.0.25
  • aou-2.0.26
  • aou-2.0.27
  • aou-2.0.28
  • aou-2.0.29
  • aou-2.0.3
  • aou-2.0.30
  • aou-2.0.31
  • aou-2.0.32
  • aou-2.0.33
  • aou-2.0.34
  • aou-2.0.4
  • aou-2.0.5
  • aou-2.0.6
  • aou-2.0.7
  • aou-2.0.8
  • aou-2.0.9
  • aou-2.1.0
  • aou-2.1.1
  • aou-2.1.10
  • aou-2.1.11
  • aou-2.1.12
  • aou-2.1.13
  • aou-2.1.14
  • aou-2.1.15
  • aou-2.1.16
  • aou-2.1.17
  • aou-2.1.18
  • aou-2.1.19
  • aou-2.1.2
  • aou-2.1.20
  • aou-2.1.21
  • aou-2.1.22
  • aou-2.1.23
  • aou-2.1.24
  • aou-2.1.25
  • aou-2.1.26
  • aou-2.1.27
  • aou-2.1.28
  • aou-2.1.29
  • aou-2.1.3
  • aou-2.1.30
  • aou-2.1.31
  • aou-2.1.32
  • aou-2.1.33
  • aou-2.1.4
  • aou-2.1.5
  • aou-2.1.6
  • aou-2.1.7
  • aou-2.1.8
151 results
Show changes
Commits on Source (12)
Showing
with 367 additions and 1375 deletions
......@@ -26,8 +26,9 @@ import ch.unige.aou.rest.AouActionName;
import ch.unige.aou.rest.UrlPath;
import ch.unige.aou.service.metadata.imports.ArxivImportService;
import ch.unige.aou.service.metadata.imports.DoiCrossrefImportService;
import ch.unige.aou.service.rest.JournalTitleRemoteService;
import ch.unige.aou.service.metadata.imports.PmidImportService;
import ch.unige.aou.service.rest.JournalTitleRemoteService;
import ch.unige.aou.service.rest.RomeoService;
import ch.unige.aou.service.rest.UnigePersonSearch;
@UserPermissions
......@@ -41,14 +42,17 @@ public class ExternalDataController {
private ArxivImportService arxivImportService;
private JournalTitleRemoteService journalTitleService;
private PmidImportService pmidImportService;
private RomeoService romeoService;
public ExternalDataController(UnigePersonSearch unigePersonSearch, DoiCrossrefImportService doiCrossrefImportService,
ArxivImportService arxivImportService, JournalTitleRemoteService journalTitleService, PmidImportService pmidImportService) {
ArxivImportService arxivImportService, JournalTitleRemoteService journalTitleService, PmidImportService pmidImportService,
RomeoService romeoService) {
this.unigePersonSearch = unigePersonSearch;
this.doiCrossrefImportService = doiCrossrefImportService;
this.arxivImportService = arxivImportService;
this.journalTitleService = journalTitleService;
this.pmidImportService = pmidImportService;
this.romeoService = romeoService;
}
@GetMapping(AouActionName.SEARCH_UNIGE_PERSON)
......@@ -108,8 +112,8 @@ public class ExternalDataController {
@GetMapping(AouActionName.GET_JOURNAL_TITLES)
public HttpEntity<Collection<JournalTitleDTO>> getJournalTitlesByISSN(@RequestParam(required = false) String issn,
@RequestParam(required = false) String title,
Pageable page) {
@RequestParam(required = false) String title,
Pageable page) {
if (!StringTool.isNullOrEmpty(title)) {
SearchDTO search = new SearchDTO();
search.setPage(page.getPageNumber());
......@@ -123,4 +127,16 @@ public class ExternalDataController {
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
}
}
@GetMapping(AouActionName.GET_ROMEO_INFOS)
public HttpEntity<String> getRomeoByIssn(@RequestParam String issn) {
if (!StringTool.isNullOrEmpty(issn)) {
String romeoInfos = this.romeoService.getInfosByIssn(issn);
final HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
return new ResponseEntity<>(romeoInfos, headers, HttpStatus.OK);
}
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
}
}
......@@ -70,6 +70,10 @@ import ch.unige.aou.service.MetadataService;
import ch.unige.aou.service.metadata.imports.ArxivImportService;
import ch.unige.aou.service.metadata.imports.DoiCrossrefImportService;
import ch.unige.aou.service.metadata.imports.EuropePmcImportService;
import ch.unige.aou.service.metadata.imports.UnpaywallImportService;
import ch.unige.aou.specification.PublicationContributorSpecification;
import ch.unige.aou.specification.PublicationSpecification;
import ch.unige.aou.specification.UserSpecification;
@UserPermissions
@RestController
......@@ -83,16 +87,18 @@ public class PublicationController extends AouResourceController<Publication> {
private final ArxivImportService arxivImportService;
private final DoiCrossrefImportService doiCrossrefImportService;
private final EuropePmcImportService europePmcImportService;
private final UnpaywallImportService unpaywallImportService;
public PublicationController(MetadataService metadataService, PersonService personService, EventService eventService,
ArxivImportService arxivImportService, DoiCrossrefImportService doiCrossrefImportService,
EuropePmcImportService europePmcImportService) {
EuropePmcImportService europePmcImportService, UnpaywallImportService unpaywallImportService) {
this.metadataService = metadataService;
this.personService = personService;
this.eventService = eventService;
this.arxivImportService = arxivImportService;
this.doiCrossrefImportService = doiCrossrefImportService;
this.europePmcImportService = europePmcImportService;
this.unpaywallImportService = unpaywallImportService;
}
@Override
......@@ -147,11 +153,18 @@ public class PublicationController extends AouResourceController<Publication> {
@GetMapping(AouActionName.LIST_MY_PUBLICATIONS)
public HttpEntity<Collection<Publication>> listMyPublications(@ModelAttribute Publication search, Pageable pageable) {
return listMyPublications(null, search, pageable);
}
@GetMapping(path = AouActionName.LIST_MY_PUBLICATIONS, params = "fullName")
public HttpEntity<Collection<Publication>> listMyPublications(@RequestParam String fullName, @ModelAttribute Publication search,
Pageable pageable) {
Person creator = this.personService.getLinkedPerson(SecurityContextHolder.getContext().getAuthentication());
String cnIndividu = this.personService.getCnIndividuLinkedPerson();
if (creator != null && !StringTool.isNullOrEmpty(creator.getResId())) {
Page<Publication> listItem = ((PublicationService) this.itemService).findMyPublications(search, creator.getResId(), cnIndividu, pageable);
Page<Publication> listItem = ((PublicationService) this.itemService)
.findMyPublications(search, creator.getResId(), cnIndividu, pageable, fullName);
this.setRessourceLinks(listItem);
final Collection<Publication> collection = this.setCollectionLinks(listItem, pageable);
return new ResponseEntity<>(collection, HttpStatus.OK);
......@@ -355,12 +368,14 @@ public class PublicationController extends AouResourceController<Publication> {
this.arxivImportService.createDocumentFileFromArxivMetadata(publication);
} else if (publication.getImportSource().equals(Publication.ImportSource.DOI)) {
this.doiCrossrefImportService.createDocumentFileFromCrossrefMetadata(publication);
this.unpaywallImportService.createDocumentFileFromUnpaywall(publication);
} else if (publication.getImportSource().equals(Publication.ImportSource.PMID)) {
//check if there is pmcid, if so import files from (Europe)PMC
String pmicId = ((PublicationService) this.itemService).getPmcIdFromPublicationMetadata(publication);
if (!StringTool.isNullOrEmpty(pmicId)) {
this.europePmcImportService.createDocumentFileFromEuropePmc(publication);
}
this.unpaywallImportService.createDocumentFileFromUnpaywall(publication);
}
}
......
......@@ -9,10 +9,12 @@ import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import ch.unige.solidify.SolidifyConstants;
......@@ -26,6 +28,7 @@ import ch.unige.solidify.security.UserPermissions;
import ch.unige.aou.business.ResearchGroupService;
import ch.unige.aou.controller.AdminController;
import ch.unige.aou.model.settings.License;
import ch.unige.aou.model.settings.ResearchGroup;
import ch.unige.aou.rest.AouActionName;
import ch.unige.aou.rest.UrlPath;
......@@ -36,6 +39,14 @@ import ch.unige.aou.rest.UrlPath;
@RequestMapping(UrlPath.ADMIN_RESEARCH_GROUPS)
public class ResearchGroupController extends ResourceController<ResearchGroup> {
@UserPermissions
@Override
public HttpEntity<Collection<ResearchGroup>> advancedSearch(@ModelAttribute ResearchGroup researchGroup,
@RequestParam("search") String search,
@RequestParam(value = "match", required = false) String matchType, Pageable pageable) {
return super.advancedSearch(researchGroup, search, matchType, pageable);
}
@Override
@UserPermissions
public HttpEntity<Collection<ResearchGroup>> list(ResearchGroup search, Pageable pageable) {
......
......@@ -241,10 +241,12 @@ public class AouProperties {
private int maxPreservationPolicyRetentionPeriodInYears = 100;
//need to specify the same order for an specific type of format for metadata and frontend
private String[] metadataDateFormat = {"yyyy-MM-dd", "yyyy-MM", "yyyy"};
private String[] metadataOutputDateFormat = {"yyyy-MM-dd", "yyyy-MM", "yyyy"};
private String[] frontendEnterDateFormat = {"d.M.yyyy", "M.yyyy","yyyy"}; // format in which a date can be entered on frontend (1 digit allowed for day and month)
private String[] frontendOutputDateFormat = {"dd.MM.yyyy", "MM.yyyy", "yyyy"}; // format to which a date is given back to frontend (2 digits for day and month)
private String[] metadataDateFormat = { "yyyy-MM-dd", "yyyy-MM", "yyyy" };
private String[] metadataOutputDateFormat = { "yyyy-MM-dd", "yyyy-MM", "yyyy" };
private String[] frontendEnterDateFormat = { "d.M.yyyy", "M.yyyy",
"yyyy" }; // format in which a date can be entered on frontend (1 digit allowed for day and month)
private String[] frontendOutputDateFormat = { "dd.MM.yyyy", "MM.yyyy",
"yyyy" }; // format to which a date is given back to frontend (2 digits for day and month)
private String emailTemplatePath;
private String submissionPortalHomepage = "https://archive-ouverte.unige.ch"; // used in emails templates to build links to the portal
......@@ -1227,6 +1229,7 @@ public class AouProperties {
private Pmid pmid = new Pmid();
private Pmc pmc = new Pmc();
private EuropePmc europePmc = new EuropePmc();
private Unpaywall unpaywall = new Unpaywall();
private int limitMaxContributors = 100;
public Crossref getCrossref() {
......@@ -1269,6 +1272,14 @@ public class AouProperties {
this.europePmc = europePmc;
}
public Unpaywall getUnpaywall() {
return this.unpaywall;
}
public void setUnpaywall(Unpaywall unpaywall) {
this.unpaywall = unpaywall;
}
public int getLimitMaxContributors() {
return this.limitMaxContributors;
}
......@@ -1331,7 +1342,7 @@ public class AouProperties {
private SupplementaryFiles supplementaryFiles = new SupplementaryFiles();
public SupplementaryFiles getSupplementaryFiles() {
return supplementaryFiles;
return this.supplementaryFiles;
}
public void setSupplementaryFiles(SupplementaryFiles supplementaryFiles) {
......@@ -1347,7 +1358,7 @@ public class AouProperties {
}
}
public static class SupplementaryFiles {
public static class Unpaywall {
private String url;
public String getUrl() {
......@@ -1359,10 +1370,22 @@ public class AouProperties {
}
}
public static class SupplementaryFiles {
private String url;
public String getUrl() {
return this.url;
}
public void setUrl(String url) {
this.url = url;
}
}
public static class Search {
private Person person = new Person();
private Journal journal = new Journal();
private Romeo romeo = new Romeo();
public Person getPerson() {
return this.person;
......@@ -1379,6 +1402,14 @@ public class AouProperties {
public void setJournal(Journal journal) {
this.journal = journal;
}
public Romeo getRomeo() {
return this.romeo;
}
public void setRomeo(Romeo romeo) {
this.romeo = romeo;
}
}
public static class Person {
......@@ -1432,6 +1463,27 @@ public class AouProperties {
}
}
public static class Romeo {
private String url = "https://v2.sherpa.ac.uk/cgi/retrieve";
private String apiKey;
public String getUrl() {
return this.url;
}
public void setUrl(String url) {
this.url = url;
}
public String getApiKey() {
return this.apiKey;
}
public void setApiKey(String apiKey) {
this.apiKey = apiKey;
}
}
public static class Orcid {
private String clientId = "";
private String clientSecret = "";
......
......@@ -60,6 +60,8 @@ deposit.error.container.identifiers.invalid_urn=The value is not a valid URN
deposit.error.structure.invalid_code=This Structure code doesn't exit
deposit.error.researchGroup.invalid_code=This research group code doesn't exit
deposit.error.contributors.appears_more_than_once=This contributor appears more than once
deposit.error.contributors.missing_author_in_contributors=Missing author for this subtype of publication:''{0}''
deposit.error.contributors.missing_director_in_contributors=Missing director for this subtype of publication:''{0}''
deposit.error.field_cannot_be_empty=This field cannot be empty
deposit.error.field_invalid_value=This value is not valid
deposit.error.date.invalid_date=This date is not a valid date
......
......@@ -100,6 +100,7 @@ public abstract class AbstractAdminIT extends AbstractIT {
protected final String TEST_USER_ADMIN_ID = "admin";
protected final String TEST_USER_ROOT_ID = "root";
protected final String TEST_USER_USER_CN_INDIVIDU = "USER_externalUid";
protected final String TEST_DEWEY_CODE = "100";
@Autowired
protected CommentClientServiceInterface commentClientService;
......@@ -189,7 +190,7 @@ public abstract class AbstractAdminIT extends AbstractIT {
topStructure.setName(this.TOP_STRUCTURE_NAME);
topStructure.setCnStructC(this.TOP_STRUCTURE_CN_STRUCTC);
topStructure.setCodeStruct(this.TOP_STRUCTURE_CODE_STRUCTC);
topStructure.setDewey("100");
topStructure.setDewey(this.TEST_DEWEY_CODE);
topStructure.setSortValue(10);
this.structureService.create(topStructure);
}
......
......@@ -256,6 +256,98 @@ class DepositMetadataValidationV2IT extends PublicationIT {
assertTrue(this.validationErrorsContain("contributors.contributors.2.role", "This field cannot be empty", validationErrors));
}
@Test
void testAuthorAndDirectorPresentForThesis() {
Map<String, Object> metadataProperties = new HashMap<>();
metadataProperties.put("title", "validation test");
metadataProperties.put("languages", List.of(this.PUBLICATION_TEST_LANGUAGE));
metadataProperties.put("type", this.PUBLICATION_TYPE_DIPLOME_NAME);
metadataProperties.put("subtype", this.PUBLICATION_SUBTYPE_THESE_NAME);
List<AbstractContributor> contributors = new ArrayList<>();
ContributorDTO contributorDTO = new ContributorDTO();
contributorDTO.setFirstName("John");
contributorDTO.setLastName("Doe");
contributorDTO.setRole("author");
contributorDTO.setCnIndividu("12345");
contributors.add(contributorDTO);
CollaborationDTO collaborationDTO = new CollaborationDTO();
collaborationDTO.setName("My collaboration");
contributors.add(collaborationDTO);
contributorDTO = new ContributorDTO();
contributorDTO.setFirstName("Mika");
contributorDTO.setLastName("Mou");
contributorDTO.setRole("director");
contributorDTO.setCnIndividu("8596");
contributors.add(contributorDTO);
metadataProperties.put("contributors", contributors);
String xmlMetadata = this.getMetadata(metadataProperties);
Publication publication = new Publication();
publication.setMetadata(xmlMetadata);
publication.setFormStep(Publication.DepositFormStep.CONTRIBUTORS);
Publication savedPublication = this.publicationService.create(publication);
assertNotNull(savedPublication);
assertEquals(this.getTemporaryTestLabel("validation test"), savedPublication.getTitle());
DepositDoc savedDepositDoc = this.createDepositDocFromXml(savedPublication.getMetadata());
assertEquals("John", ((Contributor) savedDepositDoc.getContributors().getContributorOrCollaboration().get(0)).getFirstname());
assertEquals("Doe", ((Contributor) savedDepositDoc.getContributors().getContributorOrCollaboration().get(0)).getLastname());
assertEquals(AuthorRole.AUTHOR.name(),
((Contributor) savedDepositDoc.getContributors().getContributorOrCollaboration().get(0)).getRole().name());
assertEquals("12345", ((Contributor) savedDepositDoc.getContributors().getContributorOrCollaboration().get(0)).getCnIndividu());
assertEquals("My collaboration", ((Collaboration) savedDepositDoc.getContributors().getContributorOrCollaboration().get(1)).getName());
assertEquals("Mika", ((Contributor) savedDepositDoc.getContributors().getContributorOrCollaboration().get(2)).getFirstname());
assertEquals("Mou", ((Contributor) savedDepositDoc.getContributors().getContributorOrCollaboration().get(2)).getLastname());
assertEquals(AuthorRole.DIRECTOR.name(),
((Contributor) savedDepositDoc.getContributors().getContributorOrCollaboration().get(2)).getRole().name());
assertEquals("8596", ((Contributor) savedDepositDoc.getContributors().getContributorOrCollaboration().get(2)).getCnIndividu());
}
@Test
void testContributorsMissingAuthorForThesis() {
Map<String, Object> metadataProperties = new HashMap<>();
metadataProperties.put("title", "validation test");
metadataProperties.put("languages", List.of(this.PUBLICATION_TEST_LANGUAGE));
metadataProperties.put("type", this.PUBLICATION_TYPE_DIPLOME_NAME);
metadataProperties.put("subtype", this.PUBLICATION_SUBTYPE_THESE_NAME);
List<AbstractContributor> contributors = new ArrayList<>();
ContributorDTO contributorDTO = new ContributorDTO();
contributorDTO.setFirstName("John");
contributorDTO.setLastName("Doe");
contributorDTO.setRole("director");
contributorDTO.setCnIndividu("12345");
contributors.add(contributorDTO);
contributorDTO = new ContributorDTO();
contributorDTO.setFirstName("Mika");
contributorDTO.setLastName("Mou");
contributorDTO.setRole("director");
contributorDTO.setCnIndividu("8596");
contributors.add(contributorDTO);
metadataProperties.put("contributors", contributors);
String xmlMetadata = this.getMetadata(metadataProperties);
Publication publication = new Publication();
publication.setMetadata(xmlMetadata);
publication.setFormStep(Publication.DepositFormStep.CONTRIBUTORS);
HttpClientErrorException e = assertThrows(HttpClientErrorException.class, () -> {
this.publicationService.create(publication);
});
List<FieldValidationError> validationErrors = this.getValidationErrors(e.getResponseBodyAsString());
assertTrue(this.validationErrorsContain("contributors.contributors", "Missing author for this subtype of publication:'" + this.PUBLICATION_SUBTYPE_THESE_NAME + "'", validationErrors));
}
@Test
void testRepeatedContributors() {
Map<String, Object> metadataProperties = this.getBasicMetadataProperties();
......
......@@ -32,6 +32,7 @@ class LicenseIT extends AbstractAdminIT {
// Create a license
License expectedLicense = new License();
expectedLicense.setTitle(AouConstants.TEMPORARY_TEST_DATA_LABEL + "GNU Free Documentation License ");
expectedLicense.setSortValue(10);
final String gnuLicense = "GNU" + ThreadLocalRandom.current().nextInt();
expectedLicense.setOpenLicenseId(gnuLicense);
expectedLicense = this.licenseService.create(expectedLicense);
......@@ -59,6 +60,7 @@ class LicenseIT extends AbstractAdminIT {
License expectedLicense = new License();
expectedLicense.setTitle(AouConstants.TEMPORARY_TEST_DATA_LABEL + "License " + ThreadLocalRandom.current().nextInt());
expectedLicense.setOpenLicenseId("License " + ThreadLocalRandom.current().nextInt());
expectedLicense.setSortValue(10);
expectedLicense = this.licenseService.create(expectedLicense);
// Delete
......@@ -76,6 +78,7 @@ class LicenseIT extends AbstractAdminIT {
final License expectedLicense = new License();
expectedLicense.setTitle(AouConstants.TEMPORARY_TEST_DATA_LABEL + " License " + ThreadLocalRandom.current().nextInt());
expectedLicense.setOpenLicenseId("License " + ThreadLocalRandom.current().nextInt());
expectedLicense.setSortValue(10);
this.licenseService.create(expectedLicense);
......@@ -93,7 +96,7 @@ class LicenseIT extends AbstractAdminIT {
String actualPayload = this.licenseService.importLicenseFile(AOU_IMPORT_FILE_NAME).getBody();
assertEquals(expectedPayload, actualPayload);
// Test import as openLicense file format
expectedPayload = new JSONObject().put("imported", 109).toString();
expectedPayload = new JSONObject().put("imported", 11).toString();
actualPayload = this.licenseService.importOpenLicenseFile(ALL_IMPORT_FILE_NAME).getBody();
assertEquals(expectedPayload, actualPayload);
// Test import as ckan file format
......@@ -162,6 +165,7 @@ class LicenseIT extends AbstractAdminIT {
assertEquals(expectedLicense.getOdConformance(), actualLicense.getOsdConformance());
assertEquals(expectedLicense.getOsdConformance(), actualLicense.getOsdConformance());
assertEquals(expectedLicense.getStatus(), actualLicense.getStatus());
assertEquals(expectedLicense.getSortValue(), actualLicense.getSortValue());
assertEquals(expectedLicense.getUrl(), actualLicense.getUrl());
assertEquals(expectedLicense.getOpenLicenseId() + " (" + expectedLicense.getTitle() + ")", actualLicense.getDescription());
}
......
......@@ -137,6 +137,13 @@ class PublicationAsUserIT extends PublicationIT {
assertTrue(structurePublications.stream().anyMatch(st -> st.getCodeStruct().equals(structureToFill.getCodeStruct())));
this.assertEqualsFormData(formData, createdPublication.getFormData());
// check that the structure's dewey code is stored as a classification in Json metadata
JSONObject createdPublicationFormData = new JSONObject(createdPublication.getFormData());
assertEquals("Dewey",
createdPublicationFormData.getJSONObject("description").getJSONArray("classifications").getJSONObject(0).getString("code"));
assertEquals(this.TEST_DEWEY_CODE,
createdPublicationFormData.getJSONObject("description").getJSONArray("classifications").getJSONObject(0).getString("item"));
}
@Test
......
......@@ -72,8 +72,8 @@ abstract class PublicationIT extends AbstractAdminIT {
String personId = this.profilePerson.getResId();
// Subtype is taken from formData on backend
formData = formData.replace("\"" + this.PUBLICATION_TYPE_ARTICLE_ID + "\"", type.getResId());
formData = formData.replace("\"" + this.PUBLICATION_SUBTYPE_ARTICLE_SCIENTIFIQUE_ID + "\"", subtype.getResId());
formData = formData.replace("\"" + this.PUBLICATION_TYPE_ARTICLE_ID + "\"", "\"" + type.getResId() + "\"");
formData = formData.replace("\"" + this.PUBLICATION_SUBTYPE_ARTICLE_SCIENTIFIQUE_ID + "\"", "\"" + subtype.getResId() + "\"");
formData = formData.replace("\"A1-LETTRE\"", "null");
Publication createdPublication = this.createNewTemporaryPublication(formData);
......
......@@ -29,11 +29,13 @@ class ResearchGroupIT extends AbstractAdminIT {
ResearchGroup researchGroup = new ResearchGroup();
researchGroup.setName(this.getTemporaryTestLabel("Unilab"));
researchGroup.setCode("1234");
researchGroup.setAcronym("UL");
ResearchGroup createdResearchGroup = this.researchGroupService.create(researchGroup);
assertNotNull(createdResearchGroup);
assertEquals(researchGroup.getName(), createdResearchGroup.getName());
assertEquals(researchGroup.getCode(), createdResearchGroup.getCode());
assertEquals(researchGroup.getAcronym(), createdResearchGroup.getAcronym());
}
@Test
......@@ -98,20 +100,24 @@ class ResearchGroupIT extends AbstractAdminIT {
@Test
void updateResearchGroupTest() {
String newName = this.getTemporaryTestLabel("Unilab2");
final String acronym = "ULB";
ResearchGroup researchGroup = new ResearchGroup();
researchGroup.setName(this.getTemporaryTestLabel("Unilab"));
researchGroup.setCode("1111");
researchGroup.setAcronym("UL");
ResearchGroup createdResearchGroup = this.researchGroupService.create(researchGroup);
ResearchGroup researchGroupUpdate = new ResearchGroup();
researchGroupUpdate.setName(newName);
researchGroupUpdate.setCode("2222");
researchGroupUpdate.setAcronym(acronym);
this.researchGroupService.update(createdResearchGroup.getResId(), researchGroupUpdate);
ResearchGroup researchGroupFound = this.researchGroupService.findOne(createdResearchGroup.getResId());
assertNotNull(researchGroupFound);
assertEquals(newName, researchGroupFound.getName());
assertEquals(acronym, researchGroupFound.getAcronym());
}
@Test
......@@ -119,6 +125,7 @@ class ResearchGroupIT extends AbstractAdminIT {
ResearchGroup researchGroup = new ResearchGroup();
researchGroup.setName(this.getTemporaryTestLabel("Unilab"));
researchGroup.setCode("1234");
researchGroup.setAcronym("UL");
ResearchGroup createdResearchGroup = this.researchGroupService.create(researchGroup);
assertNotNull(createdResearchGroup);
......@@ -134,12 +141,14 @@ class ResearchGroupIT extends AbstractAdminIT {
ResearchGroup researchGroup = new ResearchGroup();
researchGroup.setName(this.getTemporaryTestLabel("Unilab"));
researchGroup.setCode("1234");
researchGroup.setAcronym("UL");
ResearchGroup createdResearchGroup1 = this.researchGroupService.create(researchGroup);
assertNotNull(createdResearchGroup1);
ResearchGroup researchGroup2 = new ResearchGroup();
researchGroup2.setName(this.getTemporaryTestLabel("Unilab2"));
researchGroup2.setCode("9999");
researchGroup2.setAcronym("UL2");
ResearchGroup createdResearchGroup2 = this.researchGroupService.create(researchGroup2);
assertNotNull(createdResearchGroup2);
......
......@@ -20,6 +20,7 @@ import ch.unige.aou.service.admin.StructureClientService;
class StructureIT extends AbstractAdminIT {
@Override
protected void setUser() {
this.restClientTool.sudoAdmin();
}
......
......@@ -50,7 +50,7 @@ class ErrorIT {
@BeforeEach
void init() {
this.restClientTool = new SudoRestClientTool(rootToken, adminToken, userToken);
this.restClientTool = new SudoRestClientTool(this.rootToken, this.adminToken, this.userToken);
}
protected void setUser() {
......@@ -114,11 +114,11 @@ class ErrorIT {
try {
final URL url = new URL(this.adminUrl);
String port = "";
final int portNumber = url.getPort();
if (portNumber != -1) {
port = String.valueOf(portNumber);
if (url.getPort() != -1) {
port = ":" + url.getPort();
}
final String urlWithoutUserInfo = url.getProtocol() + "://" + url.getHost() + ":" + port + url.getPath();
final String urlWithoutUserInfo = url.getProtocol() + "://" + url.getHost() + port + url.getPath();
final RestTemplate restTemplate = new RestTemplate();
restTemplate.getForObject(urlWithoutUserInfo, String.class);
fail("An UNAUTHORIZED Http response should be received");
......
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>ch.unige.aou</groupId>
......
......@@ -172,6 +172,12 @@ public class License extends AouSearchableResourceNormalized<License> {
@NotNull
private String title;
/**
* Property allowing to sort subtypes in lists
*/
@Column(nullable = false)
private Integer sortValue;
private URL url;
public String getDescription() {
......@@ -224,6 +230,14 @@ public class License extends AouSearchableResourceNormalized<License> {
return this.title;
}
public Integer getSortValue() {
return this.sortValue;
}
public void setSortValue(Integer sort) {
this.setCurrentProperty(sort);
}
public URL getUrl() {
return this.url;
}
......
......@@ -8,17 +8,23 @@ import javax.persistence.ManyToMany;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.hateoas.server.mvc.WebMvcLinkBuilder;
import com.fasterxml.jackson.annotation.JsonIgnore;
import ch.unige.solidify.util.SearchCriteria;
import ch.unige.aou.AouConstants;
import ch.unige.aou.model.AouResourceNormalized;
import ch.unige.aou.model.AouSearchableResourceNormalized;
import ch.unige.aou.model.publication.Publication;
import ch.unige.aou.rest.ResourceName;
import ch.unige.aou.specification.LicenseSearchSpecification;
import ch.unige.aou.specification.ResearchGroupSearchSpecification;
@Entity
public class ResearchGroup extends AouResourceNormalized<ResearchGroup> {
public class ResearchGroup extends AouSearchableResourceNormalized<ResearchGroup> {
@Size(min = 1)
@NotNull
......@@ -28,6 +34,9 @@ public class ResearchGroup extends AouResourceNormalized<ResearchGroup> {
@Column(unique = true)
private String code;
@Column()
private String acronym;
@NotNull
private Boolean active = Boolean.FALSE;
......@@ -51,6 +60,10 @@ public class ResearchGroup extends AouResourceNormalized<ResearchGroup> {
return this.code;
}
public String getAcronym() {
return this.acronym;
}
public void setName(String name) {
this.setCurrentProperty(name);
}
......@@ -59,6 +72,10 @@ public class ResearchGroup extends AouResourceNormalized<ResearchGroup> {
this.setCurrentProperty(code);
}
public void setAcronym(String acronym) {
this.setCurrentProperty(acronym);
}
public Boolean isActive() {
return this.active;
}
......@@ -83,6 +100,11 @@ public class ResearchGroup extends AouResourceNormalized<ResearchGroup> {
return result;
}
@Override
public Specification<ResearchGroup> getSearchSpecification(SearchCriteria criteria) {
return new ResearchGroupSearchSpecification(criteria);
}
@Override
public void addLinks(WebMvcLinkBuilder linkBuilder, boolean mainRes, boolean subResOnly) {
super.addLinks(linkBuilder, mainRes, subResOnly);
......
......@@ -29,6 +29,7 @@ public class AouActionName {
public static final String GET_METADATA_FROM_ARXIV = "get-metadata-from-arxiv";
public static final String IMPORT_FILE_ARXIV = "import-file-from-arxiv";
public static final String GET_METADATA_FROM_PMID = "get-metadata-from-pmid";
public static final String GET_ROMEO_INFOS = "get-romeo-infos";
public static final String LIST_VALIDATOR_COMMENTS = "list-validator-comments";
public static final String GET_MY_DEFAULT_PROFILE_DATA = "get-my-default-profile-data";
public static final String GET_JOURNAL_TITLES = "get-journal-titles";
......
......@@ -34,5 +34,8 @@ public class LicenseSpecification extends SolidifySpecification<License> {
if (this.criteria.getFamily() != null) {
predicatesList.add(builder.like(root.get("family"), "%" + this.criteria.getFamily() + "%"));
}
if (this.criteria.getSortValue() != null) {
predicatesList.add(builder.equal(root.get("sortValue"), this.criteria.getSortValue()));
}
}
}
package ch.unige.aou.specification;
import java.time.OffsetDateTime;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import ch.unige.solidify.specification.SolidifySpecification;
import ch.unige.solidify.util.StringTool;
import ch.unige.aou.model.publication.Publication;
public class PublicationSpecification extends SolidifySpecification<Publication> {
private static final long serialVersionUID = -2649320901418924922L;
private String fullName;
public PublicationSpecification(Publication criteria) {
super(criteria);
}
......@@ -35,5 +41,22 @@ public class PublicationSpecification extends SolidifySpecification<Publication>
if (this.criteria.getMetadata() != null) {
predicatesList.add(builder.like(root.get("metadata"), "%" + this.criteria.getMetadata() + "%"));
}
if (this.criteria.getSubtype() != null && this.criteria.getSubtype().getResId() != null) {
predicatesList.add(builder.equal(root.get("subtype").get("resId"), this.criteria.getSubtype().getResId()));
}
if (!StringTool.isNullOrEmpty(fullName)) {
List<String> listTerm = Arrays.stream(fullName.split(" ")).filter(term -> !StringTool.isNullOrEmpty(term)).collect(Collectors.toList());
if (listTerm.size() > 0) {
for (String term : listTerm) {
Predicate likeFirstName = builder.like(root.get("creator").get("firstName"), "%" + term + "%");
Predicate likeLastName = builder.like(root.get("creator").get("lastName"), "%" + term + "%");
predicatesList.add(builder.or(likeFirstName, likeLastName));
}
}
}
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
}