info.informatica.ui
Class DataView

java.lang.Object
  extended by info.informatica.ui.DataView
All Implemented Interfaces:
Valueset
Direct Known Subclasses:
HTTPDataEntryForm, SwingDataEntryForm

public abstract class DataView
extends Object
implements Valueset

Encapsulation of data entry form.

SYNOPSIS / EXAMPLE:

  // initialize
  DataDict dic = ...
  DataViewConfig vc = ...
  ViewSecurity vsec = ... [OPTIONAL]
  DataView view = ...
  view.setMetaData(dic.getMetaData(mdname));
  try {
     // feed the form with data view
     view.setDataViewConfig(vc);
     // Set the security constraints [optional]
     view.setSecurity(vsec);
     // initialize
     view.init();
  } catch(DataException e){
     ...
  }
  // Usually, values are introduced by subclass-specific methods
  ...
  // Validate the view
  try {
     view.validate();
  } catch(DataFieldException e){
     ...
  }
  // Do something with values
  Object value = view.getValue("field1");
  ...
  view.close();
 

You won't use this class directly, but one of the subclasses instead.

Author:
amengual at informatica dot info

Constructor Summary
DataView(String id)
           
 
Method Summary
 void close()
           
 DataControl createDataControl(ControlName controlname)
           
 Map<String,Object> dataToUI(Dataset ds)
           
 Map<String,Object> dataToUI(Dataset ds, MetaData md)
          Given a dataset, uses the data values to get a map of UI field names -> UI field values.
 boolean equals(Object obj)
           
 int fieldCount()
          Gets the number of data view elements.
 Set getAllowedRoles(String opname)
          Convenience method that accesses the view security object to test for allowed roles.
 DataControl getDataControl(ControlName controlname)
          Returns the instance of the DataControl peer object with name controlname.
 Collection<DataControl> getDataControls()
           
 DataViewConfig getDataViewConfig()
          Gets the DataViewConfig object associated to this view.
 String getId()
          Get the ID of this View.
 MetaData getMetaData()
          Get the metadata that applies to this view.
 ViewSecurity getSecurity()
          Gets the ViewSecurity instance associated to this form.
 Object getValue(FieldName fieldname)
          Gets the value of the fieldname entity.
 int hashCode()
           
 void init()
          initialize the form prior to display (defaults, etc.)
 void setDataViewConfig(DataViewConfig vc)
          load the configuration
 void setMetaData(MetaData md)
          Set the metadata that applies to this view.
 void setSecurity(ViewSecurity viewsec)
          Sets the security information.
 String toString()
           
 Map<FieldName,Object> validate()
           
 Map<FieldName,Object> validate(boolean checkauto)
           
 Map<FieldName,Object> validate(boolean checkauto, Object helper)
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DataView

public DataView(String id)
Method Detail

setDataViewConfig

public void setDataViewConfig(DataViewConfig vc)
                       throws DataViewException
load the configuration

Throws:
DataViewException

setMetaData

public void setMetaData(MetaData md)
Set the metadata that applies to this view.

Parameters:
md - the metadata.

init

public void init()
          throws DataException
initialize the form prior to display (defaults, etc.)

Throws:
DataException

createDataControl

public DataControl createDataControl(ControlName controlname)
                              throws DataViewException
Throws:
DataViewException

getMetaData

public MetaData getMetaData()
Get the metadata that applies to this view.

Returns:
the metadata.

getDataControl

public DataControl getDataControl(ControlName controlname)
Returns the instance of the DataControl peer object with name controlname.

Parameters:
controlname - name of the data control
Returns:
Entity UI peer

getDataControls

public Collection<DataControl> getDataControls()

fieldCount

public int fieldCount()
Gets the number of data view elements.

Returns:
number of fields

validate

public Map<FieldName,Object> validate()
                               throws DataException
Throws:
DataException

validate

public Map<FieldName,Object> validate(boolean checkauto)
                               throws DataException
Throws:
DataException

validate

public Map<FieldName,Object> validate(boolean checkauto,
                                      Object helper)
                               throws DataException
Throws:
DataException

getId

public String getId()
Get the ID of this View.

Returns:
a String with the view ID.

getValue

public Object getValue(FieldName fieldname)
Gets the value of the fieldname entity.

Specified by:
getValue in interface Valueset
Parameters:
fieldname - name of the field in database.
Returns:
the field value.

setSecurity

public void setSecurity(ViewSecurity viewsec)
Sets the security information.

Parameters:
viewsec - the ViewSecurity object to be associated with this view config.

getSecurity

public ViewSecurity getSecurity()
Gets the ViewSecurity instance associated to this form.

Returns:
the ViewSecurity instance for this View, or null if no security constraints apply.

getAllowedRoles

public Set getAllowedRoles(String opname)
Convenience method that accesses the view security object to test for allowed roles.


getDataViewConfig

public DataViewConfig getDataViewConfig()
Gets the DataViewConfig object associated to this view.

Returns:
the view config, or null if not available.

dataToUI

public Map<String,Object> dataToUI(Dataset ds)
                            throws DatasetException
Throws:
DatasetException

dataToUI

public Map<String,Object> dataToUI(Dataset ds,
                                   MetaData md)
                            throws DatasetException
Given a dataset, uses the data values to get a map of UI field names -> UI field values.

Throws:
DatasetException

close

public void close()

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object