Пример #1
0
  public static void main(String args[])
      throws FileNotFoundException, SQLException, SimulationException {
    LOAD_SIM_TEST_PARAMS = true;
    // get output directory
    JFrame parent = null;
    userInput = new UserInput(parent);
    userInput.destDir = System.getProperty("user.dir");
    userInput.setVisible(true);
    if (userInput.destDir.isEmpty()) {
      System.out.println(
          "Destination directory not specified or user " + "selected cancel.  Aborting run.");
      System.exit(0);
    }

    ATNEngine atn = new ATNEngine();

    SimJob job = new SimJob();
    job.setJob_Descript("atn1");
    // job.setNode_Config("2,[5],2000,1.000,0,0,[70],2494,13.000,1,X=0.155,0");	//Info comes from
    // client
    job.setNode_Config(
        "5,[5],2000,1.000,1,K=9431.818,0,[14],1751,20.000,1,X=0.273,0,[31],1415,0.008,1,X=1.000,0,[42],240,0.205,1,X=0.437,0,[70],2494,13.000,1,X=0.155,0");
    job.setManip_Timestamp((new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(new Date()));
    job.setTimesteps(401);
    String atnManipId = UUID.randomUUID().toString();
    job.setATNManipulationId(atnManipId);
    atn.processSimJob(job);
    System.out.println("Processing complete.");
  }
 public Properties getUserInputValues() {
   Properties prop = new Properties();
   for (int i = 0; i < uiList.size(); i++) {
     UserInput ui = (UserInput) uiList.get(i);
     XmlUIElement el = (XmlUIElement) uiElementsList.get(i);
     ui.setValue(el.getValue());
     prop.put("$UserInput$" + ui.getID(), el.getValue());
   }
   return prop;
 }
 public XmlUIElement getXmlElement(UserInput uiArg) {
   String type = "textfield";
   Qualifier qual = uiArg.getQualifier();
   String enumNames[] = null;
   String enumValues[] = null;
   if (qual != null) {
     type = qual.getType();
     Vector enumVec = qual.getEnums();
     if (enumVec.size() > 0) {
       enumNames = new String[enumVec.size()];
       enumValues = new String[enumVec.size()];
       for (int i = 0; i < enumNames.length; i++) {
         com.adventnet.management.config.xml.Enum e =
             (com.adventnet.management.config.xml.Enum) enumVec.elementAt(i);
         enumNames[i] = e.getName();
         enumValues[i] = e.getValue();
         if (enumNames[i] == null) {
           enumNames[i] = enumValues[i];
         }
       }
     }
   }
   XmlUIElement el = getXmlUIElementFor(type);
   if (el == null) {
     return null;
   }
   el.setDescription(uiArg.getDescription());
   if (enumNames != null) {
     el.setEnumeratedValues(enumNames, enumValues);
   }
   if ((qual != null) && (qual.getRange() != null) && (!(qual.getRange().equals("")))) {
     el.setRange(qual.getRange());
   }
   if (uiArg.getDefaultValue() != null) {
     el.setValue(uiArg.getDefaultValue());
   }
   String isEditable = uiArg.getAttribute("editable");
   if (isEditable != null) {
     if (isEditable.trim().equals("false")) {
       el.setEditable(false);
     } else {
       el.setEditable(true);
     }
   }
   String required = uiArg.getAttribute("required");
   {
     if (required.trim().equals("true")) {
       el.setRequired(true);
       numberOfRequiredFields++;
     } else {
       el.setRequired(false);
     }
   }
   el.setLabelName(uiArg.getLabel());
   return el;
 }
 public ArrayList getXmlUIElements(Form f) throws InvalidTemplateException {
   Vector v = f.getUserInputs();
   Vector userInputVecArg = new Vector();
   int size = v.size();
   for (int i = 0; i < size; i++) {
     UserInput ui = (UserInput) v.elementAt(i);
     String satisfied = ui.getAttribute("satisfied");
     if (satisfied == null || (!satisfied.equals("false"))) {
       userInputVecArg.addElement(ui);
     }
   }
   ArrayList list = new ArrayList(userInputVecArg.size());
   for (int i = 0, j = userInputVecArg.size(); i < j; i++) {
     UserInput ui = (UserInput) userInputVecArg.elementAt(i);
     uiList.add(ui);
     XmlUIElement el = getXmlElement(ui);
     uiElementsList.add(el);
     list.add(el);
   }
   return list;
 }
 /** This replaces the user input variables in the XML template * */
 public String replaceVariablesInString(String xmlStringArg) {
   String modXmlString = xmlStringArg;
   Properties prop = new Properties();
   for (int i = 0; i < uiList.size(); i++) {
     UserInput ui = (UserInput) uiList.get(i);
     XmlUIElement el = (XmlUIElement) uiElementsList.get(i);
     ui.setValue(el.getValue());
     prop.put("$UserInput$" + ui.getID(), el.getValue());
     // modXmlString = StringUtil.replaceStringBySpecifiedString(modXmlString,"$UserInput$" +
     // ui.getID(),el.getValue());
   }
   Template template = null;
   try {
     template = new Template(xmlStringArg);
     //			template = PopulateTemplateParams.substituteParams(template, prop, 3);
     template = PopulateTemplateParams.substituteParams(template, prop);
   } catch (Exception exc) {
     exc.printStackTrace();
   }
   // return modXmlString;
   return template.toString();
 }
  /**
   * Enter an interactive user-query loop, accepting queries and showing the retrieved documents in
   * ranked order.
   */
  public void processQueries() {

    System.out.println("Now able to process queries. When done, enter an empty query to exit.");
    // Loop indefinitely answering queries
    do {
      // Get a query from the console
      String query = UserInput.prompt("\nEnter query:  ");
      // If query is empty then exit the interactive loop
      if (query.equals("")) break;

      HashMapVector queryVector;
      // If there is a space in the query, then the user is searching for a bigram
      // therefore, make a bigram hashmapvector
      if (query.contains(" "))
        queryVector = (new TextStringDocument(query, stem)).hashMapBigramVector();
      // Otherwise, queryVector is a normal hashmapvector
      else queryVector = (new TextStringDocument(query, stem)).hashMapVector();
      Retrieval[] retrievals = retrieve(queryVector);
      presentRetrievals(queryVector, retrievals);
    } while (true);
  }