コード例 #1
0
ファイル: DsInConfigPanel.java プロジェクト: marcora/biomart
 private void initGui() {
   this.setLayout(new GridBagLayout());
   this.setBorder(
       new TitledBorder(new EtchedBorder(), dsElement.getAttributeValue(Resources.get("NAME"))));
   // find all partition tables in this dataset
   List<Element> ptList = dsElement.getChildren(Resources.get("PARTITIONTABLE"));
   for (Element ptElement : ptList) {
     List<ArrayList<String>> ptTable = JDomUtils.ptElement2Table(ptElement);
     ptTableMap.put(ptElement.getAttributeValue(Resources.get("NAME")), ptTable);
     // default 0
     ptCurrentIndex.put(ptElement.getAttributeValue(Resources.get("NAME")), 0);
   }
   // find the one has the same user and gui
   HashMap<String, String> conditions = new HashMap<String, String>();
   List<Element> myContainers =
       JDomUtils.findChildElements(dsElement, Resources.get("CONTAINER"), conditions);
   Set<String> ftSet = this.getFlattenPTableName();
   GridBagConstraints c = new GridBagConstraints();
   c.gridy = 0;
   c.gridx = 0;
   c.anchor = GridBagConstraints.FIRST_LINE_START;
   for (Element container : myContainers) {
     if (JDomUtils.isElementHiden(container)) continue;
     // if container is empty, don't add it
     if (!this.isContainerEmpty(container)) {
       this.add(createContainerPanel(container, dsElement, ftSet, false), c);
       c.gridx = c.gridx + 1;
     }
   }
 }
コード例 #2
0
  /**
   * Creates this from a JDOM element.
   *
   * @param jdom input
   */
  public UserQueryInput(Element jdom) {

    // Done in LuceneSearcher#computeQuery
    // protectRequest(jdom);

    for (Object e : jdom.getChildren()) {
      if (e instanceof Element) {
        Element node = (Element) e;
        String nodeName = node.getName();
        String nodeValue = StringUtils.trim(node.getText());
        if (SearchParameter.SIMILARITY.equals(nodeName)) {
          setSimilarity(jdom.getChildText(SearchParameter.SIMILARITY));
        } else {
          if (StringUtils.isNotBlank(nodeValue)) {

            if (SECURITY_FIELDS.contains(nodeName) || nodeName.contains("_op")) {
              addValues(searchPrivilegeCriteria, nodeName, nodeValue);
            } else if (RESERVED_FIELDS.contains(nodeName)) {
              searchOption.put(nodeName, nodeValue);
            } else {
              // addValues(searchCriteria, nodeName, nodeValue);
              // Rename search parameter to lucene index field
              // when needed
              addValues(
                  searchCriteria,
                  (searchParamToLuceneField.containsKey(nodeName)
                      ? searchParamToLuceneField.get(nodeName)
                      : nodeName),
                  nodeValue);
            }
          }
        }
      }
    }
  }
コード例 #3
0
ファイル: ExecuteJAR.java プロジェクト: vjutvik/Contiki-IPsec
  private static void handleExportAttributesFromJAR(Element e, File config, File toDir) {
    for (Element c : ((List<Element>) e.getChildren()).toArray(new Element[0])) {
      Attribute a = c.getAttribute("EXPORT");
      if (a != null && a.getValue().equals("copy")) {
        /* Copy file from JAR */
        File file = GUI.restoreConfigRelativePath(config, new File(c.getText()));
        InputStream inputStream = GUI.class.getResourceAsStream("/" + file.getName());
        if (inputStream == null) {
          throw new RuntimeException("Could not unpack file: " + file);
        }
        byte[] fileData = ArrayUtils.readFromStream(inputStream);
        if (fileData == null) {
          logger.info("Failed unpacking file");
          throw new RuntimeException("Could not unpack file: " + file);
        }
        if (OVERWRITE || !file.exists()) {
          boolean ok = ArrayUtils.writeToFile(file, fileData);
          if (!ok) {
            throw new RuntimeException("Failed unpacking file: " + file);
          }
          logger.info("Unpacked file from JAR: " + file.getName());
        } else if (OVERWRITE) {
          logger.info("Skip: unpack file from JAR: " + file.getName());
        }
      }

      /* Recursive search */
      handleExportAttributesFromJAR(c, config, toDir);
    }
  }
コード例 #4
0
ファイル: DifToArc.java プロジェクト: asascience-open/EDC
  private void parseProperties(Document doc, CsvProperties properties) {
    try {

      ArrayList<String> els;

      // Get unique times
      List<Element> timeList = XPath.selectNodes(doc, ".//gml:timePosition");
      if (!timeList.isEmpty()) {
        ArrayList<String> times = new ArrayList<String>(timeList.size());
        for (Element e : timeList) {
          times.add(e.getValue());
        }
        els = new ArrayList(new HashSet(times));
        Collections.sort(els);
        properties.setTimesteps(els);
      }

      // Get unique variable names
      List<Element> varList = XPath.selectNodes(doc, ".//ioos:Quantity");
      if (!varList.isEmpty()) {
        ArrayList<String> vars = new ArrayList<String>(varList.size());
        for (Element e : varList) {
          vars.add(e.getAttributeValue("name"));
        }
        els = new ArrayList(new HashSet(vars));
        properties.setVariableHeaders(els);
      }

    } catch (JDOMException e1) {
      e1.printStackTrace();
    }
  }
コード例 #5
0
 public static GenerationDependencies fromXml(Element root) {
   String version = GenerationRootDependencies.getValue(root, ATTR_VERSION);
   if (version == null || !version.equals(Integer.toString(DEPENDENCIES_VERSION))) {
     /* regenerate all */
     return null;
   }
   Map<String, String> externalHashes = new HashMap<String, String>();
   for (Element e : ((List<Element>) root.getChildren(NODE_MODEL))) {
     String modelReference = GenerationRootDependencies.getValue(e, ATTR_MODEL_ID);
     String rootHash = GenerationRootDependencies.getValue(e, ATTR_HASH);
     if (modelReference != null) {
       externalHashes.put(modelReference, rootHash);
     }
   }
   List<GenerationRootDependencies> data = new ArrayList<GenerationRootDependencies>();
   for (Element e : ((List<Element>) root.getChildren(NODE_COMMON))) {
     data.add(GenerationRootDependencies.fromXml(e, true));
   }
   for (Element e : ((List<Element>) root.getChildren(NODE_ROOT))) {
     data.add(GenerationRootDependencies.fromXml(e, false));
   }
   String modelHash = GenerationRootDependencies.getValue(root, ATTR_MODEL_HASH);
   String paramsHash = GenerationRootDependencies.getValue(root, ATTR_PARAMS_HASH);
   if (externalHashes.isEmpty() && data.isEmpty()) {
     return new GenerationDependencies(modelHash, paramsHash);
   }
   return new GenerationDependencies(
       data,
       modelHash,
       paramsHash,
       externalHashes,
       Collections.<GenerationRootDependencies>emptyList(),
       0,
       0);
 }
 @NotNull
 private static Element createOption(@NotNull final String name, @Nullable final String value) {
   final Element option = new Element("option");
   option.setAttribute("name", name);
   option.setAttribute("value", value == null ? "" : value);
   return option;
 }
コード例 #7
0
ファイル: XMLParsor.java プロジェクト: raisedragon/practice
	/**
	 *  普通版填写包的公共部分
	 * @param root	开始节点
	 * @param map	参数map
	 * @param sCycName	循环节点名
	 * @return
	 */
	public Element writeptPublicNode(Element root,HashMap map,String sCycName)
	{
		Element node=null;
		try
		{
			String sName="";
			String sValue="";
			List list=root.getChildren();
			for(int i=0;i<list.size();i++)
			{
				node=(Element)list.get(i);
				sName=node.getName();
				sName=sName.trim();
				sValue=(String)map.get(sName);
				//System.err.println("sName:"+sName+":"+sValue);
				if(sCycName.equals(sName)&&(root.getName()).trim().equals("ReqParamSet"))
				{
					//System.err.println("find cyc node:"+sName );
					return node;
				}
				else if(sValue!=null && !"".equals(sValue) )
					node.setText(sValue);
				node=writeptPublicNode(node,map,sCycName);
			}
		}catch(Exception ex)
		{
			ex.printStackTrace();
			System.err.println("error:"+ex.getMessage());
		}
		return node;
	}
コード例 #8
0
ファイル: SeleniumXml.java プロジェクト: RainerJava/ERP-3
 public void partialRunDependency(Element elem) throws TestCaseException {
   String isRun = replaceParam(elem.getAttributeValue("isRun"));
   if (isRun != null && Boolean.valueOf(isRun)) {
     List<Element> children = UtilGenerics.cast(elem.getChildren());
     this.runCommands(children);
   }
 }
コード例 #9
0
ファイル: SeleniumXml.java プロジェクト: RainerJava/ERP-3
 /**
  * Gets the visible (displayed) value of a list box
  *
  * @param elem
  */
 private void getSelectedLabel(Element elem) {
   String locator = elem.getAttributeValue("locator");
   String out = elem.getAttributeValue("out");
   String text = this.sel.getSelectedLabel(locator);
   logger.info("getSelectedValue: locator=" + locator + " text=" + text);
   addParam(out, text);
 }
コード例 #10
0
ファイル: SeleniumXml.java プロジェクト: RainerJava/ERP-3
  public void waitForValue(Element elem) {
    String locator = replaceParam(elem.getAttributeValue("locator"));
    String timeout = elem.getAttributeValue("timeout");
    String outParam = elem.getAttributeValue("out");

    int maxTime = Integer.parseInt(timeout);
    int maxSeconds = maxTime / 1000;
    logger.debug("waitForValue: locator=" + locator + " timeout=" + timeout);
    String foundValue = null;
    for (int second = 0; ; second++) {
      if (second >= maxSeconds) {
        throw new SeleniumException("waitForValue exceeded timeout: " + maxTime);
      }
      try {
        // getValue throws an exception if it can't find locator
        // - sleep for 1 sec and try again
        // - otherwise break as we found the value
        foundValue = sel.getValue(locator);
        if (outParam != null) {
          this.addParam(outParam, foundValue);
        }
        break;
      } catch (Exception e) {
        // wait for 1 second and then resume
        try {
          Thread.sleep(1000);
        } catch (InterruptedException threadE) {
          threadE.printStackTrace();
        }
      }
    }
  }
コード例 #11
0
ファイル: SeleniumXml.java プロジェクト: RainerJava/ERP-3
  public void waitForCondition(Element elem) {
    String script = elem.getAttributeValue("script");
    String timeout = elem.getAttributeValue("timeout");

    logger.debug("waitForCondition: script=" + script + " timeout=" + timeout);
    this.sel.waitForCondition(script, timeout);
  }
コード例 #12
0
ファイル: SeleniumXml.java プロジェクト: RainerJava/ERP-3
  private void callByReflection(Element elem) {
    String methodName = elem.getName();
    String param1 = elem.getAttributeValue("param1");
    String param2 = elem.getAttributeValue("param2");

    Class[] paramTypes = null;
    Object[] args = null;
    if ((param1 != null) && (param2 != null)) {
      paramTypes = new Class[] {String.class, String.class};
      args = new Object[] {replaceParam(param1), replaceParam(param2)};
    } else if (param1 != null) {
      paramTypes = new Class[] {String.class};
      args = new Object[] {replaceParam(param1)};
    } else {
      paramTypes = new Class[] {};
      args = new Object[] {};
    }

    // Capture the output name for "get" methods
    String out = elem.getAttributeValue("out");

    Method m;
    try {
      m = (Method) this.sel.getClass().getDeclaredMethod(methodName, paramTypes);
      Object results = m.invoke(this.sel, args);

      // Add output parameter to common map
      if ((out != null) && (results != null)) {
        addParam(out, results);
      }
    } catch (Exception e) {
      logger.error("Exception occurred when Unknown SeleniumXml command found:" + elem.getName());
      e.printStackTrace();
    }
  }
コード例 #13
0
  @NotNull
  public static TreeMap<String, Element> load(
      @NotNull Element rootElement,
      @Nullable PathMacroSubstitutor pathMacroSubstitutor,
      boolean intern) {
    if (pathMacroSubstitutor != null) {
      pathMacroSubstitutor.expandPaths(rootElement);
    }

    StringInterner interner = intern ? new StringInterner() : null;
    List<Element> children = rootElement.getChildren(COMPONENT);
    TreeMap<String, Element> map = new TreeMap<String, Element>();
    for (Element element : children) {
      String name = getComponentNameIfValid(element);
      if (name == null
          || !(element.getAttributes().size() > 1 || !element.getChildren().isEmpty())) {
        continue;
      }

      if (interner != null) {
        JDOMUtil.internElement(element, interner);
      }

      map.put(name, element);

      if (pathMacroSubstitutor instanceof TrackingPathMacroSubstitutor) {
        ((TrackingPathMacroSubstitutor) pathMacroSubstitutor)
            .addUnknownMacros(name, PathMacrosCollector.getMacroNames(element));
      }

      // remove only after "getMacroNames" - some PathMacroFilter requires element name attribute
      element.removeAttribute(NAME);
    }
    return map;
  }
コード例 #14
0
ファイル: JDRUtils.java プロジェクト: esprayer/EMPPlatform
  /** 打开查询结果 */
  public static String[] openQuery(Hashtable params) {

    JParamObject PO = new JParamObject();

    for (Enumeration e = params.keys(); e.hasMoreElements(); ) {
      String key = (String) e.nextElement();
      String val = (String) params.get(key);
      PO.SetValueByParamName(key, val);
    }
    String[] queryResult = new String[2];
    JResponseObject RO =
        (JResponseObject)
            JActiveDComDM.AbstractDataActiveFramework.InvokeObjectMethod(
                "DataReport", "OpenQuery", PO, "");
    String XMLStr = (String) RO.ResponseObject;
    if (RO != null && RO.ResponseObject != null) {
      XMLStr = (String) RO.ResponseObject;
      JXMLBaseObject XMLObj = new JXMLBaseObject(XMLStr);
      Element queryElmt = XMLObj.GetElementByName("Query");
      // 格式
      queryResult[0] = queryElmt.getAttributeValue("QueryFormat");
      // 数据
      queryResult[0] = queryElmt.getAttributeValue("QueryData");
    }
    return queryResult;
  }
コード例 #15
0
ファイル: DBXML.java プロジェクト: rsyuxiangyang/haiercard
  public String SqlExcute(String xmlStr) {
    String outstr = "false";
    Document doc;
    Element rootNode;
    String intStr = Basic.decode(xmlStr);

    try {
      Reader reader = new StringReader(intStr);
      SAXBuilder ss = new SAXBuilder();
      doc = ss.build(reader);

      rootNode = doc.getRootElement();

      List list = rootNode.getChildren();

      DBTable datatable = new DBTable();

      for (int i = 0; i < list.size(); i++) {
        Element childRoot = (Element) list.get(i);
        // System.out.print(childRoot.getText());
        outstr = String.valueOf(datatable.SaveDateStr(childRoot.getText()));
      }

    } catch (JDOMException ex) {
      System.out.print(ex.getMessage());
    }
    return outstr;
  }
コード例 #16
0
ファイル: SeleniumXml.java プロジェクト: RainerJava/ERP-3
  private void loadParameter(Element elem) {
    logger.info("loadParameter: fileName=" + elem.getAttributeValue("file"));
    String parameterFile = elem.getAttributeValue("file");
    String absolutePath = getAbsolutePath(parameterFile);
    BasicConfigurator.configure();

    try {
      InputStream in = new FileInputStream(absolutePath);
      Properties parameter = new Properties();
      parameter.load(in);
      in.close();

      Set<Entry<Object, Object>> entrySet = parameter.entrySet();

      for (Map.Entry entry : entrySet) {
        String key = (String) entry.getKey();
        String value = (String) entry.getValue();
        System.out.println(key + " = " + value);
        addParam(key, value);
      }
    } catch (Exception e) {
      logger.error("Can not load parameter . ");
    }

    String newStr =
        replaceParam(elem.getAttributeValue("src1")) + replaceParam(elem.getAttributeValue("src2"));
    addParam(elem.getAttributeValue("out"), newStr);
  }
コード例 #17
0
 /** Establece el sub-elemento Source */
 private void setSource() {
   Element eAux;
   eAux = new Element("Source");
   // eAux.setAttribute("Type","pcap o xml");
   eAux.setText(getPBExport().getExpSource());
   addContent(eAux);
 }
コード例 #18
0
ファイル: Opml.java プロジェクト: jsmadja/fluxx
 private void insertHead() {
   Element head = new Element("head");
   Element title = new Element("title");
   title.setText(FluxxMessage.m("opml_title"));
   head.addContent(title);
   root.addContent(head);
 }
コード例 #19
0
ファイル: XMLParsor.java プロジェクト: raisedragon/practice
	/*
	 * 递归完成查找
	 * para: Element root 开始查找节点
	 */
	public Element findNode(Element root,String sNodeName)
	{
		Element node =null;
		try
		{
			String sName="";
			List list=root.getChildren();
			for(int i=0;i<list.size();i++)
			{
				node=(Element)list.get(i);
				sName=node.getName();
				sName=sName.trim();
				//System.err.println("node name:"+sName+"-"+sNodeName);
				if(sName.equals(sNodeName))
				{
					System.err.println("find the node:"+sName);
					return node;
				}
				node=findNode(node,sNodeName);
			}
		}catch(Exception ex)
		{
			ex.printStackTrace();
			System.err.println("error:"+ex.getMessage());
		}
		return node;
	}
コード例 #20
0
ファイル: CoordRerunXCommand.java プロジェクト: InMobi/oozie
 /**
  * Refresh an action's input and ouput events.
  *
  * @param coordJob coordinator job bean
  * @param coordAction coordinator action bean
  * @throws Exception thrown if failed to materialize coordinator action
  */
 private void refreshAction(CoordinatorJobBean coordJob, CoordinatorActionBean coordAction)
     throws Exception {
   Configuration jobConf = null;
   try {
     jobConf = new XConfiguration(new StringReader(coordJob.getConf()));
   } catch (IOException ioe) {
     LOG.warn("Configuration parse error. read from DB :" + coordJob.getConf(), ioe);
     throw new CommandException(ErrorCode.E1005, ioe.getMessage(), ioe);
   }
   String jobXml = coordJob.getJobXml();
   Element eJob = XmlUtils.parseXml(jobXml);
   Date actualTime = new Date();
   String actionXml =
       CoordCommandUtils.materializeOneInstance(
           jobId,
           dryrun,
           (Element) eJob.clone(),
           coordAction.getNominalTime(),
           actualTime,
           coordAction.getActionNumber(),
           jobConf,
           coordAction);
   LOG.debug(
       "Refresh Action actionId="
           + coordAction.getId()
           + ", actionXml="
           + XmlUtils.prettyPrint(actionXml).toString());
   coordAction.setActionXml(actionXml);
 }
コード例 #21
0
ファイル: LoadWS.java プロジェクト: UGA-WSAG/RadiantWeb
 public static boolean isWADL(Document doc) {
   boolean iswadl = false;
   Element root = doc.getRootElement();
   String rootTag = root.getName();
   if (rootTag.equalsIgnoreCase("application")) iswadl = true;
   return iswadl;
 }
  private static void saveJavaModuleExtension(JpsModule module, Element rootModelComponent) {
    JpsJavaModuleExtension extension = getService().getModuleExtension(module);
    if (extension == null) return;
    if (extension.isExcludeOutput()) {
      rootModelComponent.addContent(0, new Element(EXCLUDE_OUTPUT_TAG));
    }

    String testOutputUrl = extension.getTestOutputUrl();
    if (testOutputUrl != null) {
      rootModelComponent.addContent(
          0, new Element(TEST_OUTPUT_TAG).setAttribute(URL_ATTRIBUTE, testOutputUrl));
    }

    String outputUrl = extension.getOutputUrl();
    if (outputUrl != null) {
      rootModelComponent.addContent(
          0, new Element(OUTPUT_TAG).setAttribute(URL_ATTRIBUTE, outputUrl));
    }

    LanguageLevel languageLevel = extension.getLanguageLevel();
    if (languageLevel != null) {
      rootModelComponent.setAttribute(MODULE_LANGUAGE_LEVEL_ATTRIBUTE, languageLevel.name());
    }
    rootModelComponent.setAttribute(
        INHERIT_COMPILER_OUTPUT_ATTRIBUTE, String.valueOf(extension.isInheritOutput()));
    saveAdditionalRoots(rootModelComponent, JAVADOC_PATHS_TAG, extension.getJavadocRoots());
    saveAdditionalRoots(rootModelComponent, ANNOTATION_PATHS_TAG, extension.getAnnotationRoots());
  }
コード例 #23
0
ファイル: FileMPSProject.java プロジェクト: rr-develop/MPS
 private void load(File projFile) {
   if (projFile == null) {
     return;
   }
   Document document = null;
   try {
     document = JDOMUtil.loadDocument(projFile);
   } catch (JDOMException ex) {
   } catch (IOException ex) {
   }
   Element projectElement = null;
   if (document != null) {
     Element root = document.getRootElement();
     if ("project".equals(root.getName())) {
       for (Object ch : root.getChildren("component")) {
         if (ch instanceof Element
             && "MPSProject".equals(((Element) ch).getAttributeValue("name"))) {
           projectElement = (Element) ch;
           break;
         }
       }
     }
   }
   if (projectElement != null) {
     load(projFile, (Element) projectElement);
   }
 }
 private static void loadAdditionalRoots(
     Element rootModelComponent, final String rootsTagName, final JpsUrlList result) {
   final Element roots = rootModelComponent.getChild(rootsTagName);
   for (Element root : JDOMUtil.getChildren(roots, ROOT_TAG)) {
     result.addUrl(root.getAttributeValue(URL_ATTRIBUTE));
   }
 }
コード例 #25
0
  public XMIVersionExtractor(File xmlFile) {
    try {
      SAXBuilder builder = new SAXBuilder();
      Document doc = builder.build(xmlFile);

      Element root = doc.getRootElement();
      if (root.getName().equals("XMI")) {
        String version = null;
        version = root.getAttributeValue("xmi.version");
        if (version != null) {
          this.version = version;
        } else {
          version = root.getAttributeValue("version", root.getNamespace());
          if (version != null) this.version = version;
        }
      } else {
        Element xmiRoot = root.getChild("XMI");
        if (xmiRoot != null) {
          String version = null;
          version = xmiRoot.getAttributeValue("xmi.version");
          if (version != null) {
            this.version = version;
          } else {
            version = xmiRoot.getAttributeValue("version", xmiRoot.getNamespace());
            if (version != null) this.version = version;
          }
        }
      }
    } catch (IOException e) {
      e.printStackTrace();
    } catch (JDOMException e) {
      e.printStackTrace();
    }
  }
コード例 #26
0
ファイル: PurchasechkBak.java プロジェクト: fuhongliang/hhvss
  @Override
  public Element search(Map parms) {
    Filter filter = cookFilter(parms);

    if (filter.count() == 0) throw new InvalidDataException("请设置查询过滤条件.");

    int count = this.getCount(filter);
    if (count > VSSConfig.getInstance().getRowsLimitHard())
      throw new InvalidDataException("满足条件的记录数已超过系统处理上限,请重新设置查询条件.");

    String sql =
        " SELECT "
            + " t.sheetid, status4purchase( t.status ) status, t.validdays, "
            + " t.orderdate, t.venderid, v.vendername, sg.categoryname majorname, pay.paytypename, "
            + " t.deadline, name4code(t.logistics,'logistics') as logistics, t.note, "
            + " t.editor, t.editdate, t.checker, t.checkdate, t.releasedate, t.readtime ,status4purchasetype(t.purchasetype) purchasetype "
            + " FROM (SELECT DISTINCT p0.sheetid,p0.validdays,p0.orderdate,p0.venderid,p0.purchasetype, "
            + " p0.deadline,p0.logistics,p0.note,p0.editor,p0.editdate,p0.checker,p0.checkdate, "
            + " p0.paytypeid,p0.sgroupid,c.status,c.releasedate, c.readtime  FROM purchase0_bak  p0  "
            + " JOIN purchase_bak  p ON ( p0.sheetid = p.refsheetid ) "
            + " JOIN cat_order_bak c ON ( c.sheetid = p0.sheetid ) WHERE "
            + filter.toString()
            + ") t "
            + " JOIN vender v ON ( v.venderid = t.venderid ) "
            + " JOIN paytype pay ON ( pay.paytypeid = t.paytypeid ) "
            + " left JOIN category sg ON ( sg.categoryid = t.sgroupid ) "
            + " ORDER BY t.checkdate DESC, t.status";

    Element elm_cat = SqlUtil.getRowSetElement(conn, sql, "rowset");
    elm_cat.setAttribute("row_total", "" + count);
    return elm_cat;
  }
コード例 #27
0
ファイル: Topic.java プロジェクト: hci-gnomex/gnomex
  /*
   *  An analysis, experiment, or data track can be part of many topics.  This convenience method
   *  allows the caller to send in the list of parent topics and it will generate XML nodes showing the
   *  topic with its contents.  This methods is used the GetAnalysis, GetRequest, and GetDataTrack to
   *  fill in the XML structure for "related" topics.
   */
  public static void appendParentTopicsXML(
      SecurityAdvisor secAdvisor, Element parentNode, Set topics)
      throws UnknownPermissionException {

    for (Topic topic : (Set<Topic>) topics) {
      Element topicNode = new Element("Topic");
      topicNode.setAttribute("idTopic", topic.getIdTopic().toString());
      topicNode.setAttribute(
          "label",
          (secAdvisor.canRead(topic)
              ? (topic.getName() != null ? topic.getName() : "")
              : "(Not authorized)"));
      topicNode.setAttribute("codeVisibility", topic.getCodeVisibility());
      parentNode.addContent(topicNode);

      for (Request r : (Set<Request>) topic.getRequests()) {
        Element rNode = new Element("Request");
        r.appendBasicXML(secAdvisor, topicNode);
      }
      for (Analysis a : (Set<Analysis>) topic.getAnalyses()) {
        Element aNode = new Element("Analysis");
        a.appendBasicXML(secAdvisor, topicNode);
      }
      for (DataTrack dt : (Set<DataTrack>) topic.getDataTracks()) {

        Element dtNode = new Element("DataTrack");
        dt.appendBasicXML(secAdvisor, topicNode);
      }
    }
  }
コード例 #28
0
 /**
  * The "default" is the highest priority and will receive the private messages. Negative priority
  * is a preference that the sender should not be used for direct or immediate contact. It must be
  * an integer value between -127 to +127. A 0 value is the default.
  */
 public void setPriority(int priority) {
   this.priority = priority;
   getDOM().removeChild("priority", XMLNS_PRESENCE);
   Element temp = new Element("priority", XMLNS_PRESENCE);
   temp.setText("" + priority);
   getDOM().addContent(temp);
 }
コード例 #29
0
ファイル: Custom.java プロジェクト: carlosamtech/SmartWetLab
  /** {@inheritDoc} */
  public Content encodeXML(String name, Namespace ns) {
    // element in namespace defined by parent element
    Element element = new Element(name, ns);
    // child element are always in default LLRP namespace
    ns = Namespace.getNamespace("llrp", LLRPConstants.LLRPNAMESPACE);

    if (vendorIdentifier == null) {
      LOGGER.warn(" vendorIdentifier not set");
      throw new MissingParameterException(" vendorIdentifier not set");
    } else {
      element.addContent(vendorIdentifier.encodeXML("VendorIdentifier", ns));
    }

    if (parameterSubtype == null) {
      LOGGER.warn(" parameterSubtype not set");
      throw new MissingParameterException(" parameterSubtype not set");
    } else {
      element.addContent(parameterSubtype.encodeXML("ParameterSubtype", ns));
    }

    if (data == null) {
      LOGGER.warn(" data not set");
      throw new MissingParameterException(" data not set");
    } else {
      element.addContent(data.encodeXML("Data", ns));
    }

    // parameters
    return element;
  }
コード例 #30
0
  @Override
  public void writeExternal(Element element) throws WriteExternalException {
    List<HighlightSeverity> list = getOrderAsList(getOrderMap());
    for (HighlightSeverity severity : list) {
      Element info = new Element(INFO_TAG);
      String severityName = severity.getName();
      final SeverityBasedTextAttributes infoType = getAttributesBySeverity(severity);
      if (infoType != null) {
        infoType.writeExternal(info);
        final Color color = myRendererColors.get(severityName);
        if (color != null) {
          info.setAttribute(COLOR_ATTRIBUTE, Integer.toString(color.getRGB() & 0xFFFFFF, 16));
        }
        element.addContent(info);
      }
    }

    if (myReadOrder != null && !myReadOrder.isEmpty()) {
      myReadOrder.writeExternal(element);
    } else if (!getDefaultOrder().equals(list)) {
      final JDOMExternalizableStringList ext =
          new JDOMExternalizableStringList(Collections.nCopies(getOrderMap().size(), ""));
      getOrderMap()
          .forEachEntry(
              new TObjectIntProcedure<HighlightSeverity>() {
                @Override
                public boolean execute(HighlightSeverity orderSeverity, int oIdx) {
                  ext.set(oIdx, orderSeverity.getName());
                  return true;
                }
              });
      ext.writeExternal(element);
    }
  }