Java Code Examples for org.dom4j.tree.DefaultElement#add()

The following examples show how to use org.dom4j.tree.DefaultElement#add() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CPOrganization.java    From olat with Apache License 2.0 6 votes vote down vote up
/**
*/
  @Override
  public void buildDocument(final DefaultElement parent) {

      final DefaultElement orgaElement = new DefaultElement(CPCore.ORGANIZATION);

      orgaElement.addAttribute(CPCore.IDENTIFIER, identifier);
      orgaElement.addAttribute(CPCore.STRUCTURE, structure);

      final DefaultElement titleElement = new DefaultElement(CPCore.TITLE);
      titleElement.setText(title);
      orgaElement.add(titleElement);

      if (metadata != null) {
          metadata.buildDocument(orgaElement);
      }
      for (final Iterator<CPItem> itItem = items.iterator(); itItem.hasNext();) {
          final CPItem item = itItem.next();
          item.buildDocument(orgaElement);
      }
      parent.add(orgaElement);

  }
 
Example 2
Source File: CPManifest.java    From olat with Apache License 2.0 6 votes vote down vote up
/**
 * @param doc
 */
public void buildDocument(final DefaultDocument doc) {
    // Manifest is the root-node of the document, therefore we need to pass the
    // "doc"
    final DefaultElement manifestElement = new DefaultElement(CPCore.MANIFEST);

    manifestElement.add(new DefaultAttribute(CPCore.IDENTIFIER, this.identifier));
    manifestElement.add(new DefaultAttribute(CPCore.SCHEMALOCATION, this.schemaLocation));
    // manifestElement.setNamespace(this.getNamespace()); //FIXME: namespace

    doc.add(manifestElement);

    if (metadata != null) {
        metadata.buildDocument(manifestElement);
    }
    organizations.buildDocument(manifestElement);
    resources.buildDocument(manifestElement);

}
 
Example 3
Source File: CPOrganization.java    From olat with Apache License 2.0 6 votes vote down vote up
/**
*/
  @Override
  public void buildDocument(final DefaultElement parent) {

      final DefaultElement orgaElement = new DefaultElement(CPCore.ORGANIZATION);

      orgaElement.addAttribute(CPCore.IDENTIFIER, identifier);
      orgaElement.addAttribute(CPCore.STRUCTURE, structure);

      final DefaultElement titleElement = new DefaultElement(CPCore.TITLE);
      titleElement.setText(title);
      orgaElement.add(titleElement);

      if (metadata != null) {
          metadata.buildDocument(orgaElement);
      }
      for (final Iterator<CPItem> itItem = items.iterator(); itItem.hasNext();) {
          final CPItem item = itItem.next();
          item.buildDocument(orgaElement);
      }
      parent.add(orgaElement);

  }
 
Example 4
Source File: CPManifest.java    From olat with Apache License 2.0 6 votes vote down vote up
/**
 * @param doc
 */
public void buildDocument(final DefaultDocument doc) {
    // Manifest is the root-node of the document, therefore we need to pass the
    // "doc"
    final DefaultElement manifestElement = new DefaultElement(CPCore.MANIFEST);

    manifestElement.add(new DefaultAttribute(CPCore.IDENTIFIER, this.identifier));
    manifestElement.add(new DefaultAttribute(CPCore.SCHEMALOCATION, this.schemaLocation));
    // manifestElement.setNamespace(this.getNamespace()); //FIXME: namespace

    doc.add(manifestElement);

    if (metadata != null) {
        metadata.buildDocument(manifestElement);
    }
    organizations.buildDocument(manifestElement);
    resources.buildDocument(manifestElement);

}
 
Example 5
Source File: CPResources.java    From olat with Apache License 2.0 5 votes vote down vote up
@Override
public void buildDocument(final DefaultElement parent) {
    final DefaultElement resourceElement = new DefaultElement(CPCore.RESOURCES);

    for (final Iterator<CPResource> itResources = resources.iterator(); itResources.hasNext();) {
        final CPResource res = itResources.next();
        res.buildDocument(resourceElement);
    }
    parent.add(resourceElement);
}
 
Example 6
Source File: CPOrganizations.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
*/
  @Override
  public void buildDocument(final DefaultElement parent) {
      final DefaultElement orgaElement = new DefaultElement(CPCore.ORGANIZATIONS);

      for (final Iterator<CPOrganization> itOrgas = orgas.iterator(); itOrgas.hasNext();) {
          final CPOrganization org = itOrgas.next();
          org.buildDocument(orgaElement);
      }
      parent.add(orgaElement);
  }
 
Example 7
Source File: CPFile.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
*/
  @Override
  public void buildDocument(final DefaultElement parent) {
      final DefaultElement fileElement = new DefaultElement(CPCore.FILE);
      fileElement.addAttribute(CPCore.HREF, href);
      if (metadata != null) {
          metadata.buildDocument(fileElement);
      }
      parent.add(fileElement);
  }
 
Example 8
Source File: CPDependency.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
*/
  @Override
  public void buildDocument(final DefaultElement parent) {
      final DefaultElement depElement = new DefaultElement(CPCore.DEPENDENCY);
      depElement.addAttribute(CPCore.IDENTIFIERREF, identifierRef);
      parent.add(depElement);
  }
 
Example 9
Source File: CPMetadata.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
*/
  @Override
  public void buildDocument(final DefaultElement parent) {
      final DefaultElement metaElement = new DefaultElement(CPCore.METADATA);
      metaElement.setContent(this.content());
      parent.add(metaElement);
  }
 
Example 10
Source File: CPResource.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
*/
  @Override
  public void buildDocument(final DefaultElement parent) {
      // String base = "";
      // if(xmlbase != null && !xmlbase.equals("")) base="
      // xml:base=\""+xmlbase+"\"";

      // TODO: xml base imlement !!!

      final DefaultElement resourceElement = new DefaultElement(CPCore.RESOURCE);

      resourceElement.addAttribute(CPCore.IDENTIFIER, identifier);
      resourceElement.addAttribute(CPCore.TYPE, type);
      resourceElement.addAttribute(CPCore.HREF, href);
      if (!xmlbase.equals("")) {
          resourceElement.addAttribute(CPCore.BASE, xmlbase);
      }

      if (metadata != null) {
          metadata.buildDocument(resourceElement);
      }

      // build files
      for (final Iterator<CPFile> itFiles = files.iterator(); itFiles.hasNext();) {
          final CPFile file = itFiles.next();
          file.buildDocument(resourceElement);
      }

      // build dependencies
      for (final Iterator<CPDependency> itDep = dependencies.iterator(); itDep.hasNext();) {
          final CPDependency dep = itDep.next();
          dep.buildDocument(resourceElement);
      }

      parent.add(resourceElement);
  }
 
Example 11
Source File: CPItem.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
*/
  @Override
  public void buildDocument(final DefaultElement parent) {
      final DefaultElement itemElement = new DefaultElement(CPCore.ITEM);

      itemElement.addAttribute(CPCore.IDENTIFIER, identifier);
      if (!identifierRef.equals("")) {
          itemElement.addAttribute(CPCore.IDENTIFIERREF, identifierRef);
      }
      itemElement.addAttribute(CPCore.ISVISIBLE, isVisibleString());

      if (metadata != null) {
          metadata.buildDocument(itemElement);
      }

      final DefaultElement titleElement = new DefaultElement(CPCore.TITLE);
      titleElement.setText(title);
      itemElement.add(titleElement);

      for (final Iterator<CPItem> itItem = items.iterator(); itItem.hasNext();) {
          final CPItem item = itItem.next();
          item.buildDocument(itemElement);
      }

      parent.add(itemElement);

  }
 
Example 12
Source File: CPItem.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
*/
  @Override
  public void buildDocument(final DefaultElement parent) {
      final DefaultElement itemElement = new DefaultElement(CPCore.ITEM);

      itemElement.addAttribute(CPCore.IDENTIFIER, identifier);
      if (!identifierRef.equals("")) {
          itemElement.addAttribute(CPCore.IDENTIFIERREF, identifierRef);
      }
      itemElement.addAttribute(CPCore.ISVISIBLE, isVisibleString());

      if (metadata != null) {
          metadata.buildDocument(itemElement);
      }

      final DefaultElement titleElement = new DefaultElement(CPCore.TITLE);
      titleElement.setText(title);
      itemElement.add(titleElement);

      for (final Iterator<CPItem> itItem = items.iterator(); itItem.hasNext();) {
          final CPItem item = itItem.next();
          item.buildDocument(itemElement);
      }

      parent.add(itemElement);

  }
 
Example 13
Source File: CPFile.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
*/
  @Override
  public void buildDocument(final DefaultElement parent) {
      final DefaultElement fileElement = new DefaultElement(CPCore.FILE);
      fileElement.addAttribute(CPCore.HREF, href);
      if (metadata != null) {
          metadata.buildDocument(fileElement);
      }
      parent.add(fileElement);
  }
 
Example 14
Source File: CPResources.java    From olat with Apache License 2.0 5 votes vote down vote up
@Override
public void buildDocument(final DefaultElement parent) {
    final DefaultElement resourceElement = new DefaultElement(CPCore.RESOURCES);

    for (final Iterator<CPResource> itResources = resources.iterator(); itResources.hasNext();) {
        final CPResource res = itResources.next();
        res.buildDocument(resourceElement);
    }
    parent.add(resourceElement);
}
 
Example 15
Source File: CPOrganizations.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
*/
  @Override
  public void buildDocument(final DefaultElement parent) {
      final DefaultElement orgaElement = new DefaultElement(CPCore.ORGANIZATIONS);

      for (final Iterator<CPOrganization> itOrgas = orgas.iterator(); itOrgas.hasNext();) {
          final CPOrganization org = itOrgas.next();
          org.buildDocument(orgaElement);
      }
      parent.add(orgaElement);
  }
 
Example 16
Source File: CPResource.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
*/
  @Override
  public void buildDocument(final DefaultElement parent) {
      // String base = "";
      // if(xmlbase != null && !xmlbase.equals("")) base="
      // xml:base=\""+xmlbase+"\"";

      // TODO: xml base imlement !!!

      final DefaultElement resourceElement = new DefaultElement(CPCore.RESOURCE);

      resourceElement.addAttribute(CPCore.IDENTIFIER, identifier);
      resourceElement.addAttribute(CPCore.TYPE, type);
      resourceElement.addAttribute(CPCore.HREF, href);
      if (!xmlbase.equals("")) {
          resourceElement.addAttribute(CPCore.BASE, xmlbase);
      }

      if (metadata != null) {
          metadata.buildDocument(resourceElement);
      }

      // build files
      for (final Iterator<CPFile> itFiles = files.iterator(); itFiles.hasNext();) {
          final CPFile file = itFiles.next();
          file.buildDocument(resourceElement);
      }

      // build dependencies
      for (final Iterator<CPDependency> itDep = dependencies.iterator(); itDep.hasNext();) {
          final CPDependency dep = itDep.next();
          dep.buildDocument(resourceElement);
      }

      parent.add(resourceElement);
  }
 
Example 17
Source File: CPDependency.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
*/
  @Override
  public void buildDocument(final DefaultElement parent) {
      final DefaultElement depElement = new DefaultElement(CPCore.DEPENDENCY);
      depElement.addAttribute(CPCore.IDENTIFIERREF, identifierRef);
      parent.add(depElement);
  }
 
Example 18
Source File: CPMetadata.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
*/
  @Override
  public void buildDocument(final DefaultElement parent) {
      final DefaultElement metaElement = new DefaultElement(CPCore.METADATA);
      metaElement.setContent(this.content());
      parent.add(metaElement);
  }
 
Example 19
Source File: AddSpringConfigurationPropertyMigrationTask.java    From tesb-studio-se with Apache License 2.0 5 votes vote down vote up
private void addIgnoreExchangeEventProperty(CamelProcessItem item) throws PersistenceException, DocumentException {
	String springContent = item.getSpringContent();
	if (null != springContent && !springContent.isEmpty()) {
		Document document = DocumentHelper.parseText(springContent);
		QName qname = QName.get("bean", SPRING_BEANS_NAMESPACE);
		List<Element> beans = document.getRootElement().elements(qname);
		for (Element bean : beans) {
			if ("jmxEventNotifier".equals(bean.attributeValue("id")) &&
					"org.apache.camel.management.JmxNotificationEventNotifier".equals(bean.attributeValue("class")))
			{
				List<Element> properties = bean.elements(QName.get("property", SPRING_BEANS_NAMESPACE));
				boolean hasIgnore = false;
				for (Element property : properties) {
					List<Attribute> propertyAttributes = property.attributes();
					for (Attribute propertyAttribute : propertyAttributes) {
						if (propertyAttribute.getValue().equals(IGNORE_EXCHANGE_EVENTS)) {
							hasIgnore = true;
							break;
						}
					}
				}
				if (!hasIgnore)
				{
					DefaultElement ignoreExchangeElement = new DefaultElement("property", bean.getNamespace());
					ignoreExchangeElement.add(DocumentHelper.createAttribute(ignoreExchangeElement, "name", IGNORE_EXCHANGE_EVENTS));
					ignoreExchangeElement.add(DocumentHelper.createAttribute(ignoreExchangeElement, "value", "true"));
					bean.add(ignoreExchangeElement);
					item.setSpringContent(document.asXML());
					saveItem(item);
				}
				break;
			}
		}
	}
}
 
Example 20
Source File: XmppDecoderTest.java    From onos with Apache License 2.0 5 votes vote down vote up
private void buildXmppStanza() {
    xmppStanzaElement = new DefaultElement("iq");
    xmppStanzaElement.addAttribute("type", "set");
    xmppStanzaElement.addAttribute("from", "[email protected]");
    xmppStanzaElement.addAttribute("to", "xmpp.onosproject.org");
    Element pubsub = new DefaultElement("pubsub",
                                        new org.dom4j.Namespace("", "http://jabber.org/protocol/pubsub"));
    Element subscribe = new DefaultElement("subscribe");
    subscribe.addAttribute("node", "test");
    pubsub.add(subscribe);
    xmppStanzaElement.add(pubsub);
}