How to import and use StringUtils in tMap using Talend 3.6 - talend

I understand the library http://commons.apache.org/proper/commons-lang/javadocs/api-3.4/index.html provides a number of string functions including StringUtils.capitalize
In Talend OpenStudio 6.3 I have added the tLibraryLoad and in basic settings selected commons-lang3-3.4.jar In advanced settings I have import org.apache.commons.lang3.StringUtils.*;
in my tMap I have StringUtils.Capitalize(row20.Forename) assigned to a variable but I get the error The method Capitalize(String) is undefined for the type StringUtils
On TalendExchange there is a StringUtils available but its only for 6.2 and lower.
Whats the best and most reliable way to get access to additional string handling tools like Capitalize which converts a string like MONKEY to Monkey

It seems that talend uses its own StringUtils library (routines.system), then when specifying "StringUtils", Talend does not recognize your importn and still uses its own class.
In tMap, try org.apache.commons.lang3.StringUtils.capitalize(row20.Forename) instead

You almost got the correct set-up in your tLibraryload but you may try to configure it as illustrated below:
tLibraryload set-up
Tmap
Result

I think you should try StringUtils.Capitalize(row20.Forename)

You can use StringHandling.UPCASE(row20.Forename) to convert to uppercase.
In tMap, click on "..." just where you place the expression to fill the output fields. It oppens the expression builder. Search for "StringHandling" in the categories column, then click on UPCASE and complete the expression proposed as an example by TOS.

Related

Most efficient way to change the value of a specific tag in a DICOM file using GDCM

I have a need to go through a set of DICOM files and modify certain tags to be current with the data maintained in the database of an external system. I am looking to use GDCM. I am new to GDCM. A search through stack overflow posts demonstrates that the anonymizer class can be used to change tag values.
Generating a simple CT DICOM image using GDCM
My question is if this is the best use of the GDCM API or if there is a better approach for changing the values of individual tags such as patient name or accession number. I am unfamiliar with all of the API options but have a link to the API documentation. It looks like the DataElement SetValue member could be used, but it doesn't appear that there is a valid constructor for doing this in the Value class. Any assistance would appreciated. This is my current approach:
Anonymizer anon = new Anonymizer();
anon.SetFile(myFile);
anon.Replace(new Tag(0x0010, 0x0010), "BUGS^BUNNY");
Quite late, but maybe it would be still useful. You have not mention if you write in C++ or C#, but I assume the latter, as you do not use pointers. Generally, your approach is correct (unless you use System.IO.File instead of gdcm.File). The value (second parameter of Replace function) has to be a plain string so no special constructor is needed. You should probably start with doxygen documentation of gdcm, and there is especially one complete example. It is in C++, but there should be no problems with translation.
There are two different ways to pad dicom tags:
Anonymizer
gdcm::Anonymizer anon;
anon.SetFile(file);
anon.Replace(gdcm::Tag(0x0002, 0x0013), "Implementation Version Name");
//Implementation Version Name
DatsElement
gdcm::Attribute<0x0018, 0x0088> ss;
ss.SetValue(10.0);
ds.Insert(ss.GetAsDataElement());

How to extend IErrorParser in eclipse to define own syntax checking?

My intention is to have own naming rules in eclipse editor for C programming
Ex: a function should start with File name, it shall contain maximum of 20 character- FILENAME_MaxOf20Char().
When it is violated has to show an warning.
To do this tried to extend org.eclipse.cdt.core.IErrorParser. But this one is parsing from compilor output.
IErrorParser is not the right extension point to use for this.
You want to use the Code Analysis (CodAn) framework and write a custom checker. See this page for documentation.

what is the best way to specify default value for a date parameter in ireport

I have created a parameter in iReport Value_DT with Date data type.
If I'm using expression "new java.util.Date("01-SEP-14") as default value it works fine but this is hard code.
I'd like to use user defined function from Oracle DB, i.e. it might be similar to "new java.util.Date(new java.util.Date($F{GETACCOUNTINGDATE})) where GETACCOUNTINGDATE is oracle function.
With such syntax I have an error "The constructor Date(Timestamp) is undefined".
What should be changed in order to use function from DB in default parameter?
I'm not sure of any way to do this directly in the default value expression without writing custom code. I believe you would need to write a custom class with a static method which connects to your database, calls GETACCOUNTINGDATE, and returns the date. You could then, bundle this as a JAR, put it in your classpath and call this method in your Default Value Expression.
That's quite a bit of work though, so alternatively you may be able to 'recreate' the date using Java Date Function libraries.
We've used apache dateUtils:
org.apache.commons.lang.time.DateUtils.addMonths(new Date(),0))
I know a colleague has used jchronic to use strings and create dates.

i18n in Symfony Forms

Is there any way I can use the format_number_choice function inside of a actions file. In fact I need to use it for a Form error message.
'max_size' => 'File is too large (maximum is %max_size% bytes).',
In English it's simply "bytes", but in other languages the syntax changes after a certain value (for example if the number is greater than 20 it's: "20 of bytes").
I can use parenthesis, of course, but if the framework offers support for doing this specific thing, why not to use it?!
The way it's currently implemented in the 1.4 branch, you can define only one translation per message using il18n XML files.
What you could do is create a custom validator which inherits the current validator (sfValidatorFile in your example) and does the size checking in the doClean method before calling its parent's method.
I suggest you take a look at the source to see how it works : sfValidatorFile
The correct way to handle number ranges for translation is explained here in the Definitive Guide. I won't reproduce it here as the documentation itself is clear and concise. Note however that the string is not extracted automatically by the i18n-extract task, so you need to add it manually - again, the documentation explains this.
So yes, you can use the format_number_choice() function inside an action - you just need to load the helper inside the action like this:
sfContext::getInstance()->getConfiguration()->loadHelpers('I18N');

Generate all setXXX calls of a POJO in Eclipse?

Im currently doing a lot of testing with JPA entities, where i have to keep calling the setter methods on the entity that looks something like this :
myEntity.setXXX(value);
myEntity.setYYY(value);
myEntity.setZZZ(value);
Is there any magic shortcut or menu in eclipse IDE to generate all the setter-method-calls that starts with "set", like those displayed in the ctrl-space (auto completion) popup (i think the inherited methods from Object are not being shown at popup) ?
So im imagining something like :
i type myEntity.set
and myEntity.set* are generated right away
Im a lazy programmer and currently using Eclipse Helios IDE.
Thank you !
Edit
Im not looking for source -> generate getter and setter, because that would helps me in generating the methods itself. Generating the method calls is what i want to achieve.
I have found the answer (I was always searching for this thing)...
The easiest way is to expand the class members in the "Package Explorer", sort them by name, multi-select all the setters, and then you have in the clipboard all the method names...
;-)
I like #Oscar's answer. It does lead to some cleanup though.
When I paste from the clipboard, I get something that looks like this:
setOne(int)
setTwo(String)
In order to clean this up, I first add semicolons with this search/replace regexp:
search = (.)$
replace = \1;
Then I add the getter calls (assuming incoming data object is named "data"):
search = s(et.*)\(.*
replace = s\1(data.g\1());
This doesn't handle multiple arguments in a method call...
you can use the outline at right side. There you can sort alphabetically or by declaration order using the toolbar button of the view.
and then you can filter out non required this.
From here also you can copy..all setter functions or getters functions names...
There is eclipse plugin to do that. The name of the plugin is **
FastCode
**. There are so many templates. Among those there is template to generate code for create object of the class and all setters method.
Source --> Generate Getters and Setters...
You can also get at it via the Quick Fix command (Ctrl+1) when the cursor is on a property.
EDIT
If you are simply looking for a faster way to copy properties from one object to another I suggest that you look at using reflection. I think this path would be much easier long term then generating the same-looking code over-and-over.
Commons BeanUtils can take away some of the pain in writing pure reflection code. For example, copyProperties takes a destination bean and either another bean or a Map as the source.