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

java.lang.Object
  extended by hudson.model.JobProperty<hudson.model.AbstractProject<?,?>>
      extended by com.sonyericsson.hudson.plugins.metadata.model.MetadataJobProperty
All Implemented Interfaces:
MetadataContainer<MetadataValue>, MetadataParent<MetadataValue>, hudson.ExtensionPoint, hudson.model.Describable<hudson.model.JobProperty<?>>, hudson.model.ReconfigurableDescribable<hudson.model.JobProperty<?>>, hudson.tasks.BuildStep

@ExportedBean
public class MetadataJobProperty
extends hudson.model.JobProperty<hudson.model.AbstractProject<?,?>>
implements MetadataContainer<MetadataValue>

Gives support for meta data on Projects and their builds.

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

Nested Class Summary
static class MetadataJobProperty.MetaDataJobPropertyDescriptor
          Descriptor for the MetadataJobProperty.
 
Nested classes/interfaces inherited from interface hudson.tasks.BuildStep
hudson.tasks.BuildStep.PublisherList
 
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
hudson.ExtensionPoint.LegacyInstancesAreScopedToHudson
 
Field Summary
 
Fields inherited from class hudson.model.JobProperty
owner
 
Fields inherited from interface hudson.tasks.BuildStep
BUILDERS, PUBLISHERS
 
Constructor Summary
MetadataJobProperty()
          Default constructor.
MetadataJobProperty(List<MetadataValue> values)
          Standard DataBound Constructor.
 
Method Summary
 Collection<MetadataValue> addChild(MetadataValue value)
          Adds the child to the list of children.
 Collection<MetadataValue> addChildren(Collection<MetadataValue> childValues)
          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.
<T extends MetadataDefinition>
List<MetadataDefinition>
getDefinitionsAsFlatList(org.kohsuke.stapler.StaplerRequest request)
          Returns the registered MetadataDefinitions as a flattened out Collection, with only leaves.
 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.
 Collection<? extends hudson.model.Action> getJobActions(hudson.model.AbstractProject<?,?> job)
           
 Collection<MetadataValue> getNonDefinitionValues()
          Getter for the Values not coming from definitions.
 hudson.model.AbstractProject<?,?> getOwner()
          The current Project.
 List<MetadataValue> getUserValues()
          All the non generated values.
 Object getValueForDefinition(MetadataDefinition definition)
          Returns the user set value for a definition if one is set, if not, returns the default value for the definition.
 List<MetadataValue> getValues()
          The meta data.
 int indexOf(String name)
          The index of the child with the provided name.
 MetadataValueDefinitionHelper initiateHelper()
          Initiates and returns a MetadataValueDefinitionHelper.
 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.
 void setValues(List<MetadataValue> values)
          Setter for the values.
 net.sf.json.JSON toJson()
          Convert this object into a JSON object.
 
Methods inherited from class hudson.model.JobProperty
getDescriptor, getJobAction, getJobOverrides, getProjectAction, getProjectActions, getRequiredMonitorService, getSubTasks, perform, prebuild, reconfigure, setOwner
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MetadataJobProperty

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

Parameters:
values - the meta data.

MetadataJobProperty

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

Method Detail

getValues

public List<MetadataValue> getValues()
The meta data.

Returns:
the values.

setValues

public void setValues(List<MetadataValue> values)
Setter for the values.

Parameters:
values - the values.

getUserValues

public List<MetadataValue> getUserValues()
All the non generated values. I.e. the values that the user has put in.

Returns:
all user values.

getOwner

public hudson.model.AbstractProject<?,?> getOwner()
The current Project.

Returns:
the owner.

getJobActions

public Collection<? extends hudson.model.Action> getJobActions(hudson.model.AbstractProject<?,?> job)
Overrides:
getJobActions in class hudson.model.JobProperty<hudson.model.AbstractProject<?,?>>

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> childValues)
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:
childValues - 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.

getDefinitionsAsFlatList

public <T extends MetadataDefinition> List<MetadataDefinition> getDefinitionsAsFlatList(org.kohsuke.stapler.StaplerRequest request)
Returns the registered MetadataDefinitions as a flattened out Collection, with only leaves.

Type Parameters:
T - the MetadataDefinition type.
Parameters:
request - the current http request.
Returns:
a list of MetadataDefinitions.

getValueForDefinition

public Object getValueForDefinition(MetadataDefinition definition)
Returns the user set value for a definition if one is set, if not, returns the default value for the definition.

Parameters:
definition - the MetadataDefinition to find a value for.
Returns:
the value for the MetadataDefinition if one is set, otherwise the default.

getNonDefinitionValues

public Collection<MetadataValue> getNonDefinitionValues()
Getter for the Values not coming from definitions.

Returns:
the values.

initiateHelper

public MetadataValueDefinitionHelper initiateHelper()
Initiates and returns a MetadataValueDefinitionHelper.

Returns:
a new MetadataValueDefinitionHelper.

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)

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.