Marketcircle Home Products Support Blog Forums Partners Store
Marketcircle    Forums  Hop To Forum Categories  Extending Daylite  Hop To Forums  Creating Plugins    Plug-in: Tasks, BDQualifiers, eomodeld
Go
New
Find
Notify
Tools
Reply
  
-star Rating Rate It!  Login/Join 
Apprentice
Posted
Have I a simple plug-in working to export Tasks to a basic OPML list.

As a next step, I would now like the plug-in to:
1) filter by category qualifier
2) filter by a qualifier for a predetermined linked contact
3) sort by priority

Based on the documentation BDQualifiers appear to be the way to go. (MCPFetchSpecification & NSPredicates appear to not be the recommended path)

QUESTION: To confirm, are BDQualifiers the best way to go?

The plug-in uses the standard Daylite Xcode template with Daylite Headers. I added the ../Qualifiers/Source to the project and ended up with 78 errors on a previously successful project.

for example,
error: MCFoundationDefines.h: No such file or directory

QUESTION: Where/how does one get MCFoundationDefines.h ?

QUESTION: What else is needed for the errors to go away?

Assuming, one gets past the project errors...

QUESTION: What are the steps to (1) filter on a linked contact and (2) sort on priority?
 
Posts: 6 | Registered: January 31, 2008Reply With QuoteEdit or Delete MessageReport This Post
AJ
Marketcircle Team
Picture of AJ
Posted Hide Post
You don't need to compile the BDQualifier source. That is already built and linked in the app. We included the source because BDQualifier was(is?) an open source project.

All you need are the headers (the ones we include in the xcode template).

Question 1: For queries to the database BDQualifiers are the way to do. If you have stuff in memory then you can filter it using NSPredicates. If you are unsure, use DBQualifiers.

Question 2: You shouldn't need that. No need to compile the BDQualifier source.

Question 3: Same as above.

Question 4: Depends. If you have the contact in memory (the user's selection for example), you get to the tasks like this:

NSArray *tasks = [theSelectedContact tasks];


To get tasks from the database, linked to a specific contact try this:

// Assuming you have an handle on the ObjectContext
BDQualifier *qual = [BDQualifier qualifierWhereValueOfKey:@"contacts.firstname" isLike:@"Bob%"];
NSArray *tasks = [theObjectContext objectsForEntityNamed:@"Task" matchingQualifier:qual];
// NOTE: I have not tested this code - just writing it quickly from memory


To filter based on priorities, use NSSortDescriptor (see Cocoa documentation).

NSSortDescriptor *sort = [[[NSSortDescriptor alloc] initWithKey:@"priority" ascending:YES] autorelease];

NSArray *sortedArray = [tasks sortedArrayUsingDescriptors:[NSArray arrayWithObject:sort]];


Your gateway to the database is the ObjectContext. The center of the whole application is the Document (subclass of NSDocument). The objectContext and all windows hang off of that.

You can use MCPFetchSpecification - which has the concept of batching and sorting at the database level (instead of in memory).

MCPFetchSpecification *spec = [[[MCPFetchSpecification alloc] init] autorelease];

[spec setEntityName:@"Task"];
[spec setObjectContext:myObjectContext];
[spec setFetchLimit:100];
[spec setQualifier:myQualifier];
[spec setSortOrderings:mySortDescriptors];

// how many are there
long res = [spec resultCount];
unsigned int batches = [spec totalBatches];

NSArray *tasks = [spec fetchObjectForNextBatch];

// Once again - I have not tested this code, it's from my memory, so there are mistakes


HTH
 
Posts: 940 | Location: Toronto | Registered: May 03, 2006Reply With QuoteEdit or Delete MessageReport This Post
Apprentice
Posted Hide Post
The reply is helpful. Thanks.

Regarding, BDQualifiers... daylite plugin xcode template (DayliteDeveloperKit3) does not include any of DBQualifier header files.

However, based on the above info, I added just the DBQualifier*.h header files.... and the project now compiles fine.

Now on to testing...
 
Posts: 6 | Registered: January 31, 2008Reply With QuoteEdit or Delete MessageReport This Post
 Previous Topic | Next Topic powered by eve community  
 

Marketcircle    Forums  Hop To Forum Categories  Extending Daylite  Hop To Forums  Creating Plugins    Plug-in: Tasks, BDQualifiers, eomodeld

 

Refund Policy | Privacy Policy | Site Map | About Marketcircle
©2008 Marketcircle Inc. All rights reserved.
webmaster@marketcircle.com