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 getAllPersistent() throws XavaException
      All models (Entities and Aggregates) with a mapping associated.
      Returns:
      of type MetaModel
      Throws:
      XavaException
    • getAllPojoGenerated

      public static Collection getAllPojoGenerated() throws XavaException
      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 getMetaFinders()
      Returns:
      Collection of MetaFinder. Not null
    • getMetaMethods

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

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

      public boolean hasDefaultCalculatorOnCreate()
    • addMetaReference

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

      public void addMetaView(MetaView newMetaView) throws XavaException
      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() throws XavaException
      Class that contains the properties defined in this model.

      Returns:
      Not null
      Throws:
      XavaException
    • getMetaMember

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

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

      Throws:
      ElementNotFoundException
      XavaException
    • getMetaPropertyView

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

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

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

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

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

      public Collection getMetaViews() throws XavaException
      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 getPropertiesNames()
      Ordered as in component definition.
      Returns:
      Not null, read only and serializable
    • getReferencesNames

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

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

      public Collection getEntityReferencesNames() throws XavaException
      Throws:
      XavaException
    • getAggregateReferencesNames

      public Collection getAggregateReferencesNames() throws XavaException
      Throws:
      XavaException
    • getMetaCollectionsAgregate

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

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

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

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

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

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

      public Collection<String> getAllKeyPropertiesNames() throws XavaException
      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() throws XavaException
      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() throws XavaException
      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() throws XavaException
      Returns:
      Collection of MetaProperty, not null and read only
      Throws:
      XavaException
    • getMetaMembersKey

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

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

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

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

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

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

      public Collection getMetaPropertiesWithDefaultValueCalculator()
    • getMetaPropertiesViewWithDefaultCalculator

      public Collection getMetaPropertiesViewWithDefaultCalculator()
    • getMetaReferencesWithDefaultValueCalculator

      public Collection<MetaReference> getMetaReferencesWithDefaultValueCalculator()
    • getMetaPropertiesPersistents

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

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

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

      public Collection<MetaProperty> getMetaPropertiesWithDefaultValueOnCreate() throws XavaException
      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 getMetaEntityReferences() throws XavaException
      Returns:
      Collection of MetaReference, not null and read only
      Throws:
      XavaException
    • getMetaReferencesWithMapping

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

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

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

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

      public Collection getMetaAggregateReferences() throws XavaException
      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() throws XavaException
      Returns:
      Not null. If no view is set, then it will generate a default one
      Throws:
      XavaException
    • getMetaViewOnlyKeys

      public MetaView getMetaViewOnlyKeys() throws XavaException
      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
      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
      Throws:
      XavaException
    • containsMetaReferenceWithModel

      public boolean containsMetaReferenceWithModel(String name)
    • extractKeyValues

      public Map extractKeyValues(Map values) throws XavaException
      A map with the values that are keys in the sent map.

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

      public Map extractSearchKeyValues(Map values) throws XavaException
      Throws:
      XavaException
    • extractKeyValuesFlattenEmbeddedIds

      public Map extractKeyValuesFlattenEmbeddedIds(Map values) throws XavaException
      Throws:
      XavaException
      Since:
      6.2.2
    • isKeyOrSearchKey

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

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

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

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

      public boolean containsValidadors()
    • getMetaCalculatorsPostCreate

      public List getMetaCalculatorsPostCreate()
      Returns:
      Not null
    • getMetaCalculatorPostCreate

      public MetaCalculator getMetaCalculatorPostCreate(int idx)
    • getMetaCalculatorsPostLoad

      public List getMetaCalculatorsPostLoad()
      Returns:
      Not null
    • getMetaCalculatorPostLoad

      public MetaCalculator getMetaCalculatorPostLoad(int idx)
    • getMetaCalculatorsPreRemove

      public List getMetaCalculatorsPreRemove()
      Returns:
      Not null
    • getMetaCalculatorPreRemove

      public MetaCalculator getMetaCalculatorPreRemove(int idx)
    • getMetaCalculatorsPostModify

      public List getMetaCalculatorsPostModify()
      Returns:
      Not null
    • getMetaCalculatorPostModify

      public MetaCalculator getMetaCalculatorPostModify(int idx)
    • getMetaValidators

      public Collection getMetaValidators()
      Returns:
      Not null
    • getMetaValidatorsRemove

      public Collection getMetaValidatorsRemove()
    • toPOJO

      public Object toPOJO(Map values) throws XavaException
      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 values) throws XavaException
      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 toMap(Object modelObject) throws XavaException
      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 toKeyMap(Object modelObject) throws XavaException
      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 key) throws XavaException
      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) throws XavaException
      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 getViewPropertiesNames()
    • getMetaPropertiesView

      public Collection getMetaPropertiesView()
    • getMetaModelContainer

      public MetaModel getMetaModelContainer() throws XavaException
      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 getMetaCollectionsWithConditionInOthersModels() throws XavaException
      Throws:
      XavaException
    • getMetaColectionsWithConditionReferenceTo

      public Collection getMetaColectionsWithConditionReferenceTo(String modelName)
    • addInterfaceName

      public void addInterfaceName(String name)
    • getInterfacesNames

      public Collection getInterfacesNames()
    • getImplements

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

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

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

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

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

      public static MetaModel get(String modelName) throws ElementNotFoundException, XavaException
      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, XavaException
      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, XavaException
      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
      Throws:
      XavaException
    • isPOJOAvailable

      public boolean isPOJOAvailable()
      Since:
      5.6.1
    • getPOJOClassName

      public String getPOJOClassName() throws XavaException
      Throws:
      XavaException
    • setPOJOClassName

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

      public Class getPOJOClass() throws XavaException
      Throws:
      XavaException
    • getPOJOKeyClass

      public Class getPOJOKeyClass() throws XavaException
      Throws:
      XavaException
    • setPOJOKeyClass

      public void setPOJOKeyClass(Class pojoKeyClass)
    • isAnnotatedEJB3

      public boolean isAnnotatedEJB3()
    • setAnnotatedEJB3

      public void setAnnotatedEJB3(boolean annotatedEJB3)
    • getVersionPropertyName

      public String getVersionPropertyName() throws XavaException
      Throws:
      XavaException
    • hasVersionProperty

      public boolean hasVersionProperty() throws XavaException
      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