com.sonyericsson.hudson.plugins.metadata.model
Class MetadataNodeProperty

java.lang.Object
  extended by hudson.slaves.NodeProperty<hudson.model.Node>
      extended by com.sonyericsson.hudson.plugins.metadata.model.MetadataNodeProperty
All Implemented Interfaces:
MetadataContainer<MetadataValue>, MetadataParent<MetadataValue>, hudson.ExtensionPoint, hudson.model.Describable<hudson.slaves.NodeProperty<?>>, hudson.model.ReconfigurableDescribable<hudson.slaves.NodeProperty<?>>

@ExportedBean
public class MetadataNodeProperty
extends hudson.slaves.NodeProperty<hudson.model.Node>
implements MetadataContainer<MetadataValue>

Stores metadata about Nodes.

Author:
Robert Sandell <robert.sandell@sonyericsson.com>

Nested Class Summary
static class MetadataNodeProperty.MetadataNodePropertyDescriptor
          Descriptor for MetadataNodeProperty.
 
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
hudson.ExtensionPoint.LegacyInstancesAreScopedToHudson
 
Field Summary
 
Fields inherited from class hudson.slaves.NodeProperty
node
 
Constructor Summary
MetadataNodeProperty()
          Default constructor.
MetadataNodeProperty(List<MetadataValue> values)
          Standard Constructor.
 
Method Summary
 Collection<MetadataValue> addChild(MetadataValue value)
          Adds the child to the list of children.
 Collection<MetadataValue> addChildren(Collection<MetadataValue> children)
          Adds the children to this parent's list of children.
 hudson.security.ACL getACL()
          Returns the ACL for the owner of the container..
 MetadataValue getChild(String name)
          Returns the child with the given name, or null if there is none.
 Collection<String> getChildNames()
          The child names of this parent.
 Collection<MetadataValue> getChildren()
          The children of this parent.
 String getFullName()
          The full name of the element.
 String getFullName(String separator)
          The full name of the element, using the chosen separator string.
 String getFullNameFrom(MetadataParent base)
          Gives the full name from the given parent.
 List<MetadataValue> getValues()
          The list of metadata values.
 int indexOf(String name)
          The index of the child with the provided name.
 boolean requiresReplacement()
          If this parent type requires to be replaced or not when a replacement command is issued.
 void save()
          Saves the container to disc, usually achieved by calling save on whatever Saveable this container is in.
 MetadataValue setChild(int index, MetadataValue value)
          Sets the child on index with the provided value, replacing any object currently on that index.
 boolean shouldDisplaySummary(org.kohsuke.stapler.StaplerRequest request)
          Jenkins likes to display both the master's properties summary.jelly and the node's summary.jelly on the computer page.
 net.sf.json.JSON toJson()
          Convert this object into a JSON object.
 
Methods inherited from class hudson.slaves.NodeProperty
all, buildEnvVars, canTake, canTake, for_, getDescriptor, reconfigure, setNode, setUp
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MetadataNodeProperty

@DataBoundConstructor
public MetadataNodeProperty(List<MetadataValue> values)
Standard Constructor.

Parameters:
values - the metadata for a Node.

MetadataNodeProperty

public MetadataNodeProperty()
Default constructor. Do not use this unless you are a serializer.

Method Detail

getValues

public List<MetadataValue> getValues()
The list of metadata values.

Returns:
the values.
See Also:
getChildren()

getChild

public MetadataValue getChild(String name)
Description copied from interface: MetadataParent
Returns the child with the given name, or null if there is none. comparison is case insensitive.

Specified by:
getChild in interface MetadataParent<MetadataValue>
Parameters:
name - the name to search for.
Returns:
the child.

indexOf

public int indexOf(String name)
Description copied from interface: MetadataParent
The index of the child with the provided name.

Specified by:
indexOf in interface MetadataParent<MetadataValue>
Parameters:
name - the name of the child to find.
Returns:
the index of the child or -1 if no child with that name was found.

setChild

public MetadataValue setChild(int index,
                              MetadataValue value)
Description copied from interface: MetadataParent
Sets the child on index with the provided value, replacing any object currently on that index.

Specified by:
setChild in interface MetadataParent<MetadataValue>
Parameters:
index - the index to set.
value - the child to set.
Returns:
the value previous at the specified index.

addChild

public Collection<MetadataValue> addChild(MetadataValue value)
Description copied from interface: MetadataParent
Adds the child to the list of children. If a child with the same name is already present, the children should try to be merged. The returned child is either the child itself if it is a leaf or a clone of itself with the children that failed to be merged if it contains children, null indicates a fully successful merge/add.

Specified by:
addChild in interface MetadataParent<MetadataValue>
Parameters:
value - the child to add.
Returns:
null if the operation was successful.

addChildren

public Collection<MetadataValue> addChildren(Collection<MetadataValue> children)
Description copied from interface: MetadataParent
Adds the children to this parent's list of children. If a child with the same name is already present, the children should try to be merged.

Specified by:
addChildren in interface MetadataParent<MetadataValue>
Parameters:
children - the children to add.
Returns:
the children that failed to be added/merged or null if all succeeded.

getChildren

@Exported
public Collection<MetadataValue> getChildren()
Description copied from interface: MetadataParent
The children of this parent.

Specified by:
getChildren in interface MetadataParent<MetadataValue>
Returns:
the children.

getChildNames

public Collection<String> getChildNames()
Description copied from interface: MetadataParent
The child names of this parent.

Specified by:
getChildNames in interface MetadataParent<MetadataValue>
Returns:
the child names of this parent.

getFullName

public String getFullName()
Description copied from interface: MetadataParent
The full name of the element.

Specified by:
getFullName in interface MetadataParent<MetadataValue>
Returns:
the fullName.

getFullName

public String getFullName(String separator)
Description copied from interface: MetadataParent
The full name of the element, using the chosen separator string.

Specified by:
getFullName in interface MetadataParent<MetadataValue>
Parameters:
separator - the separator string.
Returns:
the fullName.

getFullNameFrom

public String getFullNameFrom(MetadataParent base)
Description copied from interface: MetadataParent
Gives the full name from the given parent.

Specified by:
getFullNameFrom in interface MetadataParent<MetadataValue>
Parameters:
base - the parent to base the tree structure from.
Returns:
a dot separated path from the base up to this item.

toJson

public net.sf.json.JSON toJson()
Description copied from interface: MetadataParent
Convert this object into a JSON object.

Specified by:
toJson in interface MetadataParent<MetadataValue>
Returns:
the JSON version.

requiresReplacement

public boolean requiresReplacement()
Description copied from interface: MetadataParent
If this parent type requires to be replaced or not when a replacement command is issued. I.e. If this is just a holder of children then it is not necessary, but if it contains more complex structures it might want to.

Specified by:
requiresReplacement in interface MetadataParent<MetadataValue>
Returns:
true if it needs to be replaced by fresher instances or false if it can be reused.
See Also:
MetadataValue.replacementOf( com.sonyericsson.hudson.plugins.metadata.model.values.MetadataValue)

shouldDisplaySummary

public boolean shouldDisplaySummary(org.kohsuke.stapler.StaplerRequest request)
Jenkins likes to display both the master's properties summary.jelly and the node's summary.jelly on the computer page. This method determines if the request really represents the Node that this property is tied to.

Parameters:
request - the request.
Returns:
true if the request is for this Node and the summary should be displayed.

save

public void save()
          throws IOException
Description copied from interface: MetadataContainer
Saves the container to disc, usually achieved by calling save on whatever Saveable this container is in.

Specified by:
save in interface MetadataContainer<MetadataValue>
Throws:
IOException - if the persistence.

getACL

public hudson.security.ACL getACL()
Description copied from interface: MetadataContainer
Returns the ACL for the owner of the container..

Specified by:
getACL in interface MetadataContainer<MetadataValue>
Returns:
the ACL.


Copyright © 2004-2013. All Rights Reserved.