EMF error : the attribute "XYZ.Attribute_name" is not transient o it must have a data type that is serializable - eclipse-emf

I am creating an ECore model. I created an EClass and inside it I want to create a data member that is a list. So I created an EAttribute of type EEList.
However when I try to create the genmodel file I get an error saying
the attribute "XYZ.Attribute_name" is not transient o it must have a data type that is serializable.
It also gives a warning saying
The generic type associated with the 'EEList' classifier should have 1 type atrgument(s) to match the number of type parameter(s) of the classifier.
Can anyone tell me what I'm doing wrong? I could not figure out how to set the E in EEList<E>.

First error
The first error probably disappears after you've fix the second error. I write an explanation here, but you probably don't have to deal with it to solve you problem.
It is because, to be saved to disk, the EDataTypes of attributes must be convertible to a text format.
There are two ways to ensure this:
Implement conversion to and from strings for the used EDataType. Standard EMF EDataTypes already do this, but if you have created your own EDataType you have to do it manually.
Use a Java type for the EDataType that is serializable. It must thus implement the Serializable interface and provide serializating operations. Many standard Java classes, such as String and Integer already do that.
Another solution is to set the Transient property of the attribute to true. The the attribute will not be saved and its EDataType does not need to be serialized.
Second error
The normal way to create a list attribute is to set the Upper Bound property of the attribute to a value different from 1. To create a list attribute which can contain any number of elements, set Upper Bound to -1, which means Unbounded.
The EAttribute Type should be set to the element type, not to a list type.
The generated Java code will contain a property with the type EList<ElementType>.

Related

How to create an association to a parameterized CDS view?

I'm struggling to find the syntax to create an association between an extension of a parameterized CDS view and a parameterized CDS view. Their input parameters have the same names.
I've tried this:
extend view I_AAA with ZZ_AAA
association [0..1] to ZZ_BBB(P_param1 : $parameters.P_param1) as _ZZ_BBB
This gives the error: "unexpected keyword '(' (ON was expected)".
Or this:
extend view I_AAA with ZZ_AAA
association [0..1] to ZZ_BBB as _ZZ_BBB on $parameters.P_param1 = _ZZ_BBB.P_param1
This gives the error: "The entity ZZ_BBB requires parameter P_X".
The documentation states:
If the data source target of a specified CDS association is a CDS
entity with input parameters, parameters must be used after the name
_assoc to pass actual parameters to them. No parameters can be specified for a CDS association published as an element of a SELECT
list.
Putting parameters after _assoc is what I tried in the first example.
I've found a workaround: parameters have to be specified for each data element in the selection list using the following syntax:
association [0..1] to ZZ_BBB as _ZZ_BBB on $projection.operand1 = _ZZ_BBB.operand1
{
_ZZ_BBB(P_Param1:$parameters.P_Param1, P_Param2:$parameters.P_Param2).Element1 as SomeElement
...
I still would like to know if it is possible to specify a general parameter for the association that would affect all data elements. I'm going to accept this answer in the meantime.

Wireshark Dissector VoidString type

I am working on a Wireshark Dissector Generator for a senior project. I have done some reading but had a question about the VoidString object in the ProtoField Object. The documentation wasn't too clear on this particular value or what its used for.
Our generator uses C++ so that our client can modify it after the project is complete. I was reading in another thread here that it could be passed a table of key, value pairs. Are there other structures or information this parameter is used for? We're trying to make a data structure to contain the parse of a file passed by the user and we're trying to determine how to best make this object. Would it be better to allow a template object to be passed here instead or is the table sufficient?
I'm not sure to understand your needs but according to the wireshark source code (wslua_proto_fields.c), the definition of the VoidString parameter is :
#define WSLUA_OPTARG_ProtoField_new_VALUESTRING 4 /* A table containing the text that
corresponds to the values, or a table containing unit name for the values if base is
`base.UNIT_STRING`, or one of `frametype.NONE`, `frametype.REQUEST`, `frametype.RESPONSE`,
`frametype.ACK` or `frametype.DUP_ACK` if field type is ftypes.FRAMENUM. */
So the table will be "cast" following the type and print in base representation.

Weka GUI: add attribute is-missing-value

I have a couple of attributes with missing values.
This is a survey, so the fact that the person refused to answer is, by itself, useful information!
I would like to create a new attribute called is-missing-value = 1 if a given value in an attribute is a missing value and 0 otherwise.
Things I have tried:
I have tried using AddExpression, but this seems to only perform arithmetic operations such as 2*attribute.
I know that MathExpression allows using if-elses, such as ifelse(A < 3.0, 1, 0)... Do you guys know if/how I can test if a value is nan?
MakeIndicator (or NominalToBinary) should be able to do what I want, but I think I need (i) to convert my missing values to a nominal value, so that then (ii) I can convert this new nominal value to binary. The problem is that ReplaceMissingValue only works for mode or mean; I need to be able to define a new value. One solution could be to Edit the data directly, but I'd rather avoid this.
Please notice that I need to do this using the Weka GUI, not the Java interface.
I think I have a solution for you:
copy the attribute (if you want the original one to remain): apply the copy filter (this and the following filters are all under unsupervised/attribute folder) with the index of the attribute
Convert your attribute to nominal using the numericToNominal filter (set the attribute index)
Fill the missing values with a new value using ReplaceMissingWithUserConstant. Here you need to specify the nominalStringReplacementValue parameter (e.g. "missing") in addition to the index of your attribute.
Apply the NominalToBinary filter on your attribute. This will create several new attributes (as the number of unique values in the dataset + the missing value). You can remove the attributes you don't need and keep only the missing attribute.
Hope it helped.

Updating ElasticSearch mappings field type with existing data

I'm storing a few fields and for the sake of simplicity lets call the field in question 'age'. Initially ES created the index for me and it ended up choosing the wrong field type for 'age'. It's a string type right now instead of a numeric type. I'm aware that, I should have defined the mappings myself to begin with and force the data values been sent to be consistently all strings or numeric values.
What I've right now is an index with a ton of data that uses a 'string' type for age with following values: 1, 10, 'na', etc..
Now my question is: if I were to change the mapping from string to integer, would indexing have any issues with the existing data values such as 'na' when being updated ??
I just wanted to ask first before I start creating a playground environment to test with a sample data set.
What you can update according to the doc:
new properties can be added to Object datatype fields.
new multi-fields can be added to existing fields.
doc_values can be disabled, but not enabled.
the ignore_above parameter can be updated.
Otherwise I am afraid you will have to create a new mapping and reindex your data, see this post for example

Convert String attributes to numeric values in WEKA

I am new to weka.. My data contains a column of student name. I want to convert these names to numeric values, over the whole column.
Eg: Suppose there are 10 names abcd ,cdef,xyz ,etc. I want to pre process the data so that corresponding to each name there is distinct numeric value, like abcd changes to 1 ,cdef changes to 2 ,etc.
Also two or more rows can have same name. So in this case, same name should have same value.
Please help me...
Weka supports 4 non-relational attribute types: nominal, numeric, string and date. You can find out more about them in Weka Manual (it can be found in the same folder were you downloaded Weka), chapter "The ARFF Header Section".
You should find out what is the type of the "student's name" attribute (probably string, but could be nominal), and decide what should be the type of the attribute with converted values (numeric, nominal, or string).
There can be 2 scenarios:
(1) If types of the existing and desired attributes are the same (string-string or nominal-nominal, i.e. you only want to change values, not attribute type), you could do so
(a) manually - open the data file in Weka Explorer, and click Edit... button, or
(b) write a small program using Weka's Attribute class functions value and setValue.
(2) Types are different - Weka attribute types cannot be converted, so you will have to create and insert a new attribute with the converted values, and delete the old attribute. An example of how to create a new attribute can be found at
http://weka.wikispaces.com/Programmatic+Use#Step.
As far as I understand, strictly converting names into a "numeric" type doesn't seem like the best approach, within the context of WEKA - WEKA will treat numeric attributes differently than it does "string" or "nominal" attributes (for example, for running certain "attribute selection" algorithms, you can not use "numeric" types - they need to be "discretized" or converted into nominal form).
So, for your case, I think you can convert your "string" names into just "nominal" type using the StringToNominal class (this class acts as a WEKA "filter" to help convert a given "string" attribute into an attribute of type "nominal"). This will also take care about the repeating names - the list of "nominal" values for the names (that will be generated after you apply this filter) will contain any given name (that appears any number of times) only one time.
"Nominal" attributes also have the advantage that implicitly, they do have a numeric representation (the index of the value within the set of values; similar to how the "enums" in Java have a numeric index). So, you can utilize that as the "numeric" information corresponding to the names (though as I said earlier, it's probably best to just use it as "nominal" attribute; really depends on your particular use case).
I had the same problem as the one mentioned in the question, and I could "address" it in the following way.
I first applied the StringToNominal filter as mentioned before (don't forget to change the attribute range (from "last" to "first-last")). Once done that, I saved the dataset in LibSVM format, which changes the nominal values to numeric ones.
Then, if you close Weka and open it again, you will have the same dataset with the same number of features but they will be numeric. Now some changes should be done, first of all, normalizing all the numeric values in the dataset, using the Normalize filter. After that, apply the NumericToNominal filter to the last attribute.
Then, you will have a similar dataset with numeric values.
Hope this helps.