http://git-wip-us.apache.org/repos/asf/cayenne/blob/34646fd5/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Gallery.java ---------------------------------------------------------------------- diff --git a/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Gallery.java b/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Gallery.java new file mode 100644 index 0000000..bac8eb9 --- /dev/null +++ b/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Gallery.java @@ -0,0 +1,43 @@ +package org.apache.cayenne.tutorial.persistent.auto; + +import java.util.List; + +import org.apache.cayenne.CayenneDataObject; +import org.apache.cayenne.exp.Property; +import org.apache.cayenne.tutorial.persistent.Painting; + +/** + * Class _Gallery was generated by Cayenne. + * It is probably a good idea to avoid changing this class manually, + * since it may be overwritten next time code is regenerated. + * If you need to make any customizations, please use subclass. + */ +public abstract class _Gallery extends CayenneDataObject { + + private static final long serialVersionUID = 1L; + + public static final String ID_PK_COLUMN = "ID"; + + public static final Property<String> NAME = new Property<String>("name"); + public static final Property<List<Painting>> PAINTINGS = new Property<List<Painting>>("paintings"); + + public void setName(String name) { + writeProperty("name", name); + } + public String getName() { + return (String)readProperty("name"); + } + + public void addToPaintings(Painting obj) { + addToManyTarget("paintings", obj, true); + } + public void removeFromPaintings(Painting obj) { + removeToManyTarget("paintings", obj, true); + } + @SuppressWarnings("unchecked") + public List<Painting> getPaintings() { + return (List<Painting>)readProperty("paintings"); + } + + +}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/34646fd5/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Painting.java ---------------------------------------------------------------------- diff --git a/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Painting.java b/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Painting.java new file mode 100644 index 0000000..876ad07 --- /dev/null +++ b/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/auto/_Painting.java @@ -0,0 +1,49 @@ +package org.apache.cayenne.tutorial.persistent.auto; + +import org.apache.cayenne.CayenneDataObject; +import org.apache.cayenne.exp.Property; +import org.apache.cayenne.tutorial.persistent.Artist; +import org.apache.cayenne.tutorial.persistent.Gallery; + +/** + * Class _Painting was generated by Cayenne. + * It is probably a good idea to avoid changing this class manually, + * since it may be overwritten next time code is regenerated. + * If you need to make any customizations, please use subclass. + */ +public abstract class _Painting extends CayenneDataObject { + + private static final long serialVersionUID = 1L; + + public static final String ID_PK_COLUMN = "ID"; + + public static final Property<String> NAME = new Property<String>("name"); + public static final Property<Artist> ARTIST = new Property<Artist>("artist"); + public static final Property<Gallery> GALLERY = new Property<Gallery>("gallery"); + + public void setName(String name) { + writeProperty("name", name); + } + public String getName() { + return (String)readProperty("name"); + } + + public void setArtist(Artist artist) { + setToOneTarget("artist", artist, true); + } + + public Artist getArtist() { + return (Artist)readProperty("artist"); + } + + + public void setGallery(Gallery gallery) { + setToOneTarget("gallery", gallery, true); + } + + public Gallery getGallery() { + return (Gallery)readProperty("gallery"); + } + + +} http://git-wip-us.apache.org/repos/asf/cayenne/blob/34646fd5/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/client/Artist.java ---------------------------------------------------------------------- diff --git a/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/client/Artist.java b/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/client/Artist.java new file mode 100644 index 0000000..efe03bd --- /dev/null +++ b/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/client/Artist.java @@ -0,0 +1,12 @@ +package org.apache.cayenne.tutorial.persistent.client; + +import org.apache.cayenne.tutorial.persistent.client.auto._Artist; + +/** + * A persistent class mapped as "Artist" Cayenne entity. + */ +public class Artist extends _Artist { + + private static final long serialVersionUID = 1L; + +} http://git-wip-us.apache.org/repos/asf/cayenne/blob/34646fd5/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/client/Gallery.java ---------------------------------------------------------------------- diff --git a/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/client/Gallery.java b/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/client/Gallery.java new file mode 100644 index 0000000..54553d9 --- /dev/null +++ b/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/client/Gallery.java @@ -0,0 +1,12 @@ +package org.apache.cayenne.tutorial.persistent.client; + +import org.apache.cayenne.tutorial.persistent.client.auto._Gallery; + +/** + * A persistent class mapped as "Gallery" Cayenne entity. + */ +public class Gallery extends _Gallery { + + private static final long serialVersionUID = 1L; + +} http://git-wip-us.apache.org/repos/asf/cayenne/blob/34646fd5/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/client/Painting.java ---------------------------------------------------------------------- diff --git a/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/client/Painting.java b/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/client/Painting.java new file mode 100644 index 0000000..2084706 --- /dev/null +++ b/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/client/Painting.java @@ -0,0 +1,12 @@ +package org.apache.cayenne.tutorial.persistent.client; + +import org.apache.cayenne.tutorial.persistent.client.auto._Painting; + +/** + * A persistent class mapped as "Painting" Cayenne entity. + */ +public class Painting extends _Painting { + + private static final long serialVersionUID = 1L; + +} http://git-wip-us.apache.org/repos/asf/cayenne/blob/34646fd5/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/client/auto/_Artist.java ---------------------------------------------------------------------- diff --git a/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/client/auto/_Artist.java b/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/client/auto/_Artist.java new file mode 100644 index 0000000..d98d444 --- /dev/null +++ b/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/client/auto/_Artist.java @@ -0,0 +1,96 @@ +package org.apache.cayenne.tutorial.persistent.client.auto; + +import java.time.LocalDate; +import java.util.List; + +import org.apache.cayenne.PersistentObject; +import org.apache.cayenne.exp.Property; +import org.apache.cayenne.tutorial.persistent.client.Painting; +import org.apache.cayenne.util.PersistentObjectList; + +/** + * A generated persistent class mapped as "Artist" Cayenne entity. It is a good idea to + * avoid changing this class manually, since it will be overwritten next time code is + * regenerated. If you need to make any customizations, put them in a subclass. + */ +public abstract class _Artist extends PersistentObject { + + public static final Property<LocalDate> DATE_OF_BIRTH = new Property<LocalDate>("dateOfBirth"); + public static final Property<String> NAME = new Property<String>("name"); + public static final Property<List<Painting>> PAINTINGS = new Property<List<Painting>>("paintings"); + + protected LocalDate dateOfBirth; + protected String name; + protected List<Painting> paintings; + + public LocalDate getDateOfBirth() { + if(objectContext != null) { + objectContext.prepareForAccess(this, "dateOfBirth", false); + } + + return dateOfBirth; + } + public void setDateOfBirth(LocalDate dateOfBirth) { + if(objectContext != null) { + objectContext.prepareForAccess(this, "dateOfBirth", false); + } + + Object oldValue = this.dateOfBirth; + // notify objectContext about simple property change + if(objectContext != null) { + objectContext.propertyChanged(this, "dateOfBirth", oldValue, dateOfBirth); + } + + this.dateOfBirth = dateOfBirth; + } + + public String getName() { + if(objectContext != null) { + objectContext.prepareForAccess(this, "name", false); + } + + return name; + } + public void setName(String name) { + if(objectContext != null) { + objectContext.prepareForAccess(this, "name", false); + } + + Object oldValue = this.name; + // notify objectContext about simple property change + if(objectContext != null) { + objectContext.propertyChanged(this, "name", oldValue, name); + } + + this.name = name; + } + + public List<Painting> getPaintings() { + if(objectContext != null) { + objectContext.prepareForAccess(this, "paintings", true); + } else if (this.paintings == null) { + this.paintings = new PersistentObjectList(this, "paintings"); + } + + return paintings; + } + public void addToPaintings(Painting object) { + if(objectContext != null) { + objectContext.prepareForAccess(this, "paintings", true); + } else if (this.paintings == null) { + this.paintings = new PersistentObjectList(this, "paintings"); + } + + this.paintings.add(object); + } + public void removeFromPaintings(Painting object) { + if(objectContext != null) { + objectContext.prepareForAccess(this, "paintings", true); + } else if (this.paintings == null) { + this.paintings = new PersistentObjectList(this, "paintings"); + } + + this.paintings.remove(object); + } + +} http://git-wip-us.apache.org/repos/asf/cayenne/blob/34646fd5/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/client/auto/_Gallery.java ---------------------------------------------------------------------- diff --git a/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/client/auto/_Gallery.java b/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/client/auto/_Gallery.java new file mode 100644 index 0000000..6189902 --- /dev/null +++ b/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/client/auto/_Gallery.java @@ -0,0 +1,72 @@ +package org.apache.cayenne.tutorial.persistent.client.auto; + +import java.util.List; + +import org.apache.cayenne.PersistentObject; +import org.apache.cayenne.exp.Property; +import org.apache.cayenne.tutorial.persistent.client.Painting; +import org.apache.cayenne.util.PersistentObjectList; + +/** + * A generated persistent class mapped as "Gallery" Cayenne entity. It is a good idea to + * avoid changing this class manually, since it will be overwritten next time code is + * regenerated. If you need to make any customizations, put them in a subclass. + */ +public abstract class _Gallery extends PersistentObject { + + public static final Property<String> NAME = new Property<String>("name"); + public static final Property<List<Painting>> PAINTINGS = new Property<List<Painting>>("paintings"); + + protected String name; + protected List<Painting> paintings; + + public String getName() { + if(objectContext != null) { + objectContext.prepareForAccess(this, "name", false); + } + + return name; + } + public void setName(String name) { + if(objectContext != null) { + objectContext.prepareForAccess(this, "name", false); + } + + Object oldValue = this.name; + // notify objectContext about simple property change + if(objectContext != null) { + objectContext.propertyChanged(this, "name", oldValue, name); + } + + this.name = name; + } + + public List<Painting> getPaintings() { + if(objectContext != null) { + objectContext.prepareForAccess(this, "paintings", true); + } else if (this.paintings == null) { + this.paintings = new PersistentObjectList(this, "paintings"); + } + + return paintings; + } + public void addToPaintings(Painting object) { + if(objectContext != null) { + objectContext.prepareForAccess(this, "paintings", true); + } else if (this.paintings == null) { + this.paintings = new PersistentObjectList(this, "paintings"); + } + + this.paintings.add(object); + } + public void removeFromPaintings(Painting object) { + if(objectContext != null) { + objectContext.prepareForAccess(this, "paintings", true); + } else if (this.paintings == null) { + this.paintings = new PersistentObjectList(this, "paintings"); + } + + this.paintings.remove(object); + } + +} http://git-wip-us.apache.org/repos/asf/cayenne/blob/34646fd5/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/client/auto/_Painting.java ---------------------------------------------------------------------- diff --git a/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/client/auto/_Painting.java b/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/client/auto/_Painting.java new file mode 100644 index 0000000..23c14e2 --- /dev/null +++ b/tutorials/tutorial-rop-server-http2/src/main/java/org/apache/cayenne/tutorial/persistent/client/auto/_Painting.java @@ -0,0 +1,98 @@ +package org.apache.cayenne.tutorial.persistent.client.auto; + +import org.apache.cayenne.PersistentObject; +import org.apache.cayenne.ValueHolder; +import org.apache.cayenne.exp.Property; +import org.apache.cayenne.tutorial.persistent.client.Artist; +import org.apache.cayenne.tutorial.persistent.client.Gallery; +import org.apache.cayenne.util.PersistentObjectHolder; + +/** + * A generated persistent class mapped as "Painting" Cayenne entity. It is a good idea to + * avoid changing this class manually, since it will be overwritten next time code is + * regenerated. If you need to make any customizations, put them in a subclass. + */ +public abstract class _Painting extends PersistentObject { + + public static final Property<String> NAME = new Property<String>("name"); + public static final Property<Artist> ARTIST = new Property<Artist>("artist"); + public static final Property<Gallery> GALLERY = new Property<Gallery>("gallery"); + + protected String name; + protected ValueHolder artist; + protected ValueHolder gallery; + + public String getName() { + if(objectContext != null) { + objectContext.prepareForAccess(this, "name", false); + } + + return name; + } + public void setName(String name) { + if(objectContext != null) { + objectContext.prepareForAccess(this, "name", false); + } + + Object oldValue = this.name; + // notify objectContext about simple property change + if(objectContext != null) { + objectContext.propertyChanged(this, "name", oldValue, name); + } + + this.name = name; + } + + public Artist getArtist() { + if(objectContext != null) { + objectContext.prepareForAccess(this, "artist", true); + } else if (this.artist == null) { + this.artist = new PersistentObjectHolder(this, "artist"); + } + + return (Artist) artist.getValue(); + } + public void setArtist(Artist artist) { + if(objectContext != null) { + objectContext.prepareForAccess(this, "artist", true); + } else if (this.artist == null) { + this.artist = new PersistentObjectHolder(this, "artist"); + } + + // note how we notify ObjectContext of change BEFORE the object is actually + // changed... this is needed to take a valid current snapshot + Object oldValue = this.artist.getValueDirectly(); + if (objectContext != null) { + objectContext.propertyChanged(this, "artist", oldValue, artist); + } + + this.artist.setValue(artist); + } + + public Gallery getGallery() { + if(objectContext != null) { + objectContext.prepareForAccess(this, "gallery", true); + } else if (this.gallery == null) { + this.gallery = new PersistentObjectHolder(this, "gallery"); + } + + return (Gallery) gallery.getValue(); + } + public void setGallery(Gallery gallery) { + if(objectContext != null) { + objectContext.prepareForAccess(this, "gallery", true); + } else if (this.gallery == null) { + this.gallery = new PersistentObjectHolder(this, "gallery"); + } + + // note how we notify ObjectContext of change BEFORE the object is actually + // changed... this is needed to take a valid current snapshot + Object oldValue = this.gallery.getValueDirectly(); + if (objectContext != null) { + objectContext.propertyChanged(this, "gallery", oldValue, gallery); + } + + this.gallery.setValue(gallery); + } + +} http://git-wip-us.apache.org/repos/asf/cayenne/blob/34646fd5/tutorials/tutorial-rop-server-http2/src/main/resources/cayenne-project.xml ---------------------------------------------------------------------- diff --git a/tutorials/tutorial-rop-server-http2/src/main/resources/cayenne-project.xml b/tutorials/tutorial-rop-server-http2/src/main/resources/cayenne-project.xml new file mode 100644 index 0000000..05c2351 --- /dev/null +++ b/tutorials/tutorial-rop-server-http2/src/main/resources/cayenne-project.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="utf-8"?> +<domain project-version="8"> + <map name="datamap"/> + + <node name="datanode" + factory="org.apache.cayenne.configuration.server.XMLPoolingDataSourceFactory" + schema-update-strategy="org.apache.cayenne.access.dbsync.CreateIfNoSchemaStrategy" + > + <map-ref name="datamap"/> + <data-source> + <driver value="org.apache.derby.jdbc.EmbeddedDriver"/> + <url value="jdbc:derby:memory:testdb;create=true"/> + <connectionPool min="1" max="1"/> + <login/> + </data-source> + </node> +</domain> http://git-wip-us.apache.org/repos/asf/cayenne/blob/34646fd5/tutorials/tutorial-rop-server-http2/src/main/resources/datamap.map.xml ---------------------------------------------------------------------- diff --git a/tutorials/tutorial-rop-server-http2/src/main/resources/datamap.map.xml b/tutorials/tutorial-rop-server-http2/src/main/resources/datamap.map.xml new file mode 100644 index 0000000..c77fcf6 --- /dev/null +++ b/tutorials/tutorial-rop-server-http2/src/main/resources/datamap.map.xml @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="utf-8"?> +<data-map xmlns="http://cayenne.apache.org/schema/8/modelMap" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://cayenne.apache.org/schema/8/modelMap http://cayenne.apache.org/schema/8/modelMap.xsd" + project-version="8"> + <property name="defaultPackage" value="org.apache.cayenne.tutorial.persistent"/> + <property name="clientSupported" value="true"/> + <property name="defaultClientPackage" value="org.apache.cayenne.tutorial.persistent.client"/> + <db-entity name="ARTIST"> + <db-attribute name="DATE_OF_BIRTH" type="DATE"/> + <db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/> + <db-attribute name="NAME" type="VARCHAR" length="200"/> + </db-entity> + <db-entity name="GALLERY"> + <db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/> + <db-attribute name="NAME" type="VARCHAR" length="200"/> + </db-entity> + <db-entity name="PAINTING"> + <db-attribute name="ARTIST_ID" type="INTEGER"/> + <db-attribute name="GALLERY_ID" type="INTEGER"/> + <db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/> + <db-attribute name="NAME" type="VARCHAR" length="200"/> + </db-entity> + <obj-entity name="Artist" className="org.apache.cayenne.tutorial.persistent.Artist" clientClassName="org.apache.cayenne.tutorial.persistent.client.Artist" dbEntityName="ARTIST"> + <obj-attribute name="dateOfBirth" type="java.time.LocalDate" db-attribute-path="DATE_OF_BIRTH"/> + <obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/> + </obj-entity> + <obj-entity name="Gallery" className="org.apache.cayenne.tutorial.persistent.Gallery" clientClassName="org.apache.cayenne.tutorial.persistent.client.Gallery" dbEntityName="GALLERY"> + <obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/> + </obj-entity> + <obj-entity name="Painting" className="org.apache.cayenne.tutorial.persistent.Painting" clientClassName="org.apache.cayenne.tutorial.persistent.client.Painting" dbEntityName="PAINTING"> + <obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/> + </obj-entity> + <db-relationship name="paintings" source="ARTIST" target="PAINTING" toMany="true"> + <db-attribute-pair source="ID" target="ARTIST_ID"/> + </db-relationship> + <db-relationship name="paintings" source="GALLERY" target="PAINTING" toMany="true"> + <db-attribute-pair source="ID" target="GALLERY_ID"/> + </db-relationship> + <db-relationship name="artist" source="PAINTING" target="ARTIST" toMany="false"> + <db-attribute-pair source="ARTIST_ID" target="ID"/> + </db-relationship> + <db-relationship name="gallery" source="PAINTING" target="GALLERY" toMany="false"> + <db-attribute-pair source="GALLERY_ID" target="ID"/> + </db-relationship> + <obj-relationship name="paintings" source="Artist" target="Painting" deleteRule="Cascade" db-relationship-path="paintings"/> + <obj-relationship name="paintings" source="Gallery" target="Painting" deleteRule="Nullify" db-relationship-path="paintings"/> + <obj-relationship name="artist" source="Painting" target="Artist" deleteRule="Nullify" db-relationship-path="artist"/> + <obj-relationship name="gallery" source="Painting" target="Gallery" deleteRule="Nullify" db-relationship-path="gallery"/> +</data-map> http://git-wip-us.apache.org/repos/asf/cayenne/blob/34646fd5/tutorials/tutorial-rop-server-http2/src/main/resources/keystore ---------------------------------------------------------------------- diff --git a/tutorials/tutorial-rop-server-http2/src/main/resources/keystore b/tutorials/tutorial-rop-server-http2/src/main/resources/keystore new file mode 100644 index 0000000..d6592f9 Binary files /dev/null and b/tutorials/tutorial-rop-server-http2/src/main/resources/keystore differ http://git-wip-us.apache.org/repos/asf/cayenne/blob/34646fd5/tutorials/tutorial-rop-server/pom.xml ---------------------------------------------------------------------- diff --git a/tutorials/tutorial-rop-server/pom.xml b/tutorials/tutorial-rop-server/pom.xml index 96a6286..0bba067 100644 --- a/tutorials/tutorial-rop-server/pom.xml +++ b/tutorials/tutorial-rop-server/pom.xml @@ -32,6 +32,10 @@ <version>${project.version}</version> </dependency> <dependency> + <groupId>javax.servlet</groupId> + <artifactId>servlet-api</artifactId> + </dependency> + <dependency> <groupId>org.apache.derby</groupId> <artifactId>derby</artifactId> <scope>compile</scope>