Example usage for org.dom4j DocumentHelper makeElement

List of usage examples for org.dom4j DocumentHelper makeElement

Introduction

In this page you can find the example usage for org.dom4j DocumentHelper makeElement.

Prototype

public static Element makeElement(Branch source, String path) 

Source Link

Document

makeElement

a helper method which navigates from the given Document or Element node to some Element using the path expression, creating any necessary elements along the way.

Usage

From source file:org.pentaho.actionsequence.dom.actions.EmailAttachment.java

License:Open Source License

EmailAttachment(EmailAction emailAction, String name, URI uri, String mimeType) {
    attachmentElement = DocumentHelper
            .makeElement(emailAction.getElement(), ActionSequenceDocument.COMPONENT_DEF_NAME)
            .addElement(ELEMENT_NAME); //$NON-NLS-1$
    actionInputProvider = emailAction.actionParameterMgr;
    setName(name);/*from  w ww  .  j a va  2 s  . co m*/
    setContentResource(uri, mimeType);
}

From source file:org.pentaho.actionsequence.dom.actions.EmailAttachment.java

License:Open Source License

void convertToNewAttachmentStyle() {
    Element actionElement = emailAction.getElement();

    attachmentElement = DocumentHelper.makeElement(actionElement,
            ActionSequenceDocument.COMPONENT_DEF_NAME + "/" + ELEMENT_NAME); //$NON-NLS-1$

    // Convert the attachment content.
    Element oldAttachmentElement = (Element) actionElement
            .selectSingleNode(ActionSequenceDocument.COMPONENT_DEF_NAME + "/" + OLD_ATTACHMENT_ELEMENT);
    String attachmentParam = oldAttachmentElement.getText();
    oldAttachmentElement.detach();/*w  ww. j  a  va  2 s.c o m*/
    attachmentElement.addAttribute(ATTACHMENT_CONTENT_ATTRIBUTE, attachmentParam);

    // Convert the attachment name.
    String attachmentNameParam = null;
    String attachmentName = null;
    Element oldAttachmentNameElement = (Element) actionElement
            .selectSingleNode(ActionSequenceDocument.COMPONENT_DEF_NAME + "/" + OLD_ATTACHMENT_NAME_ELEMENT);
    if (oldAttachmentNameElement != null) {
        attachmentName = oldAttachmentNameElement.getText();
        oldAttachmentNameElement.detach();
    } else {
        attachmentNameParam = OLD_ATTACHMENT_NAME_ELEMENT;
    }
    if (attachmentName != null) {
        attachmentElement.addAttribute(ATTACHMENT_NAME_ATTRIBUTE, getUniqueNameParam());
        emailAction.setActionInputValue(
                attachmentElement.attribute(ATTACHMENT_NAME_ATTRIBUTE).getValue().trim(),
                new ActionInputConstant(attachmentName, this.actionInputProvider));
    } else {
        attachmentElement.addAttribute(ATTACHMENT_NAME_ATTRIBUTE, attachmentNameParam);
    }

    emailAction = null;
}

From source file:org.pentaho.actionsequence.dom.ActionSequenceDocument.java

License:Open Source License

/**
 * Sets the action sequence description.
 * /* w w w .j  av a  2 s .co m*/
 * @param value
 *          the description
 */
public void setDescription(String value) {
    Element actSeq = (Element) document.selectSingleNode(ACTION_SEQUENCE);
    Element subElement = DocumentHelper.makeElement(actSeq, ACTION_SEQUENCE_DOCUMENTATION_DESCRIPT);
    subElement.setText(value == null ? "" : value); //$NON-NLS-1$
    fireHeaderChanged(this);
}

From source file:org.pentaho.actionsequence.dom.ActionSequenceDocument.java

License:Open Source License

/**
 * Sets the action sequence help message
 * //from ww  w  . ja v a  2 s  .  co m
 * @param value
 *          the help message
 */
public void setHelp(String value) {
    Element actSeq = (Element) document.selectSingleNode(ACTION_SEQUENCE);
    Element subElement = DocumentHelper.makeElement(actSeq, ACTION_SEQUENCE_DOCUMENTATION_HELP);
    subElement.setText(value == null ? "" : value); //$NON-NLS-1$
    fireHeaderChanged(this);
}

From source file:org.pentaho.actionsequence.dom.ActionSequenceDocument.java

License:Open Source License

/**
 * Sets the action sequence version./*from  ww  w.ja v a2 s .  c o  m*/
 * 
 * @param value
 *          the version
 */
public void setVersion(String value) {
    Element actSeq = (Element) document.selectSingleNode(ACTION_SEQUENCE);
    Element subElement = DocumentHelper.makeElement(actSeq, ACTION_SEQUENCE_VERSION);
    subElement.setText(value == null ? "" : value); //$NON-NLS-1$
    fireHeaderChanged(this);
}

From source file:org.pentaho.actionsequence.dom.ActionSequenceDocument.java

License:Open Source License

/**
 * Sets the action sequence logging level
 * /*from   w  ww . j a  v a 2  s  .co  m*/
 * @param value
 *          the logging level
 */
public void setLoggingLevel(String value) {
    Element actSeq = (Element) document.selectSingleNode(ACTION_SEQUENCE);
    Element subElement = DocumentHelper.makeElement(actSeq, ACTION_SEQUENCE_LOGGING_LEVEL);
    subElement.setText(value == null ? "" : value); //$NON-NLS-1$
    fireHeaderChanged(this);
}

From source file:org.pentaho.actionsequence.dom.ActionSequenceDocument.java

License:Open Source License

/**
 * Sets the action sequence author/*from  w w w.  j a  v  a2 s .  com*/
 * 
 * @param value
 *          the author name
 */
public void setAuthor(String value) {
    Element actSeq = (Element) document.selectSingleNode(ACTION_SEQUENCE);
    Element subElement = DocumentHelper.makeElement(actSeq, ACTION_SEQUENCE_DOCUMENTATION_AUTHOR);
    subElement.setText(value == null ? "" : value); //$NON-NLS-1$
    fireHeaderChanged(this);
}

From source file:org.pentaho.actionsequence.dom.ActionSequenceDocument.java

License:Open Source License

/**
 * Sets the action sequence result type//from ww  w .  ja  va  2 s  .c  o  m
 * 
 * @param value
 *          the result type
 */
public void setResultType(String value) {
    Element actSeq = (Element) document.selectSingleNode(ACTION_SEQUENCE);
    if (value == null) {
        Node subElement = actSeq.selectSingleNode(ACTION_SEQUENCE_DOCUMENTATION_RESULT_TYPE);
        if (subElement != null) {
            subElement.detach();
            fireHeaderChanged(this);
        }
    } else {
        Element subElement = DocumentHelper.makeElement(actSeq, ACTION_SEQUENCE_DOCUMENTATION_RESULT_TYPE);
        subElement.setText(value == null ? "" : value); //$NON-NLS-1$
        fireHeaderChanged(this);
    }
}

From source file:org.pentaho.actionsequence.dom.ActionSequenceDocument.java

License:Open Source License

/**
 * Sets the location of the icon for this action sequence
 * //ww w.j  ava  2 s .  c o  m
 * @param value
 *          the icon path
 */
public void setIconLocation(String value) {
    String location = ""; //$NON-NLS-1$
    Element actSeq = (Element) document.selectSingleNode(ACTION_SEQUENCE);
    Element subElement = DocumentHelper.makeElement(actSeq, ACTION_SEQUENCE_DOCUMENTATION_ICON);
    if (value != null) {
        location = value;
    }
    String flyOverIcon = getFlyoverIconLocation();
    if (flyOverIcon.length() > 0) {
        location = location + "|" + flyOverIcon; //$NON-NLS-1$
    }
    subElement.setText(location);
    fireHeaderChanged(this);
}

From source file:org.pentaho.actionsequence.dom.ActionSequenceDocument.java

License:Open Source License

/**
 * Sets the location of the icon for this action sequence
 * /*from  w  ww . j  a  v  a2 s  .c o m*/
 * @param value
 *          the icon path
 */
public void setFlyoverIconLocation(String value) {
    Element actSeq = (Element) document.selectSingleNode(ACTION_SEQUENCE);
    Element subElement = DocumentHelper.makeElement(actSeq, ACTION_SEQUENCE_DOCUMENTATION_ICON);
    String location = getIconLocation();
    if ((value != null) && (value.trim().length() > 0)) {
        location = location + "|" + value; //$NON-NLS-1$
    }
    subElement.setText(location);
    fireHeaderChanged(this);
}