org.kuali.student.common.assembly.dictionary
Class MetadataServiceImpl

java.lang.Object
  extended by org.kuali.student.common.assembly.dictionary.MetadataServiceImpl
Direct Known Subclasses:
ProgramMetadataServiceImpl

public class MetadataServiceImpl
extends Object

This class provides metadata lookup for service dto objects.

Author:
Kuali Student Team

Nested Class Summary
private static class MetadataServiceImpl.RecursionCounter
           
 
Field Summary
private  Map<String,DictionaryService> dictionaryServiceMap
           
(package private)  Logger LOG
           
private  List<UILookupConfig> lookupObjectStructures
           
private  String uiLookupContext
           
 
Constructor Summary
MetadataServiceImpl()
           
MetadataServiceImpl(DictionaryService... dictionaryServices)
          Create a metadata service initializing it with all known dictionary services
 
Method Summary
private  void addLookupstoMetadata(String objectKey, Metadata metadata, String type)
           
private  String calcSimpleName(String objectKey)
           
protected  Data.Value convertDefaultValue(Data.DataType dataType, Object value)
          Convert Object value to respective DataType.
protected  Data.Value convertDefaultValue(Object value)
           
protected  Data.DataType convertDictionaryDataType(DataType dataType)
           
protected  List<ConstraintMetadata> getConstraints(FieldDefinition fd, String type, String state, String nextState, String workflowNode, String documentTypeName)
           
 Metadata getMetadata(String objectKey)
          This method gets the metadata for the given object key for state DRAFT.
 Metadata getMetadata(String objectKey, String state)
          This method gets the metadata for the given object key and state
 Metadata getMetadata(String objectKey, String type, String state)
          This method gets the metadata for the given object key, type and state
 Metadata getMetadata(String objectKey, String type, String state, String nextState, String documentTypeName)
          This method gets the metadata for the given object key, type, state and nextState
 Metadata getMetadataByWorkflowNode(String objectKey, String workflowNode, String documentTypeName)
          This method gets the metadata for the given object id key, workflowNode and documentTypeName
protected  Metadata getMetadataFromDictionaryService(String objectKey, String type, String state, String nextState, String workflowNode, String documentTypeName)
          This invokes the appropriate dictionary service to get the object structure and then converts it to a metadata structure.
protected  ObjectStructureDefinition getObjectStructure(String objectKey)
          This method gets the object structure for given objectKey from a dictionaryService
private static String[] getPathTokens(String fieldPath)
           
private  Map<String,Metadata> getProperties(ObjectStructureDefinition objectStructure, String type, String state, String nextState, String workflowNode, MetadataServiceImpl.RecursionCounter counter, String documentTypeName)
          This method is used to convert a list of dictionary fields into metadata properties
private  void init()
           
protected  boolean isRepeating(FieldDefinition fd)
          This method determines if a field is repeating
private  boolean isWorkflowNodeFirstConstraintValue(String workflowNode, List<Object> values)
           
private  LookupMetadata mapLookupDatatoMeta(UILookupData lookupData)
           
private  LookupParamMetadata mapLookupParamMetadata(CommonLookupParam param)
           
private  boolean matchesObjectKey(String objectKey, String path)
           
private  boolean matchesType(String paramType, String lookupType)
           
protected  void processCaseConstraint(ConstraintMetadata constraintMetadata, CaseConstraint caseConstraint, String type, String state, String nextState, String workflowNode)
          Currently this only handles requiredness indicators for case constraints with the following field paths: type, state, and proposal/workflowNode
private  void processRequiredByNodeCaseConstraint(ConstraintMetadata constraintMetadata, CaseConstraint caseConstraint, String workflowNode)
          Modifies the constraintMetadata to add required to save or required to approve constraints based on the workflow route node the proposal is currently in.
private  void processStateCaseConstraint(ConstraintMetadata constraintMetadata, CaseConstraint caseConstraint, String type, String state, String nextState, String workflowNode)
          Processes a case constraint with field path of state.
private  void processTypeCaseConstraint(ConstraintMetadata constraintMetadata, CaseConstraint caseConstraint, String type, String state, String nextState, String workflowNode)
          Process a case constraint with fieldPath of type
 void setDictionaryServices(List<DictionaryService> dictionaryServices)
           
 void setUiLookupContext(String uiLookupContext)
           
protected  void updateConstraintMetadata(ConstraintMetadata constraintMetadata, Constraint constraint, String type, String state, String nextState, String workflowNode)
          This updates the constraintMetadata with defintions from the dictionary constraint field.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

final Logger LOG

dictionaryServiceMap

private Map<String,DictionaryService> dictionaryServiceMap

lookupObjectStructures

private List<UILookupConfig> lookupObjectStructures

uiLookupContext

private String uiLookupContext
Constructor Detail

MetadataServiceImpl

public MetadataServiceImpl()

MetadataServiceImpl

public MetadataServiceImpl(DictionaryService... dictionaryServices)
Create a metadata service initializing it with all known dictionary services

Parameters:
dictionaryServices -
Method Detail

setDictionaryServices

public void setDictionaryServices(List<DictionaryService> dictionaryServices)

getMetadata

public Metadata getMetadata(String objectKey,
                            String type,
                            String state,
                            String nextState,
                            String documentTypeName)
This method gets the metadata for the given object key, type, state and nextState

Parameters:
objectKey -
type - The type of the object (value can be null)
state - The state for which to retrieve object constraints (value can be null)
nextState - The state to to check requiredForNextState indicators (value can be null)
documentTypeName - The type of the document (value can be null)
Returns:

getMetadataByWorkflowNode

public Metadata getMetadataByWorkflowNode(String objectKey,
                                          String workflowNode,
                                          String documentTypeName)
This method gets the metadata for the given object id key, workflowNode and documentTypeName

Returns:

getMetadata

public Metadata getMetadata(String objectKey,
                            String type,
                            String state)
This method gets the metadata for the given object key, type and state

Parameters:
objectKey -
type - The type of the object (value can be null)
state - The state for which to retrieve object constraints (value can be null)
Returns:

getMetadata

public Metadata getMetadata(String objectKey,
                            String state)
This method gets the metadata for the given object key and state

Parameters:
objectKey -
type - The type of the object (value can be null)

getMetadata

public Metadata getMetadata(String objectKey)
This method gets the metadata for the given object key for state DRAFT.

Parameters:
objectKey -
Returns:
See Also:
getMetadata(String, String)

getMetadataFromDictionaryService

protected Metadata getMetadataFromDictionaryService(String objectKey,
                                                    String type,
                                                    String state,
                                                    String nextState,
                                                    String workflowNode,
                                                    String documentTypeName)
This invokes the appropriate dictionary service to get the object structure and then converts it to a metadata structure.

Parameters:
objectKey -
type -
state -
documentTypeName -
Returns:

getProperties

private Map<String,Metadata> getProperties(ObjectStructureDefinition objectStructure,
                                           String type,
                                           String state,
                                           String nextState,
                                           String workflowNode,
                                           MetadataServiceImpl.RecursionCounter counter,
                                           String documentTypeName)
This method is used to convert a list of dictionary fields into metadata properties

Parameters:
type -
state -
documentTypeName - TODO
fields -
Returns:

isRepeating

protected boolean isRepeating(FieldDefinition fd)
This method determines if a field is repeating

Parameters:
fd -
Returns:

getObjectStructure

protected ObjectStructureDefinition getObjectStructure(String objectKey)
This method gets the object structure for given objectKey from a dictionaryService

Parameters:
objectKey -
Returns:

getConstraints

protected List<ConstraintMetadata> getConstraints(FieldDefinition fd,
                                                  String type,
                                                  String state,
                                                  String nextState,
                                                  String workflowNode,
                                                  String documentTypeName)

updateConstraintMetadata

protected void updateConstraintMetadata(ConstraintMetadata constraintMetadata,
                                        Constraint constraint,
                                        String type,
                                        String state,
                                        String nextState,
                                        String workflowNode)
This updates the constraintMetadata with defintions from the dictionary constraint field.

Parameters:
constraintMetadata -
constraint -

processCaseConstraint

protected void processCaseConstraint(ConstraintMetadata constraintMetadata,
                                     CaseConstraint caseConstraint,
                                     String type,
                                     String state,
                                     String nextState,
                                     String workflowNode)
Currently this only handles requiredness indicators for case constraints with the following field paths: type, state, and proposal/workflowNode


processRequiredByNodeCaseConstraint

private void processRequiredByNodeCaseConstraint(ConstraintMetadata constraintMetadata,
                                                 CaseConstraint caseConstraint,
                                                 String workflowNode)
Modifies the constraintMetadata to add required to save or required to approve constraints based on the workflow route node the proposal is currently in.

Parameters:
constraintMetadata - The fields constraintMetadata to be modified
caseConstraint - The caseConstraint defined in dictionary for field
workflowNode - The current node in workflow process

isWorkflowNodeFirstConstraintValue

private boolean isWorkflowNodeFirstConstraintValue(String workflowNode,
                                                   List<Object> values)
Parameters:
values -
workflowNode -
Returns:
true if workflowNode is first item in values, otherwise returns false

processStateCaseConstraint

private void processStateCaseConstraint(ConstraintMetadata constraintMetadata,
                                        CaseConstraint caseConstraint,
                                        String type,
                                        String state,
                                        String nextState,
                                        String workflowNode)
Processes a case constraint with field path of state.


processTypeCaseConstraint

private void processTypeCaseConstraint(ConstraintMetadata constraintMetadata,
                                       CaseConstraint caseConstraint,
                                       String type,
                                       String state,
                                       String nextState,
                                       String workflowNode)
Process a case constraint with fieldPath of type


convertDefaultValue

protected Data.Value convertDefaultValue(Data.DataType dataType,
                                         Object value)
Convert Object value to respective DataType. Method return null for object Value.

Parameters:
dataType -
value -
Returns:

convertDefaultValue

protected Data.Value convertDefaultValue(Object value)

convertDictionaryDataType

protected Data.DataType convertDictionaryDataType(DataType dataType)

setUiLookupContext

public void setUiLookupContext(String uiLookupContext)

init

private void init()

calcSimpleName

private String calcSimpleName(String objectKey)

matchesObjectKey

private boolean matchesObjectKey(String objectKey,
                                 String path)

matchesType

private boolean matchesType(String paramType,
                            String lookupType)

addLookupstoMetadata

private void addLookupstoMetadata(String objectKey,
                                  Metadata metadata,
                                  String type)

mapLookupDatatoMeta

private LookupMetadata mapLookupDatatoMeta(UILookupData lookupData)

mapLookupParamMetadata

private LookupParamMetadata mapLookupParamMetadata(CommonLookupParam param)

getPathTokens

private static String[] getPathTokens(String fieldPath)


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