|
| 1 | +package org.incode.extended.integtests.examples.alias.demo.dom.demo; |
| 2 | + |
| 3 | +import javax.jdo.annotations.IdGeneratorStrategy; |
| 4 | +import javax.jdo.annotations.IdentityType; |
| 5 | +import javax.jdo.annotations.VersionStrategy; |
| 6 | +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; |
| 7 | + |
| 8 | +import com.google.common.collect.Ordering; |
| 9 | + |
| 10 | +import org.apache.isis.applib.annotation.BookmarkPolicy; |
| 11 | +import org.apache.isis.applib.annotation.DomainObject; |
| 12 | +import org.apache.isis.applib.annotation.DomainObjectLayout; |
| 13 | +import org.apache.isis.applib.annotation.Editing; |
| 14 | +import org.apache.isis.applib.annotation.Title; |
| 15 | +import org.apache.isis.applib.util.ObjectContracts; |
| 16 | +import org.apache.isis.schema.utils.jaxbadapters.PersistentEntityAdapter; |
| 17 | + |
| 18 | +import lombok.AllArgsConstructor; |
| 19 | +import lombok.Builder; |
| 20 | +import lombok.Getter; |
| 21 | +import lombok.Setter; |
| 22 | + |
| 23 | +@javax.jdo.annotations.PersistenceCapable( |
| 24 | + identityType=IdentityType.DATASTORE, |
| 25 | + schema="exampleDemoAlias" |
| 26 | +) |
| 27 | +@javax.jdo.annotations.DatastoreIdentity(strategy= IdGeneratorStrategy.IDENTITY, column = "id") |
| 28 | +@javax.jdo.annotations.Version(strategy=VersionStrategy.VERSION_NUMBER, column = "version") |
| 29 | +@javax.jdo.annotations.Queries({ |
| 30 | + @javax.jdo.annotations.Query( |
| 31 | + name = "findByName", language = "JDOQL", |
| 32 | + value = "SELECT " |
| 33 | + + "FROM org.incode.extended.integtests.examples.alias.demo.dom.demo.DemoObject " |
| 34 | + + "WHERE name.indexOf(:name) >= 0 ") |
| 35 | +}) |
| 36 | + |
| 37 | +@DomainObject(editing = Editing.DISABLED ) |
| 38 | +@DomainObjectLayout(bookmarking = BookmarkPolicy.AS_ROOT ) |
| 39 | +@AllArgsConstructor |
| 40 | +@Builder |
| 41 | +@XmlJavaTypeAdapter(PersistentEntityAdapter.class) |
| 42 | +public class DemoObject implements Comparable<DemoObject> { |
| 43 | + |
| 44 | + |
| 45 | + @javax.jdo.annotations.Column(allowsNull="false") |
| 46 | + @Title(sequence="1") |
| 47 | + @Getter @Setter |
| 48 | + private String name; |
| 49 | + |
| 50 | + |
| 51 | + @Override |
| 52 | + public String toString() { |
| 53 | + return ObjectContracts.toString(this, "name"); |
| 54 | + } |
| 55 | + |
| 56 | + @Override |
| 57 | + public int compareTo(final DemoObject other) { |
| 58 | + return Ordering.natural().onResultOf(DemoObject::getName).compare(this, other); |
| 59 | + } |
| 60 | + |
| 61 | + |
| 62 | + // required by DemoObjectData#findUsing |
| 63 | + @Override |
| 64 | + public boolean equals(final Object o) { |
| 65 | + return ObjectContracts.equals(this,o, "name"); |
| 66 | + } |
| 67 | + |
| 68 | + @Override |
| 69 | + public int hashCode() { |
| 70 | + return ObjectContracts.hashCode(this, "name"); |
| 71 | + } |
| 72 | +} |
0 commit comments