ConvertAvroSchema.java - rename avro field - How to set dynamic property in nifi? - avro

I am trying to convert an avro object from one schema to another and rename few attributes using NIFI ConvertAvroSchema.
In the documentation,I see notes about renaming attributes using dynamic properties. But I am not sure how to set it up in NIFI.Should these be set under properties as key value pairs?
"companyName" -> "name"
"parent.id" -> "parentId"

Yes dynamic properties mean properties added by the user at runtime using the + icon on the properties tab. That processor says the name of a dynamic property is the field name from the input schema, and the value is the field name from the output schema.

Related

Avro schema: adding a new field with default value - straight default value or a union with null?

So I have an avro record like so (call it v1):
record MyRecord {
array<string> keywords;
}
I'd like to add a field caseSensitive with a default value of false (call it v2). The first approach I have is:
record MyRecord {
array<string> keywords;
boolean caseSensitive = false;
}
According to schema evolution, this is both backward and forward compatible because a reader with the new schema v2 reading a record that was encoded with old writer schema v1 will be able to fill this field with the default value and a reader with older schema v1 will be able to read a record encoded with the new writer schema v2 because it will just ignore the newly added field.
Another way to add this field is by adding a union type of null and boolean with a default value of null, like so:
record MyRecord {
array<string> keywords;
union{null, boolean} caseSensitive = null;
}
This is also backward and forward compatible. I can see that sometimes one would want to use the 2nd approach if there is no clear default value for a field (such as name, address, etc.). But given my use case with a clear default value, I'm thinking of going with the first solution. My question is: is there any other concerns that I'm missing here?
There will be a potential issue with writers in the first case--apparently writers do not use default values. So a writer writing "old data" (missing the new field--so writer is publishing a record with the "keywords" field only) will blow up against the first schema. Same writer using second schema will be successful, and the "caseSensitive" field will be set to null in the resulting message.

Archer to Archer Data Feed in RSA Archer

Need to create Archer to Archer Data Feed that should set value of two fields as NULL in a cross referenced application, if the value of a field is Approved in first field. I am not getting how can I send a NULL value to the fields through data feed??
Archer doesn't have "NULL" value, but you still can get it done like this:
Step 1. Calculation. Open your data feed configuration and go to the source definition tab. Add a new field to the end of the list and make it calculated.Add formula to check value of 1st field that present in the data source and if it is equal to "Approved" then return empty string.
Something like this
=IF([field field] = VALUEOF([first field],[Approved]), "","SOMETHING ELSE")
The key here is to have this calculation return an empty string when you need it - "".
I suggest you to test your calculation in the calculated field in the application before you put it in the calculated data source field.
Step 2. Data feed mapping. Now you need to map new calculated field in your data feed to the field you want to remove value from. Go to the mapping tab in your data feed configuration and map the field. Make sure to selection options "Replace value" and "Empty Values" - this way existing value will be replaced even with empty values.
Similar approach works for me in multiple data feeds.
Good luck!
You can use novalue() function in the calculation
I don't believe there is a concept of NULL in Archer. The closest you're probably going to get is blank/empty. To do that, in the Data Map tab of your data feed, click the edit icon under Actions column. Check the box that Empty Values should be populated rather than ignored.
Assumption is that what is in the question is the only task required by the data feed.
Create report with the filter set as First Field = Approved
Fields to display should contain tracking id (tracking ID which is configured to System ID) of the Target app along with the Tracking ID of the Cross-Reference App.
In Source Definition add new source and give it an adequate name as clear or Null if you want
Where it says Raw Data Field in the drop-down, update this to static. Leave the source as not configured or unconfigured.
Map this newsource to the 2 fields that you are trying to clear. In Options set to Replace and uncheck add unknown and set to populate empty values.
Map the Tracking ID of the Target app and map the Tracking ID of the cross-reference.
Set key field definition for both apps to the tracking id
Set data feed to update only. Remove checkmark for create
If your are doing more than just clearing the 2 fields, then
Stan Utevski answer is mostly correct except you must have the field you are evaluating for "Approve" in the fields to display of your report. Otherwise the calculation will not validate.

Scout Eclipse Neon set title of the field label in form data

I am wondering if you could set title of field in form data on server side.
Use case for this is that you have one field, and depend on some server logic you would set title of the field. Is it posible to set it on server somehow, to not sending string value to client and then set the title.
I was looking at method
formData.getMyField.setPropertyByClass(c, v);
but I don't know if this method could do this and which property I need to set.
FormData classes can contain two types of data holder classes:
data holders for values associated with value fields (these holders always extend AbstractValueFieldData) and
data holders for values associated with form data properties (these holders always extend AbstractPropertyData).
A form data property is generated if the associated form has a member variable whose setter and getter is annotated with #FormData.
The method setPropertyByClass(...) is intended to set the value of a form data property in a form data object.
The method cannot be used to set the label of a form.
The standard way to set the label of a field would be to load the form data from the server and to set the label afterwards, as in the following code snippet:
...
public class ModifyHandler extends AbstractFormHandler {
MyFormData formData = SERVICES.getService(IMyProcessService.class).load();
importFormData(formData);
getMyField.setLabel(formData.getMyProperty().getValue());
}
...

CoreData - Setting a property of entity to be not null - Should the attribute be set as Optional or Mandatory

I need to have an attribute in Coredata's entity be set as not null and have a default value.
I have set a default value for the attribute of the Entity in the .xcdatamodeld schema definition
My question is Should the attribute be marked as Optional or not.
What will be the impact if I don't check any of the following three to the attribute - Transient, Optional, Indexed ? Will this attribute be treated as mandatory ?
EDIT: When I set the property as mandatory and if the value trying to set is nil, the insert fails with error code 1570 - NSValidationMissingMandatoryPropertyError, where I am simply expecting the property to be set its default value and gets inserted.
What is the point of having a default value then ? Can anyone help me what I am really missing here.
Set it as mandatory and configure it with an appropriate default value (e.g. 0). If it is optional, the setting of the default value is not guaranteed, regardless of the other options.

Objective-C get a class property from string

I've heard a number of similar questions for other languages, but I'm looking for a specific scenario.
My app has a Core Data model called "Record", which has a number of columns/properties like "date, column1 and column2". To keep the programming clean so I can adapt my app to multiple scenarios, input fields are mapped to a Core Data property inside a plist (so for example, I have a string variable called "dataToGet" with a value of 'column1'.
How can I retrieve the property "column1" from the Record class by using the dataToGet variable?
The Key Value Coding mechanism allows you to interact with a class's properties using string representations of the property names. So, for example, if your Record class has a property called column1, you can access that property as follows:
NSString* dataToGet = #"column1";
id value = [myRecord valueForKey:dataToGet];
You can adapt that principle to your specific needs.

Resources