org.kuali.student.common.ui.client.mvc
Class DataModel

java.lang.Object
  extended by org.kuali.student.common.ui.client.mvc.DataModel
All Implemented Interfaces:
Model

public class DataModel
extends Object
implements Model

Author:
Kuali Student Team

Nested Class Summary
static interface DataModel.QueryCallback<T>
           
 
Field Summary
private  HasChangeCallbacks.ChangeCallbackRegistration bridgeCallbackReg
           
private  ModelDefinition definition
           
private  com.google.gwt.event.shared.HandlerManager handlers
           
private  String modelName
           
private  String parentPath
           
private  Data root
           
private static long serialVersionUID
           
private  DataModelValidator validator
           
 
Constructor Summary
DataModel()
           
DataModel(ModelDefinition definition, Data root)
           
DataModel(String name)
           
 
Method Summary
 com.google.gwt.event.shared.HandlerRegistration addModelChangeHandler(ModelChangeHandler handler)
          Adds a ModelChangeHandler that will be invoked for ModelChangeEvents
<T> T
get(QueryPath path)
           
<T> T
get(String path)
           
 ModelDefinition getDefinition()
           
 Metadata getMetadata(QueryPath path)
           
 String getModelName()
           
 String getParentPath()
           
 Data getRoot()
           
 Data.DataType getType(QueryPath path)
           
 boolean isValidPath(String sPath)
          Checks to see if data exists for the path passed in
 Map<QueryPath,Object> query(QueryPath path)
           
 Map<QueryPath,Object> query(String path)
           
private  void queryRelative(Data branch, QueryPath path, Map<QueryPath,Object> result)
           
 void remove(QueryPath path)
           
 void resetRoot()
           
 void set(QueryPath path, Boolean value)
           
 void set(QueryPath path, Data.Value value)
           
 void set(QueryPath path, Data value)
           
 void set(QueryPath path, Date value)
           
 void set(QueryPath path, Double value)
           
 void set(QueryPath path, Float value)
           
 void set(QueryPath path, Integer value)
           
 void set(QueryPath path, Long value)
           
 void set(QueryPath path, Short value)
           
 void set(QueryPath path, String value)
           
 void setDefinition(ModelDefinition definition)
           
 void setModelName(String modelName)
           
 void setParentPath(String parentPath)
          If the root element for this is a child of another data object, then the parent path must be set to the path where this child data object can be found.
 void setRoot(Data root)
          Set the top level data for this DataModel
 void validate(Callback<List<ValidationResultInfo>> callback)
          Validates this data model against its ModelDefinition/Metadata and returns the result to the callback
 void validateField(FieldDescriptor fd, Callback<List<ValidationResultInfo>> callback)
          Validates a single field
 void validateNextState(Callback<List<ValidationResultInfo>> callback)
          Validates this data model against the next state in its ModelDefinition and returns the result to the callback
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

modelName

private String modelName

definition

private ModelDefinition definition

validator

private DataModelValidator validator

handlers

private com.google.gwt.event.shared.HandlerManager handlers

bridgeCallbackReg

private HasChangeCallbacks.ChangeCallbackRegistration bridgeCallbackReg

root

private Data root

parentPath

private String parentPath
Constructor Detail

DataModel

public DataModel()

DataModel

public DataModel(String name)

DataModel

public DataModel(ModelDefinition definition,
                 Data root)
Method Detail

getModelName

public String getModelName()

setModelName

public void setModelName(String modelName)

get

public <T> T get(QueryPath path)

get

public <T> T get(String path)

getRoot

public Data getRoot()
Returns:
the root

resetRoot

public void resetRoot()

remove

public void remove(QueryPath path)

query

public Map<QueryPath,Object> query(QueryPath path)
Parameters:
path - The path in the data model
Returns:
A map containing the path/value pairs for all matching elements, or an empty map if no matching values found.

query

public Map<QueryPath,Object> query(String path)
Parameters:
path - The path in the data model
Returns:
A map containing the path/value pairs for all matching elements, or an empty map if no matching values found.

queryRelative

private void queryRelative(Data branch,
                           QueryPath path,
                           Map<QueryPath,Object> result)
Parameters:
branch - The data branch on which to perform the query
path - The path string relative to the root of the branch
result - A map containing all matching paths and the corresponding data value. For a non-wildcard path this should return a single entry in the map of the path supplied and the corresponding value. For a path containing wildcard, an entry in the map will exist for each matching path and their corresponding values. Note: A path ending in a wild card will not match the _runtimeData element.

set

public void set(QueryPath path,
                Data value)

set

public void set(QueryPath path,
                Integer value)

set

public void set(QueryPath path,
                String value)

set

public void set(QueryPath path,
                Long value)

set

public void set(QueryPath path,
                Short value)

set

public void set(QueryPath path,
                Double value)

set

public void set(QueryPath path,
                Float value)

set

public void set(QueryPath path,
                Boolean value)

set

public void set(QueryPath path,
                Date value)

set

public void set(QueryPath path,
                Data.Value value)

getType

public Data.DataType getType(QueryPath path)

getMetadata

public Metadata getMetadata(QueryPath path)

setRoot

public void setRoot(Data root)
Set the top level data for this DataModel

Parameters:
root - the root to set

addModelChangeHandler

public com.google.gwt.event.shared.HandlerRegistration addModelChangeHandler(ModelChangeHandler handler)
Description copied from interface: Model
Adds a ModelChangeHandler that will be invoked for ModelChangeEvents

Specified by:
addModelChangeHandler in interface Model
Parameters:
handler - the handler to add
Returns:
HandlerRegistration that can be used to unregister the handler later

getDefinition

public ModelDefinition getDefinition()

setDefinition

public void setDefinition(ModelDefinition definition)

getParentPath

public String getParentPath()

setParentPath

public void setParentPath(String parentPath)
If the root element for this is a child of another data object, then the parent path must be set to the path where this child data object can be found.

Parameters:
parentPath -

validate

public void validate(Callback<List<ValidationResultInfo>> callback)
Validates this data model against its ModelDefinition/Metadata and returns the result to the callback

Parameters:
callback -

validateNextState

public void validateNextState(Callback<List<ValidationResultInfo>> callback)
Validates this data model against the next state in its ModelDefinition and returns the result to the callback

Parameters:
callback -

validateField

public void validateField(FieldDescriptor fd,
                          Callback<List<ValidationResultInfo>> callback)
Validates a single field

Parameters:
fd -
callback -

isValidPath

public boolean isValidPath(String sPath)
Checks to see if data exists for the path passed in

Parameters:
sPath -
Returns:


Copyright © 2007-2011 The Kuali Foundation. All Rights Reserved.