lumis.doui.source
Class Source<F extends ISourceField>

Package class diagram package Source
java.lang.Object
  extended by java.util.Observable
      extended by lumis.doui.source.Source<F>
Type Parameters:
F - the interface all fields of this source must implement.
Direct Known Subclasses:
TabularSource

@StableMinor(version="6.2",
             sinceVersion="4.0")
public abstract class Source<F extends ISourceField>
extends Observable

The base implementation of a doui data source.

Since:
4.0.0

Field Summary
protected  String addInterfaceId
           
protected  String administrationInterfaceId
           
protected  String connectionId
           
protected  String detailsInterfaceId
           
protected  String editInterfaceId
           
protected  List<F> fields
          A unmodifiable list of this source's fields.
protected  Map<String,F> fieldsMap
          A map of field id to the ISourceField instance.
protected  String id
           
protected  F introductionSourceField
           
protected  F keywordsSourceField
           
protected  boolean load
           
protected  String metaDataSourceId
           
protected  Map<String,Object> parameters
           
protected  F primaryNameSourceField
           
protected  String readData
           
static String SOURCE_READ_DATA_ALWAYS
           
static String SOURCE_READ_DATA_NEVER
           
static String SOURCE_READ_DATA_ON_DEMAND
           
protected  ISourceContext sourceContext
           
protected  Node sourceDefinitionNode
           
 
Constructor Summary
Source(Node sourceDefinitionNode, ISourceContext sourceContext)
           
 
Method Summary
 void applyPostLoadFilters()
          Apply the filters specified in this source to its data.
protected abstract  void convertDataToDefinedDataTypes()
          Converts the data in this source to the values that should be used according to its fields definitions.
protected  F createCustomSourceField(Node fieldNode)
          Factory method for creating a custom source field.
protected  ISourceFilter createDefaultCompositeFilterInstance()
          Creates and returns a source filter instance to be used as default to filters nodes.
protected  ISourceFilter createDefaultFilterInstance()
          Creates and returns a source filter instance to be used as default to filter nodes.
protected  F createSourceField(Node fieldNode)
          Factory method for creating a source field instance that corresponds to the field node given.
 ISourceFilter createSourceFilter(Node filterNode)
          Creates a source filter for the given filter definition node.
 String getAddInterfaceId()
          Returns the default add interface id for this source.
 String getAdministrationInterfaceId()
          Returns the main administration interface id for this source.
 ISourceData getData()
          Returns this source's data.
<S extends Source>
IDataProvider<S>
getDataProvider()
          Returns the data provider for this source.
protected abstract  String getDefaultProviderClass()
          Abstract method that returns the default data provider class name.
 Node getDefinitionNode()
          Deprecated. This method may not be public in the future.
 String getDetailsInterfaceId()
          Returns the default details interface id for this source.
 boolean getDistinct()
          Returns the distinct property of the source.
 DouiContext getDouiContext()
          Returns this source's doui context.
 DouiHyperlinkItemParameterField getDouiHyperlinkItemParameterField()
          Returns the information about the field that is associated with the item id page parameter.
 String getEditInterfaceId()
          Returns the default edit interface id for this source.
 F getField(String fieldId)
          Returns the field with the given id.
 List<F> getFields()
          Returns a unmodifiable list of the fields in this source.
 ISourceFilter getFilter()
          Returns the filter for this source.
 Node getFiltersNode()
          Returns the "filters" node of the source.
 Collection<String> getHyperlinkDefaultParameters()
          Returns the default parameters that should be used when creating a hyperlink url from this source.
 String getId()
          Returns the source id.
 F getIntroductionField()
          Returns the field that is the introduction of this source.
 F getKeywordsField()
           
 boolean getLoad()
          Returns the load property.
 String getMetaDataSourceId()
          Returns the metaDataId.
 Class<?> getParameterClass(String parameterName)
          Returns the class given a parameter name.
 Object getParameterValue(String parameterName)
          Returns a parameter value previously set.
 F getPrimaryNameField()
          Returns the field that is the primary name of this source.
 String getReadData()
           
 SourceContainer getSourceContainer()
          Returns this source's container.
 ISourceContext getSourceContext()
          Returns this source's context.
 ITransaction getTransaction()
          Returns the transaction for this source.
protected  boolean isAdministrationInterface(IServiceInterface serviceInterface)
          Returns true if the given service interface is the main administration interface for this source.
 void load()
          This is where the actual loading of the source data takes place.
protected  void postProcessSource()
          Executes the post load processors associated with the current source.
protected  void readFieldsIntoFieldsMap()
          Reads this source's fields into the fieldsMap.
 void setLoad(boolean load)
          Sets the property indicating whether this source must be loaded by its data provider.
 void setParameterValue(String parameterName, Object value)
          Sets the parameter value of the source.
 void setReadData(String loadType)
          Returns the load type of the source.
protected  boolean valueChanged(String parameterName, Object value)
          Returns true if the current value of the parameter changed from the previous value.
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SOURCE_READ_DATA_ON_DEMAND

public static final String SOURCE_READ_DATA_ON_DEMAND
See Also:
Constant Field Values

SOURCE_READ_DATA_NEVER

public static final String SOURCE_READ_DATA_NEVER
See Also:
Constant Field Values

SOURCE_READ_DATA_ALWAYS

public static final String SOURCE_READ_DATA_ALWAYS
See Also:
Constant Field Values

id

protected final String id

metaDataSourceId

protected final String metaDataSourceId

connectionId

protected final String connectionId

parameters

protected final Map<String,Object> parameters

sourceContext

protected final ISourceContext sourceContext

sourceDefinitionNode

protected final Node sourceDefinitionNode

administrationInterfaceId

protected final String administrationInterfaceId

addInterfaceId

protected final String addInterfaceId

editInterfaceId

protected final String editInterfaceId

detailsInterfaceId

protected final String detailsInterfaceId

fieldsMap

protected final Map<String,F extends ISourceField> fieldsMap
A map of field id to the ISourceField instance. Changes to this map automatically reflects in the fields list. The fields list has the order the entries were put in this map.

Since:
4.0.4
See Also:
fields

fields

protected final List<F extends ISourceField> fields
A unmodifiable list of this source's fields. This list automatically reflects the changes done in fieldsMap. The order of fields in this list is the same as the order the fields were put in fieldsMap.

Since:
4.0.4
See Also:
fieldsMap

load

protected boolean load

readData

protected String readData

primaryNameSourceField

protected F extends ISourceField primaryNameSourceField

introductionSourceField

protected F extends ISourceField introductionSourceField

keywordsSourceField

protected F extends ISourceField keywordsSourceField
Constructor Detail

Source

public Source(Node sourceDefinitionNode,
              ISourceContext sourceContext)
       throws PortalException
Throws:
PortalException
Method Detail

isAdministrationInterface

protected boolean isAdministrationInterface(IServiceInterface serviceInterface)
Returns true if the given service interface is the main administration interface for this source.

Parameters:
serviceInterface - the service interface.
Returns:
true if the given service interface is the main administration interface for this source, false otherwise.
Since:
4.0.6

readFieldsIntoFieldsMap

protected void readFieldsIntoFieldsMap()
                                throws PortalException
Reads this source's fields into the fieldsMap. The order the source fields are put in the map will define the order the fields will be in the fields list. This order may affect some field processing.

Throws:
PortalException - if an error was found while reading the source's fields into the fields map.
Since:
4.0.4

createCustomSourceField

protected F createCustomSourceField(Node fieldNode)
                                                  throws PortalException
Factory method for creating a custom source field. A source field is a field whose class name is specified in its definition.

Parameters:
fieldNode - the field definition.
Returns:
the field instance, or null if the field is not a custom source field.
Throws:
PortalException
Since:
4.0.6

createSourceField

protected F createSourceField(Node fieldNode)
                                            throws PortalException
Factory method for creating a source field instance that corresponds to the field node given. This method instantiate and returns the source field, without initializing it.

Parameters:
fieldNode - the field node.
Returns:
the ISourceField created, or null if no field should be created for this node.
Throws:
PortalException
Since:
4.0.4
See Also:
createCustomSourceField(Node)

createSourceFilter

public ISourceFilter createSourceFilter(Node filterNode)
                                 throws PortalException
Creates a source filter for the given filter definition node. The node may be a filters or filter node.

Parameters:
filterNode - the filter definition node.
Returns:
the source filter.
Throws:
PortalException
Since:
4.0.5

createDefaultFilterInstance

protected ISourceFilter createDefaultFilterInstance()
Creates and returns a source filter instance to be used as default to filter nodes.

Returns:
the created instance.
Since:
4.0.5

createDefaultCompositeFilterInstance

protected ISourceFilter createDefaultCompositeFilterInstance()
Creates and returns a source filter instance to be used as default to filters nodes.

Returns:
the created instance.
Since:
4.0.5

getFilter

public ISourceFilter getFilter()
Returns the filter for this source. The filter must be initialized with the appropriated parameters before each use.

Returns:
the filter or null if this source has no filter.
Since:
4.0.5

getId

public String getId()
Returns the source id.

Returns:
Since:
4.0.11

getParameterClass

public Class<?> getParameterClass(String parameterName)
Returns the class given a parameter name.

The class is determined by the field type where the fieldId equals the parameter name.

Parameters:
parameterName -
Returns:
Since:
4.0.11

setParameterValue

public void setParameterValue(String parameterName,
                              Object value)
Sets the parameter value of the source.

Parameters:
parameterName -
value -
Since:
4.0.11

getParameterValue

public Object getParameterValue(String parameterName)
Returns a parameter value previously set.

Parameters:
parameterName -
Returns:
Since:
4.0.11

valueChanged

protected boolean valueChanged(String parameterName,
                               Object value)
Returns true if the current value of the parameter changed from the previous value.

Parameters:
parameterName -
value -
Returns:
Since:
4.0.11

getDefinitionNode

public Node getDefinitionNode()
Deprecated. This method may not be public in the future.

Returns:
Since:
4.0.4

getAdministrationInterfaceId

public String getAdministrationInterfaceId()
Returns the main administration interface id for this source.

Returns:
the main administration interface id for this source. It may be null if the source does not have a main administration interface.
Since:
4.0.4

getAddInterfaceId

public String getAddInterfaceId()
Returns the default add interface id for this source.

Returns:
the default add interface id for this source. It may be null if the source does not have a default add interface.
Since:
6.0.0

getEditInterfaceId

public String getEditInterfaceId()
Returns the default edit interface id for this source.

Returns:
the default edit interface id for this source. It may be null if the source does not have a default edit interface.
Since:
6.0.0

getDetailsInterfaceId

public String getDetailsInterfaceId()
Returns the default details interface id for this source.

Returns:
the default details interface id for this source. It may be null if the source does not have a default details interface.
Since:
6.0.0

getDataProvider

public <S extends Source> IDataProvider<S> getDataProvider()
                                                throws PortalException
Returns the data provider for this source.

Type Parameters:
S -
Returns:
Throws:
PortalException
Since:
4.0.11

getDefaultProviderClass

protected abstract String getDefaultProviderClass()
                                           throws PortalException
Abstract method that returns the default data provider class name.

Returns:
Throws:
PortalException
Since:
4.0.11

getData

public ISourceData getData()
                    throws PortalException
Returns this source's data.

Returns:
this source's data.
Throws:
PortalException
Since:
4.0.4

setLoad

public void setLoad(boolean load)
Sets the property indicating whether this source must be loaded by its data provider.

Parameters:
load -
Since:
4.0.11

getLoad

public boolean getLoad()
Returns the load property.

The doui framework uses this to determine whether the source should be loaded or not.

Returns:
Since:
4.0.11

getTransaction

public ITransaction getTransaction()
                            throws PortalException
Returns the transaction for this source.

Returns:
the transaction for this source.
Throws:
PortalException
Since:
4.0.4

load

public void load()
          throws PortalException
This is where the actual loading of the source data takes place.

The data provider is called by the source to load its data. After data is loaded, all data conversion is performed and observers are notified.

Throws:
PortalException
Since:
4.0.11

postProcessSource

protected void postProcessSource()
                          throws PortalException
Executes the post load processors associated with the current source. Note: this task was previously executed by the SourceContainer.

Throws:
PortalException
Since:
4.0.6

convertDataToDefinedDataTypes

protected abstract void convertDataToDefinedDataTypes()
                                               throws PortalException
Converts the data in this source to the values that should be used according to its fields definitions.

Throws:
PortalException
Since:
4.0.4

getReadData

public String getReadData()
Returns:
Returns the loadType.

setReadData

public void setReadData(String loadType)
Returns the load type of the source.

Parameters:
loadType - The loadType to set.

getFiltersNode

public Node getFiltersNode()
                    throws PortalException
Returns the "filters" node of the source.

A null value is returned if no filters are specified.

Returns:
Throws:
PortalException
Since:
4.0.11

applyPostLoadFilters

public void applyPostLoadFilters()
                          throws PortalException
Apply the filters specified in this source to its data. This is an utility method for data providers that does not support filtering during the source load operation. After loading the source's data without filtering it, the data provider may call this method for the source to remove data that does not attend to the filters specified.

Data providers that may provide significant quantity of data should implement its own filtering during load instead of using this method, to prevent unnecessary use of server's memory and cpu.

Throws:
UnsupportedOperationException - if the source's implementation for this method does not support the filters specified.
PortalException
See Also:
IDataProvider#loadData(lumis.portal.SessionConfig, Source, lumis.util.ITransaction)

getSourceContext

public ISourceContext getSourceContext()
Returns this source's context.

Returns:
this source's context.

getDouiContext

public DouiContext getDouiContext()
Returns this source's doui context.

Returns:
this source's doui context. May be null if this source does not belong to a doui context.

getSourceContainer

public SourceContainer getSourceContainer()
Returns this source's container.

Returns:
this source's container. May be null if this source does not belong to a source container.

getDistinct

public boolean getDistinct()
                    throws PortalException
Returns the distinct property of the source.

The data provider reads this property to determine how to retireve data.

Returns:
Throws:
PortalException
Since:
4.0.11

getMetaDataSourceId

public String getMetaDataSourceId()
Returns the metaDataId.

Returns:
Returns the metaDataId.

getField

public F getField(String fieldId)
Returns the field with the given id.

Parameters:
fieldId - the field's id.
Returns:
the field with the given id, or null if there is no field with such id.
Since:
4.0.4

getFields

public List<F> getFields()
Returns a unmodifiable list of the fields in this source.

Returns:
a unmodifiable list of the fields in this source.
Since:
4.0.4

getPrimaryNameField

public F getPrimaryNameField()
Returns the field that is the primary name of this source.

Returns:
the field that is the primary name of this source, or null if this source has no primary name field.
Since:
4.0.4

getIntroductionField

public F getIntroductionField()
Returns the field that is the introduction of this source.

Returns:
the field that is the introduction of this source, or null if this source has no introduction field.
Since:
4.0.4

getKeywordsField

public F getKeywordsField()

getDouiHyperlinkItemParameterField

public DouiHyperlinkItemParameterField getDouiHyperlinkItemParameterField()
Returns the information about the field that is associated with the item id page parameter.

Returns:
the information about the field that is associated with the item id page parameter.
Since:
4.0.6
See Also:
PageConfig.PAGE_PARAMETER_ITEMID, DouiHyperlinkItemParameterField

getHyperlinkDefaultParameters

public Collection<String> getHyperlinkDefaultParameters()
Returns the default parameters that should be used when creating a hyperlink url from this source.

Returns:
a collection with the default parameter names.
Since:
4.2.0


Lumisportal  6.2.0.120405 - Copyright © 2006–2012 Lumis EIP Tecnologia da Informação LTDA. All Rights Reserved.