mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#919 - io.ebean package initial
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
package org.tests.model.draftable;
|
||||
|
||||
import io.ebean.Model;
|
||||
import io.ebean.annotation.WhenCreated;
|
||||
import io.ebean.annotation.WhenModified;
|
||||
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
import javax.persistence.Version;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@MappedSuperclass
|
||||
public class BaseDomain extends Model {
|
||||
|
||||
@Id
|
||||
Long id;
|
||||
|
||||
@Version
|
||||
Long version;
|
||||
|
||||
@WhenCreated
|
||||
Timestamp whenCreated;
|
||||
|
||||
@WhenModified
|
||||
Timestamp whenModified;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(Long version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public Timestamp getWhenCreated() {
|
||||
return whenCreated;
|
||||
}
|
||||
|
||||
public void setWhenCreated(Timestamp whenCreated) {
|
||||
this.whenCreated = whenCreated;
|
||||
}
|
||||
|
||||
public Timestamp getWhenModified() {
|
||||
return whenModified;
|
||||
}
|
||||
|
||||
public void setWhenModified(Timestamp whenModified) {
|
||||
this.whenModified = whenModified;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package org.tests.model.draftable;
|
||||
|
||||
import io.ebean.annotation.Draftable;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.ManyToMany;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Draftable
|
||||
@Entity
|
||||
public class Doc extends BaseDomain {
|
||||
|
||||
String name;
|
||||
|
||||
@ManyToMany(cascade = CascadeType.ALL)
|
||||
List<Link> links;
|
||||
|
||||
public Doc(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<Link> getLinks() {
|
||||
return links;
|
||||
}
|
||||
|
||||
public void setLinks(List<Link> links) {
|
||||
this.links = links;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package org.tests.model.draftable;
|
||||
|
||||
import io.ebean.annotation.DraftOnly;
|
||||
import io.ebean.annotation.Draftable;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Draftable
|
||||
@Entity
|
||||
public class Document extends BaseDomain {
|
||||
|
||||
@Column(unique = true)
|
||||
String title;
|
||||
|
||||
String body;
|
||||
|
||||
@DraftOnly
|
||||
Timestamp whenPublish;
|
||||
|
||||
@ManyToOne
|
||||
Organisation organisation;
|
||||
|
||||
/**
|
||||
* Relationship to draftable elements.
|
||||
*/
|
||||
//@PrivateOwned
|
||||
@OneToMany(mappedBy = "document")//, cascade = CascadeType.ALL)
|
||||
List<DocumentMedia> media;
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getBody() {
|
||||
return body;
|
||||
}
|
||||
|
||||
public void setBody(String body) {
|
||||
this.body = body;
|
||||
}
|
||||
|
||||
public Organisation getOrganisation() {
|
||||
return organisation;
|
||||
}
|
||||
|
||||
public void setOrganisation(Organisation organisation) {
|
||||
this.organisation = organisation;
|
||||
}
|
||||
|
||||
public List<DocumentMedia> getMedia() {
|
||||
return media;
|
||||
}
|
||||
|
||||
public void setMedia(List<DocumentMedia> media) {
|
||||
this.media = media;
|
||||
}
|
||||
|
||||
public Timestamp getWhenPublish() {
|
||||
return whenPublish;
|
||||
}
|
||||
|
||||
public void setWhenPublish(Timestamp whenPublish) {
|
||||
this.whenPublish = whenPublish;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package org.tests.model.draftable;
|
||||
|
||||
import io.ebean.annotation.DraftableElement;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.ManyToOne;
|
||||
|
||||
/**
|
||||
* 'Owned' by @Draftable root.
|
||||
*/
|
||||
@DraftableElement
|
||||
@Entity
|
||||
public class DocumentMedia extends BaseDomain {
|
||||
|
||||
@ManyToOne
|
||||
Document document;
|
||||
|
||||
String name;
|
||||
|
||||
String description;
|
||||
|
||||
public Document getDocument() {
|
||||
return document;
|
||||
}
|
||||
|
||||
public void setDocument(Document document) {
|
||||
this.document = document;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
package org.tests.model.draftable;
|
||||
|
||||
import io.ebean.annotation.Draft;
|
||||
import io.ebean.annotation.DraftDirty;
|
||||
import io.ebean.annotation.DraftReset;
|
||||
import io.ebean.annotation.Draftable;
|
||||
import io.ebean.annotation.History;
|
||||
import io.ebean.annotation.SoftDelete;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.ManyToMany;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@History
|
||||
@Draftable
|
||||
@Entity
|
||||
public class Link extends BaseDomain {
|
||||
|
||||
@SoftDelete
|
||||
boolean deleted;
|
||||
|
||||
String name;
|
||||
|
||||
String location;
|
||||
|
||||
/**
|
||||
* Draft reset to null on publish.
|
||||
*/
|
||||
@DraftReset
|
||||
Timestamp whenPublish;
|
||||
|
||||
/**
|
||||
* Draft reset to null on publish.
|
||||
*/
|
||||
@DraftReset
|
||||
@Column(name = "link_comment")
|
||||
String comment;
|
||||
|
||||
/**
|
||||
* Indicates if the instance is a 'draft' or 'live' bean.
|
||||
*/
|
||||
@Draft
|
||||
boolean draft;
|
||||
|
||||
/**
|
||||
* Indicates if the draft has modifications that have not been published
|
||||
* to 'live'. This is automatically set when a draft is saved.
|
||||
*/
|
||||
@DraftDirty
|
||||
boolean dirty;
|
||||
|
||||
@ManyToMany(mappedBy = "links")
|
||||
List<Doc> docs;
|
||||
|
||||
public Link(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Link() {
|
||||
}
|
||||
|
||||
public boolean isDraft() {
|
||||
return draft;
|
||||
}
|
||||
|
||||
public void setDraft(boolean draft) {
|
||||
this.draft = draft;
|
||||
}
|
||||
|
||||
public boolean isDeleted() {
|
||||
return deleted;
|
||||
}
|
||||
|
||||
public void setDeleted(boolean deleted) {
|
||||
this.deleted = deleted;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(String location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public List<Doc> getDocs() {
|
||||
return docs;
|
||||
}
|
||||
|
||||
public void setDocs(List<Doc> docs) {
|
||||
this.docs = docs;
|
||||
}
|
||||
|
||||
public boolean isDirty() {
|
||||
return dirty;
|
||||
}
|
||||
|
||||
public void setDirty(boolean dirty) {
|
||||
this.dirty = dirty;
|
||||
}
|
||||
|
||||
public Timestamp getWhenPublish() {
|
||||
return whenPublish;
|
||||
}
|
||||
|
||||
public void setWhenPublish(Timestamp whenPublish) {
|
||||
this.whenPublish = whenPublish;
|
||||
}
|
||||
|
||||
public String getComment() {
|
||||
return comment;
|
||||
}
|
||||
|
||||
public void setComment(String comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package org.tests.model.draftable;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
@Entity
|
||||
public class Organisation extends BaseDomain {
|
||||
|
||||
String name;
|
||||
|
||||
public Organisation(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user