PK e>Q=M
RELEASE-NOTESPlay Siena release notes:
From v2.0.3, we will try to keep tracks of modifications from now.
The github issues are not traced because
v2.0.3
----------------------------------------------------------
Third draft of v1.0.0 with bug fixes and code optimization
== BUG FIXES ==
* corrected bugs on EnhancedModel functions which were not
enhanced at all (findById, getByKey & batch)
== ENHANCEMENTS ==
* added tests for EnhancedModel enhanced functions
PK e>KHq q build.xml
PK e>T README.markdownSiena support for Play! Framework v2.0
======================================
The siena module automatically enables [Siena](http://www.sienaproject.com) support for your application for GAE/MySQL/PostgreSQL/H2 databases.
Release notes
--------------------
* v2.x brings support for :
+ GAE
+ MySQL
+ Postgresql
+ H2
* v2.x brings support for IDs of type Long (auto-generated or manual) and String (manual or auto-generated as UUID).
* v2.x brings a new class called __EnhancedModel__ which is a normal __siena.Model__ enhanced at runtime by Play to provide __all()__ function (and other functions also but it will be detailed later). Please see below for more details.
* v2.x is a complete refactoring of siena module based on Siena v1.x. Yet, for those who used Siena before, it doesn't change anything as Siena v1.0.0 is 100% backward compatible (at least in theory).
* v2.x is compatible with Play version >1.2.1 and uses dependency management.
> **Note** v1.x only supported GAE but this is not the case anymore. Other NoSQL Databases will be added later.
> **Note** play-siena v2.0.3 embeds siena v1.0.0-b5: don't worry about the beta5, the code is quite stable but there are lots of new features in this version and we need to evaluate them in real environments such as Play!
PK >*$) ) manifestversion=2.0.3
frameworkVersions=[1.2.1,)
PK e> : samples-and-tests/sienatest/app/models/ContainerModel.javapackage models;
import play.modules.siena.EnhancedModel;
import siena.Column;
import siena.Generator;
import siena.Id;
import siena.Table;
import siena.embed.Embedded;
import siena.embed.EmbeddedList;
@Table("container_models")
@EmbeddedList
public class ContainerModel extends EnhancedModel{
@Id(Generator.NONE)
public String id;
@Embedded
@Column("embed")
public EmbeddedModel embed;
public String toString() {
return id + " " + embed;
}
}
PK e>ܷ 9 samples-and-tests/sienatest/app/models/EmbeddedModel.javapackage models;
import play.modules.siena.EnhancedModel;
import siena.Generator;
import siena.Id;
import siena.Model;
import siena.Table;
import siena.embed.EmbeddedMap;
@Table("embedded_models")
@EmbeddedMap
public class EmbeddedModel extends EnhancedModel{
@Id(Generator.NONE)
public String id;
public String alpha;
public short beta;
public String toString() {
return id + " " + alpha + " " + beta;
}
}
PK e>] 8 samples-and-tests/sienatest/app/models/OtherIdModel.javapackage models;
import play.modules.siena.EnhancedModel;
import siena.Generator;
import siena.Id;
import siena.Table;
@Table("otherid_models")
public class OtherIdModel extends EnhancedModel{
@Id(Generator.AUTO_INCREMENT)
public Long myId;
public String alpha;
public short beta;
public String toString() {
return myId + " " + alpha + " " + beta;
}
}
PK e> Gnw w 5 samples-and-tests/sienatest/app/models/UUIDModel.javapackage models;
import play.modules.siena.EnhancedModel;
import siena.Generator;
import siena.Id;
import siena.Table;
@Table("uuid_models")
public class UUIDModel extends EnhancedModel{
@Id(Generator.UUID)
public String id;
public String alpha;
public short beta;
public String toString() {
return id + " " + alpha + " " + beta;
}
}
PK e>}l2 > samples-and-tests/sienatest/app/models/DiscoveryLifeCycle.javapackage models;
import siena.Generator;
import siena.Id;
import siena.Max;
import siena.Model;
import siena.Table;
import siena.core.lifecycle.PostDelete;
import siena.core.lifecycle.PostFetch;
import siena.core.lifecycle.PostInsert;
import siena.core.lifecycle.PostSave;
import siena.core.lifecycle.PostUpdate;
import siena.core.lifecycle.PreDelete;
import siena.core.lifecycle.PreFetch;
import siena.core.lifecycle.PreInsert;
import siena.core.lifecycle.PreSave;
import siena.core.lifecycle.PreUpdate;
@Table("discoveries_lifecycle")
public class DiscoveryLifeCycle extends Model {
@Id(Generator.AUTO_INCREMENT)
public Long id;
@Max(100)
public String name;
public DiscoveryLifeCycle(String name) {
this.name = name;
}
public DiscoveryLifeCycle() {
}
@PreFetch
private void preFetch() {
System.out.println("preFetch");
}
@PostFetch
private void postFetch() {
System.out.println("postFetch");
}
@PreInsert
private void preInsert() {
System.out.println("preInsert");
}
@PostInsert
private void postInsert() {
System.out.println("postInsert");
}
@PreDelete
private void preDelete() {
System.out.println("preDelete");
}
@PostDelete
private void postDelete() {
System.out.println("postDelete");
}
@PreUpdate
private void preUpdate() {
System.out.println("preUpdate");
}
@PostUpdate
private void postUpdate() {
System.out.println("postUpdate");
}
@PreSave
private void preSave() {
System.out.println("preSave");
}
@PostSave
private void postSave() {
System.out.println("postSave");
}
@Override
public boolean equals(Object obj) {
if (obj == null || getClass() != obj.getClass())
return false;
DiscoveryLifeCycle other = (DiscoveryLifeCycle) obj;
if(other.name != null && other.name.equals(name))
return true;
return false;
}
public boolean isOnlyIdFilled() {
if(this.id != null
&& this.name == null
) return true;
return false;
}
public String toString() {
return "Discovery [ id:"+id+" - name:"+name+" ]";
}
}
PK e>IhQ G samples-and-tests/sienatest/app/models/TransactionAccountFromModel.java/*
* Copyright 2011 Pascal
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package models;
import siena.Generator;
import siena.Id;
import siena.Model;
import siena.Query;
import siena.Table;
import siena.core.batch.Batch;
@Table("transaction_from")
public class TransactionAccountFromModel extends Model{
@Id(Generator.AUTO_INCREMENT)
public Long id;
public Long amount;
public TransactionAccountFromModel() {
}
public TransactionAccountFromModel(Long amount) {
this.amount = amount;
}
public Query all() {
return Model.all(TransactionAccountFromModel.class);
}
public Batch batch() {
return Model.batch(TransactionAccountFromModel.class);
}
public String toString() {
return "id: "+id+", amount: "+amount;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((amount == null) ? 0 : amount.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
TransactionAccountFromModel other = (TransactionAccountFromModel) obj;
if (amount == null) {
if (other.amount != null)
return false;
}
if(!amount.equals(other.amount))
return false;
return true;
}
public boolean isOnlyIdFilled() {
if(this.id != null
&& this.amount == null
) return true;
return false;
}
}
PK e>h = samples-and-tests/sienatest/app/models/ManualStringModel.javapackage models;
import play.modules.siena.EnhancedModel;
import siena.Generator;
import siena.Id;
import siena.Model;
import siena.Table;
@Table("manual_string_models")
public class ManualStringModel extends EnhancedModel{
@Id(Generator.NONE)
public String id;
public String alpha;
public short beta;
public String toString() {
return id + " " + alpha + " " + beta;
}
}
PK e>|#
4 samples-and-tests/sienatest/app/models/Employee.javapackage models;
import java.util.Date;
import java.util.List;
import java.util.Map;
import play.data.validation.Password;
import siena.Column;
import siena.DateTime;
import siena.Entity;
import siena.Filter;
import siena.Generator;
import siena.Id;
import siena.Index;
import siena.Json;
import siena.Max;
import siena.Model;
import siena.NotNull;
import siena.Query;
import siena.Table;
import siena.core.batch.Batch;
import siena.embed.At;
import siena.embed.Embedded;
import siena.embed.EmbeddedList;
import siena.embed.EmbeddedMap;
@Table("employees")
public class Employee extends Model {
@Id(Generator.AUTO_INCREMENT)
public Long id;
@Column("first_name")
@Max(10) @NotNull
//@play.data.validation.MaxSize(10) @play.data.validation.Required
public String firstName;
@Column("last_name")
@Max(200) @NotNull
public String lastName;
@Password
@Column("pwd")
public String pwd;
@Column("contact_info")
public Json contactInfo;
@Column("hire_date")
public Date hireDate;
@Column("fire_date")
@DateTime
public Date fireDate;
@Column("boss") @Index("boss_index")
public Employee boss;
@Filter("boss")
public siena.Query employees;
@Embedded
public Image profileImage;
@Embedded
public List otherImages;
@Embedded
public Map stillImages;
@EmbeddedMap
public class Image {
public String filename;
public String title;
public int views;
public MyEnum itemEnum;
}
@Embedded
public List items;
@EmbeddedList
public class UserBlabla {
@At(0) public String item;
@At(1) public String item2;
@At(2) public MyEnum itemEnum;
}
public MyEnum enumField;
public static enum MyEnum{
VAL1,
VAL2,
VAL3
};
public String toString() {
return firstName + " " + lastName;
}
public static Query all() {
return Model.all(Employee.class);
}
public static Batch batch() {
return Model.batch(Employee.class);
}
public Employee(Employee emp){
this.firstName = emp.firstName;
this.lastName = emp.lastName;
this.pwd = emp.pwd;
this.contactInfo = new Json(emp.contactInfo);
this.hireDate = emp.hireDate;
this.fireDate = emp.fireDate;
this.boss = emp.boss;
this.enumField = emp.enumField;
// ...
}
}PK e>pFZja a <