Commits

Tuukka Norri  committed 9eb7dc5

Groundwork for schema upgrading
- Removed the install schema menu item. There are enough options for the user to do this already, such as clicking any check box in the main window.
- Remove menu item is now validated.
- Added functions for getting version numbers for the bundled BaseTen schema. The version numbers are read directly from the file. Perhaps the compatibility version function should be in BaseTen framework, though.
-

  • Participants
  • Parent commits ecdb173
  • Branches PGTS-NG

Comments (0)

Files changed (5)

File BaseTenAssistant/BaseTenAssistant.xcodeproj/project.pbxproj

 	objects = {
 
 /* Begin PBXBuildFile section */
-		2B66D97D0B1C664300F8C64A /* BaseTenModifications.sql in Resources */ = {isa = PBXBuildFile; fileRef = 2B66D97C0B1C664300F8C64A /* BaseTenModifications.sql */; };
+		2B66D97D0B1C664300F8C64A /* BaseTenModifications.sql.m4 in Resources */ = {isa = PBXBuildFile; fileRef = 2B66D97C0B1C664300F8C64A /* BaseTenModifications.sql.m4 */; };
+		531C016C0E32AEC300E43208 /* BXACurrentVersion.m.m4 in Sources */ = {isa = PBXBuildFile; fileRef = 531C016B0E32AEC300E43208 /* BXACurrentVersion.m.m4 */; };
 		531DCABA0B52818E00200097 /* MKCAlternativeDataCellColumn.m in Sources */ = {isa = PBXBuildFile; fileRef = 531DCAB80B52818E00200097 /* MKCAlternativeDataCellColumn.m */; };
 		532F42A00D69B70F009FEDCD /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 532F429A0D69B70F009FEDCD /* MainMenu.xib */; };
 		53425B650E2CD237005F6123 /* MKCStackView.m in Sources */ = {isa = PBXBuildFile; fileRef = 53425B640E2CD237005F6123 /* MKCStackView.m */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXBuildRule section */
-		53DD5AC90A78D47D00CD5924 /* PBXBuildRule */ = {
+		531C01780E32AF7900E43208 /* PBXBuildRule */ = {
 			isa = PBXBuildRule;
 			compilerSpec = com.apple.compilers.proxy.script;
-			filePatterns = "*.sql";
+			filePatterns = "*.m4";
 			fileType = pattern.proxy;
 			isEditable = 1;
 			outputFiles = (
-				"${DERIVED_FILES_DIR}/${INPUT_FILE_BASE}.sql",
+				"${DERIVED_FILES_DIR}/${INPUT_FILE_BASE}",
 			);
-			script = "perl -p -e 's/PGTS_SCHEMA_NAME/BX/g' ${INPUT_FILE_PATH} > ${DERIVED_FILES_DIR}/${INPUT_FILE_BASE}.sql\n";
+			script = "m4 ${INPUT_FILE_PATH} > ${DERIVED_FILES_DIR}/${INPUT_FILE_BASE}";
 		};
 /* End PBXBuildRule section */
 
 		089C165DFE840E0CC02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
 		29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = Source/main.m; sourceTree = "<group>"; };
 		2B66D7D70B1C5CB800F8C64A /* SetupApplication_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.h; name = SetupApplication_Prefix.pch; path = Source/SetupApplication_Prefix.pch; sourceTree = "<group>"; };
-		2B66D97C0B1C664300F8C64A /* BaseTenModifications.sql */ = {isa = PBXFileReference; explicitFileType = text; fileEncoding = 5; name = BaseTenModifications.sql; path = ../BaseTenModifications.sql; sourceTree = SOURCE_ROOT; };
+		2B66D97C0B1C664300F8C64A /* BaseTenModifications.sql.m4 */ = {isa = PBXFileReference; explicitFileType = text; fileEncoding = 5; name = BaseTenModifications.sql.m4; path = ../BaseTenModifications.sql.m4; sourceTree = SOURCE_ROOT; };
+		531C016B0E32AEC300E43208 /* BXACurrentVersion.m.m4 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = BXACurrentVersion.m.m4; path = Source/BXACurrentVersion.m.m4; sourceTree = "<group>"; };
 		531DCAB70B52818E00200097 /* MKCAlternativeDataCellColumn.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MKCAlternativeDataCellColumn.h; path = Source/MKCAlternativeDataCellColumn.h; sourceTree = "<group>"; };
 		531DCAB80B52818E00200097 /* MKCAlternativeDataCellColumn.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MKCAlternativeDataCellColumn.m; path = Source/MKCAlternativeDataCellColumn.m; sourceTree = "<group>"; };
 		532F429B0D69B70F009FEDCD /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/MainMenu.xib; sourceTree = "<group>"; };
 		29B97315FDCFA39411CA2CEA /* Other Sources */ = {
 			isa = PBXGroup;
 			children = (
+				531C016B0E32AEC300E43208 /* BXACurrentVersion.m.m4 */,
 				5374E4B60B0D364E000D353D /* Additions.h */,
 				5374E4B70B0D364E000D353D /* Additions.m */,
 				2B66D7D70B1C5CB800F8C64A /* SetupApplication_Prefix.pch */,
 		29B97317FDCFA39411CA2CEA /* Resources */ = {
 			isa = PBXGroup;
 			children = (
-				2B66D97C0B1C664300F8C64A /* BaseTenModifications.sql */,
+				2B66D97C0B1C664300F8C64A /* BaseTenModifications.sql.m4 */,
 				8D1107310486CEB800E47090 /* Info.plist */,
 				089C165CFE840E0CC02AAC07 /* InfoPlist.strings */,
 				532F429A0D69B70F009FEDCD /* MainMenu.xib */,
 				8D11072E0486CEB800E47090 /* Frameworks */,
 			);
 			buildRules = (
-				53DD5AC90A78D47D00CD5924 /* PBXBuildRule */,
+				531C01780E32AF7900E43208 /* PBXBuildRule */,
 			);
 			dependencies = (
 				5388DE670E23AE6C006CDBD8 /* PBXTargetDependency */,
 			isa = PBXResourcesBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
-				2B66D97D0B1C664300F8C64A /* BaseTenModifications.sql in Resources */,
+				2B66D97D0B1C664300F8C64A /* BaseTenModifications.sql.m4 in Resources */,
 				8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */,
 				536CB9C90B0D217000EBCB39 /* Log32.png in Resources */,
 				536CB9CA0B0D217000EBCB39 /* Inspector32.png in Resources */,
 				53DAF3D00E2BC40200085C3E /* BXAPGInterface.m in Sources */,
 				53425B650E2CD237005F6123 /* MKCStackView.m in Sources */,
 				53C80FEF0E31413300302B3F /* MKCEventPassingTextField.m in Sources */,
+				531C016C0E32AEC300E43208 /* BXACurrentVersion.m.m4 in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

File BaseTenAssistant/English.lproj/MainMenu.xib

 		<string key="IBDocument.HIToolboxVersion">352.00</string>
 		<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
 			<bool key="EncodedWithXMLCoder">YES</bool>
-			<integer value="573"/>
+			<integer value="595"/>
 		</object>
 		<object class="NSArray" key="IBDocument.PluginDependencies">
 			<bool key="EncodedWithXMLCoder">YES</bool>
 											</object>
 											<string key="NSFrame">{{0, 17}, {191, 288}}</string>
 											<reference key="NSSuperview" ref="552675218"/>
+											<reference key="NSNextKeyView" ref="903510436"/>
 											<reference key="NSDocView" ref="903510436"/>
 											<object class="NSColor" key="NSBGColor" id="874207058">
 												<int key="NSColorSpace">6</int>
 											</object>
 											<string key="NSFrameSize">{191, 17}</string>
 											<reference key="NSSuperview" ref="552675218"/>
+											<reference key="NSNextKeyView" ref="457879329"/>
 											<reference key="NSDocView" ref="457879329"/>
 											<reference key="NSBGColor" ref="874207058"/>
 											<int key="NScvFlags">4</int>
 									</object>
 									<string key="NSFrameSize">{206, 305}</string>
 									<reference key="NSSuperview" ref="786131969"/>
+									<reference key="NSNextKeyView" ref="232001951"/>
 									<int key="NSsFlags">16</int>
 									<reference key="NSVScroller" ref="135616931"/>
 									<reference key="NSHScroller" ref="185590363"/>
 											</object>
 											<string key="NSFrame">{{0, 17}, {286, 288}}</string>
 											<reference key="NSSuperview" ref="819491386"/>
+											<reference key="NSNextKeyView" ref="468408091"/>
 											<reference key="NSDocView" ref="468408091"/>
 											<reference key="NSBGColor" ref="874207058"/>
 											<int key="NScvFlags">4</int>
 											</object>
 											<string key="NSFrameSize">{286, 17}</string>
 											<reference key="NSSuperview" ref="819491386"/>
+											<reference key="NSNextKeyView" ref="123496907"/>
 											<reference key="NSDocView" ref="123496907"/>
 											<reference key="NSBGColor" ref="874207058"/>
 											<int key="NScvFlags">4</int>
 									</object>
 									<string key="NSFrame">{{207, 0}, {301, 305}}</string>
 									<reference key="NSSuperview" ref="786131969"/>
+									<reference key="NSNextKeyView" ref="518332610"/>
 									<int key="NSsFlags">16</int>
 									<reference key="NSVScroller" ref="319945358"/>
 									<reference key="NSHScroller" ref="762737495"/>
 									<reference key="NSOnImage" ref="987414617"/>
 									<reference key="NSMixedImage" ref="105564158"/>
 								</object>
+								<object class="NSMenuItem" id="765264690">
+									<reference key="NSMenu" ref="452600950"/>
+									<string key="NSTitle">Upgrade BaseTen Schema</string>
+									<string key="NSKeyEquiv"/>
+									<int key="NSMnemonicLoc">2147483647</int>
+									<reference key="NSOnImage" ref="987414617"/>
+									<reference key="NSMixedImage" ref="105564158"/>
+									<int key="NSTag">5</int>
+								</object>
 								<object class="NSMenuItem" id="713132677">
 									<reference key="NSMenu" ref="452600950"/>
 									<string key="NSTitle">Remove BaseTen Schema</string>
 									<int key="NSMnemonicLoc">2147483647</int>
 									<reference key="NSOnImage" ref="987414617"/>
 									<reference key="NSMixedImage" ref="105564158"/>
-									<int key="NSTag">1</int>
+									<int key="NSTag">4</int>
 								</object>
 							</object>
 						</object>
 					</object>
 					<int key="connectionID">992</int>
 				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<string key="label">upgradeSchema:</string>
+						<reference key="source" ref="1038163843"/>
+						<reference key="destination" ref="765264690"/>
+					</object>
+					<int key="connectionID">994</int>
+				</object>
 			</object>
 			<object class="IBMutableOrderedSet" key="objectRecords">
 				<object class="NSArray" key="orderedObjects">
 							<reference ref="127461706"/>
 							<reference ref="374225419"/>
 							<reference ref="713132677"/>
+							<reference ref="765264690"/>
 						</object>
 						<reference key="parent" ref="1011302266"/>
 					</object>
 						<reference key="object" ref="726096961"/>
 						<reference key="parent" ref="941234970"/>
 					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">993</int>
+						<reference key="object" ref="765264690"/>
+						<reference key="parent" ref="452600950"/>
+						<string key="objectName">10</string>
+					</object>
 				</object>
 			</object>
 			<object class="NSMutableDictionary" key="flattenedProperties">
 					<string>973.ImportedFromIB2</string>
 					<string>974.IBPluginDependency</string>
 					<string>974.ImportedFromIB2</string>
+					<string>993.IBPluginDependency</string>
+					<string>993.ImportedFromIB2</string>
 				</object>
 				<object class="NSMutableArray" key="dict.values">
 					<bool key="EncodedWithXMLCoder">YES</bool>
 					<string>{{923, 941}, {232, 23}}</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<string>{{163, 692}, {251, 133}}</string>
+					<string>{{164, 672}, {255, 153}}</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
 					<string>{{766, 811}, {235, 153}}</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>{{205, 582}, {243, 243}}</string>
+					<string>{{206, 582}, {243, 243}}</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+					<reference ref="9"/>
 				</object>
 			</object>
 			<object class="NSMutableDictionary" key="unlocalizedProperties">
 				</object>
 			</object>
 			<nil key="sourceID"/>
-			<int key="maxID">992</int>
+			<int key="maxID">994</int>
 		</object>
 		<object class="IBClassDescriber" key="IBDocument.Classes">
 			<object class="NSMutableArray" key="referencedPartialClassDescriptions">
 							<string>dismissMomcErrorPanel:</string>
 							<string>displayLogWindow:</string>
 							<string>importDataModel:</string>
-							<string>installSchema:</string>
 							<string>reload:</string>
 							<string>removeSchema:</string>
 							<string>terminate:</string>
 							<string>id</string>
 							<string>id</string>
 							<string>id</string>
-							<string>id</string>
 						</object>
 					</object>
 					<object class="NSMutableDictionary" key="outlets">

File BaseTenAssistant/Source/BXAController.h

 - (IBAction) displayLogWindow: (id) sender;
 - (IBAction) reload: (id) sender;
 
-- (IBAction) installSchema: (id) sender;
 - (IBAction) upgradeSchema: (id) sender;
 - (IBAction) removeSchema: (id) sender;
 @end

File BaseTenAssistant/Source/BXAController.m

 #import <RegexKit/RegexKit.h>
 
 
+extern NSNumber* BXACopyBundledVersionNumber ();
+extern NSNumber* BXACopyBundledCompatibilityVersionNumber ();
+
+
 static NSString* kBXAControllerCtx = @"kBXAControllerCtx";
 static NSString* kBXAControllerErrorDomain = @"kBXAControllerErrorDomain";
 
 	NSDictionary* entities = [mContext entitiesBySchemaAndName: YES error: NULL];
 	[mEntitiesBySchema setContent: entities];
 }
+
+- (BOOL) canUpgradeSchema
+{
+	//FIXME: make me work.
+	return NO;
+}
+
+- (BOOL) canRemoveSchema
+{
+	return [[[(BXPGInterface *) [mContext databaseInterface] transactionHandler] 
+			 databaseDescription] hasBaseTenSchema];
+}
 @end
 
 
 			retval = [self hasBaseTenSchema];
 			break;
 			
+		case 4: //Remove schema
+			retval = [self canRemoveSchema];
+			break;
+			
+		case 5: //Upgrade schema
+			retval = [self canUpgradeSchema];
+			break;
+			
     }
 	if (nil != [mMainWindow attachedSheet])
 		retval = NO;
 	[mReader cancel];
 }
 
-- (IBAction) installSchema: (id) sender
-{
-	//FIXME: make me work.
-}
-
 - (IBAction) upgradeSchema: (id) sender
 {
 	//FIXME: make me work.

File BaseTenAssistant/Source/BXACurrentVersion.m.m4

+//
+// BXACurrentVersion.m.m4
+// BaseTen Setup
+//
+// Copyright (C) 2006-2008 Marko Karppinen & Co. LLC.
+//
+// Before using this software, please review the available licensing options
+// by visiting http://basetenframework.org/licensing/ or by contacting
+// us at sales@karppinen.fi. Without an additional license, this software
+// may be distributed only in compliance with the GNU General Public License.
+//
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License, version 2.0,
+// as published by the Free Software Foundation.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+// $Id$
+//
+
+#import <Foundation/Foundation.h>
+
+divert(-1)
+include(`../BaseTenModifications.sql.m4')
+divert(0)dnl
+
+NSNumber*
+BXACopyBundledVersionNumber ()
+{
+    return [[NSNumber alloc] initWithString: @"_bx_version_"];
+}
+
+NSNumber*
+BXACopyBundledCompatibilityVersionNumber ()
+{
+    return [[NSNumber alloc] initWithString: @"_bx_compat_version_"];
+}
+