Exemple #1
0
 private SQNode getNodeInfoFromSQ(String nodeId) {
   SQNode nodeInfo = null;
   ProtocolBuilder mgr = m_studyQueue.getMgr();
   VElement velem = mgr.getElement(nodeId);
   if (velem != null) {
     nodeInfo = new SQNode();
     for (String attr : SQNode.getStandardAttributes()) {
       String value = mgr.getAttribute(velem, attr);
       nodeInfo.setAttr(attr, value);
     }
   }
   //        String when = "";
   //        String[] whenEnums = {"_day", "_night"};
   //        for (String w : whenEnums) {
   //            if (psLabel.contains(w)) {
   //                when = w;
   //                psLabel = psLabel.replace(w, "");
   //            }
   //            if (title.contains(w)) {
   //                when = w;
   //                title = title.replace(w, "");
   //            }
   //        }
   return nodeInfo;
 }
Exemple #2
0
  /**
   * Set properties in studies "prop" file for the given SQ node. A typical location: <br>
   * <CODE>
   *  vnmrsys/studies/exp2/tmpstudy/info/n002/prop
   *  </CODE>
   *
   * @param cursqexp Experiment directory for the SQ.
   * @param id The ID of the SQ node.
   * @param node The node to write about.
   */
  private void writePropFile(String cursqexp, String id, SQNode node) {

    // The attributes that are written into the "props" file
    // (e.g., studies/exp2/tmpstudy/info/n002/prop), in the order
    // they should appear. Order is important, because macros
    // may read the value of a particular line number without checking
    // the key.
    // In xmaction it is noted:
    // "$id=sqval[1]    $type=sqval[2] $status=sqval[3]  - fixed position"
    // (ID is added to the front of the list after reading the prop file.)
    final String[] propAttributes = {
      ATTR_TYPE, ATTR_STATUS, ATTR_LOCK, ATTR_TITLE, ATTR_EXP, ATTR_TIME, ATTR_MACRO, ATTR_DATA,
    };

    String path = cursqexp + "/tmpstudy/info/" + id;
    File filePath = new File(path, "/prop");
    PrintWriter out = null;
    try {
      new File(path).mkdirs();
      out = new PrintWriter(filePath);
      for (String name : propAttributes) {
        out.println(name + " " + node.getAttr(name));
      }
    } catch (FileNotFoundException e) {
      Messages.postDebug("Could not write file " + filePath.getPath());
    } finally {
      try {
        out.close();
      } catch (Exception e) {
      }
    }
  }
Exemple #3
0
 private boolean updateNodeInSQ(String id, SQNode srcNode, List<String> changed) {
   boolean ok = false;
   ProtocolBuilder mgr = m_studyQueue.getMgr();
   VElement elem = mgr.getElement(id);
   if (elem != null) {
     for (String attr : changed) {
       String value = srcNode.getAttr(attr);
       mgr.setAttribute(elem, attr, value);
     }
     ok = true;
   }
   return ok;
 }
Exemple #4
0
  public void updateStatsBuildUI(boolean isInitial, SQNodeList nodeList, String cursqexp) {
    if (DebugOutput.isSetFor("AllSQUpdater")) {
      Messages.postDebug("--------------------- Calc node list:");
      SQBuild.printNodeList(nodeList);
      Messages.postDebug("--------------------- End calc nodes");
    }
    // TODO: All of updateStatsBuildUI needs cleaning up.
    // Get list of action nodes visible in the SQ
    List<String> visibleIds = getNodeIdsFromSQ(ProtocolBuilder.ACTIONS);
    String sampleInfoId = removeSampleInfoNode(visibleIds);
    if (DebugOutput.isSetFor("AllSQUpdater") && sampleInfoId != null) {
      Messages.postDebug("SampleInfo node ignored");
    }

    if (!isInitial && nodeList.size() != visibleIds.size()) {
      Messages.postDebug(
          "SQUpdater", "calc nodes: " + nodeList.size() + ", vis nodes: " + visibleIds.size());
      Util.sendToVnmr(m_updateCmd);
      if (DebugOutput.isSetFor("AllSQUpdater")) {
        Messages.postDebug(
            visibleIds.size() + " nodes visible in SQ; " + nodeList.size() + " calculated");

        // Print out the visibleNodes
        Messages.postDebug("--------------------- Visible node list:");
        SQNodeList visibleNodes = getNodeInfoFromSQ(visibleIds);
        for (SQNode node : visibleNodes) {
          Messages.postDebug(node.toString());
        }
        Messages.postDebug("--------------------- End visible nodes");
      }

    } else {
      // Get all attributes from the visible SQ nodes
      // Build list of the visible SQ Nodes
      SQNodeList visibleNodes = getNodeInfoFromSQ(visibleIds);

      if (DebugOutput.isSetFor("AllSQUpdater")) {
        Messages.postDebug("--------------------- Visible node attrs:");
        printAllNodeAttributes(visibleIds);
        Messages.postDebug("--------------------- End visible attrs");
      }

      // Find differences between nodeList and SQ
      boolean isDiff = false;
      if (DebugOutput.isSetFor("AllSQUpdater")) {
        Messages.postDebug("--------------------- Node diffs:");
      }
      for (int i = 0; i < nodeList.size(); i++) {
        SQNode node = nodeList.get(i);
        SQNode vnode = visibleNodes.get(i);
        String diffs = vnode.diff(node);
        if (diffs.length() > 0) {
          isDiff = true;
          if (DebugOutput.isSetFor("AllSQUpdater")) {
            Messages.postDebug("Node " + i + " (" + visibleIds.get(i) + ") differs:");
            Messages.postDebug(diffs);
          }

          //                    // TODO: May not need to check this stuff
          //                    String vstat = vnode.getStatus();
          //                    String cstat = node.getStatus();
          //                    Boolean completed = (cstat.equals(COMPLETED)
          //                                         && (vstat.equals(EXECUTING)
          //                                             || vstat.equals(ACTIVE)));
          //                    String vtitle = vnode.getTitle().trim();
          //                    // Displayed title may have other stuff after true title
          //                    String[] titleTokens = vtitle.split(" +", 2);
          //                    if (node.getTitle().contains(titleTokens[0]) || completed) {

          // Set some SQ node attributes to match calculated node
          List<String> changed = vnode.update(node);
          if (changed.size() > 0) {
            String nodeId = visibleIds.get(i);
            updateNodeInSQ(nodeId, vnode, changed);
            writePropFile(cursqexp, nodeId, vnode);
          }
          //                    }
        }
      }
      if (DebugOutput.isSetFor("AllSQUpdater")) {
        Messages.postDebug("--------------------- End node diffs");
      }
      if (!isDiff) {
        if (DebugOutput.isSetFor("SQUpdater")) {
          Messages.postDebug("NO DIFFERENCES");
        }
        //            } else {
        //                m_sqInfoDir = m_curSQExp + "/tmpstudy/info";
      }
    }
  }