In a sqlite based core data storage I have 2 entities: Item and Tag.
Item has a many to many relationship to Tag. Tag also has a recursive relationship for one parent tag. Hence tags form a tree.
Now I want to create a NSPredicate to fetch all items which have all the tags in a list of criteria tags.
The problem now is that the criteria should also be met if the item does not have a tag of the criteria list but a tag which is below the criteria tag in the tag tree.
I could expand the criteria list to include all descendants. But this would explode the list to enormous size as the tree a big.
One theoretic solution would be a Fetched Property in Tag "ancestors" which is "self joined with parent.ancestors". But I don't know how to formulate this. And I even think that it is not possible to traverse relationships in Fetched Properties, right?
For performance reasons I want to avoid to fetch all items and filter programmatically.
Any ideas?
Thanks,
Marco
Related
I am trying to design a view with multiple categories, and each document can belong to multiple categories at the same time.
For example, File A is in category:
1->a;
2
I can achieve this effect by specifying the columns as categories and access the document through various routes. However, I fail to specify which category the sub-categories belong to. This is what I am getting instead:
1->a;
2->a
The case doesn't seem too big of a difference but basically the view is returning every combination of the categories and the amount of entries can get very large.
I have tried to add the super category in front of the sub-category and try to filter out entries which the categories do not match the prefix of the sub-categories(e.g. 1,a), but I cannot find a way filter them out. Although the multiple values are shown in different entries, when I try to use the variable it extracts all the values.
Is there a way I can filter the entries based on that particular row instead of all the values? Or is there anyway I can achieve the effect through other methods? Thank you in advance.
You need to collapse Categories and subcategories into a single field. The Domino way to do this is to separate category and subcategory by backslash. So your category field would be something like:
"1\a":"2"
That ties the subcategory to the category. Or if you want to be able to find a document by subcategory only:
"1\a":"a":"2"
You then can use a little formula magic to get from the subcategory back to the main category (presuming the subcategories don't duplicate):
AllCategories := "1\a":"a":"2";
foundCategory := "a";
#Trim(#Replace(AllCategories;foundCategory:#Trim(#ReplaceSubstring(allCategories;foundCategory)));
This would return "1\a" (Note: the formula above is written is classic #Formula language, it is left as an exercise to the reader to translate that to the JavaScript formula equivalent)
Hope that helps
We have an Xpages application and recently discovered an issue where there are several Notes documents that have duplicates but the duplicates are PARENT documents too and NOT response documents. Is it possible to create a Notes view that will show duplicates where all the duplicates are parents? I know the formula for showing conflicts is the following but what about where they are all parents?
SELECT #IsAvailable($Conflict)
Expounding on my comment:
Create a view which is categorized on the first column
In the first column formula, put in criteria that you would use to determine a duplicate. This may be the Document Unique ID, or maybe another field or combination of fields.
Add a second column that contains the number 1. Then enable column totals on this column.
Now look at this view you created. With the view categories collapsed, look for any number greater that 1 to determine which documents are duplicates.
I think what you are asking is not how to identify the duplicates - but how to find out which of them are parent documents. So basically you would create a view as Steve suggests - but instead of putting a constant of 1 into the second column I would suggest putting either #DocChildren (for immediate responses) or #DocDescendants (for all responses and responses to responses).
If I understand your logic then all the ones returning 0 (zero) are child documents and those returning 1 or higher would be parent documents. Of course you could also use an item on the document in your view formula - if it only exists on the parent doc (or its value can tell that it is a parent doc)
View selection formulas act on only one document at a time. They cannot perform lookups. They have no way to compare two documents. There is therefore no possible way for a view to identify duplicates.
A view can, as per the other answers, categorize documents based on common values. If there is a single field that is supposed to be unique across all documents, you can categorize on that field. That will give you a visualization of the duplicates, but it won't filter them in or out.
The only way for a view to filter duplicates - either to show only duplicates, or to exlude duplicates - would be if you run an agent that reads all documents, looks for those that are duplicates, and marks them with a special field value - e.g., IsDuplicate = 1. Once you do that, you can create a view that selects all documents with IsDuplicated = 1, or a view that excludes IsDuplicated = 1.
I have a datamodel in core data as such:
Store <--->> Product <<--->> Tag
I'm looking to create a query that matches products based on their associated tags. A typical use scenario would be you choose to search storeA and output storeB. By selecting storeA a list of storeA products is presented. Let's say you pick productA from the list which brings you to a second viewcontroller. That second viewcontroller lists all relating productB's (because earlier you set storeB as output). I'm following this: predicate subquery to return items by matching tags but want the added store filter of products. Is subquery the way to go? How would I include a filter by selected Store?
I'm using Core Data with an NSFetchedResultsController. My data consists of many students and lesson dates. I set my Predicate and Sort Descriptors up to return a sorted lists of lessons for a particular student. I sort ascending or defending, and my table view is loaded and happy.
However, at times, I want to return only the previous two lessons, sorted ascending. How in the world can I construct a NSFetchRequest to only return an array of two items?
I've been trying to fool the table view by modifying rows and sections... and yes, it is getting tangled up and clunky.
It seems I need to nest NSFetchRequests inside of the NSFetchedResultsController. First fetching and getting the number of total items / sections. And then just getting the last two objects when sorting ascending. How do I limit the results to the last two items when I don't know how many items there are when setting up the NSFetchRequest?
Thanks
Just tell the fetch request how many you want:
[fetchRequest setFetchLimit:2];
Results will be sorted according to your sort descriptor(s), and you'll get the first two results.
I have two forms that are related and I would to combine them in a view control. Not that difficult. This is for a "1 to Many" type scenario.
Say I have a customer view with the columns customerID and Customer Name. Then I have a view showing the "many" documents that has the columns masterCustomerID, orderNumber, orderDate.
On the XPage I create a view control of the many documents and add the columns masterCustomerID, orderNumber, orderDate. Then I add a column in the front to do a DbLookup to pull in the actual name of the customer. Nothing too fancy really.
My question is, in this situation, where the lookup column is the FIRST column. What are the strategies to sort the view column by that column. By default it would sort by the Key Value in the order view which is likely different then the Name values.
I'm not averse to using repeat controls if that would be easier.
My first thought would be to employ TreeMaps somehow, but I don't know if that's practical in the event that there might be a LOT of documents. Maybe there's something I'm missing...
Any advice would be appreciated. Thanks
Use view with (Customer name, Customer ID) structure as main view. Then based on Customer ID populate other columns by lookup from view with structure (Customer ID, Order ID, Order date). Hence it is 1:N relationship, you can't use single view component, but two nested - repeat inside view column would do.
I hope you are aware of performance impact (orders looked up for every customer row), so don't try to show too many customers at once.