com.sonyericsson.hudson.plugins.gerrit.trigger.gerritnotifier
Class ParameterExpander

java.lang.Object
  extended by com.sonyericsson.hudson.plugins.gerrit.trigger.gerritnotifier.ParameterExpander

public class ParameterExpander
extends Object

Expands a parameterized string to its full potential.

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

Field Summary
static int DEFAULT_PARAMETERS_COUNT
          How many default parameters there are (plus one) to initialize the size of the parameters-map.
static String MESSAGE_DELIMITER
          The delimiter used to separate build URLs from their messages.
 
Constructor Summary
ParameterExpander(IGerritHudsonTriggerConfig config)
          Constructor.
ParameterExpander(IGerritHudsonTriggerConfig config, hudson.model.Hudson hudson)
          Constructor.
 
Method Summary
protected  String findMessage(String completedCommand)
          Finds the --message part of the command.
 String getBuildCompletedCommand(BuildMemory.MemoryImprint memoryImprint, hudson.model.TaskListener listener)
          Gets the "expanded" build completed command to send to gerrit.
 String getBuildCompletedMessage(BuildMemory.MemoryImprint memoryImprint, hudson.model.TaskListener listener)
          Returns cover message to be send after build has been completed.
 String getBuildStartedCommand(hudson.model.AbstractBuild r, hudson.model.TaskListener taskListener, ChangeBasedEvent event, BuildsStartedStats stats)
          Gets the expanded string to send to Gerrit for a build-started event.
 String getBuildStartedMessage(hudson.model.AbstractBuild build, hudson.model.TaskListener listener, ChangeBasedEvent event, BuildsStartedStats stats)
          Returns cover message to be send after build has been started.
protected  int getCodeReviewValue(hudson.model.Result res, GerritTrigger trigger)
          Finds the code review value for the specified build result on the configured trigger.
 int getMinimumCodeReviewValue(BuildMemory.MemoryImprint memoryImprint, boolean onlyBuilt)
          Returns the minimum code review value for the build results in the memory.
 int getMinimumVerifiedValue(BuildMemory.MemoryImprint memoryImprint, boolean onlyBuilt)
          Returns the minimum verified value for the build results in the memory.
protected  int getVerifiedValue(hudson.model.Result res, GerritTrigger trigger)
          Finds the verified value for the specified build result on the configured trigger.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_PARAMETERS_COUNT

public static final int DEFAULT_PARAMETERS_COUNT
How many default parameters there are (plus one) to initialize the size of the parameters-map.

See Also:
Constant Field Values

MESSAGE_DELIMITER

public static final String MESSAGE_DELIMITER
The delimiter used to separate build URLs from their messages.

See Also:
Constant Field Values
Constructor Detail

ParameterExpander

public ParameterExpander(IGerritHudsonTriggerConfig config,
                         hudson.model.Hudson hudson)
Constructor.

Parameters:
config - the global config.
hudson - the Hudson instance.

ParameterExpander

public ParameterExpander(IGerritHudsonTriggerConfig config)
Constructor.

Parameters:
config - the global config.
Method Detail

getBuildStartedCommand

public String getBuildStartedCommand(hudson.model.AbstractBuild r,
                                     hudson.model.TaskListener taskListener,
                                     ChangeBasedEvent event,
                                     BuildsStartedStats stats)
Gets the expanded string to send to Gerrit for a build-started event.

Parameters:
r - the build.
taskListener - the taskListener.
event - the event.
stats - the statistics.
Returns:
the "expanded" command string.

getCodeReviewValue

protected int getCodeReviewValue(hudson.model.Result res,
                                 GerritTrigger trigger)
Finds the code review value for the specified build result on the configured trigger.

Parameters:
res - the build result.
trigger - the trigger that might have overridden values.
Returns:
the value.

getVerifiedValue

protected int getVerifiedValue(hudson.model.Result res,
                               GerritTrigger trigger)
Finds the verified value for the specified build result on the configured trigger.

Parameters:
res - the build result.
trigger - the trigger that might have overridden values.
Returns:
the value.

getMinimumVerifiedValue

public int getMinimumVerifiedValue(BuildMemory.MemoryImprint memoryImprint,
                                   boolean onlyBuilt)
Returns the minimum verified value for the build results in the memory.

Parameters:
memoryImprint - the memory.
onlyBuilt - only count builds that completed (no NOT_BUILT builds)
Returns:
the lowest verified value.

getMinimumCodeReviewValue

public int getMinimumCodeReviewValue(BuildMemory.MemoryImprint memoryImprint,
                                     boolean onlyBuilt)
Returns the minimum code review value for the build results in the memory.

Parameters:
memoryImprint - the memory
onlyBuilt - only count builds that completed (no NOT_BUILT builds)
Returns:
the lowest code review value.

getBuildCompletedCommand

public String getBuildCompletedCommand(BuildMemory.MemoryImprint memoryImprint,
                                       hudson.model.TaskListener listener)
Gets the "expanded" build completed command to send to gerrit.

Parameters:
memoryImprint - the memory with all the information
listener - the taskListener
Returns:
the command.

getBuildCompletedMessage

public String getBuildCompletedMessage(BuildMemory.MemoryImprint memoryImprint,
                                       hudson.model.TaskListener listener)
Returns cover message to be send after build has been completed.

Parameters:
memoryImprint - memory
listener - listener
Returns:
the message for the build completed command.

getBuildStartedMessage

public String getBuildStartedMessage(hudson.model.AbstractBuild build,
                                     hudson.model.TaskListener listener,
                                     ChangeBasedEvent event,
                                     BuildsStartedStats stats)
Returns cover message to be send after build has been started.

Parameters:
build - build
listener - listener
event - event
stats - stats
Returns:
the message for the build started command.

findMessage

protected String findMessage(String completedCommand)
Finds the --message part of the command. TODO Solve it in a better way

Parameters:
completedCommand - the command
Returns:
the message


Copyright © 2004-2013. All Rights Reserved.