org.faktorips.runtime.internal
Class ProductComponent

java.lang.Object
  extended by org.faktorips.runtime.internal.RuntimeObject
      extended by org.faktorips.runtime.internal.ProductComponent
All Implemented Interfaces:
IClRepositoryObject, IXmlPersistenceSupport, IProductComponent, IProductComponentLinkSource, IRuntimeObject

public abstract class ProductComponent
extends RuntimeObject
implements IProductComponent, IXmlPersistenceSupport

Base class for all product components.

Deliberately implements IXmlPersistenceSupport directly. Letting IProductComponent extend IXmlPersistenceSupport would have published it, which is undesired.


Constructor Summary
ProductComponent(IRuntimeRepository repository, String id, String productKindId, String versionId)
          Creates a new product component with the indicate id, kind id and version id.
 
Method Summary
protected  void doInitFormulaFromXml(Element element)
          Initializes all formulas contained by Element.
protected  void doInitPropertiesFromXml(Map<String,Element> map)
          Initializes the properties with the data in the map.
protected  void doInitReferencesFromXml(Map<String,List<Element>> linkElements)
           
protected  void doInitTableUsagesFromXml(Map<String,Element> map)
          Initializes the table content usages with the data in the map.
 IFormulaEvaluator getFormulaEvaluator()
           
 IProductComponentGeneration getGenerationBase(Calendar effectiveDate)
          Returns the generation that is effective on the given date or null if no generation is effective on that date.
 String getId()
          Returns the product component's id that uniquely identifies it in the repository it belongs to.
 String getKindId()
          Returns the id of the product component kind that this product component belongs to.
 IProductComponentGeneration getLatestProductComponentGeneration()
          Returns the latest product component generation of the provided product component or null if non available.
 IProductComponentLink<? extends IProductComponent> getLink(String linkName, IProductComponent target)
          Returns the IProductComponentLink for the association with the given role name to the given product component or null if no such association exists.
 List<IProductComponentLink<? extends IProductComponent>> getLinks()
          Returns a List of all the IProductComponentLinks from this product component generation to other product components.
 IRuntimeRepository getRepository()
          Returns the repository this product component belongs to.
 DateTime getValidFrom()
          Returns the date from which this product component is valid.
 Date getValidFrom(TimeZone zone)
          Returns the date from which this product component is valid as a Date.
 DateTime getValidTo()
          Returns the date when this product component expires.
 String getVersionId()
          Returns the version id that identifies this product component in its kind.
 void initFromXml(Element cmptElement)
          Initializes the generation with the data from the xml element.
protected  boolean isFormulaAvailable(String formularSignature)
          Returns true if the expression of the given formulaSignature not empty.
 void setValidFrom(DateTime validfrom)
          Sets the new valid from date.
 void setValidTo(DateTime validTo)
           
 String toString()
           
 Element toXml(Document document)
          Creates an XML Element that represents this product component's data.
 Element toXml(Document document, boolean includeGenerations)
          Creates an XML Element that represents this product component's data.
protected  void writeFormulaToXml(Element element)
          This method is used for writing a formulas to the XML of the given Element.
protected  void writePropertiesToXml(Element element)
          Subclasses override this method to write their properties into the given XML element.
protected  void writeReferencesToXml(Element element)
          This is a utility method called by generated code.
protected  void writeTableUsagesToXml(Element element)
          This is a utility method called by generated code.
protected  void writeTableUsageToXml(Element element, String structureUsage, String tableContentName)
          This method is used for writing a table usage to the XML of the given Element.
 
Methods inherited from class org.faktorips.runtime.internal.RuntimeObject
getExtensionPropertyIds, getExtensionPropertyValue, initExtensionPropertiesFromXml, writeExtensionPropertiesToXml, writeExtensionPropertiesToXml
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.faktorips.runtime.IProductComponent
createPolicyComponent, isChangingOverTime
 
Methods inherited from interface org.faktorips.runtime.IRuntimeObject
getExtensionPropertyIds, getExtensionPropertyValue
 

Constructor Detail

ProductComponent

public ProductComponent(IRuntimeRepository repository,
                        String id,
                        String productKindId,
                        String versionId)
Creates a new product component with the indicate id, kind id and version id.

Parameters:
repository - The component registry the component uses to resolve references to other components.
id - The component's runtime id.
productKindId - The component's kind id
versionId - The component's version id
Throws:
NullPointerException - if repository, id, productKindId, or versionId is null.
Method Detail

getKindId

public String getKindId()
Description copied from interface: IProductComponent
Returns the id of the product component kind that this product component belongs to.

Specified by:
getKindId in interface IProductComponent

getVersionId

public String getVersionId()
Description copied from interface: IProductComponent
Returns the version id that identifies this product component in its kind.

Specified by:
getVersionId in interface IProductComponent

getId

public final String getId()
Description copied from interface: IProductComponent
Returns the product component's id that uniquely identifies it in the repository it belongs to.

Specified by:
getId in interface IProductComponent

getValidFrom

public DateTime getValidFrom()
Description copied from interface: IProductComponent
Returns the date from which this product component is valid. If this product component supports generations this is the same valid from date as the first generation.

Specified by:
getValidFrom in interface IProductComponent
Returns:
The valid from date of this product component

getValidFrom

public Date getValidFrom(TimeZone zone)
Description copied from interface: IProductComponent
Returns the date from which this product component is valid as a Date. If this product component supports generations this is the same valid from date as the first generation.

Specified by:
getValidFrom in interface IProductComponent
Parameters:
zone - The time zone which is used to calculate the returned valid from date.
Returns:
The valid from date of this product component

setValidFrom

public void setValidFrom(DateTime validfrom)
Sets the new valid from date.

Attention: Conceptually, the valid from date of the first generation must be equal to the valid from date of the product component itself. Therefore, if clients call this method, then to achieve data consistency clients must set the valid from date of the first generation, too.

Throws:
IllegalRepositoryModificationException - if the repository this product component belongs to does not allow to modify its contents
See Also:
ProductComponentGeneration.setValidFrom(DateTime)

getValidTo

public DateTime getValidTo()
Description copied from interface: IProductComponent
Returns the date when this product component expires. Returning null means no end of the validity period.

Specified by:
getValidTo in interface IProductComponent

setValidTo

public void setValidTo(DateTime validTo)

getRepository

public IRuntimeRepository getRepository()
Description copied from interface: IProductComponent
Returns the repository this product component belongs to. This method never returns null.

Specified by:
getRepository in interface IProductComponent
Specified by:
getRepository in interface IProductComponentLinkSource
Returns:
The IRuntimeRepository that was used to create this IProductComponentLinkSource

getGenerationBase

public IProductComponentGeneration getGenerationBase(Calendar effectiveDate)
Description copied from interface: IProductComponent
Returns the generation that is effective on the given date or null if no generation is effective on that date.

Specified by:
getGenerationBase in interface IProductComponent

getLatestProductComponentGeneration

public IProductComponentGeneration getLatestProductComponentGeneration()
Description copied from interface: IProductComponent
Returns the latest product component generation of the provided product component or null if non available.

Specified by:
getLatestProductComponentGeneration in interface IProductComponent

getFormulaEvaluator

public IFormulaEvaluator getFormulaEvaluator()

initFromXml

public void initFromXml(Element cmptElement)
Initializes the generation with the data from the xml element.

Specified by:
initFromXml in interface IClRepositoryObject
Throws:
NullPointerException - if cmptElement is null.

doInitPropertiesFromXml

protected void doInitPropertiesFromXml(Map<String,Element> map)
Initializes the properties with the data in the map.

Parameters:
map - the map of property elements

doInitTableUsagesFromXml

protected void doInitTableUsagesFromXml(Map<String,Element> map)
Initializes the table content usages with the data in the map. The map contains the table structure usage roles as key and the qualified table content name as value.

Parameters:
map - the map of property elements

doInitFormulaFromXml

protected void doInitFormulaFromXml(Element element)
Initializes all formulas contained by Element. If formula evaluation is supported, the map contains the compiled expression for every formula.


isFormulaAvailable

protected boolean isFormulaAvailable(String formularSignature)
Returns true if the expression of the given formulaSignature not empty.


doInitReferencesFromXml

protected void doInitReferencesFromXml(Map<String,List<Element>> linkElements)
Parameters:
linkElements - the XML elements used to initialize ProductComponentLink instances.

toString

public String toString()
Overrides:
toString in class Object

toXml

public Element toXml(Document document)
Creates an XML Element that represents this product component's data.

Throws an UnsupportedOperationException if the support for toXml ("Generate toXml Support") is not activated in the FIPS standard builder.

Specified by:
toXml in interface IXmlPersistenceSupport
Parameters:
document - a document, that can be used to create XML elements.
Returns:
an Element that represents this object as XML element

toXml

public Element toXml(Document document,
                     boolean includeGenerations)
Creates an XML Element that represents this product component's data.

Throws an UnsupportedOperationException if the support for toXml ("Generate toXml Support") is not activated in the FIPS standard builder.

Parameters:
document - a document, that can be used to create XML elements.
includeGenerations - true if the created XML element should include the data of all the product component's generations, false if generations should be ignored when creating the XML output.

writePropertiesToXml

protected void writePropertiesToXml(Element element)
Subclasses override this method to write their properties into the given XML element.

The standard implementation throws an UnsupportedOperationException if the support for toXml ("Generate toXml Support") is not activated in the FIPS standard builder. Generated classes override but do NOT call super.

Parameters:
element - the XML element to write the properties to

writeTableUsagesToXml

protected void writeTableUsagesToXml(Element element)
This is a utility method called by generated code. The given Element is the element representing this ProductComponent.

Parameters:
element - the element all table usages should be added to

writeTableUsageToXml

protected void writeTableUsageToXml(Element element,
                                    String structureUsage,
                                    String tableContentName)
This method is used for writing a table usage to the XML of the given Element.

Parameters:
element - the element where the table usage will be added to
structureUsage - the value for the structureUsage XML attribute
tableContentName - the name of the used table content

getLink

public IProductComponentLink<? extends IProductComponent> getLink(String linkName,
                                                                  IProductComponent target)
Description copied from interface: IProductComponent
Returns the IProductComponentLink for the association with the given role name to the given product component or null if no such association exists.

Specified by:
getLink in interface IProductComponent

getLinks

public List<IProductComponentLink<? extends IProductComponent>> getLinks()
Description copied from interface: IProductComponent
Returns a List of all the IProductComponentLinks from this product component generation to other product components.

Specified by:
getLinks in interface IProductComponent

writeReferencesToXml

protected void writeReferencesToXml(Element element)
This is a utility method called by generated code. The given Element is the element representing this ProductComponentGeneration.

Parameters:
element - the element all table usages should be added to
Since:
3.8

writeFormulaToXml

protected void writeFormulaToXml(Element element)
This method is used for writing a formulas to the XML of the given Element.



Copyright © 2015. All rights reserved.