Search in sources :

Example 46 with Namespace

use of com.google.cloud.servicedirectory.v1.Namespace in project mycore by MyCoRe-Org.

the class MCRNodeBuilder method buildNameStep.

@SuppressWarnings("unchecked")
private Object buildNameStep(NameStep nameStep, String value, Parent parent) throws JaxenException {
    String name = nameStep.getLocalName();
    String prefix = nameStep.getPrefix();
    Namespace ns = prefix.isEmpty() ? Namespace.NO_NAMESPACE : MCRConstants.getStandardNamespace(prefix);
    if (nameStep.getAxis() == Axis.CHILD) {
        if (parent instanceof Document) {
            return buildPredicates(nameStep.getPredicates(), ((Document) parent).getRootElement());
        } else {
            return buildPredicates(nameStep.getPredicates(), buildElement(ns, name, value, (Element) parent));
        }
    } else if (nameStep.getAxis() == Axis.ATTRIBUTE) {
        return buildAttribute(ns, name, value, (Element) parent);
    } else {
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("ignoring axis, can not be built: {} {}{}", nameStep.getAxis(), prefix.isEmpty() ? "" : prefix + ":", name);
        }
        return null;
    }
}
Also used : Element(org.jdom2.Element) Document(org.jdom2.Document) Namespace(org.jdom2.Namespace)

Example 47 with Namespace

use of com.google.cloud.servicedirectory.v1.Namespace in project mycore by MyCoRe-Org.

the class MCRORCIDConstants method buildNamespace.

private static Namespace buildNamespace(String prefix) {
    Namespace namespace = Namespace.getNamespace(prefix, "http://www.orcid.org/ns/" + prefix);
    NAMESPACES.add(namespace);
    return namespace;
}
Also used : Namespace(org.jdom2.Namespace)

Example 48 with Namespace

use of com.google.cloud.servicedirectory.v1.Namespace in project oozie by apache.

the class TestLiteWorkflowAppParser method extractConfig.

private XConfiguration extractConfig(LiteWorkflowApp app, String actionNode) throws Exception {
    String confXML = app.getNode(actionNode).getConf();
    Element confElement = XmlUtils.parseXml(confXML);
    Namespace ns = confElement.getNamespace();
    String configSection = XmlUtils.prettyPrint(confElement.getChild("configuration", ns)).toString();
    XConfiguration xconf = new XConfiguration(new StringReader(configSection));
    return xconf;
}
Also used : XConfiguration(org.apache.oozie.util.XConfiguration) Element(org.jdom2.Element) StringReader(java.io.StringReader) Namespace(org.jdom2.Namespace)

Example 49 with Namespace

use of com.google.cloud.servicedirectory.v1.Namespace in project oozie by apache.

the class TestHiveActionExecutor method testActionConfLoadDefaultResources.

public void testActionConfLoadDefaultResources() throws Exception {
    ConfigurationService.setBoolean("oozie.service.HadoopAccessorService.action.configurations.load.default.resources", false);
    Path inputDir = new Path(getFsTestCaseDir(), INPUT_DIRNAME);
    Path outputDir = new Path(getFsTestCaseDir(), OUTPUT_DIRNAME);
    FileSystem fs = getFileSystem();
    Path script = new Path(getAppPath(), HIVE_SCRIPT_FILENAME);
    Writer scriptWriter = new OutputStreamWriter(fs.create(script), StandardCharsets.UTF_8);
    scriptWriter.write(getHiveScript(inputDir.toString(), outputDir.toString()));
    scriptWriter.close();
    Writer dataWriter = new OutputStreamWriter(fs.create(new Path(inputDir, DATA_FILENAME)), StandardCharsets.UTF_8);
    dataWriter.write(SAMPLE_DATA_TEXT);
    dataWriter.close();
    Context context = createContext(getActionScriptXml());
    Namespace ns = Namespace.getNamespace("uri:oozie:hive-action:0.2");
    submitAction(context, ns);
    FSDataInputStream os = fs.open(new Path(context.getActionDir(), LauncherAMUtils.ACTION_CONF_XML));
    XConfiguration conf = new XConfiguration();
    conf.addResource(os);
    assertNull(conf.get("oozie.HadoopAccessorService.created"));
}
Also used : Path(org.apache.hadoop.fs.Path) XConfiguration(org.apache.oozie.util.XConfiguration) FileSystem(org.apache.hadoop.fs.FileSystem) FSDataInputStream(org.apache.hadoop.fs.FSDataInputStream) OutputStreamWriter(java.io.OutputStreamWriter) Writer(java.io.Writer) OutputStreamWriter(java.io.OutputStreamWriter) Namespace(org.jdom2.Namespace)

Example 50 with Namespace

use of com.google.cloud.servicedirectory.v1.Namespace in project qpp-conversion-tool by CMSgov.

the class AggregateCountDecoderTest method testInternalDecode.

@Test
void testInternalDecode() {
    Namespace rootNs = Namespace.getNamespace("urn:hl7-org:v3");
    Namespace ns = Namespace.getNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
    Context context = new Context();
    Element element = new Element("observation", rootNs);
    element.addContent(new Element("templateId", rootNs).setAttribute("root", TemplateId.PI_AGGREGATE_COUNT.getTemplateId(context)));
    element.addContent(new Element("value", rootNs).setAttribute("value", "450").setAttribute("type", "INT", ns));
    element.addNamespaceDeclaration(ns);
    Node thisNode = new Node();
    AggregateCountDecoder instance = new AggregateCountDecoder(context);
    instance.setNamespace(element.getNamespace());
    instance.decode(element, thisNode);
    assertThat(thisNode.getValue("aggregateCount")).isEqualTo("450");
}
Also used : Context(gov.cms.qpp.conversion.Context) Element(org.jdom2.Element) Node(gov.cms.qpp.conversion.model.Node) Namespace(org.jdom2.Namespace) Test(org.junit.jupiter.api.Test)

Aggregations

Namespace (org.jdom2.Namespace)176 Element (org.jdom2.Element)145 IOException (java.io.IOException)45 Document (org.jdom2.Document)36 ArrayList (java.util.ArrayList)30 Attribute (org.jdom2.Attribute)25 HashMap (java.util.HashMap)23 List (java.util.List)21 XConfiguration (org.apache.oozie.util.XConfiguration)19 StringReader (java.io.StringReader)18 JDOMException (org.jdom2.JDOMException)18 Configuration (org.apache.hadoop.conf.Configuration)15 SAXBuilder (org.jdom2.input.SAXBuilder)15 Map (java.util.Map)14 ActionExecutorException (org.apache.oozie.action.ActionExecutorException)14 Namespace.getNamespace (org.jdom2.Namespace.getNamespace)14 MigrationReport (com.mulesoft.tools.migration.step.category.MigrationReport)13 File (java.io.File)13 Path (org.apache.hadoop.fs.Path)12 Path (java.nio.file.Path)11