mirror of
https://github.com/querydsl/querydsl.git
synced 2026-06-30 21:08:30 +08:00
moved JoinExpression and JoinType out of QueryBase
moved Order and OrderSpecifier out of Types
This commit is contained in:
parent
b8c2e3c914
commit
cab707f0e3
@ -75,6 +75,7 @@
|
||||
<version>1.0.15</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>dummy-domain</id>
|
||||
<phase>generate-test-sources</phase>
|
||||
<goals>
|
||||
<goal>testExecute</goal>
|
||||
@ -90,16 +91,38 @@
|
||||
<nocompile>true</nocompile>
|
||||
<A>
|
||||
-Ainclude=src/test/includes/instances.txt,
|
||||
-AdestClass=com.mysema.query.grammar.hql.domain.Domain,
|
||||
-AdestClass=com.mysema.query.Domain1,
|
||||
-AnamePrefix=
|
||||
</A>
|
||||
<includes>
|
||||
<include>
|
||||
com/mysema/query/grammar/hql/domain/*.java
|
||||
</include>
|
||||
</includes>
|
||||
<testIncludes>
|
||||
<testInclude>com/mysema/query/grammar/hql/domain/*.java</testInclude>
|
||||
</testIncludes>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>thinglink-domain</id>
|
||||
<phase>generate-test-sources</phase>
|
||||
<goals>
|
||||
<goal>testExecute</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<aptSourceRoots>
|
||||
<aptSourceRoot>src/test/java</aptSourceRoot>
|
||||
</aptSourceRoots>
|
||||
<force>true</force>
|
||||
<fork>true</fork>
|
||||
<factory>com.mysema.query.apt.APTFactory</factory>
|
||||
<testGenerated>target/generated-test-sources/java</testGenerated>
|
||||
<nocompile>true</nocompile>
|
||||
<A>
|
||||
-AdestClass=com.mysema.query.Domain2,
|
||||
-AnamePrefix=
|
||||
</A>
|
||||
<testIncludes>
|
||||
<testInclude>com/mysema/query/grammar/hql/domain2/*.java</testInclude>
|
||||
</testIncludes>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
@ -9,7 +9,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.mysema.query.QueryBase.JoinExpression;
|
||||
import com.mysema.query.JoinExpression;
|
||||
import com.mysema.query.grammar.HqlGrammar.Constructor;
|
||||
import com.mysema.query.grammar.HqlGrammar.CountExpr;
|
||||
import com.mysema.query.grammar.Types.*;
|
||||
@ -75,7 +75,7 @@ public class HqlSerializer extends VisitorAdapter<HqlSerializer>{
|
||||
}
|
||||
// type specifier
|
||||
if (je.target instanceof PathEntity && !je.target.toString().contains(".")){
|
||||
_append(((PathEntity<?>)je.target)._type().getSimpleName())._append(" ");
|
||||
_append(((PathEntity<?>)je.target).getType().getSimpleName())._append(" ");
|
||||
}
|
||||
handle(je.target);
|
||||
if (je.conditions != null){
|
||||
@ -126,7 +126,7 @@ public class HqlSerializer extends VisitorAdapter<HqlSerializer>{
|
||||
}
|
||||
|
||||
protected void visit(Constructor<?> expr){
|
||||
_append("new ")._append(expr._type().getName())._append("(");
|
||||
_append("new ")._append(expr.getType().getName())._append("(");
|
||||
_append(", ",Arrays.asList(expr.args))._append(")");
|
||||
}
|
||||
|
||||
@ -153,4 +153,14 @@ public class HqlSerializer extends VisitorAdapter<HqlSerializer>{
|
||||
_append(expr.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void visit(SubQuery<?> subQuery) {
|
||||
_append("(");
|
||||
_append("\n select ").handle(subQuery._select());
|
||||
_append("\n from ")._append(", ", subQuery._from());
|
||||
_append("\n where ")._append(" and ", subQuery._where());
|
||||
_append(")");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -58,6 +58,10 @@ public class HqlQuery extends HqlQueryBase<HqlQuery>{
|
||||
return query;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO : replace this with Hibernate Criteria based usage
|
||||
*/
|
||||
@Deprecated
|
||||
public HqlQuery forExample(PathEntity<?> entity, Map<String, Object> map) {
|
||||
select(entity).from(entity);
|
||||
try {
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
// AuditLog
|
||||
|
||||
// AuditLog
|
||||
public static final AuditLog log = new AuditLog("log");
|
||||
|
||||
// Cat
|
||||
@ -55,4 +56,5 @@
|
||||
public static final User user2 = new User("user2");
|
||||
public static final User user3 = new User("user3");
|
||||
public static final User user4 = new User("user4");
|
||||
public static final User user5 = new User("user5");
|
||||
public static final User user5 = new User("user5");
|
||||
|
||||
@ -1,10 +1,19 @@
|
||||
package com.mysema.query.grammar.hql;
|
||||
|
||||
import static com.mysema.query.grammar.HqlGrammar.*;
|
||||
import static com.mysema.query.grammar.hql.domain.Domain.*;
|
||||
import static com.mysema.query.Domain1.catalog;
|
||||
import static com.mysema.query.Domain1.item;
|
||||
import static com.mysema.query.Domain1.order;
|
||||
import static com.mysema.query.Domain1.price;
|
||||
import static com.mysema.query.Domain1.product;
|
||||
import static com.mysema.query.grammar.Grammar.not;
|
||||
import static com.mysema.query.grammar.HqlGrammar.count;
|
||||
import static com.mysema.query.grammar.HqlGrammar.sum;
|
||||
import static com.mysema.query.grammar.HqlGrammar.sysdate;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.mysema.query.grammar.HqlQueryBase;
|
||||
import com.mysema.query.grammar.hql.domain.Catalog;
|
||||
import com.mysema.query.grammar.hql.domain.Customer;
|
||||
import com.mysema.query.grammar.hql.domain.Product;
|
||||
|
||||
@ -52,7 +61,7 @@ public class ComplexQueriesTest extends HqlQueryBase<ComplexQueriesTest>{
|
||||
catalog.effectiveDate.lt(sysdate()), // lt as static method
|
||||
catalog.effectiveDate.goe(sysdate())) // goe as static method
|
||||
.groupBy(order)
|
||||
.having(gt(sum(price.amount), minAmount))
|
||||
.having(sum(price.amount).gt(minAmount))
|
||||
.orderBy(sum(price.amount).desc());
|
||||
}
|
||||
|
||||
@ -70,7 +79,25 @@ public class ComplexQueriesTest extends HqlQueryBase<ComplexQueriesTest>{
|
||||
// and catalog = :currentCatalog
|
||||
// group by order
|
||||
// having sum(price.amount) > :minAmount
|
||||
// order by sum(price.amount) desc
|
||||
// order by sum(price.amount) desc
|
||||
Customer c = new Customer();
|
||||
Product p = new Product();
|
||||
Catalog currentCatalog = new Catalog();
|
||||
long minAmount = 0l;
|
||||
|
||||
select(order.id, sum(price.amount), count(item))
|
||||
.from(order)
|
||||
.innerJoin(order.lineItems.as(item))
|
||||
.innerJoin(item.product.as(product))
|
||||
.join(catalog)
|
||||
.innerJoin(catalog.prices.as(price))
|
||||
.where(not(order.paid),
|
||||
order.customer.eq(c),
|
||||
price.product.eq(p),
|
||||
catalog.eq(currentCatalog))
|
||||
.groupBy(order)
|
||||
.having(sum(price.amount).gt(minAmount))
|
||||
.orderBy(sum(price.amount).desc());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -89,7 +116,7 @@ public class ComplexQueriesTest extends HqlQueryBase<ComplexQueriesTest>{
|
||||
// and statusChange.user <> :currentUser
|
||||
// )
|
||||
// group by status.name, status.sortOrder
|
||||
// order by status.sortOrder
|
||||
// order by status.sortOrder
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -115,6 +142,7 @@ public class ComplexQueriesTest extends HqlQueryBase<ComplexQueriesTest>{
|
||||
|
||||
@Test
|
||||
public void testExample6(){
|
||||
|
||||
// select account, payment
|
||||
// from Account as account
|
||||
// join account.holder.users as user
|
||||
|
||||
@ -2,17 +2,17 @@ package com.mysema.query.grammar.hql;
|
||||
|
||||
import static com.mysema.query.grammar.Grammar.*;
|
||||
import static com.mysema.query.grammar.HqlGrammar.*;
|
||||
import static com.mysema.query.grammar.hql.domain.Domain.*;
|
||||
import static com.mysema.query.Domain1.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.mysema.query.grammar.HqlGrammar;
|
||||
import com.mysema.query.grammar.HqlQueryBase;
|
||||
import com.mysema.query.grammar.HqlSerializer;
|
||||
import com.mysema.query.grammar.HqlGrammar.Constructor;
|
||||
import com.mysema.query.grammar.Types.Expr;
|
||||
import com.mysema.query.grammar.Types.PathEntityCollection;
|
||||
import com.mysema.query.grammar.hql.domain.Cat;
|
||||
|
||||
|
||||
/**
|
||||
* FeaturesTest provides
|
||||
@ -236,7 +236,7 @@ public class FeaturesTest extends HqlQueryBase<FeaturesTest>{
|
||||
@Test
|
||||
public void testStringConcatenations(){
|
||||
// string concatenation ...||... or concat(...,...)
|
||||
toString("cat.name || kitten.name", concat(cat.name, kitten.name));
|
||||
toString("cat.name || kitten.name", cat.name.concat(kitten.name));
|
||||
}
|
||||
|
||||
// coalesce() and nullif()
|
||||
@ -248,11 +248,21 @@ public class FeaturesTest extends HqlQueryBase<FeaturesTest>{
|
||||
|
||||
@Test
|
||||
public void testStringOperationsInFunctionalWay(){
|
||||
toString("cat.name || cust.name.firstName", concat(cat.name,cust.name().firstName));
|
||||
toString("cat.name || cust.name.firstName", cat.name.concat(cust.name().firstName));
|
||||
toString("cat.name like :a1",cat.name.like("A%"));
|
||||
toString("lower(cat.name)",cat.name.lower());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSubQuery(){
|
||||
StringBuilder b = new StringBuilder();
|
||||
b.append("(");
|
||||
b.append("\n select cust.name");
|
||||
b.append("\n from cust");
|
||||
b.append("\n where cust.name is not null)");
|
||||
toString(b.toString(), HqlGrammar.select(cust.name).from(cust).where(cust.name.isnotnull()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToString(){
|
||||
toString("cat", cat);
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
package com.mysema.query.grammar.hql;
|
||||
|
||||
import static com.mysema.query.grammar.HqlGrammar.*;
|
||||
import static com.mysema.query.grammar.hql.domain.Domain.*;
|
||||
import static com.mysema.query.Domain1.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.Date;
|
||||
@ -41,10 +41,10 @@ public class SimpleQueriesTest extends HqlQueryBase<SimpleQueriesTest>{
|
||||
where(be);
|
||||
with(be);
|
||||
// select(cat.name.as("cat_name")); // not allowed
|
||||
from(cat,cust).where(gt(cat.name,cust.name().firstName));
|
||||
from(cat,cust).where(cat.name.gt(cust.name().firstName));
|
||||
select(cat.name.lower()).from(cat).where(cat.name.substring(0,2).eq("Mi"));
|
||||
select(cat.name.upper()).from(cat);
|
||||
select(concat(cat.name.lower(),cat.mate().name)).from(cat);
|
||||
select(cat.name.lower().concat(cat.mate().name)).from(cat);
|
||||
// cat.as(company); // not allowed
|
||||
// asc(cust.name()); // not allowed
|
||||
cust.name().firstName.asc();
|
||||
@ -57,12 +57,12 @@ public class SimpleQueriesTest extends HqlQueryBase<SimpleQueriesTest>{
|
||||
|
||||
@Test
|
||||
public void testOperations(){
|
||||
gt(kitten.bodyWeight, 10);
|
||||
kitten.bodyWeight.gt(10);
|
||||
kitten.bodyWeight.lt(10);
|
||||
goe(kitten.bodyWeight, 10);
|
||||
kitten.bodyWeight.goe(10);
|
||||
kitten.bodyWeight.loe(10);
|
||||
|
||||
gt(cat.name, "ABC");
|
||||
cat.name.gt("ABC");
|
||||
cust.name().firstName.lt("Albert");
|
||||
cust.name().firstName.lower();
|
||||
cust.name().firstName.upper();
|
||||
@ -76,7 +76,7 @@ public class SimpleQueriesTest extends HqlQueryBase<SimpleQueriesTest>{
|
||||
// from Cat as cat left join cat.kittens as kitten
|
||||
// with kitten.bodyWeight > 10.0
|
||||
from(cat).leftJoin(cat.kittens.as(kitten))
|
||||
.with(gt(kitten.bodyWeight,10));
|
||||
.with(kitten.bodyWeight.gt(10));
|
||||
expect("from Cat cat\nleft join cat.kittens as kitten\n"+
|
||||
"with kitten.bodyWeight > :a1");
|
||||
}
|
||||
|
||||
@ -0,0 +1,50 @@
|
||||
package com.mysema.query.grammar.hql;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.mysema.query.grammar.HqlQueryBase;
|
||||
import com.mysema.query.Domain2;
|
||||
import static com.mysema.query.grammar.HqlGrammar.*;
|
||||
|
||||
/**
|
||||
* ThingLinkQueriesTest provides
|
||||
*
|
||||
* @author tiwe
|
||||
* @version $Id$
|
||||
*/
|
||||
public class ThingLinkQueriesTest extends HqlQueryBase<ComplexQueriesTest>{
|
||||
|
||||
private Domain2.Association a = new Domain2.Association("a");
|
||||
private Domain2.Tag g = new Domain2.Tag("g");
|
||||
private Domain2.Thing h = new Domain2.Thing("h");
|
||||
private Domain2.Thing t = new Domain2.Thing("t");
|
||||
|
||||
@Test
|
||||
public void testQuery1(){
|
||||
// "select g._keyword, count(g._keyword) from " + Thing.class.getName()
|
||||
// + " h inner join h._tags as g where h._code in" + "(select t._code from "
|
||||
// + Association.class.getName() + " a " + "inner join a._thing as t "
|
||||
// + "where a._association = :association "
|
||||
// + "and t._isHidden = :hidden) group by g._keyword order by count(g._keyword) desc");
|
||||
|
||||
// select(g._keyword, count(g._keyword))
|
||||
// .from(h).innerJoin(h._tags.as(g))
|
||||
// .where(h._code.in(
|
||||
// select(t._code).from(a
|
||||
|
||||
}
|
||||
|
||||
public void testQuery2(){
|
||||
// "select g._keyword, count(g._keyword) from "
|
||||
// + Thing.class.getName()
|
||||
// + " h inner join h._tags as g where h._code in"
|
||||
// + "(select t._code from "
|
||||
// + Association.class.getName()
|
||||
// + " a "
|
||||
// + "inner join a._thing as t "
|
||||
// + "where a._association = :association "
|
||||
// + "and t._isHidden = :hidden and t._timeStamp > :lastweek)
|
||||
// group by g._keyword order by count(g._keyword) desc");
|
||||
}
|
||||
|
||||
}
|
||||
@ -10,6 +10,6 @@ import javax.persistence.Entity;
|
||||
*/
|
||||
@Entity
|
||||
public class EvilType {
|
||||
protected EvilType isnull, isnotnull, asc, desc, get, _type, path, _parent;
|
||||
protected EvilType isnull, isnotnull, asc, desc, get, getType, getMetadata;
|
||||
protected EvilType toString, hashCode, getClass, notify, notifyAll, wait;
|
||||
}
|
||||
|
||||
@ -0,0 +1,83 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.mysema.query.grammar.hql.domain2;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.OneToOne;
|
||||
|
||||
/**
|
||||
* An Association represents a relationship between a Thing an a User. For
|
||||
* example a User can like, hate or sell a Thing. (see thinglink-2.0 datamodel)
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
// @Table(uniqueConstraints={@UniqueConstraint(columnNames={ "user", "thing",
|
||||
// "association" })})
|
||||
public class Association extends TimeStamped {
|
||||
|
||||
@OneToOne
|
||||
private User _user;
|
||||
|
||||
@OneToOne
|
||||
private Thing _thing;
|
||||
|
||||
private AssociationType _association;
|
||||
|
||||
public enum AssociationType {
|
||||
LIKE, COLLECT, MAKE, OWN, SWAP, GIVE, HATE, SELL, WANT, LOVE, LINKED;
|
||||
}
|
||||
|
||||
public Association() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param user
|
||||
* The User the Association is related to.
|
||||
* @param thing
|
||||
* The Thing the Association is related to.
|
||||
* @param association
|
||||
* The type of the Association.
|
||||
*/
|
||||
public Association(User user, Thing thing, AssociationType association) {
|
||||
_user = user;
|
||||
_thing = thing;
|
||||
_association = association;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The User the Association is related to.
|
||||
*/
|
||||
public User getUser() {
|
||||
return _user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The Thing the Association is related to.
|
||||
*/
|
||||
public Thing getThing() {
|
||||
return _thing;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The type of the Association.
|
||||
*/
|
||||
public AssociationType getAssociation() {
|
||||
return _association;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object association) {
|
||||
boolean sameUser = ((Association) association).getUser().equals(_user);
|
||||
boolean sameThing = ((Association) association).getThing().equals(_thing);
|
||||
boolean sameType = ((Association) association).getAssociation().equals(_association);
|
||||
return (sameUser && sameThing && sameType);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
package com.mysema.query.grammar.hql.domain2;
|
||||
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
|
||||
|
||||
/**
|
||||
* BaseEntity is the top of entity hierarchy. (see thinglink-2.0 datamodel)
|
||||
*
|
||||
*/
|
||||
@MappedSuperclass
|
||||
public class BaseEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
protected Long _id;
|
||||
|
||||
/**
|
||||
* @return The id of the entity.
|
||||
*/
|
||||
public Long getId() {
|
||||
return _id;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,99 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.mysema.query.grammar.hql.domain2;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
|
||||
/**
|
||||
* A comment is Created by a User and belongs to a Thing. A Thing has a List
|
||||
* with its comments. (see thinglink-2.0 datamodel)
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
public class Comment extends TimeStamped {
|
||||
|
||||
@Column(length = 500)
|
||||
private String _userName;
|
||||
|
||||
@Column(length = 500)
|
||||
private String _userEmail;
|
||||
|
||||
@Column(length = 15000)
|
||||
private String _text;
|
||||
|
||||
private Boolean _isNew;
|
||||
|
||||
public Comment() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls super() to create timeStamp. _isNew is initialized with true.
|
||||
*
|
||||
* @param userName
|
||||
* Name of the user who created the Comment.
|
||||
* @param text
|
||||
* The comment.
|
||||
*/
|
||||
public Comment(String userName, String text) {
|
||||
super();
|
||||
_userName = userName;
|
||||
_text = text;
|
||||
_isNew = new Boolean(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Name of the user who created the Comment.
|
||||
*/
|
||||
public String getUserName() {
|
||||
return _userName;
|
||||
}
|
||||
|
||||
public void setUserEmail(String userEmail) {
|
||||
_userEmail = userEmail;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return EMail of the user who created the Comment.
|
||||
*/
|
||||
public String getUserEmail() {
|
||||
return _userEmail;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Text of the Comment.
|
||||
*/
|
||||
public String getText() {
|
||||
return _text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param text
|
||||
* Text of the Comment.
|
||||
*/
|
||||
public void setText(String text) {
|
||||
_text = text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this method, when the User has read the Comment.
|
||||
*/
|
||||
public void setOld() {
|
||||
_isNew = new Boolean(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return False, when the User has read the Comment.
|
||||
*/
|
||||
public Boolean isNew() {
|
||||
return _isNew;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object comment) {
|
||||
return ((((Comment) comment).getUserName().equals(_userName)) && (((Comment) comment).getText().equals(_text)) && (((Comment) comment)
|
||||
.getTimeStamp().equals(getTimeStamp())));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,61 @@
|
||||
package com.mysema.query.grammar.hql.domain2;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
|
||||
/**
|
||||
* To set and get Content of html-pages with admin-gui.
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
public class Content {
|
||||
|
||||
@Id
|
||||
private String _title;
|
||||
|
||||
@Column(length = 100000)
|
||||
private String _content;
|
||||
|
||||
public Content() {
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* @param title
|
||||
* @param content
|
||||
*/
|
||||
public Content(String title, String content) {
|
||||
_title = title;
|
||||
_content = content;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public String getContent() {
|
||||
return _content;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param content
|
||||
*/
|
||||
public void setContent(String content) {
|
||||
_content = content;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public String getTitle() {
|
||||
return _title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param title
|
||||
*/
|
||||
public void setTitle(String title) {
|
||||
_title = title;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.mysema.query.grammar.hql.domain2;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
|
||||
/**
|
||||
* A Thing can belong to multiple Countries. The Countries specify where a Thing
|
||||
* comes from, whereas the {@link Location} specifies, where the Thing currently
|
||||
* is located.
|
||||
*/
|
||||
@Entity
|
||||
public class Country {
|
||||
|
||||
@Id
|
||||
private String _name;
|
||||
|
||||
public Country() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* Name of the country.
|
||||
*/
|
||||
public Country(String name) {
|
||||
_name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Name of the country.
|
||||
*/
|
||||
public String getName() {
|
||||
return _name;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object country) {
|
||||
return ((Country) country).getName().equals(_name);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,141 @@
|
||||
package com.mysema.query.grammar.hql.domain2;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.ManyToMany;
|
||||
import javax.persistence.OneToOne;
|
||||
|
||||
@Entity
|
||||
public class Exhibition extends FeaturedItem {
|
||||
|
||||
@Column(unique = true)
|
||||
private String _name;
|
||||
|
||||
@OneToOne
|
||||
private User _user;
|
||||
|
||||
@ManyToMany
|
||||
private List<Thing> _things;
|
||||
|
||||
private String _location;
|
||||
|
||||
private String _host;
|
||||
|
||||
private Date _startDate;
|
||||
|
||||
private Date _endDate;
|
||||
|
||||
public Exhibition() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* The name of the Exhibition.
|
||||
* @param user
|
||||
* The User responsible for the Exhibition.
|
||||
*/
|
||||
public Exhibition(String name, User user) {
|
||||
_name = name;
|
||||
_user = user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The name of the Exhibition.
|
||||
*/
|
||||
public String getName() {
|
||||
return _name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The User responsible for the Exhibition.
|
||||
*/
|
||||
public User getUser() {
|
||||
return _user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param thing
|
||||
* The Thing to add to the Exhibition.
|
||||
*/
|
||||
public void addThing(Thing thing) {
|
||||
if (_things == null)
|
||||
_things = new ArrayList<Thing>();
|
||||
_things.add(thing);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return All Things of the Exhibition.
|
||||
*/
|
||||
public List<Thing> getThings() {
|
||||
return _things;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param location
|
||||
* The location of the Exhibition.
|
||||
*/
|
||||
public void setLocation(String location) {
|
||||
_location = location;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The location of the Exhibition.
|
||||
*/
|
||||
public String getLocation() {
|
||||
return _location;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param location
|
||||
* The host of the Exhibition.
|
||||
*/
|
||||
public void setHost(String host) {
|
||||
_host = host;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The host of the Exhibition.
|
||||
*/
|
||||
public String getHost() {
|
||||
return _host;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param startDate
|
||||
* Date when the Exhibition begins.
|
||||
*/
|
||||
public void setStartDate(Date startDate) {
|
||||
_startDate = startDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Date when the Exhibition begins.
|
||||
*/
|
||||
public Date getStartDate() {
|
||||
return _startDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param endDate
|
||||
* Date when the Exhibition ends.
|
||||
*/
|
||||
public void setEndDate(Date endDate) {
|
||||
_endDate = endDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Date when the Exhibition ends.
|
||||
*/
|
||||
public Date getEndDate() {
|
||||
return _endDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object exhibition){
|
||||
return ((Exhibition)exhibition).getName().equals(_name);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,101 @@
|
||||
package com.mysema.query.grammar.hql.domain2;
|
||||
|
||||
import javax.persistence.MappedSuperclass;
|
||||
|
||||
/**
|
||||
* An item can be featured. If an item is featured, it has a weight and a
|
||||
* featuredTimeStamp. (see thinglink-2.0 datamodel)
|
||||
*
|
||||
*/
|
||||
@MappedSuperclass
|
||||
public class FeaturedItem extends MetaDataContainer {
|
||||
|
||||
private Boolean _isFeatured;
|
||||
|
||||
private Long _featuredTimeStamp;
|
||||
|
||||
private Integer _weight;
|
||||
|
||||
/**
|
||||
* Calls super() to create timeStamp. Initially isFeatured is set false.
|
||||
* featuredTimeStamp and weight is initialized 0.
|
||||
*/
|
||||
public FeaturedItem() {
|
||||
super();
|
||||
_isFeatured = new Boolean(false);
|
||||
_featuredTimeStamp = new Long(-1);
|
||||
_weight = new Integer(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return True if the item is featured, false otherwise.
|
||||
*/
|
||||
public Boolean isFeatured() {
|
||||
return _isFeatured;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The featuredTimeStamp is equivalent to the time, when the Item
|
||||
* has been featured.
|
||||
*/
|
||||
public Long getFeaturedTimeStamp() {
|
||||
return _featuredTimeStamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The weight of the featuredItem. If the item is not featured,
|
||||
* weight is -1.
|
||||
*/
|
||||
public Integer getWeight() {
|
||||
return _weight;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param weight
|
||||
* If the item is featured, the weight is set. Otherwise the
|
||||
* weight remains -1.
|
||||
*/
|
||||
public void setWeight(int weight) {
|
||||
if (_isFeatured.booleanValue()) {
|
||||
_weight = Integer.valueOf(weight);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets isFeatured=true and creates a featuredTimeStamp and adds the given
|
||||
* weight to the current weight.
|
||||
*
|
||||
* @param weight
|
||||
* The weight to add to the featuredItem.
|
||||
*/
|
||||
public void setFeatured(int weight) {
|
||||
_isFeatured = Boolean.valueOf(true);
|
||||
_featuredTimeStamp = Long.valueOf(System.currentTimeMillis());
|
||||
int currentWeight;
|
||||
if (_weight != null) {
|
||||
currentWeight = _weight.intValue();
|
||||
} else {
|
||||
currentWeight = 0;
|
||||
}
|
||||
final int newWeight = currentWeight + weight;
|
||||
_weight = Integer.valueOf(newWeight);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets isFeatured=false, and featuredTimeStamp and weight -1.
|
||||
*/
|
||||
public void unfeature() {
|
||||
_isFeatured = Boolean.valueOf(false);
|
||||
_featuredTimeStamp = Long.valueOf(-1);
|
||||
_weight = Integer.valueOf(0);
|
||||
}
|
||||
|
||||
public void unfeature(int weight) {
|
||||
_weight = _weight - weight;
|
||||
if (_weight <= 0) {
|
||||
_isFeatured = Boolean.valueOf(false);
|
||||
_featuredTimeStamp = Long.valueOf(-1);
|
||||
_weight = Integer.valueOf(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,106 @@
|
||||
package com.mysema.query.grammar.hql.domain2;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToMany;
|
||||
|
||||
@Entity
|
||||
public class GroupOfInterest {
|
||||
|
||||
@Id
|
||||
private String _name;
|
||||
|
||||
@OneToMany
|
||||
private List<User> _users;
|
||||
|
||||
@OneToMany
|
||||
private List<Thing> _things;
|
||||
|
||||
private GroupOfInterestPrivacy _privacyLevel;
|
||||
|
||||
public enum GroupOfInterestPrivacy {
|
||||
PRIVATE, PUBLIC;
|
||||
}
|
||||
|
||||
public GroupOfInterest() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* The name of the GroupOfInterest.
|
||||
*/
|
||||
public GroupOfInterest(String name) {
|
||||
_name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param user
|
||||
* The User to add to the GroupOfInterest.
|
||||
*/
|
||||
public void addUser(User user) {
|
||||
if (_users == null) {
|
||||
_users = new ArrayList<User>();
|
||||
}
|
||||
_users.add(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param thing
|
||||
* The Thing to add to the GroupOfInterest.
|
||||
*/
|
||||
public void addThing(Thing thing) {
|
||||
if (_things == null) {
|
||||
_things = new ArrayList<Thing>();
|
||||
}
|
||||
_things.add(thing);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The name of the GroupOfInterest.
|
||||
*/
|
||||
public String getName() {
|
||||
return _name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The privacy level of the GroupOfInterest.
|
||||
*/
|
||||
public GroupOfInterestPrivacy getPrivacyLevel() {
|
||||
return _privacyLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param privacyLevel
|
||||
* Privacy-level of the GroupOfInterest.
|
||||
*/
|
||||
public void setPrivacyLevel(GroupOfInterestPrivacy privacyLevel) {
|
||||
_privacyLevel = privacyLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return All Users that belong to the GroupOfInterest.
|
||||
*/
|
||||
public List<User> getUsers() {
|
||||
return _users;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return All Things that belong to the GroupOfInterest.
|
||||
*/
|
||||
public List<Thing> getThings() {
|
||||
return _things;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object group) {
|
||||
return ((GroupOfInterest) group).getName().equals(_name);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
package com.mysema.query.grammar.hql.domain2;
|
||||
|
||||
public interface IDisplayObject {
|
||||
|
||||
public String getDisplayObjectType();
|
||||
|
||||
public enum DisplayObjectType{
|
||||
USER, THING;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,163 @@
|
||||
package com.mysema.query.grammar.hql.domain2;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
|
||||
/**
|
||||
* The Location specifies where a Thing is currently located, whereas a
|
||||
* {@link Country} specifies where a Thing comes from.
|
||||
*/
|
||||
@Entity
|
||||
public class Location extends TimeStamped {
|
||||
|
||||
@Column(length = 500)
|
||||
private String _country;
|
||||
|
||||
@Column(length = 500)
|
||||
private String _city;
|
||||
|
||||
@Column(length = 500)
|
||||
private String _zipCode;
|
||||
|
||||
private Double _longitude;
|
||||
|
||||
private Double _latitude;
|
||||
|
||||
@Column(length = 500)
|
||||
private String _street;
|
||||
|
||||
@Column(length = 500)
|
||||
private String _url;
|
||||
|
||||
public Location() {//
|
||||
}
|
||||
|
||||
/**
|
||||
* @param country
|
||||
* @param url
|
||||
* @param zipCode
|
||||
*/
|
||||
public Location(String country, String url, String zipCode) {
|
||||
super();
|
||||
_country = country;
|
||||
_url = url;
|
||||
_zipCode = zipCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param country
|
||||
*/
|
||||
public void setCountry(String country) {
|
||||
_country = country;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The country where the Thing is currently located.
|
||||
*/
|
||||
public String getCountry() {
|
||||
return _country;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param city
|
||||
*/
|
||||
public void setCity(String city) {
|
||||
_city = city;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The city where the Thing is currently located.
|
||||
*/
|
||||
public String getCity() {
|
||||
return _city;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param zipCode
|
||||
*/
|
||||
public void setZipCode(String zipCode) {
|
||||
_zipCode = zipCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The zip code where the Thing is currently located.
|
||||
*/
|
||||
public String getZipCode() {
|
||||
return _zipCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param longitude
|
||||
*/
|
||||
public void setLongitude(Double longitude) {
|
||||
_longitude = longitude;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public Double getLongitude() {
|
||||
return _longitude;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param latitude
|
||||
*/
|
||||
public void setLatitude(Double latitude) {
|
||||
_latitude = latitude;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param latitude
|
||||
* @return
|
||||
*/
|
||||
public Double getLatitude(Double latitude) {
|
||||
return _latitude;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param street
|
||||
*/
|
||||
public void setStreet(String street) {
|
||||
_street = street;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public String getStreet() {
|
||||
return _street;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param url
|
||||
* This could be a URL like
|
||||
* http://beta.plazes.com/plaze/f93d8d1a909b6f80341e5b4f9178b218
|
||||
*/
|
||||
public void setUrl(String url) {
|
||||
_url = url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A URL like
|
||||
* http://beta.plazes.com/plaze/f93d8d1a909b6f80341e5b4f9178b218 if
|
||||
* previously set.
|
||||
*/
|
||||
public String getUrl() {
|
||||
return _url;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object location) {
|
||||
if (location == null)
|
||||
return false;
|
||||
|
||||
return (((Location) location).getUrl().equals(_url) && ((Location) location).getZipCode().equals(_zipCode) && ((Location) location)
|
||||
.getCountry().equals(_country));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,48 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.mysema.query.grammar.hql.domain2;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
|
||||
/**
|
||||
* A Thing has one or more Makers. A Maker can be featured. (see thinglink-2.0
|
||||
* datamodel)
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
public class Maker extends FeaturedItem {
|
||||
|
||||
@Column(unique = true)
|
||||
private String _name;
|
||||
|
||||
public Maker() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls super() to create timeStamp.
|
||||
*/
|
||||
public Maker(String name) {
|
||||
super();
|
||||
_name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Name of the Maker.
|
||||
*/
|
||||
public String getName() {
|
||||
return _name;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object maker) {
|
||||
return ((Maker) maker).getName().equals(_name);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
package com.mysema.query.grammar.hql.domain2;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import javax.persistence.MappedSuperclass;
|
||||
|
||||
/**
|
||||
* Objects can have metadata as key/value pairs. Internally those pairs are
|
||||
* stored in a HashMap. (see thinglink-2.0 datamodel)
|
||||
*
|
||||
*
|
||||
*/
|
||||
@MappedSuperclass
|
||||
public class MetaDataContainer extends TimeStamped {
|
||||
|
||||
private HashMap<String, String> _metaDataEntries;
|
||||
|
||||
/**
|
||||
* Calls super() to create timeStamp.
|
||||
*/
|
||||
public MetaDataContainer() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a metadata entry to this container.
|
||||
*
|
||||
* @param key
|
||||
* Metadata key.
|
||||
* @param value
|
||||
* Metadata value.
|
||||
*/
|
||||
public void addMetaDataEntry(String key, String value) {
|
||||
if (_metaDataEntries == null)
|
||||
_metaDataEntries = new HashMap<String, String>(10);
|
||||
_metaDataEntries.put(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a metadata entry by key.
|
||||
*
|
||||
* @param key
|
||||
* The key of the metadata entry to retrieve.
|
||||
* @return The value of the metadata entry.
|
||||
*/
|
||||
public String getMetaDataEntry(String key) {
|
||||
if (_metaDataEntries != null)
|
||||
return _metaDataEntries.get(key);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,44 @@
|
||||
package com.mysema.query.grammar.hql.domain2;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
|
||||
/**
|
||||
* A Thing can have multiple Tags.
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
public class Tag {
|
||||
|
||||
@Id
|
||||
private String _keyword;
|
||||
|
||||
public Tag() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param keyword
|
||||
* Keyword of the Tag.
|
||||
*/
|
||||
public Tag(String keyword) {
|
||||
_keyword = keyword;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Keyword of the Tag.
|
||||
*/
|
||||
public String getKeyword() {
|
||||
return _keyword;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object tag) {
|
||||
return ((Tag) tag).getKeyword().equals(_keyword);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,494 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.mysema.query.grammar.hql.domain2;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.ManyToMany;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
|
||||
import org.hibernate.annotations.CollectionOfElements;
|
||||
import org.hibernate.search.annotations.DocumentId;
|
||||
import org.hibernate.search.annotations.Field;
|
||||
import org.hibernate.search.annotations.FieldBridge;
|
||||
import org.hibernate.search.annotations.Index;
|
||||
import org.hibernate.search.annotations.Indexed;
|
||||
|
||||
/**
|
||||
* A thinglink Thing is represented. This is the core of the data model. (see
|
||||
* thinglink-2.0 datamodel)
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Indexed
|
||||
public class Thing extends FeaturedItem implements IDisplayObject {
|
||||
|
||||
@Column(unique = true)
|
||||
private String _code;
|
||||
|
||||
@CollectionOfElements
|
||||
private List<String> _imageFileNames = new ArrayList<String>();
|
||||
|
||||
@CollectionOfElements
|
||||
private List<String> _soundFileNames = new ArrayList<String>();
|
||||
|
||||
@OneToMany(cascade = { CascadeType.ALL })
|
||||
private List<Comment> _comments = new ArrayList<Comment>();
|
||||
|
||||
@ManyToMany(cascade = { CascadeType.ALL })
|
||||
private List<Maker> _makers = new ArrayList<Maker>();
|
||||
|
||||
@ManyToMany(cascade = { CascadeType.ALL })
|
||||
// @Field(index = Index.TOKENIZED)
|
||||
// @FieldBridge(impl = TagsListBridge.class)
|
||||
private List<Tag> _tags = new ArrayList<Tag>();
|
||||
|
||||
@ManyToMany(cascade = { CascadeType.ALL })
|
||||
// @Field(index = Index.TOKENIZED)
|
||||
// @FieldBridge(impl = CountriesListBridge.class)
|
||||
private List<Country> _countries = new ArrayList<Country>();
|
||||
|
||||
@ManyToMany(cascade = { CascadeType.ALL })
|
||||
private List<Year> _years = new ArrayList<Year>();
|
||||
|
||||
@ManyToOne
|
||||
private User _linker;
|
||||
|
||||
@ManyToMany(cascade = { CascadeType.ALL })
|
||||
private List<Location> _locations = new ArrayList<Location>();
|
||||
|
||||
@ManyToOne(cascade = { CascadeType.ALL })
|
||||
// @Field(index = Index.TOKENIZED)
|
||||
// @FieldBridge(impl = LocationBridge.class)
|
||||
private Location _currentLocation;
|
||||
|
||||
@Override
|
||||
@DocumentId
|
||||
public Long getId() {
|
||||
return _id;
|
||||
}
|
||||
|
||||
private ThingPrivacy _privacyLevel;
|
||||
|
||||
@Field(index = Index.TOKENIZED)
|
||||
private String _name;
|
||||
|
||||
@Column(length = 500)
|
||||
private String _password;
|
||||
|
||||
private Boolean _isHidden;
|
||||
|
||||
@Column(length = 40000)
|
||||
@Field(index = Index.TOKENIZED)
|
||||
private String _description;
|
||||
|
||||
private Integer _viewCount;
|
||||
|
||||
private Boolean _isVersion1;
|
||||
|
||||
@Column(length = 500)
|
||||
private String _imageFileName;
|
||||
|
||||
private Integer _createYear;
|
||||
|
||||
private Integer _createMonth;
|
||||
|
||||
private Integer _createDay;
|
||||
|
||||
public enum ThingPrivacy {
|
||||
PRIVATE, FRIENDS, PUBLIC;
|
||||
}
|
||||
|
||||
public Thing() {//
|
||||
}
|
||||
|
||||
/**
|
||||
* Initially the Thing is not hidden.
|
||||
*
|
||||
* @param code
|
||||
* The unique code of the Thing. Something like "ABC123".
|
||||
*/
|
||||
public Thing(String code) {
|
||||
_code = code;
|
||||
_isHidden = new Boolean(false);
|
||||
_isVersion1 = new Boolean(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param code
|
||||
* The unique code of the Thing.
|
||||
*/
|
||||
public void setCode(String code) {
|
||||
_code = code;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The unique code of the Thing.
|
||||
*/
|
||||
public String getCode() {
|
||||
return _code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set true if this Thing has been created with thinglink-1.0
|
||||
*
|
||||
* @param version1
|
||||
*/
|
||||
public void setVersion1(boolean version1) {
|
||||
_isVersion1 = new Boolean(version1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return True if this Thing has been created with thinglink-1.0
|
||||
*/
|
||||
public Boolean isVersion1() {
|
||||
return _isVersion1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param linker
|
||||
* The User who created the Thing.
|
||||
*/
|
||||
public void setLinker(User linker) {
|
||||
_linker = linker;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The User who created the Thing.
|
||||
*/
|
||||
public User getLinker() {
|
||||
return _linker;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should be called each time the Thing is viewed.
|
||||
*/
|
||||
public void view() {
|
||||
if (_viewCount == null)
|
||||
_viewCount = new Integer(0);
|
||||
_viewCount = Integer.valueOf(_viewCount.intValue() + 1);
|
||||
}
|
||||
|
||||
public void setViewCount(int count) {
|
||||
_viewCount = new Integer(count);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Viewcount for the Thing.
|
||||
*/
|
||||
public Integer getViewCount() {
|
||||
return _viewCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param comment
|
||||
* The Comment to add to the Thing.
|
||||
*/
|
||||
public void addComment(Comment comment) {
|
||||
_comments.add(comment);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return All Comments that belong to this Thing.
|
||||
*/
|
||||
public List<Comment> getComments() {
|
||||
return _comments;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param imageFileName
|
||||
*/
|
||||
public void addImageFileName(String imageFileName) {
|
||||
if (_imageFileNames == null)
|
||||
_imageFileNames = new ArrayList<String>();
|
||||
_imageFileNames.add(imageFileName);
|
||||
}
|
||||
|
||||
public void addSoundFileName(String soundFileName) {
|
||||
if (_soundFileNames == null)
|
||||
_soundFileNames = new ArrayList<String>();
|
||||
_soundFileNames.add(soundFileName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public List<String> getImageFileNames() {
|
||||
return _imageFileNames;
|
||||
}
|
||||
|
||||
public List<String> getSoundFileNames() {
|
||||
return _soundFileNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a Location to the Thing. The last Location added represents the
|
||||
* current Location of the Thing.
|
||||
*
|
||||
* @param location
|
||||
* The current Location of the Thing.
|
||||
*/
|
||||
public void addLocation(Location location) {
|
||||
_locations.add(location);
|
||||
_currentLocation = location;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return All Locations where the Thing has been located during the past.
|
||||
*/
|
||||
public List<Location> getLocations() {
|
||||
return _locations;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The Location where the Thing is currently located.
|
||||
*/
|
||||
public Location getCurrentLocation() {
|
||||
// return _locations.get(_locations.size()-1);
|
||||
return _currentLocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* Name of the Maker of this Thing.
|
||||
*/
|
||||
public void addMaker(Maker maker) {
|
||||
if (_makers == null)
|
||||
_makers = new ArrayList<Maker>();
|
||||
if (_makers.contains(maker))
|
||||
_makers.remove(maker);
|
||||
_makers.add(0, maker);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return All Makers of this Thing.
|
||||
*/
|
||||
public List<Maker> getMakers() {
|
||||
return _makers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param keyword
|
||||
* Keyword of the Tag.
|
||||
*/
|
||||
public void addTag(Tag tag) {
|
||||
if (_tags == null)
|
||||
_tags = new ArrayList<Tag>();
|
||||
if (!_tags.contains(tag))
|
||||
_tags.add(tag);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return All Tags of this Thing.
|
||||
*/
|
||||
public List<Tag> getTags() {
|
||||
return _tags;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* Name of the Country.
|
||||
*/
|
||||
public void addCountry(Country country) {
|
||||
if (_countries == null)
|
||||
_countries = new ArrayList<Country>();
|
||||
if (_countries.contains(country))
|
||||
_countries.remove(country);
|
||||
_countries.add(0, country);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return All Countries this Thing belongs to.
|
||||
*/
|
||||
public List<Country> getCountries() {
|
||||
return _countries;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param year
|
||||
*/
|
||||
public void addYear(Year year) {
|
||||
if (_years == null)
|
||||
_years = new ArrayList<Year>();
|
||||
if (!_years.contains(year))
|
||||
_years.add(year);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public List<Year> getYears() {
|
||||
return _years;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param privacyLevel
|
||||
* The privacy level of the Thing.
|
||||
*/
|
||||
public void setPrivacyLevel(ThingPrivacy privacy) {
|
||||
_privacyLevel = privacy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Privacy level of the Thing.
|
||||
*/
|
||||
public ThingPrivacy getPrivacyLevel() {
|
||||
return _privacyLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* Name of the Thing.
|
||||
*/
|
||||
public void setName(String name) {
|
||||
_name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Name of the Thing.
|
||||
*/
|
||||
public String getName() {
|
||||
if (_name == null)
|
||||
return "unknown name";
|
||||
return _name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encrypts the given password.
|
||||
*
|
||||
* @param password
|
||||
* Things password.
|
||||
*/
|
||||
public void setPassword(String password) {
|
||||
// _password = PasswordUtil.encryptPassword(password);
|
||||
_password = password;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether the given password is equal to Things password.
|
||||
*
|
||||
* @param password
|
||||
* The non-encrypted password to test.
|
||||
* @return True if passwords are equal.
|
||||
*/
|
||||
public boolean equalsEncryptedPassword(String password) {
|
||||
// return _password.equals(PasswordUtil.encryptPassword(password));
|
||||
return _password.equals(password);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hidden
|
||||
*/
|
||||
public void setHidden(boolean hidden) {
|
||||
_isHidden = Boolean.valueOf(hidden);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public Boolean isHidden() {
|
||||
return _isHidden;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The description of the Thing.
|
||||
*/
|
||||
public String getDescription() {
|
||||
if (_description == null)
|
||||
return "";
|
||||
return _description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param description
|
||||
* The description of the Thing.
|
||||
*/
|
||||
public void setDescription(String description) {
|
||||
_description = description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param imageFileName
|
||||
*/
|
||||
public void setImageFileName(String imageFileName) {
|
||||
_imageFileName = imageFileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public String getImageFileName() {
|
||||
return _imageFileName;
|
||||
}
|
||||
|
||||
public Integer getCreateDay() {
|
||||
return _createDay;
|
||||
}
|
||||
|
||||
public void setCreateDay(Integer createDay) {
|
||||
_createDay = createDay;
|
||||
}
|
||||
|
||||
public Integer getCreateMonth() {
|
||||
return _createMonth;
|
||||
}
|
||||
|
||||
public void setCreateMonth(Integer createMonth) {
|
||||
_createMonth = createMonth;
|
||||
}
|
||||
|
||||
public Integer getCreateYear() {
|
||||
return _createYear;
|
||||
}
|
||||
|
||||
public void setCreateYear(Integer createYear) {
|
||||
_createYear = createYear;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object thing) {
|
||||
return ((Thing) thing).getCode().equals(_code);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return _code;
|
||||
}
|
||||
|
||||
public void removeTags() {
|
||||
_tags = new ArrayList<Tag>();
|
||||
}
|
||||
|
||||
public void deleteImages(int[] toDeleteImageIndices) {
|
||||
for (int i = toDeleteImageIndices.length - 1; i > -1; i--) {
|
||||
_imageFileNames.remove(toDeleteImageIndices[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteSounds(int[] toDeleteSoundIndices) {
|
||||
for (int i = toDeleteSoundIndices.length - 1; i > -1; i--) {
|
||||
_soundFileNames.remove(toDeleteSoundIndices[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public String getDisplayObjectType() {
|
||||
return DisplayObjectType.THING.name();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
package com.mysema.query.grammar.hql.domain2;
|
||||
|
||||
import javax.persistence.MappedSuperclass;
|
||||
|
||||
/**
|
||||
* Each object has a timeStamp that is equivalent to the time the object has
|
||||
* been created. (see thinglink-2.0 datamodel)
|
||||
*
|
||||
*/
|
||||
@MappedSuperclass
|
||||
public class TimeStamped extends BaseEntity {
|
||||
|
||||
private Long _timeStamp;
|
||||
|
||||
/**
|
||||
* When the constructor is called, the timeStamp is created.
|
||||
*/
|
||||
public TimeStamped() {
|
||||
_timeStamp = new Long(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return timeStamp that is equivalent to the time the object has been
|
||||
* created.
|
||||
*/
|
||||
public Long getTimeStamp() {
|
||||
return _timeStamp;
|
||||
}
|
||||
|
||||
public void setTimeStamp(long timeStamp) {
|
||||
_timeStamp = new Long(timeStamp);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,504 @@
|
||||
package com.mysema.query.grammar.hql.domain2;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.ManyToMany;
|
||||
|
||||
import org.hibernate.annotations.CollectionOfElements;
|
||||
import org.hibernate.search.annotations.DocumentId;
|
||||
import org.hibernate.search.annotations.Field;
|
||||
import org.hibernate.search.annotations.Index;
|
||||
import org.hibernate.search.annotations.Indexed;
|
||||
|
||||
/**
|
||||
* A thinglink User is represented. (see thinglink-2.0 datamodel)
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Indexed
|
||||
public class User extends FeaturedItem implements IDisplayObject {
|
||||
|
||||
@Column(unique = true)
|
||||
@Field(index = Index.TOKENIZED)
|
||||
private String _name;
|
||||
|
||||
@Field(index = Index.TOKENIZED)
|
||||
private String _fullName;
|
||||
|
||||
private UserType _type;
|
||||
|
||||
@Column(length = 500)
|
||||
private String _password;
|
||||
|
||||
private String _bio;
|
||||
|
||||
@Column(length = 500)
|
||||
@Field(index = Index.TOKENIZED)
|
||||
private String _homepage;
|
||||
|
||||
@Column(length = 500)
|
||||
private String _email;
|
||||
|
||||
@Column(length = 500)
|
||||
private String _phone;
|
||||
|
||||
@Column(length = 500)
|
||||
private String _flickrUsername;
|
||||
|
||||
@Column(length = 500)
|
||||
private String _flickrId;
|
||||
|
||||
@Column(length = 500)
|
||||
private String _facebookId;
|
||||
|
||||
@Column(length = 500)
|
||||
private String _description;
|
||||
|
||||
@Column(length = 500)
|
||||
private String _imageFileName;
|
||||
|
||||
private Integer _yearOfBirthday;
|
||||
|
||||
private Integer _monthOfBirthday;
|
||||
|
||||
private Integer _dayOfBirthday;
|
||||
|
||||
@Column(length = 500)
|
||||
@Field(index = Index.TOKENIZED)
|
||||
private String _originalLocationCountry;
|
||||
|
||||
private Boolean _doChat;
|
||||
|
||||
@Column(length = 500)
|
||||
@Field(index = Index.TOKENIZED)
|
||||
private String _chatName;
|
||||
|
||||
private ChatType _chatType;
|
||||
|
||||
@Column(length = 500)
|
||||
@Field(index = Index.TOKENIZED)
|
||||
private String _location;
|
||||
|
||||
@ManyToMany
|
||||
private List<User> _friends = new ArrayList<User>();
|
||||
|
||||
@CollectionOfElements
|
||||
private List<String> _urls = new ArrayList<String>();
|
||||
|
||||
@Override
|
||||
@DocumentId
|
||||
public Long getId() {
|
||||
return _id;
|
||||
}
|
||||
|
||||
public enum UserType {
|
||||
ARTIST, COLLECTOR, CRAFTER, CURATOR, DESIGNER, DEVELOPER, ENTREPRENEUR, HOBBYIST, MAGAZINE, MISCELLANEOUS, MUSEUM, RETAILER, STUDENT, TRENDSPOTTER, OTHER, BUSINESS, MANUFACTURER, SCHOOL, TEACHER;
|
||||
}
|
||||
|
||||
public enum ChatType {
|
||||
NONE, AIM, GOOGLE, ICQ, MSN, YAHOO;
|
||||
}
|
||||
|
||||
private boolean _admin = false;
|
||||
|
||||
private String _deactivationId;
|
||||
|
||||
public User() {//
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name
|
||||
*/
|
||||
public User(String name) {
|
||||
super();
|
||||
_name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls super() to create timeStamp.
|
||||
*
|
||||
* @param name
|
||||
* Users name.
|
||||
* @param eMail
|
||||
* Users E-Mail.
|
||||
*/
|
||||
public User(String name, String eMail) {
|
||||
super();
|
||||
_name = name;
|
||||
_email = eMail;
|
||||
}
|
||||
|
||||
/**
|
||||
* Where is the User currently located?
|
||||
*
|
||||
* @param location
|
||||
*/
|
||||
public void setLocation(String location) {
|
||||
_location = location;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Where is the User currently located?
|
||||
*/
|
||||
public String getLocation() {
|
||||
return _location;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param chatType
|
||||
*/
|
||||
public void setChatType(ChatType chatType) {
|
||||
_chatType = chatType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public ChatType getChatType() {
|
||||
return _chatType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param chatName
|
||||
* @return
|
||||
*/
|
||||
public void setChatName(String chatName) {
|
||||
_chatName = chatName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public String getChatName() {
|
||||
return _chatName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param doChat
|
||||
*/
|
||||
public void doChat(Boolean doChat) {
|
||||
_doChat = doChat;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public Boolean doChat() {
|
||||
return _doChat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Where is the User born?
|
||||
*
|
||||
* @param country
|
||||
*/
|
||||
public void setOriginalLocationCountry(String country) {
|
||||
_originalLocationCountry = country;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Where is the User born?
|
||||
*/
|
||||
public String getOriginalLocationCountry() {
|
||||
return _originalLocationCountry;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fullName
|
||||
*/
|
||||
public void setFullName(String fullName) {
|
||||
_fullName = fullName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public String getFullName() {
|
||||
return _fullName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param year
|
||||
* @param month
|
||||
* @param day
|
||||
*/
|
||||
public void setBirthday(Integer year, Integer month, Integer day) {
|
||||
_yearOfBirthday = year;
|
||||
_monthOfBirthday = month;
|
||||
_dayOfBirthday = day;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public Integer getYearOfBirthday() {
|
||||
return _yearOfBirthday;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public Integer getMonthOfBirthday() {
|
||||
return _monthOfBirthday;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public Integer getDayOfBirthday() {
|
||||
return _dayOfBirthday;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encrypts the given password.
|
||||
*
|
||||
* @param password
|
||||
* Users password.
|
||||
*/
|
||||
public void setPassword(String password) {
|
||||
// _password = PasswordUtil.encryptPassword(password);
|
||||
_password = password;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param friend
|
||||
* Another user can be a friend.
|
||||
*/
|
||||
public void addFriend(User friend) {
|
||||
_friends.add(friend);
|
||||
}
|
||||
|
||||
public boolean removeFriend(User friend) {
|
||||
boolean success = _friends.remove(friend);
|
||||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return All users that are friends of this user. Null if there are no
|
||||
* friends.
|
||||
*/
|
||||
public List<User> getFriends() {
|
||||
return _friends;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param url
|
||||
*/
|
||||
public void addUrl(String url) {
|
||||
_urls.add(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public List<String> getUrls() {
|
||||
return _urls;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* Name of the user.
|
||||
*/
|
||||
public void setName(String name) {
|
||||
_name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type
|
||||
*/
|
||||
public void setType(UserType type) {
|
||||
_type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param email
|
||||
* E-Mail address of the user.
|
||||
*/
|
||||
public void setEmail(String email) {
|
||||
_email = email;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
_phone = phone;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bio
|
||||
* Users bio.
|
||||
*/
|
||||
public void setBio(String bio) {
|
||||
_bio = bio;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param homepage
|
||||
* Users homepage.
|
||||
*/
|
||||
public void setHomepage(String homepage) {
|
||||
_homepage = homepage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param flickrUsername
|
||||
* Users flickr username.
|
||||
*/
|
||||
public void setFlickrUsername(String flickrUsername) {
|
||||
_flickrUsername = flickrUsername;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Users E-Mail.
|
||||
*/
|
||||
public String getEmail() {
|
||||
return _email;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return _phone;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Users bio.
|
||||
*/
|
||||
public String getBio() {
|
||||
return _bio;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Users homepage.
|
||||
*/
|
||||
public String getHomepage() {
|
||||
return _homepage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Users name.
|
||||
*/
|
||||
public String getName() {
|
||||
return _name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Users type.
|
||||
*/
|
||||
public UserType getType() {
|
||||
return _type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Users flickr username.
|
||||
*/
|
||||
public String getFlickrUsername() {
|
||||
return _flickrUsername;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param imageFileName
|
||||
*/
|
||||
public void setImageFileName(String imageFileName) {
|
||||
_imageFileName = imageFileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public String getImageFileName() {
|
||||
return _imageFileName;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object user) {
|
||||
return (((User) user).getName().equals(_name));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return _name + " " + _email;
|
||||
}
|
||||
|
||||
// public GrantedAuthority[] getAuthorities() {
|
||||
// return new GrantedAuthority[] { new GrantedAuthorityImpl("ROLE_USER") };
|
||||
// }
|
||||
|
||||
public String getPassword() {
|
||||
return _password;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return _name;
|
||||
}
|
||||
|
||||
public boolean isAccountNonExpired() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isAccountNonLocked() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isCredentialsNonExpired() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isAdmin() {
|
||||
return _admin;
|
||||
}
|
||||
|
||||
public void setAdmin(boolean admin) {
|
||||
_admin = admin;
|
||||
}
|
||||
|
||||
public void setDeactivationId(String activationId) {
|
||||
_deactivationId = activationId;
|
||||
}
|
||||
|
||||
public String getDeactivationId() {
|
||||
return _deactivationId;
|
||||
}
|
||||
|
||||
public String getFlickrId() {
|
||||
return _flickrId;
|
||||
}
|
||||
|
||||
public void setFlickrId(String id) {
|
||||
_flickrId = id;
|
||||
}
|
||||
|
||||
public String getFacebookId() {
|
||||
return _facebookId;
|
||||
}
|
||||
|
||||
public void setFacebookId(String facebookId) {
|
||||
_facebookId = facebookId;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return _description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
_description = description;
|
||||
}
|
||||
|
||||
public String getDisplayObjectType() {
|
||||
return DisplayObjectType.USER.name();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.mysema.query.grammar.hql.domain2;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
public class Year {
|
||||
|
||||
@Id
|
||||
private Integer _year;
|
||||
|
||||
public Year() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param year
|
||||
*/
|
||||
public Year(int year) {
|
||||
_year = new Integer(year);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public Integer getYear() {
|
||||
return _year;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object year) {
|
||||
return ((Year) year).getYear().equals(_year);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user