Rev 7082 | Blame | Compare with Previous | Last modification | View Log | RSS feed
package com.erggroup.buildtool.ripple;import java.util.ArrayList;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import com.erggroup.buildtool.utilities.XmlBuilder;/*** entity class representing how derived files are produced on a platform* Recognizes that a package may have different build standards on different platforms* for example, Jats may be used to build production code on a win32 build machine and debug code on a solaris build* machine* potentially supports mixing build standards* for example, Jats may be used to build code on one build machine, and ERG ant on another* this is not supported in the release manager** This package maps the BuildStandard Family (Windows,Linux,Solaris) to the underlying* Machine Types based on information provided by the Release Manager Database**/public class BuildStandard{/*** Logger** @attribute*/private static final Logger mLogger = LoggerFactory.getLogger(BuildStandard.class);/*** engine associated with the baseline in which this packages build standard is owned** @aggregation composite*/private RippleEngine mRippleEngine;/**** @attribute*/private boolean mGeneric = false;/*** When true the package can be built using one of the known standards**/private boolean mSupported = true;/*** build Family: Linux, Win32, Solaris, ...*/public String mMachClass = null;/*** Array of build machine types: win32, solaris, solaris10_x86 ....*/public ArrayList<String> mMachTypes = null;/*** Items to assist in creating platform and standard descriptions*/String mType = null;String mData = null;String mFriendly = null;/*** Constructor* The only method to create and modify the Build Standard Information* Once set it cannot be modified - this greatly simplifies its implementation** Since the class captures data from the Ripple Engine the data is only valid for the duration of a* build cycle. When the machine information is refreshed from database the data in this class* will be stale. This is not an issue as the package data is discarded on every planning cycle.*/public BuildStandard(RippleEngine rippleEngine, String buildMachineFamily, String buildStandardAddendum){mLogger.debug("BuildStandard");mRippleEngine = rippleEngine;mMachClass = buildMachineFamily;//// Convert the provided Machine Class into an array of Machine Types// Generic is special// EscrowMode: Generic is treated as all known (in the buildset) platforms// DeaemonMode: Generic is treated as the master machine type//if (buildMachineFamily.compareTo("Generic") == 0){mGeneric = true;if(mRippleEngine.mDaemon){mMachTypes = new ArrayList<String>();mMachTypes.add(Package.mGenericMachtype);}else{mMachTypes = mRippleEngine.mReleaseManager.mReleaseConfigCollection.mMachineTypes;}}else{// Not Generic// Create a list of machine types based on the conversion from machClass to the machTypes in// the current build set//mMachTypes = mRippleEngine.mReleaseManager.mReleaseConfigCollection.mMachineHash.get(mMachClass);}if (mMachTypes == null || mMachTypes.size() == 0){mSupported = false;}if (buildStandardAddendum.compareTo("Production") == 0){mType = "jats";mData = "production";mFriendly = "Jats Production";}else if (buildStandardAddendum.compareTo("Debug") == 0){mType = "jats";mData = "debug";mFriendly = "Jats Debug";}else if (buildStandardAddendum.compareTo("Production and Debug") == 0){mType = "jats";mData = "all";mFriendly = "Jats All";}else if (buildStandardAddendum.startsWith("Java ")){mType = "ant";mData = buildStandardAddendum.substring(5);mFriendly = "Ant Java " + mData;}else{mSupported = false;mType = "jats";mData = "unknown";mFriendly = "Jats Unknown";}}/*** returns for xml purposes* "<platform machtype="win32" method="jats" arg="all"/>",* "<platform machtype="solaris10_sparc32" method="ant" arg="java 1.6"/>"* "<platform machtype="solaris10_x86" method="ant" arg="java 1.6"/>"* "<platform machtype="sparc" method="ant" arg="java 1.6"/>"* "<platform machtype="linux_i386" method="jats" arg="prod"/>"** May return multiple lines*/public void getBuildStandardXml(XmlBuilder xml){mLogger.debug("getBuildStandardXml");if (mMachTypes != null && mSupported){for (String item : mMachTypes){XmlBuilder entry = xml.addNewElement("buildinfo");entry.addAttribute("machtype", item);entry.addAttribute("method", mType);if (mData != null){entry.addAttribute("arg", mData);}}}mLogger.debug("getBuildStandardXml returned {}", xml.toString());}/*** returns for text (email) purposes* win32: jats all* solaris10_sparc32: ant java 1.6* solaris10_x86: ant java 1.6* sparc: ant java 1.6* linux_i386: jats prod** May return multiple lines, separated by <br> as the string is intended for use in email*/public String getBuildStandard(){mLogger.debug("getBuildStandard");String retVal = new String();if (mMachTypes != null && mSupported){String joiner1 = "";for (String item : mMachTypes){retVal += joiner1 + item + ":" + mFriendly;joiner1 = "<br>";}}mLogger.debug("getBuildStandard returned {}", retVal);return retVal;}/*** Get a string that describes the Build Standard* It will be used within emails and info within XML files.** Expected format:* machineClass:standard** May be an empty string - if there is no build standard.*/public String getBuildStandardText(){String rv = "";// No build standardif (!mSupported){return rv;}rv += mMachClass + ":" + mFriendly;return rv;}/*** accessor method*/public boolean isGeneric(){mLogger.debug("getGeneric returned {}", mGeneric);return mGeneric;}/*** accessor method*/public boolean supportedBuildStandard(){mLogger.debug("supportedBuildStandard returned {}", mSupported);return mSupported;}/**** @return true if the Build Standard is active* ie: This build standard will participate in the building of the package**/public boolean isActive(){return (mSupported);}}