Example usage for org.dom4j DocumentHelper createDocument

List of usage examples for org.dom4j DocumentHelper createDocument

Introduction

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

Prototype

public static Document createDocument() 

Source Link

Usage

From source file:com.liferay.jbpm.WorkflowComponentImpl.java

License:Open Source License

public String getDefinitionsXml(long definitionId, String name, int start, int end)
        throws WorkflowComponentException {

    List definitions = getDefinitions(definitionId, name, start, end);

    Document doc = DocumentHelper.createDocument();

    Element root = doc.addElement("result");

    for (int i = 0; i < definitions.size(); i++) {
        ProcessDefinition definition = (ProcessDefinition) definitions.get(i);

        createElement(definition, root);
    }/*from   w  w w  . j a  v a2  s .  c om*/

    return doc.asXML();
}

From source file:com.liferay.jbpm.WorkflowComponentImpl.java

License:Open Source License

public String getDefinitionXml(long definitionId) throws WorkflowComponentException {

    ProcessDefinition definition = (ProcessDefinition) getDefinition(definitionId);

    Document doc = DocumentHelper.createDocument();

    Element root = doc.addElement("result");

    createElement(definition, root);/*from  www.  j a v  a  2s .c om*/

    return doc.asXML();
}

From source file:com.liferay.jbpm.WorkflowComponentImpl.java

License:Open Source License

public String getInstancesXml(long definitionId, long instanceId, String definitionName,
        String definitionVersion, String startDateGT, String startDateLT, String endDateGT, String endDateLT,
        boolean hideEndedTasks, boolean retrieveUserInstances, boolean andOperator, int start, int end)
        throws WorkflowComponentException {

    List instances = getInstances(definitionId, instanceId, definitionName, definitionVersion, startDateGT,
            startDateLT, endDateGT, endDateLT, hideEndedTasks, retrieveUserInstances, andOperator, start, end);

    Document doc = DocumentHelper.createDocument();

    Element root = doc.addElement("result");

    for (int i = 0; i < instances.size(); i++) {
        ProcessInstance instance = (ProcessInstance) instances.get(i);

        createElement(instance, root, true);
    }/* w w  w. ja v  a 2  s.  c  o m*/

    return doc.asXML();
}

From source file:com.liferay.jbpm.WorkflowComponentImpl.java

License:Open Source License

public String getTaskXml(long taskId) throws WorkflowComponentException {

    TaskInstance task = (TaskInstance) getTask(taskId);

    Document doc = DocumentHelper.createDocument();

    Element root = doc.addElement("result");

    createElement(task, root);/*  w w  w. jav  a2s . c o m*/

    return doc.asXML();
}

From source file:com.liferay.jbpm.WorkflowComponentImpl.java

License:Open Source License

public String getTaskFormElementsXml(long taskId) throws WorkflowComponentException {

    List taskFormElements = getTaskFormElements(taskId);

    Document doc = DocumentHelper.createDocument();

    Element root = doc.addElement("result");

    for (int i = 0; i < taskFormElements.size(); i++) {
        TaskFormElement taskFormElement = (TaskFormElement) taskFormElements.get(i);

        createElement(taskFormElement, root);
    }//from  ww w .j  a va 2s .  co m

    return doc.asXML();
}

From source file:com.liferay.jbpm.WorkflowComponentImpl.java

License:Open Source License

public String getTaskTransitionsXml(long taskId) throws WorkflowComponentException {

    List transitions = getTaskTransitions(taskId);

    Document doc = DocumentHelper.createDocument();

    Element root = doc.addElement("result");

    for (int i = 0; i < transitions.size(); i++) {
        Transition transition = (Transition) transitions.get(i);

        DocUtil.add(root, "transition", transition.getName());
    }/*from w ww  .  ja  v  a 2  s  . c  om*/

    return doc.asXML();
}

From source file:com.liferay.jbpm.WorkflowComponentImpl.java

License:Open Source License

public String getUserTasksXml(long instanceId, String taskName, String definitionName, String assignedTo,
        String createDateGT, String createDateLT, String startDateGT, String startDateLT, String endDateGT,
        String endDateLT, boolean hideEndedTasks, boolean andOperator, int start, int end)
        throws WorkflowComponentException {

    List tasks = getUserTasks(instanceId, taskName, definitionName, assignedTo, createDateGT, createDateLT,
            startDateGT, startDateLT, endDateGT, endDateLT, hideEndedTasks, andOperator, start, end);

    Document doc = DocumentHelper.createDocument();

    Element root = doc.addElement("result");

    for (int i = 0; i < tasks.size(); i++) {
        TaskInstance task = (TaskInstance) tasks.get(i);

        createElement(task, root);/*from  w  w w  .  j  av a  2s.c om*/
    }

    return doc.asXML();
}

From source file:com.liferay.jbpm.WorkflowComponentImpl.java

License:Open Source License

public String startWorkflow(long definitionId) throws WorkflowComponentException {

    ProcessDefinition definition = graphSession.loadProcessDefinition(definitionId);

    ProcessInstance instance = new ProcessInstance(definition);

    // After creating process instance, assign the currently authenticated
    // user to the first task if it exists

    if (instance.getTaskMgmtInstance().getTaskMgmtDefinition().getStartTask() != null) {

        jbpmContext.setActorId(userId);/*from   ww  w . j a va  2  s .  c  om*/

        instance.getTaskMgmtInstance().createStartTaskInstance();
    }

    jbpmContext.save(instance);

    WorkflowUtil.initInstance(instance);

    Document doc = DocumentHelper.createDocument();

    Element root = doc.addElement("result");

    createElement(instance, root, false);

    return doc.asXML();
}

From source file:com.liferay.jbpm.WorkflowComponentImpl.java

License:Open Source License

public String updateTaskXml(long taskId, String transition, Map parameterMap)
        throws WorkflowComponentException {

    Map errors = updateTask(taskId, transition, parameterMap);

    Document doc = DocumentHelper.createDocument();

    Element root = doc.addElement("results");

    Iterator itr = errors.entrySet().iterator();

    while (itr.hasNext()) {
        Map.Entry entry = (Map.Entry) itr.next();

        String name = (String) entry.getKey();
        String code = (String) entry.getValue();

        Element el = root.addElement("error");

        DocUtil.add(el, "name", name);
        DocUtil.add(el, "code", code);
    }/*from w ww . jav  a  2  s .c o  m*/

    return doc.asXML();
}

From source file:com.liferay.portal.tools.ExtInfoBuilder.java

License:Open Source License

public ExtInfoBuilder(String basedir, String outputDir, String servletContextName) throws Exception {

    DirectoryScanner ds = new DirectoryScanner();

    ds.setBasedir(basedir);//  w ww. ja v  a  2 s.  c  o  m
    ds.setExcludes(new String[] { ".svn/**", "**/.svn/**", "ext-impl/ext-impl.jar", "ext-impl/src/**",
            "ext-service/ext-service.jar", "ext-service/src/**", "ext-util-bridges/ext-util-bridges.jar",
            "ext-util-bridges/src/**", "ext-util-java/ext-util-java.jar", "ext-util-java/src/**",
            "ext-util-taglib/ext-util-taglib.jar", "ext-util-taglib/src/**",
            "liferay-plugin-package.properties" });

    ds.scan();

    String[] files = ds.getIncludedFiles();

    Arrays.sort(files);

    Element rootElement = new ElementImpl(DocumentHelper.createElement("ext-info"));

    Document document = new DocumentImpl(DocumentHelper.createDocument());

    document.setRootElement(rootElement);

    DocUtil.add(rootElement, "servlet-context-name", servletContextName);

    Element filesElement = rootElement.addElement("files");

    for (String file : files) {
        DocUtil.add(filesElement, "file", StringUtil.replace(file, StringPool.BACK_SLASH, StringPool.SLASH));
    }

    _fileUtil.write(outputDir + "/ext-" + servletContextName + ".xml", document.formattedString());
}