Example usage for org.dom4j Document getRootElement

List of usage examples for org.dom4j Document getRootElement

Introduction

In this page you can find the example usage for org.dom4j Document getRootElement.

Prototype

Element getRootElement();

Source Link

Document

Returns the root Element for this document.

Usage

From source file:com.founder.fix.fixflow.core.impl.flowgraphics.svg.component.SvgTerminateEndEventComponent.java

License:Apache License

public String createComponent(SvgBaseTo svgTo) {
    String result = null;//from  w  ww . j a  va2  s .  com
    try {
        SvgTerminateEndEventTo steevent = (SvgTerminateEndEventTo) svgTo;
        InputStream in = SvgBench.class.getResourceAsStream(comPath);
        Document doc = XmlUtil.read(in);
        String str = doc.getRootElement().asXML();
        str = FlowSvgUtil.replaceAll(str, local_x, StringUtil.getString(steevent.getX()));
        str = FlowSvgUtil.replaceAll(str, local_y, StringUtil.getString(steevent.getY()));
        str = FlowSvgUtil.replaceAll(str, id, steevent.getId());
        str = FlowSvgUtil.replaceAll(str, text, steevent.getLabel());
        result = str;
    } catch (DocumentException e) {
        throw new FixFlowException("", e);
    }
    return result;
}

From source file:com.founder.fix.fixflow.core.impl.ProcessEngineConfigurationImpl.java

License:Apache License

private void initRulesConfig() {
    // this.rulesConfigs=new ArrayList<RulesConfig>();
    ruleMap.clear();/*from  w w  w.j av a  2s.  c om*/

    RulesResourceConfig rulesResourceConfig = getFixFlowConfig().getRulesResourceConfig();
    List<RulesResource> rulesResources = rulesResourceConfig.getRulesResource();

    for (RulesResource rulesResource : rulesResources) {
        String classPath = rulesResource.getSrc();
        Document document = null;
        try {
            InputStream in = ReflectUtil.getResourceAsStream(classPath);
            document = XmlUtil.read(in);
        } catch (DocumentException e) {
            log.error("??:" + classPath + "", e);
            throw new FixFlowClassLoadingException(ExceptionCode.CLASSLOAD_EXCEPTION_DCUMENT, classPath, e);
        }

        for (Object ele : document.getRootElement().elements("dataBaseTable")) {
            Element element = (Element) ele;

            DataBaseTable dataBaseTable = SqlmappingconfigFactory.eINSTANCE.createDataBaseTable();
            dataBaseTable.setTableId(element.attributeValue("tableId"));
            dataBaseTable.setTableName(element.attributeValue("tableName"));
            dataBaseTable.setTableValue(element.attributeValue("tableValue"));
            dataBaseTable.setArchiveTable(element.attributeValue("archiveTable"));
            //dataBaseTable.setMappingType(element.attributeValue("mappingType"));

            for (Object eleNew : element.elements("column")) {
                Element columnElement = (Element) eleNew;
                Column column = SqlmappingconfigFactory.eINSTANCE.createColumn();
                column.setColumn(columnElement.attributeValue("column"));
                column.setName(columnElement.attributeValue("name"));
                column.setJdbcType(columnElement.attributeValue("jdbcType"));
                //column.setProperty(columnElement.attributeValue("property"));
                //column.setSimpleKey(columnElement.attributeValue("property"));

                dataBaseTable.getColumn().add(column);
                columnMap.put(dataBaseTable.getTableId() + "_" + column.getColumn(), column);
            }

            dataBaseTables.put(dataBaseTable.getTableId(), dataBaseTable);

        }

        for (Object ele : document.getRootElement().elements("resultMap")) {
            Element element = (Element) ele;

            ResultMap resultMap = SqlmappingconfigFactory.eINSTANCE.createResultMap();
            resultMap.setId(element.attributeValue("id"));
            resultMap.setName(element.attributeValue("name"));
            resultMap.setType(element.attributeValue("type"));

            for (Object eleNew : element.elements("result")) {
                Element resultMappingElement = (Element) eleNew;
                Result result = SqlmappingconfigFactory.eINSTANCE.createResult();
                result.setColumn(resultMappingElement.attributeValue("column"));
                result.setName(resultMappingElement.attributeValue("name"));
                result.setJdbcType(resultMappingElement.attributeValue("jdbcType"));
                result.setProperty(resultMappingElement.attributeValue("property"));
                //result.setSimpleKey(columnMappingElement.attributeValue("property"));

                resultMap.getResult().add(result);
                //columnMappingMap.put(dataBaseTable.getTableId()+"_"+columnMapping.getColumn(), columnMapping);
            }

            resultMaps.put(resultMap.getId(), resultMap);

        }

        for (Object ele : document.getRootElement().elements("insert")) {
            Element element = (Element) ele;

            Insert insertObj = SqlmappingconfigFactory.eINSTANCE.createInsert();
            insertObj.setId(element.attributeValue("id"));
            insertObj.setParameterType(element.attributeValue("parameterType"));
            insertObj.setRemark(element.attributeValue("remark"));
            insertObj.setSqlValue(element.getText());

            String classPathString = element.attributeValue("classPath");

            if (StringUtil.isNotEmpty(classPathString)) {
                Class<?> classObj = ReflectUtil.loadClass(classPathString);
                if (classObj != null) {
                    insertObj.setClassPath(classPathString);
                    ruleClassMap.put(element.attributeValue("id"), classObj);
                }
            }

            ruleMap.put(insertObj.getId(), insertObj);

        }

        for (Object ele : document.getRootElement().elements("delete")) {
            Element element = (Element) ele;

            Delete deleteObj = SqlmappingconfigFactory.eINSTANCE.createDelete();
            deleteObj.setId(element.attributeValue("id"));
            deleteObj.setParameterType(element.attributeValue("parameterType"));
            deleteObj.setRemark(element.attributeValue("remark"));
            deleteObj.setSqlValue(element.getText());

            String classPathString = element.attributeValue("classPath");

            if (StringUtil.isNotEmpty(classPathString)) {
                Class<?> classObj = ReflectUtil.loadClass(classPathString);
                if (classObj != null) {
                    deleteObj.setClassPath(classPathString);
                    ruleClassMap.put(element.attributeValue("id"), classObj);
                }
            }

            ruleMap.put(deleteObj.getId(), deleteObj);

        }

        for (Object ele : document.getRootElement().elements("update")) {
            Element element = (Element) ele;
            Update updateObj = SqlmappingconfigFactory.eINSTANCE.createUpdate();
            updateObj.setId(element.attributeValue("id"));
            updateObj.setParameterType(element.attributeValue("parameterType"));
            updateObj.setRemark(element.attributeValue("remark"));
            updateObj.setSqlValue(element.getText());
            String classPathString = element.attributeValue("classPath");

            if (StringUtil.isNotEmpty(classPathString)) {
                Class<?> classObj = ReflectUtil.loadClass(classPathString);
                if (classObj != null) {
                    updateObj.setClassPath(classPathString);
                    ruleClassMap.put(element.attributeValue("id"), classObj);
                }
            }
            ruleMap.put(updateObj.getId(), updateObj);
        }

        for (Object ele : document.getRootElement().elements("select")) {
            Element element = (Element) ele;
            Select selectObj = SqlmappingconfigFactory.eINSTANCE.createSelect();
            selectObj.setId(element.attributeValue("id"));
            selectObj.setParameterType(element.attributeValue("parameterType"));
            selectObj.setRemark(element.attributeValue("remark"));
            selectObj.setSqlValue(element.getText());
            selectObj.setResultMap(element.attributeValue("resultMap"));
            String classPathString = element.attributeValue("classPath");
            if (StringUtil.isNotEmpty(classPathString)) {
                Class<?> classObj = ReflectUtil.loadClass(classPathString);
                if (classObj != null) {
                    selectObj.setClassPath(classPathString);
                    ruleClassMap.put(element.attributeValue("id"), classObj);
                }
            }
            ruleMap.put(selectObj.getId(), selectObj);
        }

        for (Object ele : document.getRootElement().elements("businessRules")) {
            Element element = (Element) ele;
            BusinessRules businessRules = SqlmappingconfigFactory.eINSTANCE.createBusinessRules();
            businessRules.setId(element.attributeValue("id"));
            businessRules.setParameterType(element.attributeValue("parameterType"));
            businessRules.setRemark(element.attributeValue("remark"));
            businessRules.setSqlValue(element.getText());
            businessRules.setResultType(element.attributeValue("resultType"));
            String classPathString = element.attributeValue("classPath");
            if (StringUtil.isNotEmpty(classPathString)) {
                Class<?> classObj = ReflectUtil.loadClass(classPathString);
                if (classObj != null) {
                    businessRules.setClassPath(classPathString);
                    ruleClassMap.put(element.attributeValue("id"), classObj);
                }
            }
            ruleMap.put(businessRules.getId(), businessRules);
        }
    }
}

From source file:com.founder.fix.fixflow.core.impl.util.XmlUtil.java

License:Apache License

public static Element getRootElement(Document document) {

    return document.getRootElement();
}

From source file:com.fxdigital.manager.SoftInfoImpl.java

/**
 * ???/*w ww  .j a  v a 2  s  . co  m*/
 * 
 * @return
 */
public String getDeviceType() {
    String type = null;
    String path = getPath();
    if (path == null) {
        return "?";
    }
    File f = new File(path);
    SAXReader reader = new SAXReader();
    try {
        Document doc = reader.read(f);
        Element root = doc.getRootElement();
        type = root.attributeValue("DeviceType");
    } catch (Exception e) {
        e.printStackTrace();
    }
    return type;
}

From source file:com.fxdigital.manager.SoftInfoImpl.java

/**
 * ??//from w w  w  . ja va  2 s  . co  m
 * 
 * @return
 */
public String getSoftVersion() {
    String version = null;
    String path = getPath();
    if (path == null) {
        return "?";
    }
    File f = new File(path);
    SAXReader reader = new SAXReader();
    try {
        Document doc = reader.read(f);
        Element root = doc.getRootElement();
        version = root.attributeValue("version");
        version = "V" + version;
    } catch (Exception e) {
        e.printStackTrace();
    }
    if (version == null)
        version = "V1.0";
    return version;
}

From source file:com.fxdigital.manager.SoftInfoImpl.java

/**
 * ??/*from w ww . ja v  a2s. c o m*/
 * 
 * @return
 */
public String getLicenseTime() {
    String time = null;
    String path = getPath();
    if (path == null) {
        return "?";
    }
    File f = new File(path);
    SAXReader reader = new SAXReader();
    try {
        Document doc = reader.read(f);
        Element root = doc.getRootElement();
        time = root.attributeValue("SerialNumber");
    } catch (Exception e) {
        e.printStackTrace();
    }
    if (time != null && time.length() >= 14) {
        time = time.substring(0, 4) + "-" + time.substring(4, 6) + "-" + time.substring(6, 8) + " "
                + time.substring(8, 10) + ":" + time.substring(10, 12) + ":" + time.substring(12, 14);
    }

    return time;
}

From source file:com.gi.desktop.maptool.dialog.MapServiceConfDialog.java

License:Open Source License

@SuppressWarnings("unchecked")
private void loadAgsSchema() {
    JFileChooser dialog = getJFileChooserAgsSchema();
    int val = dialog.showOpenDialog(this);
    if (val == JFileChooser.APPROVE_OPTION) {
        File agsSchema = dialog.getSelectedFile();
        try {/*from   ww w .  j  a  v  a 2 s.  com*/
            FileInputStream in = new FileInputStream(agsSchema);
            SAXReader saxReader = new SAXReader();
            Document document = saxReader.read(in);
            Element root = document.getRootElement();
            Element eTileCacheInfo = root.element("TileCacheInfo");

            Element eTileOrigin = eTileCacheInfo.element("TileOrigin");
            this.jTextFieldOriginX.setText(eTileOrigin.elementText("X"));
            this.jTextFieldOriginY.setText(eTileOrigin.elementText("Y"));

            this.jTextFieldWidth.setText(eTileCacheInfo.elementText("TileCols"));
            this.jTextFieldHeight.setText(eTileCacheInfo.elementText("TileRows"));

            jListLevelsModel.removeAllElements();
            Element eLODInfos = eTileCacheInfo.element("LODInfos");
            for (Iterator iLODInfos = eLODInfos.elementIterator(); iLODInfos.hasNext();) {
                Element eLODInfo = (Element) iLODInfos.next();
                TileLodInfo tileLodInfo = new TileLodInfo();
                tileLodInfo.setLevel(Integer.valueOf(eLODInfo.elementText("LevelID")));
                tileLodInfo.setScale(Double.valueOf(eLODInfo.elementText("Scale")));
                tileLodInfo.setResolution(Double.valueOf(eLODInfo.elementText("Resolution")));

                LodItem item = new LodItem();
                item.setTileLodInfo(tileLodInfo);
                jListLevelsModel.addElement(item);
            }
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Load Error!");
        }
    }
}

From source file:com.github.autoprimer3.AutoPrimer3Config.java

License:Open Source License

public LinkedHashSet<String> readTableFile(Document dasXml) throws DocumentException {
    LinkedHashSet<String> tables = new LinkedHashSet<>();
    Element root = dasXml.getRootElement();
    Element gff = root.element("GFF");
    Element segment = gff.element("SEGMENT");
    for (Iterator i = segment.elementIterator("TYPE"); i.hasNext();) {
        Element type = (Element) i.next();
        Attribute id = type.attribute("id");
        tables.add(id.getValue());/*from  ww w  .j a v  a2s . c  o  m*/
    }
    return tables;
}

From source file:com.github.autoprimer3.AutoPrimer3Config.java

License:Open Source License

public LinkedHashSet<String> readTableFile(Document dasXml, String category) throws DocumentException {
    LinkedHashSet<String> tables = new LinkedHashSet<>();
    Element root = dasXml.getRootElement();
    Element gff = root.element("GFF");
    Element segment = gff.element("SEGMENT");
    for (Iterator i = segment.elementIterator("TYPE"); i.hasNext();) {
        Element type = (Element) i.next();
        Attribute id = type.attribute("id");
        Attribute cat = type.attribute("category");
        if (cat.getValue().equals(category)) {
            tables.add(id.getValue());//ww  w  .j  a v  a 2 s . c o m
        }
    }
    return tables;
}

From source file:com.github.autoprimer3.GetUcscBuildsAndTables.java

License:Open Source License

public String retrieveSequence(String build, String chrom, Integer start, Integer end)
        throws DocumentException, MalformedURLException {
    if (buildToDescription.isEmpty()) {
        this.connectToUcsc();
    }/*from  w w  w. j  a va  2s  .  c om*/
    if (!buildToMapMaster.containsKey(build)) {
        return null;
    } else {
        StringBuilder dna = new StringBuilder();
        URL genomeUrl = new URL(
                buildToMapMaster.get(build) + "/dna?segment=" + chrom + ":" + (start + 1) + "," + end);
        SAXReader reader = new SAXReader();
        Document dasXml;
        dasXml = reader.read(genomeUrl);
        Element root = dasXml.getRootElement();
        for (Iterator i = root.elementIterator("SEQUENCE"); i.hasNext();) {
            Element dsn = (Element) i.next();
            Element seq = dsn.element("DNA");
            String text = seq.getText().replaceAll("\n", "");
            dna.append(text);
            //dna.append(seq.getText());
        }
        return dna.toString();

    }

}