ObjectIdResolvers for Export and Import part I
parent
8dfc9b1c00
commit
376dbb5249
|
|
@ -5,6 +5,9 @@
|
||||||
*/
|
*/
|
||||||
package org.scientificcms.publications;
|
package org.scientificcms.publications;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIdentityReference;
|
||||||
|
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||||
import org.hibernate.envers.Audited;
|
import org.hibernate.envers.Audited;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
@ -24,12 +27,18 @@ import static org.scientificcms.publications.SciPublicationsConstants.*;
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "ARTICLES_IN_COLLECTED_VOLUME", schema = DB_SCHEMA)
|
@Table(name = "ARTICLES_IN_COLLECTED_VOLUME", schema = DB_SCHEMA)
|
||||||
@Audited
|
@Audited
|
||||||
|
@JsonIdentityInfo(
|
||||||
|
generator = ObjectIdGenerators.PropertyGenerator.class,
|
||||||
|
resolver = ArticleInCollectedVolumeIdResolver.class,
|
||||||
|
property = "uuid"
|
||||||
|
)
|
||||||
public class ArticleInCollectedVolume extends Publication {
|
public class ArticleInCollectedVolume extends Publication {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "COLLECTED_VOLUME_ID")
|
@JoinColumn(name = "COLLECTED_VOLUME_ID")
|
||||||
|
@JsonIdentityReference(alwaysAsId = true)
|
||||||
private CollectedVolume collectedVolume;
|
private CollectedVolume collectedVolume;
|
||||||
|
|
||||||
@Column(name = "START_PAGE")
|
@Column(name = "START_PAGE")
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,62 @@
|
||||||
|
package org.scientificcms.publications;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
|
||||||
|
import com.fasterxml.jackson.annotation.ObjectIdResolver;
|
||||||
|
import org.libreccm.cdi.utils.CdiUtil;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import javax.enterprise.context.RequestScoped;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
@RequestScoped
|
||||||
|
public class ArticleInCollectedVolumeIdResolver
|
||||||
|
implements Serializable, ObjectIdResolver{
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void bindItem(
|
||||||
|
final ObjectIdGenerator.IdKey idKey,
|
||||||
|
final Object object
|
||||||
|
) {
|
||||||
|
// According to the Jackson JavaDoc, this method can be used to keep
|
||||||
|
// track of objects directly in a resolver implementation. We don't need
|
||||||
|
// this here therefore this method is empty.
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object resolveId(final ObjectIdGenerator.IdKey id) {
|
||||||
|
return CdiUtil
|
||||||
|
.createCdiUtil()
|
||||||
|
.findBean(PublicationRepository.class)
|
||||||
|
.findByUuidAndType(
|
||||||
|
id.key.toString(),
|
||||||
|
ArticleInCollectedVolume.class
|
||||||
|
)
|
||||||
|
.orElseThrow(
|
||||||
|
() -> new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
"No ArticleInCollectedVolume with UUID %s in the "
|
||||||
|
+ "database.",
|
||||||
|
id.key.toString()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ObjectIdResolver newForDeserialization(final Object context) {
|
||||||
|
return new ArticleInCollectedVolumeIdResolver();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canUseFor(final ObjectIdResolver resolverType) {
|
||||||
|
return resolverType instanceof ArticleInCollectedVolumeIdResolver;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -5,6 +5,9 @@
|
||||||
*/
|
*/
|
||||||
package org.scientificcms.publications;
|
package org.scientificcms.publications;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIdentityReference;
|
||||||
|
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||||
import org.hibernate.envers.Audited;
|
import org.hibernate.envers.Audited;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
|
@ -25,12 +28,18 @@ import static org.scientificcms.publications.SciPublicationsConstants.*;
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "ARTICLES_IN_JOURNAL", schema = DB_SCHEMA)
|
@Table(name = "ARTICLES_IN_JOURNAL", schema = DB_SCHEMA)
|
||||||
@Audited
|
@Audited
|
||||||
|
@JsonIdentityInfo(
|
||||||
|
generator = ObjectIdGenerators.PropertyGenerator.class,
|
||||||
|
resolver = ArticleInCollectedVolumeIdResolver.class,
|
||||||
|
property = "uuid"
|
||||||
|
)
|
||||||
public class ArticleInJournal extends Publication {
|
public class ArticleInJournal extends Publication {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "JOURNAL_ID")
|
@JoinColumn(name = "JOURNAL_ID")
|
||||||
|
@JsonIdentityReference(alwaysAsId = true)
|
||||||
private Journal journal;
|
private Journal journal;
|
||||||
|
|
||||||
@Column(name = "VOLUME")
|
@Column(name = "VOLUME")
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,58 @@
|
||||||
|
package org.scientificcms.publications;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
|
||||||
|
import com.fasterxml.jackson.annotation.ObjectIdResolver;
|
||||||
|
import org.libreccm.cdi.utils.CdiUtil;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import javax.enterprise.context.RequestScoped;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
@RequestScoped
|
||||||
|
public class ArticleInJournalIdResolver
|
||||||
|
implements Serializable, ObjectIdResolver {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void bindItem(
|
||||||
|
final ObjectIdGenerator.IdKey idKey,
|
||||||
|
final Object object
|
||||||
|
) {
|
||||||
|
// According to the Jackson JavaDoc, this method can be used to keep
|
||||||
|
// track of objects directly in a resolver implementation. We don't need
|
||||||
|
// this here therefore this method is empty.
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object resolveId(final ObjectIdGenerator.IdKey id) {
|
||||||
|
return CdiUtil
|
||||||
|
.createCdiUtil()
|
||||||
|
.findBean(PublicationRepository.class)
|
||||||
|
.findByUuidAndType(id.key.toString(), ArticleInJournal.class)
|
||||||
|
.orElseThrow(
|
||||||
|
() -> new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
"No ArticleInJournal with UUID %s found in the "
|
||||||
|
+ "database.",
|
||||||
|
id.key.toString()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ObjectIdResolver newForDeserialization(final Object context) {
|
||||||
|
return new ArticleInJournalIdResolver();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canUseFor(final ObjectIdResolver resolverType) {
|
||||||
|
return resolverType instanceof ArticleInJournalIdResolver;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -5,6 +5,9 @@
|
||||||
*/
|
*/
|
||||||
package org.scientificcms.publications;
|
package org.scientificcms.publications;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIdentityReference;
|
||||||
|
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||||
import org.hibernate.envers.Audited;
|
import org.hibernate.envers.Audited;
|
||||||
import org.librecms.assets.Person;
|
import org.librecms.assets.Person;
|
||||||
|
|
||||||
|
|
@ -29,6 +32,10 @@ import static org.scientificcms.publications.SciPublicationsConstants.*;
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "AUTHORSHIPS", schema = DB_SCHEMA)
|
@Table(name = "AUTHORSHIPS", schema = DB_SCHEMA)
|
||||||
@Audited
|
@Audited
|
||||||
|
@JsonIdentityInfo(
|
||||||
|
generator = ObjectIdGenerators.PropertyGenerator.class,
|
||||||
|
property = "uuid"
|
||||||
|
)
|
||||||
public class Authorship implements Serializable, Comparable<Authorship> {
|
public class Authorship implements Serializable, Comparable<Authorship> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
@ -43,10 +50,12 @@ public class Authorship implements Serializable, Comparable<Authorship> {
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "PUBLICATION_ID")
|
@JoinColumn(name = "PUBLICATION_ID")
|
||||||
|
@JsonIdentityReference(alwaysAsId = true)
|
||||||
private Publication publication;
|
private Publication publication;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "AUTHOR_ID")
|
@JoinColumn(name = "AUTHOR_ID")
|
||||||
|
@JsonIdentityReference(alwaysAsId = true)
|
||||||
private Person author;
|
private Person author;
|
||||||
|
|
||||||
@Column(name = "EDITOR")
|
@Column(name = "EDITOR")
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,9 @@
|
||||||
*/
|
*/
|
||||||
package org.scientificcms.publications;
|
package org.scientificcms.publications;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||||
import org.hibernate.envers.Audited;
|
import org.hibernate.envers.Audited;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
@ -25,12 +28,18 @@ import static org.scientificcms.publications.SciPublicationsConstants.*;
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "COLLECTED_VOLUMES", schema = DB_SCHEMA)
|
@Table(name = "COLLECTED_VOLUMES", schema = DB_SCHEMA)
|
||||||
@Audited
|
@Audited
|
||||||
|
@JsonIdentityInfo(
|
||||||
|
generator = ObjectIdGenerators.PropertyGenerator.class,
|
||||||
|
resolver = CollectedVolumeIdResolver.class,
|
||||||
|
property = "uuid"
|
||||||
|
)
|
||||||
public class CollectedVolume extends PublicationWithPublisher {
|
public class CollectedVolume extends PublicationWithPublisher {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@OneToMany(mappedBy = "collectedVolume")
|
@OneToMany(mappedBy = "collectedVolume")
|
||||||
@OrderBy("chapter")
|
@OrderBy("chapter")
|
||||||
|
@JsonIgnore
|
||||||
private List<ArticleInCollectedVolume> articles;
|
private List<ArticleInCollectedVolume> articles;
|
||||||
|
|
||||||
public CollectedVolume() {
|
public CollectedVolume() {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,55 @@
|
||||||
|
package org.scientificcms.publications;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
|
||||||
|
import com.fasterxml.jackson.annotation.ObjectIdResolver;
|
||||||
|
import org.libreccm.cdi.utils.CdiUtil;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public class CollectedVolumeIdResolver
|
||||||
|
implements Serializable, ObjectIdResolver{
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void bindItem(
|
||||||
|
final ObjectIdGenerator.IdKey idKey,
|
||||||
|
final Object object
|
||||||
|
) {
|
||||||
|
// According to the Jackson JavaDoc, this method can be used to keep
|
||||||
|
// track of objects directly in a resolver implementation. We don't need
|
||||||
|
// this here therefore this method is empty.
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object resolveId(final ObjectIdGenerator.IdKey id) {
|
||||||
|
return CdiUtil
|
||||||
|
.createCdiUtil()
|
||||||
|
.findBean(PublicationRepository.class)
|
||||||
|
.findByUuidAndType(id.key.toString(), CollectedVolume.class)
|
||||||
|
.orElseThrow(
|
||||||
|
() -> new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
"No CollectedVolume with UUID found in the database.",
|
||||||
|
id.key.toString()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ObjectIdResolver newForDeserialization(final Object context) {
|
||||||
|
return new CollectedVolumeIdResolver();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canUseFor(final ObjectIdResolver resolverType) {
|
||||||
|
return resolverType instanceof CollectedVolumeIdResolver;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
package org.scientificcms.publications;
|
package org.scientificcms.publications;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIdentityReference;
|
||||||
|
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||||
import org.hibernate.envers.Audited;
|
import org.hibernate.envers.Audited;
|
||||||
import org.librecms.assets.Organization;
|
import org.librecms.assets.Organization;
|
||||||
|
|
||||||
|
|
@ -20,6 +23,11 @@ import static org.scientificcms.publications.SciPublicationsConstants.*;
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "EXPERTISES", schema = DB_SCHEMA)
|
@Table(name = "EXPERTISES", schema = DB_SCHEMA)
|
||||||
@Audited
|
@Audited
|
||||||
|
@JsonIdentityInfo(
|
||||||
|
generator = ObjectIdGenerators.PropertyGenerator.class,
|
||||||
|
resolver = ExpertiseIdResolver.class,
|
||||||
|
property = "uuid"
|
||||||
|
)
|
||||||
public class Expertise extends Publication {
|
public class Expertise extends Publication {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
@ -32,10 +40,12 @@ public class Expertise extends Publication {
|
||||||
|
|
||||||
@OneToOne
|
@OneToOne
|
||||||
@JoinColumn(name = "ORGANIZATION_ID")
|
@JoinColumn(name = "ORGANIZATION_ID")
|
||||||
|
@JsonIdentityReference(alwaysAsId = true)
|
||||||
private Organization organization;
|
private Organization organization;
|
||||||
|
|
||||||
@OneToOne
|
@OneToOne
|
||||||
@JoinColumn(name = "ORDERER_ID")
|
@JoinColumn(name = "ORDERER_ID")
|
||||||
|
@JsonIdentityReference(alwaysAsId = true)
|
||||||
private Organization orderer;
|
private Organization orderer;
|
||||||
|
|
||||||
public String getPlace() {
|
public String getPlace() {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,53 @@
|
||||||
|
package org.scientificcms.publications;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
|
||||||
|
import com.fasterxml.jackson.annotation.ObjectIdResolver;
|
||||||
|
import org.libreccm.cdi.utils.CdiUtil;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public class ExpertiseIdResolver implements Serializable, ObjectIdResolver {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void bindItem(
|
||||||
|
final ObjectIdGenerator.IdKey idKey,
|
||||||
|
final Object object
|
||||||
|
) {
|
||||||
|
// According to the Jackson JavaDoc, this method can be used to keep
|
||||||
|
// track of objects directly in a resolver implementation. We don't need
|
||||||
|
// this here therefore this method is empty.
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object resolveId(final ObjectIdGenerator.IdKey id) {
|
||||||
|
return CdiUtil
|
||||||
|
.createCdiUtil()
|
||||||
|
.findBean(PublicationRepository.class)
|
||||||
|
.findByUuidAndType(id.key.toString(), Expertise.class)
|
||||||
|
.orElseThrow(
|
||||||
|
() -> new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
"No Expertise with UUID %s found in the database.",
|
||||||
|
id.key.toString()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ObjectIdResolver newForDeserialization(final Object context) {
|
||||||
|
return new ExpertiseIdResolver();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canUseFor(final ObjectIdResolver resolverType) {
|
||||||
|
return resolverType instanceof ExpertiseIdResolver;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -5,6 +5,9 @@
|
||||||
*/
|
*/
|
||||||
package org.scientificcms.publications;
|
package org.scientificcms.publications;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||||
import org.hibernate.envers.Audited;
|
import org.hibernate.envers.Audited;
|
||||||
import org.libreccm.l10n.LocalizedString;
|
import org.libreccm.l10n.LocalizedString;
|
||||||
|
|
||||||
|
|
@ -48,6 +51,11 @@ import static org.scientificcms.publications.SciPublicationsConstants.*;
|
||||||
+ "WHERE LOWER(j.title) LIKE CONCAT('%', :title, '%')"
|
+ "WHERE LOWER(j.title) LIKE CONCAT('%', :title, '%')"
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
@JsonIdentityInfo(
|
||||||
|
generator = ObjectIdGenerators.PropertyGenerator.class,
|
||||||
|
resolver = JournalIdResolver.class,
|
||||||
|
property = "uuid"
|
||||||
|
)
|
||||||
public class Journal implements Serializable {
|
public class Journal implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
@ -102,6 +110,7 @@ public class Journal implements Serializable {
|
||||||
private String symbol;
|
private String symbol;
|
||||||
|
|
||||||
@OneToMany(mappedBy = "journal")
|
@OneToMany(mappedBy = "journal")
|
||||||
|
@JsonIgnore
|
||||||
private List<ArticleInJournal> articles;
|
private List<ArticleInJournal> articles;
|
||||||
|
|
||||||
public Journal() {
|
public Journal() {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,53 @@
|
||||||
|
package org.scientificcms.publications;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
|
||||||
|
import com.fasterxml.jackson.annotation.ObjectIdResolver;
|
||||||
|
import org.libreccm.cdi.utils.CdiUtil;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public class JournalIdResolver implements Serializable, ObjectIdResolver {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void bindItem(
|
||||||
|
final ObjectIdGenerator.IdKey idKey,
|
||||||
|
final Object object
|
||||||
|
) {
|
||||||
|
// According to the Jackson JavaDoc, this method can be used to keep
|
||||||
|
// track of objects directly in a resolver implementation. We don't need
|
||||||
|
// this here therefore this method is empty.
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object resolveId(final ObjectIdGenerator.IdKey id) {
|
||||||
|
return CdiUtil
|
||||||
|
.createCdiUtil()
|
||||||
|
.findBean(JournalRepository.class)
|
||||||
|
.findByUuid(id.key.toString())
|
||||||
|
.orElseThrow(
|
||||||
|
() -> new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
"No Journa with UUID %s found in the database.",
|
||||||
|
id.key.toString()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ObjectIdResolver newForDeserialization(final Object context) {
|
||||||
|
return new JournalIdResolver();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canUseFor(final ObjectIdResolver resolverType) {
|
||||||
|
return resolverType instanceof JournalIdResolver;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -5,6 +5,9 @@
|
||||||
*/
|
*/
|
||||||
package org.scientificcms.publications;
|
package org.scientificcms.publications;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||||
import org.hibernate.annotations.NamedQueries;
|
import org.hibernate.annotations.NamedQueries;
|
||||||
import org.hibernate.annotations.NamedQuery;
|
import org.hibernate.annotations.NamedQuery;
|
||||||
import org.hibernate.envers.Audited;
|
import org.hibernate.envers.Audited;
|
||||||
|
|
@ -93,6 +96,11 @@ import static org.scientificcms.publications.SciPublicationsConstants.*;
|
||||||
+ "AND TYPE(p) = :type"
|
+ "AND TYPE(p) = :type"
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
@JsonIdentityInfo(
|
||||||
|
generator = ObjectIdGenerators.PropertyGenerator.class,
|
||||||
|
resolver = PublicationIdResolver.class,
|
||||||
|
property = "uuid"
|
||||||
|
)
|
||||||
public class Publication implements Serializable {
|
public class Publication implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
@ -115,6 +123,7 @@ public class Publication implements Serializable {
|
||||||
orphanRemoval = true
|
orphanRemoval = true
|
||||||
)
|
)
|
||||||
@OrderBy("authorOrder")
|
@OrderBy("authorOrder")
|
||||||
|
@JsonIgnore
|
||||||
private List<Authorship> authorships;
|
private List<Authorship> authorships;
|
||||||
|
|
||||||
@Embedded
|
@Embedded
|
||||||
|
|
@ -179,6 +188,7 @@ public class Publication implements Serializable {
|
||||||
private Locale languageOfPublication;
|
private Locale languageOfPublication;
|
||||||
|
|
||||||
@OneToMany(mappedBy = "publication")
|
@OneToMany(mappedBy = "publication")
|
||||||
|
@JsonIgnore
|
||||||
private List<VolumeInSeries> series;
|
private List<VolumeInSeries> series;
|
||||||
|
|
||||||
public Publication() {
|
public Publication() {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,58 @@
|
||||||
|
package org.scientificcms.publications;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
|
||||||
|
import com.fasterxml.jackson.annotation.ObjectIdResolver;
|
||||||
|
import org.libreccm.cdi.utils.CdiUtil;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import javax.enterprise.context.RequestScoped;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
@RequestScoped
|
||||||
|
public class PublicationIdResolver implements Serializable, ObjectIdResolver {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void bindItem(
|
||||||
|
final ObjectIdGenerator.IdKey idKey,
|
||||||
|
final Object object
|
||||||
|
) {
|
||||||
|
// According to the Jackson JavaDoc, this method can be used to keep
|
||||||
|
// track of objects directly in a resolver implementation. We don't need
|
||||||
|
// this here therefore this method is empty.
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object resolveId(final ObjectIdGenerator.IdKey id) {
|
||||||
|
return CdiUtil
|
||||||
|
.createCdiUtil()
|
||||||
|
.findBean(PublicationRepository.class)
|
||||||
|
.findByUuid(id.key.toString())
|
||||||
|
.orElseThrow(
|
||||||
|
() -> new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
"No Publiation with UUID %s found in database.",
|
||||||
|
id.key.toString()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ObjectIdResolver newForDeserialization(final Object context) {
|
||||||
|
return new PublicationIdResolver();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canUseFor(final ObjectIdResolver resolverType) {
|
||||||
|
return resolverType instanceof PublicationIdResolver;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -5,6 +5,11 @@
|
||||||
*/
|
*/
|
||||||
package org.scientificcms.publications;
|
package org.scientificcms.publications;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIdentityReference;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
|
||||||
|
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||||
import org.hibernate.envers.Audited;
|
import org.hibernate.envers.Audited;
|
||||||
import org.libreccm.l10n.LocalizedString;
|
import org.libreccm.l10n.LocalizedString;
|
||||||
|
|
||||||
|
|
@ -53,11 +58,17 @@ import static org.scientificcms.publications.SciPublicationsConstants.*;
|
||||||
+ "WHERE p.isbn13 = :isbn"
|
+ "WHERE p.isbn13 = :isbn"
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
@JsonIdentityInfo(
|
||||||
|
generator = ObjectIdGenerators.PropertyGenerator.class,
|
||||||
|
resolver = PublicationWithPublisherIdResolver.class,
|
||||||
|
property = "uuid"
|
||||||
|
)
|
||||||
public class PublicationWithPublisher extends Publication {
|
public class PublicationWithPublisher extends Publication {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
|
@JsonIdentityReference(alwaysAsId = true)
|
||||||
private Publisher publisher;
|
private Publisher publisher;
|
||||||
|
|
||||||
@Column(name = "ISBN10", length = 13)
|
@Column(name = "ISBN10", length = 13)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
package org.scientificcms.publications;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
|
||||||
|
import com.fasterxml.jackson.annotation.ObjectIdResolver;
|
||||||
|
import org.libreccm.cdi.utils.CdiUtil;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import javax.enterprise.context.RequestScoped;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
@RequestScoped
|
||||||
|
public class PublicationWithPublisherIdResolver
|
||||||
|
implements Serializable, ObjectIdResolver {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void bindItem(
|
||||||
|
final ObjectIdGenerator.IdKey idKey,
|
||||||
|
final Object object
|
||||||
|
) {
|
||||||
|
// According to the Jackson JavaDoc, this method can be used to keep
|
||||||
|
// track of objects directly in a resolver implementation. We don't need
|
||||||
|
// this here therefore this method is empty.
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object resolveId(final ObjectIdGenerator.IdKey id) {
|
||||||
|
return CdiUtil
|
||||||
|
.createCdiUtil()
|
||||||
|
.findBean(PublicationRepository.class)
|
||||||
|
.findByUuidAndType(
|
||||||
|
id.key.toString(),
|
||||||
|
PublicationWithPublisher.class
|
||||||
|
)
|
||||||
|
.orElseThrow(
|
||||||
|
() -> new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
"No PublicationWithPublisher with UUID %s found in "
|
||||||
|
+ "database.",
|
||||||
|
id.key.toString()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ObjectIdResolver newForDeserialization(final Object context) {
|
||||||
|
return new PublicationWithPublisherIdResolver();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canUseFor(final ObjectIdResolver resolverType) {
|
||||||
|
return resolverType instanceof PublicationWithPublisherIdResolver;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -5,6 +5,9 @@
|
||||||
*/
|
*/
|
||||||
package org.scientificcms.publications;
|
package org.scientificcms.publications;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||||
import org.hibernate.envers.Audited;
|
import org.hibernate.envers.Audited;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
@ -43,6 +46,11 @@ import static org.scientificcms.publications.SciPublicationsConstants.*;
|
||||||
+ "WHERE p.name LIKE CONCAT('%', :name, '%')"
|
+ "WHERE p.name LIKE CONCAT('%', :name, '%')"
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
@JsonIdentityInfo(
|
||||||
|
generator = ObjectIdGenerators.PropertyGenerator.class,
|
||||||
|
resolver = PublisherIdResolver.class,
|
||||||
|
property = "uuid"
|
||||||
|
)
|
||||||
public class Publisher implements Serializable {
|
public class Publisher implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
@ -70,6 +78,7 @@ public class Publisher implements Serializable {
|
||||||
private String place;
|
private String place;
|
||||||
|
|
||||||
@OneToMany(mappedBy = "publisher")
|
@OneToMany(mappedBy = "publisher")
|
||||||
|
@JsonIgnore
|
||||||
private List<PublicationWithPublisher> publications;
|
private List<PublicationWithPublisher> publications;
|
||||||
|
|
||||||
public Publisher() {
|
public Publisher() {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,56 @@
|
||||||
|
package org.scientificcms.publications;
|
||||||
|
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
|
||||||
|
import com.fasterxml.jackson.annotation.ObjectIdResolver;
|
||||||
|
import org.libreccm.cdi.utils.CdiUtil;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public class PublisherIdResolver implements Serializable, ObjectIdResolver {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void bindItem(
|
||||||
|
final ObjectIdGenerator.IdKey idKey,
|
||||||
|
final Object object
|
||||||
|
) {
|
||||||
|
// According to the Jackson JavaDoc, this method can be used to keep
|
||||||
|
// track of objects directly in a resolver implementation. We don't need
|
||||||
|
// this here therefore this method is empty.
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object resolveId(final ObjectIdGenerator.IdKey id) {
|
||||||
|
return CdiUtil
|
||||||
|
.createCdiUtil()
|
||||||
|
.findBean(PublisherRepository.class)
|
||||||
|
.findByUuid(id.key.toString())
|
||||||
|
.orElseThrow(
|
||||||
|
() -> new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
"No Pubisher with UUID %s found in the database.",
|
||||||
|
id.key.toString()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ObjectIdResolver newForDeserialization(final Object context) {
|
||||||
|
return new PublicationIdResolver();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canUseFor(final ObjectIdResolver resolverType) {
|
||||||
|
return resolverType instanceof PublicationIdResolver;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
package org.scientificcms.publications;
|
package org.scientificcms.publications;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||||
import org.hibernate.envers.Audited;
|
import org.hibernate.envers.Audited;
|
||||||
import org.libreccm.l10n.LocalizedString;
|
import org.libreccm.l10n.LocalizedString;
|
||||||
|
|
||||||
|
|
@ -42,6 +45,11 @@ import static org.scientificcms.publications.SciPublicationsConstants.*;
|
||||||
query = "SELECT DISTINCT s FROM Series s JOIN s.title.values t WHERE lower(t) LIKE CONCAT ('%', :title, '%')"
|
query = "SELECT DISTINCT s FROM Series s JOIN s.title.values t WHERE lower(t) LIKE CONCAT ('%', :title, '%')"
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
@JsonIdentityInfo(
|
||||||
|
generator = ObjectIdGenerators.PropertyGenerator.class,
|
||||||
|
resolver = SeriesIdResolver.class,
|
||||||
|
property = "uuid"
|
||||||
|
)
|
||||||
public class Series implements Serializable {
|
public class Series implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
@ -81,6 +89,7 @@ public class Series implements Serializable {
|
||||||
private LocalizedString description;
|
private LocalizedString description;
|
||||||
|
|
||||||
@OneToMany(mappedBy = "series")
|
@OneToMany(mappedBy = "series")
|
||||||
|
@JsonIgnore
|
||||||
private List<VolumeInSeries> volumes;
|
private List<VolumeInSeries> volumes;
|
||||||
|
|
||||||
public Series() {
|
public Series() {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,53 @@
|
||||||
|
package org.scientificcms.publications;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
|
||||||
|
import com.fasterxml.jackson.annotation.ObjectIdResolver;
|
||||||
|
import org.libreccm.cdi.utils.CdiUtil;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public class SeriesIdResolver implements Serializable, ObjectIdResolver {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void bindItem(
|
||||||
|
final ObjectIdGenerator.IdKey idKey,
|
||||||
|
final Object object
|
||||||
|
) {
|
||||||
|
// According to the Jackson JavaDoc, this method can be used to keep
|
||||||
|
// track of objects directly in a resolver implementation. We don't need
|
||||||
|
// this here therefore this method is empty.
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object resolveId(final ObjectIdGenerator.IdKey id) {
|
||||||
|
return CdiUtil
|
||||||
|
.createCdiUtil()
|
||||||
|
.findBean(SeriesRepository.class)
|
||||||
|
.findByUuid(id.key.toString())
|
||||||
|
.orElseThrow(
|
||||||
|
() -> new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
"No Series with UUID %s found in the database.",
|
||||||
|
id.key.toString()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ObjectIdResolver newForDeserialization(final Object context) {
|
||||||
|
return new SeriesIdResolver();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canUseFor(final ObjectIdResolver resolverType) {
|
||||||
|
return resolverType instanceof SeriesIdResolver;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -5,6 +5,9 @@
|
||||||
*/
|
*/
|
||||||
package org.scientificcms.publications;
|
package org.scientificcms.publications;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIdentityReference;
|
||||||
|
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||||
import org.hibernate.envers.Audited;
|
import org.hibernate.envers.Audited;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
@ -28,6 +31,10 @@ import static org.scientificcms.publications.SciPublicationsConstants.*;
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "VOLUMES_IN_SERIES", schema = DB_SCHEMA)
|
@Table(name = "VOLUMES_IN_SERIES", schema = DB_SCHEMA)
|
||||||
@Audited
|
@Audited
|
||||||
|
@JsonIdentityInfo(
|
||||||
|
generator = ObjectIdGenerators.PropertyGenerator.class,
|
||||||
|
property = "uuid"
|
||||||
|
)
|
||||||
public class VolumeInSeries implements Serializable {
|
public class VolumeInSeries implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
@ -45,10 +52,12 @@ public class VolumeInSeries implements Serializable {
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "PUBLICATION_ID")
|
@JoinColumn(name = "PUBLICATION_ID")
|
||||||
|
@JsonIdentityReference(alwaysAsId = true)
|
||||||
private Publication publication;
|
private Publication publication;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "SERIES_ID")
|
@JoinColumn(name = "SERIES_ID")
|
||||||
|
@JsonIdentityReference(alwaysAsId = true)
|
||||||
private Series series;
|
private Series series;
|
||||||
|
|
||||||
public long getVolumeId() {
|
public long getVolumeId() {
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,9 @@
|
||||||
*/
|
*/
|
||||||
package org.scientificcms.contenttypes.sciproject;
|
package org.scientificcms.contenttypes.sciproject;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIdentityReference;
|
||||||
|
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||||
import org.hibernate.envers.Audited;
|
import org.hibernate.envers.Audited;
|
||||||
import org.libreccm.core.CcmObjects;
|
import org.libreccm.core.CcmObjects;
|
||||||
import org.librecms.assets.ContactableEntity;
|
import org.librecms.assets.ContactableEntity;
|
||||||
|
|
@ -30,6 +33,10 @@ import static org.scientificcms.contenttypes.sciproject.SciProjectConstants.*;
|
||||||
@Entity
|
@Entity
|
||||||
@Audited
|
@Audited
|
||||||
@Table(name = "PROJECT_CONTACTS", schema = DB_SCHEMA)
|
@Table(name = "PROJECT_CONTACTS", schema = DB_SCHEMA)
|
||||||
|
@JsonIdentityInfo(
|
||||||
|
generator = ObjectIdGenerators.PropertyGenerator.class,
|
||||||
|
property = "uuid"
|
||||||
|
)
|
||||||
public class Contact implements Serializable {
|
public class Contact implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
@ -47,10 +54,12 @@ public class Contact implements Serializable {
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "PROJECT_ID")
|
@JoinColumn(name = "PROJECT_ID")
|
||||||
|
@JsonIdentityReference(alwaysAsId = true)
|
||||||
private SciProject project;
|
private SciProject project;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "CONTACTABLE_ID")
|
@JoinColumn(name = "CONTACTABLE_ID")
|
||||||
|
@JsonIdentityReference(alwaysAsId = true)
|
||||||
private ContactableEntity contactable;
|
private ContactableEntity contactable;
|
||||||
|
|
||||||
public long getContactId() {
|
public long getContactId() {
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,9 @@
|
||||||
*/
|
*/
|
||||||
package org.scientificcms.contenttypes.sciproject;
|
package org.scientificcms.contenttypes.sciproject;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIdentityReference;
|
||||||
|
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||||
import org.hibernate.envers.Audited;
|
import org.hibernate.envers.Audited;
|
||||||
import org.libreccm.core.CcmObjects;
|
import org.libreccm.core.CcmObjects;
|
||||||
import org.librecms.assets.Person;
|
import org.librecms.assets.Person;
|
||||||
|
|
@ -32,6 +35,10 @@ import static org.scientificcms.contenttypes.sciproject.SciProjectConstants.*;
|
||||||
@Entity
|
@Entity
|
||||||
@Audited
|
@Audited
|
||||||
@Table(name = "PROJECT_MEMBERSHIPS", schema = DB_SCHEMA)
|
@Table(name = "PROJECT_MEMBERSHIPS", schema = DB_SCHEMA)
|
||||||
|
@JsonIdentityInfo(
|
||||||
|
generator = ObjectIdGenerators.PropertyGenerator.class,
|
||||||
|
property = "uuid"
|
||||||
|
)
|
||||||
public class Membership implements Serializable {
|
public class Membership implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
@ -50,10 +57,12 @@ public class Membership implements Serializable {
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "PROJECT_ID")
|
@JoinColumn(name = "PROJECT_ID")
|
||||||
|
@JsonIdentityReference(alwaysAsId = true)
|
||||||
private SciProject project;
|
private SciProject project;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "MEMBER_ID")
|
@JoinColumn(name = "MEMBER_ID")
|
||||||
|
@JsonIdentityReference(alwaysAsId = true)
|
||||||
private Person member;
|
private Person member;
|
||||||
|
|
||||||
public long getMembershipId() {
|
public long getMembershipId() {
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,11 @@
|
||||||
*/
|
*/
|
||||||
package org.scientificcms.contenttypes.sciproject;
|
package org.scientificcms.contenttypes.sciproject;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
|
||||||
|
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
|
||||||
import org.hibernate.envers.Audited;
|
import org.hibernate.envers.Audited;
|
||||||
|
|
@ -88,6 +93,11 @@ import static org.scientificcms.contenttypes.sciproject.SciProjectConstants.*;
|
||||||
+ "WHERE m.member = :member"
|
+ "WHERE m.member = :member"
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
@JsonIdentityInfo(
|
||||||
|
generator = ObjectIdGenerators.PropertyGenerator.class,
|
||||||
|
resolver = SciProjectIdResolver.class,
|
||||||
|
property = "uuid"
|
||||||
|
)
|
||||||
public class SciProject extends ContentItem implements Serializable {
|
public class SciProject extends ContentItem implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
@ -142,17 +152,20 @@ public class SciProject extends ContentItem implements Serializable {
|
||||||
)
|
)
|
||||||
private LocalizedString fundingVolume;
|
private LocalizedString fundingVolume;
|
||||||
|
|
||||||
|
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "project")
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "project")
|
||||||
@OrderBy("order ASC")
|
@OrderBy("order ASC")
|
||||||
|
@JsonIgnore
|
||||||
private List<Contact> contacts;
|
private List<Contact> contacts;
|
||||||
|
|
||||||
@OneToMany(mappedBy = "project", cascade = CascadeType.ALL)
|
@OneToMany(mappedBy = "project", cascade = CascadeType.ALL)
|
||||||
// @OrderBy("member.personName ASC")
|
|
||||||
@OrderBy("member ASC")
|
@OrderBy("member ASC")
|
||||||
|
@JsonIgnore
|
||||||
private List<Membership> members;
|
private List<Membership> members;
|
||||||
|
|
||||||
@OneToMany(mappedBy = "project", cascade = CascadeType.ALL)
|
@OneToMany(mappedBy = "project", cascade = CascadeType.ALL)
|
||||||
@OrderBy("order ASC")
|
@OrderBy("order ASC")
|
||||||
|
@JsonIgnore
|
||||||
private List<Sponsoring> sponsoring;
|
private List<Sponsoring> sponsoring;
|
||||||
|
|
||||||
public SciProject() {
|
public SciProject() {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
package org.scientificcms.contenttypes.sciproject;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
|
||||||
|
import com.fasterxml.jackson.annotation.ObjectIdResolver;
|
||||||
|
import org.libreccm.cdi.utils.CdiUtil;
|
||||||
|
import org.librecms.contentsection.ContentItemRepository;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import javax.enterprise.context.RequestScoped;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
@RequestScoped
|
||||||
|
public class SciProjectIdResolver implements Serializable, ObjectIdResolver {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void bindItem(
|
||||||
|
final ObjectIdGenerator.IdKey idKey,
|
||||||
|
final Object object
|
||||||
|
) {
|
||||||
|
// According to the Jackson JavaDoc, this method can be used to keep
|
||||||
|
// track of objects directly in a resolver implementation. We don't need
|
||||||
|
// this here therefore this method is empty.
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object resolveId(final ObjectIdGenerator.IdKey id) {
|
||||||
|
return CdiUtil
|
||||||
|
.createCdiUtil()
|
||||||
|
.findBean(ContentItemRepository.class)
|
||||||
|
.findByUuid(id.key.toString(), SciProject.class)
|
||||||
|
.orElseThrow(
|
||||||
|
() -> new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
"No SciProject with UUID %s found in the datbase.",
|
||||||
|
id.key.toString()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ObjectIdResolver newForDeserialization(final Object context) {
|
||||||
|
return new SciProjectIdResolver();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canUseFor(final ObjectIdResolver resolverType) {
|
||||||
|
return resolverType instanceof SciProjectIdResolver;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -5,6 +5,9 @@
|
||||||
*/
|
*/
|
||||||
package org.scientificcms.contenttypes.sciproject;
|
package org.scientificcms.contenttypes.sciproject;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIdentityReference;
|
||||||
|
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||||
import org.hibernate.envers.Audited;
|
import org.hibernate.envers.Audited;
|
||||||
import org.libreccm.core.CcmObjects;
|
import org.libreccm.core.CcmObjects;
|
||||||
import org.librecms.assets.Organization;
|
import org.librecms.assets.Organization;
|
||||||
|
|
@ -30,6 +33,10 @@ import static org.scientificcms.contenttypes.sciproject.SciProjectConstants.*;
|
||||||
@Entity
|
@Entity
|
||||||
@Audited
|
@Audited
|
||||||
@Table(name = "SPONSORING", schema = DB_SCHEMA)
|
@Table(name = "SPONSORING", schema = DB_SCHEMA)
|
||||||
|
@JsonIdentityInfo(
|
||||||
|
generator = ObjectIdGenerators.PropertyGenerator.class,
|
||||||
|
property = "uuid"
|
||||||
|
)
|
||||||
public class Sponsoring implements Serializable {
|
public class Sponsoring implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
@ -47,10 +54,12 @@ public class Sponsoring implements Serializable {
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "PROJECT_ID")
|
@JoinColumn(name = "PROJECT_ID")
|
||||||
|
@JsonIdentityReference(alwaysAsId = true)
|
||||||
private SciProject project;
|
private SciProject project;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "SPONSOR_ID")
|
@JoinColumn(name = "SPONSOR_ID")
|
||||||
|
@JsonIdentityReference(alwaysAsId = true)
|
||||||
private Organization sponsor;
|
private Organization sponsor;
|
||||||
|
|
||||||
public long getSponsoringId() {
|
public long getSponsoringId() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue