Revision: 29211
          http://sourceforge.net/p/bibdesk/svn/29211
Author:   hofman
Date:     2025-04-27 14:13:42 +0000 (Sun, 27 Apr 2025)
Log Message:
-----------
Allow different equivalent forms for record syntax strring, like case 
insensitive and with or without space. Normalize in method, and use the same 
default forms for UI in Zoom and RSU.

Modified Paths:
--------------
    trunk/bibdesk/BDSKSRUGroupServer.m
    trunk/bibdesk/BDSKZoomGroupServer.m

Modified: trunk/bibdesk/BDSKSRUGroupServer.m
===================================================================
--- trunk/bibdesk/BDSKSRUGroupServer.m  2025-04-27 13:53:33 UTC (rev 29210)
+++ trunk/bibdesk/BDSKSRUGroupServer.m  2025-04-27 14:13:42 UTC (rev 29211)
@@ -48,9 +48,13 @@
 #define MAX_RESULTS 100
 
 #define MARCXML_STRING  @"MARC XML"
-#define DC_STRING       @"DC"
+#define DCXML_STRING    @"DC XML"
 #define MODS_STRING     @"MODS"
 
+#define MARCXML_SYNTAX  @"marcxml"
+#define DC_SYNTAX       @"dc"
+#define MODS_SYNTAX     @"mods"
+
 enum { BDSKSRUStateIdle, BDSKSRUStateSearch, BDSKSRUStateFetch };
 
 @interface BDSKSRUGroupServer ()
@@ -90,8 +94,19 @@
     return self;
 }
 
-+ (NSArray *)supportedRecordSyntaxes { return @[MARCXML_STRING, DC_STRING, 
MODS_STRING]; }
++ (NSArray *)supportedRecordSyntaxes { return @[MARCXML_STRING, DCXML_STRING, 
MODS_STRING]; }
 
++ (NSString *)normalizedRecordSyntax:(NSString *)syntax {
+    if ([syntax isCaseInsensitiveEqual:MARCXML_STRING] || [syntax 
isCaseInsensitiveEqual:MARCXML_SYNTAX] || [syntax 
isCaseInsensitiveEqual:@"MARC"])
+        return MARCXML_SYNTAX;
+    else if ([syntax isCaseInsensitiveEqual:DCXML_STRING] || [syntax 
isCaseInsensitiveEqual:DC_SYNTAX] || [syntax isCaseInsensitiveEqual:@"DCXML"])
+        return DC_SYNTAX;
+    else if ([syntax isCaseInsensitiveEqual:MODS_STRING])
+        return MODS_SYNTAX;
+    else
+        return nil;
+}
+
 #pragma mark URLs
 
 - (NSURLComponents *)baseURLComponents {
@@ -111,12 +126,12 @@
     NSURLComponents *components = [self baseURLComponents];
     NSMutableArray *query = [NSMutableArray array];
     NSString *version = [[[self serverInfo] options] objectForKey:@"version"] 
?: @"1.1";
-    NSString *syntax = [[[self serverInfo] options] 
objectForKey:@"recordSyntax"];
+    NSString *syntax = [[self class] normalizedRecordSyntax:[[[self 
serverInfo] options] objectForKey:@"recordSyntax"]];
     [query addObject:[@"version=" stringByAppendingString:version]];
     [query addObject:@"operation=searchRetrieve"];
     [query addObject:[@"query=%@" stringByAppendingString:[[self searchTerm] 
stringByAddingPercentEscapesForQueryTerm]]];
-    if ([syntax length])
-        [query addObject:[@"recordSchema=" stringByAppendingString:[[syntax 
stringByRemovingWhitespace] lowercaseString]]];
+    if (syntax)
+        [query addObject:[@"recordSchema=" stringByAppendingString:syntax]];
     if (range.length > 0) {
         [query addObject:[NSString stringWithFormat:@"startRecord=%lu", 1 + 
range.location]];
         [query addObject:[NSString stringWithFormat:@"maximumRecords=%lu", 
range.length]];
@@ -192,17 +207,17 @@
 }
 
 - (BDSKStringType)stringTypeForRecordString:(NSString *)string {
-    NSString *recordSyntax = [serverInfo recordSyntax];
+    NSString *recordSyntax = [[self class] normalizedRecordSyntax:[serverInfo 
recordSyntax]];
     BDSKStringType stringType = BDSKStringTypeUnknown;
-    if(recordSyntax == nil || [recordSyntax isEqualToString:MARCXML_STRING]) {
+    if(recordSyntax == nil || [recordSyntax isEqualToString:MARCXML_SYNTAX]) {
         stringType = BDSKStringTypeMARC;
         if ([BDSKStringParser canParseString:string ofType:stringType] == NO)
             stringType = BDSKStringTypeDublinCore;
-    } else if([recordSyntax isEqualToString:DC_STRING]) {
+    } else if([recordSyntax isEqualToString:DC_SYNTAX]) {
         stringType = BDSKStringTypeDublinCore;
         if ([BDSKStringParser canParseString:string ofType:stringType] == NO)
             stringType = BDSKStringTypeMARC;
-    } else if([recordSyntax isEqualToString:MODS_STRING]) {
+    } else if([recordSyntax isEqualToString:MODS_SYNTAX]) {
         stringType = BDSKStringTypeMODS;
     }
     if (NO == [BDSKStringParser canParseString:string ofType:stringType])

Modified: trunk/bibdesk/BDSKZoomGroupServer.m
===================================================================
--- trunk/bibdesk/BDSKZoomGroupServer.m 2025-04-27 13:53:33 UTC (rev 29210)
+++ trunk/bibdesk/BDSKZoomGroupServer.m 2025-04-27 14:13:42 UTC (rev 29211)
@@ -82,13 +82,13 @@
 }
 
 + (ZOOMSyntaxType)zoomRecordSyntaxForRecordSyntaxString:(NSString *)syntax{
-    if ([syntax isEqualToString:USMARC_STRING]) 
+    if ([syntax isCaseInsensitiveEqual:USMARC_STRING] || [syntax 
isCaseInsensitiveEqual:@"USMARC"])
         return USMARC;
-    else if ([syntax isEqualToString:UNIMARC_STRING]) 
+    else if ([syntax isCaseInsensitiveEqual:UNIMARC_STRING])
         return UNIMARC;
-    else if ([syntax isEqualToString:OPAC_STRING]) 
+    else if ([syntax isCaseInsensitiveEqual:OPAC_STRING])
         return OPAC;
-    else if ([syntax isEqualToString:MARCXML_STRING] || [syntax 
isEqualToString:DCXML_STRING] || [syntax isEqualToString:MODS_STRING]) 
+    else if ([syntax isCaseInsensitiveEqual:MARCXML_STRING] || [syntax 
isCaseInsensitiveEqual:@"MARCXML"] || [syntax 
isCaseInsensitiveEqual:DCXML_STRING] || [syntax 
isCaseInsensitiveEqual:@"DCXML"] || [syntax isCaseInsensitiveEqual:@"DC"] || 
[syntax isCaseInsensitiveEqual:MODS_STRING])
         return XML;
     else
         return UNKNOWN;
@@ -198,17 +198,17 @@
 {
     NSString *recordSyntax = [serverInfo recordSyntax];
     BDSKStringType stringType = BDSKStringTypeUnknown;
-    if([recordSyntax isEqualToString:USMARC_STRING] || [recordSyntax 
isEqualToString:UNIMARC_STRING] || [recordSyntax isEqualToString:OPAC_STRING]) {
+    if([recordSyntax isCaseInsensitiveEqual:USMARC_STRING] || [recordSyntax 
isCaseInsensitiveEqual:@"USMARC"] || [recordSyntax 
isCaseInsensitiveEqual:UNIMARC_STRING] || [recordSyntax 
isCaseInsensitiveEqual:OPAC_STRING]) {
         stringType = BDSKStringTypeMARC;
-    } else if([recordSyntax isEqualToString:MARCXML_STRING]) {
+    } else if([recordSyntax isCaseInsensitiveEqual:MARCXML_STRING] || 
[recordSyntax isCaseInsensitiveEqual:@"MARCXML"]) {
         stringType = BDSKStringTypeMARC;
         if ([BDSKStringParser canParseString:string ofType:stringType] == NO)
             stringType = BDSKStringTypeDublinCore;
-    } else if([recordSyntax isEqualToString:DCXML_STRING]) {
+    } else if([recordSyntax isCaseInsensitiveEqual:DCXML_STRING] || 
[recordSyntax isCaseInsensitiveEqual:@"DCXML"] || [recordSyntax 
isCaseInsensitiveEqual:@"DC"]) {
         stringType = BDSKStringTypeDublinCore;
         if ([BDSKStringParser canParseString:string ofType:stringType] == NO)
             stringType = BDSKStringTypeMARC;
-    } else if([recordSyntax isEqualToString:MODS_STRING]) {
+    } else if([recordSyntax isCaseInsensitiveEqual:MODS_STRING]) {
         stringType = BDSKStringTypeMODS;
     }
     if (NO == [BDSKStringParser canParseString:string ofType:stringType])
@@ -305,7 +305,7 @@
             searchTerm = mutableCopy;
         }
         
-        BOOL isOPAC = [[info recordSyntax] isEqualToString:OPAC_STRING];
+        BOOL isOPAC = [[info recordSyntax] isCaseInsensitiveEqual:OPAC_STRING];
         
         // the resultSet is cached for each searchTerm, so we have no overhead 
calling it for retrieving more results
         ZOOMQuery *query = [ZOOMQuery queryWithCCLString:searchTerm 
config:[info queryConfig]];

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Bibdesk-commit mailing list
Bibdesk-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to