Class MetaModel

java.lang.Object
org.openxava.util.meta.MetaElement
org.openxava.model.meta.MetaModel
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
MetaAggregate, MetaEntity

public abstract class MetaModel extends MetaElement
Author:
Javier Paniza
See Also:
  • Constructor Details

    • MetaModel

      public MetaModel()
  • Method Details

    • getAllPersistent

      public static Collection<MetaModel> getAllPersistent()
      All models (Entities and Aggregates) with a mapping associated.
      Returns:
      of type MetaModel
      Throws:
      XavaException
    • getAllPojoGenerated

      public static Collection<MetaModel> getAllPojoGenerated()
      All models (Entities and Aggregates) where its POJO code and Hiberante mapping is generated.
      Returns:
      of type MetaModel
      Throws:
      XavaException
    • addMetaFinder

      public void addMetaFinder(MetaFinder metaFinder)
    • addMetaMethod

      public void addMetaMethod(MetaMethod metaMethod)
    • addMetaCalculatorPostCreate

      public void addMetaCalculatorPostCreate(MetaCalculator metaCalculator)
    • addMetaCalculatorPostLoad

      public void addMetaCalculatorPostLoad(MetaCalculator metaCalculator)
    • addMetaCalculatorPostModify

      public void addMetaCalculatorPostModify(MetaCalculator metaCalculator)
    • addMetaCalculatorPreRemove

      public void addMetaCalculatorPreRemove(MetaCalculator metaCalculator)
    • addMetaValidator

      public void addMetaValidator(MetaValidator metaValidator)
    • addMetaValidatorRemove

      public void addMetaValidatorRemove(MetaValidator metaValidator)
    • getQualifiedName

      public String getQualifiedName()
      If entity the name of component, if aggregate the name of component + the name of aggregate.

    • setQualifiedName

      public void setQualifiedName(String qualifiedName)
      If entity the name of component, if aggregate the name of component + the name of aggregate.

    • getMetaFinders

      public Collection<MetaFinder> getMetaFinders()
      Returns:
      Collection of MetaFinder. Not null
    • getMetaMethods

      public Collection<MetaMethod> getMetaMethods()
      Returns:
      Collection of MetaMethod. Not null
    • addMetaProperty

      public void addMetaProperty(MetaProperty newMetaProperty)
      Parameters:
      newMetaProperty - not null
      Throws:
      XavaException
    • hasDefaultCalculatorOnCreate

      public boolean hasDefaultCalculatorOnCreate()
    • addMetaReference

      public void addMetaReference(MetaReference newMetaReference)
      Parameters:
      newMetaReference - not null
      Throws:
      XavaException
    • addMetaView

      public void addMetaView(MetaView newMetaView)
      Throws:
      XavaException
    • addMetaCollection

      public void addMetaCollection(MetaCollection newMetaCollection)
      Parameters:
      newMetaCollection - not null
    • containsMetaProperty

      public boolean containsMetaProperty(String property)
    • containsMetaPropertyView

      public boolean containsMetaPropertyView(String property)
    • containsMetaReference

      public boolean containsMetaReference(String reference)
    • containsMetaCollection

      public boolean containsMetaCollection(String collection)
    • getPropertiesClass

      public Class getPropertiesClass()
      Class that contains the properties defined in this model.

      Returns:
      Not null
      Throws:
      XavaException
    • getMetaMember

      public MetaMember getMetaMember(String name) throws ElementNotFoundException
      Throws:
      XavaException
      ElementNotFoundException
    • getMetaProperty

      public MetaProperty getMetaProperty(String name) throws ElementNotFoundException
      Support qualified for properties of references with dot (.).

      Throws:
      XavaException
      ElementNotFoundException
    • getMetaPropertyView

      public MetaProperty getMetaPropertyView(String name) throws ElementNotFoundException
      Throws:
      XavaException
      ElementNotFoundException
    • getMetaReference

      public MetaReference getMetaReference(String name) throws ElementNotFoundException
      Parameters:
      name - May be qualified, that is myreference.mynestedreference
      Throws:
      XavaException
      ElementNotFoundException
    • getMetaMethod

      public MetaMethod getMetaMethod(String name) throws ElementNotFoundException
      Throws:
      XavaException
      ElementNotFoundException
    • getMetaCollection

      public MetaCollection getMetaCollection(String name) throws ElementNotFoundException
      Parameters:
      name - May be qualified, that is mycollection.mynestedcollection
      Throws:
      XavaException
      ElementNotFoundException
    • getMetaView

      public MetaView getMetaView(String name) throws ElementNotFoundException
      Throws:
      XavaException
      ElementNotFoundException
    • getMetaViews

      public Collection<MetaView> getMetaViews()
      Throws:
      XavaException
    • getMembersNames

      public Collection<String> getMembersNames()
      Ordered as in component definition file.
      Returns:
      Not null, read only and serializable
    • getMembersNamesNestingAggregates

      public Collection<String> getMembersNamesNestingAggregates()
    • getPropertiesNames

      public List<String> getPropertiesNames()
      Ordered as in component definition.
      Returns:
      Not null, read only and serializable
    • getReferencesNames

      public Collection<String> getReferencesNames()
      Returns:
      Not null, read only and serializable
    • getColectionsNames

      public Collection<String> getColectionsNames()
      Returns:
      Not null, read only and serializable
    • getEntityReferencesNames

      public Collection<String> getEntityReferencesNames()
      Throws:
      XavaException
    • getAggregateReferencesNames

      public Collection<String> getAggregateReferencesNames()
      Throws:
      XavaException
    • getMetaCollectionsAgregate

      public Collection<MetaCollection> getMetaCollectionsAgregate()
      Returns:
      Collection of MetaCollection, not null and read only
      Throws:
      XavaException
    • getRequiredPropertiesNames

      public Collection<String> getRequiredPropertiesNames()
      Returns:
      Collection of String, not null and read only
      Throws:
      XavaException
    • getRequiredMemberNames

      public Collection<String> getRequiredMemberNames()
      Returns:
      Collection of String, not null and read only
      Throws:
      XavaException
    • getSarchKeyPropertiesNames

      public Collection<String> getSarchKeyPropertiesNames()
      SearchKey properties names ordered in declaration order.
      Throws:
      XavaException
      Since:
      7.4.4
    • getKeyPropertiesNames

      public Collection<String> getKeyPropertiesNames()
      Key properties names ordered in declaration order.
      Returns:
      Collection of String, not null and read only
      Throws:
      XavaException
    • getKeyReferencesNames

      public Collection<String> getKeyReferencesNames()
      Key reference names in undetermined order.
      Returns:
      Collection of String, not null and read only
      Throws:
      XavaException
    • getAllKeyPropertiesNames

      public Collection<String> getAllKeyPropertiesNames()
      Includes qualified properties in case of key references, ordered alphabetically.

      Returns:
      Collection of String, not null and read only
      Throws:
      XavaException
    • getAllKeyPropertiesNamesOrderedAsInModel

      public Collection<String> getAllKeyPropertiesNamesOrderedAsInModel()
      Includes qualified properties in case of key references, ordered as in model.

      Returns:
      Collection of String, not null and read only
      Throws:
      XavaException
      Since:
      7.2.1
    • getPropertiesNamesWithoutHiddenNorTransient

      public List<String> getPropertiesNamesWithoutHiddenNorTransient()
      Ordered as in component definition.

      Calculated properties are included.

      Returns:
      Collection of String, not null and read only
      Throws:
      XavaException
    • getMetaPropertiesKey

      public Collection<MetaProperty> getMetaPropertiesKey()
      Returns:
      Collection of MetaProperty, not null and read only
      Throws:
      XavaException
    • getMetaMembersKey

      public Collection<MetaMember> getMetaMembersKey()
      Key members.
      Returns:
      Collection of MetaMember, not null and read only
      Throws:
      XavaException
    • getAllMetaPropertiesKey

      public List<MetaProperty> getAllMetaPropertiesKey()
      Include qualified properties in case of key references. <p<
      Returns:
      Collection of MetaProperty, not null and read only
      Throws:
      XavaException
    • getMetaPropertiesCalculated

      public Collection<MetaProperty> getMetaPropertiesCalculated()
      Returns:
      Collection of MetaProperty, not null and read only
      Throws:
      XavaException
    • getOnlyReadPropertiesNames

      public Collection<String> getOnlyReadPropertiesNames()
      Returns:
      Collection of String, not null and read only
      Throws:
      XavaException
    • getOnlyReadWithFormulaPropertiesNames

      public Collection<String> getOnlyReadWithFormulaPropertiesNames()
      Returns:
      Collection of String, not null and read only
      Throws:
      XavaException
    • getCalculatedPropertiesNames

      public Collection<String> getCalculatedPropertiesNames()
      Returns:
      Collection of String, not null and read only
    • getMetaPropertiesWithDefaultValueCalculator

      public Collection<MetaProperty> getMetaPropertiesWithDefaultValueCalculator()
    • getMetaPropertiesViewWithDefaultCalculator

      public Collection<MetaProperty> getMetaPropertiesViewWithDefaultCalculator()
    • getMetaReferencesWithDefaultValueCalculator

      public Collection<MetaReference> getMetaReferencesWithDefaultValueCalculator()
    • getMetaPropertiesPersistents

      public Collection<MetaProperty> getMetaPropertiesPersistents()
      Ordered as in component definition.
      Throws:
      XavaException
    • getMetaPropertiesPersistentsFromReference

      public Collection<MetaProperty> getMetaPropertiesPersistentsFromReference(String referenceName)
      Ordered as in component definition.
      Throws:
      XavaException
    • getPersistentPropertiesNames

      public Collection<String> getPersistentPropertiesNames()
      Ordered as in component definition.
      Throws:
      XavaException
    • getMetaPropertiesWithDefaultValueOnCreate

      public Collection<MetaProperty> getMetaPropertiesWithDefaultValueOnCreate()
      Excludes calculator that implements IHibernateIdGeneratorCalculator.

      Returns:
      Collection of String, not null and read only
      Throws:
      XavaException
    • getMetaProperties

      public Collection<MetaProperty> getMetaProperties()
      Returns:
      Collection of MetaProperty, not null and read only
    • getMetaReferences

      public Collection<MetaReference> getMetaReferences()
      Returns:
      Collection of MetaReference, not null and read only
    • getMetaEntityReferences

      public Collection<MetaReference> getMetaEntityReferences()
      Returns:
      Collection of MetaReference, not null and read only
      Throws:
      XavaException
    • getMetaReferencesWithMapping

      public Collection<MetaReference> getMetaReferencesWithMapping()
      Returns:
      Collection of MetaReference, not null and read only
      Throws:
      XavaException
    • getMetaReferencesToEntity

      public Collection<MetaReference> getMetaReferencesToEntity()
      Returns:
      Collection of MetaReference, not null and read only
      Throws:
      XavaException
    • getMetaReferencesKey

      public Collection<MetaReference> getMetaReferencesKey()
      Returns:
      Collection of MetaReference, not null and read only
      Throws:
      XavaException
    • getMetaReferencesKeyAndSearchKey

      public Collection<MetaReference> getMetaReferencesKeyAndSearchKey()
      Returns:
      Collection of MetaReference, not null and read only
      Throws:
      XavaException
    • getMetaAggregateReferences

      public Collection<MetaReference> getMetaAggregateReferences()
      Returns:
      Collection of MetaReference, not null and read only
      Throws:
      XavaException
    • getMetaCollections

      public Collection<MetaCollection> getMetaCollections()
      Returns:
      Collection of MetaCollection, not null and read only
    • getMetaViewByDefault

      public MetaView getMetaViewByDefault()
      Returns:
      Not null. If no view is set, then it will generate a default one
      Throws:
      XavaException
    • getMetaViewOnlyKeys

      public MetaView getMetaViewOnlyKeys()
      Throws:
      XavaException
      Since:
      7.1.6
    • getMetaComponent

      public MetaComponent getMetaComponent()
      Container component of model.

      Returns:
      Not null
    • setMetaComponent

      public void setMetaComponent(MetaComponent metaComponent)
      Container component of model.

      Parameters:
      metaComponent - Not null
    • isCalculated

      public boolean isCalculated(String propertyName)
      Throws:
      XavaException
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • isPojoGenerated

      public boolean isPojoGenerated()
    • setPojoGenerated

      public void setPojoGenerated(boolean generated)
    • getMapping

      public abstract ModelMapping getMapping()
      Throws:
      XavaException
    • containsMetaReferenceWithModel

      public boolean containsMetaReferenceWithModel(String name)
    • extractKeyValues

      public Map<String,Object> extractKeyValues(Map<String,Object> values)
      A map with the values that are keys in the sent map.

      Parameters:
      values - Not null
      Returns:
      Not null
      Throws:
      XavaException
    • extractSearchKeyValues

      public Map<String,Object> extractSearchKeyValues(Map<String,Object> values)
      Throws:
      XavaException
    • extractKeyValuesFlattenEmbeddedIds

      public Map<String,Object> extractKeyValuesFlattenEmbeddedIds(Map<String,Object> values)
      Throws:
      XavaException
      Since:
      6.2.2
    • isKeyOrSearchKey

      public boolean isKeyOrSearchKey(String name)
      Throws:
      XavaException
    • isKey

      public boolean isKey(String name)
      Throws:
      XavaException
    • isHiddenKey

      public boolean isHiddenKey(String name)
      Throws:
      XavaException
    • isVersion

      public boolean isVersion(String name)
      Throws:
      XavaException
    • containsValidadors

      public boolean containsValidadors()
    • getMetaCalculatorsPostCreate

      public List<MetaCalculator> getMetaCalculatorsPostCreate()
      Returns:
      Not null
    • getMetaCalculatorPostCreate

      public MetaCalculator getMetaCalculatorPostCreate(int idx)
    • getMetaCalculatorsPostLoad

      public List<MetaCalculator> getMetaCalculatorsPostLoad()
      Returns:
      Not null
    • getMetaCalculatorPostLoad

      public MetaCalculator getMetaCalculatorPostLoad(int idx)
    • getMetaCalculatorsPreRemove

      public List<MetaCalculator> getMetaCalculatorsPreRemove()
      Returns:
      Not null
    • getMetaCalculatorPreRemove

      public MetaCalculator getMetaCalculatorPreRemove(int idx)
    • getMetaCalculatorsPostModify

      public List<MetaCalculator> getMetaCalculatorsPostModify()
      Returns:
      Not null
    • getMetaCalculatorPostModify

      public MetaCalculator getMetaCalculatorPostModify(int idx)
    • getMetaValidators

      public Collection<MetaValidator> getMetaValidators()
      Returns:
      Not null
    • getMetaValidatorsRemove

      public Collection<MetaValidator> getMetaValidatorsRemove()
    • toPOJO

      public Object toPOJO(Map values)
      Create a POJO corresponding to this model, and populate it with the sent values in map format.

      Parameters:
      values - Values to populate the pojo. Can contains nested maps. Cannot be null
      Throws:
      XavaException
    • fillPOJO

      public void fillPOJO(Object pojo, Map<String,Object> values)
      Fill an already existing POJO corresponding to this model, and populate it with the sent values in map format.

      Parameters:
      values - Values to populate the pojo. Can contain nested maps. Cannot be null
      Throws:
      XavaException
    • toMap

      public Map<String,Object> toMap(Object modelObject)
      Convert an object of this model in a map of values.

      The model object can be a POJO (of class in getPOJOClass()) or any object that implements the interface of this model, that is, IInvoice, ICustomer, ISeller, etc. Hence you can use POJOs or EJB2 CMP beans, or whatever object that implements the interface.

      Parameters:
      modelObject -
      Returns:
      if modelObject is null returns an empty map
      Throws:
      XavaException
    • toKeyMap

      public Map<String,Object> toKeyMap(Object modelObject)
      Convert an object of this model in a map of values with its key values.

      The model object can be a POJO (of class in getPOJOClass()) or any object that implements the interface of this model, that is, IInvoice, ICustomer, ISeller, etc. Hence you can use POJOs or EJB2 CMP beans, or whatever object that implements the interface.

      Parameters:
      modelObject -
      Returns:
      if modelObject is null returns an empty map
      Throws:
      XavaException
    • toString

      public String toString(Map<String,Object> key)
      The string representation of models represented by this meta model, from a map with its values.

      Returns:
      null if the sent map is null, empty or all values are null
      Throws:
      XavaException
    • toString

      public String toString(Object pojo)
      The string representation of models represented by this meta model, from a pojo object.

      Returns:
      null if the sent object is null
      Throws:
      XavaException
    • getViewPropertiesNames

      public Collection<String> getViewPropertiesNames()
    • getMetaPropertiesView

      public Collection<MetaProperty> getMetaPropertiesView()
    • getMetaModelContainer

      public MetaModel getMetaModelContainer()
      If this is a aggregate the return the container, else the main entity.
      Returns:
      Not null
      Throws:
      XavaException
    • setContainerModelName

      public void setContainerModelName(String modelName)
    • getContainerModelName

      public String getContainerModelName()
    • getMetaCollectionsWithConditionInOthersModels

      public Collection<MetaCollection> getMetaCollectionsWithConditionInOthersModels()
      Throws:
      XavaException
    • getMetaColectionsWithConditionReferenceTo

      public Collection<MetaCollection> getMetaColectionsWithConditionReferenceTo(String modelName)
    • addInterfaceName

      public void addInterfaceName(String name)
    • getInterfacesNames

      public Collection<String> getInterfacesNames()
    • getImplements

      public String getImplements()
      String in java format: comma separate interfaces names
    • getRecursiveQualifiedPropertiesNames

      public Collection<String> getRecursiveQualifiedPropertiesNames()
      Does not include Transient properties and properties from collections
      Throws:
      XavaException
    • getRecursiveQualifiedPropertiesNamesUntilSecondLevel

      public Collection<String> getRecursiveQualifiedPropertiesNamesUntilSecondLevel()
      Does not include Transient properties and properties from collections
      Throws:
      XavaException
      Since:
      4.9
    • getRecursiveQualifiedPropertiesNamesIncludingCollections

      public Collection<String> getRecursiveQualifiedPropertiesNamesIncludingCollections()
      Does not include Transient properties
      Throws:
      XavaException
      Since:
      6.5
    • getRecursiveQualifiedPropertiesNamesUntilSecondLevelIncludingCollections

      public Collection<String> getRecursiveQualifiedPropertiesNamesUntilSecondLevelIncludingCollections()
      Does not include Transient properties
      Throws:
      XavaException
      Since:
      6.5
    • get

      public static MetaModel get(String modelName) throws ElementNotFoundException
      Gets the MetaModel from its name.

      Qualified names are supported, that is you can use:

       MetaModel.get("Invoice.InvoceDetail");
       
      If InvoiceDetail is a aggregate of Invoice component.

      For obtaining the entity metamodel you can use the name of the component, in this way

       MetaModel.get("Invoice");
       
      Throws:
      ElementNotFoundException - If the component does not have associated any MetaModel
      XavaException - Any problem
    • getForPOJO

      public static MetaModel getForPOJO(Object pojo) throws ElementNotFoundException
      Gets the MetaModel for the pojo class specified.

      Throws:
      ElementNotFoundException - If the pojo does not have associated any MetaModel
      XavaException - Any problem
    • getForPOJOClass

      public static MetaModel getForPOJOClass(Class pojoClass) throws ElementNotFoundException
      Gets the MetaModel for the pojo class specified.

      Throws:
      ElementNotFoundException - If the pojoClass does not have associated any MetaModel
      XavaException - Any problem
    • existsForPOJOClass

      public static boolean existsForPOJOClass(Class pojoClass) throws Exception
      To ask if the pojo class has an MetaModel associated.
      Throws:
      Exception
    • getInterfaceName

      public String getInterfaceName()
      Throws:
      XavaException
    • isPOJOAvailable

      public boolean isPOJOAvailable()
      Since:
      5.6.1
    • getPOJOClassName

      public String getPOJOClassName()
      Throws:
      XavaException
    • setPOJOClassName

      public void setPOJOClassName(String pojoClassName)
      Throws:
      XavaException
    • getPOJOClass

      public Class getPOJOClass()
      Throws:
      XavaException
    • getPOJOKeyClass

      public Class getPOJOKeyClass()
      Throws:
      XavaException
    • setPOJOKeyClass

      public void setPOJOKeyClass(Class pojoKeyClass)
    • isAnnotatedEJB3

      public boolean isAnnotatedEJB3()
    • setAnnotatedEJB3

      public void setAnnotatedEJB3(boolean annotatedEJB3)
    • getVersionPropertyName

      public String getVersionPropertyName()
      Throws:
      XavaException
    • hasVersionProperty

      public boolean hasVersionProperty()
      Throws:
      XavaException
    • hasDateTimeProperty

      public boolean hasDateTimeProperty()
    • hasHiddenKey

      public boolean hasHiddenKey()
    • someModelHasDefaultCalculatorOnCreate

      public static boolean someModelHasDefaultCalculatorOnCreate()
    • someModelHasPostCreateCalculator

      public static boolean someModelHasPostCreateCalculator()
    • someModelHasPostModifyCalculator

      public static boolean someModelHasPostModifyCalculator()
    • someModelHasPreRemoveCalculator

      public static boolean someModelHasPreRemoveCalculator()
    • someModelHasPostLoadCalculator

      public static boolean someModelHasPostLoadCalculator()
    • getContainerReference

      public String getContainerReference()
    • setContainerReference

      public void setContainerReference(String containerReference)
    • isXmlComponent

      public boolean isXmlComponent()
      Since:
      5.6
    • setXmlComponent

      public void setXmlComponent(boolean xmlComponent)
      Since:
      5.6