Search in sources :

Example 81 with Namespace

use of org.jdom.Namespace in project oozie by apache.

the class TestHiveActionExecutor method testHiveAction.

public void testHiveAction() throws Exception {
    Path inputDir = new Path(getFsTestCaseDir(), INPUT_DIRNAME);
    Path outputDir = new Path(getFsTestCaseDir(), OUTPUT_DIRNAME);
    String hiveScript = getHiveScript(inputDir.toString(), outputDir.toString());
    FileSystem fs = getFileSystem();
    {
        Path script = new Path(getAppPath(), HIVE_SCRIPT_FILENAME);
        Writer scriptWriter = new OutputStreamWriter(fs.create(script));
        scriptWriter.write(hiveScript);
        scriptWriter.close();
        Writer dataWriter = new OutputStreamWriter(fs.create(new Path(inputDir, DATA_FILENAME)));
        dataWriter.write(SAMPLE_DATA_TEXT);
        dataWriter.close();
        Context context = createContext(getActionScriptXml());
        Namespace ns = Namespace.getNamespace("uri:oozie:hive-action:0.2");
        final String launcherId = submitAction(context, ns);
        waitUntilYarnAppDoneAndAssertSuccess(launcherId);
        Configuration conf = new XConfiguration();
        conf.set("user.name", getTestUser());
        Map<String, String> actionData = LauncherHelper.getActionData(getFileSystem(), context.getActionDir(), conf);
        assertFalse(LauncherHelper.hasIdSwap(actionData));
        HiveActionExecutor ae = new HiveActionExecutor();
        ae.check(context, context.getAction());
        assertTrue(launcherId.equals(context.getAction().getExternalId()));
        assertEquals("SUCCEEDED", context.getAction().getExternalStatus());
        ae.end(context, context.getAction());
        assertEquals(WorkflowAction.Status.OK, context.getAction().getStatus());
        assertNotNull(context.getExternalChildIDs());
        // while this works in a real cluster, it does not with miniMR
        // assertTrue(outputData.getProperty(LauncherMain.HADOOP_JOBS).trim().length() > 0);
        // assertTrue(!actionData.get(LauncherAMUtils.ACTION_DATA_EXTERNAL_CHILD_IDS).isEmpty());
        assertTrue(fs.exists(outputDir));
        assertTrue(fs.isDirectory(outputDir));
    }
    {
        Context context = createContext(getActionQueryXml(hiveScript));
        Namespace ns = Namespace.getNamespace("uri:oozie:hive-action:0.6");
        final String launcherId = submitAction(context, ns);
        waitUntilYarnAppDoneAndAssertSuccess(launcherId);
        Configuration conf = new XConfiguration();
        conf.set("user.name", getTestUser());
        Map<String, String> actionData = LauncherHelper.getActionData(getFileSystem(), context.getActionDir(), conf);
        assertFalse(LauncherHelper.hasIdSwap(actionData));
        HiveActionExecutor ae = new HiveActionExecutor();
        ae.check(context, context.getAction());
        assertTrue(launcherId.equals(context.getAction().getExternalId()));
        assertEquals("SUCCEEDED", context.getAction().getExternalStatus());
        ae.end(context, context.getAction());
        assertEquals(WorkflowAction.Status.OK, context.getAction().getStatus());
        assertNotNull(context.getAction().getExternalChildIDs());
        // while this works in a real cluster, it does not with miniMR
        // assertTrue(outputData.getProperty(LauncherMain.HADOOP_JOBS).trim().length() > 0);
        // assertTrue(!actionData.get(LauncherAMUtils.ACTION_DATA_EXTERNAL_CHILD_IDS).isEmpty());
        assertTrue(fs.exists(outputDir));
        assertTrue(fs.isDirectory(outputDir));
    }
}
Also used : Path(org.apache.hadoop.fs.Path) XConfiguration(org.apache.oozie.util.XConfiguration) XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) FileSystem(org.apache.hadoop.fs.FileSystem) OutputStreamWriter(java.io.OutputStreamWriter) Map(java.util.Map) Writer(java.io.Writer) OutputStreamWriter(java.io.OutputStreamWriter) Namespace(org.jdom.Namespace)

Example 82 with Namespace

use of org.jdom.Namespace in project wildfly-camel by wildfly-extras.

the class WildFlyCamelConfigPlugin method addProperty.

private static void addProperty(Element systemProperties, Map<String, Element> propertiesByName, String name, String value) {
    Namespace namespace = systemProperties.getNamespace();
    if (!propertiesByName.containsKey(name)) {
        systemProperties.addContent(new Text("   "));
        systemProperties.addContent(new Element("property", namespace).setAttribute("name", name).setAttribute("value", value));
        systemProperties.addContent(new Text("\n    "));
    }
}
Also used : Element(org.jdom.Element) Text(org.jdom.Text) Namespace(org.jdom.Namespace)

Example 83 with Namespace

use of org.jdom.Namespace in project vcell by virtualcell.

the class PathwayReader method addObjectPhysicalEntity.

private PhysicalEntity addObjectPhysicalEntity(Element element) {
    PhysicalEntity physicalEntity = new PhysicalEntity();
    Namespace rdf = Namespace.getNamespace("rdf", DefaultNameSpaces.RDF.uri);
    if (element.getAttributes().size() > 0) {
        physicalEntity = new PhysicalEntity();
        addAttributes(physicalEntity, element);
    }
    for (Object child : element.getChildren()) {
        if (child instanceof Element) {
            Element childElement = (Element) child;
            if (!addContentPhysicalEntity(physicalEntity, element, childElement)) {
                showUnexpected(childElement, physicalEntity);
            }
        }
    }
    pathwayModel.add(physicalEntity);
    return physicalEntity;
}
Also used : PhysicalEntity(org.vcell.pathway.PhysicalEntity) Element(org.jdom.Element) BioPaxObject(org.vcell.pathway.BioPaxObject) Namespace(org.jdom.Namespace)

Example 84 with Namespace

use of org.jdom.Namespace in project vcell by virtualcell.

the class PathwayIOUtil method extractPathwayFromJDOM.

public static PathwayModel extractPathwayFromJDOM(Document jdomDocument, RDFXMLContext context, ClientTaskStatusSupport statusSupport) {
    PathwayModel pathwayModel = null;
    Element rootElement = jdomDocument.getRootElement();
    @SuppressWarnings("unchecked") List<Namespace> namespaces = rootElement.getAdditionalNamespaces();
    boolean itIsLevel3 = false;
    for (Namespace namespace : namespaces) {
        if (namespace != null && namespace.getURI() != null && namespace.getURI().equals(BioPAX3.ns.uri)) {
            itIsLevel3 = true;
            break;
        }
    }
    if (itIsLevel3) {
        PathwayReaderBiopax3 pathwayReader = new PathwayReaderBiopax3(context);
        pathwayModel = pathwayReader.parse(rootElement, true);
    } else {
        // if it's not level3 we assume it to be level2
        // TODO: once biopax version3 becomes dominant change the code to use that as the default
        PathwayReader pathwayReader = new PathwayReader(context);
        pathwayModel = pathwayReader.parse(rootElement, statusSupport);
    }
    pathwayModel.reconcileReferences(statusSupport);
    pathwayModel.refreshParentMap();
    return pathwayModel;
}
Also used : Element(org.jdom.Element) PathwayModel(org.vcell.pathway.PathwayModel) Namespace(org.jdom.Namespace)

Example 85 with Namespace

use of org.jdom.Namespace in project vcell by virtualcell.

the class XMLUtils method getXPathFor.

public String getXPathFor(Element el, Document doc) {
    Map<Namespace, String> ns2Prefix = getNamespacesWithPrefixes(doc);
    Stack<Element> elementStack = buildElementStack(el);
    StringBuffer out = new StringBuffer();
    while (!elementStack.isEmpty()) {
        Element el2 = elementStack.pop();
        out.append("/").append(ns2Prefix.get(el2.getNamespace()) + ":" + el2.getName());
        if (elementStack.size() == 0) {
            addIdentifiersToXPath(out, el2, ns2Prefix);
        } else {
            addIdentifiersToXPath(out, el2, ns2Prefix);
        }
    }
    return out.toString();
}
Also used : Element(org.jdom.Element) Namespace(org.jdom.Namespace)

Aggregations

Namespace (org.jdom.Namespace)102 Element (org.jdom.Element)85 IOException (java.io.IOException)24 XConfiguration (org.apache.oozie.util.XConfiguration)19 StringReader (java.io.StringReader)15 Configuration (org.apache.hadoop.conf.Configuration)15 JDOMException (org.jdom.JDOMException)15 ActionExecutorException (org.apache.oozie.action.ActionExecutorException)13 ArrayList (java.util.ArrayList)12 Path (org.apache.hadoop.fs.Path)11 Document (org.jdom.Document)11 List (java.util.List)9 File (java.io.File)7 HashMap (java.util.HashMap)6 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)6 SAXBuilder (org.jdom.input.SAXBuilder)6 XMLOutputter (org.jdom.output.XMLOutputter)6 Writer (java.io.Writer)5 Attribute (org.jdom.Attribute)5 Format (org.jdom.output.Format)5