How code generate from protege data property with getter single value instead collection? - code-generation

I have a simple model in protege of class and data property.
But when I use code generator - in generated class - property getter have type - Collection< String > instead simple String.
I try to add something like with different types predicate in class:
"title some xsd:string"
But it is Collection yet.
Is it can be done in protege and how? May be example ontology?

Related

replacing drools getter lookup for non-pojo

Drools supports the usage of properties of Pojos using a simple name. For example Person(age==10) to match a Person instance that has a getAge() method returning 10.
My problem now is that I have to handle something that is not a pure Pojo and instead has a generic getter. So for the Person example above I need a transformation to Person(myGenericPropertyLookupMethod("age")==10). And I need this for all such property usages, which includes for example the usage of from and chaining like $street : String() from $person.address.street. where at least street must be looked up using myGenericPropertyLookupMethod.

dynamic setting and getting values from Swift class

I'd like to copy all properties from a NSManagedObject over to a "regular" Swift class. I don't want to do this manually, i.e. make a regular class with all the properties for every NSManagedObject and then manually copy all those values.
I do know how to read property names and values dynamically from my managed object, but how to set them on a Swift class in a way that I can then use those values like
mySwiftObject.name
which returns a String or
mySwiftObject.age
which returns a Number (as those are the types on the Managed Object). Custom subscripting and stuff like that came to my mind, but I didn't manage to achieve this... Is there a nice way to do exactly that?

How To Model A String List in EMF ECORE

I'm stuck trying to use ecore annotations to model a List for the type attribute I have tried the type="java.lang.String" and type="EString" but both are not getting the results I want. When using annotations to model a simple String getter/setter it works fine but now I'm stuck using an object holder for a string for string lists and its getting annoying. Does anyone have an idea? - Duncan
I don't understand why are you using annotations to model a List.
To model an attribute as a List of Strings, just define the EType as EString and Upper Bound to -1.

Swift Core Data: auto-generating managed object subclass makes the class name to PRODUCT_MODULE_NAME.entityName in model

I'm making a purely Swift project, and when I create an entity in model file, then use Editor->Create NSManagedObject Subclass to create class file for the entity, in the model, the Class property for entity becomes PRODUCT_MODULE_NAME.entityName, this will cause core data to fail loading NSManagedObject subclass instance.
I know how to get pass by this by using #objc() and rename the class property in model file, but is there any better idea?
Two options:
Replace the PRODUCT_MODULE_NAME with the value of this build setting. By default, it will be the same as your TARGET_NAME. The full value in the Class field should be something like MyApp.entityName.
Use only entityName in the Class field and prefix your swift class with #objc(entityName)
The representedClassName field in the data model appears to be evaluated at runtime so it needs a literal value.

Spring batch: FieldSetMapper should set field to null instead of empty

I am using spring batch to read pipe (| delimited) separated file which have have 7 field. I created a class called MyLineMapper that extends spring's FieldSetMapper. This class maps field values provided in file to my object (XYZ type). Now the problem is that fieldSet object that i get inside class extending FieldSetMapper contain empty value for field that are not present in delimited values.
For example:
Suppose that the delimited file format is as follows: |ID|Country|City|Pin|
Suppose i provide following line in file: |1|India|
As you can see the above line does not contain information for City and Pin. Therefore, I expect FieldSet object should contain Null value for these two fiels (City and Pin) instead of empty string. I don't want empty value as Null will help me to know if that field was actually present in file or not.
How can I achieve this ? Do I need to extend DelimitedLineTokenizer which I am using for tokenizing ? Or this is a simple way to do this ?
Any help will be appreciated.
From FieldSetMapper javadoc
To customize the way that FieldSet values are converted to the desired
type for injecting into the prototype there are several choices. You
can inject PropertyEditor instances directly through the customEditors
property, or you can override the createBinder(Object) and
initBinder(DataBinder) methods, or you can provide a custom FieldSet
implementation.
Depending on type of your target bean conversion is done using default Spring convention. If you need other type of logic write your own.