ObjectIdResolvers for Import and Export for SciPublications part II
parent
376dbb5249
commit
e7ba0e4822
|
|
@ -1,5 +1,7 @@
|
||||||
package org.scientificcms.publications;
|
package org.scientificcms.publications;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||||
|
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||||
import org.hibernate.envers.Audited;
|
import org.hibernate.envers.Audited;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
|
|
@ -15,6 +17,11 @@ import static org.scientificcms.publications.SciPublicationsConstants.*;
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "GREY_LITERATURE", schema = DB_SCHEMA)
|
@Table(name = "GREY_LITERATURE", schema = DB_SCHEMA)
|
||||||
@Audited
|
@Audited
|
||||||
|
@JsonIdentityInfo(
|
||||||
|
generator = ObjectIdGenerators.PropertyGenerator.class,
|
||||||
|
resolver = GreyLiteratureIdResolver.class,
|
||||||
|
property = "uuid"
|
||||||
|
)
|
||||||
public class GreyLiterature extends UnPublished {
|
public class GreyLiterature extends UnPublished {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
|
||||||
|
|
@ -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 GreyLiteratureIdResolver
|
||||||
|
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(), GreyLiterature.class)
|
||||||
|
.orElseThrow(
|
||||||
|
() -> new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
"No GreyLiterature publication with UUID %s found in "
|
||||||
|
+ "the database.",
|
||||||
|
id.key.toString()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ObjectIdResolver newForDeserialization(Object context) {
|
||||||
|
return new GreyLiteratureIdResolver();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canUseFor(final ObjectIdResolver resolverType) {
|
||||||
|
return resolverType instanceof GreyLiteratureIdResolver;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -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 java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
@ -19,12 +22,18 @@ import static org.scientificcms.publications.SciPublicationsConstants.*;
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "IN_PROCEEDINGS", schema = DB_SCHEMA)
|
@Table(name = "IN_PROCEEDINGS", schema = DB_SCHEMA)
|
||||||
@Audited
|
@Audited
|
||||||
|
@JsonIdentityInfo(
|
||||||
|
generator = ObjectIdGenerators.PropertyGenerator.class,
|
||||||
|
resolver = InProceedingsIdResolver.class,
|
||||||
|
property = "uuid"
|
||||||
|
)
|
||||||
public class InProceedings extends Publication {
|
public class InProceedings extends Publication {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
@JoinColumn(name = "PROCEEDINGS_ID")
|
@JoinColumn(name = "PROCEEDINGS_ID")
|
||||||
|
@JsonIdentityReference(alwaysAsId = true)
|
||||||
private Proceedings proceedings;
|
private Proceedings proceedings;
|
||||||
|
|
||||||
private int startPage;
|
private int startPage;
|
||||||
|
|
|
||||||
|
|
@ -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 InProceedingsIdResolver
|
||||||
|
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(), InProceedings.class)
|
||||||
|
.orElseThrow(
|
||||||
|
() -> new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
"No InProceedings publication with UUID %s found in "
|
||||||
|
+ "the database.",
|
||||||
|
id.key.toString()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ObjectIdResolver newForDeserialization(final Object context) {
|
||||||
|
return new InProceedingsIdResolver();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canUseFor(final ObjectIdResolver resolverType) {
|
||||||
|
return resolverType instanceof InProceedingsIdResolver;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -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;
|
||||||
|
|
||||||
|
|
@ -21,6 +24,11 @@ import static org.scientificcms.publications.SciPublicationsConstants.*;
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "INTERNET_ARTICLES", schema = DB_SCHEMA)
|
@Table(name = "INTERNET_ARTICLES", schema = DB_SCHEMA)
|
||||||
@Audited
|
@Audited
|
||||||
|
@JsonIdentityInfo(
|
||||||
|
generator = ObjectIdGenerators.PropertyGenerator.class,
|
||||||
|
resolver = InternetArticleIdResolver.class,
|
||||||
|
property = "uuid"
|
||||||
|
)
|
||||||
public class InternetArticle extends Publication {
|
public class InternetArticle extends Publication {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
@ -57,6 +65,7 @@ public class InternetArticle extends Publication {
|
||||||
|
|
||||||
@OneToOne
|
@OneToOne
|
||||||
@JoinColumn(name = "ORGANIZATION_ID")
|
@JoinColumn(name = "ORGANIZATION_ID")
|
||||||
|
@JsonIdentityReference(alwaysAsId = true)
|
||||||
private Organization organization;
|
private Organization organization;
|
||||||
|
|
||||||
public String getPlace() {
|
public String getPlace() {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
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 InternetArticleIdResolver
|
||||||
|
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(), InternetArticle.class)
|
||||||
|
.orElseThrow(
|
||||||
|
() -> new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
"No InternetArticle with UUID %s found in the database.",
|
||||||
|
id.key.toString()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ObjectIdResolver newForDeserialization(final Object context) {
|
||||||
|
return new InternetArticleIdResolver();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canUseFor(final ObjectIdResolver resolverType) {
|
||||||
|
return resolverType instanceof InternetArticleIdResolver;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,10 +1,7 @@
|
||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
package org.scientificcms.publications;
|
package org.scientificcms.publications;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||||
|
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||||
import org.hibernate.envers.Audited;
|
import org.hibernate.envers.Audited;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
@ -22,6 +19,11 @@ import static org.scientificcms.publications.SciPublicationsConstants.*;
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "MONOGRAPHS", schema = DB_SCHEMA)
|
@Table(name = "MONOGRAPHS", schema = DB_SCHEMA)
|
||||||
@Audited
|
@Audited
|
||||||
|
@JsonIdentityInfo(
|
||||||
|
generator = ObjectIdGenerators.PropertyGenerator.class,
|
||||||
|
resolver = MonographIdResolver.class,
|
||||||
|
property = "uuid"
|
||||||
|
)
|
||||||
public class Monograph extends PublicationWithPublisher {
|
public class Monograph extends PublicationWithPublisher {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
||||||
|
import javax.enterprise.context.RequestScoped;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
@RequestScoped
|
||||||
|
public class MonographIdResolver 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(), Monograph.class)
|
||||||
|
.orElseThrow(
|
||||||
|
() -> new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
"No Monograph with UUID %s found in the database.",
|
||||||
|
id.key.toString()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ObjectIdResolver newForDeserialization(final Object context) {
|
||||||
|
return new MonographIdResolver();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canUseFor(final ObjectIdResolver resolverType) {
|
||||||
|
return resolverType instanceof MonographIdResolver;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -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.librecms.assets.Organization;
|
import org.librecms.assets.Organization;
|
||||||
|
|
||||||
|
|
@ -26,6 +29,11 @@ import static org.scientificcms.publications.SciPublicationsConstants.*;
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "PROCEEDINGS", schema = DB_SCHEMA)
|
@Table(name = "PROCEEDINGS", schema = DB_SCHEMA)
|
||||||
@Audited
|
@Audited
|
||||||
|
@JsonIdentityInfo(
|
||||||
|
generator = ObjectIdGenerators.PropertyGenerator.class,
|
||||||
|
resolver = ProceedingsIdResolver.class,
|
||||||
|
property = "uuid"
|
||||||
|
)
|
||||||
public class Proceedings extends PublicationWithPublisher {
|
public class Proceedings extends PublicationWithPublisher {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
@ -47,6 +55,7 @@ public class Proceedings extends PublicationWithPublisher {
|
||||||
private Organization organizer;
|
private Organization organizer;
|
||||||
|
|
||||||
@OneToMany(fetch = FetchType.LAZY, mappedBy = "proceedings")
|
@OneToMany(fetch = FetchType.LAZY, mappedBy = "proceedings")
|
||||||
|
@JsonIgnore
|
||||||
private List<InProceedings> papers;
|
private List<InProceedings> papers;
|
||||||
|
|
||||||
public Proceedings() {
|
public Proceedings() {
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
||||||
|
import javax.enterprise.context.RequestScoped;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
@RequestScoped
|
||||||
|
public class ProceedingsIdResolver 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(), Proceedings.class)
|
||||||
|
.orElseThrow(
|
||||||
|
() -> new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
"No Proceedings with UUID %s found in the database.",
|
||||||
|
id.key.toString()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ObjectIdResolver newForDeserialization(final Object context) {
|
||||||
|
return new ProceedingsIdResolver();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canUseFor(final ObjectIdResolver resolverType) {
|
||||||
|
return resolverType instanceof ProceedingsIdResolver;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,10 +1,7 @@
|
||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
package org.scientificcms.publications;
|
package org.scientificcms.publications;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||||
|
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||||
import org.hibernate.envers.Audited;
|
import org.hibernate.envers.Audited;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
|
@ -23,6 +20,11 @@ import static org.scientificcms.publications.SciPublicationsConstants.*;
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "TALKS", schema = DB_SCHEMA)
|
@Table(name = "TALKS", schema = DB_SCHEMA)
|
||||||
@Audited
|
@Audited
|
||||||
|
@JsonIdentityInfo(
|
||||||
|
generator = ObjectIdGenerators.PropertyGenerator.class,
|
||||||
|
resolver = TalkIdResolver.class,
|
||||||
|
property = "uuid"
|
||||||
|
)
|
||||||
public class Talk extends Publication {
|
public class Talk extends Publication {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
|
||||||
|
|
@ -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 org.libreccm.workflow.TaskIdResolver;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import javax.enterprise.context.RequestScoped;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
@RequestScoped
|
||||||
|
public class TalkIdResolver 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(), Talk.class)
|
||||||
|
.orElseThrow(
|
||||||
|
() -> new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
"No Talk with UUID %s found in the database.",
|
||||||
|
id.key.toString()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ObjectIdResolver newForDeserialization(final Object context) {
|
||||||
|
return new TalkIdResolver();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canUseFor(final ObjectIdResolver resolverType) {
|
||||||
|
return resolverType instanceof TaskIdResolver;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -5,6 +5,8 @@
|
||||||
*/
|
*/
|
||||||
package org.scientificcms.publications;
|
package org.scientificcms.publications;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||||
|
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;
|
||||||
|
|
||||||
|
|
@ -25,6 +27,11 @@ import static org.scientificcms.publications.SciPublicationsConstants.*;
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "UNPUBLISHED", schema = DB_SCHEMA)
|
@Table(name = "UNPUBLISHED", schema = DB_SCHEMA)
|
||||||
@Audited
|
@Audited
|
||||||
|
@JsonIdentityInfo(
|
||||||
|
generator = ObjectIdGenerators.PropertyGenerator.class,
|
||||||
|
resolver = UnPublishedIdResolver.class,
|
||||||
|
property = "uuid"
|
||||||
|
)
|
||||||
public class UnPublished extends Publication {
|
public class UnPublished extends Publication {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
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 UnPublishedIdResolver 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(), UnPublished.class)
|
||||||
|
.orElseThrow(
|
||||||
|
() -> new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
"No UnPublished publication with UUID %s found in the "
|
||||||
|
+ "database",
|
||||||
|
id.key.toString()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ObjectIdResolver newForDeserialization(final Object context) {
|
||||||
|
return new UnPublishedIdResolver();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canUseFor(final ObjectIdResolver resolverType) {
|
||||||
|
return resolverType instanceof UnPublishedIdResolver;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -5,6 +5,8 @@
|
||||||
*/
|
*/
|
||||||
package org.scientificcms.publications;
|
package org.scientificcms.publications;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||||
|
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||||
import org.hibernate.envers.Audited;
|
import org.hibernate.envers.Audited;
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
|
@ -19,6 +21,11 @@ import static org.scientificcms.publications.SciPublicationsConstants.*;
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "WORKING_PAPERS", schema = DB_SCHEMA)
|
@Table(name = "WORKING_PAPERS", schema = DB_SCHEMA)
|
||||||
@Audited
|
@Audited
|
||||||
|
@JsonIdentityInfo(
|
||||||
|
generator = ObjectIdGenerators.PropertyGenerator.class,
|
||||||
|
resolver = WorkingPaperIdResolver.class,
|
||||||
|
property = "uuid"
|
||||||
|
)
|
||||||
public class WorkingPaper extends UnPublished {
|
public class WorkingPaper extends UnPublished {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
||||||
|
import javax.enterprise.context.RequestScoped;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
@RequestScoped
|
||||||
|
public class WorkingPaperIdResolver 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(), WorkingPaper.class)
|
||||||
|
.orElseThrow(
|
||||||
|
() -> new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
"No WorkingPaper with UUID %s found in the database.",
|
||||||
|
id.key.toString()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ObjectIdResolver newForDeserialization(final Object context) {
|
||||||
|
return new WorkingPaperIdResolver();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canUseFor(final ObjectIdResolver resolverType) {
|
||||||
|
return resolverType instanceof WorkingPaperIdResolver;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue