List of usage examples for org.dom4j Element elementText
String elementText(QName qname);
From source file:com.glaf.jbpm.config.JbpmExtensionReader.java
License:Apache License
public List<Extension> readTasks(java.io.InputStream inputStream) { List<Extension> extensions = new java.util.ArrayList<Extension>(); SAXReader xmlReader = new SAXReader(); try {/* ww w.jav a2s .com*/ Document doc = xmlReader.read(inputStream); Element root = doc.getRootElement(); String x_type = root.attributeValue("type"); List<?> rows = root.elements("taskmgr"); Iterator<?> iterator = rows.iterator(); while (iterator.hasNext()) { Element element = (Element) iterator.next(); Extension extension = new Extension(); extension.setProcessName(element.attributeValue("processName")); extension.setTaskName(element.attributeValue("taskName")); extension.setType(x_type); if (element.elementTextTrim("taskMgmtType") != null) { ExtensionField extensionField = new ExtensionField(); extensionField.setName("taskMgmtType"); extensionField.setValue(element.elementTextTrim("taskMgmtType")); extension.addField(extensionField); } Element propertiesE = element.element("properties"); if (propertiesE != null) { List<?> properties = propertiesE.elements("property"); Iterator<?> iter = properties.iterator(); while (iter.hasNext()) { Element elem = (Element) iter.next(); String propertyName = elem.attributeValue("key"); String propertyValue = null; if (elem.attribute("value") != null) { propertyValue = elem.attributeValue("value"); } else { propertyValue = elem.getTextTrim(); } if (StringUtils.isNotEmpty(propertyName) && StringUtils.isNotEmpty(propertyValue)) { ExtensionField extensionField = new ExtensionField(); extensionField.setName(propertyName.trim()); extensionField.setValue(propertyValue.trim()); extension.addField(extensionField); } } } if (element.elementText("handlers") != null) { ExtensionField extensionField = new ExtensionField(); extensionField.setName("handlers"); extensionField.setValue(element.elementTextTrim("handlers")); extension.addField(extensionField); } extensions.add(extension); } } catch (Exception ex) { throw new RuntimeException(ex); } return extensions; }
From source file:com.glaf.jbpm.config.JbpmExtensionReader.java
License:Apache License
public List<Extension> readActions(java.io.InputStream inputStream) { List<Extension> extensions = new java.util.ArrayList<Extension>(); SAXReader xmlReader = new SAXReader(); try {/*from w ww .j a va2 s . c o m*/ Document doc = xmlReader.read(inputStream); Element root = doc.getRootElement(); String x_type = root.attributeValue("type"); List<?> actions = root.elements("action"); Iterator<?> iter = actions.iterator(); while (iter.hasNext()) { Element element = (Element) iter.next(); Extension extension = new Extension(); extension.setProcessName(element.attributeValue("processName")); extension.setTaskName(element.attributeValue("taskName")); extension.setName(element.attributeValue("name")); extension.setType(x_type); extension.setDescription(element.elementTextTrim("description")); Iterator<?> it99 = element.elementIterator(); while (it99.hasNext()) { Element elem = (Element) it99.next(); String propertyName = elem.getName(); String propertyValue = elem.getTextTrim(); if (StringUtils.isNotEmpty(propertyValue)) { ExtensionField extensionField = new ExtensionField(); extensionField.setName(propertyName.trim()); extensionField.setValue(propertyValue.trim()); extension.addField(extensionField); } } if (element.elementText("sql") != null) { ExtensionField extensionField = new ExtensionField(); extensionField.setName("sql"); extensionField.setValue(element.elementTextTrim("sql")); extension.addField(extensionField); } if (element.elementText("handlers") != null) { ExtensionField extensionField = new ExtensionField(); extensionField.setName("handlers"); extensionField.setValue(element.elementTextTrim("handlers")); extension.addField(extensionField); } Element parametersE = element.element("parameters"); if (parametersE != null) { List<?> parameters = parametersE.elements("parameter"); Iterator<?> it = parameters.iterator(); while (it.hasNext()) { Element elem = (Element) it.next(); String propertyName = elem.attributeValue("name"); String type = elem.attributeValue("type"); String propertyValue = null; if (elem.attribute("value") != null) { propertyValue = elem.attributeValue("value"); } else { propertyValue = elem.getTextTrim(); } if (StringUtils.isNotEmpty(propertyName) && StringUtils.isNotEmpty(propertyValue)) { ExtensionParam extensionParam = new ExtensionParam(); extensionParam.setName(propertyName.trim()); extensionParam.setValue(propertyValue.trim()); extensionParam.setType(type); extension.addParam(extensionParam); } } } extensions.add(extension); } } catch (Exception ex) { throw new RuntimeException(ex); } return extensions; }
From source file:com.glaf.jbpm.xml.JpdlXmlReader.java
License:Apache License
public List<Todo> read(InputStream inputStream) { List<Todo> todoList = new java.util.ArrayList<Todo>(); SAXReader xmlReader = new SAXReader(); int sortNo = 1; try {/*from w w w. ja va 2s .c o m*/ Document doc = xmlReader.read(inputStream); Element root = doc.getRootElement(); String processName = root.attributeValue("name"); String moduleName = root.elementText("description"); List<?> rows = root.elements("task-node"); Iterator<?> iterator = rows.iterator(); while (iterator.hasNext()) { Element element = (Element) iterator.next(); List<?> tasks = element.elements("task"); Iterator<?> iter = tasks.iterator(); while (iter.hasNext()) { Element elem = (Element) iter.next(); String taskName = elem.attributeValue("name"); if (taskName.startsWith("task55")) { continue; } Todo model = new Todo(); model.setSortNo(sortNo++); model.setProcessName(processName); model.setModuleName(moduleName); model.setTitle(moduleName + " " + elem.attributeValue("description") + "??"); model.setContent(moduleName + " " + elem.attributeValue("description") + "??"); model.setCode(processName + "_" + taskName); model.setTaskName(taskName); model.setProvider("jbpm"); model.setLinkType(processName + "_" + taskName); String detail_url = conf.get("jbpm_task_detail_url"); String list_url = conf.get("jbpm_task_url"); model.setLink(detail_url + "&rowId=#{rowId}&x_method=view&app_name=" + processName); model.setListLink(list_url + "&taskType=running&app_name=" + processName); model.setLimitDay(2); model.setXa(6); model.setXb(6); todoList.add(model); } } } catch (Exception ex) { throw new RuntimeException(ex); } return todoList; }
From source file:com.glaf.mail.xml.MailXmlReader.java
License:Apache License
public List<MailTemplate> read(java.io.InputStream inputStream) { List<MailTemplate> mailTemplates = new java.util.ArrayList<MailTemplate>(); SAXReader xmlReader = new SAXReader(); Document doc = null;//www. j a v a 2 s . co m try { doc = xmlReader.read(inputStream); } catch (Exception ex) { throw new RuntimeException(ex); } Element root = doc.getRootElement(); List<?> rows = root.elements(); Iterator<?> iterator = rows.iterator(); while (iterator.hasNext()) { Element element = (Element) iterator.next(); String mailId = element.attributeValue("id"); String title = element.attributeValue("title"); String templateId = element.elementText("templateId"); String templatePath = element.elementText("templatePath"); MailTemplate mt = new MailTemplate(); mt.setTitle(title); mt.setMailDefId(mailId); mt.setTemplateId(templateId); mt.setTemplatePath(templatePath); mt.setProperties(this.readProperties(element)); mt.setContent(element.elementText("content")); mt.setDescription(element.elementText("description")); List<?> datasets = element.elements("dataset"); Iterator<?> iter = datasets.iterator(); while (iter.hasNext()) { Element elem = (Element) iter.next(); MailDataSet mailDS = new MailDataSet(); mailDS.setProperties(this.readProperties(elem)); List<?> rowsets = elem.elements("rowset"); Iterator<?> it = rowsets.iterator(); while (it.hasNext()) { Element em = (Element) it.next(); MailRowSet rs = new MailRowSet(); rs.setQuery(em.elementTextTrim("query")); rs.setMapping(em.attributeValue("mapping")); rs.setMailMgr(em.attributeValue("mailMgr")); rs.setMailMgrClassName(em.attributeValue("mailMgrClassName")); rs.setMailMgrMapping(em.attributeValue("mailMgrMapping")); rs.setDataMgr(em.attributeValue("dataMgr")); rs.setDataMgrBeanId(em.attributeValue("dataMgrBeanId")); rs.setDataMgrClassName(em.attributeValue("dataMgrClassName")); rs.setProperties(this.readProperties(em)); String singleResult = em.attributeValue("singleResult"); if ("true".equals(singleResult)) { rs.setSingleResult(true); } mailDS.addRowSet(rs); } mt.addDataSet(mailDS); } mailTemplates.add(mt); } return mailTemplates; }
From source file:com.glaf.report.xml.ReportDefinitionReader.java
License:Apache License
public List<ReportDefinition> read(java.io.InputStream inputStream) { List<ReportDefinition> reports = new java.util.ArrayList<ReportDefinition>(); SAXReader xmlReader = new SAXReader(); Document doc = null;/*ww w. j ava 2 s. co m*/ try { doc = xmlReader.read(inputStream); } catch (Exception ex) { throw new RuntimeException(ex); } Element root = doc.getRootElement(); List<?> rows = root.elements(); Iterator<?> iterator = rows.iterator(); while (iterator.hasNext()) { Element element = (Element) iterator.next(); String reportId = element.attributeValue("id"); String templateId = element.elementText("templateId"); String templateFile = element.elementText("templateFile"); ReportDefinition rdf = new ReportDefinition(); rdf.setReportId(reportId); rdf.setTemplateId(templateId); rdf.setTemplateFile(templateFile); rdf.setProperties(this.readProperties(element)); List<?> datasets = element.elements("dataset"); Iterator<?> iter = datasets.iterator(); while (iter.hasNext()) { Element elem = (Element) iter.next(); ReportDataSet rds = new ReportDataSet(); rds.setDatasourceName(elem.attributeValue("datasourceName")); rds.setProperties(this.readProperties(elem)); List<?> rowsets = elem.elements("rowset"); Iterator<?> it = rowsets.iterator(); while (it.hasNext()) { Element em = (Element) it.next(); ReportRowSet rs = new ReportRowSet(); rs.setQuery(em.elementTextTrim("query")); rs.setMapping(em.attributeValue("mapping")); rs.setRptMgr(em.attributeValue("rptMgr")); rs.setRptMgrClassName(em.attributeValue("rptMgrClassName")); rs.setRptMgrMapping(em.attributeValue("rptMgrMapping")); rs.setDataMgr(em.attributeValue("dataMgr")); rs.setDataMgrBeanId(em.attributeValue("dataMgrBeanId")); rs.setDataMgrClassName(em.attributeValue("dataMgrClassName")); rs.setProperties(this.readProperties(em)); String singleResult = em.attributeValue("singleResult"); if ("true".equals(singleResult)) { rs.setSingleResult(true); } rds.addRowSet(rs); } rdf.addDataSet(rds); } reports.add(rdf); } return reports; }
From source file:com.glaf.template.TemplateReader.java
License:Apache License
@SuppressWarnings("unchecked") public Map<String, Template> getTemplates(InputStream inputStream) { Map<String, Template> dataMap = new java.util.HashMap<String, Template>(); Element root = this.getRootElement(inputStream); List<?> templates = root.elements("template"); if (templates != null && templates.size() > 0) { Iterator<?> iterator = templates.iterator(); while (iterator.hasNext()) { Element element = (Element) iterator.next(); Template template = new Template(); List<Element> elems = element.elements(); if (elems != null && !elems.isEmpty()) { Map<String, Object> rowMap = new java.util.HashMap<String, Object>(); for (Element em : elems) { rowMap.put(em.getName(), em.getStringValue()); }/*from w w w . j a v a2 s . c o m*/ Tools.populate(template, rowMap); } String text = element.elementText("text"); String name = element.elementText("name"); String title = element.elementText("title"); String templateId = element.attributeValue("id"); String dataFile = element.elementText("dataFile"); String moduleId = element.elementText("moduleId"); String moduleName = element.elementText("moduleName"); String callbackUrl = element.elementText("callbackUrl"); String description = element.elementText("description"); String language = element.elementText("language"); String objectId = element.elementText("objectId"); String objectValue = element.elementText("objectValue"); String _fileType = element.elementText("fileType"); template.setLanguage(language); int fileType = 0; if (StringUtils.isNumeric(_fileType)) { fileType = Integer.parseInt(_fileType); } if (dataFile.endsWith(".java")) { fileType = 50; } else if (dataFile.endsWith(".jsp")) { fileType = 51; } else if (dataFile.endsWith(".ftl")) { fileType = 52; template.setLanguage("freemarker"); } else if (dataFile.endsWith(".vm")) { fileType = 54; template.setLanguage("velocity"); } else if (dataFile.endsWith(".xml")) { fileType = 60; } else if (dataFile.endsWith(".htm") || dataFile.endsWith(".html")) { fileType = 80; } template.setTemplateType(FileUtils.getFileExt(dataFile)); if (StringUtils.isEmpty(text)) { String filename = SystemProperties.getConfigRootPath() + dataFile; File file = new File(filename); template.setLastModified(file.lastModified()); template.setFileSize(file.length()); byte[] data = FileUtils.getBytes(file); template.setData(data); } if (template.getData() == null || template.getFileSize() == 0) { throw new RuntimeException(" template content is null "); } template.setContent(text); template.setDataFile(dataFile); template.setTitle(title); template.setName(name); if (StringUtils.isNotEmpty(name)) { template.setName(name); } else { template.setName(title); } template.setFileType(fileType); template.setCallbackUrl(callbackUrl); template.setDescription(description); template.setTemplateId(templateId); template.setModuleId(moduleId); template.setModuleName(moduleName); template.setObjectId(objectId); template.setObjectValue(objectValue); dataMap.put(templateId, template); } } return dataMap; }
From source file:com.glaf.wechat.sdk.message.handler.AbstractMessageHandler.java
License:Apache License
@Override public void parseMessage(Message message, Element root) { message.setMsgType(root.elementText(TAG_MSGTYPE)); message.setFromUserName(root.elementText(TAG_FROMUSERNAME)); message.setToUserName(root.elementText(TAG_TOUSERNAME)); parseSpecialMessage(message, root);// ww w. j av a2 s . c om }
From source file:com.glaf.wechat.sdk.message.handler.EventMessageHandler.java
License:Apache License
@Override protected void parseSpecialMessage(Message message, Element root) { EventMessage msg = (EventMessage) message; msg.setEvent(root.elementText(TAG_EVENT)); msg.setEventKey(root.elementText(TAG_EVENTKEY)); }
From source file:com.glaf.wechat.sdk.message.handler.ImageMessageHandler.java
License:Apache License
@Override protected void parseSpecialMessage(Message message, Element root) { ImageMessage msg = (ImageMessage) message; msg.setPicUrl(root.elementText(TAG_PICURL)); }
From source file:com.glaf.wechat.sdk.message.handler.LinkMessageHandler.java
License:Apache License
@Override protected void parseSpecialMessage(Message message, Element root) { LinkMessage msg = (LinkMessage) message; msg.setUrl(root.elementText(TAG_URL)); msg.setDescription(root.elementText(TAG_DESCRIPTION)); msg.setTitle(root.elementText(TAG_TITLE)); }