Oozie: pass parameter via separate file - loops

I'm experimenting with the loop 'hack' to iterate the same workflow over a list of of values and I am trying to load that list at run-time.
The list contains a number of files that I would like to process and so this list will change every time.
In the example the value is passed via the job.properties file and I can also pass it in the workflow itself as a key/value pair but than the values are hard-coded in my workflow and I would like to prevent that (as the list will change every time).
I found a similar question:
OOZIE: properties defined in file referenced in global job-xml not visible in workflow.xml
and the answer there explains also my initial mistakes (parameters vs properties) where I tried to pass it via a global job.xml file (which is only for properties and not for parameters) but a good solution is not provided.
One solution would be to read the parameter from a file via a shell action and capturing the output but I think there could be a more elegant way of reading this parameter in my workflow?

Related

How to read text from file into an array in ruby

Is there a way to treat the HOST, USER, PASS varibales in the net - ssh gem as an array and have multiple values for them?
I currently have an outside text file with the HOST, USER AND PASS values, but i need to pass these into the aforementioned variables within the net - ssh gem.
Any help and edits to clarify the question are appreciated!
:)
You should be able to do this using the splat operator. Have a read around on this, but Google quickly returns this intro. Using this, you can pass an array of arguments to a method as you describe. Something like:
some_values = ['host_name', 'user_name', 'password']
some_method(*some_values)
If you could update your question to include some example input, what you've tried so far, and the desired result, that'd be really handy to go into greater detail.
I'm not sure if your problem occurs before that, in reading the file / values. If so, show me the file format and I'll have a think - you'll likely need to use something like File.read('your_file.txt').
Otherwise, have a think on storing the values in a YAML file, a common pattern for storing sensitive variables outside of a rail app. With this, you can load the file and access the data as in a hash, and pass across as your arguments.
That help? Hope so - if not, add a little more detail to the question and I'll update to reflect this.

DTM - multiple values to single eVar in single call

I have a set of eVars defined in DTM(dynamic tag manager). I would be setting those values in a custom event in my code. There will be multiple instances where I would be setting this values. I can trigger multiple s.tl() calls and set those values. But I want to reduce the number of s.tl() calls. Is there any way to make one s.tl() call and set multiple values to the same eVars?
Your options for sending multiple values to the same variable on the same hit are:
Use a list variable
Since you wanted to use an eVar, the closest to what you want to do is probably a list variable. It is mostly like an eVar, but not as flexible. Also, you only get 3 of them per report suite, so you should try to see if the other options will work for you first, unless this is a super important KPI and the other options just won't work for you (from a reporting PoV).
Example:
s.list1='foo1,foo2,foo3';
Use a merchandising eVar (product syntax)
This method uses a regular eVar but you configure it as a product syntax merchandising eVar (configuration done within the Adobe Analytics Admin interface).
Example:
s.products=";;;;;eVar1=foo1,;;;;;eVar1=foo2,;;;;;eVar1=foo3";
Note: You may optionally want to specify a category and/or product depending on what you are ultimately trying to do (especially if your site has ecommerce tracking; it helps filter this out of actual products)
Use a list prop
You can configure any (or all!) of the 75 available props in the interface to be a list prop. The main downsides to a list prop is the 100 char limit for the prop (which may be too short, given you have multiple values), and that it is a traffic variable (only hit scope). But.. depending on what you are actually trying to record and report on, a list prop may be all you need.
Example:
s.prop1='foo1,foo2,foo3';

Ranorex winforms localization issues

I'm trying to write a common test module for a localized application.
The first issue I'm having is the fact that MenuItems do not support controlname attributes. Currently my menu items are located via text or accessiblename attribute. Is there a way to support controlname attribute?
I've tried to make text and accessiblename attribute point to a variable and then bind the variable to some external dictionary. As I understand the external data sources are treated as rows which contain various data items for a single variable. I don't see a way to use external data sources that treat first column as variable name and second column as variable value. Is there a way to achieve such functionality?
I've thought about a way to extend RanorexXPath to accept functions. Then I could write something like ...menuitem[text=localizationService.Translate("#ADMINISTRATION") and have Ranorex find the menu item based on the result of localizationService.Translate function. Is there a way to do this?
Finally I've somewhat managed to get the result I need by using global variables and module variables. What I did was create a module that uses localizationService to fill module variables with correct data. Next I bind the module variables to global parameters and use the data in subsequent test. This is quite error prone and difficult to implement for large number of variables. Is there a way to access and set global variables directly from code (without the need to use binding)?
If any of the 4. points is possible please let me know.
The recomendation from Ranorex support team:
In general only the whole menu is a control in WinForms. The elements within that control (MenuItems) can only be recognized via MSAA.
The problem is that the "Name" attribute of the MenuItems is not accessible.
As workaround I would suggest to use the attribute "AccessibleDescription" in your application in order to automate the menu. This attribute can also be used for language independent names.

Grails - Where to store properties related to domains

This is something I have been struggling about for some time now. The thing is: I have many (20 or so) static arrays of values. I say static because that is how I'm actually storing them, as static arrays inside some domains. For example, if I have a list of known websites, I do:
class Website {
...
static websites = ["web1", "web2" ...]
}
But I do this just while developing, because I can easily change the arrays if needed, but what I'm going to do when the application is ready for deployment? In my project it is very probable that, at some point, these arrays of values change. I've been researching on that matter, one can store application properties inside an external .properties file, but it will be impossible to store an array, even futile, because if some array gets an additional value, the application can't recognize it until the name of the new property is added where needed.
Another approach is to store this information in the database, but for some reason it seems like a waste to add 20 or more tables that will have just two rows, an id and a name.
And the last option, as far as I know, would be an XML, but I'm not very experienced with those. It seems groovy has a way of creating and reading XML files relatively easy, but I don't know how difficult would be to modify an XML whose layout is predefined in the application.
Needless to say that storing them in the config.groovy is not an option since any change will require to recompile.
I haven't come across some "standard" (maybe a best practice?) way of dealing with these.
So the questions is: Where to store these arrays?
Use Enum for a fixed set of attributes. Do this, if you rely at some places in your code on some concrete values.
If you do not rely on the attributes within your code (which you obviously don't), use a String-type. In this case, if you need to provide a select box, just do a distinct-query on this property in your database.
Default: Use a domain class per dynamic set of attributes. Another table is OK.
For something as simple as arrays you should use groovy own type of property files. They allow you too define properties as proper groovy variables (not just strings) and obviously loading them would be done dinamically in a simple way by using ConfigSlurper. For an example on how to use this kind of file you can have a look at the following ConfigSlurper:
For defining properties:
my.property.array=[1,2,3,4]
For loading property files:
def config = new ConfigSlurper().parse(new File('myconfig.groovy').toURL())
assert [1,2,3,4] == config.my.property.array
Tip: When you want to access the property files you want to do it in a way that can work for any environment. To make paths environment-independent use the following path as the root path:
import org.codehaus.groovy.grails.commons.ApplicationHolder
def ctx = ApplicationHolder.application.mainContext.servletContext
def rootPath = ctx.contextPath

NSTreeController how to save to file

Hi I am using an NSTreeController to control an NSOutlineView. This application loads bookmarks from file to application. As in the SourceView example in ADC:
http://developer.apple.com/mac/library/samplecode/SourceView/index.html
My questions is how do I save the bookmark to file once user makes the changes. Should I maintain the array/tree internally in my application and save before quitting or is there any easier methods?
You want to reverse the action taking place in the populateOutline method of MyWindowController.m. This method is reading the plist into one dictionary, reading a value from that dictionary, and using it to build the tree. Start with that method and follow the code to see how it is building the tree. It's using the BaseNode and ChildNode classes to build up the data model as a tree (I'm not sure why they didn't just use NSTreeNode). You want to reverse that procedure, ending up with an NSDictionary. You can then use writeToFile:atomically: to save the dictionary back to disk.
This can get as complex as you'd like to make it. For instance, the current code loads the dictionary file in a separate thread, so you could save in a separate thread, too. Or, you might want to save after every edit, again in a separate thread.

Resources