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 IXmlPersistenceSupport directly. Letting IProductComponent extend IXmlPersistenceSupport would have published it, which is undesired.

  • Field Details

    • ATTRIBUTE_NAME_VARIED_PRODUCT_CMPT

      protected static final String 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 id
      versionId - The component's version id
      Throws:
      NullPointerException - if repository, id, productKindId, or versionId is null.
  • Method Details

    • 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 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
    • isVariant

      public boolean isVariant()
      Description copied from interface: IProductComponent
      A 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:
      isVariant in interface IProductComponent
      Returns:
      true if this is a variant of another IProductComponent, false for regular product components.
      See Also:
    • getVariedBase

      public IProductComponent getVariedBase()
      Description copied from interface: IProductComponent
      Allows 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:
      getVariedBase in interface IProductComponent
      Returns:
      the IProductComponent this IProductComponent is based on. Returns null if it is a regular product component or the variedBase can not be found in the IRuntimeRepository.
      See Also:
    • setVariedBase

      public void setVariedBase(ProductComponent variedBase)
      Sets the varied base product, marking this product as its variant.
      Throws:
      IllegalRepositoryModificationException - if the repository this product component belongs to is not modifiable.
      See Also:
    • getValidFrom

      public DateTime getValidFrom()
      Description copied from interface: IProductObject
      Returns the date from which this generation is valid.
      Specified by:
      getValidFrom in interface IProductObject
      Returns:
      The valid from date of this generation
    • getValidFrom

      public Date getValidFrom(TimeZone zone)
      Description copied from interface: IProductObject
      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 IProductObject
    • 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:
    • 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()
    • getDescription

      public String getDescription(Locale locale)
      Description copied from interface: IProductComponent
      Returns 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:
      getDescription in interface IProductComponent
      Returns:
      the description for the given locale/language or an empty string if no description exists for the given locale
    • 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.
    • doInitValidationRuleConfigsFromXml

      protected void doInitValidationRuleConfigsFromXml(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 an ValidationRuleConfiguration instance as value.
      Parameters:
      element - an XML element containing a product component's data
      Throws:
      NullPointerException - if element is null.
      Since:
      3.22
    • 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.
    • 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: IProductComponentLinkSource
      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 IProductComponentLinkSource
    • getLinks

      public List<IProductComponentLink<? extends IProductComponent>> getLinks()
      Description copied from interface: IProductComponentLinkSource
      Returns a List of all the IProductComponentLinks from this product component generation to other product components.
      Specified by:
      getLinks in interface IProductComponentLinkSource
    • 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
    • writeValidationRuleConfigsToXml

      protected void writeValidationRuleConfigsToXml(Element genElement)
      Since:
      3.22
    • writeFormulaToXml

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

      public boolean isValidationRuleActivated(String ruleName)
      Description copied from interface: IProductObject
      Returns whether the validation rule with the given name is configured as active in this IProductObject. If there is no configuration for the given rule, false is returned.

      Please be aware that only one of IProductComponent or IProductComponentGeneration can configure any given rule depending on its changing-over-time configuration.

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

      public void setValidationRuleActivated(String ruleName, boolean active)
      Description copied from interface: IProductObject
      Enables or disables validation for a specific rule.
      Specified by:
      setValidationRuleActivated in interface IProductObject
      Parameters:
      ruleName - the name of the rule in question
      active - indicating whether the validation rule is configured as active