Commits

vmorsiani committed 586773f

replaced BaseEntity interface by spring-data AbstractPersistable

Comments (0)

Files changed (10)

jticketing-core/src/main/java/org/wanna/jticketing/persistence/entity/BaseEntity.java

-package org.wanna.jticketing.persistence.entity;
-
-public interface BaseEntity<PK> {
-    PK getId();
-    String toString();
-    boolean equals(Object o);
-    int hashCode();
-}

jticketing-core/src/main/java/org/wanna/jticketing/persistence/entity/PrivilegeEntity.java

 package org.wanna.jticketing.persistence.entity;
 
 import org.apache.commons.lang.builder.ToStringBuilder;
+import org.springframework.data.jpa.domain.AbstractPersistable;
 import org.springframework.security.core.GrantedAuthority;
 
 import javax.persistence.*;
 
 @Entity
 @Table(name = "privileges")
-public class PrivilegeEntity implements BaseEntity<Long>,GrantedAuthority{
+public class PrivilegeEntity extends AbstractPersistable<Long> implements GrantedAuthority{
     @Id
     @GeneratedValue(strategy = GenerationType.AUTO)
     private Long id;

jticketing-core/src/main/java/org/wanna/jticketing/persistence/entity/TicketCategoryEntity.java

 package org.wanna.jticketing.persistence.entity;
 
 import org.apache.commons.lang.builder.ToStringBuilder;
+import org.springframework.data.jpa.domain.AbstractPersistable;
 
 import javax.persistence.*;
 
 @Entity
 @Table(name="ticket_categories")
-public class TicketCategoryEntity implements BaseEntity<Long>{
+public class TicketCategoryEntity extends AbstractPersistable<Long> {
     @Id
     @GeneratedValue(strategy = GenerationType.AUTO)
     private Long id;

jticketing-core/src/main/java/org/wanna/jticketing/persistence/entity/TicketEntity.java

 package org.wanna.jticketing.persistence.entity;
 
 import org.apache.commons.lang.builder.ToStringBuilder;
+import org.springframework.data.jpa.domain.AbstractPersistable;
 
 import javax.persistence.*;
 import java.util.HashSet;
 
 @Entity
 @Table(name = "tickets")
-public class TicketEntity implements BaseEntity<Long>{
+public class TicketEntity extends AbstractPersistable<Long>{
     @Id
     @GeneratedValue(strategy = GenerationType.AUTO)
     private Long id;

jticketing-core/src/main/java/org/wanna/jticketing/persistence/entity/TicketMessageEntity.java

 package org.wanna.jticketing.persistence.entity;
 
+import org.springframework.data.jpa.domain.AbstractPersistable;
+
 import javax.persistence.*;
 
 @Entity
 @Table(name="messages")
-public class TicketMessageEntity implements BaseEntity<Long>{
+public class TicketMessageEntity extends AbstractPersistable<Long> {
     @Id
     @GeneratedValue(strategy = GenerationType.AUTO)
     private Long id;

jticketing-core/src/main/java/org/wanna/jticketing/persistence/entity/TicketStatusEntity.java

 package org.wanna.jticketing.persistence.entity;
 
 import org.apache.commons.lang.builder.ToStringBuilder;
+import org.springframework.data.jpa.domain.AbstractPersistable;
 
 import javax.persistence.*;
 
 @Entity
 @Table(name="ticket_status")
-public class TicketStatusEntity implements BaseEntity<Long>{
+public class TicketStatusEntity extends AbstractPersistable<Long> {
     @Id
     @GeneratedValue(strategy = GenerationType.AUTO)
     private Long id;

jticketing-core/src/main/java/org/wanna/jticketing/persistence/entity/UserEntity.java

 package org.wanna.jticketing.persistence.entity;
 
 import org.apache.commons.lang.builder.*;
+import org.springframework.data.jpa.domain.AbstractPersistable;
 import org.springframework.security.core.userdetails.UserDetails;
 
 import javax.persistence.*;
 
 @Entity
 @Table(name = "users")
-public class UserEntity implements BaseEntity<Long>,UserDetails{
+public class UserEntity extends AbstractPersistable<Long> implements UserDetails{
     @Id
     @GeneratedValue(strategy = GenerationType.AUTO)
     private Long id;

jticketing-core/src/main/java/org/wanna/jticketing/persistence/entity/UserGroupEntity.java

 package org.wanna.jticketing.persistence.entity;
 
 import org.apache.commons.lang.builder.ToStringBuilder;
+import org.springframework.data.jpa.domain.AbstractPersistable;
 
 import javax.persistence.*;
 import java.util.Set;
 
 @Entity
 @Table(name="groups")
-public class UserGroupEntity implements BaseEntity<Long>{
+public class UserGroupEntity extends AbstractPersistable<Long> {
     @Id
     @GeneratedValue(strategy = GenerationType.AUTO)
     private Long id;

jticketing-webapp/src/main/java/org/wanna/jticketing/web/faces/converter/entity/AbstractEntityConverter.java

 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.springframework.web.jsf.FacesContextUtils;
-import org.wanna.jticketing.persistence.entity.BaseEntity;
+import org.springframework.data.jpa.domain.AbstractPersistable;
 
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
 import javax.persistence.EntityManager;
 import javax.persistence.EntityManagerFactory;
 
 public abstract class AbstractEntityConverter extends AbstractSpringAwareConverter {
-    private Class<? extends BaseEntity> clazz;
+    private Class<? extends AbstractPersistable> clazz;
     public final Log LOG = LogFactory.getLog(this.getClass());
 
-    public AbstractEntityConverter(Class<? extends BaseEntity> clazz){
+    public AbstractEntityConverter(Class<? extends AbstractPersistable> clazz){
         this.clazz = clazz;
     }
 
         LOG.trace("converting "+clazz.getSimpleName()+" getAsObject for id "+(value==null?"null":value));
         if(value == null) return null;
         long id = Long.parseLong(value);
-        BaseEntity object =  getEntityManager(context).find(clazz,id);
+        AbstractPersistable object =  getEntityManager(context).find(clazz,id);
         LOG.trace("converting "+clazz.getSimpleName()+" found "+(object == null?"none":object.toString()+"with id "+object.getId()));
         return object;
     }
         LOG.trace("converting "+clazz.getSimpleName()+" getAsObject for object "+(value==null?"null":value.toString()));
         if(value == null) return null;
 
-        return String.valueOf(((BaseEntity)value).getId());
+        return String.valueOf(((AbstractPersistable)value).getId());
     }
 
     private EntityManager getEntityManager(FacesContext context){

jticketing-webapp/src/main/java/org/wanna/jticketing/web/faces/converter/entity/TicketReferenceConverter.java

 package org.wanna.jticketing.web.faces.converter.entity;
 
-import org.wanna.jticketing.persistence.entity.BaseEntity;
 import org.wanna.jticketing.persistence.entity.TicketEntity;
 import org.wanna.jticketing.persistence.service.ticket.TicketService;