Class ProductComponent
- All Implemented Interfaces:
IClRepositoryObject,IXmlPersistenceSupport,IProductComponent,IProductComponentLinkSource,IProductObject,IRuntimeObject
Deliberately implements IXmlPersistenceSupport directly. Letting
IProductComponent extend IXmlPersistenceSupport would have published it, which is
undesired.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionProductComponent(IRuntimeRepository repository, String id, String productKindId, String versionId) Creates a new product component with the indicate id, kind id and version id. -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoInitFormulaFromXml(Element element) Initializes all formulas contained by Element.protected voidInitializes the properties with the data in the map.protected voiddoInitReferencesFromXml(Map<String, List<Element>> linkElements) protected voidInitializes the table content usages with the data in the map.protected voidCreates a map containing the validation rule configurations found in the indicated XML element.getDescription(Locale locale) Returns the description for this product component in the specified locale.getGenerationBase(Calendar effectiveDate) Returns the generation that is effective on the given date ornullif no generation is effective on that date.getId()Returns the product component's id that uniquely identifies it in the repository it belongs to.Returns the id of the product component kind that this product component belongs to.Returns the latest product component generation of the provided product component ornullif non available.IProductComponentLink<? extends IProductComponent>getLink(String linkName, IProductComponent target) Returns theIProductComponentLinkfor the association with the given role name to the given product component ornullif no such association exists.List<IProductComponentLink<? extends IProductComponent>>getLinks()Returns aListof all theIProductComponentLinks from this product component generation to other product components.Returns the repository this product component belongs to.Returns the date from which this generation is valid.getValidFrom(TimeZone zone) Returns the point in time this generation is valid from in the given time zone.Returns the date when this product component expires.Allows distinguishing variants not only by their product component type but also their varied base.Returns the version id that identifies this product component in its kind.voidinitFromXml(Element cmptElement) Initializes the generation with the data from the xml element.protected booleanisFormulaAvailable(String formularSignature) Returnstrueif the expression of the given formulaSignature not empty.booleanisValidationRuleActivated(String ruleName) Returns whether the validation rule with the given name is configured as active in thisIProductObject.booleanA variant is a product component that is based on another product component (hence varied base).voidsetValidationRuleActivated(String ruleName, boolean active) Enables or disables validation for a specific rule.voidsetValidFrom(DateTime validfrom) Sets the new valid from date.voidsetValidTo(DateTime validTo) voidsetVariedBase(ProductComponent variedBase) Sets the varied base product, marking this product as its variant.toString()Creates an XMLElementthat represents this product component's data.Creates an XMLElementthat represents this product component's data.protected voidwriteFormulaToXml(Element element) This method is used for writing a formulas to the XML of the givenElement.protected voidwritePropertiesToXml(Element element) Subclasses override this method to write their properties into the given XML element.protected voidwriteReferencesToXml(Element element) This is a utility method called by generated code.protected voidwriteTableUsagesToXml(Element element) This is a utility method called by generated code.protected voidwriteTableUsageToXml(Element element, String structureUsage, String tableContentName) This method is used for writing a table usage to the XML of the givenElement.protected voidwriteValidationRuleConfigsToXml(Element genElement) Methods inherited from class org.faktorips.runtime.internal.RuntimeObject
getExtensionPropertyIds, getExtensionPropertyValue, initExtensionPropertiesFromXml, writeExtensionPropertiesToXml, writeExtensionPropertiesToXmlMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.faktorips.runtime.IProductComponent
isChangingOverTimeMethods inherited from interface org.faktorips.runtime.IProductObject
createPolicyComponentMethods inherited from interface org.faktorips.runtime.IRuntimeObject
getExtensionPropertyIds, getExtensionPropertyValue
-
Field Details
-
ATTRIBUTE_NAME_VARIED_PRODUCT_CMPT
- See Also:
-
-
Constructor Details
-
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 idversionId- The component's version id- Throws:
NullPointerException- if repository, id, productKindId, or versionId isnull.
-
-
Method Details
-
getKindId
Description copied from interface:IProductComponentReturns the id of the product component kind that this product component belongs to.- Specified by:
getKindIdin interfaceIProductComponent
-
getVersionId
Description copied from interface:IProductComponentReturns the version id that identifies this product component in its kind.- Specified by:
getVersionIdin interfaceIProductComponent
-
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:
-
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:
-
setVariedBase
Sets the varied base product, marking this product as its variant.- Throws:
IllegalRepositoryModificationException- if therepositorythis product component belongs to is notmodifiable.- See Also:
-
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
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
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:
-
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
-
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
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
Description copied from interface:IProductComponentReturns the latest product component generation of the provided product component ornullif non available.- Specified by:
getLatestProductComponentGenerationin interfaceIProductComponent
-
getFormulaEvaluator
-
getDescription
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
Initializes the generation with the data from the xml element.- Specified by:
initFromXmlin interfaceIClRepositoryObject- Throws:
NullPointerException- if cmptElement isnull.
-
doInitPropertiesFromXml
Initializes the properties with the data in the map.- Parameters:
map- the map of property elements
-
doInitTableUsagesFromXml
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
Initializes all formulas contained by Element. If formula evaluation is supported, the map contains the compiled expression for every formula. -
isFormulaAvailable
Returnstrueif the expression of the given formulaSignature not empty. -
doInitReferencesFromXml
- Parameters:
linkElements- the XML elements used to initializeProductComponentLinkinstances.
-
doInitValidationRuleConfigsFromXml
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:
NullPointerException- if element isnull.- Since:
- 3.22
-
toString
-
toXml
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
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
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
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(Element element, String structureUsage, 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(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
Description copied from interface:IProductComponentLinkSourceReturns aListof all theIProductComponentLinks from this product component generation to other product components.- Specified by:
getLinksin interfaceIProductComponentLinkSource
-
writeReferencesToXml
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
- Since:
- 3.22
-
writeFormulaToXml
This method is used for writing a formulas to the XML of the givenElement. -
isValidationRuleActivated
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
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
-