E
- public class DefaultEventsService<E extends AbstractEvent> extends Object implements EventsService<E>
EventsService
Constructor and Description |
---|
DefaultEventsService() |
Modifier and Type | Method and Description |
---|---|
List<DateRange> |
compliment(DateRange e1,
DateRange e2)
|
boolean |
contains(DateRange e1,
DateRange e2)
Check if e1 contains e2 completely
|
Long |
count(Query<E> query)
|
long |
daysDiff(DateRange range,
boolean normalizeTime,
boolean factorDayStartNotMidNight)
Calculate number of days difference.
Note on Time Zone : It is very important to note that both the date should have the same JVM Time-Zone set in the Date. |
void |
delete(E event) |
Long |
delete(Long id)
A special Delete operation on the entity that will remove the entity and related entities based on id.
|
<ED extends EventsDao<E>> |
getDao() |
float |
getDayStartHours()
Like Check in time
|
E |
getEntityInstance()
The entity instance maybe an extension of the Base ensure Queries work for extensions
derive the exact instance required for the Query.
|
DateRange |
intersection(DateRange e1,
DateRange e2)
Get the intersection (as an Event) between 2 Events.
|
E |
load(Object objectId) |
E |
load(Object objectId,
Class entityClass)
In some situations the DAO represents an Interface or perhaps a parent of the actual Entity./
The exact type of the entity would have to be Supplied.
|
boolean |
overlaps(DateRange e1,
DateRange e2)
Check if 2 Date Ranges Overlap
|
List<E> |
query(Query<E> query)
|
<SUB_T> List<SUB_T> |
query(Query<E> query,
Class<SUB_T> claz)
Derive a SubSet (claz) of T only as an queried entity.
|
List |
query(String ql,
String dialect,
Object... params)
Execute a raw Query in the native implementation language.
|
Page |
query(String ql,
String dialect,
PageInfo pageInfo,
Object... params)
Execute a raw Query in the native implementation language.
|
Page<E> |
queryPage(Query<E> query)
|
<S> Page<S> |
queryPage(Query<E> query,
Class<S> claz)
Derive a SubSet (claz) of T only as an queried entity.
|
E |
save(E event) |
void |
setDao(EventsDao<E> dao) |
int |
update(String query,
boolean isNative,
Object... params)
An Update query with optional params
|
protected EventsDao<E extends AbstractEvent> dao
public float getDayStartHours()
public long daysDiff(DateRange range, boolean normalizeTime, boolean factorDayStartNotMidNight)
daysDiff
in interface EventsService<E extends AbstractEvent>
range
- as DateRangenormalizeTime
- as boolean, if true will ignore any time settings.factorDayStartNotMidNight
- as boolean, if true will factor in getDayStartHours()
If the day is not to be considered from midnight. Depends on getDayStartHours()
. Useful like check-in time in Hotel situations.public DateRange intersection(DateRange e1, DateRange e2)
|e1S<-----x--------->e1E| |e2S<---------y----->e2E|This function will calculate (x,y) in the above scenario.
intersection
in interface EventsService<E extends AbstractEvent>
e1
- as DateRange
e2
- as DateRange
AbstractEvent
part. If e1 is not overlapping with e2 at all, it will throw an IllegalArgumentException
.public boolean overlaps(DateRange e1, DateRange e2)
overlaps
in interface EventsService<E extends AbstractEvent>
e1
- as DateRange
e2
- as DateRange
public boolean contains(DateRange e1, DateRange e2)
contains
in interface EventsService<E extends AbstractEvent>
e1
- as DateRange
e2
- as DateRange
public List<DateRange> compliment(DateRange e1, DateRange e2)
compliment
in interface EventsService<E extends AbstractEvent>
e1
- as DateRange
e2
- as DateRange
public List<E> query(Query<E> query) throws Exception
QueryableDao
Query
and on Queryable
fields only.
Queryable
fields will face problems.query
in interface QueryableDao<E extends AbstractEvent>
query
- as Queryable
Exception
public Page<E> queryPage(Query<E> query) throws Exception
QueryableDao
Query
and on Queryable
fields only.
Query.setNullSet(Set)
Queryable
fields will face problems.queryPage
in interface QueryableDao<E extends AbstractEvent>
query
- as Queryable
Exception
public Long count(Query<E> query) throws Exception
QueryableDao
Query
and on Queryable
fields only.
Query.setNullSet(Set)
Queryable
fields will face problems.count
in interface QueryableDao<E extends AbstractEvent>
query
- as Queryable
Exception
public <SUB_T> List<SUB_T> query(Query<E> query, Class<SUB_T> claz) throws Exception
QueryableDao
query
in interface QueryableDao<E extends AbstractEvent>
query
- as Query
claz
- as Class
Exception
public <S> Page<S> queryPage(Query<E> query, Class<S> claz) throws Exception
QueryableDao
queryPage
in interface QueryableDao<E extends AbstractEvent>
query
- as Query
claz
- as Class
Exception
public E getEntityInstance()
QueryableDao
getEntityInstance
in interface QueryableDao<E extends AbstractEvent>
public E save(E event)
save
in interface GenericDao<E extends AbstractEvent>
public void delete(E event)
delete
in interface GenericDao<E extends AbstractEvent>
public Long delete(Long id)
GenericDao
delete
in interface GenericDao<E extends AbstractEvent>
Long
public E load(Object objectId, Class entityClass)
GenericDao
load
in interface GenericDao<E extends AbstractEvent>
objectId
- as Id for EntityentityClass
- as Class
of entitypublic E load(Object objectId)
load
in interface GenericDao<E extends AbstractEvent>
public List query(String ql, String dialect, Object... params) throws Exception
FreeQuery
query
in interface FreeQuery
ql
- as String in native Schema languagedialect
- as String. NULL or empty or "NATIVE" implies NATIVE, "JPA" implies JPA will be used. Additional dialects can be supported but they will be implementation dependent.params
- as Query parameters to the string.
List
Exception
public Page query(String ql, String dialect, PageInfo pageInfo, Object... params) throws Exception
FreeQuery
query
in interface FreeQuery
ql
- as String in native Schema languagedialect
- as String. NULL or empty or "NATIVE" implies NATIVE, "JPA" implies JPA will be used. Additional dialects can be supported but they will be implementation dependent.pageInfo
- as PageInfo
for pagination of resultparams
- as Query parameters to the string
Page
Exception
public int update(String query, boolean isNative, Object... params)
FreeQuery
public <ED extends EventsDao<E>> ED getDao()
getDao
in interface EventsService<E extends AbstractEvent>
public void setDao(EventsDao<E> dao)
setDao
in interface EventsService<E extends AbstractEvent>
Copyright © 2018. All rights reserved.