ReportMill 12 API

com.reportmill.datasource
Class RMDataSource

java.lang.Object
  extended by com.reportmill.base.RMObject
      extended by com.reportmill.datasource.RMDataSource
All Implemented Interfaces:
com.reportmill.base.RMPropertyChanger, java.beans.PropertyChangeListener, java.lang.Cloneable, java.util.EventListener
Direct Known Subclasses:
RMFileDataSource, RMXMLDataSource

public class RMDataSource
extends com.reportmill.base.RMObject
implements java.beans.PropertyChangeListener

This class is used as a proxy for objects passed to document's generateReport() method. It provides schema information of the object graph (in the form of RMEntity and RMProperty objects) and it provides sample data (probably in the form of Java Collections and core types: List, Map, String, Number, Date).


Nested Class Summary
static interface RMDataSource.EntityResolver
           
 
Constructor Summary
RMDataSource()
          Creates a plain datasource.
 
Method Summary
 void create()
          Creates the data source remote site (database, directory file, etc.).
 RMEntity createEntity(RMEntity anEntity)
          Creates an entity in data source for given entity.
 java.lang.Object createObject(RMEntity anEntity)
          Creates and returns a new object for a given entity.
 void delete()
          Deletes this data source, assuming it corresponds to something that can be deleted, like a database.
 void deleteEntity(RMEntity anEntity)
          Deletes an entity in data source for given entity.
 void deleteFile(RMFile aFile)
          Deletes a file.
 void deleteRow(RMRow aRow)
          Registers row to be deleted.
 boolean equals(java.lang.Object anObj)
          Standard equals implementation.
 RMDataSource fromXML(com.reportmill.archiver.RXArchiver anArchiver, com.reportmill.archiver.RXElement anElement, java.lang.Object anOwner)
          XML unarchival.
 java.util.List<RMRow> getAllRows(RMEntity anEntity)
          Returns all the rows for an entity.
 java.util.Map getDataset()
          Returns a sample dataset of objects associated with the datasource.
 java.util.List getDataset(java.lang.String aKey)
          Returns the named dataset from this datasource.
 RMEntity getEntity(java.lang.String aKeyPath)
          Returns the entity at the given key path.
 java.lang.Class<? extends RMRow> getEntityClass(RMEntity anEntity)
          Returns the class for a given entity.
 RMDataSource.EntityResolver getEntityResolver()
          Returns the custom entity resolver.
 RMFile getFile(java.lang.String aPath)
          Returns the individual file with the given path.
 RMFile getFile(java.lang.String aPath, boolean doCreate)
          Returns the individual file with the given path, with an option to create it, if missing.
 RMFile getFile(java.lang.String aPath, boolean doCreate, boolean isDirectory)
          Returns the individual file with the given path, with an option to create it, if missing.
 java.util.List<? extends RMFile> getFilesImpl(java.lang.String aPath)
          Returns files at path.
 java.lang.String getName()
          Returns the name for the datasource.
 RMFile getRootDirectory()
          Returns the root directory.
 RMRow getRow(RMEntity anEntity, RMCondition aCondition)
          Returns a cached row for a entity and condition.
 RMRow getRow(java.lang.String anEntityName, RMCondition aCondition)
          Returns a cached row for an entity name and condition.
 java.util.List<RMRow> getRows(java.util.List<? extends RMProperty> theProperties, RMCondition aCondition)
          Returns a set of rows for the given properties and condition.
 RMSchema getSchema()
          Returns the schema of represented datasource as a hierarchy of RMEntity and RMProperty objects.
 RMSchema getSchemaVisible()
          Returns the schema that should be visible to users.
 java.lang.String getTypeString()
          Returns the type string.
 RMRow getUniqueRow(RMRow aRow)
          Returns any previously loaded incarnation of given row, based on its primary key, otherwise it returns the given row (after adding it to allRows for row entity).
 void insertRow(RMRow aRow)
          Registers row to be inserted.
 void propertyChange(java.beans.PropertyChangeEvent anEvent)
          Overridden to track property changes.
 void readFile(RMFile aFile)
          Reads a file (bytes really).
 void refresh()
          Clears all cached data in the data source, forcing everything to reload.
 void saveRows()
          Save row changes.
 void saveRowsImmediately()
          Save row changes immediately.
 void setEntityResolver(RMDataSource.EntityResolver anEntityResolver)
          Sets the custom entity resolver.
 void setName(java.lang.String aName)
          Sets the name for the datasource.
 java.lang.String toString()
          Returns a string representation of the datasource (just its name).
 com.reportmill.archiver.RXElement toXML(com.reportmill.archiver.RXArchiver anArchiver, java.lang.Object anOwner)
          XML archival.
 void updateRow(RMRow aRow)
          Registers row to be updated.
 void writeFile(RMFile aFile)
          Writes a file (bytes really).
 
Methods inherited from class com.reportmill.base.RMObject
addListener, addPropertyChangeListener, animUpdate, clone, firePropertyChange, firePropertyChange, getListener, getListenerCount, getListeners, isFirePropertyChangeEnabled, isUndoing, removeListener, removePropertyChangeListener, setFirePropertyChangeEnabled, setUndoing
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RMDataSource

public RMDataSource()
Creates a plain datasource.

Method Detail

getName

public java.lang.String getName()
Returns the name for the datasource.


setName

public void setName(java.lang.String aName)
Sets the name for the datasource.


getTypeString

public java.lang.String getTypeString()
Returns the type string.


getSchema

public RMSchema getSchema()
Returns the schema of represented datasource as a hierarchy of RMEntity and RMProperty objects.


getSchemaVisible

public RMSchema getSchemaVisible()
Returns the schema that should be visible to users.


getDataset

public java.util.Map getDataset()
Returns a sample dataset of objects associated with the datasource.


getDataset

public java.util.List getDataset(java.lang.String aKey)
Returns the named dataset from this datasource.


createObject

public java.lang.Object createObject(RMEntity anEntity)
Creates and returns a new object for a given entity.


getEntity

public RMEntity getEntity(java.lang.String aKeyPath)
Returns the entity at the given key path.


getRow

public RMRow getRow(java.lang.String anEntityName,
                    RMCondition aCondition)
Returns a cached row for an entity name and condition.


getRow

public RMRow getRow(RMEntity anEntity,
                    RMCondition aCondition)
Returns a cached row for a entity and condition.


getRows

public java.util.List<RMRow> getRows(java.util.List<? extends RMProperty> theProperties,
                                     RMCondition aCondition)
Returns a set of rows for the given properties and condition.


getAllRows

public java.util.List<RMRow> getAllRows(RMEntity anEntity)
Returns all the rows for an entity.


getUniqueRow

public RMRow getUniqueRow(RMRow aRow)
Returns any previously loaded incarnation of given row, based on its primary key, otherwise it returns the given row (after adding it to allRows for row entity).


insertRow

public void insertRow(RMRow aRow)
Registers row to be inserted.


updateRow

public void updateRow(RMRow aRow)
Registers row to be updated.


deleteRow

public void deleteRow(RMRow aRow)
Registers row to be deleted.


getEntityClass

public java.lang.Class<? extends RMRow> getEntityClass(RMEntity anEntity)
Returns the class for a given entity.


getEntityResolver

public RMDataSource.EntityResolver getEntityResolver()
Returns the custom entity resolver.


setEntityResolver

public void setEntityResolver(RMDataSource.EntityResolver anEntityResolver)
Sets the custom entity resolver.


propertyChange

public void propertyChange(java.beans.PropertyChangeEvent anEvent)
Overridden to track property changes.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener

saveRows

public void saveRows()
Save row changes.


saveRowsImmediately

public void saveRowsImmediately()
Save row changes immediately.


getRootDirectory

public RMFile getRootDirectory()
Returns the root directory.


getFile

public RMFile getFile(java.lang.String aPath)
Returns the individual file with the given path.


getFile

public RMFile getFile(java.lang.String aPath,
                      boolean doCreate)
Returns the individual file with the given path, with an option to create it, if missing.


getFile

public RMFile getFile(java.lang.String aPath,
                      boolean doCreate,
                      boolean isDirectory)
Returns the individual file with the given path, with an option to create it, if missing.


getFilesImpl

public java.util.List<? extends RMFile> getFilesImpl(java.lang.String aPath)
Returns files at path.


readFile

public void readFile(RMFile aFile)
Reads a file (bytes really).


writeFile

public void writeFile(RMFile aFile)
Writes a file (bytes really).


deleteFile

public void deleteFile(RMFile aFile)
Deletes a file.


createEntity

public RMEntity createEntity(RMEntity anEntity)
Creates an entity in data source for given entity.


deleteEntity

public void deleteEntity(RMEntity anEntity)
Deletes an entity in data source for given entity.


create

public void create()
Creates the data source remote site (database, directory file, etc.).


delete

public void delete()
Deletes this data source, assuming it corresponds to something that can be deleted, like a database.


refresh

public void refresh()
Clears all cached data in the data source, forcing everything to reload.


equals

public boolean equals(java.lang.Object anObj)
Standard equals implementation.

Overrides:
equals in class java.lang.Object

toXML

public com.reportmill.archiver.RXElement toXML(com.reportmill.archiver.RXArchiver anArchiver,
                                               java.lang.Object anOwner)
XML archival.


fromXML

public RMDataSource fromXML(com.reportmill.archiver.RXArchiver anArchiver,
                            com.reportmill.archiver.RXElement anElement,
                            java.lang.Object anOwner)
XML unarchival.


toString

public java.lang.String toString()
Returns a string representation of the datasource (just its name).

Overrides:
toString in class com.reportmill.base.RMObject

ReportMill 12 API