Class TriggerContext
- java.lang.Object
-
- com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.TriggerContext
-
public class TriggerContext extends Object
This bean contains information to theGerritCause
about what other builds were involved in the same event. For backwards compatibility reasons this class is serialized by the help of the XStream converterTriggerContextConverter
so any future additions to this class need to be handled in that class as well or it won't be serialized correctly.- Author:
- Robert Sandell <robert.sandell@sonyericsson.com>
-
-
Constructor Summary
Constructors Constructor Description TriggerContext()
Default constructor.TriggerContext(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
Standard constructor.TriggerContext(Run thisBuild, com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event, List<TriggeredItemEntity> others)
standard constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addOtherBuild(Run build)
Adds a build to the list of other builds if it doesn't exist in the list.void
addOtherProject(Job project)
Adds a project to the list of other projects if it doesn't exist in the list.com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent
getEvent()
The event for this context.List<Run>
getOtherBuilds()
Gets all the other builds in this context.List<Job>
getOtherProjects()
Gets all the other projects in this context.List<TriggeredItemEntity>
getOthers()
A list of builds that were triggered by the same event as "this" build.List<TriggeredItemEntity>
getSortedOthers()
Gets all the other entities in the most user friendly order.TriggeredItemEntity
getThisBuild()
The build that this context represents.boolean
hasOthers()
Tells if there are any other builds or projects in this context.void
setOthers(List<TriggeredItemEntity> otherBuilds)
A list of builds that were triggered by the same event as "this" build.void
setThisBuild(TriggeredItemEntity thisBuild)
The build that this context represents.void
setThisBuild(Run thisBuild)
The build that this context represents.
-
-
-
Constructor Detail
-
TriggerContext
public TriggerContext(Run thisBuild, com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event, List<TriggeredItemEntity> others)
standard constructor.- Parameters:
thisBuild
- this build.event
- the event for this context.others
- the other building and untriggered builds.
-
TriggerContext
public TriggerContext(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
Standard constructor.- Parameters:
event
- the event for this context.
-
TriggerContext
public TriggerContext()
Default constructor.
-
-
Method Detail
-
getOthers
public List<TriggeredItemEntity> getOthers()
A list of builds that were triggered by the same event as "this" build.- Returns:
- the builds.
-
setOthers
public void setOthers(List<TriggeredItemEntity> otherBuilds)
A list of builds that were triggered by the same event as "this" build. Could contain non-triggered builds represented byTriggeredItemEntity.getBuild()
== null. Do not use this method unless you are a serializer, useaddOtherBuild(hudson.model.Run)
for adding builds.- Parameters:
otherBuilds
- the builds.
-
getThisBuild
public TriggeredItemEntity getThisBuild()
The build that this context represents.- Returns:
- the build.
-
setThisBuild
public void setThisBuild(TriggeredItemEntity thisBuild)
The build that this context represents.- Parameters:
thisBuild
- the build.
-
setThisBuild
public void setThisBuild(Run thisBuild)
The build that this context represents.- Parameters:
thisBuild
- the build.
-
getEvent
public com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent getEvent()
The event for this context.- Returns:
- the event.
-
addOtherBuild
public void addOtherBuild(Run build)
Adds a build to the list of other builds if it doesn't exist in the list. Also if the build's project exists in the list of other projects, the project will be removed from that list.- Parameters:
build
- the build to add.- See Also:
getOtherBuilds()
-
addOtherProject
public void addOtherProject(Job project)
Adds a project to the list of other projects if it doesn't exist in the list.- Parameters:
project
- the project to add.- See Also:
getOtherProjects()
-
hasOthers
public boolean hasOthers()
Tells if there are any other builds or projects in this context.- Returns:
- true if it is so.
- See Also:
getOtherBuilds()
,getOtherProjects()
-
getOtherBuilds
public List<Run> getOtherBuilds()
Gets all the other builds in this context. If some project hasn't started a build yet, that project will be unrepresented in this list.- Returns:
- a list of builds from this context.
-
getOtherProjects
public List<Job> getOtherProjects()
Gets all the other projects in this context.- Returns:
- a list of projects from this context.
-
getSortedOthers
public List<TriggeredItemEntity> getSortedOthers()
Gets all the other entities in the most user friendly order. on-going builds already finished builds builds without build number- Returns:
- a sorted list of entities from this context.
-
-