Hi Guys,
In Wonder's documentation there is a method called setDeduplicationEnabled()
for ERXKeyFilter. I've the latest code from trunk but couldn't find this
method. Can someone help me locate that? or is there any alternative way to
implement the similar behaviour?
The problem I'm facing is here:
I've following entities, Horse, HorseDetail, HorseType, HorseColor.
Following are the relationships.
Horse -> toMany -> HorseDetail
Horse -> toOne -> Horse (Sir)
Horse -> toOne -> Horse (Dam)
Horse -> toOne -> HorseType
Horse -> toOne -> HorseColor
There are many horses in the database and I fetch record based on HorseDetail
because it contains the horseName. E.g. I fetch all the instances of
HorseDetail where the horseName contains letter "a".
It works fine when I set the rule for entity = "HorseDetail", task = "GET":
displayPropertyKeys =
(
"horseName",
"horseBio",
"toLanguage",
"toHorseProfile.toHorseType.typeName",
"toHorseProfile.toHorseColor.colorName"
)
For all the horses the filter works fine. But when I modify the above rule as
following:
displayPropertyKeys =
(
"horseName",
"horseBio",
"toLanguage",
"toHorse.toHorseType.typeName",
"toHorse.toHorseColor.colorName",
"toHorse.toSirHorse.toHorseDetails.horseName",
"toHorse.toDamHorse.toHorseDetails.horseName"
)
This also works fine but for only those horses which have toSirHorse and
toDamHorse set. If any of them is missing, the returned data for those horses
only contain the "horseName".
Here is the method that I use for creating the ERXKeyFilter for HorseDetail.
Basically the inferFilterKeysForEntity checks the d2w rules for the entity
where the task is "GET" and gets the "displayPropertyKeys".
public ERXKeyFilter showFilter(String entityName) {
NSArray<String> keys = inferFilterKeysForEntity(entityName);
ERXKeyFilter filter = null;
if (keys != null && !keys.isEmpty()) {
filter = ERXKeyFilter.filterWithNone();
for (String key : keys) {
filter.include(new ERXKey<String>(key));
}
} else {
filter =
ERXKeyFilter.filterWithAttributesAndToOneRelationships();
}
return filter;
}
Here is the action defined in the custom rest controller for the horses method:
public WOActionResults searchAction() throws Throwable {
NSArray<EOQualifier> quals = new NSMutableArray<EOQualifier>();
String name = request().stringFormValueForKey("name");
if (name != null) {
quals.add(HorseDetail.TO_LANGUAGE.eq(language()));
quals.add(HorseDetail.PROFILE_NAME.ilike(name));
}
EOFetchSpecification fs = new EOFetchSpecification(
HorseDetail.ENTITY_NAME, new ERXAndQualifier(quals),
null);
NSArray<HorseDetail> elements = editingContext()
.objectsWithFetchSpecification(fs);
HorseColor horseColor = horseColor();
if (horseColor != null) {
elements = HorseDetail.TO_HORSE
.append(Horse.TO_HORSE_COLOR).eq(horseColor)
.filtered(elements);
}
HorseType type = type();
if (type != null) {
elements = HorseDetail.TO_HORSE
.append(Horse.TO_HORSE_TYPE).eq(type)
.filtered(elements);
}
return response(elements, showFilter(HorseDetail.ENTITY_NAME));
}
I guess modifying the value of deduplication can give me the intended results.
or is there any other solution to this problem?
Here is the link:
http://webobjects.mdimension.com/hudson/job/Wonder/javadoc/er/extensions/eof/ERXKeyFilter.html#setDeduplicationEnabled(boolean)
Thanks,
Farrukh _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com
This email sent to [email protected]