pl.edu.agh.cast.data.model.general
Class GeneralDataSet<T extends IGeneralElement>

java.lang.Object
  extended by pl.edu.agh.cast.data.model.property.PropertyContainer
      extended by pl.edu.agh.cast.data.model.AbstractDataSet<T>
          extended by pl.edu.agh.cast.data.model.domain.DomainDataSet<T>
              extended by pl.edu.agh.cast.data.model.general.GeneralDataSet<T>
Type Parameters:
T - type of contained elements
All Implemented Interfaces:
Serializable, Observer, IDisposable, IValidatable, IDomainDataSet<T>, IGeneralDataSet<T>, IDataSet<T>, Identifiable, IPropertyContainer
Direct Known Subclasses:
SampleGeneralDataSet

public class GeneralDataSet<T extends IGeneralElement>
extends DomainDataSet<T>
implements IGeneralDataSet<T>

Default implementation of IGeneralDataSet which contains IEntity objects connected with IManyToManyRelation.

The new elements (entity and relations) should be added in the following way:

Author:
AGH CAST Team
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface pl.edu.agh.cast.data.model.IDataSet
IDataSet.Properties
 
Field Summary
 
Fields inherited from interface pl.edu.agh.cast.data.model.general.IGeneralDataSet
ACCEPTED_TYPES, TYPE
 
Constructor Summary
GeneralDataSet()
          Default constructor.
GeneralDataSet(DomainDataSetDescriptor descriptor)
          Initializes data set with its descriptor and a newly created MetaPropertyManager.
GeneralDataSet(DomainDataSetDescriptor descriptor, MetaPropertyManager metaPropertyManager)
          Initializes data set with its descriptor and MetaPropertyManager.
GeneralDataSet(String name)
          Initializes data set with its descriptor and a newly created MetaPropertyManager.
GeneralDataSet(String name, String sourceName, String sourceDescription, Date sourceDate)
          Initializes data set with its descriptor and a newly created MetaPropertyManager.
 
Method Summary
protected  void afterAddElement(T element)
          This method is called after successfully adding the given element to the data set.
protected  void beforeRemoveElement(T element)
          This method is called before attempting to remove the given element from the data set.
 Collection<Type> getAcceptedTypes()
          Returns collection of types of IElements this data set is able to accept.
 Collection<IEntity> getEntities()
          Returns all entities contained in the data set.
 Collection<IManyToManyRelation> getRelations()
          Returns all relations (many-to-many) contained in the data set.
protected  boolean isElementValid(T element)
          Checks if given element is valid for the data set.
 
Methods inherited from class pl.edu.agh.cast.data.model.domain.DomainDataSet
acquireDescriptor, createNewDescriptor, getDescriptor, getSourceDate, getSourceDescription, getSourceName, isDescriptorValid, setSourceDate, setSourceDescription, setSourceName
 
Methods inherited from class pl.edu.agh.cast.data.model.AbstractDataSet
addElement, addElements, addElements, addMetaPropertyManager, addMetaPropertyManager, addMetaPropertyManagersForAcceptedTypes, afterRemoveElement, afterSetMetaPropertyManager, beforeAddElement, checkIfValid, equals, getAssignableElements, getCreationDate, getDescString, getElement, getElementCount, getElements, getElements, getElementTypes, getId, getMetaPropertyManager, getMetaPropertyManagers, getName, getRegisteredTypes, getType, hashCode, isValid, removeElement, removeElement, removeElements, removeElements, setCreationDate, setDescriptor, setElements, setId, setName, setType, toString
 
Methods inherited from class pl.edu.agh.cast.data.model.property.PropertyContainer
addProperty, createProperty, dispose, getCustomProperties, getMetaPropertyManager, getPermanentProperties, getProperties, getProperty, getTransientProperties, initializeProperties, matches, removeProperty, setMetaPropertyManager, setProperty, update
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface pl.edu.agh.cast.data.model.domain.IDomainDataSet
getDescriptor, getSourceDate, getSourceDescription, getSourceName, setSourceDate, setSourceDescription, setSourceName
 
Methods inherited from interface pl.edu.agh.cast.data.model.IDataSet
addElement, addElements, addElements, addMetaPropertyManager, addMetaPropertyManagersForAcceptedTypes, getAssignableElements, getCreationDate, getElement, getElementCount, getElements, getElements, getElementTypes, getMetaPropertyManager, getMetaPropertyManagers, getName, getRegisteredTypes, removeElement, removeElement, removeElements, removeElements, setCreationDate, setElements, setName
 
Methods inherited from interface pl.edu.agh.cast.data.model.Identifiable
getId, getType
 
Methods inherited from interface pl.edu.agh.cast.data.model.property.IPropertyContainer
addProperty, getCustomProperties, getMetaPropertyManager, getPermanentProperties, getProperties, getProperty, getTransientProperties, matches, removeProperty, setProperty
 
Methods inherited from interface java.util.Observer
update
 
Methods inherited from interface pl.edu.agh.cast.common.IValidatable
isValid
 
Methods inherited from interface pl.edu.agh.cast.common.IDisposable
dispose
 

Constructor Detail

GeneralDataSet

public GeneralDataSet()
Default constructor.

Usage of this constructor is discouraged, since it does not provide any integrity control. If, however, this constructor is used, the AbstractDataSet.isValid() method should be called in order to check the integrity.


GeneralDataSet

public GeneralDataSet(String name)
Initializes data set with its descriptor and a newly created MetaPropertyManager. The name of the source is the same as name, its description is null, and its date is set to current date.

Parameters:
name - the name of the data set

GeneralDataSet

public GeneralDataSet(String name,
                      String sourceName,
                      String sourceDescription,
                      Date sourceDate)
Initializes data set with its descriptor and a newly created MetaPropertyManager.

Parameters:
name - the name of the data set
sourceName - data source name (short)
sourceDescription - data source detailed description
sourceDate - data source acquisition date

GeneralDataSet

public GeneralDataSet(DomainDataSetDescriptor descriptor)
Initializes data set with its descriptor and a newly created MetaPropertyManager.

Parameters:
descriptor - the domain data set descriptor

GeneralDataSet

public GeneralDataSet(DomainDataSetDescriptor descriptor,
                      MetaPropertyManager metaPropertyManager)
Initializes data set with its descriptor and MetaPropertyManager.

Parameters:
descriptor - the domain data set descriptor
metaPropertyManager - manager of data set's meta properties
Method Detail

isElementValid

protected boolean isElementValid(T element)
Checks if given element is valid for the data set.

This method is called by the AbstractDataSet.addElement(IElement) method. By default it always returns true , however it can be overridden in order to define new validation rules. In such case the implementation from base class should be called inside the overridden method in order to preserve data consistency.

Overrides:
isElementValid in class AbstractDataSet<T extends IGeneralElement>
Parameters:
element - the element to validate
Returns:
true if the element is valid, false otherwise
See Also:
AbstractDataSet.isElementValid(pl.edu.agh.cast.data.model.IElement)

afterAddElement

protected void afterAddElement(T element)
This method is called after successfully adding the given element to the data set.

It should be overridden by subclasses to add custom activities which should be perform after removing the given element.

Overrides:
afterAddElement in class AbstractDataSet<T extends IGeneralElement>
Parameters:
element - element which has been just removed
See Also:
AbstractDataSet.afterAddElement(pl.edu.agh.cast.data.model.IElement)

beforeRemoveElement

protected void beforeRemoveElement(T element)
This method is called before attempting to remove the given element from the data set.

It should be overridden by subclasses to add custom activities which should be perform after removing the given element.

Overrides:
beforeRemoveElement in class AbstractDataSet<T extends IGeneralElement>
Parameters:
element - element which is to be removed
See Also:
AbstractDataSet.beforeRemoveElement(pl.edu.agh.cast.data.model.IElement)

getAcceptedTypes

public Collection<Type> getAcceptedTypes()
Returns collection of types of IElements this data set is able to accept.

This method should be overridden by all concrete subclasses.

Returns collection of types of elements this data set is able to accept.

Specified by:
getAcceptedTypes in interface IDataSet<T extends IGeneralElement>
Overrides:
getAcceptedTypes in class DomainDataSet<T extends IGeneralElement>
Returns:
collection of element types this data set is able to accept
See Also:
DomainDataSet.getAcceptedTypes()

getEntities

public Collection<IEntity> getEntities()
Returns all entities contained in the data set.

Specified by:
getEntities in interface IGeneralDataSet<T extends IGeneralElement>
Returns:
collection of all entities from the data set; if data set contains no entities then an empty collection
See Also:
IGeneralDataSet.getEntities()

getRelations

public Collection<IManyToManyRelation> getRelations()
Returns all relations (many-to-many) contained in the data set.

Specified by:
getRelations in interface IGeneralDataSet<T extends IGeneralElement>
Returns:
collection of all many-to-many relations from the data set; if data set contains no relations then an empty collection
See Also:
IGeneralDataSet.getRelations()


Copyright © 2007-2009 IISG AGH-UST Krakow, Poland. All Rights Reserved.