Revision: 29223
http://sourceforge.net/p/bibdesk/svn/29223
Author: hofman
Date: 2025-04-27 21:56:26 +0000 (Sun, 27 Apr 2025)
Log Message:
-----------
Formatter for CQL queries for SRU search groups
Modified Paths:
--------------
trunk/bibdesk/BDSKSRUGroupServer.m
trunk/bibdesk/de.lproj/Localizable.strings
trunk/bibdesk/en.lproj/Localizable.strings
trunk/bibdesk/fr.lproj/Localizable.strings
Modified: trunk/bibdesk/BDSKSRUGroupServer.m
===================================================================
--- trunk/bibdesk/BDSKSRUGroupServer.m 2025-04-27 17:10:38 UTC (rev 29222)
+++ trunk/bibdesk/BDSKSRUGroupServer.m 2025-04-27 21:56:26 UTC (rev 29223)
@@ -43,6 +43,7 @@
#import "NSString_BDSKExtensions.h"
#import "NSURL_BDSKExtensions.h"
#import "BDSKStringConstants.h"
+#import <yaz/ZOOMObjC.h>
#define MAX_RESULTS 100
@@ -56,6 +57,11 @@
enum { BDSKSRUStateIdle, BDSKSRUStateSearch, BDSKSRUStateRetrieve };
+@interface BDSKCQLQueryFormatter : NSFormatter
+@end
+
+#pragma mark -
+
@interface BDSKSRUGroupServer ()
@property (nonatomic, copy) NSString *searchTerm;
@@ -187,7 +193,12 @@
- (BOOL)isRetrieving { return BDSKSRUStateIdle != downloadState; }
-- (NSFormatter *)searchStringFormatter { return nil; }
+- (NSFormatter *)searchStringFormatter {
+ static NSFormatter *formatter = nil;
+ if (formatter == nil)
+ formatter = [[BDSKCQLQueryFormatter alloc] init];
+ return formatter;
+}
#pragma mark Search methods
@@ -357,3 +368,31 @@
}
@end
+
+#pragma mark -
+
+@implementation BDSKCQLQueryFormatter
+
+- (NSString *)stringForObjectValue:(id)obj { return obj; }
+
+- (BOOL)getObjectValue:(id *)obj forString:(NSString *)string
errorDescription:(NSString **)error;
+{
+ BOOL success;
+ if (string && [@"" isEqualToString:string] == NO) {
+ ZOOM_query query = ZOOM_query_create();
+ int status = ZOOM_query_cql2rpn(query, [string UTF8String], NULL);
+ if (status) {
+ if (error) *error = NSLocalizedString(@"This is not a valid CQL
query.", @"Error description");
+ success = NO;
+ } else {
+ success = YES;
+ }
+ ZOOM_query_destroy(query);
+ } else {
+ success = YES;
+ }
+ *obj = string;
+ return success;
+}
+
+@end
Modified: trunk/bibdesk/de.lproj/Localizable.strings
===================================================================
(Binary files differ)
Modified: trunk/bibdesk/en.lproj/Localizable.strings
===================================================================
(Binary files differ)
Modified: trunk/bibdesk/fr.lproj/Localizable.strings
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit