Example usage for org.dom4j DocumentHelper createElement

List of usage examples for org.dom4j DocumentHelper createElement

Introduction

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

Prototype

public static Element createElement(String name) 

Source Link

Usage

From source file:org.etudes.jforum.view.admin.ImportExportAction.java

License:Apache License

/**
 * creates the LOM metadata element//from   www.  j a va  2 s  .  co m
 * 
 * @param elename
 *            - element name
 * @param qname
 *            - qualified name
 * @return - returns the metadata element
 */
private Element createLOMElement(String elename, String qname) {

    Element imsmdlom = DocumentHelper.createElement(elename);
    imsmdlom.setQName(new QName(qname, new Namespace("imsmd", IMSMD_NAMESPACE_URI)));

    return imsmdlom;
}

From source file:org.forzaframework.layout.FileDefinition.java

License:Apache License

public Element toXml(String elementName) {
    Element el = DocumentHelper.createElement("item");

    el.addElement("id").addText(this.getId().toString());
    el.addElement("code").addText(this.getCode() == null ? "" : this.getCode());
    el.addElement("name").addText(this.getName() == null ? "" : this.getName());
    el.addElement("externalSystem").addText(this.getExternalSystem() == null ? "" : this.getExternalSystem());
    el.addElement("updateExistingRecords")
            .addText(this.getUpdateExistingRecords() == null ? "" : this.getUpdateExistingRecords().toString());
    el.addElement("allowCreateNewRecords")
            .addText(this.getAllowCreateNewRecords() == null ? "" : this.getAllowCreateNewRecords().toString());
    el.addElement("ignoreNotExistingRecords").addText(
            this.getIgnoreNotExistingRecords() == null ? "" : this.getIgnoreNotExistingRecords().toString());
    el.addElement("entity").addText(this.getEntity() == null ? "" : this.getEntity());
    el.addElement("format").addText(this.getFormat() == null ? "" : this.getFormat());
    el.addElement("delimiter").addText(this.getDelimiter() == null ? "" : this.getDelimiter());
    if (this.getColumns().size() > 0) {
        Element columns = el.addElement("columns");
        for (ColumnDefinition columnDefinition : this.getColumns()) {
            Element column = columns.addElement("column");
            column.addElement("id").addText(columnDefinition.getId().toString());
            column.addElement("beanProperty").addText(columnDefinition.getBeanProperty());
            column.addElement("name").addText(columnDefinition.getName());
            column.addElement("format")
                    .addText(columnDefinition.getFormat() == null ? "" : columnDefinition.getFormat());
        }// w  w w.  j a v  a  2  s .co  m
    }
    return el;
}

From source file:org.forzaframework.metadata.Catalog.java

License:Apache License

public Element toXml(String elementName) {
    Element el = DocumentHelper.createElement(elementName);
    el.addElement("id").addText(this.getId() == null ? "" : this.getId().toString());
    el.addElement("code").addText(this.getCode() == null ? "" : this.getCode());
    el.addElement("name").addText(this.getName() == null ? "" : this.getName());
    return el;//w w  w .  j a  v  a2  s . co m
}

From source file:org.forzaframework.metadata.NamedEntity.java

License:Apache License

public Element toXml(String elementName) {
    Element el = DocumentHelper.createElement(elementName);
    el.addElement("id").addText(this.getId() == null ? "" : this.getId().toString());
    el.addElement("name").addText(this.getName() == null ? "" : this.getName());
    return el;//from  w  w  w.  ja  va2 s  . co  m
}

From source file:org.forzaframework.metadata.TranslatableCatalog.java

License:Apache License

public Element toXml(String elementName) {
    Element el = DocumentHelper.createElement(elementName);
    el.addElement("id").addText(this.getId().toString());
    el.addElement("code").addText(this.getCode() == null ? "" : this.getCode());
    el.addElement("name").addText(this.getName() == null ? "" : this.getName());
    if (this.translations != null) {
        for (Object o : this.translations.entrySet()) {
            Map.Entry entry = (Map.Entry) o;
            Object value = entry.getValue();
            el.addElement(entry.getKey().toString()).addText(value == null ? "" : value.toString());
        }/*from   ww  w  .ja va 2  s.  c  o m*/
    }
    return el;
}

From source file:org.forzaframework.security.Role.java

License:Apache License

public Element toXml(String elementName) {
    Element el = DocumentHelper.createElement(elementName);
    el.addElement("name").addText(this.getName());
    el.addElement("description").addText(this.getDescription() == null ? "" : this.getDescription());
    return el;//  w  w w  . ja v a  2  s. c om
}

From source file:org.forzaframework.security.SmartGroup.java

License:Apache License

public Element toXml(String elementName) {
    Element el = DocumentHelper.createElement(elementName);
    el.addElement("id").addText(this.getId().toString());
    el.addElement("code").addText(this.getCode() == null ? "" : this.getCode());
    el.addElement("name").addText(this.getName());
    //        if(this.getFilters().size() > 0){
    //            Element filters = el.addElement("filters");
    //            for(SmartGroupFilter smartGroupFilter : this.getFilters()){
    //                Element filter = filters.addElement("filterdef");
    //                filter.addElement("id").addText(smartGroupFilter.getId().toString());
    //                filter.addElement("property").addText(smartGroupFilter.getProperty());
    //                filter.addElement("type").addText(smartGroupFilter.getType());
    //                filter.addElement("filter").addText(smartGroupFilter.getFilter());
    //            }
    //        }/*from  w w w .j a  va2 s.c o m*/
    return el;
}

From source file:org.forzaframework.security.User.java

License:Apache License

public Element toXml(String elementName) {
    Element el = DocumentHelper.createElement(elementName);
    el.addElement("id").addText(this.getId().toString());
    el.addElement("username").addText(this.getUsername() == null ? "" : this.getUsername());
    el.addElement("password").addText(this.getPassword() == null ? "" : this.getPassword());
    el.addElement("firstName").addText(this.getFirstName() == null ? "" : this.getFirstName());
    el.addElement("lastName").addText(this.getLastName() == null ? "" : this.getLastName());
    el.addElement("name").addText(this.getFullName());
    el.addElement("email").addText(this.getEmail() == null ? "" : this.getEmail());
    el.addElement("preferredLocale")
            .addText(this.getPreferredLocale() == null ? "" : this.getPreferredLocale());
    el.addElement("enabled").addText(String.valueOf(this.isEnabled()));
    el.addElement("accountExpired").addText(String.valueOf(this.isAccountExpired()));
    el.addElement("accountLocked").addText(String.valueOf(this.isAccountLocked()));
    el.addElement("credentialsExpired").addText(String.valueOf(this.isCredentialsExpired()));
    el.addElement("enableExpiredPasswordProcess")
            .addText(String.valueOf(this.getEnableExpiredPasswordProcess()));
    if (this.getRoles().size() > 0) {
        Element roles = el.addElement("roles");
        for (Role role : this.getRoles()) {
            Element roleEl = roles.addElement("role");
            roleEl.addElement("id").addText(role.getName());
            roleEl.addElement("name").addText(role.getName());
        }//from   ww w.  ja v a 2s.c  o m
    }
    return el;
}

From source file:org.forzaframework.util.XmlUtils.java

License:Apache License

public static Document buildDocumentFromMap(List<Map> list) {
    Document doc = DocumentHelper.createDocument();
    doc.setXMLEncoding("ISO-8859-1");

    Element root = doc.addElement("items");
    root.addAttribute("success", "true");
    doc.setRootElement(root);// ww  w  .j a  v  a 2 s.c om

    for (Map map : list) {
        Element el = DocumentHelper.createElement("item");
        for (Iterator it = map.entrySet().iterator(); it.hasNext();) {
            Map.Entry entry = (Map.Entry) it.next();
            if (entry.getKey().toString().equals("$type$"))
                continue;

            el.addElement(entry.getKey().toString())
                    .addText(entry.getValue() == null ? "" : entry.getValue().toString());
        }
        root.add(el);
    }

    return doc;
}

From source file:org.frogx.service.core.iq.IQOwnerHandler.java

License:Open Source License

/**
 * Generating the configuration form// w  w w  . j  a va2 s . co m
 */
private void initConfigForm() {
    Element element = DocumentHelper.createElement(QName.get("query", MUGService.mugNS + "#owner"));

    configurationForm = new DataForm(DataForm.Type.form);
    configurationForm.setTitle(locale.getLocalizedString("mug.config.form.title.1") + " " + room.getName() + " "
            + locale.getLocalizedString("mug.config.form.title.2"));
    List<String> params = new ArrayList<String>();
    params.add(room.getName());
    configurationForm.addInstruction(locale.getLocalizedString("mug.config.form.instruction"));

    FormField field = configurationForm.addField();
    field.setVariable("FORM_TYPE");
    field.setType(FormField.Type.hidden);
    field.addValue(MUGService.mugNS + "#matchconfig");

    field = configurationForm.addField();
    field.setVariable("mug#roomconfig_roomname");
    field.setType(FormField.Type.text_single);
    field.setLabel(locale.getLocalizedString("mug.config.form.name"));

    field = configurationForm.addField();
    field.setVariable("mug#roomconfig_matchdesc");
    field.setType(FormField.Type.text_single);
    field.setLabel(locale.getLocalizedString("mug.config.form.description"));

    field = configurationForm.addField();
    field.setVariable("mug#roomconfig_moderated");
    field.setType(FormField.Type.boolean_type);
    field.setLabel(locale.getLocalizedString("mug.config.form.moderated"));

    field = configurationForm.addField();
    field.setVariable("mug#roomconfig_allowinvites");
    field.setType(FormField.Type.boolean_type);
    field.setLabel(locale.getLocalizedString("mug.config.form.allowinvites"));

    field = configurationForm.addField();
    field.setVariable("mug#roomconfig_maxusers");
    field.setType(FormField.Type.list_single);
    field.setLabel(locale.getLocalizedString("mug.config.form.maxusers"));
    field.addOption("10", "10");
    field.addOption("20", "20");
    field.addOption("30", "30");
    field.addOption("40", "40");
    field.addOption("50", "50");

    field = configurationForm.addField();
    field.setVariable("mug#roomconfig_publicroom");
    field.setType(FormField.Type.boolean_type);
    field.setLabel(locale.getLocalizedString("mug.config.form.publicroom"));

    field = configurationForm.addField();
    field.setVariable("mug#roomconfig_membersonly");
    field.setType(FormField.Type.boolean_type);
    field.setLabel(locale.getLocalizedString("mug.config.form.membersonly"));

    field = configurationForm.addField();
    field.setVariable("mug#roomconfig_anonymity");
    field.setType(FormField.Type.list_single);
    field.setLabel(locale.getLocalizedString("mug.config.form.anonymity"));
    field.addOption(locale.getLocalizedString("mug.config.form.anonymity.fully"), "fully-anonymous");
    field.addOption(locale.getLocalizedString("mug.config.form.anonymity.semi"), "semi-anonymous");
    field.addOption(locale.getLocalizedString("mug.config.form.anonymity.non"), "non-anonymous");

    field = configurationForm.addField();
    field.setVariable("mug#roomconfig_passwordprotectedroom");
    field.setType(FormField.Type.boolean_type);
    field.setLabel(locale.getLocalizedString("mug.config.form.password.protected"));

    field = configurationForm.addField();
    field.setType(FormField.Type.fixed);
    field.addValue(locale.getLocalizedString("mug.config.form.password.instruction"));

    field = configurationForm.addField();
    field.setVariable("mug#roomconfig_roomsecret");
    field.setType(FormField.Type.text_private);
    field.setLabel(locale.getLocalizedString("mug.config.form.password"));

    gameOptionsElement = element.addElement("options");
    gameOptionsElement.add(configurationForm.getElement());
    probeResult = element;
}