From 2e613688d81125f5a6c155bff26df347a886767a Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Thu, 5 Sep 2019 20:29:54 +0200 Subject: [PATCH] Assets for various data used by publiations --- .../assets/CollectedVolumeAsset.java | 144 +++++------- .../publications/assets/JournalAsset.java | 201 +++++------------ .../publications/assets/ProceedingsAsset.java | 213 +++++------------- .../publications/assets/PublisherAsset.java | 135 +++++------ 4 files changed, 229 insertions(+), 464 deletions(-) diff --git a/sci-publications/src/main/java/org/scientificcms/publications/assets/CollectedVolumeAsset.java b/sci-publications/src/main/java/org/scientificcms/publications/assets/CollectedVolumeAsset.java index 9318782..bc42d06 100644 --- a/sci-publications/src/main/java/org/scientificcms/publications/assets/CollectedVolumeAsset.java +++ b/sci-publications/src/main/java/org/scientificcms/publications/assets/CollectedVolumeAsset.java @@ -5,13 +5,15 @@ */ package org.scientificcms.publications.assets; +import org.hibernate.envers.Audited; import org.librecms.contentsection.Asset; -import org.scientificcms.publications.Publication; -import org.scientificcms.publications.PublicationWithPublisher; +import org.scientificcms.publications.CollectedVolume; import java.util.Objects; import javax.persistence.Entity; +import javax.persistence.JoinColumn; +import javax.persistence.OneToOne; import javax.persistence.Table; import static org.scientificcms.publications.SciPublicationsConstants.*; @@ -22,89 +24,61 @@ import static org.scientificcms.publications.SciPublicationsConstants.*; */ @Entity @Table(name = "COLLECTED_VOLUMES", schema = DB_SCHEMA) +@Audited public class CollectedVolumeAsset extends Asset { -// private static final long serialVersionUID = 1L; -// -// private Publication basicProperties; -// -// private PublicationWithPublisher withPublisherProperties; -// -// public CollectedVolumeAsset() { -// -// super(); -// -// basicProperties = new Publication(); -// withPublisherProperties = new PublicationWithPublisher(); -// } -// -// public Publication getBasicProperties() { -// return basicProperties; -// } -// -// protected void setBasicProperties( -// final Publication basicProperties) { -// this.basicProperties = basicProperties; -// } -// -// public PublicationWithPublisher getWithPublisherProperties() { -// return withPublisherProperties; -// } -// -// protected void setWithPublisherProperties( -// final PublicationWithPublisher withPublisherProperties) { -// this.withPublisherProperties = withPublisherProperties; -// } -// -// @Override -// public int hashCode() { -// int hash = super.hashCode(); -// hash = 19 * hash + Objects.hashCode(basicProperties); -// hash = 19 * hash + Objects.hashCode(withPublisherProperties); -// return hash; -// } -// -// @Override -// public boolean equals(final Object obj) { -// if (this == obj) { -// return true; -// } -// if (obj == null) { -// return false; -// } -// if (!super.equals(obj)) { -// return false; -// } -// if (!(obj instanceof CollectedVolumeAsset)) { -// return false; -// } -// final CollectedVolumeAsset other = (CollectedVolumeAsset) obj; -// if (!other.canEqual(this)) { -// return false; -// } -// if (!Objects.equals(basicProperties, other.getBasicProperties())) { -// return false; -// } -// return Objects.equals(withPublisherProperties, -// other.getWithPublisherProperties()); -// } -// -// @Override -// public boolean canEqual(final Object obj) { -// -// return obj instanceof CollectedVolumeAsset; -// } -// -// @Override -// public String toString(final String data) { -// -// return super.toString(String.format( -// "basicProperties = %s, " -// + "withPublisherProperties = %s%s", -// Objects.toString(basicProperties), -// Objects.toString( -// withPublisherProperties), -// data)); -// } -// + private static final long serialVersionUID = 1L; + + @OneToOne + @JoinColumn(name = "COLLECTED_VOLUME_ID") + private CollectedVolume collectedVolume; + + public CollectedVolume getCollectedVolume() { + return collectedVolume; + } + + protected void setCollectedVolume(final CollectedVolume collectedVolume) { + this.collectedVolume = collectedVolume; + } + + @Override + public int hashCode() { + int hash = super.hashCode(); + hash = 29 * hash + Objects.hashCode(collectedVolume); + return hash; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (!super.equals(obj)) { + return false; + } + if (!(obj instanceof CollectedVolumeAsset)) { + return false; + } + final CollectedVolumeAsset other = (CollectedVolumeAsset) obj; + if (!other.canEqual(this)) { + return false; + } + return Objects.equals(this.collectedVolume, other.getCollectedVolume()); + } + + @Override + public boolean canEqual(final Object obj) { + return obj instanceof CollectedVolumeAsset; + } + + @Override + public String toString(final String data) { + return super.toString(String.format("collectedVolume = %s%s", + Objects.toString(collectedVolume), + data)); + } + } diff --git a/sci-publications/src/main/java/org/scientificcms/publications/assets/JournalAsset.java b/sci-publications/src/main/java/org/scientificcms/publications/assets/JournalAsset.java index 398671e..2c8235d 100644 --- a/sci-publications/src/main/java/org/scientificcms/publications/assets/JournalAsset.java +++ b/sci-publications/src/main/java/org/scientificcms/publications/assets/JournalAsset.java @@ -6,16 +6,14 @@ package org.scientificcms.publications.assets; import org.hibernate.envers.Audited; -import org.libreccm.l10n.LocalizedString; import org.librecms.contentsection.Asset; +import org.scientificcms.publications.Journal; import java.util.Objects; -import javax.persistence.AssociationOverride; -import javax.persistence.Embedded; import javax.persistence.Entity; import javax.persistence.JoinColumn; -import javax.persistence.JoinTable; +import javax.persistence.OneToOne; import javax.persistence.Table; import static org.scientificcms.publications.SciPublicationsConstants.*; @@ -30,146 +28,59 @@ import static org.scientificcms.publications.SciPublicationsConstants.*; @Audited public class JournalAsset extends Asset { -// private static final long serialVersionUID = 1L; -// -// /** -// * Year in which the journal was published first. -// */ -// private Integer firstYear; -// -// /** -// * Year in which the journal was published last -// */ -// private Integer lastYear; -// -// /** -// * The ISSN of the journal. -// */ -// private String issn; -// -// /** -// * A short description of the journal. -// */ -// @Embedded -// @AssociationOverride( -// name = "values", -// joinTable = @JoinTable(name = "JOURNAL_DESCRIPTIONS", -// schema = DB_SCHEMA, -// joinColumns = { -// @JoinColumn(name = "OBJECT_ID") -// }) -// ) -// private LocalizedString description; -// -// /** -// * The usual symbol/abbrevation used to refer to the journal. -// */ -// private String symbol; -// -// public Integer getFirstYear() { -// return firstYear; -// } -// -// public void setFirstYear(final Integer firstYear) { -// this.firstYear = firstYear; -// } -// -// public Integer getLastYear() { -// return lastYear; -// } -// -// public void setLastYear(final Integer lastYear) { -// this.lastYear = lastYear; -// } -// -// public String getIssn() { -// return issn; -// } -// -// public void setIssn(final String issn) { -// this.issn = issn; -// } -// -// public LocalizedString getDescription() { -// return description; -// } -// -// public void setDescription(final LocalizedString description) { -// this.description = description; -// } -// -// public String getSymbol() { -// return symbol; -// } -// -// public void setSymbol(final String symbol) { -// this.symbol = symbol; -// } -// -// @Override -// public int hashCode() { -// int hash = super.hashCode(); -// hash = 73 * hash + Objects.hashCode(firstYear); -// hash = 73 * hash + Objects.hashCode(lastYear); -// hash = 73 * hash + Objects.hashCode(issn); -// hash = 73 * hash + Objects.hashCode(description); -// hash = 73 * hash + Objects.hashCode(symbol); -// return hash; -// } -// -// @Override -// public boolean equals(final Object obj) { -// if (this == obj) { -// return true; -// } -// if (obj == null) { -// return false; -// } -// if (!super.equals(obj)) { -// return false; -// } -// if (!(obj instanceof JournalAsset)) { -// return false; -// } -// final JournalAsset other = (JournalAsset) obj; -// if (!other.canEqual(this)) { -// return false; -// } -// if (!Objects.equals(firstYear, other.getFirstYear())) { -// return false; -// } -// if (!Objects.equals(lastYear, other.getLastYear())) { -// return false; -// } -// if (!Objects.equals(issn, other.getIssn())) { -// return false; -// } -// if (!Objects.equals(symbol, other.getSymbol())) { -// return false; -// } -// return Objects.equals(description, other.getDescription()); -// } -// -// @Override -// public boolean canEqual(final Object obj) { -// return obj instanceof JournalAsset; -// } -// -// @Override -// public String toString(final String data) { -// -// return super.toString(String.format( -// ", firstYear = %s, " -// + "lastYear = %s, " -// + "issn = \"%s\", " -// + "symbol = \"%s\", " -// + "description = %s%s", -// Objects.toString(firstYear), -// Objects.toString(lastYear), -// issn, -// symbol, -// description, -// data)); -// } + private static final long serialVersionUID = 1L; + + @OneToOne + @JoinColumn(name = "JOURNAL_ID") + private Journal journal; + + public Journal getJournal() { + return journal; + } + + protected void setJournal(final Journal journal) { + this.journal = journal; + } + + @Override + public int hashCode() { + int hash = super.hashCode(); + hash = 59 * hash + Objects.hashCode(journal); + return hash; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (!super.equals(obj)) { + return false; + } + if (!(obj instanceof JournalAsset)) { + return false; + } + final JournalAsset other = (JournalAsset) obj; + if (!other.canEqual(this)) { + return false; + } + return Objects.equals(journal, other.getJournal()); + } + + @Override + public boolean canEqual(final Object obj) { + return obj instanceof JournalAsset; + } + + @Override + public String toString(final String data) { + + return super.toString(String.format(", journal = %s%s", + Objects.toString(journal), + data)); + } } diff --git a/sci-publications/src/main/java/org/scientificcms/publications/assets/ProceedingsAsset.java b/sci-publications/src/main/java/org/scientificcms/publications/assets/ProceedingsAsset.java index 7beba21..0414673 100644 --- a/sci-publications/src/main/java/org/scientificcms/publications/assets/ProceedingsAsset.java +++ b/sci-publications/src/main/java/org/scientificcms/publications/assets/ProceedingsAsset.java @@ -5,15 +5,15 @@ */ package org.scientificcms.publications.assets; +import org.hibernate.envers.Audited; import org.librecms.contentsection.Asset; -import org.scientificcms.publications.Publication; -import org.scientificcms.publications.PublicationWithPublisher; +import org.scientificcms.publications.Proceedings; -import java.time.LocalDate; import java.util.Objects; -import javax.persistence.Column; import javax.persistence.Entity; +import javax.persistence.JoinColumn; +import javax.persistence.OneToOne; import javax.persistence.Table; import static org.scientificcms.publications.SciPublicationsConstants.*; @@ -24,158 +24,61 @@ import static org.scientificcms.publications.SciPublicationsConstants.*; */ @Entity @Table(name = "PROCEEDINGS", schema = DB_SCHEMA) +@Audited public class ProceedingsAsset extends Asset { -// private static final long serialVersionUID = 1L; -// -// private Publication basicProperties; -// -// private PublicationWithPublisher withPublisherProperties; -// -// @Column(name = "NAME_OF_CONFERENCE", length = 1024) -// private String nameOfConference; -// -// @Column(name = "PLACE_OF_CONFERENCE", length = 1024) -// private String placeOfConference; -// -// @Column(name = "START_DATE_OF_CONFERENCE") -// private LocalDate startDateOfConference; -// -// @Column(name = "END_DATE_OF_CONFERENCE") -// private LocalDate endDateOfConference; -// -// public ProceedingsAsset() { -// -// super(); -// -// basicProperties = new Publication(); -// withPublisherProperties = new PublicationWithPublisher(); -// } -// -// public Publication getBasicProperties() { -// return basicProperties; -// } -// -// protected void setBasicProperties( -// final Publication basicProperties) { -// this.basicProperties = basicProperties; -// } -// -// public PublicationWithPublisher getWithPublisherProperties() { -// return withPublisherProperties; -// } -// -// protected void setWithPublisherProperties( -// final PublicationWithPublisher withPublisherProperties) { -// this.withPublisherProperties = withPublisherProperties; -// } -// -// public String getNameOfConference() { -// return nameOfConference; -// } -// -// public void setNameOfConference(final String nameOfConference) { -// this.nameOfConference = nameOfConference; -// } -// -// public String getPlaceOfConference() { -// return placeOfConference; -// } -// -// public void setPlaceOfConference(final String placeOfConference) { -// this.placeOfConference = placeOfConference; -// } -// -// public LocalDate getStartDateOfConference() { -// return startDateOfConference; -// } -// -// public void setStartDateOfConference(final LocalDate startDateOfConference) { -// this.startDateOfConference = startDateOfConference; -// } -// -// public LocalDate getEndDateOfConference() { -// return endDateOfConference; -// } -// -// public void setEndDateOfConference(final LocalDate endDateOfConference) { -// this.endDateOfConference = endDateOfConference; -// } -// -// @Override -// public int hashCode() { -// int hash = super.hashCode(); -// hash = 19 * hash + Objects.hashCode(basicProperties); -// hash = 19 * hash + Objects.hashCode(withPublisherProperties); -// hash = 19 * hash + Objects.hashCode(nameOfConference); -// hash = 19 * hash + Objects.hashCode(placeOfConference); -// hash = 19 * hash + Objects.hashCode(startDateOfConference); -// hash = 19 * hash + Objects.hashCode(endDateOfConference); -// return hash; -// } -// -// @Override -// public boolean equals(final Object obj) { -// if (this == obj) { -// return true; -// } -// if (obj == null) { -// return false; -// } -// if (!super.equals(obj)) { -// return false; -// } -// if (!(obj instanceof ProceedingsAsset)) { -// return false; -// } -// final ProceedingsAsset other = (ProceedingsAsset) obj; -// if (!other.canEqual(this)) { -// return false; -// } -// if (!Objects.equals(basicProperties, other.getBasicProperties())) { -// return false; -// } -// if (!Objects.equals(withPublisherProperties, -// other.getWithPublisherProperties())) { -// return false; -// } -// if (!Objects.equals(nameOfConference, other.getNameOfConference())) { -// return false; -// } -// if (!Objects.equals(placeOfConference, other.getPlaceOfConference())) { -// return false; -// } -// if (!Objects.equals(startDateOfConference, -// other.getStartDateOfConference())) { -// return false; -// } -// return Objects.equals(endDateOfConference, -// other.getEndDateOfConference()); -// } -// -// @Override -// public boolean canEqual(final Object obj) { -// -// return obj instanceof ProceedingsAsset; -// } -// -// @Override -// public String toString(final String data) { -// -// return super.toString(String.format( -// "basicProperties = %s, " -// + "withPublisherProperties = %s, " -// + "nameOfConference = \"%s\", " -// + "placeOfConference = \"%s\", " -// + "startDateOfConference = \"%s\", " -// + "endDateOfConference = \"%s\"%s", -// Objects.toString(basicProperties), -// Objects.toString(withPublisherProperties), -// nameOfConference, -// placeOfConference, -// Objects.toString(startDateOfConference), -// Objects.toString(endDateOfConference), -// data)); -// } + private static final long serialVersionUID = 1L; + + @OneToOne + @JoinColumn(name = "PROCEEDINGS_ID") + private Proceedings proceedings; + + public Proceedings getProceedings() { + return proceedings; + } + + public void setProceedings(Proceedings proceedings) { + this.proceedings = proceedings; + } + + @Override + public int hashCode() { + int hash = super.hashCode(); + hash = 59 * hash + Objects.hashCode(proceedings); + return hash; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (!super.equals(obj)) { + return false; + } + if (!(obj instanceof ProceedingsAsset)) { + return false; + } + final ProceedingsAsset other = (ProceedingsAsset) obj; + if (!other.canEqual(this)) { + return false; + } + return Objects.equals(this.proceedings, other.getProceedings()); + } + + @Override + public boolean canEqual(final Object obj) { + return obj instanceof ProceedingsAsset; + } + + @Override + public String toString(final String data) { + return super.toString(String.format(", proceeeings = %s%s", + Objects.toString(proceedings), + data)); + } } diff --git a/sci-publications/src/main/java/org/scientificcms/publications/assets/PublisherAsset.java b/sci-publications/src/main/java/org/scientificcms/publications/assets/PublisherAsset.java index 70a0ce1..3d29409 100644 --- a/sci-publications/src/main/java/org/scientificcms/publications/assets/PublisherAsset.java +++ b/sci-publications/src/main/java/org/scientificcms/publications/assets/PublisherAsset.java @@ -7,11 +7,13 @@ package org.scientificcms.publications.assets; import org.hibernate.envers.Audited; import org.librecms.contentsection.Asset; +import org.scientificcms.publications.Publisher; import java.util.Objects; -import javax.persistence.Column; import javax.persistence.Entity; +import javax.persistence.JoinColumn; +import javax.persistence.OneToOne; import javax.persistence.Table; import static org.scientificcms.publications.SciPublicationsConstants.*; @@ -27,83 +29,58 @@ import static org.scientificcms.publications.SciPublicationsConstants.*; @Audited public class PublisherAsset extends Asset { -// private static final long serialVersionUID = 1L; -// -// /** -// * Name of the publisher. The title of the asset is only for internal use, -// * this property should be used for name of the publisher which is displayed -// * on public pages. -// */ -// @Column(name = "NAME", length = 2048, nullable = false) -// private String name; -// -// /** -// * The place of the publisher. -// */ -// @Column(name = "PLACE", length = 2048) -// private String place; -// -// public String getName() { -// return name; -// } -// -// public void setName(final String name) { -// this.name = name; -// } -// -// public String getPlace() { -// return place; -// } -// -// public void setPlace(final String place) { -// this.place = place; -// } -// -// @Override -// public int hashCode() { -// int hash = super.hashCode(); -// hash = 29 * hash + Objects.hashCode(name); -// hash = 29 * hash + Objects.hashCode(place); -// return hash; -// } -// -// @Override -// public boolean equals(final Object obj) { -// if (this == obj) { -// return true; -// } -// if (obj == null) { -// return false; -// } -// if (!super.equals(obj)) { -// return false; -// } -// if (!(obj instanceof PublisherAsset)) { -// return false; -// } -// final PublisherAsset other = (PublisherAsset) obj; -// if (!other.canEqual(this)) { -// return false; -// } -// if (!Objects.equals(name, other.getName())) { -// return false; -// } -// return Objects.equals(place, other.getPlace()); -// } -// -// @Override -// public boolean canEqual(final Object obj) { -// return obj instanceof PublisherAsset; -// } -// -// @Override -// public String toString(final String data) { -// return super.toString(String.format( -// ", name = \"%s\", " -// + "place = \"%s\"%s", -// name, -// place, -// data)); -// } + private static final long serialVersionUID = 1L; + + @OneToOne + @JoinColumn(name = "PUBLISHER_ID") + private Publisher publisher; + + public Publisher getPublisher() { + return publisher; + } + + protected void setPublisher(final Publisher publisher) { + this.publisher = publisher; + } + + @Override + public int hashCode() { + int hash = super.hashCode(); + hash = 97 * hash + Objects.hashCode(publisher); + return hash; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (!super.canEqual(this)) { + return false; + } + if (!(obj instanceof PublisherAsset)) { + return false; + } + final PublisherAsset other = (PublisherAsset) obj; + if (!other.canEqual(this)) { + return false; + } + return Objects.equals(this.publisher, other.getPublisher()); + } + + @Override + public boolean canEqual(final Object obj) { + return obj instanceof PublisherAsset; + } + + @Override + public String toString(final String data) { + return super.toString(String.format(", publisher = %s%s", + Objects.toString(publisher), + data)); + } }