001: /*
002: * <copyright>
003: *
004: * Copyright 2000-2004 BBNT Solutions, LLC
005: * under sponsorship of the Defense Advanced Research Projects
006: * Agency (DARPA).
007: *
008: * You can redistribute this software and/or modify it under the
009: * terms of the Cougaar Open Source License as published on the
010: * Cougaar Open Source Website (www.cougaar.org).
011: *
012: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
013: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
014: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
015: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
016: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
017: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
018: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
019: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
020: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
021: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
022: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
023: *
024: * </copyright>
025: */
026:
027: package org.cougaar.tools.csmart.core.db;
028:
029: import java.util.Map;
030: import java.util.Set;
031:
032: /**
033: * Utility methods used by <code>CMT</code> and calling into it.
034: * @see CMT
035: */
036: public class ExperimentDB {
037:
038: /*
039: * Returns Map where the keys are human readable names (Strings) and
040: * the values are experiment ids (Strings).
041: */
042: public static Map getExperimentNames() {
043: return (Map) CMT.getExperimentNames();
044: }
045:
046: /*
047: * Deletes the given experiment from the database. Gets rid of the trial and associated other data.
048: * Does not get rid of the CMT assembly or other assemblies.
049: */
050: public static void deleteExperiment(String experimentId,
051: String experimentName) {
052: CMT.deleteExperiment(experimentId, experimentName);
053: }
054:
055: /**
056: * Returns true if experiment name is in database and false otherwise.
057: * Used to guarantee that experiment names in database are unique.
058: * @param experimentName human readable experiment name
059: * @return true if name is unique and false otherwise
060: */
061: public static boolean isExperimentNameInDatabase(
062: String experimentName) {
063: Map experimentNamesHT = getExperimentNames();
064: Set namesInDB = experimentNamesHT.keySet();
065: if (namesInDB != null && namesInDB.contains(experimentName))
066: return true;
067: return false;
068: }
069:
070: public static boolean isSocietyNameInDatabase(String societyName) {
071: return DBUtils.isSocietyNameInDatabase(societyName);
072: }
073:
074: public static boolean isRecipeNameInDatabase(String recipeName) {
075: return DBUtils.isRecipeNameInDatabase(recipeName);
076: }
077:
078: public static String getTrialId(String experimentId) {
079: return CMT.getTrialId(experimentId);
080: }
081:
082: public static Map getOrganizationGroups(String experimentId) {
083: return CMT.getOrganizationGroups(experimentId);
084: }
085:
086: public static Set getOrganizationsInGroup(String experimentId,
087: String groupId) {
088: return CMT.getOrganizationsInGroup(experimentId, groupId);
089: }
090:
091: public static boolean isULThreadSelected(String trialId,
092: String threadName) {
093: return CMT.isULThreadSelected(trialId, threadName);
094: }
095:
096: public static void setULThreadSelected(String trialId,
097: String threadName, boolean selected) {
098:
099: CMT.setULThreadSelected(trialId, threadName, selected);
100: //System.out.println("Thread: " + threadName + " selected: " + selected);
101: }
102:
103: public static boolean isGroupSelected(String trialId,
104: String groupName) {
105: return CMT.isGroupSelected(trialId, groupName);
106: }
107:
108: public static void setGroupSelected(String trialId,
109: String groupName, boolean selected) {
110: CMT.setGroupSelected(trialId, groupName, selected);
111: }
112:
113: public static int getMultiplier(String trialId, String groupName) {
114: return CMT.getMultiplier(trialId, groupName);
115: }
116:
117: public static void setMultiplier(String trialId, String groupName,
118: int value) {
119: CMT.setMultiplier(trialId, groupName, value);
120: }
121:
122: /**
123: * Clone specified experimentId with the specified human readable name.
124: * Returns new experiment id.
125: * Creates new trial id for new experiment id.
126: */
127: public static String cloneExperiment(String experimentId,
128: String newName) {
129: return (String) CMT.cloneExperiment(experimentId, newName);
130: }
131:
132: /**
133: * This MUST be called after calling setGroups, setThreads, or setMultipliers
134: * to actually update the experiment.
135: */
136: public static String updateCMTAssembly(String experimentId) {
137: return CMT.updateCMTAssembly(experimentId);
138: }
139:
140: // public static String getAssemblyId(String experimentId) {
141: // return CMT.getAssemblyId(experimentId);
142: // }
143:
144: public static void deleteCMTAssembly(String experimentId) {
145: String cmtASB = CMT.getAssemblyId(experimentId);
146: // System.out.println("Deleting CMT assembly: "+cmtASB+" for experiment: " +experimentId );
147: // This is only used when the forceRecomputeBox is checked
148: // In such cases though we still don't want to touch a base assembly
149: CMT.reallyClearCMTasb(cmtASB);
150: }
151: } // end of ExperimentDB.java
|