T
- public class ReadOnlyWrapper<T extends Model> extends Object implements ModelController<T>
Constructor and Description |
---|
ReadOnlyWrapper(ModelController<T> original) |
Modifier and Type | Method and Description |
---|---|
List<T> |
all()
Return a list of all objects.
|
int |
countForKey(String keyName,
Object value)
Counts the items for a indexed/keyed field.
|
T |
detach(T obj)
Gets a cloned version of an object, so that you can work with the object with out affecting
the live, in memory version
|
FilterChain<T> |
filter(String name,
Object value)
Create a new FilterChain and set an initial filter whereby
the field @name is equal to @value
|
FilterChain<T> |
filter(String name,
Object value,
String op)
Create a new FilterChain and initialize with an initial filter.
|
FilterChain<T> |
filterBy(String name,
Object value,
FilterOperator op)
Create a new FilterChain and initialize with an initial filter.
|
FilterChain<T> |
filterByKey(String keyName,
Object value)
Instantiate a filter chain and start by filtering on an index/keyed field.
|
FilterChain<T> |
filterChain()
Create a new FilterChain instance for this controller.
|
T |
forId(Long id)
Loads an object by primary id.
|
T |
forIdWithDeleted(Long id)
Get the object by id.
|
T |
forUniqueKey(String keyName,
Object value)
Look up an object by a unique key.
|
String |
getBucket()
A name by which this controller gets accessed when it is accessed via a template,
or via DalRegistry.instance().get("bucketName").
|
Set<String> |
getKeyFields()
Get all model field names that were marked as indexed/keyed using the @Key
annotation on the getter
|
Class<T> |
getModelClass()
The Model class this controller manages.
|
Persister<T> |
getPersister()
The instance of the Perister class
|
ReadOnlyWrapper<T> |
getReadonlyWrapper()
Gets a controller implementation that wraps this controller, while stubbing out
all the write methods.
|
Stash<T> |
getStash()
The instance of the Stash class.
|
Set<String> |
getUniqueFields()
Get all model field names that were marked as a unique key using the @UniqueKey
annotation on the getter.
|
void |
hardDelete(T obj)
Actually removes the item from the underlying data store
|
void |
init(DataAccessRegistration registration,
Persister<T> persister,
Stash<T> stash)
Initialize the controller, loading all the key fields, setting defaults,
initializing key variables, etc.
|
Boolean |
isWritable()
True if this controller can create or update objects, false if this
controller is read-only.
|
List<T> |
listForKey(String keyName,
Object value)
Get all items for a indexed/keyed field.
|
void |
onPostCreate(T obj)
Override this to perform some action after the object is created.
|
void |
onPostLoadItem(T obj)
Override this to perform some action after an item is loaded from the datastore
|
void |
onPostSave(T obj)
Override this to perform some action after the object is saved
|
void |
onPreCreatePrepare(T obj)
Override this to prepare the object with any default values before it is
saved to the datastore for the first time.
|
void |
onPreCreateValidate(T obj)
Override this to prepare the validate the object before it is saved to the datastore
for the very first time.
|
void |
onPreRead() |
void |
onPreSavePrepare(T obj)
Override this to perform an action every time before the object is saved.
|
void |
onPreSaveValidate(T obj)
Override this to validate the object before it is saved.
|
T |
originalForId(Long id)
Load an object by id, without detaching it.
|
T |
originalForId(T id)
Load an object by id, without detaching it.
|
void |
reset()
If the datastore has been synced to memory, reset() will resync everything.
|
void |
save(T obj)
Saves "obj" to the persistence layer, creating it if it does not exist.
|
void |
softDelete(T obj)
Calls obj.setDeleted(true) then saves the object.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
anyOf, anyOf, find, forIdOrNotFound, forUniqueKeyOrNotFound, onPostSaveAuditTrailLog, search, update, updateValues
public ReadOnlyWrapper(ModelController<T> original)
public void init(DataAccessRegistration registration, Persister<T> persister, Stash<T> stash)
ModelController
init
in interface ModelController<T extends Model>
public String getBucket()
ModelController
getBucket
in interface ModelController<T extends Model>
public T detach(T obj)
ModelController
detach
in interface ModelController<T extends Model>
public void save(T obj)
ModelController
save
in interface ModelController<T extends Model>
public void softDelete(T obj)
ModelController
softDelete
in interface ModelController<T extends Model>
public void hardDelete(T obj)
ModelController
hardDelete
in interface ModelController<T extends Model>
public void onPreRead()
onPreRead
in interface ModelController<T extends Model>
public void onPreSavePrepare(T obj)
ModelController
onPreSavePrepare
in interface ModelController<T extends Model>
public void onPreSaveValidate(T obj)
ModelController
onPreSaveValidate
in interface ModelController<T extends Model>
public void onPreCreatePrepare(T obj)
ModelController
onPreCreatePrepare
in interface ModelController<T extends Model>
public void onPreCreateValidate(T obj)
ModelController
onPreCreateValidate
in interface ModelController<T extends Model>
public void onPostSave(T obj)
ModelController
onPostSave
in interface ModelController<T extends Model>
public void onPostCreate(T obj)
ModelController
onPostCreate
in interface ModelController<T extends Model>
public void onPostLoadItem(T obj)
ModelController
onPostLoadItem
in interface ModelController<T extends Model>
public FilterChain<T> filterChain()
ModelController
filterChain
in interface ModelController<T extends Model>
public FilterChain<T> filter(String name, Object value)
ModelController
filter
in interface ModelController<T extends Model>
public FilterChain<T> filter(String name, Object value, String op)
ModelController
filter
in interface ModelController<T extends Model>
public FilterChain<T> filterBy(String name, Object value, FilterOperator op)
ModelController
filterBy
in interface ModelController<T extends Model>
public FilterChain<T> filterByKey(String keyName, Object value)
ModelController
filterByKey
in interface ModelController<T extends Model>
public T forIdWithDeleted(Long id)
ModelController
forIdWithDeleted
in interface ModelController<T extends Model>
public T originalForId(T id)
ModelController
originalForId
in interface ModelController<T extends Model>
public T forId(Long id)
ModelController
forId
in interface ModelController<T extends Model>
public T originalForId(Long id)
ModelController
originalForId
in interface ModelController<T extends Model>
public T forUniqueKey(String keyName, Object value)
ModelController
forUniqueKey
in interface ModelController<T extends Model>
public List<T> listForKey(String keyName, Object value)
ModelController
listForKey
in interface ModelController<T extends Model>
public int countForKey(String keyName, Object value)
ModelController
countForKey
in interface ModelController<T extends Model>
public Set<String> getKeyFields()
ModelController
getKeyFields
in interface ModelController<T extends Model>
public Set<String> getUniqueFields()
ModelController
getUniqueFields
in interface ModelController<T extends Model>
public List<T> all()
ModelController
all
in interface ModelController<T extends Model>
public Persister<T> getPersister()
ModelController
getPersister
in interface ModelController<T extends Model>
public Stash<T> getStash()
ModelController
getStash
in interface ModelController<T extends Model>
public Class<T> getModelClass()
ModelController
getModelClass
in interface ModelController<T extends Model>
public Boolean isWritable()
ModelController
isWritable
in interface ModelController<T extends Model>
public void reset()
ModelController
reset
in interface ModelController<T extends Model>
public ReadOnlyWrapper<T> getReadonlyWrapper()
ModelController
getReadonlyWrapper
in interface ModelController<T extends Model>
Copyright © 2016. All rights reserved.