BrightSide Workbench Full Report + Source Code
org.turro.jpa.entity.DaoEntity< T extends IDaoEntity, ID extends Serializable > Class Template Referenceabstract
Inheritance diagram for org.turro.jpa.entity.DaoEntity< T extends IDaoEntity, ID extends Serializable >:
Collaboration diagram for org.turro.jpa.entity.DaoEntity< T extends IDaoEntity, ID extends Serializable >:

Public Member Functions

 DaoEntity ()
 
 DaoEntity (Class< T > persistentClass)
 
 DaoEntity (T entity)
 
Dao getDao ()
 
getEntity ()
 
IElephantEntity getIee ()
 
find (ID id)
 
save ()
 
boolean delete ()
 
ID getId ()
 
List< String > getMessages ()
 
boolean canDelete ()
 
boolean canSave ()
 
boolean equals (Object obj)
 
int hashCode ()
 

Static Public Member Functions

static Object getEntityId (Object entity)
 
static boolean isNewId (Object id)
 

Protected Member Functions

abstract Dao createDao ()
 
abstract boolean shouldLog ()
 
void logEntity (SystemLogType logType, Object entity, String action, String data)
 
String dataEntity (Object entity)
 
void initOperation ()
 
void addMessage (String message)
 

Protected Attributes

entity
 
ID id
 
List< String > messages = new ArrayList<>()
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g
Parameters
<T>
<ID>

Definition at line 41 of file DaoEntity.java.

Constructor & Destructor Documentation

◆ DaoEntity() [1/3]

org.turro.jpa.entity.DaoEntity< T extends IDaoEntity, ID extends Serializable >.DaoEntity ( )

Definition at line 49 of file DaoEntity.java.

49  {
50  this.persistentClass = (Class<T>) ((ParameterizedType) getClass()
51  .getGenericSuperclass()).getActualTypeArguments()[0];
52  }
Here is the caller graph for this function:

◆ DaoEntity() [2/3]

org.turro.jpa.entity.DaoEntity< T extends IDaoEntity, ID extends Serializable >.DaoEntity ( Class< T >  persistentClass)

Definition at line 54 of file DaoEntity.java.

54  {
55  this.persistentClass = persistentClass;
56  }

◆ DaoEntity() [3/3]

org.turro.jpa.entity.DaoEntity< T extends IDaoEntity, ID extends Serializable >.DaoEntity ( entity)

Definition at line 58 of file DaoEntity.java.

58  {
59  this.entity = entity;
60  this.persistentClass = (Class<T>) entity.getClass();
61  }

Member Function Documentation

◆ addMessage()

void org.turro.jpa.entity.DaoEntity< T extends IDaoEntity, ID extends Serializable >.addMessage ( String  message)
protected

Definition at line 149 of file DaoEntity.java.

149  {
150  messages.add(message);
151  }

◆ canDelete()

◆ canSave()

boolean org.turro.jpa.entity.DaoEntity< T extends IDaoEntity, ID extends Serializable >.canSave ( )

Reimplemented in org.turro.crm.zul.sale.SaleProspectWrapper, org.turro.crm.zul.sale.CampaignWrapper, org.turro.financials.product.logic.ProductWrapper, and org.turro.financials.model.product.ProductWrapper.

Definition at line 141 of file DaoEntity.java.

141  {
142  return !entity.isEmpty();
143  }
Here is the caller graph for this function:

◆ createDao()

◆ dataEntity()

String org.turro.jpa.entity.DaoEntity< T extends IDaoEntity, ID extends Serializable >.dataEntity ( Object  entity)
protected

Definition at line 129 of file DaoEntity.java.

129  {
130  String entityData = Stubs.json(entity);
131  if(Jsons.isEmpty(entityData)) {
132  entityData = new XMLSerializer(entity).data();
133  }
134  return entityData;
135  }
Here is the caller graph for this function:

◆ delete()

boolean org.turro.jpa.entity.DaoEntity< T extends IDaoEntity, ID extends Serializable >.delete ( )

Reimplemented in org.turro.dossier.issue.IssueWrapper, org.turro.dossier.dossier.DossierWrapper, org.turro.crm.zul.vendor.VendorWrapper, org.turro.crm.zul.sale.SaleProspectWrapper, org.turro.contacts.form.ContactWrapper, org.turro.financials.model.document.DocumentWrapper, and org.turro.financials.model.business.CompanyWrapper.

Definition at line 99 of file DaoEntity.java.

99  {
100  initOperation();
101  if(entity != null && canDelete()) {
102  entity.prepareDelete();
103  logEntity(SystemLogType.LOG_INFO, entity, "deleted", dataEntity(entity));
105  return true;
106  }
107  return false;
108  }
void deleteObject(Object obj)
Definition: Dao.java:162
String dataEntity(Object entity)
Definition: DaoEntity.java:129
void logEntity(SystemLogType logType, Object entity, String action, String data)
Definition: DaoEntity.java:123
Here is the call graph for this function:
Here is the caller graph for this function:

◆ equals()

boolean org.turro.jpa.entity.DaoEntity< T extends IDaoEntity, ID extends Serializable >.equals ( Object  obj)

Definition at line 154 of file DaoEntity.java.

154  {
155  if (obj == null) {
156  return false;
157  }
158  if (getClass() != obj.getClass() && entity.getClass() != obj.getClass()) {
159  return false;
160  }
161  if(obj.equals(entity)) {
162  return true;
163  }
164  if(obj instanceof DaoEntity && ((DaoEntity) obj).getEntity().equals(entity)) {
165  return true;
166  }
167  return (getId() == null && obj == null) ||
168  (getId() != null && (obj instanceof DaoEntity) && getId().equals(((DaoEntity) obj).getId()));
169  }
boolean equals(Object obj)
Definition: DaoEntity.java:154
Here is the call graph for this function:
Here is the caller graph for this function:

◆ find()

T org.turro.jpa.entity.DaoEntity< T extends IDaoEntity, ID extends Serializable >.find ( ID  id)

Definition at line 82 of file DaoEntity.java.

82  {
83  this.id = id;
84  entity = getDao().find(persistentClass, id);
85  return entity;
86  }
Here is the call graph for this function:

◆ getDao()

Dao org.turro.jpa.entity.DaoEntity< T extends IDaoEntity, ID extends Serializable >.getDao ( )

Definition at line 63 of file DaoEntity.java.

63  {
64  if(dao == null) {
65  dao = createDao();
66  }
67  return dao;
68  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getEntity()

T org.turro.jpa.entity.DaoEntity< T extends IDaoEntity, ID extends Serializable >.getEntity ( )

Definition at line 70 of file DaoEntity.java.

70  {
71  return entity;
72  }
Here is the caller graph for this function:

◆ getEntityId()

static Object org.turro.jpa.entity.DaoEntity< T extends IDaoEntity, ID extends Serializable >.getEntityId ( Object  entity)
static

Definition at line 176 of file DaoEntity.java.

176  {
177  if(entity != null) {
178  return Beans.of(entity).silentGetter(f -> f.isAnnotationPresent(Id.class));
179  }
180  return null;
181  }

◆ getId()

ID org.turro.jpa.entity.DaoEntity< T extends IDaoEntity, ID extends Serializable >.getId ( )

Definition at line 110 of file DaoEntity.java.

110  {
111  if(entity == null) {
112  id = null;
113  } else if(id == null) {
114  id = (ID) Beans.of(entity).silentGetter(f -> f.isAnnotationPresent(Id.class));
115  }
116  return id;
117  }
Here is the caller graph for this function:

◆ getIee()

IElephantEntity org.turro.jpa.entity.DaoEntity< T extends IDaoEntity, ID extends Serializable >.getIee ( )

Definition at line 74 of file DaoEntity.java.

74  {
75  return Entities.getController(entity);
76  }
Here is the call graph for this function:

◆ getMessages()

List<String> org.turro.jpa.entity.DaoEntity< T extends IDaoEntity, ID extends Serializable >.getMessages ( )

Definition at line 119 of file DaoEntity.java.

119  {
120  return messages;
121  }

◆ hashCode()

int org.turro.jpa.entity.DaoEntity< T extends IDaoEntity, ID extends Serializable >.hashCode ( )

Definition at line 172 of file DaoEntity.java.

172  {
173  return getId() == null ? 0 : getId().hashCode();
174  }
Here is the call graph for this function:

◆ initOperation()

void org.turro.jpa.entity.DaoEntity< T extends IDaoEntity, ID extends Serializable >.initOperation ( )
protected

Definition at line 145 of file DaoEntity.java.

145  {
146  messages.clear();
147  }
Here is the caller graph for this function:

◆ isNewId()

static boolean org.turro.jpa.entity.DaoEntity< T extends IDaoEntity, ID extends Serializable >.isNewId ( Object  id)
static

Definition at line 183 of file DaoEntity.java.

183  {
184  if(id instanceof String) {
185  return Strings.isBlank((String) id);
186  } else if(id instanceof Long) {
187  return ((Long) id) == 0L;
188  }
189  return true;
190  }
Here is the caller graph for this function:

◆ logEntity()

void org.turro.jpa.entity.DaoEntity< T extends IDaoEntity, ID extends Serializable >.logEntity ( SystemLogType  logType,
Object  entity,
String  action,
String  data 
)
protected

Definition at line 123 of file DaoEntity.java.

123  {
124  if(shouldLog()) {
125  SystemLogger.type(logType).entity(entity).comment(action).object(data).log();
126  }
127  }
abstract boolean shouldLog()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ save()

◆ shouldLog()

Member Data Documentation

◆ entity

T org.turro.jpa.entity.DaoEntity< T extends IDaoEntity, ID extends Serializable >.entity
protected

Definition at line 45 of file DaoEntity.java.

◆ id

ID org.turro.jpa.entity.DaoEntity< T extends IDaoEntity, ID extends Serializable >.id
protected

Definition at line 46 of file DaoEntity.java.

◆ messages

List<String> org.turro.jpa.entity.DaoEntity< T extends IDaoEntity, ID extends Serializable >.messages = new ArrayList<>()
protected

Definition at line 47 of file DaoEntity.java.


The documentation for this class was generated from the following file: