Resolve "Ведение списка литературы статей" #235

Merged
SemenovaMasha merged 1 commits from 127-paper-references into dev 2019-05-24 23:43:29 +04:00
3 changed files with 30 additions and 31 deletions

View File

@ -1,42 +1,43 @@
package ru.ulstu.paper.model;
import java.util.ArrayList;
import java.util.List;
public class AutoCompleteData {
ArrayList<String> authors = new ArrayList<>();
ArrayList<String> publicationTitles = new ArrayList<>();
ArrayList<String> publishers = new ArrayList<>();
ArrayList<String> journalOrCollectionTitles = new ArrayList<>();
private List<String> authors = new ArrayList<>();
private List<String> publicationTitles = new ArrayList<>();
private List<String> publishers = new ArrayList<>();
private List<String> journalOrCollectionTitles = new ArrayList<>();
public ArrayList<String> getAuthors() {
public List<String> getAuthors() {
return authors;
}
public void setAuthors(ArrayList<String> authors) {
public void setAuthors(List<String> authors) {
this.authors = authors;
}
public ArrayList<String> getPublicationTitles() {
public List<String> getPublicationTitles() {
return publicationTitles;
}
public void setPublicationTitles(ArrayList<String> publicationTitles) {
public void setPublicationTitles(List<String> publicationTitles) {
this.publicationTitles = publicationTitles;
}
public ArrayList<String> getPublishers() {
public List<String> getPublishers() {
return publishers;
}
public void setPublishers(ArrayList<String> publishers) {
public void setPublishers(List<String> publishers) {
this.publishers = publishers;
}
public ArrayList<String> getJournalOrCollectionTitles() {
public List<String> getJournalOrCollectionTitles() {
return journalOrCollectionTitles;
}
public void setJournalOrCollectionTitles(ArrayList<String> journalOrCollectionTitles) {
public void setJournalOrCollectionTitles(List<String> journalOrCollectionTitles) {
this.journalOrCollectionTitles = journalOrCollectionTitles;
}
}

View File

@ -4,20 +4,20 @@ import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import ru.ulstu.paper.model.Reference;
import java.util.ArrayList;
import java.util.List;
public interface ReferenceRepository extends JpaRepository<Reference, Integer> {
void deleteById(Integer id);
@Query("SELECT DISTINCT r.authors FROM Reference r")
ArrayList<String> findDistinctAuthors();
List<String> findDistinctAuthors();
@Query("SELECT DISTINCT r.publicationTitle FROM Reference r")
ArrayList<String> findDistinctPublicationTitles();
List<String> findDistinctPublicationTitles();
@Query("SELECT DISTINCT r.publisher FROM Reference r")
ArrayList<String> findDistinctPublishers();
List<String> findDistinctPublishers();
@Query("SELECT DISTINCT r.journalOrCollectionTitle FROM Reference r where r.journalOrCollectionTitle <> ''")
ArrayList<String> findDistinctJournalOrCollectionTitles();
List<String> findDistinctJournalOrCollectionTitles();
}

View File

@ -146,13 +146,7 @@ public class PaperService {
@Transactional
public Reference updateReference(ReferenceDto referenceDto) {
Reference updateReference = referenceRepository.findOne(referenceDto.getId());
updateReference.setAuthors(referenceDto.getAuthors());
updateReference.setJournalOrCollectionTitle(referenceDto.getJournalOrCollectionTitle());
updateReference.setPages(referenceDto.getPages());
updateReference.setPublicationTitle(referenceDto.getPublicationTitle());
updateReference.setPublicationYear(referenceDto.getPublicationYear());
updateReference.setPublisher(referenceDto.getPublisher());
updateReference.setReferenceType(referenceDto.getReferenceType());
copyFromDto(updateReference, referenceDto);
referenceRepository.save(updateReference);
return updateReference;
}
@ -160,17 +154,21 @@ public class PaperService {
@Transactional
public Reference createReference(ReferenceDto referenceDto) {
Reference newReference = new Reference();
newReference.setAuthors(referenceDto.getAuthors());
newReference.setJournalOrCollectionTitle(referenceDto.getJournalOrCollectionTitle());
newReference.setPages(referenceDto.getPages());
newReference.setPublicationTitle(referenceDto.getPublicationTitle());
newReference.setPublicationYear(referenceDto.getPublicationYear());
newReference.setPublisher(referenceDto.getPublisher());
newReference.setReferenceType(referenceDto.getReferenceType());
copyFromDto(newReference, referenceDto);
newReference = referenceRepository.save(newReference);
return newReference;
}
private Reference copyFromDto(Reference reference, ReferenceDto referenceDto) {
reference.setAuthors(referenceDto.getAuthors());
reference.setJournalOrCollectionTitle(referenceDto.getJournalOrCollectionTitle());
reference.setPages(referenceDto.getPages());
reference.setPublicationTitle(referenceDto.getPublicationTitle());
reference.setPublicationYear(referenceDto.getPublicationYear());
reference.setPublisher(referenceDto.getPublisher());
reference.setReferenceType(referenceDto.getReferenceType());
return reference;
}
@Transactional
public Integer update(PaperDto paperDto) throws IOException {