Class ProductComponent
- java.lang.Object
-
- org.faktorips.runtime.internal.RuntimeObject
-
- org.faktorips.runtime.internal.ProductComponent
-
- All Implemented Interfaces:
IClRepositoryObject,IXmlPersistenceSupport,IProductComponent,IProductComponentLinkSource,IProductObject,IRuntimeObject
public abstract class ProductComponent extends RuntimeObject implements IProductComponent, IXmlPersistenceSupport
Base class for all product components.Deliberately implements
IXmlPersistenceSupportdirectly. LettingIProductComponentextendIXmlPersistenceSupportwould have published it, which is undesired.
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.StringATTRIBUTE_NAME_VARIED_PRODUCT_CMPT
-
Constructor Summary
Constructors Constructor Description ProductComponent(IRuntimeRepository repository, java.lang.String id, java.lang.String productKindId, java.lang.String versionId)Creates a new product component with the indicate id, kind id and version id.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddoInitFormulaFromXml(org.w3c.dom.Element element)Initializes all formulas contained by Element.protected voiddoInitPropertiesFromXml(java.util.Map<java.lang.String,org.w3c.dom.Element> map)Initializes the properties with the data in the map.protected voiddoInitReferencesFromXml(java.util.Map<java.lang.String,java.util.List<org.w3c.dom.Element>> linkElements)protected voiddoInitTableUsagesFromXml(java.util.Map<java.lang.String,org.w3c.dom.Element> map)Initializes the table content usages with the data in the map.protected voiddoInitValidationRuleConfigsFromXml(org.w3c.dom.Element element)Creates a map containing the validation rule configurations found in the indicated XML element.java.lang.StringgetDescription(java.util.Locale locale)Returns the description for this product component in the specified locale.IFormulaEvaluatorgetFormulaEvaluator()IProductComponentGenerationgetGenerationBase(java.util.Calendar effectiveDate)Returns the generation that is effective on the given date ornullif no generation is effective on that date.java.lang.StringgetId()Returns the product component's id that uniquely identifies it in the repository it belongs to.java.lang.StringgetKindId()Returns the id of the product component kind that this product component belongs to.IProductComponentGenerationgetLatestProductComponentGeneration()Returns the latest product component generation of the provided product component ornullif non available.IProductComponentLink<? extends IProductComponent>getLink(java.lang.String linkName, IProductComponent target)Returns theIProductComponentLinkfor the association with the given role name to the given product component ornullif no such association exists.java.util.List<IProductComponentLink<? extends IProductComponent>>getLinks()Returns aListof all theIProductComponentLinks from this product component generation to other product components.IRuntimeRepositorygetRepository()Returns the repository this product component belongs to.DateTimegetValidFrom()Returns the date from which this generation is valid.java.util.DategetValidFrom(java.util.TimeZone zone)Returns the point in time this generation is valid from in the given time zone.DateTimegetValidTo()Returns the date when this product component expires.IProductComponentgetVariedBase()Allows distinguishing variants not only by their product component type but also their varied base.java.lang.StringgetVersionId()Returns the version id that identifies this product component in its kind.voidinitFromXml(org.w3c.dom.Element cmptElement)Initializes the generation with the data from the xml element.protected booleanisFormulaAvailable(java.lang.String formularSignature)Returnstrueif the expression of the given formulaSignature not empty.booleanisValidationRuleActivated(java.lang.String ruleName)Returns whether the validation rule with the given name is configured as active in thisIProductObject.booleanisVariant()A variant is a product component that is based on another product component (hence varied base).voidsetValidationRuleActivated(java.lang.String ruleName, boolean active)Enables or disables validation for a specific rule.voidsetValidFrom(DateTime validfrom)Sets the new valid from date.voidsetValidTo(DateTime validTo)java.lang.StringtoString()org.w3c.dom.ElementtoXml(org.w3c.dom.Document document)Creates an XMLElementthat represents this product component's data.org.w3c.dom.ElementtoXml(org.w3c.dom.Document document, boolean includeGenerations)Creates an XMLElementthat represents this product component's data.protected voidwriteFormulaToXml(org.w3c.dom.Element element)This method is used for writing a formulas to the XML of the givenElement.protected voidwritePropertiesToXml(org.w3c.dom.Element element)Subclasses override this method to write their properties into the given XML element.protected voidwriteReferencesToXml(org.w3c.dom.Element element)This is a utility method called by generated code.protected voidwriteTableUsagesToXml(org.w3c.dom.Element element)This is a utility method called by generated code.protected voidwriteTableUsageToXml(org.w3c.dom.Element element, java.lang.String structureUsage, java.lang.String tableContentName)This method is used for writing a table usage to the XML of the givenElement.protected voidwriteValidationRuleConfigsToXml(org.w3c.dom.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.IProductComponent
isChangingOverTime
-
Methods inherited from interface org.faktorips.runtime.IProductObject
createPolicyComponent
-
Methods inherited from interface org.faktorips.runtime.IRuntimeObject
getExtensionPropertyIds, getExtensionPropertyValue
-
-
-
-
Field Detail
-
ATTRIBUTE_NAME_VARIED_PRODUCT_CMPT
protected static final java.lang.String ATTRIBUTE_NAME_VARIED_PRODUCT_CMPT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ProductComponent
public ProductComponent(IRuntimeRepository repository, java.lang.String id, java.lang.String productKindId, java.lang.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 idversionId- The component's version id- Throws:
java.lang.NullPointerException- if repository, id, productKindId, or versionId isnull.
-
-
Method Detail
-
getKindId
public java.lang.String getKindId()
Description copied from interface:IProductComponentReturns the id of the product component kind that this product component belongs to.- Specified by:
getKindIdin interfaceIProductComponent
-
getVersionId
public java.lang.String getVersionId()
Description copied from interface:IProductComponentReturns the version id that identifies this product component in its kind.- Specified by:
getVersionIdin interfaceIProductComponent
-
getId
public java.lang.String getId()
Description copied from interface:IProductComponentReturns the product component's id that uniquely identifies it in the repository it belongs to.- Specified by:
getIdin interfaceIProductComponent
-
isVariant
public boolean isVariant()
Description copied from interface:IProductComponentA variant is a product component that is based on another product component (hence varied base). It uses the varied base as a template and "changes" specific values.- Specified by:
isVariantin interfaceIProductComponent- Returns:
trueif this is a variant of anotherIProductComponent,falsefor regular product components.- See Also:
IProductComponent.getVariedBase()
-
getVariedBase
public IProductComponent getVariedBase()
Description copied from interface:IProductComponentAllows distinguishing variants not only by their product component type but also their varied base.IProductComponent.isVariant()allows determining whether a product component is a variant.- Specified by:
getVariedBasein interfaceIProductComponent- Returns:
- the
IProductComponentthisIProductComponentis based on. Returnsnullif it is a regular product component or thevariedBasecan not be found in theIRuntimeRepository. - See Also:
IProductComponent.isVariant(),IRuntimeRepository.getProductComponent(String)
-
getValidFrom
public DateTime getValidFrom()
Description copied from interface:IProductObjectReturns the date from which this generation is valid.- Specified by:
getValidFromin interfaceIProductObject- Returns:
- The valid from date of this generation
-
getValidFrom
public java.util.Date getValidFrom(java.util.TimeZone zone)
Description copied from interface:IProductObjectReturns the point in time this generation is valid from in the given time zone. This method never returnsnull.- Specified by:
getValidFromin interfaceIProductObject
-
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:IProductComponentReturns the date when this product component expires. Returningnullmeans no end of the validity period.- Specified by:
getValidToin interfaceIProductComponent
-
setValidTo
public void setValidTo(DateTime validTo)
-
getRepository
public IRuntimeRepository getRepository()
Description copied from interface:IProductComponentReturns the repository this product component belongs to. This method never returnsnull.- Specified by:
getRepositoryin interfaceIProductComponent- Specified by:
getRepositoryin interfaceIProductComponentLinkSource- Returns:
- The
IRuntimeRepositorythat was used to create thisIProductComponentLinkSource
-
getGenerationBase
public IProductComponentGeneration getGenerationBase(java.util.Calendar effectiveDate)
Description copied from interface:IProductComponentReturns the generation that is effective on the given date ornullif no generation is effective on that date.- Specified by:
getGenerationBasein interfaceIProductComponent
-
getLatestProductComponentGeneration
public IProductComponentGeneration getLatestProductComponentGeneration()
Description copied from interface:IProductComponentReturns the latest product component generation of the provided product component ornullif non available.- Specified by:
getLatestProductComponentGenerationin interfaceIProductComponent
-
getFormulaEvaluator
public IFormulaEvaluator getFormulaEvaluator()
-
getDescription
public java.lang.String getDescription(java.util.Locale locale)
Description copied from interface:IProductComponentReturns the description for this product component in the specified locale. If there is no description in the specified locale, it tries to find the description in the locale's language. If there is also no description in the locale's language it returns the empty string.- Specified by:
getDescriptionin interfaceIProductComponent- Returns:
- the description for the given locale/language or an empty string if no description exists for the given locale
-
initFromXml
public void initFromXml(org.w3c.dom.Element cmptElement)
Initializes the generation with the data from the xml element.- Specified by:
initFromXmlin interfaceIClRepositoryObject- Throws:
java.lang.NullPointerException- if cmptElement isnull.
-
doInitPropertiesFromXml
protected void doInitPropertiesFromXml(java.util.Map<java.lang.String,org.w3c.dom.Element> map)
Initializes the properties with the data in the map.- Parameters:
map- the map of property elements
-
doInitTableUsagesFromXml
protected void doInitTableUsagesFromXml(java.util.Map<java.lang.String,org.w3c.dom.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(org.w3c.dom.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(java.lang.String formularSignature)
Returnstrueif the expression of the given formulaSignature not empty.
-
doInitReferencesFromXml
protected void doInitReferencesFromXml(java.util.Map<java.lang.String,java.util.List<org.w3c.dom.Element>> linkElements)
- Parameters:
linkElements- the XML elements used to initializeProductComponentLinkinstances.
-
doInitValidationRuleConfigsFromXml
protected void doInitValidationRuleConfigsFromXml(org.w3c.dom.Element element)
Creates a map containing the validation rule configurations found in the indicated XML element. For each validation rule configuration the map contains an entry with the rule name as a key and anValidationRuleConfigurationinstance as value.- Parameters:
element- an XML element containing a product component's data- Throws:
java.lang.NullPointerException- if element isnull.- Since:
- 3.22
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
toXml
public org.w3c.dom.Element toXml(org.w3c.dom.Document document)
Creates an XMLElementthat represents this product component's data.Throws an
UnsupportedOperationExceptionif the support for toXml ("Generate toXml Support") is not activated in the FIPS standard builder.- Specified by:
toXmlin interfaceIXmlPersistenceSupport- Parameters:
document- a document, that can be used to create XML elements.- Returns:
- an
Elementthat represents this object as XML element
-
toXml
public org.w3c.dom.Element toXml(org.w3c.dom.Document document, boolean includeGenerations)Creates an XMLElementthat represents this product component's data.Throws an
UnsupportedOperationExceptionif 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-trueif the created XML element should include the data of all the product component's generations,falseif generations should be ignored when creating the XML output.
-
writePropertiesToXml
protected void writePropertiesToXml(org.w3c.dom.Element element)
Subclasses override this method to write their properties into the given XML element.The standard implementation throws an
UnsupportedOperationExceptionif 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(org.w3c.dom.Element element)
This is a utility method called by generated code. The givenElementis the element representing thisProductComponent.- Parameters:
element- the element all table usages should be added to
-
writeTableUsageToXml
protected void writeTableUsageToXml(org.w3c.dom.Element element, java.lang.String structureUsage, java.lang.String tableContentName)This method is used for writing a table usage to the XML of the givenElement.- Parameters:
element- the element where the table usage will be added tostructureUsage- the value for the structureUsage XML attributetableContentName- the name of the used table content
-
getLink
public IProductComponentLink<? extends IProductComponent> getLink(java.lang.String linkName, IProductComponent target)
Description copied from interface:IProductComponentLinkSourceReturns theIProductComponentLinkfor the association with the given role name to the given product component ornullif no such association exists.- Specified by:
getLinkin interfaceIProductComponentLinkSource
-
getLinks
public java.util.List<IProductComponentLink<? extends IProductComponent>> getLinks()
Description copied from interface:IProductComponentLinkSourceReturns aListof all theIProductComponentLinks from this product component generation to other product components.- Specified by:
getLinksin interfaceIProductComponentLinkSource
-
writeReferencesToXml
protected void writeReferencesToXml(org.w3c.dom.Element element)
This is a utility method called by generated code. The givenElementis the element representing thisProductComponentGeneration.- Parameters:
element- the element all table usages should be added to- Since:
- 3.8
-
writeValidationRuleConfigsToXml
protected void writeValidationRuleConfigsToXml(org.w3c.dom.Element genElement)
- Since:
- 3.22
-
writeFormulaToXml
protected void writeFormulaToXml(org.w3c.dom.Element element)
This method is used for writing a formulas to the XML of the givenElement.
-
isValidationRuleActivated
public boolean isValidationRuleActivated(java.lang.String ruleName)
Description copied from interface:IProductObjectReturns whether the validation rule with the given name is configured as active in thisIProductObject. If there is no configuration for the given rule,falseis returned.Please be aware that only one of
IProductComponentorIProductComponentGenerationcan configure any given rule depending on its changing-over-time configuration.- Specified by:
isValidationRuleActivatedin interfaceIProductObject- Parameters:
ruleName- the name of the rule in question- Returns:
trueif the rule was activated,falseelse.
-
setValidationRuleActivated
public void setValidationRuleActivated(java.lang.String ruleName, boolean active)Description copied from interface:IProductObjectEnables or disables validation for a specific rule.- Specified by:
setValidationRuleActivatedin interfaceIProductObject- Parameters:
ruleName- the name of the rule in questionactive- indicating whether the validation rule is configured as active
-
-