How to supply hiveconf variable from hive oozie action - oozie

I want to supply variable as hiveconf namespace from my hive-oozie action, how to do that?
<action name="setupAct">
<hive xmlns="uri:oozie:hive-action:0.2">
<job-tracker>maprfs:///</job-tracker>
<name-node>maprfs:///</name-node>
<script>
XYZ.hql
</script>
<!--how to add variable to hiveconf-->
<param>DB_NAME=test</param>
</hive>
<ok to="ok" />
<error to="error" />
</action>
The values inside param element are supplied as --hivevar namespace to hive.
Below is application log, the param element gets added as hivevar:
------------------------
DB_NAME=test
------------------------
Hive command arguments :
--hivevar
DB_NAME=test
-f
test.hql

For hiveconf in Oozie, Use the configuration element.
<hive xmlns="uri:oozie:hive-action:0.2">
<job-tracker>maprfs:///</job-tracker>
<name-node>maprfs:///</name-node>
<script>
XYZ.hql
</script>
<!--how to add variable to hiveconf-->
<configuration>
<property>
<name>hive.default.fileformat</name>
<value>Parquet</value>
</property>
</configuration>
<param>DB_NAME=test</param>
</hive>

Related

loop xml and retrieve node values and construct xml outputusing Xquery

Team, I need your help /expertise to retrieve node value by traversing an xml response. I would like to use this an integration middleware.
Input file sample:
<feed xmlns="http://www.w3.org/2005/Atom"
xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
xml:base="https://api12preview.sapsf.eu:443/odata/v2/">
<title type="text">PerEmail</title>
<id>https://api12preview.sapsf.eu:443/odata/v2/PerEmail</id>
<updated>2022-11-09T13:58:27Z</updated>
<link href="PerEmail" rel="self" title="PerEmail"/>
<entry>
<id>https://api12preview.sapsf.eu:443/odata/v2/PerEmail(emailType='54139',personIdExternal='GI00152188')</id>
<title type="text"/>
<updated>2022-11-09T13:58:27Z</updated>
<author>
<name/>
</author>
<link href="PerEmail(emailType='54139',personIdExternal='GI00152188')"
rel="edit"
title="PerEmail"/>
<category scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"
term="SFOData.PerEmail"/>
<content type="application/xml">
< properties>
<d:personIdExternal>GI00152188</d:personIdExternal>
<d:emailAddress>someone#test_boehringer.com</d:emailAddress>
</m:properties>
</content>
</entry>
<entry>
<id>https://api12preview.sapsf.eu:443/odata/v2/PerEmail(emailType='54139',personIdExternal='GI00453224')</id>
<title type="text"/>
<updated>2022-11-09T13:58:27Z</updated>
<author>
<name/>
</author>
<link href="PerEmail(emailType='54139',personIdExternal='GI00453224')"
rel="edit"
title="PerEmail"/>
<category scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"
term="SFOData.PerEmail"/>
<content type="application/xml">
<m:properties>
<d:personIdExternal>GI00453224</d:personIdExternal>
<d:emailAddress>someone#test_boehringer.com</d:emailAddress>
</m:properties>
</content>
</entry>
<link href="https://api12preview.sapsf.eu:443/odata/v2/PerEmail?$select=emailAddress,personIdExternal&$filter=emailType%20eq%2054139&$skiptoken=eyJzdGFydFJvdyI6MTAwMCwiZW5kUm93IjoyMDAwfQ=="
rel="next"/>
</feed>
Out of this response or xml Xquery should run through all 'entry' node and pick values of node 'personIdExternal' and I'm expecting result like this
<element>
<personIdExternal>GI00152188</personIdExternal>
<personIdExternal>GI00453224</personIdExternal>
</element>
I have tried something below code earlier but it's not working here, and I suspect this is due to namespace in the source xml. My knowledge is limited in XQuery - Please help
{let $input:= /entry
for $i in $input/properties
return
<element>
<personIdExternal>{i/personIdExternal/text()}</personIdExternal>
</element>}
/entry doesn't select anything because the entry elements aren't at the top level, and they're in a namespace.
$input/properties is wrong because the properties element isn't a child of entry and it's in a namespace.
i doesn't select anything, it should be $i
personIdExternal doesn't select anything because it's in a namespace.
You just need
<element>{//*:personIdExternal}</element>

Symfony2 - "Invalid Resource Exception" when translating twig template

I am trying to translate labels in my twig template located in Resources/views/User/ folder:
<label for="username">{% trans %}Username{% endtrans %} </label>
And the following is a section from my login.ka.xliff file located in my project under "translations" folder:
<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" datatype="plaintext" original="file.ext">
<body>
<trans-unit id="1">
<source>Username</source>
<target>მომხმარებელი</target>
</trans-unit>
</body>
</file>
</xliff>
and this is my route to the login page:
login:
path: /login/{_locale}
defaults: { _controller: ExampleBundle:LogIn:login }
requirements:
_locale: en|ka
I have two problems:
When I try to open the login page with a locale (say, ka) I get the:
500 Internal Server Error - Twig_Error_Runtime
1 linked Exception:
InvalidResourceException »
I know I can get the locale from request using $request->getLocale(); but how do I specify that login page should use login.ka.xliff file for translations?
Ok, I seem to have provided not enough info, so here it is:
I put my translation file in Example:MyBundle:Resources:translations (this is what I meant above "in my project").
I get exception when rending my login view and the following is the full version of the exception I get:
"An exception has been thrown during the rendering of a template ("") in ExampleMyBundle:User:login.html.twig at line 32.
500 Internal Server Error - Twig_Error_Runtime
1 linked Exception:
InvalidResourceException »"
And yes, I did try clearing cache each time I made changes, but it didn't help.
And also, I added the complete version of my login.ka.xliff file.
Thanks again!
Your xliff file seems to be invalid - it should look like this: ( containing the xml-namespace, body, ... ).
<!-- messages.ka.xliff -->
<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" datatype="plaintext" original="file.ext">
<body>
<trans-unit id="1">
<source>Username</source>
<target>მომხმარებელი</target>
</trans-unit>
</body>
</file>
</xliff>
The file should be named messages.ka.xliff if you haven't actually specified a different translation domain in your template!
{{ 'Username'|trans({}, "login") }}
... or configured a different default translation-domain in your template ...
{% trans_default_domain "login" %}
<trans-unit id="1">
<source>Username</source>
<target>მომხმარებელი</target>
</trans-unit>
... is an invalid xliff-file.

XSLT to format Wordpress WXR XML for importing in to Drupal via Feeds

I'm trying to format a Wordpress WXR file using XSLT so I can import it into Drupal.
I'm aware of modules for Drupal that will import WXR files but I need the flexibility that the Feeds module can give as the imported data will be imported against different content types and I'll be pulling images and other attachments into the newly created Drupal pages. With this in mind the standard WordPress Migrate just won't cut it.
So, the WXR format has Wordpress posts and attachments as separate items within the feed and links the posts an attachments using an id. Attachments can be images, files (pdf,doc etc) and are found at the xpath wp:postmeta/wp:meta_key and have values of _thumbnail_id, _wp_attached_file
What I'd like to do is take various nodes from items of type attachment and put them within the cooresponding post item, where the id links them together
A fragment of the xml to be transformed... First item is post second is attachment. The
<item>
<title>Some groovy title</title>
<link>http://example.com/groovy-example</link>
<wp:post_id>2050</wp:post_id>
<wp:post_type>page</wp:post_type>
...
...
...
<wp:postmeta>
<wp:meta_key>_thumbnail_id</wp:meta_key>
<wp:meta_value>566</wp:meta_value>
</wp:postmeta>
</item>
...
...
...
<item>
<title>My fantastic attachment</title>
<link>http://www.example.com/fantastic-attachment</link>
<wp:post_id>566</wp:post_id>
<wp:post_type>attachment</wp:post_type>
...
...
...
<wp:attachment_url>http://www.example.com/wp-content/uploads/2012/12/fantastic.jpg</wp:attachment_url>
<wp:postmeta>
<wp:meta_key>_wp_attached_file</wp:meta_key>
<wp:meta_value>2012/12/fantastic.jpg</wp:meta_value>
</wp:postmeta>
</item>
After the transform I would like
<item>
<title>Some groovy title</title>
<link>http://example.com/groovy-example</link>
<wp:post_id>2050</wp:post_id>
<wp:post_type>page</wp:post_type>
...
...
...
<wp:postmeta>
<wp:meta_key>_thumbnail_id</wp:meta_key>
<wp:meta_value>566</wp:meta_value>
<wp:meta_url>http://www.example.com/wp-content/uploads/2012/12/fantastic.jpg</wp:attachment_url>
</wp:postmeta>
</item>
Maybe, there is a better approach? Maybe merge post and attachment where the id create a link between the nodes?
I'm new to XSLT and have read a few posts on identity transforms and I think thats the correct direction but I just don't have the experience to pull of what i need, assistance would be appreciated.
It looks like I've managed to sort out a solution.
I used a number of indexes to organise the attachments. My requirements changed a little on further inspection of the XML, as there was
I changed my resulting output to be in the format of...
<item>
<title>Some groovy title</title>
<link>http://example.com/groovy-example</link>
<wp:post_id>2050</wp:post_id>
<wp:post_type>page</wp:post_type>
...
...
...
<thumbnail>
<title>Spaner</title>
<url>http://www.example.com/wp-content/uploads/2012/03/spanner.jpg</url>
</thumbnail>
<attachments>
<attachment>
<title>Fixing your widgets: An idiots guide</title>
<url>http://www.example.com/wp-content/uploads/2012/12/fixiing-widgets.pdf</url>
</attachment>
<attachment>
<title>Do It Yourself Trepanning</title>
<url>http://www.example.com/wp-content/uploads/2013/04/trepanning.pdf</url>
</attachment>
</attachments>
</item>
So using the following xsl gave me the desired result. The conditions on the indexes ensured I was selecting the correct files.
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:wp="http://wordpress.org/export/1.2/">
<xsl:output indent="yes" cdata-section-elements="content"/>
<!-- Setup indexes -->
<!-- Index all main posts -->
<xsl:key
name="mainposts"
match="*/item[wp:post_type[text()='post']]"
use="wp:post_id" />
<!-- Index all sub posts (posts within posts)-->
<xsl:key
name="subposts"
match="*/item[wp:post_type[text()='post'] and category[#nicename = 'documents']]"
use="category[#domain = 'post_tag']" />
<!-- Index all image thumbs -->
<xsl:key
name="images"
match="*/item[wp:post_type[text()='attachment'] and wp:postmeta/wp:meta_key[text()='_wp_attachment_metadata']]"
use="wp:post_parent" />
<!-- Index all files (unable to sort members file at the moment)-->
<xsl:key
name="attachments"
match="*/item[wp:post_type[text()='attachment'] and not(wp:postmeta/wp:meta_key = '_wp_attachment_metadata')]"
use="wp:post_parent" />
<xsl:key
name="thumbnails"
match="*/item[wp:post_type[text()='attachment']]"
use="wp:post_id" />
<xsl:template match="node()|#*">
<xsl:copy>
<xsl:apply-templates select="node()|#*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="*/item/wp:post_parent[text()= 0]">
<wp:post_parent>
<xsl:value-of select="." />
</wp:post_parent>
<xsl:for-each select="key('thumbnails', ../wp:postmeta[wp:meta_key[text()='_thumbnail_id']]/wp:meta_value)">
<thumbnail>
<title><xsl:value-of select="title" /></title>
<url><xsl:value-of select="wp:attachment_url" /></url>
</thumbnail>
</xsl:for-each>
<xsl:for-each select="key('subposts', ../category[#domain = 'post_tag'])">
<attachments>
<xsl:for-each select="key('images', wp:post_id)">
<file>
<title><xsl:value-of select="title" /></title>
<url><xsl:value-of select="wp:attachment_url" /></url>
</file>
</xsl:for-each>
<xsl:for-each select="key('attachments', wp:post_id)">
<file>
<title><xsl:value-of select="title" /></title>
<url><xsl:value-of select="wp:attachment_url" /></url>
</file>
</xsl:for-each>
</attachments>
</xsl:for-each>
</xsl:template>

Spring MVC Static Resources partially work

I have a basic directory app that works fine except that it seems to only sometimes find the static resources that I’ve configured using the mvc:resources tag. My search of the board found problems related to handler mappings, but my problem seems to be different.
Specifically, when the PersonController is called via a method mapping to “/person”, it returns personlist.jsp using the view resolver and correctly finds and uses the static css and js files. No problems.
When the same controller is called via another method mapping to “/person/{familyid}” ( narrows the person list to a particular family), it returns the same personlist.jsp…but now it fails to find or use the css and js files (though it does display the correct data).
I don’t understand why there is a behavior difference since both scenarios use the same Controller, the same return String (return “personlist”), and resolve to the same JSP (ie. with the same Head section links for the css, js).
I looked at what came back in the browser for each case using ‘view source’, and both pages return the same head tag rendering for the css and js linking:
<link href="resources/css/directory.css" rel="stylesheet" type="text/css"></link>
<script type="text/javascript" src="resources/scripts/jquery-1.7.min.js"></script>
<script type="text/javascript" src="resources/scripts/directory.js"></script>
I thought the problem could be with my tag mapping, so I also tried this:
<resources mapping="**/resources/**" and
resources mapping="resources/**"
but no help.
Am I approaching the use of static resources properly here (and what is the right resources tag mapping if that’s the problem)? Thanks.
I am using Spring 3.0.6 and my css and js files are located under /WebContent/resources/css and /WebContent/resources/scripts respectively, which are mapped using the mvc:resource tag (see below).
PersonController:
#Controller
public class PersonController {
private static final Logger logger = LoggerFactory.getLogger(HomeController.class);
/**
* Simply selects the home view to render by returning its name.
*/
List<Person> personList;
Boolean familyCalled = false;
#Autowired
PersonService personService;
#RequestMapping(value="/people", method=RequestMethod.GET)
public String people(Model model) {
logger.debug("Received request to show peoplelist page");
System.out.println("Running inside people() method of PersonController");
personList = personService.getPersons();
familyCalled = false;
model.addAttribute("personList", personList);
return "personlist";
}
#RequestMapping(value="/people/{familyId}", method=RequestMethod.GET)
public String familyMembers(#PathVariable("familyId") String fid, Model model) {
System.out.println("Running inside familyMembers() method of PersonController");
personList = personService.getPersonsInFamily(fid);
familyCalled = true;
model.addAttribute("personList", personList);
return "personlist";
}
Servlet-Context.xml (without namespaces):
<!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->
<!-- for transactions -->
<tx:annotation-driven/>
<!-- Needed for #PreAuthorize security on methods -->
<aop:aspectj-autoproxy/>
<context:annotation-config />
<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
<resources mapping="/resources/**" location="resources/" />
<!-- Enables the Spring MVC #Controller programming model -->
<annotation-driven/>
<!-- Resolves views selected for rendering by #Controllers to .jsp resources in the /WEB-INF/views directory -->
<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>
<context:component-scan base-package="com.c3works.preps" />
</beans:beans>
personlist.jsp (Head section):
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</meta>
<title>XXXXXXXXXXXXXXXXXXX</title>
<link href="resources/css/directory.css" rel="stylesheet" type="text/css">
</link>
<script type="text/javascript" src="resources/scripts/jquery-1.7.min.js">
</script>
<script type="text/javascript" src="resources/scripts/directory.js">
</script>
</head>
Your URLs are relative and therefore the browser is looking for the resources in the wrong place. (Check the resulting HTML code)
One solution is to use the <spring:url> tag to build the urls of the resources.
<spring:url var="banner" value="/resources/images/banner-graphic.png" />
<img src="${banner}" />

spring bean - inject Context Base URL in property

On Spring 3, I got a bean in my applicationContext.xml with this definition :
<bean id="serviceProperties" class="org.springframework.security.cas.ServiceProperties">
<property name="service" value="http://www.mysite.com/my_webapp/j_spring_cas_security_check"/>
<property name="sendRenew" value="false"/>
</bean>
Instead of
"value="http://www.mysite.com/my_webapp/j_spring_cas_security_check"
Is there a way to directly and dynamically inject the "base URL" of my tomcat server + j_spring_cas_security_check
( like we can do in a jsp to set :
<base href="<%=request.getScheme() + "://" + request.getServerName()+ ":" + request.getServerPort() + request.getContextPath()+ "/"%>" />
)
Try this:
<%# taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<spring:url value="/j_spring_cas_security_check" var="baseUrl" />
<base href="${baseUrl}" />
spring:url evaluates the URL "/j_spring_cas_security_check" relative to your application path and stores it in baseUrl variable. After this, you can replace ${baseUrl} in your JSP.
It's recommended not to use base tag. Instead, you should have relative paths but this is up to you.
Hope it helps.

Resources