Examples of IterableElementList


Examples of org.openiaml.model.xpath.IterableElementList

    for (String filename : getGenList()) {
      try {
      Document doc = getCache().get(filename);
     
      // will do both links and nodes
      IterableElementList nodes = xpath(doc, "/GenEditorGenerator/diagram/topLevelNodes");
      nodes.addAll(xpath(doc, "/GenEditorGenerator/diagram/links"));
      assertFalse(filename + ": No nodes found", nodes.isEmpty());
     
      for (Element node : nodes) {
        // find the meta element for this node
        Element meta = xpathFirst(node, "modelFacet/metaClass");
        // iaml.genmodel#//model/CompositeOperation
        String metaHref = meta.getAttribute("href");
        // CompositeOperation
        metaHref = metaHref.substring(metaHref.lastIndexOf("/") + 1);
       
        EClass metaElement = resolveSimpleEClass(metaHref);
       
        if (rootElement.isSuperTypeOf(metaElement)) {
          // there must be a behaviour for this meta element!
          boolean found = false;
         
          IterableElementList beh = xpath(node, "behaviour");
          String foundType = null;
          for (Element b : beh) {
            if (b.getAttribute("xsi:type").equals("gmfgen:OpenDiagramBehaviour")) {
              // found it directly
              foundType = b.getAttribute("diagramKind");
View Full Code Here

Examples of org.openiaml.model.xpath.IterableElementList

      List<String> diagramKinds = new ArrayList<String>();
      List<String> editorIDs = new ArrayList<String>();
      List<String> policyNames = new ArrayList<String>();
     
      // will do both links and nodes
      IterableElementList nodes = xpath(doc, "/GenEditorGenerator/diagram/topLevelNodes");
      nodes.addAll(xpath(doc, "/GenEditorGenerator/diagram/links"));
      assertFalse(filename + ": No nodes found", nodes.isEmpty());
     
      for (Element node : nodes) {
        // does this have a behaviour?
        IterableElementList beh = xpath(node, "behaviour");
        for (Element b : beh) {
          if (b.getAttribute("xsi:type").equals("gmfgen:OpenDiagramBehaviour")) {
            String diagramKind = b.getAttribute("diagramKind");
            String editorID = b.getAttribute("editorID");
            String policyName = b.getAttribute("editPolicyClassName");
View Full Code Here

Examples of org.openiaml.model.xpath.IterableElementList

   */
  public void testContextMenus() throws Exception {
    for (String filename : getGenList()) {
      Document doc = getCache().get(filename);
     
      IterableElementList nodes = xpath(doc, "/GenEditorGenerator/contextMenus");
     
      assertEquals(filename + ": there should be exactly one /contextMenus", nodes.size(), 1);
    }
  }
View Full Code Here

Examples of org.openiaml.model.xpath.IterableElementList

   */
  public void testJavaExpressionInjection() throws Exception {
    for (String filename : getGenList()) {
      Document doc = getCache().get(filename);
     
      IterableElementList javaProviders = xpath(doc, "/GenEditorGenerator/expressionProviders/providers");
     
      for (Element p : javaProviders) {
        if ("gmfgen:GenJavaExpressionProvider".equals(p.getAttribute("xsi:type"))) {
          // found a Java expression provider
          assertEquals(filename + ": injectExpressionBody should be 'true'", "true", p.getAttribute("injectExpressionBody"));
View Full Code Here

Examples of org.openiaml.model.xpath.IterableElementList

          throws Exception {
       
        // first, let's try and add it if it doesn't already exist
        boolean changed = false;
        {
          IterableElementList attributes = xpath(doc, "//topLevelNodes/viewmap/attributes");
          assertNotSame("Found no fixed labels in " + filename, 0, attributes.size());
          for (Element e : attributes) {
            if (!"false".equals(e.getAttribute("fixedFont"))) {
              // force changed to 'false'
              e.setAttribute("fixedFont", "false");
              changed = true;
            }
          }
        }

        // save
        if (changed) {
          saveDocument(doc, filename);
        }
       
        // then recheck
        {
          IterableElementList attributes = xpath(doc, "//topLevelNodes/viewmap/attributes");
          assertNotSame(0, attributes.size());
          for (Element e : attributes) {
            assertEquals(filename, "false", e.getAttribute("fixedFont"));
          }
        }
       
View Full Code Here

Examples of org.openiaml.model.xpath.IterableElementList

        boolean changed = false;
        if (filename.endsWith("/root.gmfgen")) {
          holder.value++;
         
          // check that generateDomainModelNavigator is either true or not set
          IterableElementList nav = xpath(doc, "/GenEditorGenerator/navigator");
          assertEquals("Only one <navigator> expected", 1, nav.size());
          for (Element e : nav) {
            if (e.hasAttribute("generateDomainModelNavigator") && !"true".equals(e.getAttribute("generateDomainModelNavigator"))) {
              // force change to 'true'
              e.setAttribute("generateDomainModelNavigator", "true");
            }
          }
        } else {
          // check that generateDomainModelNavigator is either true or not set
          IterableElementList nav = xpath(doc, "/GenEditorGenerator/navigator");
          assertEquals("Only one <navigator> expected", 1, nav.size());
          for (Element e : nav) {
            if (!e.hasAttribute("generateDomainModelNavigator") || !"false".equals(e.getAttribute("generateDomainModelNavigator"))) {
              // force change to 'false'
              e.setAttribute("generateDomainModelNavigator", "false");
            }
          }
        }
       
        // save
        if (changed) {
          saveDocument(doc, filename);
        }
       
        // then recheck
        if (filename.endsWith("/root.gmfgen")) {
          // check that generateDomainModelNavigator is either true or not set
          IterableElementList nav = xpath(doc, "/GenEditorGenerator/navigator");
          assertEquals("Only one <navigator> expected", 1, nav.size());
          for (Element e : nav) {
            if (e.hasAttribute("generateDomainModelNavigator")) {
              assertEquals(filename, "true", e.getAttribute("generateDomainModelNavigator"));
            }
          }
        } else {
          // check that generateDomainModelNavigator is either true or not set
          IterableElementList nav = xpath(doc, "/GenEditorGenerator/navigator");
          assertEquals("Only one <navigator> expected", 1, nav.size());
          for (Element e : nav) {
            assertTrue(filename, e.hasAttribute("generateDomainModelNavigator"));
            assertEquals(filename, "false", e.getAttribute("generateDomainModelNavigator"));
          }
        }
View Full Code Here

Examples of org.openiaml.model.xpath.IterableElementList

  public IterableElementList xpath(Node doc, String query) throws XPathExpressionException {
    XPathFactory factory = XPathFactory.newInstance();
    XPath xpath = factory.newXPath();
    XPathExpression expr = xpath.compile(query);
    NodeList result = (NodeList) expr.evaluate(doc, XPathConstants.NODESET);
    return new IterableElementList(result);
  }
View Full Code Here

Examples of org.openiaml.model.xpath.IterableElementList

  /**
   * Get the first node result from an XPath query.
   */
  public Element xpathFirst(Document doc, String query) throws XPathExpressionException {
    assertNotNull("Cannot find the xpath for a null document", doc);
    IterableElementList results = xpath(doc, query);
    if (results.size() == 0) {
      fail("XPath query '" + query + "' returned no results");
    }
    Element e = results.item(0);
    assertNotNull("Could not find result for query '" + query + "'", e);
    return e;
  }
View Full Code Here

Examples of org.openiaml.model.xpath.IterableElementList

   *
   * @throws RuntimeException if no results are found
   */
  public Element xpathFirst(Element e, String query) throws XPathExpressionException {
    assertNotNull("Cannot find the xpath for a null element", e);
    IterableElementList result = xpath(e, query);
    if (result.isEmpty())
      throw new RuntimeException("No results found for query '" + query + "' on element '" + e + "'");
    Element e2 = (Element) result.item(0);
    assertNotNull("Could not find result for query '" + query + "'", e2);
    return e2;
  }
View Full Code Here

Examples of org.openiaml.model.xpath.IterableElementList

   *
   * @returns the found node, or null if none is found (or more than one is found)
   */
  public Element hasXpathFirst(Element e, String query) throws XPathExpressionException {
    assertNotNull("Cannot find the xpath for a null element", e);
    IterableElementList nl = xpath(e, query);
    if (nl.getLength() == 1) {
      return (Element) nl.item(0);
    }
    return null;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.