org.faktorips.runtime.internal
Class ProductComponentGeneration

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

public abstract class ProductComponentGeneration
extends RuntimeObject
implements IProductComponentGeneration, IXmlPersistenceSupport

Base class for product component generations

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


Constructor Summary
ProductComponentGeneration(ProductComponent productCmpt)
           
 
Method Summary
static void addToCardinalityMap(Map<String,org.faktorips.valueset.IntegerRange> cardinalityMap, String targetId, Element relationElement)
          This method for implementations of the doInitReferencesFromXml method to read the cardinality bounds from an xml dom element.
 IConfigurableModelObject createPolicyComponent()
          Creates a new policy component that is configured by this product component generation.
protected  void doInitFormulaFromXml(Element genElement)
          Initializes all formulas contained by genElement.
protected  void doInitPropertiesFromXml(Map<String,Element> map)
          Initializes the properties with the data in the map.
protected  void doInitReferencesFromXml(Map<String,List<Element>> map)
          Initializes the links with the data in the map.
protected  void doInitTableUsagesFromXml(Map<String,Element> map)
          Initializes the table content usages with the data in the map.
protected  void doInitValidationRuleConfigsFromXml(Element genElement)
          Creates a map containing the validation rule configurations found in the indicated generation's XML element.
protected  NodeList getEnumNodeList(Element configElement)
           
 IFormulaEvaluator getFormulaEvaluator()
           
 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.
 IProductComponentGeneration getNextGeneration()
          Returns the next generation if available if not null will be returned.
 IProductComponentGeneration getPreviousGeneration()
          Returns the previous generation if available if not null will be returned.
 IProductComponent getProductComponent()
          Returns the product component this generation belongs to.
protected  Element getRangeElement(Element configElement)
           
 IRuntimeRepository getRepository()
          Returns the repository this product component generation belongs to.
 DateTime getValidFrom()
          Returns the date from which this generation is valid.
 Date getValidFrom(TimeZone zone)
          Returns the point in time this generation is valid from in the given time zone.
 long getValidFromInMillisec(TimeZone zone)
           
 void initFromXml(Element genElement)
          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.
 boolean isValidationRuleActivated(String ruleName)
          Returns whether the validation rule with the given name is configured as active in this ProductComponent.
protected  void setProductCmpt(ProductComponent productCmpt)
          Sets the product component this generation belongs to.
 void setValidFrom(DateTime newValidFrom)
          Sets the new valid from date.
 String toString()
           
 Element toXml(Document document)
          Creates an XML Element that represents this product component generation'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 generationElement)
          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.
protected  void writeValidationRuleConfigsToXml(Element genElement)
           
 
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.IRuntimeObject
getExtensionPropertyIds, getExtensionPropertyValue
 

Constructor Detail

ProductComponentGeneration

public ProductComponentGeneration(ProductComponent productCmpt)
Method Detail

createPolicyComponent

public IConfigurableModelObject createPolicyComponent()
Creates a new policy component that is configured by this product component generation. After creating the policy component it is automatically initialized. The new policy component is not added to any parent structure.

Specified by:
createPolicyComponent in interface IProductComponentGeneration

getProductComponent

public final IProductComponent getProductComponent()
Description copied from interface: IProductComponentGeneration
Returns the product component this generation belongs to. This method never returns null.

Specified by:
getProductComponent in interface IProductComponentGeneration

getPreviousGeneration

public final IProductComponentGeneration getPreviousGeneration()
Description copied from interface: IProductComponentGeneration
Returns the previous generation if available if not null will be returned.

Specified by:
getPreviousGeneration in interface IProductComponentGeneration

getNextGeneration

public final IProductComponentGeneration getNextGeneration()
Description copied from interface: IProductComponentGeneration
Returns the next generation if available if not null will be returned.

Specified by:
getNextGeneration in interface IProductComponentGeneration

getRepository

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

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

getValidFromInMillisec

public final long getValidFromInMillisec(TimeZone zone)

getValidFrom

public DateTime getValidFrom()
Description copied from interface: IProductComponentGeneration
Returns the date from which this generation is valid.

Specified by:
getValidFrom in interface IProductComponentGeneration
Returns:
The valid from date of this generation

getValidFrom

public final Date getValidFrom(TimeZone zone)
Description copied from interface: IProductComponentGeneration
Returns the point in time this generation is valid from in the given time zone. This method never returns null.

Specified by:
getValidFrom in interface IProductComponentGeneration

setValidFrom

public void setValidFrom(DateTime newValidFrom)
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 on the first generation of a product component, to achieve data consistency, clients must set the valid from date of the product component, too.

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

getFormulaEvaluator

public IFormulaEvaluator getFormulaEvaluator()

initFromXml

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

Specified by:
initFromXml in interface IClRepositoryObject
Throws:
IllegalRepositoryModificationException - if the component has already been initialized and the repository prohibit changing its contents.
NullPointerException - if genElement 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

doInitReferencesFromXml

protected void doInitReferencesFromXml(Map<String,List<Element>> map)
Initializes the links 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 genElement)
Initializes all formulas contained by genElement. 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.


doInitValidationRuleConfigsFromXml

protected void doInitValidationRuleConfigsFromXml(Element genElement)
Creates a map containing the validation rule configurations found in the indicated generation's XML element. For each validation rule configuration the map contains an entry with the rule name as a key and an ValidationRuleConfiguration instance as value.

IPSPV-199 : removed the cleaning of nameToValidationRuleConfigMap because if the method initFromXML is called twice, the product variant would have no validation rules when cleaning is used.

Parameters:
genElement - An XML element containing a product component generation's data.
Throws:
NullPointerException - if genElement is null.

getRangeElement

protected Element getRangeElement(Element configElement)

getEnumNodeList

protected NodeList getEnumNodeList(Element configElement)

addToCardinalityMap

public static void addToCardinalityMap(Map<String,org.faktorips.valueset.IntegerRange> cardinalityMap,
                                       String targetId,
                                       Element relationElement)
This method for implementations of the doInitReferencesFromXml method to read the cardinality bounds from an xml dom element. An IntegerRange object is created and added to the provided cardinalityMap.


toString

public String toString()
Overrides:
toString in class Object

setProductCmpt

protected void setProductCmpt(ProductComponent productCmpt)
Sets the product component this generation belongs to.


getLink

public IProductComponentLink<? extends IProductComponent> getLink(String linkName,
                                                                  IProductComponent target)
Description copied from interface: IProductComponentGeneration
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 IProductComponentGeneration

getLinks

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

Specified by:
getLinks in interface IProductComponentGeneration

isValidationRuleActivated

public boolean isValidationRuleActivated(String ruleName)
Returns whether the validation rule with the given name is configured as active in this ProductComponent.

Specified by:
isValidationRuleActivated in interface IProductComponentGeneration
Parameters:
ruleName - the name of the rule in question
Returns:
true if the rule was activated, false else.

toXml

public Element toXml(Document document)
Creates an XML Element that represents this product component generation'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

writeTableUsagesToXml

protected void writeTableUsagesToXml(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

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

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

writeFormulaToXml

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


writeValidationRuleConfigsToXml

protected void writeValidationRuleConfigsToXml(Element genElement)

writePropertiesToXml

protected void writePropertiesToXml(Element generationElement)
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:
generationElement - the XML element to write the properties to


Copyright © 2015. All rights reserved.