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));
}
}
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 "));
}
}
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;
}
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;
}
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();
}
Aggregations