Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
alex2020
Contributor
Contributor

Modify LogRow data with tJavaRow

Hi everyone,

 

I did a job where it :

* Extracts an email from a IMAP server using tPOP

* Iterates and reads the email using tFileList and tFileInputMail

* Prints the results of the params of the tFileInputMail component with tLogRow

Creates an XML with the params of the tFileInputMail output.

 

I got the next model:

0683p000009M82Y.png

 

Everything is working fine (There's no code at tJavaRow yet ). But as almost of the software projects, the requirements have changed.

 

Now, I need to create an XML based on my extracted email. I need extract the a regex for Content/body tag of the MailPart of the tFileInputMail component.

 

The Mail part required:

0683p000009M7nN.png

 

The regex required (in Java code):

"(\\#Location.*?\\;)|(\\#City.*?\\;)"

I'm using a tJavaRow component in order to modify the content of the tag as follow: 

 

0683p000009M8Fq.png

 

code:

//Code generated according to input schema and output schema
output_row.Content = input_row.Content;


String data =  String.valueOf(output_row.Content);

if (data!= null) {
	Pattern pattern = Pattern.compile("(\\#Location.*?\\;)|(\\#Area.*?\\;)");
	Matcher matcher = pattern.matcher(data);
	
	while(matcher.find()) {
	    	 int i =0;
	    	 //System.out.println(matcher.group(i)+"\n");
			 row3.Content.replaceAll("(\\#Location.*?\\;)|(\\#Area.*?\\;)", matcher.group(i));

	    	 i++;
	    	 
	}
}

But is not possible to change the Content attribute of the row3. At row3, I can see the String that I want to replace for the result of the regex (regex is working fine) but no modify or replace it. 

 

How can I change this data? Is it possible? 

 

Thanks and regards!

 

P.S.: Additional information: 

1. The email original content/body (row3.Content original content that I can see)

 

<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">

<meta name="Generator" content="Microsoft Word 15 (filtered medium)">

<style><!--

/* Font Definitions */

@font-face

	{font-family:"Cambria Math";

	panose-1:2 4 5 3 5 4 6 3 2 4;}

@font-face

	{font-family:Calibri;

	panose-1:2 15 5 2 2 2 4 3 2 4;}

/* Style Definitions */

p.MsoNormal, li.MsoNormal, div.MsoNormal

	{margin:0cm;

	margin-bottom:.0001pt;

	font-size:11.0pt;

	font-family:"Calibri",sans-serif;

	mso-fareast-language:EN-US;}

a:link, span.MsoHyperlink

	{mso-style-priority:99;

	color:#0563C1;

	text-decoration:underline;}

a:visited, span.MsoHyperlinkFollowed

	{mso-style-priority:99;

	color:#954F72;

	text-decoration:underline;}

span.EstiloCorreo17

	{mso-style-type:personal-compose;

	font-family:"Calibri",sans-serif;

	color:windowtext;}

.MsoChpDefault

	{mso-style-type:export-only;

	font-family:"Calibri",sans-serif;

	mso-fareast-language:EN-US;}

@page WordSection1

	{size:612.0pt 792.0pt;

	margin:70.85pt 3.0cm 70.85pt 3.0cm;}

div.WordSection1

	{page:WordSection1;}

--></style><!--[if gte mso 9]><xml>

<o:shapedefaults v:ext="edit" spidmax="1026" />

</xml><![endif]--><!--[if gte mso 9]><xml>

<o:shapelayout v:ext="edit">

<o:idmap v:ext="edit" data="1" />

</o:shapelayout></xml><![endif]-->

</head>

<body lang="ES" link="#0563C1" vlink="#954F72">

<div class="WordSection1">

<p class="MsoNormal" style="margin:11.25pt;text-align:justify">Test<o:p></o:p></p>

<p class="MsoNormal" style="margin:11.25pt;text-align:justify">#Area:AreaTest:;<o:p></o:p></p>

<p class="MsoNormal" style="margin:11.25pt;text-align:justify"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal" style="margin:11.25pt;text-align:justify">Other testing mesagges<span style="font-size:13.5pt;font-family:&quot;Times New Roman&quot;,serif;color:black;letter-spacing:.75pt;mso-fareast-language:ES"><o:p></o:p></span></p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

</div>

</body>

</html>

2. I just want in row3.Content the next result of the application of the regex rules.

 

#Area:AreaTest:;

 

Labels (4)
1 Solution

Accepted Solutions
alex2020
Contributor
Contributor
Author

I found the answer.

 

First

It's necessary import all of input schema and output schema

0683p000009M8PL.png

 

Second

Assign directly the value of the row through a StringBuilder object.

0683p000009M7rD.png

Finally

And I got my XML file according to the modifed routine. 

 

Cheers!

View solution in original post

1 Reply
alex2020
Contributor
Contributor
Author

I found the answer.

 

First

It's necessary import all of input schema and output schema

0683p000009M8PL.png

 

Second

Assign directly the value of the row through a StringBuilder object.

0683p000009M7rD.png

Finally

And I got my XML file according to the modifed routine. 

 

Cheers!