Rev 7033 | Blame | Compare with Previous | Last modification | View Log | RSS feed
package com.erggroup.buildtool.ripple;import org.slf4j.Logger;import org.slf4j.LoggerFactory;/**Enumeration of supported run levels*/public class RunLevel{/**Logger* @attribute*/private static final Logger mLogger = LoggerFactory.getLogger(RunLevel.class);/*** Build States - Used as Run Level* The integer value is inserted directly into the Release Manager Database**/public enum BuildState {DB_CANNOT_CONTINUE(1, "Cannot Continue"),DB_PAUSED(2, "Paused"),DB_ACTIVE(3, "Active"),DB_IDLE(4, "Idle"),DB_WAITING(5, "Waiting"),DB_PUBLISHING(6 ,"Publishing");private int state;private String stateText;private BuildState(int state, String text) { this.state = state; stateText = text;}public int toValue() { return state; }@Overridepublic String toString() { return stateText; }}/**integer value* @attribute*/public BuildState mBuildState;/** Extended state information* Valid only for DB_CANNOT_CONTINUE*/private String eState;/**constructor*/public RunLevel(BuildState buildState){mBuildState = buildState;}/**updates (advertises) the run level in the database* refer to sequence diagrams* @param newState*/public void persist(ReleaseManager releaseManager, int rconId, BuildState newState) throws Exception{mBuildState = newState;eState = null;mLogger.debug("persist " + rconId + " " + mBuildState.toValue());releaseManager.updateCurrentRunLevel(rconId, mBuildState.toValue());}/*** updates (advertises) the DB_CANNOT_CONTINUE state to the database, while* retaining more information for internal display purposes* @param releaseManager - Release Manager instance to work against* @param rconId - Identifies the build instance* @param extraInfo - Reason that the daemon cannot continue**/public void persistFault(ReleaseManager releaseManager, int rconId, String extraInfo) throws Exception{persist(releaseManager, rconId, BuildState.DB_CANNOT_CONTINUE);// Set after the call to 'persist' as persist will set it to nulleState = extraInfo;}public String toString(){String retVal;retVal = mBuildState.toString();if (mBuildState == BuildState.DB_CANNOT_CONTINUE && eState != null) {retVal += " - " + eState;}return retVal;}}