info.magnolia.ui.vaadin.integration.jcr
Class AbstractJcrNodeAdapter

java.lang.Object
  extended by info.magnolia.ui.vaadin.integration.jcr.AbstractJcrAdapter
      extended by info.magnolia.ui.vaadin.integration.jcr.AbstractJcrNodeAdapter
All Implemented Interfaces:
com.vaadin.data.Item, ItemAdapter, JcrItemAdapter, Serializable
Direct Known Subclasses:
JcrNodeAdapter

public abstract class AbstractJcrNodeAdapter
extends AbstractJcrAdapter

Abstract implementation of an Item wrapping/representing a Node. Implements {Property.ValueChangeListener} in order to inform/change JCR property when a Vaadin property has changed. Access JCR repository for all read Jcr Property.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.vaadin.data.Item
com.vaadin.data.Item.Editor, com.vaadin.data.Item.PropertySetChangeEvent, com.vaadin.data.Item.PropertySetChangeListener, com.vaadin.data.Item.PropertySetChangeNotifier, com.vaadin.data.Item.Viewer
 
Field Summary
 
Fields inherited from class info.magnolia.ui.vaadin.integration.jcr.AbstractJcrAdapter
UNIDENTIFIED
 
Constructor Summary
AbstractJcrNodeAdapter(javax.jcr.Node jcrNode)
           
 
Method Summary
 AbstractJcrNodeAdapter addChild(AbstractJcrNodeAdapter child)
          Add a child adapter to the current Item.
 boolean addItemProperty(Object id, com.vaadin.data.Property property)
          Add a new JCR Property.
 javax.jcr.Node applyChanges()
          Returns the JCR Node represented by this Item with changes applied.
 AbstractJcrNodeAdapter getChild(String nodeName)
           
 Map<String,AbstractJcrNodeAdapter> getChildren()
           
 com.vaadin.data.Property getItemProperty(Object id)
           
 javax.jcr.Node getJcrItem()
          Return the corresponding node directly from the JCR repository.
 String getNodeName()
          Return the current Node Name.
 AbstractJcrNodeAdapter getParent()
          Return the current Parent Item (If Item is a child).
 String getPrimaryNodeTypeName()
          Return the Primary node type Name.
protected  Map<String,AbstractJcrNodeAdapter> getRemovedChildren()
           
protected  void initCommonAttributes(javax.jcr.Item jcrItem)
          Init common Item attributes.
 boolean isNode()
           
 boolean removeChild(AbstractJcrNodeAdapter toRemove)
          Remove a child Node from the child list.
 void setNodeName(String nodeName)
           
 void setParent(AbstractJcrNodeAdapter parent)
           
protected  void setPrimaryNodeTypeName(String primaryNodeTypeName)
           
 void updateProperties(javax.jcr.Item item)
          Updates and removes properties on given item, based on the AbstractJcrAdapter.changedProperties and AbstractJcrAdapter.removedProperties maps.
protected  void updateProperty(javax.jcr.Item item, String propertyId, com.vaadin.data.Property property)
          Update or remove property.
 
Methods inherited from class info.magnolia.ui.vaadin.integration.jcr.AbstractJcrAdapter
getChangedProperties, getItemId, getRemovedProperties, getWorkspace, hasChangedProperties, setItemId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface info.magnolia.ui.vaadin.integration.ItemAdapter
isNew
 
Methods inherited from interface com.vaadin.data.Item
getItemPropertyIds, removeItemProperty
 

Constructor Detail

AbstractJcrNodeAdapter

public AbstractJcrNodeAdapter(javax.jcr.Node jcrNode)
Method Detail

isNode

public boolean isNode()

initCommonAttributes

protected void initCommonAttributes(javax.jcr.Item jcrItem)
Description copied from class: AbstractJcrAdapter
Init common Item attributes.

Overrides:
initCommonAttributes in class AbstractJcrAdapter

setPrimaryNodeTypeName

protected void setPrimaryNodeTypeName(String primaryNodeTypeName)

getPrimaryNodeTypeName

public String getPrimaryNodeTypeName()
Return the Primary node type Name. This Node type is defined based on the related JCR Node. In case of new Node, the Type is passed during the construction of the new Item or if not defined, the Type is equivalent to the Parent Node Type.


getRemovedChildren

protected Map<String,AbstractJcrNodeAdapter> getRemovedChildren()

getJcrItem

public javax.jcr.Node getJcrItem()
Return the corresponding node directly from the JCR repository. The returned Node does not contains all changes done on the current Item, but it's a representation of the current stored Jcr node. To get the Jcr Node including the changes done on the current Item, use applyChanges().

Specified by:
getJcrItem in interface JcrItemAdapter
Overrides:
getJcrItem in class AbstractJcrAdapter

addItemProperty

public boolean addItemProperty(Object id,
                               com.vaadin.data.Property property)
Add a new JCR Property.


getItemProperty

public com.vaadin.data.Property getItemProperty(Object id)
Returns:
the property if it already exist on the JCR Item a new property if this property refer to the JCR Node name null if the property doesn't exist yet.

applyChanges

public javax.jcr.Node applyChanges()
                            throws javax.jcr.RepositoryException
Returns the JCR Node represented by this Item with changes applied. Updates both properties and child nodes. Will create new properties, set new values and remove those requested for removal. Child nodes will also be added, updated or removed.

Throws:
javax.jcr.RepositoryException

updateProperties

public void updateProperties(javax.jcr.Item item)
                      throws javax.jcr.RepositoryException
Description copied from class: AbstractJcrAdapter
Updates and removes properties on given item, based on the AbstractJcrAdapter.changedProperties and AbstractJcrAdapter.removedProperties maps. Read-only properties will not be updated and null valued properties will get removed.

Overrides:
updateProperties in class AbstractJcrAdapter
Throws:
javax.jcr.RepositoryException

updateProperty

protected void updateProperty(javax.jcr.Item item,
                              String propertyId,
                              com.vaadin.data.Property property)
Update or remove property. Property with flag saveInfo to false will not be updated. Property can refer to node property (like name, title) or node.MetaData property like (MetaData/template). Also handle the specific case of node renaming. If property JCR_NAME is present, Rename the node. In case the value has changed to null, it will be removed. When being called from updateProperties(javax.jcr.Item) we have to make sure it is removed before running in here as Item.removeItemProperty(java.lang.Object) is manipulating the AbstractJcrAdapter.changedProperties list directly.

Specified by:
updateProperty in class AbstractJcrAdapter

getChild

public AbstractJcrNodeAdapter getChild(String nodeName)
Parameters:
nodeName - name of the child node
Returns:
child if part of the children, or null if not defined.

getChildren

public Map<String,AbstractJcrNodeAdapter> getChildren()

addChild

public AbstractJcrNodeAdapter addChild(AbstractJcrNodeAdapter child)
Add a child adapter to the current Item. Only Child Nodes part of this Map will be persisted into Jcr.


removeChild

public boolean removeChild(AbstractJcrNodeAdapter toRemove)
Remove a child Node from the child list. When removing an JcrNodeAdapter, this child will be added to the Remove Child List even if this Item was not part of the current children list. All Item part from the removed list are removed from the Jcr repository.


getParent

public AbstractJcrNodeAdapter getParent()
Return the current Parent Item (If Item is a child). Parent is set by calling addChild(...


setParent

public void setParent(AbstractJcrNodeAdapter parent)

getNodeName

public String getNodeName()
Return the current Node Name. For new Item, this is the name set in the new Item constructor or null if not yet defined.


setNodeName

public void setNodeName(String nodeName)


Copyright © 2013 Magnolia International Ltd.. All Rights Reserved.