com.evolveum.midpoint.schema.processor
Class PropertyContainerDefinition

java.lang.Object
  extended by com.evolveum.midpoint.schema.processor.Definition
      extended by com.evolveum.midpoint.schema.processor.ItemDefinition
          extended by com.evolveum.midpoint.schema.processor.PropertyContainerDefinition
All Implemented Interfaces:
DebugDumpable, Dumpable, java.io.Serializable
Direct Known Subclasses:
ObjectDefinition, ResourceObjectDefinition

public class PropertyContainerDefinition
extends ItemDefinition

Definition of a property container.

Property container groups properties into logical blocks. The reason for grouping may be as simple as better understandability of data structure. But the group usually means different meaning, source or structure of the data. For example, the property container is frequently used to hold properties that are dynamic, not fixed by a static schema. Such grouping also naturally translates to XML and helps to "quarantine" such properties to avoid Unique Particle Attribute problems.

Property Container contains a set of (potentially multi-valued) properties. The order of properties is not significant, regardless of the fact that it may be fixed in the XML representation. In the XML representation, each element inside Property Container must be either Property or a Property Container.

This class represents schema definition for property container. See Definition for more details.

Author:
Radovan Semancik
See Also:
Serialized Form

Field Summary
protected  ComplexTypeDefinition complexTypeDefinition
           
protected  boolean isRuntimeSchema
          This means that the property container is not defined by fixed (compile-time) schema.
protected  Schema schema
           
 
Fields inherited from class com.evolveum.midpoint.schema.processor.ItemDefinition
name
 
Fields inherited from class com.evolveum.midpoint.schema.processor.Definition
defaultName, displayName, help, ignored, typeName
 
Fields inherited from interface com.evolveum.midpoint.util.DebugDumpable
INDENT_STRING
 
Method Summary
 PropertyContainerDefinition clone()
          Shallow clone
protected  void copyDefinitionData(PropertyContainerDefinition clone)
           
 PropertyDefinition createPropertyDefinition(javax.xml.namespace.QName name)
           
 PropertyDefinition createPropertyDefinition(javax.xml.namespace.QName name, javax.xml.namespace.QName typeName)
          Creates new instance of property definition and adds it to the container.
 PropertyDefinition createPropertyDefinition(javax.xml.namespace.QName name, javax.xml.namespace.QName typeName, int minOccurs, int maxOccurs)
          Creates new instance of property definition and adds it to the container.
 PropertyDefinition createPropertyDefinition(java.lang.String localName, javax.xml.namespace.QName typeName)
          Creates new instance of property definition and adds it to the container.
 PropertyDefinition createPropertyDefinition(java.lang.String localName, java.lang.String localTypeName)
          Creates new instance of property definition and adds it to the container.
 PropertyDefinition createPropertyDefinition(java.lang.String localName, java.lang.String localTypeName, int minOccurs, int maxOccurs)
          Creates new instance of property definition and adds it to the container.
 java.lang.String debugDump(int indent)
           
protected  void fillProperties(java.lang.Object instance, PropertyContainer source)
          used for MidPoint -> JAXB conversion
<T extends ItemDefinition>
T
findItemDefinition(PropertyPath path, java.lang.Class<T> clazz)
           
 ItemDefinition findItemDefinition(javax.xml.namespace.QName name)
           
<T extends ItemDefinition>
T
findItemDefinition(javax.xml.namespace.QName name, java.lang.Class<T> clazz)
           
 PropertyContainerDefinition findPropertyContainerDefinition(PropertyPath path)
          Finds an inner PropertyContainerDefinition by following the property container path.
 PropertyContainerDefinition findPropertyContainerDefinition(javax.xml.namespace.QName name)
          Finds an inner PropertyContainerDefinition by looking at the property container name.
 PropertyDefinition findPropertyDefinition(PropertyPath propertyPath)
           
 PropertyDefinition findPropertyDefinition(javax.xml.namespace.QName name)
          Finds a PropertyDefinition by looking at the property name.
 ComplexTypeDefinition getComplexTypeDefinition()
           
 java.util.Collection<ItemDefinition> getDefinitions()
          Returns set of property definitions.
 java.util.Set<PropertyDefinition> getPropertyDefinitions()
          Returns set of property definitions.
protected  java.lang.String getSchemaNamespace()
           
 PropertyContainer instantiate(PropertyPath parentPath)
          Create property container instance with a default name.
 PropertyContainer instantiate(javax.xml.namespace.QName name, java.lang.Object element, PropertyPath parentPath)
          Create property container instance with a specified name and element.
 PropertyContainer instantiate(javax.xml.namespace.QName name, PropertyPath parentPath)
          Create property container instance with a specified name.
protected
<T> T
instantiateJaxbClass(java.lang.Class<T> clazz)
           
 boolean isEmpty()
           
 boolean isRuntimeSchema()
           
 boolean isWildcard()
           
protected
<T extends PropertyContainer>
T
parseAsContent(javax.xml.namespace.QName name, java.util.List<java.lang.Object> contentElements, java.lang.Class<T> type, PropertyPath parentPath)
           
 PropertyContainer parseAsContent(javax.xml.namespace.QName name, java.util.List<java.lang.Object> contentElements, PropertyPath parentPath)
           
 PropertyContainer parseItem(java.util.List<java.lang.Object> elements, PropertyPath parentPath)
          Creates new property container from DOM or JAXB representation (multiple elements).
 PropertyContainer parseItem(java.lang.Object element)
          Assumes top-level element (null parentPath)
protected
<T extends PropertyContainer>
T
parseItem(java.lang.Object element, java.lang.Class<T> type, PropertyPath parentPath)
          Creates new property container from DOM or JAXB representation (multiple elements).
 PropertyContainer parseItem(java.lang.Object element, PropertyPath parentPath)
          Creates new property container from DOM or JAXB representation (single element).
protected
<T extends PropertyContainer>
T
parseItemFromJaxbElement(javax.xml.bind.JAXBElement jaxbElement, java.lang.Class<T> type, PropertyPath parentPath)
           
protected
<T extends PropertyContainer>
T
parseItemFromJaxbObject(java.lang.Object jaxbObject, java.lang.Class<T> type, PropertyPath parentPath)
           
 PropertyContainer parseItemFromJaxbObject(java.lang.Object jaxbObject, PropertyPath parentPath)
           
protected
<T extends PropertyContainer>
T
parseItemFromJaxbObject(java.lang.Object jaxbObject, javax.xml.namespace.QName elementName, java.lang.Class<T> type, PropertyPath parentPath)
           
 java.util.Collection<? extends Item> parseItems(java.util.List<java.lang.Object> elements, PropertyPath parentPath)
          Parses items from a list of elements.
protected  java.util.Collection<? extends Item> parseItems(java.util.List<java.lang.Object> elements, PropertyPath parentPath, java.util.Collection<? extends ItemDefinition> selection)
          Parses items from a list of elements.
 void setComplexTypeDefinition(ComplexTypeDefinition complexTypeDefinition)
           
 void setRuntimeSchema(boolean isRuntimeSchema)
           
 
Methods inherited from class com.evolveum.midpoint.schema.processor.ItemDefinition
copyDefinitionData, equals, getName, getNameOrDefaultName, hashCode, setName, toString
 
Methods inherited from class com.evolveum.midpoint.schema.processor.Definition
copyDefinitionData, debugDump, dump, getDefaultName, getDisplayName, getHelp, getTypeName, isIgnored, setDisplayName, setHelp, setIgnored
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

complexTypeDefinition

protected ComplexTypeDefinition complexTypeDefinition

schema

protected Schema schema

isRuntimeSchema

protected boolean isRuntimeSchema
This means that the property container is not defined by fixed (compile-time) schema. This in fact means that we need to use getAny in a JAXB types. It does not influence the processing of DOM that much, as that does not really depend on compile-time/run-time distinction.

Method Detail

getSchemaNamespace

protected java.lang.String getSchemaNamespace()

getComplexTypeDefinition

public ComplexTypeDefinition getComplexTypeDefinition()

setComplexTypeDefinition

public void setComplexTypeDefinition(ComplexTypeDefinition complexTypeDefinition)

isWildcard

public boolean isWildcard()

findItemDefinition

public <T extends ItemDefinition> T findItemDefinition(javax.xml.namespace.QName name,
                                                       java.lang.Class<T> clazz)

findItemDefinition

public <T extends ItemDefinition> T findItemDefinition(PropertyPath path,
                                                       java.lang.Class<T> clazz)

findItemDefinition

public ItemDefinition findItemDefinition(javax.xml.namespace.QName name)

findPropertyDefinition

public PropertyDefinition findPropertyDefinition(javax.xml.namespace.QName name)
Finds a PropertyDefinition by looking at the property name.

Returns null if nothing is found.

Parameters:
name - property definition name
Returns:
found property definition or null

findPropertyDefinition

public PropertyDefinition findPropertyDefinition(PropertyPath propertyPath)

findPropertyContainerDefinition

public PropertyContainerDefinition findPropertyContainerDefinition(javax.xml.namespace.QName name)
Finds an inner PropertyContainerDefinition by looking at the property container name.

Returns null if nothing is found.

Parameters:
name - property container definition name
Returns:
found property container definition or null

findPropertyContainerDefinition

public PropertyContainerDefinition findPropertyContainerDefinition(PropertyPath path)
Finds an inner PropertyContainerDefinition by following the property container path.

Returns null if nothing is found.

Parameters:
path - property container path
Returns:
found property container definition or null

getDefinitions

public java.util.Collection<ItemDefinition> getDefinitions()
Returns set of property definitions.

WARNING: This may return definitions from the associated complex type. Therefore changing the returned set may influence also the complex type definition.

The set contains all property definitions of all types that were parsed. Order of definitions is insignificant.

Returns:
set of definitions

getPropertyDefinitions

public java.util.Set<PropertyDefinition> getPropertyDefinitions()
Returns set of property definitions.

The set contains all property definitions of all types that were parsed. Order of definitions is insignificant.

The returned set is immutable! All changes may be lost.

Returns:
set of definitions

isRuntimeSchema

public boolean isRuntimeSchema()

setRuntimeSchema

public void setRuntimeSchema(boolean isRuntimeSchema)

instantiate

public PropertyContainer instantiate(PropertyPath parentPath)
Create property container instance with a default name.

This is a preferred way how to create property container.

Specified by:
instantiate in class ItemDefinition
Returns:
created item instance

instantiate

public PropertyContainer instantiate(javax.xml.namespace.QName name,
                                     PropertyPath parentPath)
Create property container instance with a specified name.

This is a preferred way how to create property container.

Specified by:
instantiate in class ItemDefinition
Returns:
created item instance

instantiate

public PropertyContainer instantiate(javax.xml.namespace.QName name,
                                     java.lang.Object element,
                                     PropertyPath parentPath)
Create property container instance with a specified name and element.

This is a preferred way how to create property container.

Specified by:
instantiate in class ItemDefinition
Returns:
created item instance

clone

public PropertyContainerDefinition clone()
Shallow clone

Overrides:
clone in class java.lang.Object

copyDefinitionData

protected void copyDefinitionData(PropertyContainerDefinition clone)

createPropertyDefinition

public PropertyDefinition createPropertyDefinition(javax.xml.namespace.QName name,
                                                   javax.xml.namespace.QName typeName)
Creates new instance of property definition and adds it to the container.

This is the preferred method of creating a new definition.

Parameters:
name - name of the property (element name)
typeName - XSD type of the property
Returns:
created property definition

createPropertyDefinition

public PropertyDefinition createPropertyDefinition(javax.xml.namespace.QName name,
                                                   javax.xml.namespace.QName typeName,
                                                   int minOccurs,
                                                   int maxOccurs)
Creates new instance of property definition and adds it to the container.

This is the preferred method of creating a new definition.

Parameters:
name - name of the property (element name)
typeName - XSD type of the property
minOccurs - minimal number of occurrences
maxOccurs - maximal number of occurrences (-1 means unbounded)
Returns:
created property definition

createPropertyDefinition

public PropertyDefinition createPropertyDefinition(javax.xml.namespace.QName name)

createPropertyDefinition

public PropertyDefinition createPropertyDefinition(java.lang.String localName,
                                                   javax.xml.namespace.QName typeName)
Creates new instance of property definition and adds it to the container.

This is the preferred method of creating a new definition.

Parameters:
localName - name of the property (element name) relative to the schema namespace
typeName - XSD type of the property
Returns:
created property definition

createPropertyDefinition

public PropertyDefinition createPropertyDefinition(java.lang.String localName,
                                                   java.lang.String localTypeName)
Creates new instance of property definition and adds it to the container.

This is the preferred method of creating a new definition.

Parameters:
localName - name of the property (element name) relative to the schema namespace
localTypeName - XSD type of the property
Returns:
created property definition

createPropertyDefinition

public PropertyDefinition createPropertyDefinition(java.lang.String localName,
                                                   java.lang.String localTypeName,
                                                   int minOccurs,
                                                   int maxOccurs)
Creates new instance of property definition and adds it to the container.

This is the preferred method of creating a new definition.

Parameters:
localName - name of the property (element name) relative to the schema namespace
localTypeName - XSD type of the property
minOccurs - minimal number of occurrences
maxOccurs - maximal number of occurrences (-1 means unbounded)
Returns:
created property definition

parseItem

public PropertyContainer parseItem(java.lang.Object element,
                                   PropertyPath parentPath)
                            throws SchemaException
Creates new property container from DOM or JAXB representation (single element).

Parameters:
element - DOM representation of property container
parentPath -
Returns:
created property container parsed from the element
Throws:
SchemaException - error parsing the element

parseItem

public PropertyContainer parseItem(java.lang.Object element)
                            throws SchemaException
Assumes top-level element (null parentPath)

Throws:
SchemaException

parseItem

public PropertyContainer parseItem(java.util.List<java.lang.Object> elements,
                                   PropertyPath parentPath)
                            throws SchemaException
Creates new property container from DOM or JAXB representation (multiple elements).

Specified by:
parseItem in class ItemDefinition
Parameters:
elements - DOM or JAXB representation of property container
Returns:
created property container parsed from the elements
Throws:
SchemaException - error parsing the elements

parseItem

protected <T extends PropertyContainer> T parseItem(java.lang.Object element,
                                                    java.lang.Class<T> type,
                                                    PropertyPath parentPath)
                                         throws SchemaException
Creates new property container from DOM or JAXB representation (multiple elements).

Internal parametric method.

Type Parameters:
T - subclass of property container to return
Parameters:
element - JAXB or DOM element representing the container
type - subclass of property container to return
Returns:
created new property container (or subclass)
Throws:
SchemaException - error parsing the elements

parseAsContent

public PropertyContainer parseAsContent(javax.xml.namespace.QName name,
                                        java.util.List<java.lang.Object> contentElements,
                                        PropertyPath parentPath)
                                 throws SchemaException
Throws:
SchemaException

parseAsContent

protected <T extends PropertyContainer> T parseAsContent(javax.xml.namespace.QName name,
                                                         java.util.List<java.lang.Object> contentElements,
                                                         java.lang.Class<T> type,
                                                         PropertyPath parentPath)
                                              throws SchemaException
Throws:
SchemaException

parseItems

public java.util.Collection<? extends Item> parseItems(java.util.List<java.lang.Object> elements,
                                                       PropertyPath parentPath)
                                                throws SchemaException
Parses items from a list of elements.

The elements must describe properties or property container as defined by this PropertyContainerDefinition. Serializes all the elements from the provided list.

Parameters:
elements - list of elements with serialized properties
Returns:
set of deserialized items
Throws:
SchemaException - error parsing the elements

parseItems

protected java.util.Collection<? extends Item> parseItems(java.util.List<java.lang.Object> elements,
                                                          PropertyPath parentPath,
                                                          java.util.Collection<? extends ItemDefinition> selection)
                                                   throws SchemaException
Parses items from a list of elements.

The elements must describe properties or property container as defined by this PropertyContainerDefinition. Serializes all the elements from the provided list.

Internal parametric method. This does the real work.

min/max constraints are not checked now TODO: maybe we need to check them

Throws:
SchemaException

parseItemFromJaxbObject

public PropertyContainer parseItemFromJaxbObject(java.lang.Object jaxbObject,
                                                 PropertyPath parentPath)
                                          throws SchemaException
Specified by:
parseItemFromJaxbObject in class ItemDefinition
Throws:
SchemaException

parseItemFromJaxbElement

protected <T extends PropertyContainer> T parseItemFromJaxbElement(javax.xml.bind.JAXBElement jaxbElement,
                                                                   java.lang.Class<T> type,
                                                                   PropertyPath parentPath)
                                                        throws SchemaException
Throws:
SchemaException

parseItemFromJaxbObject

protected <T extends PropertyContainer> T parseItemFromJaxbObject(java.lang.Object jaxbObject,
                                                                  java.lang.Class<T> type,
                                                                  PropertyPath parentPath)
                                                       throws SchemaException
Throws:
SchemaException

parseItemFromJaxbObject

protected <T extends PropertyContainer> T parseItemFromJaxbObject(java.lang.Object jaxbObject,
                                                                  javax.xml.namespace.QName elementName,
                                                                  java.lang.Class<T> type,
                                                                  PropertyPath parentPath)
                                                       throws SchemaException
Throws:
SchemaException

fillProperties

protected void fillProperties(java.lang.Object instance,
                              PropertyContainer source)
                       throws SchemaException
used for MidPoint -> JAXB conversion

Throws:
SchemaException

instantiateJaxbClass

protected <T> T instantiateJaxbClass(java.lang.Class<T> clazz)

debugDump

public java.lang.String debugDump(int indent)
Specified by:
debugDump in interface DebugDumpable
Overrides:
debugDump in class Definition

isEmpty

public boolean isEmpty()
Returns:


Copyright © 2012 evolveum. All Rights Reserved.