From: <mcu...@us...> - 2007-08-15 01:44:13
|
Revision: 1084 http://orm.svn.sourceforge.net/orm/?rev=1084&view=rev Author: mcurland Date: 2007-08-14 18:44:14 -0700 (Tue, 14 Aug 2007) Log Message: ----------- Initial batch file changes to enable building NORMA for Visual Studio 2008 (formerly Code Name "Orcas"). Minor tweaks to NUBuild to use VSCT v3.5 if running in MSBuild v3.5, and to account for item name changes in Microsoft.Common.targets. refs #337 refs #193 refs #320 refs #278 Modified Paths: -------------- trunk/FirstTimeBuildAll.bat trunk/SetupEnvironment.bat trunk/Tools/DisableRuleDirectiveProcessor/Install.bat trunk/Tools/NUBuild/Install.bat trunk/Tools/NUBuild/Neumont.Build.targets trunk/Tools/ORMCustomTool/Install.bat trunk/install.bat Modified: trunk/FirstTimeBuildAll.bat =================================================================== --- trunk/FirstTimeBuildAll.bat 2007-08-15 01:37:14 UTC (rev 1083) +++ trunk/FirstTimeBuildAll.bat 2007-08-15 01:44:14 UTC (rev 1084) @@ -3,15 +3,21 @@ SET RootDir=%~dp0. CALL "%RootDir%\SetupEnvironment.bat" %* +:: Normally, the next two lines would have parentheses around the command portions. However, it is possible +:: for there to be parentheses in the %VSIPDir% path (and there are by default on x64), which +:: causes a syntax error. Therefore, we leave the parentheses off here. +IF "%TargetVisualStudioNumericVersion%"=="8.0" SET VsSDKVsctDir=%VSIPDir%\Prerelease\VSCT +IF NOT DEFINED VsSDKVsctDir SET VsSDKVsctDir=%VSIPDir%\VisualStudioIntegration\Tools\Bin + :: GAC the VSCT compiler so that we can use it. -SET VsSDKVsctDir=%VSIPDir%\Prerelease\VSCT gacutil.exe /nologo /f /i "%VsSDKVsctDir%\VSCTCompress.dll" gacutil.exe /nologo /f /i "%VsSDKVsctDir%\VSCTLibrary.dll" gacutil.exe /nologo /f /i "%VsSDKVsctDir%\VSCT.exe" +:: As of the August 2007 release of the VsSDK, the VSCTCompress assembly is still versioned as 8.0.0.0. ngen.exe install "VSCTCompress, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /NoDependencies /nologo -ngen.exe install "VSCTLibrary, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /NoDependencies /nologo -ngen.exe install "VSCT, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /NoDependencies /nologo +ngen.exe install "VSCTLibrary, Version=%TargetVisualStudioNumericVersion%.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /NoDependencies /nologo +ngen.exe install "VSCT, Version=%TargetFrameworkNumericVersion%.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /NoDependencies /nologo MSBuild.exe /nologo "%RootDir%\Tools\NUBuild\NUBuild.sln" %* MSBuild.exe /nologo "%RootDir%\Tools\DisableRuleDirectiveProcessor\DisableRuleDirectiveProcessor.sln" %* Modified: trunk/SetupEnvironment.bat =================================================================== --- trunk/SetupEnvironment.bat 2007-08-15 01:37:14 UTC (rev 1083) +++ trunk/SetupEnvironment.bat 2007-08-15 01:44:14 UTC (rev 1084) @@ -2,8 +2,15 @@ IF "%~1"=="" (SET BuildOutDir=bin\Debug) ELSE (SET BuildOutDir=%~1.) -IF NOT DEFINED FrameworkSDKDir (CALL:_SetupVsVars) +:: TargetVisualStudioNumericVersion settings: +:: 8.0 = Visual Studio 2005 (Code Name "Whidbey") +:: 9.0 = Visual Studio 2008 (Code Name "Orcas") +SET TargetVisualStudioNumericVersion=8.0 +IF "%TargetVisualStudioNumericVersion%"=="9.0" (SET TargetFrameworkNumericVersion=3.5) ELSE (SET TargetFrameworkNumericVersion=2.0) + +IF NOT DEFINED FrameworkDir (CALL:_SetupVsVars) + :: Normally, the next line would have parentheses around the command portion. However, it is possible :: for there to be parentheses in the %ProgramFiles% path (and there are by default on x64), which :: causes a syntax error. Therefore, we leave the parentheses off here. @@ -19,23 +26,22 @@ SET DILTransformsDir=%DILDir%\Transforms SET VSRegistryRootBase=SOFTWARE\Microsoft\VisualStudio -:: VSRegistryRootVersion settings: -:: 8.0 = Visual Studio 2005 (Code Name "Whidbey") -:: 9.0 = Visual Studio Code Name "Orcas" -SET VSRegistryRootVersion=8.0 +SET VSRegistryRootVersion=%TargetVisualStudioNumericVersion% +:: Remove the value "Exp" on the next line if you want installations to be performed against the +:: regular (non-Experimental) Visual Studio registry hive SET VSRegistryRootSuffix=Exp SET VSRegistryRoot=%VSRegistryRootBase%\%VSRegistryRootVersion%%VSRegistryRootSuffix% FOR /F "usebackq skip=2 tokens=2*" %%A IN (`REG QUERY "HKLM\%VSRegistryRoot%\Setup\VS" /v "EnvironmentPath"`) DO SET VSEnvironmentPath=%%~fB FOR /F "usebackq skip=2 tokens=2*" %%A IN (`REG QUERY "HKLM\%VSRegistryRoot%\Setup\VS" /v "ProductDir"`) DO SET VSDir=%%~fB FOR /F "usebackq skip=2 tokens=2*" %%A IN (`REG QUERY "HKLM\%VSRegistryRoot%\VSTemplate\Item" /v "UserFolder"`) DO SET VSItemTemplatesDir=%%~fB -FOR /F "usebackq skip=2 tokens=2*" %%A IN (`REG QUERY "HKLM\%VSRegistryRootBase%\VSIP\8.0" /v "InstallDir"`) DO SET VSIPDir=%%~fB -SET RegPkg="%VSIPDir%\VisualStudioIntegration\Tools\Bin\regpkg.exe" /root:"%VSRegistryRoot%" +FOR /F "usebackq skip=2 tokens=2*" %%A IN (`REG QUERY "HKLM\%VSRegistryRootBase%\VSIP\%VSRegistryRootVersion%" /v "InstallDir"`) DO SET VSIPDir=%%~fB +IF "%TargetVisualStudioNumericVersion%"=="9.0" (SET RegPkg="%VSIPDir%\VisualStudioIntegration\Tools\Bin\VS2005\regpkg.exe" /root:"%VSRegistryRoot%") ELSE (SET RegPkg="%VSIPDir%\VisualStudioIntegration\Tools\Bin\regpkg.exe" /root:"%VSRegistryRoot%") GOTO:EOF :_SetupVsVars -:: Set up the build environment to use Orcas if available, falling back to 2005 otherwise. -IF DEFINED VS90COMNTOOLS (CALL "%VS90COMNTOOLS%\vsvars32.bat") ELSE (CALL "%VS80COMNTOOLS%\vsvars32.bat") +:: Set up the build environment. +CALL "%%VS%TargetVisualStudioNumericVersion:.=%COMNTOOLS%%\vsvars32.bat" GOTO:EOF Modified: trunk/Tools/DisableRuleDirectiveProcessor/Install.bat =================================================================== --- trunk/Tools/DisableRuleDirectiveProcessor/Install.bat 2007-08-15 01:37:14 UTC (rev 1083) +++ trunk/Tools/DisableRuleDirectiveProcessor/Install.bat 2007-08-15 01:44:14 UTC (rev 1084) @@ -5,8 +5,8 @@ SET BinDir=%RootDir%\bin -CALL:_AddTextTemplateReg "8.0" "DisableRuleDirectiveProcessor" -IF NOT "%VSRegistryRootSuffix%"=="" (CALL:_AddTextTemplateReg "8.0%VSRegistryRootSuffix%" "DisableRuleDirectiveProcessor") +CALL:_AddTextTemplateReg "%VSRegistryRootVersion%" "DisableRuleDirectiveProcessor" +IF NOT "%VSRegistryRootSuffix%"=="" (CALL:_AddTextTemplateReg "%VSRegistryRootVersion%%VSRegistryRootSuffix%" "DisableRuleDirectiveProcessor") GOTO:EOF @@ -15,4 +15,3 @@ REG ADD "HKLM\%VSRegistryRootBase%\%~1\TextTemplating\DirectiveProcessors\%~2" /f /v "Class" /d "Neumont.Tools.Modeling.%~2" REG ADD "HKLM\%VSRegistryRootBase%\%~1\TextTemplating\DirectiveProcessors\%~2" /f /v "CodeBase" /d "%BinDir%\Neumont.Tools.Modeling.DisableRuleDirectiveProcessor.dll" GOTO:EOF - Modified: trunk/Tools/NUBuild/Install.bat =================================================================== --- trunk/Tools/NUBuild/Install.bat 2007-08-15 01:37:14 UTC (rev 1083) +++ trunk/Tools/NUBuild/Install.bat 2007-08-15 01:44:14 UTC (rev 1084) @@ -11,8 +11,8 @@ XCOPY /Y /D /V /Q "%RootDir%\Tasks\RegexCompilationInfo.xsd" "%VSDir%\Xml\Schemas\" XCOPY /Y /D /V /Q "%RootDir%\Neumont.Build.targets" "%MSBuildExtensionsPath%\Neumont\" -REG ADD "HKLM\%VSRegistryRootBase%\8.0\MSBuild\SafeImports" /v "NUBuild1" /d "%MSBuildExtensionsPath%\Neumont\Neumont.Build.targets" /f -IF NOT "%VSRegistryRootSuffix%"=="" (REG ADD "HKLM\%VSRegistryRootBase%\8.0%VSRegistryRootSuffix%\MSBuild\SafeImports" /v "NUBuild1" /d "%MSBuildExtensionsPath%\Neumont\Neumont.Build.targets" /f) +REG ADD "HKLM\%VSRegistryRootBase%\%VSRegistryRootVersion%\MSBuild\SafeImports" /v "NUBuild1" /d "%MSBuildExtensionsPath%\Neumont\Neumont.Build.targets" /f +IF NOT "%VSRegistryRootSuffix%"=="" (REG ADD "HKLM\%VSRegistryRootBase%\%VSRegistryRootVersion%%VSRegistryRootSuffix%\MSBuild\SafeImports" /v "NUBuild1" /d "%MSBuildExtensionsPath%\Neumont\Neumont.Build.targets" /f) gacutil.exe /nologo /f /i "%RootDir%\bin\Neumont.Build.dll" ngen.exe install "Neumont.Build, Version=1.0.0.0, Culture=neutral, PublicKeyToken=957d5b7d5e79e25f" /NoDependencies /nologo /verbose Modified: trunk/Tools/NUBuild/Neumont.Build.targets =================================================================== --- trunk/Tools/NUBuild/Neumont.Build.targets 2007-08-15 01:37:14 UTC (rev 1083) +++ trunk/Tools/NUBuild/Neumont.Build.targets 2007-08-15 01:44:14 UTC (rev 1084) @@ -188,9 +188,10 @@ DependsOnTargets="$(_ResolveResourceMergeTargetsDependsOn)" Condition="'@(MergeResource)'!=''"> + <!-- In MSBuild v3.5, _CoreCompileResourceInputs and _SatelliteAssemblyResourceInputs replace ManifestResourceWithNoCulture and ManifestResourceWithCulture, respectively.--> <ResourceMergeTargetResolver MergeResources="@(MergeResource)" - ManifestResources="@(ManifestResourceWithCulture);@(ManifestResourceWithNoCulture)"> + ManifestResources="@(ManifestResourceWithCulture);@(ManifestResourceWithNoCulture);@(_CoreCompileResourceInputs);@(_SatelliteAssemblyResourceInputs)"> <Output TaskParameter="MergeResourcesWithResolvedTargets" ItemName="_MergeResourceWithResolvedTarget"/> </ResourceMergeTargetResolver> @@ -252,9 +253,14 @@ </Target> + <PropertyGroup> + <!-- HACK: BuildInParallel is a new property in MSBuild 3.5. If it is present, we can (for now) assume that we want to use the 3.5 version of VSCT. --> + <VsctAssemblyVersion Condition="'$(VsctAssemblyVersion)'=='' and '$(BuildInParallel)'!=''">3.5.0.0</VsctAssemblyVersion> + <VsctAssemblyVersion Condition="'$(VsctAssemblyVersion)'==''">2.0.0.0</VsctAssemblyVersion> + </PropertyGroup> <!-- Compiles .vsct files into .cto files. --> - <UsingTask TaskName="VSCTCompiler" AssemblyName="VSCT, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/> + <UsingTask TaskName="VSCTCompiler" AssemblyName="VSCT, Version=$(VsctAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/> <ItemGroup> <!-- Add the CompileVsct Item name to the AvailableItemName item, so that it shows up in the Build Action drop-down menu in the properties windows in Visual Studio (and the equivalent in other IDEs). --> <AvailableItemName Include="CompileVsct"/> Modified: trunk/Tools/ORMCustomTool/Install.bat =================================================================== --- trunk/Tools/ORMCustomTool/Install.bat 2007-08-15 01:37:14 UTC (rev 1083) +++ trunk/Tools/ORMCustomTool/Install.bat 2007-08-15 01:44:14 UTC (rev 1084) @@ -16,10 +16,10 @@ XCOPY /Y /D /V /Q "%~dp0\bin\Neumont.Tools.ORM.ORMCustomTool.pdb" "%NORMADir%\bin\" :: For some reason, the next copy is randomly giving errors about half the time. They can be safely ignored, so they've been redirected to NUL. XCOPY /Y /D /V /Q "%~dp0\bin\Neumont.Tools.ORM.ORMCustomTool.xml" "%NORMADir%\bin\" 2>NUL -CALL:_InstallCustomToolReg "8.0" -CALL:_InstallExtenderReg "8.0" -IF NOT "%VSRegistryRootSuffix%"=="" (CALL:_InstallCustomToolReg "8.0%VSRegistryRootSuffix%") -IF NOT "%VSRegistryRootSuffix%"=="" (CALL:_InstallExtenderReg "8.0%VSRegistryRootSuffix%") +CALL:_InstallCustomToolReg "%VSRegistryRootVersion%" +CALL:_InstallExtenderReg "%VSRegistryRootVersion%" +IF NOT "%VSRegistryRootSuffix%"=="" (CALL:_InstallCustomToolReg "%VSRegistryRootVersion%%VSRegistryRootSuffix%") +IF NOT "%VSRegistryRootSuffix%"=="" (CALL:_InstallExtenderReg "%VSRegistryRootVersion%%VSRegistryRootSuffix%") :: Get rid of old transform registrations REG DELETE "HKLM\SOFTWARE\Neumont\ORM Architect for Visual Studio\Generators" /f 1>NUL 2>&1 Modified: trunk/install.bat =================================================================== --- trunk/install.bat 2007-08-15 01:37:14 UTC (rev 1083) +++ trunk/install.bat 2007-08-15 01:44:14 UTC (rev 1084) @@ -106,7 +106,7 @@ REG ADD "HKCR\ormfile\shell\open" /ve /d "&Open" /f 1>NUL REG ADD "HKCR\ormfile\shell\open\command" /ve /d "\"%VSEnvironmentPath%\" /RootSuffix \"%VSRegistryRootSuffix%\" /dde \"%%1\"" /f 1>NUL REG ADD "HKCR\ormfile\shell\open\ddeexec" /ve /d "Open(\"%%1\")" /f 1>NUL -REG ADD "HKCR\ormfile\shell\open\ddeexec\application" /ve /d "VisualStudio.8.0" /f 1>NUL +REG ADD "HKCR\ormfile\shell\open\ddeexec\application" /ve /d "VisualStudio.%TargetVisualStudioNumericVersion%" /f 1>NUL REG ADD "HKCR\ormfile\shell\open\ddeexec\topic" /ve /d "system" /f 1>NUL This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mcu...@us...> - 2007-08-20 22:13:27
|
Revision: 1092 http://orm.svn.sourceforge.net/orm/?rev=1092&view=rev Author: mcurland Date: 2007-08-20 15:13:30 -0700 (Mon, 20 Aug 2007) Log Message: ----------- Cleaned up the ForeignKey generation to check that it's mapping to the correct targetColumn. Implemented initial mandatory constraint mapping to columns refs #328. Modified Paths: -------------- trunk/ORMModel/ORMModel.csproj trunk/RelationalModel/OialDcilBridge/OialDcilBridge.DeserializationFixupListeners.cs Modified: trunk/ORMModel/ORMModel.csproj =================================================================== --- trunk/ORMModel/ORMModel.csproj 2007-08-20 22:09:33 UTC (rev 1091) +++ trunk/ORMModel/ORMModel.csproj 2007-08-20 22:13:30 UTC (rev 1092) @@ -716,10 +716,6 @@ <SubType>Designer</SubType> <DesignTime>True</DesignTime> </EmbeddedResource> - <EmbeddedResource Include="Shell\ExtensionManager.resx"> - <SubType>Designer</SubType> - <DependentUpon>ExtensionManager.cs</DependentUpon> - </EmbeddedResource> <EmbeddedResource Include="Shell\PackageResources\VSPackage.resx"> <LogicalName>VSPackage.resources</LogicalName> <SubType>Designer</SubType> Modified: trunk/RelationalModel/OialDcilBridge/OialDcilBridge.DeserializationFixupListeners.cs =================================================================== --- trunk/RelationalModel/OialDcilBridge/OialDcilBridge.DeserializationFixupListeners.cs 2007-08-20 22:09:33 UTC (rev 1091) +++ trunk/RelationalModel/OialDcilBridge/OialDcilBridge.DeserializationFixupListeners.cs 2007-08-20 22:13:30 UTC (rev 1092) @@ -182,6 +182,8 @@ { CreateForeignKeys(table, store); } + + GenerateAllMandatoryConstraints(schema); } /// <summary> @@ -810,12 +812,42 @@ } } } + // Walk the assimililating path looking for possible relationships that may hold the key. if (columns.Count == 0) { InformationType matchingBaseType = ColumnHasConceptTypeChild.GetConceptTypeChildPath(column)[ColumnHasConceptTypeChild.GetConceptTypeChildPath(column).Count - 1] as InformationType; + LinkedElementCollection<ConceptType> assimilations; + while (columns.Count == 0 && (assimilations = conceptType.AssimilatorConceptTypeCollection).Count != 0) + { + conceptType = assimilations[0]; + + Table targetTable = TableIsPrimarilyForConceptType.GetTable(conceptType); + + //LinkedElementCollection<ConceptType> relating = ConceptTypeRelatesToConceptType.GetRelatingConceptTypeCollection(conceptType); + //int relatingCount = relating.Count; + //ConceptType[] real = new ConceptType[] { relatingCount }; + //relating.CopyTo(real, 0); + + if (targetTable != null) + { + foreach (Column possibleColumn in targetTable.ColumnCollection) + { + if (ColumnHasConceptTypeChild.GetConceptTypeChildPath(possibleColumn)[ColumnHasConceptTypeChild.GetConceptTypeChildPath(possibleColumn).Count - 1] == matchingBaseType) + { + columns.Add(possibleColumn); + } + } + } + } + } + + if(columns.Count == 0) + { + InformationType matchingBaseType = ColumnHasConceptTypeChild.GetConceptTypeChildPath(column)[ColumnHasConceptTypeChild.GetConceptTypeChildPath(column).Count - 1] as InformationType; LinkedElementCollection<ConceptType> assimilations; + while (columns.Count == 0 && (assimilations = conceptType.AssimilatorConceptTypeCollection).Count != 0) { conceptType = assimilations[0]; @@ -913,61 +945,63 @@ } } - //LinkedElementCollection<ConceptType> relating = ConceptTypeRelatesToConceptType.GetRelatingConceptTypeCollection(conceptType); //int relatingCount = relating.Count; //ConceptType[] real = new ConceptType[] { relatingCount }; //relating.CopyTo(real, 0); + List<Column> possibleColumns = ConceptTypeHasPrimaryIdentifierColumns(column, conceptType); - foreach (Column targetColumn in ConceptTypeHasPrimaryIdentifierColumns(column, conceptType)) + foreach (Column targetColumn in possibleColumns) { targetFound = true; - int offset = 0; - - for (int i = 0; i < ColumnHasConceptTypeChild.GetConceptTypeChildPath(targetColumn).Count; ++i) + if (targetColumn.Equals(column)) { - LinkedElementCollection<ConceptTypeChild> leftPath = ColumnHasConceptTypeChild.GetConceptTypeChildPath(column); - LinkedElementCollection<ConceptTypeChild> rightPath = ColumnHasConceptTypeChild.GetConceptTypeChildPath(targetColumn); - - // Look through the target path and find the first information type and set its index as the offset. - for (int j = 0; j < rightPath.Count; ++j) + targetFound = false; + } + else + { + for (int i = 0; i < ColumnHasConceptTypeChild.GetConceptTypeChildPath(targetColumn).Count; ++i) { - if (rightPath[j].GetType() == typeof(InformationType)) - { - offset = j; - } - } + LinkedElementCollection<ConceptTypeChild> leftPath = ColumnHasConceptTypeChild.GetConceptTypeChildPath(column); + LinkedElementCollection<ConceptTypeChild> rightPath = ColumnHasConceptTypeChild.GetConceptTypeChildPath(targetColumn); - // UNDONE Decimal comparision operator ID is breaking here, possibly because it is attempting to map downward, it's an odd FK. good tester - // UNDONE This may also be a part of the reason why we have some FK's that arn't mapping and are apearing outside of the column. - // TEST - if (leftPath.Count >= rightPath.Count) - { - for (int reverseIndex = rightPath.Count - 1; reverseIndex < 0; reverseIndex++) + // Look through the target path and find the first information type and set its index as the offset. + //for (int j = 0; j < rightPath.Count; ++j) + //{ + // if (rightPath[j].GetType() == typeof(InformationType)) + // { + // offset = j; + // } + //} + + // UNDONE Decimal comparision operator ID is breaking here, possibly because it is attempting to map downward, it's an odd FK. good tester + // UNDONE This may also be a part of the reason why we have some FK's that arn't mapping and are apearing outside of the column. + // TEST + if (leftPath.Count >= rightPath.Count) { - if (rightPath[reverseIndex] != leftPath[reverseIndex]) + for (int reverseIndex = 0; reverseIndex < rightPath.Count; reverseIndex++) { - targetFound = false; - break; + if (rightPath[rightPath.Count - 1 - reverseIndex] != leftPath[leftPath.Count - 1 - reverseIndex]) + { + targetFound = false; + break; + } + } - } - } - else - { - for (int reverseIndex = leftPath.Count - 1; reverseIndex < 0; reverseIndex++) + else { - if (leftPath[reverseIndex] != rightPath[reverseIndex]) + for (int reverseIndex = 0; reverseIndex < leftPath.Count; reverseIndex++) { - targetFound = false; - break; + if (leftPath[leftPath.Count - 1 - reverseIndex] != rightPath[rightPath.Count - 1 - reverseIndex]) + { + targetFound = false; + break; + } } } - - } - // END TEST //if ((i + 1 < leftPath.Count && i + offset < rightPath.Count && @@ -1146,6 +1180,32 @@ return null; } + /// <summary> + /// + /// </summary> + /// <param name="schema"></param> + private static void GenerateAllMandatoryConstraints(Schema schema) + { + foreach (Table table in schema.TableCollection) + { + foreach (Column column in table.ColumnCollection) + { + CheckColumnConstraint(column); + } + } + } + + private static void CheckColumnConstraint(Column column) + { + foreach (ConceptTypeChild concept in ColumnHasConceptTypeChild.GetConceptTypeChildPath(column)) + { + if (!concept.IsMandatory) + { + column.IsNullable = true; + } + } + } + #endregion // Fully populate from OIAL #region IDeserializationFixupListenerProvider Implementation /// <summary> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mcu...@us...> - 2007-08-20 22:24:43
|
Revision: 1094 http://orm.svn.sourceforge.net/orm/?rev=1094&view=rev Author: mcurland Date: 2007-08-20 15:24:39 -0700 (Mon, 20 Aug 2007) Log Message: ----------- Added ability to bold items in the model browser. refs #268 Added bolding for non-nullable columns, overlays for primary identifier columns, and sorted primary columns to the top of the column list. refs #328 Modified Paths: -------------- trunk/ORMModel/Framework/Shell/DynamicSurveyTreeGrid/MainList.cs trunk/ORMModel/Framework/Shell/DynamicSurveyTreeGrid/SurveyInterfaces.cs trunk/ORMModel/ObjectModel/ORMCore.SurveyQuestionProvider.cs trunk/ORMModel/Transforms/SurveyQuestionProvider.xsd trunk/ORMModel/Transforms/SurveyQuestionProvider.xslt trunk/RelationalModel/DcilModel/DcilModel.SurveyQuestionProvider.cs trunk/RelationalModel/DcilModel/DcilModel.SurveyQuestionProvider.xml trunk/RelationalModel/DcilModel/Resources/SurveyTree.ImageStrip.png trunk/RelationalModel/DcilModel/SurveyImplementations/SurveyQuestions.cs Modified: trunk/ORMModel/Framework/Shell/DynamicSurveyTreeGrid/MainList.cs =================================================================== --- trunk/ORMModel/Framework/Shell/DynamicSurveyTreeGrid/MainList.cs 2007-08-20 22:18:31 UTC (rev 1093) +++ trunk/ORMModel/Framework/Shell/DynamicSurveyTreeGrid/MainList.cs 2007-08-20 22:24:39 UTC (rev 1094) @@ -317,35 +317,50 @@ for (int i = 0; i < questionCount; i++) { SurveyQuestion question = mySurvey[i]; - if (0 != (question.Question.UISupport & SurveyQuestionUISupport.Glyph)) + ISurveyQuestionTypeInfo questionInfo = question.Question; + SurveyQuestionUISupport support = questionInfo.UISupport; + if (0 != (support & (SurveyQuestionUISupport.Glyph | SurveyQuestionUISupport.Overlay | SurveyQuestionUISupport.DisplayData))) { - int answer; - if (image == -1 && - SurveyQuestion.NeutralAnswer != (answer = myCurrentDisplays[i].Question.ExtractAnswer(nodeData)) && - 0 <= (image = question.Question.MapAnswerToImageIndex(answer))) + int answer = myCurrentDisplays[i].Question.ExtractAnswer(nodeData); + if (answer != SurveyQuestion.NeutralAnswer) { - image += question.ProviderImageListOffset; - } - } - else if (0 != (question.Question.UISupport & SurveyQuestionUISupport.Overlay)) - { - int answer; - if (SurveyQuestion.NeutralAnswer != (answer = myCurrentDisplays[i].Question.ExtractAnswer(nodeData)) && - 0 <= (answer = question.Question.MapAnswerToImageIndex(answer))) - { - if (overlayImage == -1) + // Extract image and overlay support + if (0 != (support & SurveyQuestionUISupport.Glyph)) { - overlayImage = answer + question.ProviderImageListOffset; + if (image == -1 && + 0 <= (image = questionInfo.MapAnswerToImageIndex(answer))) + { + image += question.ProviderImageListOffset; + } } - else + else if (0 != (support & SurveyQuestionUISupport.Overlay)) { - if (overlayBitField == -1) + int answerImage = questionInfo.MapAnswerToImageIndex(answer); + if (0 <= answerImage) { - overlayBitField = 0; - AddToOverlayList(overlayImage, ref overlayBitField); + if (overlayImage == -1) + { + overlayImage = answerImage + question.ProviderImageListOffset; + } + else + { + if (overlayBitField == -1) + { + overlayBitField = 0; + AddToOverlayList(overlayImage, ref overlayBitField); + } + AddToOverlayList(answerImage + question.ProviderImageListOffset, ref overlayBitField); + } } - AddToOverlayList(answer + question.ProviderImageListOffset, ref overlayBitField); } + + // Extract other display settings + if (0 != (support & SurveyQuestionUISupport.DisplayData)) + { + SurveyQuestionDisplayData displayData = questionInfo.GetDisplayData(answer); + retVal.Bold = displayData.Bold; + retVal.GrayText = displayData.GrayText; + } } } } Modified: trunk/ORMModel/Framework/Shell/DynamicSurveyTreeGrid/SurveyInterfaces.cs =================================================================== --- trunk/ORMModel/Framework/Shell/DynamicSurveyTreeGrid/SurveyInterfaces.cs 2007-08-20 22:18:31 UTC (rev 1093) +++ trunk/ORMModel/Framework/Shell/DynamicSurveyTreeGrid/SurveyInterfaces.cs 2007-08-20 22:24:39 UTC (rev 1094) @@ -56,6 +56,11 @@ /// <see cref="ISurveyQuestionTypeInfo.MapAnswerToImageIndex"/> method. /// </summary> Overlay = 8, + /// <summary> + /// Question supports additional display settings with the + /// <see cref="ISurveyQuestionTypeInfo.GetDisplayData"/> method. + /// </summary> + DisplayData = 0x10, } #endregion // SurveyQuestionUISupport enum #region ISurveyQuestionProvider interface @@ -86,6 +91,61 @@ IEnumerable<Type> GetErrorDisplayTypes(); } #endregion // ISurveyQuestionProvider interface + #region SurveyQuestionDisplayData structure + /// <summary> + /// Associate additional display information with this question. + /// Used by the <see cref="ISurveyQuestionTypeInfo.GetDisplayData"/> method. + /// </summary> + public struct SurveyQuestionDisplayData + { + private bool myIsBold; + private bool myIsGrayText; + /// <summary> + /// Default display settings + /// </summary> + public static readonly SurveyQuestionDisplayData Default = new SurveyQuestionDisplayData(); + /// <summary> + /// Create a new <see cref="SurveyQuestionDisplayData"/> + /// </summary> + /// <param name="isBold">Display text as bold</param> + /// <param name="isGrayText">Display text as gray text</param> + public SurveyQuestionDisplayData(bool isBold, bool isGrayText) + { + myIsBold = isBold; + myIsGrayText = isGrayText; + } + /// <summary> + /// Return <see langword="true"/> if these are the default settings + /// </summary> + public bool IsDefault + { + get + { + return !(myIsBold || myIsGrayText); + } + } + /// <summary> + /// Should the text display bold? + /// </summary> + public bool Bold + { + get + { + return myIsBold; + } + } + /// <summary> + /// Should the text display gray? + /// </summary> + public bool GrayText + { + get + { + return myIsGrayText; + } + } + } + #endregion // SurveyQuestionDisplayData structure #region ISurveyQuestionTypeInfo interface /// <summary> /// Holds a reference to a specific type of question and method for asking question of objects @@ -114,6 +174,13 @@ /// <returns>0-based index into the image list.</returns> int MapAnswerToImageIndex(int answer); /// <summary> + /// Retrieves additional display information for a given answer. Used only if + /// <see cref="UISupport"/> indicates support for <see cref="SurveyQuestionUISupport.DisplayData"/> + /// </summary> + /// <param name="answer">A value from the enum type returned by the <see cref="QuestionType"/> property.</param> + /// <returns><see cref="SurveyQuestionDisplayData"/> settings</returns> + SurveyQuestionDisplayData GetDisplayData(int answer); + /// <summary> /// UISupport for Question /// </summary> SurveyQuestionUISupport UISupport { get;} Modified: trunk/ORMModel/ObjectModel/ORMCore.SurveyQuestionProvider.cs =================================================================== --- trunk/ORMModel/ObjectModel/ORMCore.SurveyQuestionProvider.cs 2007-08-20 22:18:31 UTC (rev 1093) +++ trunk/ORMModel/ObjectModel/ORMCore.SurveyQuestionProvider.cs 2007-08-20 22:24:39 UTC (rev 1094) @@ -82,6 +82,10 @@ { return -1; } + public SurveyQuestionDisplayData GetDisplayData(int answer) + { + return SurveyQuestionDisplayData.Default; + } public SurveyQuestionUISupport UISupport { get @@ -126,6 +130,10 @@ } return retVal; } + public SurveyQuestionDisplayData GetDisplayData(int answer) + { + return SurveyQuestionDisplayData.Default; + } public SurveyQuestionUISupport UISupport { get @@ -160,6 +168,10 @@ { return answer; } + public SurveyQuestionDisplayData GetDisplayData(int answer) + { + return SurveyQuestionDisplayData.Default; + } public SurveyQuestionUISupport UISupport { get @@ -194,6 +206,10 @@ { return -1; } + public SurveyQuestionDisplayData GetDisplayData(int answer) + { + return SurveyQuestionDisplayData.Default; + } public SurveyQuestionUISupport UISupport { get Modified: trunk/ORMModel/Transforms/SurveyQuestionProvider.xsd =================================================================== --- trunk/ORMModel/Transforms/SurveyQuestionProvider.xsd 2007-08-20 22:18:31 UTC (rev 1093) +++ trunk/ORMModel/Transforms/SurveyQuestionProvider.xsd 2007-08-20 22:24:39 UTC (rev 1094) @@ -91,10 +91,65 @@ <xs:sequence> <xs:element ref="displaySupport" maxOccurs="unbounded"/> <xs:element ref="imageMap" minOccurs="0"/> + <xs:element ref="displayDataMap" minOccurs="0"/> </xs:sequence> <xs:attribute name="questionType" type="xs:string" use="required"/> <xs:attribute name="isErrorDisplay" type="xs:boolean" default="false"/> </xs:complexType> + <xs:element name="displayDataMap" type="displayDataMapType"> + <xs:unique name="DisplayDataUnique"> + <xs:selector xpath="qp:displayData | qp:displayDataSameAs"/> + <xs:field xpath="@enumValue"/> + </xs:unique> + <xs:key name="DisplayDataKey"> + <xs:selector xpath="qp:displayData"/> + <xs:field xpath="@enumValue"/> + </xs:key> + <xs:keyref name="DisplayDataSameAsKeyRef" refer="DisplayDataKey"> + <xs:selector xpath="qp:displayDataSameAs"/> + <xs:field xpath="@targetEnumValue"/> + </xs:keyref> + </xs:element> + <xs:complexType name="displayDataMapType"> + <xs:annotation> + <xs:documentation>Associate an answer with different display data settings.</xs:documentation> + </xs:annotation> + <xs:choice maxOccurs="unbounded"> + <xs:element name="displayData"> + <xs:complexType> + <xs:attribute name="enumValue" type="xs:token" use="required"> + <xs:annotation> + <xs:documentation>The value from the questionType enum to associate with these display settings.</xs:documentation> + </xs:annotation> + </xs:attribute> + <xs:attribute name="bold" type="xs:boolean" default="false"> + <xs:annotation> + <xs:documentation>Display answers from this category in bold text</xs:documentation> + </xs:annotation> + </xs:attribute> + <xs:attribute name="gray" type="xs:boolean" default="false"> + <xs:annotation> + <xs:documentation>Display answers from this category in gray text</xs:documentation> + </xs:annotation> + </xs:attribute> + </xs:complexType> + </xs:element> + <xs:element name="displayDataSameAs"> + <xs:complexType> + <xs:attribute name="enumValue" type="xs:token" use="required"> + <xs:annotation> + <xs:documentation>The value from the questionType enum to associate with these display settings.</xs:documentation> + </xs:annotation> + </xs:attribute> + <xs:attribute name="targetEnumValue" type="xs:token" use="required"> + <xs:annotation> + <xs:documentation>This value should have the same display settings as the targeted value.</xs:documentation> + </xs:annotation> + </xs:attribute> + </xs:complexType> + </xs:element> + </xs:choice> + </xs:complexType> <xs:complexType name="imageMapType"/> <xs:element name="imageMap" abstract="true" type="imageMapType"/> <xs:element name="sequentialImageMap" type="sequentialImageMapType" substitutionGroup="imageMap"> @@ -121,24 +176,40 @@ </xs:extension> </xs:complexContent> </xs:complexType> - <xs:element name="explicitImageMap" type="explicitImageMapType" substitutionGroup="imageMap"/> + <xs:element name="explicitImageMap" type="explicitImageMapType" substitutionGroup="imageMap"> + <xs:unique name="ExplicitImageMapUnique"> + <xs:selector xpath="qp:map | qp:mapSameAs"/> + <xs:field xpath="@enumValue"/> + </xs:unique> + <xs:key name="ExplicitImageMapKey"> + <xs:selector xpath="qp:map"/> + <xs:field xpath="@enumValue"/> + </xs:key> + <xs:keyref name="ExplicitImageMapSameAsKeyRef" refer="ExplicitImageMapKey"> + <xs:selector xpath="qp:mapSameAs"/> + <xs:field xpath="@targetEnumValue"/> + </xs:keyref> + </xs:element> <xs:complexType name="explicitImageMapType"> <xs:annotation> <xs:documentation>Enum values in this question type require custom mapping to image indices.</xs:documentation> </xs:annotation> <xs:complexContent> <xs:extension base="imageMapType"> - <xs:sequence> - <xs:element name="map" maxOccurs="unbounded"> + <xs:choice maxOccurs="unbounded"> + <xs:element name="map"> <xs:complexType> <xs:sequence> <xs:any namespace="http://schemas.neumont.edu/CodeGeneration/PLiX" processContents="strict" minOccurs="0"> <xs:annotation> - <xs:documentation>A custom expression. Used if the imageIndex attribute is set to .custom.</xs:documentation> + <xs:documentation>A custom expression. If the imageIndex attribute is set .custom then this expression is used directly. Otherwise, it is added to the imageIndex.</xs:documentation> </xs:annotation> </xs:any> </xs:sequence> <xs:attribute name="imageIndex" use="required"> + <xs:annotation> + <xs:documentation>An non-negative value indicating the index in the image list, or the special .custom value indicating a custom code expression.</xs:documentation> + </xs:annotation> <xs:simpleType> <xs:union memberTypes="xs:nonNegativeInteger"> <xs:simpleType> @@ -153,10 +224,28 @@ </xs:union> </xs:simpleType> </xs:attribute> - <xs:attribute name="enumValue" type="xs:token" use="required"/> + <xs:attribute name="enumValue" type="xs:token" use="required"> + <xs:annotation> + <xs:documentation>The value from the questionType enum to associate with this image.</xs:documentation> + </xs:annotation> + </xs:attribute> </xs:complexType> </xs:element> - </xs:sequence> + <xs:element name="mapSameAs"> + <xs:complexType> + <xs:attribute name="enumValue" type="xs:token" use="required"> + <xs:annotation> + <xs:documentation>The value from the questionType enum to associate with this image.</xs:documentation> + </xs:annotation> + </xs:attribute> + <xs:attribute name="targetEnumValue" type="xs:token" use="required"> + <xs:annotation> + <xs:documentation>This value should have the same image as the other value.</xs:documentation> + </xs:annotation> + </xs:attribute> + </xs:complexType> + </xs:element> + </xs:choice> </xs:extension> </xs:complexContent> </xs:complexType> @@ -185,6 +274,11 @@ <xs:documentation>Answers to this question are used to overlay the list of contents</xs:documentation> </xs:annotation> </xs:enumeration> + <xs:enumeration value="DisplayData"> + <xs:annotation> + <xs:documentation>Answers to this question can be used to retrieve additional display information</xs:documentation> + </xs:annotation> + </xs:enumeration> </xs:restriction> </xs:simpleType> </xs:attribute> Modified: trunk/ORMModel/Transforms/SurveyQuestionProvider.xslt =================================================================== --- trunk/ORMModel/Transforms/SurveyQuestionProvider.xslt 2007-08-20 22:18:31 UTC (rev 1093) +++ trunk/ORMModel/Transforms/SurveyQuestionProvider.xslt 2007-08-20 22:24:39 UTC (rev 1094) @@ -275,6 +275,11 @@ <plx:condition> <plx:callStatic dataTypeName="{$questionType}" name="{@enumValue}" type="field"/> </plx:condition> + <xsl:for-each select="$imageMap/qp:mapSameAs[@targetEnumValue=current()/@enumValue]"> + <plx:condition> + <plx:callStatic dataTypeName="{$questionType}" name="{@enumValue}" type="field"/> + </plx:condition> + </xsl:for-each> <plx:assign> <plx:left> <plx:nameRef name="retVal"/> @@ -285,7 +290,22 @@ <xsl:copy-of select="child::plx:*"/> </xsl:when> <xsl:otherwise> - <plx:value data="{@imageIndex}" type="i4"/> + <xsl:variable name="offset" select="child::plx:*"/> + <xsl:choose> + <xsl:when test="$offset"> + <plx:binaryOperator type="add"> + <plx:left> + <xsl:copy-of select="$offset"/> + </plx:left> + <plx:right> + <plx:value data="{@imageIndex}" type="i4"/> + </plx:right> + </plx:binaryOperator> + </xsl:when> + <xsl:otherwise> + <plx:value data="{@imageIndex}" type="i4"/> + </xsl:otherwise> + </xsl:choose> </xsl:otherwise> </xsl:choose> </plx:right> @@ -316,6 +336,65 @@ </xsl:otherwise> </xsl:choose> </plx:function> + <plx:function name="GetDisplayData" visibility="public"> + <plx:interfaceMember dataTypeName="ISurveyQuestionTypeInfo" memberName="GetDisplayData"/> + <plx:param name="answer" dataTypeName=".i4"/> + <plx:returns dataTypeName="SurveyQuestionDisplayData"/> + <xsl:if test="qp:displaySupport[@displayCategory='DisplayData']"> + <xsl:variable name="displayDataMaps" select="qp:displayDataMap/qp:displayData[(@bold='true' or @bold='1') or (@gray='true' or @gray='1')]"/> + <xsl:if test="$displayDataMaps"> + <xsl:variable name="questionType" select="string(@questionType)"/> + <plx:switch> + <plx:condition> + <plx:cast dataTypeName="{$questionType}"> + <plx:nameRef name="answer" type="parameter"/> + </plx:cast> + </plx:condition> + <xsl:for-each select="$displayDataMaps"> + <plx:case> + <plx:condition> + <plx:callStatic dataTypeName="{$questionType}" name="{@enumValue}" type="field"/> + </plx:condition> + <xsl:for-each select="../qp:displayDataSameAs[@targetEnumValue=current()/@enumValue]"> + <plx:condition> + <plx:callStatic dataTypeName="{$questionType}" name="{@enumValue}" type="field"/> + </plx:condition> + </xsl:for-each> + <plx:return> + <plx:callNew dataTypeName="SurveyQuestionDisplayData"> + <plx:passParam> + <!-- The isBold parameter --> + <xsl:choose> + <xsl:when test="@bold='true' or @bold='1'"> + <plx:trueKeyword/> + </xsl:when> + <xsl:otherwise> + <plx:falseKeyword/> + </xsl:otherwise> + </xsl:choose> + </plx:passParam> + <plx:passParam> + <!-- The isGrayText parameter --> + <xsl:choose> + <xsl:when test="@gray='true' or @gray='1'"> + <plx:trueKeyword/> + </xsl:when> + <xsl:otherwise> + <plx:falseKeyword/> + </xsl:otherwise> + </xsl:choose> + </plx:passParam> + </plx:callNew> + </plx:return> + </plx:case> + </xsl:for-each> + </plx:switch> + </xsl:if> + </xsl:if> + <plx:return> + <plx:callStatic name="Default" dataTypeName="SurveyQuestionDisplayData" type="property"/> + </plx:return> + </plx:function> <plx:property name="UISupport" visibility="public"> <plx:interfaceMember dataTypeName="ISurveyQuestionTypeInfo" memberName="UISupport"/> <plx:returns dataTypeName="SurveyQuestionUISupport"/> Modified: trunk/RelationalModel/DcilModel/DcilModel.SurveyQuestionProvider.cs =================================================================== --- trunk/RelationalModel/DcilModel/DcilModel.SurveyQuestionProvider.cs 2007-08-20 22:18:31 UTC (rev 1093) +++ trunk/RelationalModel/DcilModel/DcilModel.SurveyQuestionProvider.cs 2007-08-20 22:24:39 UTC (rev 1094) @@ -12,7 +12,8 @@ ProvideSurveyQuestionForSurveySchemaChildType.Instance}; private static readonly ISurveyQuestionTypeInfo[] mySurveyQuestionTypeInfo3 = new ISurveyQuestionTypeInfo[]{ ProvideSurveyQuestionForSurveyTableChildType.Instance, - ProvideSurveyQuestionForSurveyTableChildGlyphType.Instance}; + ProvideSurveyQuestionForSurveyTableChildGlyphType.Instance, + ProvideSurveyQuestionForSurveyColumnClassificationType.Instance}; private static readonly ISurveyQuestionTypeInfo[] mySurveyQuestionTypeInfo4 = new ISurveyQuestionTypeInfo[]{ ProvideSurveyQuestionForSurveyReferenceConstraintChildType.Instance}; private static readonly ISurveyQuestionTypeInfo[] mySurveyQuestionTypeInfo5 = new ISurveyQuestionTypeInfo[]{ @@ -96,6 +97,10 @@ { return answer; } + public SurveyQuestionDisplayData GetDisplayData(int answer) + { + return SurveyQuestionDisplayData.Default; + } public SurveyQuestionUISupport UISupport { get @@ -130,6 +135,10 @@ { return ((int)SurveySchemaType.Last + 1) + answer; } + public SurveyQuestionDisplayData GetDisplayData(int answer) + { + return SurveyQuestionDisplayData.Default; + } public SurveyQuestionUISupport UISupport { get @@ -164,6 +173,10 @@ { return -1; } + public SurveyQuestionDisplayData GetDisplayData(int answer) + { + return SurveyQuestionDisplayData.Default; + } public SurveyQuestionUISupport UISupport { get @@ -198,6 +211,10 @@ { return (((int)SurveySchemaType.Last + 1) + ((int)SurveySchemaChildType.Last + 1)) + answer; } + public SurveyQuestionDisplayData GetDisplayData(int answer) + { + return SurveyQuestionDisplayData.Default; + } public SurveyQuestionUISupport UISupport { get @@ -206,6 +223,61 @@ } } } + private sealed class ProvideSurveyQuestionForSurveyColumnClassificationType : ISurveyQuestionTypeInfo + { + private ProvideSurveyQuestionForSurveyColumnClassificationType() + { + } + public static readonly ISurveyQuestionTypeInfo Instance = new ProvideSurveyQuestionForSurveyColumnClassificationType(); + public Type QuestionType + { + get + { + return typeof(SurveyColumnClassificationType); + } + } + public int AskQuestion(object data) + { + IAnswerSurveyQuestion<SurveyColumnClassificationType> typedData = data as IAnswerSurveyQuestion<SurveyColumnClassificationType>; + if (typedData != null) + { + return typedData.AskQuestion(); + } + return -1; + } + public int MapAnswerToImageIndex(int answer) + { + int retVal; + switch ((SurveyColumnClassificationType)answer) + { + case SurveyColumnClassificationType.PrimaryRequired: + case SurveyColumnClassificationType.PrimaryNullable: + retVal = ((((((int)SurveySchemaType.Last + 1) + ((int)SurveySchemaChildType.Last + 1)) + ((int)SurveyTableChildGlyphType.Last + 1)) + ((int)SurveyReferenceConstraintChildType.Last + 1)) + ((int)SurveyUniquenessConstraintChildType.Last + 1)) + 0; + break; + default: + retVal = -1; + break; + } + return retVal; + } + public SurveyQuestionDisplayData GetDisplayData(int answer) + { + switch ((SurveyColumnClassificationType)answer) + { + case SurveyColumnClassificationType.Required: + case SurveyColumnClassificationType.PrimaryRequired: + return new SurveyQuestionDisplayData(true, false); + } + return SurveyQuestionDisplayData.Default; + } + public SurveyQuestionUISupport UISupport + { + get + { + return SurveyQuestionUISupport.Overlay | SurveyQuestionUISupport.DisplayData; + } + } + } private sealed class ProvideSurveyQuestionForSurveyReferenceConstraintChildType : ISurveyQuestionTypeInfo { private ProvideSurveyQuestionForSurveyReferenceConstraintChildType() @@ -232,6 +304,10 @@ { return ((((int)SurveySchemaType.Last + 1) + ((int)SurveySchemaChildType.Last + 1)) + ((int)SurveyTableChildGlyphType.Last + 1)) + answer; } + public SurveyQuestionDisplayData GetDisplayData(int answer) + { + return SurveyQuestionDisplayData.Default; + } public SurveyQuestionUISupport UISupport { get @@ -266,6 +342,10 @@ { return (((((int)SurveySchemaType.Last + 1) + ((int)SurveySchemaChildType.Last + 1)) + ((int)SurveyTableChildGlyphType.Last + 1)) + ((int)SurveyReferenceConstraintChildType.Last + 1)) + answer; } + public SurveyQuestionDisplayData GetDisplayData(int answer) + { + return SurveyQuestionDisplayData.Default; + } public SurveyQuestionUISupport UISupport { get Modified: trunk/RelationalModel/DcilModel/DcilModel.SurveyQuestionProvider.xml =================================================================== --- trunk/RelationalModel/DcilModel/DcilModel.SurveyQuestionProvider.xml 2007-08-20 22:18:31 UTC (rev 1093) +++ trunk/RelationalModel/DcilModel/DcilModel.SurveyQuestionProvider.xml 2007-08-20 22:24:39 UTC (rev 1094) @@ -63,6 +63,93 @@ </qp:offset> </qp:sequentialImageMap> </qp:surveyQuestion> + <qp:surveyQuestion questionType="SurveyColumnClassificationType"> + <qp:displaySupport displayCategory="Overlay"/> + <qp:displaySupport displayCategory="DisplayData"/> + <qp:explicitImageMap> + <qp:map enumValue="PrimaryRequired" imageIndex="0"> + <plx:binaryOperator type="add"> + <plx:left> + <plx:binaryOperator type="add"> + <plx:left> + <plx:binaryOperator type="add"> + <plx:left> + <plx:binaryOperator type="add"> + <plx:left> + <plx:binaryOperator type="add"> + <plx:left> + <plx:cast dataTypeName=".i4"> + <plx:callStatic dataTypeName="SurveySchemaType" name="Last" type="field"/> + </plx:cast> + </plx:left> + <plx:right> + <plx:value data="1" type="i4"/> + </plx:right> + </plx:binaryOperator> + </plx:left> + <plx:right> + <plx:binaryOperator type="add"> + <plx:left> + <plx:cast dataTypeName=".i4"> + <plx:callStatic dataTypeName="SurveySchemaChildType" name="Last" type="field"/> + </plx:cast> + </plx:left> + <plx:right> + <plx:value data="1" type="i4"/> + </plx:right> + </plx:binaryOperator> + </plx:right> + </plx:binaryOperator> + </plx:left> + <plx:right> + <plx:binaryOperator type="add"> + <plx:left> + <plx:cast dataTypeName=".i4"> + <plx:callStatic dataTypeName="SurveyTableChildGlyphType" name="Last" type="field"/> + </plx:cast> + </plx:left> + <plx:right> + <plx:value data="1" type="i4"/> + </plx:right> + </plx:binaryOperator> + </plx:right> + </plx:binaryOperator> + </plx:left> + <plx:right> + <plx:binaryOperator type="add"> + <plx:left> + <plx:cast dataTypeName=".i4"> + <plx:callStatic dataTypeName="SurveyReferenceConstraintChildType" name="Last" type="field"/> + </plx:cast> + </plx:left> + <plx:right> + <plx:value data="1" type="i4"/> + </plx:right> + </plx:binaryOperator> + </plx:right> + </plx:binaryOperator> + </plx:left> + <plx:right> + <plx:binaryOperator type="add"> + <plx:left> + <plx:cast dataTypeName=".i4"> + <plx:callStatic dataTypeName="SurveyUniquenessConstraintChildType" name="Last" type="field"/> + </plx:cast> + </plx:left> + <plx:right> + <plx:value data="1" type="i4"/> + </plx:right> + </plx:binaryOperator> + </plx:right> + </plx:binaryOperator> + </qp:map> + <qp:mapSameAs enumValue="PrimaryNullable" targetEnumValue="PrimaryRequired"/> + </qp:explicitImageMap> + <qp:displayDataMap> + <qp:displayData enumValue="Required" bold="true"/> + <qp:displayDataSameAs enumValue="PrimaryRequired" targetEnumValue="Required"/> + </qp:displayDataMap> + </qp:surveyQuestion> <qp:surveyQuestion questionType="SurveyReferenceConstraintChildType"> <qp:displaySupport displayCategory="Sorting"/> <qp:displaySupport displayCategory="Glyph"/> @@ -196,6 +283,7 @@ </qp:expansionKey> <qp:surveyQuestion ref="SurveyTableChildType"/> <qp:surveyQuestion ref="SurveyTableChildGlyphType"/> + <qp:surveyQuestion ref="SurveyColumnClassificationType"/> </qp:grouping> <qp:grouping> <qp:expansionKey> Modified: trunk/RelationalModel/DcilModel/Resources/SurveyTree.ImageStrip.png =================================================================== (Binary files differ) Modified: trunk/RelationalModel/DcilModel/SurveyImplementations/SurveyQuestions.cs =================================================================== --- trunk/RelationalModel/DcilModel/SurveyImplementations/SurveyQuestions.cs 2007-08-20 22:18:31 UTC (rev 1093) +++ trunk/RelationalModel/DcilModel/SurveyImplementations/SurveyQuestions.cs 2007-08-20 22:24:39 UTC (rev 1094) @@ -109,6 +109,32 @@ Last = PrimaryUniquenessConstraint, } /// <summary> + /// The list of possible answers to the ColumnNullableType category in the model browser + /// </summary> + public enum SurveyColumnClassificationType + { + /// <summary> + /// The column is required + /// </summary> + Required, + /// <summary> + /// The column is primary and required + /// </summary> + PrimaryRequired, + /// <summary> + /// The column is nullable + /// </summary> + Nullable, + /// <summary> + /// The column is primary and nullable + /// </summary> + PrimaryNullable, + /// <summary> + /// The current highest-valued value in the enumeration + /// </summary> + ... [truncated message content] |
From: <mcu...@us...> - 2007-08-20 22:30:52
|
Revision: 1095 http://orm.svn.sourceforge.net/orm/?rev=1095&view=rev Author: mcurland Date: 2007-08-20 15:30:52 -0700 (Mon, 20 Aug 2007) Log Message: ----------- Added verbalization support for column selections. The items displayed may change in the future, but this is a good start and important for debugging other relational mappings. refs #328 Changed VerbalizationToolWindow to use same main verbalization loop as the report verbalizer. This will be broken out more in the future as we refactor the report engine externally. refs #315 Also sorted the extension manager dialog and added license information to some files. Modified Paths: -------------- trunk/ORMModel/ObjectModel/VerbalizationReport.cs trunk/ORMModel/Shell/ExtensionManager.cs trunk/ORMModel/Shell/ORMVerbalizationToolWindow.cs trunk/Oial/ORMOialBridge/ModificationTracker.cs trunk/Oial/ORMOialBridge/ORMElementGateway.cs trunk/Oial/ORMOialBridge/ORMOialBridgePermuter.cs trunk/Oial/ORMOialBridge/ORMOialBridgeStructures.cs trunk/Oial/ORMOialBridge/OialModelIsForORMModel.cs trunk/RelationalModel/DcilModel/DcilModel.csproj trunk/RelationalModel/OialDcilBridge/ModificationTracker.cs trunk/RelationalModel/OialDcilBridge/OialDcilBridge.csproj trunk/RelationalModel/OialDcilBridge/Resources/ResourceStrings.cs Added Paths: ----------- trunk/RelationalModel/DcilModel/Verbalization.cs trunk/RelationalModel/OialDcilBridge/Verbalization.cs Modified: trunk/ORMModel/ObjectModel/VerbalizationReport.cs =================================================================== --- trunk/ORMModel/ObjectModel/VerbalizationReport.cs 2007-08-20 22:24:39 UTC (rev 1094) +++ trunk/ORMModel/ObjectModel/VerbalizationReport.cs 2007-08-20 22:30:52 UTC (rev 1095) @@ -218,6 +218,11 @@ false, ref firstCall); + if (!firstCall) + { + writer.WriteDocumentFooter(); + } + textWriter.Flush(); textWriter.Close(); #endregion // Object Type List Report @@ -331,6 +336,11 @@ false, ref firstCall); + if (!firstCall) + { + writer.WriteDocumentFooter(); + } + textWriter.Flush(); textWriter.Close(); } @@ -455,52 +465,6 @@ myDocumentHeaderReplacementFields = documentHeaderReplacementFields; } /// <summary> - /// Retrieves replacement fields for the Document Header snippet from the given IORMFontAndColorService implementation - /// </summary> - /// <param name="colorService"></param> - /// <param name="snippets"></param> - /// <returns></returns> - public static string[] GetDocumentHeaderReplacementFields(IORMFontAndColorService colorService, IVerbalizationSets<CoreVerbalizationSnippetType> snippets) - { - string[] retVal; - // The replacement fields, pulled from VerbalizationGenerator.xsd - //{0} font-family - //{1} font-size - //{2} predicate text color - //{3} predicate text bold - //{4} object name color - //{5} object name bold - //{6} formal item color - //{7} formal item bold - //{8} notes item color - //{9} notes item bold - //{10} refmode item color - //{11} refmode item bold - //{12} instance value item color - //{13} instance value item bold - string boldWeight = snippets.GetSnippet(CoreVerbalizationSnippetType.VerbalizerFontWeightBold); - string normalWeight = snippets.GetSnippet(CoreVerbalizationSnippetType.VerbalizerFontWeightNormal); - retVal = new string[] { "Tahoma", "8", "darkgreen", normalWeight, "purple", normalWeight, "mediumblue", boldWeight, "brown", normalWeight, "darkgray", normalWeight, "brown", normalWeight }; - using (Font font = colorService.GetFont(ORMDesignerColorCategory.Verbalizer)) - { - retVal[0] = font.FontFamily.Name; - retVal[1] = (font.Size * 72f).ToString(CultureInfo.InvariantCulture); - retVal[2] = ColorTranslator.ToHtml(colorService.GetForeColor(ORMDesignerColor.VerbalizerPredicateText)); - retVal[3] = (0 != (colorService.GetFontStyle(ORMDesignerColor.VerbalizerPredicateText) & FontStyle.Bold)) ? boldWeight : normalWeight; - retVal[4] = ColorTranslator.ToHtml(colorService.GetForeColor(ORMDesignerColor.VerbalizerObjectName)); - retVal[5] = (0 != (colorService.GetFontStyle(ORMDesignerColor.VerbalizerObjectName) & FontStyle.Bold)) ? boldWeight : normalWeight; - retVal[6] = ColorTranslator.ToHtml(colorService.GetForeColor(ORMDesignerColor.VerbalizerFormalItem)); - retVal[7] = (0 != (colorService.GetFontStyle(ORMDesignerColor.VerbalizerFormalItem) & FontStyle.Bold)) ? boldWeight : normalWeight; - retVal[8] = ColorTranslator.ToHtml(colorService.GetForeColor(ORMDesignerColor.VerbalizerNotesItem)); - retVal[9] = (0 != (colorService.GetFontStyle(ORMDesignerColor.VerbalizerNotesItem) & FontStyle.Bold)) ? boldWeight : normalWeight; - retVal[10] = ColorTranslator.ToHtml(colorService.GetForeColor(ORMDesignerColor.VerbalizerRefMode)); - retVal[11] = (0 != (colorService.GetFontStyle(ORMDesignerColor.VerbalizerRefMode) & FontStyle.Bold)) ? boldWeight : normalWeight; - retVal[12] = ColorTranslator.ToHtml(colorService.GetForeColor(ORMDesignerColor.VerbalizerInstanceValue)); - retVal[13] = (0 != (colorService.GetFontStyle(ORMDesignerColor.VerbalizerInstanceValue) & FontStyle.Bold)) ? boldWeight : normalWeight; - } - return retVal; - } - /// <summary> /// Gets the underlying TextWriter /// </summary> public TextWriter Writer Modified: trunk/ORMModel/Shell/ExtensionManager.cs =================================================================== --- trunk/ORMModel/Shell/ExtensionManager.cs 2007-08-20 22:24:39 UTC (rev 1094) +++ trunk/ORMModel/Shell/ExtensionManager.cs 2007-08-20 22:30:52 UTC (rev 1095) @@ -31,6 +31,8 @@ using Neumont.Tools.Modeling.Design; using Neumont.Tools.ORM.ObjectModel; using Neumont.Tools.Modeling.Shell; +using System.Collections; +using System.Globalization; namespace Neumont.Tools.ORM.Shell { @@ -293,7 +295,23 @@ { AddItemToListView(type); } + lvExtensions.ListViewItemSorter = ItemComparer.Instance; } + + private sealed class ItemComparer : IComparer + { + public static readonly IComparer Instance = new ItemComparer(); + private ItemComparer() + { + } + + public int Compare(object obj1, object obj2) + { + ListViewItem item1 = (ListViewItem) obj1; + ListViewItem item2 = (ListViewItem) obj2; + return string.Compare(item1.SubItems[1].Text, item2.SubItems[1].Text, false, CultureInfo.CurrentCulture); + } + } /// <summary> /// This method adds the passed in ORMExtensionType to the ListView on the ExtensionManager dialogue. /// </summary> Modified: trunk/ORMModel/Shell/ORMVerbalizationToolWindow.cs =================================================================== --- trunk/ORMModel/Shell/ORMVerbalizationToolWindow.cs 2007-08-20 22:24:39 UTC (rev 1094) +++ trunk/ORMModel/Shell/ORMVerbalizationToolWindow.cs 2007-08-20 22:30:52 UTC (rev 1095) @@ -33,6 +33,7 @@ using Microsoft.VisualStudio.TextManager.Interop; using Neumont.Tools.ORM.ObjectModel; using Neumont.Tools.Modeling; +using Neumont.Tools.ORM.ObjectModel.Verbalization; namespace Neumont.Tools.ORM.Shell { @@ -289,6 +290,7 @@ ICollection selectedObjects = base.GetSelectedComponents(); IDictionary<Type, IVerbalizationSets> snippetsDictionary = null; IVerbalizationSets<CoreVerbalizationSnippetType> snippets = null; + VerbalizationCallbackWriter callbackWriter = null; bool showNegative = ORMDesignerPackage.VerbalizationWindowSettings.ShowNegativeVerbalizations; bool firstCallPending = true; Dictionary<IVerbalize, IVerbalize> verbalized = myAlreadyVerbalized; @@ -317,16 +319,23 @@ { snippetsDictionary = (mel.Store as IORMToolServices).GetVerbalizationSnippetsDictionary(ORMCoreDomainModel.VerbalizationTargetName); snippets = (IVerbalizationSets<CoreVerbalizationSnippetType>)snippetsDictionary[typeof(CoreVerbalizationSnippetType)]; - myStringWriter.NewLine = snippets.GetSnippet(CoreVerbalizationSnippetType.VerbalizerNewLine); + callbackWriter = new VerbalizationCallbackWriter(snippets, myStringWriter, GetDocumentHeaderReplacementFields(mel, snippets)); } - VerbalizeElement(mel, snippetsDictionary, verbalized, showNegative, myStringWriter, ref firstCallPending); + VerbalizationHelper.VerbalizeElement( + mel, + snippetsDictionary, + verbalized, + showNegative, + callbackWriter, + true, + ref firstCallPending); } } } if (!firstCallPending) { // Write footer - myStringWriter.Write(snippets.GetSnippet(CoreVerbalizationSnippetType.VerbalizerDocumentFooter)); + callbackWriter.WriteDocumentFooter(); // Clear cache verbalized.Clear(); } @@ -341,238 +350,6 @@ } } } - private sealed class VerbalizationContextImpl : IVerbalizationContext - { - /// <summary> - /// A callback delegate enabling a verbalizer to tell - /// the hosting window that it is about to begin verbalizing. - /// This enables the host window to delay writing content outer - /// content until it knows that text is about to be written by - /// the verbalizer to the writer - /// </summary> - /// <param name="content">The style of verbalization content</param> - public delegate void NotifyBeginVerbalization(VerbalizationContent content); - public delegate void NotifyDeferVerbalization(object target, IVerbalizeFilterChildren childFilter); - private NotifyBeginVerbalization myBeginCallback; - private NotifyDeferVerbalization myDeferCallback; - public VerbalizationContextImpl(NotifyBeginVerbalization beginCallback, NotifyDeferVerbalization deferCallback) - { - myBeginCallback = beginCallback; - myDeferCallback = deferCallback; - } - #region IVerbalizationContext Implementation - void IVerbalizationContext.BeginVerbalization(VerbalizationContent content) - { - myBeginCallback(content); - } - void IVerbalizationContext.DeferVerbalization(object target, IVerbalizeFilterChildren childFilter) - { - if (myDeferCallback != null) - { - myDeferCallback(target, childFilter); - } - } - #endregion // IVerbalizationContext Implementation - } - /// <summary> - /// Determine the indentation level for verbalizing a ModelElement, and fire - /// the delegate for verbalization - /// </summary> - /// <param name="element">The element to verbalize</param> - /// <param name="snippetsDictionary">The default or loaded verbalization sets. Passed through all verbalization calls.</param> - /// <param name="alreadyVerbalized">A dictionary of top-level (indentationLevel == 0) elements that have already been verbalized.</param> - /// <param name="isNegative">Use the negative form of the reading</param> - /// <param name="writer">The TextWriter for verbalization output</param> - /// <param name="firstCallPending"></param> - private static void VerbalizeElement(ModelElement element, IDictionary<Type, IVerbalizationSets> snippetsDictionary, IDictionary<IVerbalize, IVerbalize> alreadyVerbalized, bool isNegative, TextWriter writer, ref bool firstCallPending) - { - int lastLevel = 0; - bool firstWrite = true; - bool localFirstCallPending = firstCallPending; - IVerbalizationSets<CoreVerbalizationSnippetType> snippets = (IVerbalizationSets<CoreVerbalizationSnippetType>)snippetsDictionary[typeof(CoreVerbalizationSnippetType)]; - VerbalizeElement( - element, - snippetsDictionary, - null, - delegate(IVerbalize verbalizer, int indentationLevel) - { - if (indentationLevel == 0) - { - if (alreadyVerbalized.ContainsKey(verbalizer)) - { - return VerbalizationResult.AlreadyVerbalized; - } - } - bool retVal = verbalizer.GetVerbalization( - writer, - snippetsDictionary, - new VerbalizationContextImpl( - delegate(VerbalizationContent content) - { - // Prepare for verbalization on this element. Everything - // is delayed to this point in case the verbalization implementation - // does not callback to the text writer. - if (firstWrite) - { - if (localFirstCallPending) - { - localFirstCallPending = false; - // Write the HTML header to the buffer - writer.Write(string.Format(CultureInfo.InvariantCulture, snippets.GetSnippet(CoreVerbalizationSnippetType.VerbalizerDocumentHeader), GetDocumentHeaderReplacementFields(element, snippets))); - } - - // write open tag for new verbalization - writer.Write(snippets.GetSnippet(CoreVerbalizationSnippetType.VerbalizerOpenVerbalization)); - firstWrite = false; - } - else - { - writer.WriteLine(); - } - - // Write indentation tags as needed - if (indentationLevel > lastLevel) - { - do - { - writer.Write(snippets.GetSnippet(CoreVerbalizationSnippetType.VerbalizerIncreaseIndent)); - ++lastLevel; - } while (lastLevel != indentationLevel); - } - else if (lastLevel > indentationLevel) - { - do - { - writer.Write(snippets.GetSnippet(CoreVerbalizationSnippetType.VerbalizerDecreaseIndent)); - --lastLevel; - } while (lastLevel != indentationLevel); - } - }, - null), - isNegative); - if (retVal) - { - if (indentationLevel == 0) - { - alreadyVerbalized.Add(verbalizer, verbalizer); - } - return VerbalizationResult.Verbalized; - } - else - { - return VerbalizationResult.NotVerbalized; - } - }, - isNegative, - 0); - while (lastLevel > 0) - { - writer.Write(snippets.GetSnippet(CoreVerbalizationSnippetType.VerbalizerDecreaseIndent)); - --lastLevel; - } - // close the opening tag for the new verbalization - if (!firstWrite) - { - writer.Write(snippets.GetSnippet(CoreVerbalizationSnippetType.VerbalizerCloseVerbalization)); - } - firstCallPending = localFirstCallPending; - } - /// <summary> - /// Verbalize the passed in element and all its children - /// </summary> - private static void VerbalizeElement(ModelElement element, IDictionary<Type, IVerbalizationSets> snippetsDictionary, IVerbalizeFilterChildren filter, VerbalizationHandler callback, bool isNegative, int indentLevel) - { - IVerbalize parentVerbalize = null; - IRedirectVerbalization surrogateRedirect; - if (indentLevel == 0 && - null != (surrogateRedirect = element as IRedirectVerbalization) && - null != (parentVerbalize = surrogateRedirect.SurrogateVerbalizer)) - { - element = parentVerbalize as ModelElement; - } - else - { - parentVerbalize = element as IVerbalize; - } - bool disposeVerbalizer = false; - if (filter != null && parentVerbalize != null) - { - CustomChildVerbalizer filterResult = filter.FilterChildVerbalizer(parentVerbalize, isNegative); - parentVerbalize = filterResult.Instance; - disposeVerbalizer = filterResult.Options; - } - try - { - VerbalizationResult result = (parentVerbalize != null) ? callback(parentVerbalize, indentLevel) : VerbalizationResult.NotVerbalized; - if (result == VerbalizationResult.AlreadyVerbalized) - { - return; - } - bool parentVerbalizeOK = result == VerbalizationResult.Verbalized; - bool verbalizeChildren = parentVerbalizeOK ? (element != null) : (element is IVerbalizeChildren); - if (verbalizeChildren) - { - if (parentVerbalizeOK) - { - ++indentLevel; - } - filter = parentVerbalize as IVerbalizeFilterChildren; - ReadOnlyCollection<DomainRoleInfo> aggregatingList = element.GetDomainClass().AllDomainRolesPlayed; - int aggregatingCount = aggregatingList.Count; - for (int i = 0; i < aggregatingCount; ++i) - { - DomainRoleInfo roleInfo = aggregatingList[i]; - if (roleInfo.IsEmbedding) - { - LinkedElementCollection<ModelElement> children = roleInfo.GetLinkedElements(element); - int childCount = children.Count; - for (int j = 0; j < childCount; ++j) - { - VerbalizeElement(children[j], snippetsDictionary, filter, callback, isNegative, indentLevel); - } - } - } - // TODO: Need BeforeNaturalChildren/AfterNaturalChildren/SkipNaturalChildren settings for IVerbalizeCustomChildren - IVerbalizeCustomChildren customChildren = parentVerbalize as IVerbalizeCustomChildren; - if (customChildren != null) - { - foreach (CustomChildVerbalizer customChild in customChildren.GetCustomChildVerbalizations(filter, isNegative)) - { - IVerbalize childVerbalize = customChild.Instance; - if (childVerbalize != null) - { - try - { - callback(childVerbalize, indentLevel); - } - finally - { - if (customChild.Options) - { - IDisposable dispose = childVerbalize as IDisposable; - if (dispose != null) - { - dispose.Dispose(); - } - } - } - } - } - } - } - } - finally - { - if (disposeVerbalizer) - { - IDisposable dispose = parentVerbalize as IDisposable; - if (dispose != null) - { - dispose.Dispose(); - } - } - } - } #endregion // Verbalization Implementation #region ORMToolWindow Implementation /// <summary> Modified: trunk/Oial/ORMOialBridge/ModificationTracker.cs =================================================================== --- trunk/Oial/ORMOialBridge/ModificationTracker.cs 2007-08-20 22:24:39 UTC (rev 1094) +++ trunk/Oial/ORMOialBridge/ModificationTracker.cs 2007-08-20 22:30:52 UTC (rev 1095) @@ -1,3 +1,18 @@ +#region Common Public License Copyright Notice +/**************************************************************************\ +* Neumont Object-Role Modeling Architect for Visual Studio * +* * +* Copyright \xA9 Neumont University. All rights reserved. * +* * +* The use and distribution terms for this software are covered by the * +* Common Public License 1.0 (http://opensource.org/licenses/cpl) which * +* can be found in the file CPL.txt at the root of this distribution. * +* By using this software in any fashion, you are agreeing to be bound by * +* the terms of this license. * +* * +* You must not remove this notice, or any other, from this software. * +\**************************************************************************/ +#endregion using System; using System.Collections.Generic; using System.Text; Modified: trunk/Oial/ORMOialBridge/ORMElementGateway.cs =================================================================== --- trunk/Oial/ORMOialBridge/ORMElementGateway.cs 2007-08-20 22:24:39 UTC (rev 1094) +++ trunk/Oial/ORMOialBridge/ORMElementGateway.cs 2007-08-20 22:30:52 UTC (rev 1095) @@ -1,3 +1,18 @@ +#region Common Public License Copyright Notice +/**************************************************************************\ +* Neumont Object-Role Modeling Architect for Visual Studio * +* * +* Copyright \xA9 Neumont University. All rights reserved. * +* * +* The use and distribution terms for this software are covered by the * +* Common Public License 1.0 (http://opensource.org/licenses/cpl) which * +* can be found in the file CPL.txt at the root of this distribution. * +* By using this software in any fashion, you are agreeing to be bound by * +* the terms of this license. * +* * +* You must not remove this notice, or any other, from this software. * +\**************************************************************************/ +#endregion using System; using System.Collections.Generic; using System.Text; Modified: trunk/Oial/ORMOialBridge/ORMOialBridgePermuter.cs =================================================================== --- trunk/Oial/ORMOialBridge/ORMOialBridgePermuter.cs 2007-08-20 22:24:39 UTC (rev 1094) +++ trunk/Oial/ORMOialBridge/ORMOialBridgePermuter.cs 2007-08-20 22:30:52 UTC (rev 1095) @@ -1,3 +1,18 @@ +#region Common Public License Copyright Notice +/**************************************************************************\ +* Neumont Object-Role Modeling Architect for Visual Studio * +* * +* Copyright \xA9 Neumont University. All rights reserved. * +* * +* The use and distribution terms for this software are covered by the * +* Common Public License 1.0 (http://opensource.org/licenses/cpl) which * +* can be found in the file CPL.txt at the root of this distribution. * +* By using this software in any fashion, you are agreeing to be bound by * +* the terms of this license. * +* * +* You must not remove this notice, or any other, from this software. * +\**************************************************************************/ +#endregion using System; using System.Collections.Generic; using System.Text; Modified: trunk/Oial/ORMOialBridge/ORMOialBridgeStructures.cs =================================================================== --- trunk/Oial/ORMOialBridge/ORMOialBridgeStructures.cs 2007-08-20 22:24:39 UTC (rev 1094) +++ trunk/Oial/ORMOialBridge/ORMOialBridgeStructures.cs 2007-08-20 22:30:52 UTC (rev 1095) @@ -1,3 +1,18 @@ +#region Common Public License Copyright Notice +/**************************************************************************\ +* Neumont Object-Role Modeling Architect for Visual Studio * +* * +* Copyright \xA9 Neumont University. All rights reserved. * +* * +* The use and distribution terms for this software are covered by the * +* Common Public License 1.0 (http://opensource.org/licenses/cpl) which * +* can be found in the file CPL.txt at the root of this distribution. * +* By using this software in any fashion, you are agreeing to be bound by * +* the terms of this license. * +* * +* You must not remove this notice, or any other, from this software. * +\**************************************************************************/ +#endregion using System; using System.Collections.Generic; using System.Diagnostics; Modified: trunk/Oial/ORMOialBridge/OialModelIsForORMModel.cs =================================================================== --- trunk/Oial/ORMOialBridge/OialModelIsForORMModel.cs 2007-08-20 22:24:39 UTC (rev 1094) +++ trunk/Oial/ORMOialBridge/OialModelIsForORMModel.cs 2007-08-20 22:30:52 UTC (rev 1095) @@ -1,3 +1,18 @@ +#region Common Public License Copyright Notice +/**************************************************************************\ +* Neumont Object-Role Modeling Architect for Visual Studio * +* * +* Copyright \xA9 Neumont University. All rights reserved. * +* * +* The use and distribution terms for this software are covered by the * +* Common Public License 1.0 (http://opensource.org/licenses/cpl) which * +* can be found in the file CPL.txt at the root of this distribution. * +* By using this software in any fashion, you are agreeing to be bound by * +* the terms of this license. * +* * +* You must not remove this notice, or any other, from this software. * +\**************************************************************************/ +#endregion using System; using System.Collections.Generic; using System.Text; Modified: trunk/RelationalModel/DcilModel/DcilModel.csproj =================================================================== --- trunk/RelationalModel/DcilModel/DcilModel.csproj 2007-08-20 22:24:39 UTC (rev 1094) +++ trunk/RelationalModel/DcilModel/DcilModel.csproj 2007-08-20 22:30:52 UTC (rev 1095) @@ -153,6 +153,7 @@ <DependentUpon>ResourceStringsGenerator.xml</DependentUpon> </Compile> <Compile Include="SurveyImplementations\SurveyQuestions.cs" /> + <Compile Include="Verbalization.cs" /> <EmbeddedResource Include="Catalog.resx"> <DependentUpon>Catalog.cs</DependentUpon> <SubType>Designer</SubType> Added: trunk/RelationalModel/DcilModel/Verbalization.cs =================================================================== --- trunk/RelationalModel/DcilModel/Verbalization.cs (rev 0) +++ trunk/RelationalModel/DcilModel/Verbalization.cs 2007-08-20 22:30:52 UTC (rev 1095) @@ -0,0 +1,62 @@ +#region Common Public License Copyright Notice +/**************************************************************************\ +* Neumont Object-Role Modeling Architect for Visual Studio * +* * +* Copyright \xA9 Neumont University. All rights reserved. * +* * +* The use and distribution terms for this software are covered by the * +* Common Public License 1.0 (http://opensource.org/licenses/cpl) which * +* can be found in the file CPL.txt at the root of this distribution. * +* By using this software in any fashion, you are agreeing to be bound by * +* the terms of this license. * +* * +* You must not remove this notice, or any other, from this software. * +\**************************************************************************/ +#endregion +using Microsoft.VisualStudio.Modeling; +using Neumont.Tools.ORM.ObjectModel; +using System; +using System.Collections.ObjectModel; + +namespace Neumont.Tools.RelationalModels.ConceptualDatabase +{ + partial class Column : IRedirectVerbalization + { + #region IRedirectVerbalization implementation + /// <summary> + /// The guid for the role in the bridge model we want to defer verbalization to. Lifted + /// from the generated bridge code. + /// </summary> + private static readonly Guid ColumnBridgeRoleId = new Guid(0xbc7ea8a8, 0x8772, 0x4ca4, 0xb9, 0x14, 0xb7, 0x8b, 0x4b, 0x58, 0x33, 0x38); + + /// <summary> + /// Implements <see cref="IRedirectVerbalization.SurrogateVerbalizer"/>. Defers to the + /// first bridge link element, if the bridge is loaded. + /// </summary> + protected IVerbalize SurrogateVerbalizer + { + get + { + // Look up the associated bridge links by guid, this project does not reference + // the bridge elements directly, so the type is not available. + DomainRoleInfo roleInfo; + ReadOnlyCollection<ElementLink> links; + IVerbalize retVal = null; + if (null != (roleInfo = Store.DomainDataDirectory.FindDomainRole(ColumnBridgeRoleId)) && + 0 != (links = roleInfo.GetElementLinks(this)).Count) + { + retVal = links[0] as IVerbalize; + } + return retVal; + } + } + IVerbalize IRedirectVerbalization.SurrogateVerbalizer + { + get + { + return SurrogateVerbalizer; + } + } + #endregion // IRedirectVerbalization implementation + } +} Modified: trunk/RelationalModel/OialDcilBridge/ModificationTracker.cs =================================================================== --- trunk/RelationalModel/OialDcilBridge/ModificationTracker.cs 2007-08-20 22:24:39 UTC (rev 1094) +++ trunk/RelationalModel/OialDcilBridge/ModificationTracker.cs 2007-08-20 22:30:52 UTC (rev 1095) @@ -1,3 +1,18 @@ +#region Common Public License Copyright Notice +/**************************************************************************\ +* Neumont Object-Role Modeling Architect for Visual Studio * +* * +* Copyright \xA9 Neumont University. All rights reserved. * +* * +* The use and distribution terms for this software are covered by the * +* Common Public License 1.0 (http://opensource.org/licenses/cpl) which * +* can be found in the file CPL.txt at the root of this distribution. * +* By using this software in any fashion, you are agreeing to be bound by * +* the terms of this license. * +* * +* You must not remove this notice, or any other, from this software. * +\**************************************************************************/ +#endregion using System; using System.Collections.Generic; using System.Text; Modified: trunk/RelationalModel/OialDcilBridge/OialDcilBridge.csproj =================================================================== --- trunk/RelationalModel/OialDcilBridge/OialDcilBridge.csproj 2007-08-20 22:24:39 UTC (rev 1094) +++ trunk/RelationalModel/OialDcilBridge/OialDcilBridge.csproj 2007-08-20 22:30:52 UTC (rev 1095) @@ -156,6 +156,7 @@ <AutoGen>True</AutoGen> <DependentUpon>ResourceStringsGenerator.xml</DependentU... [truncated message content] |
From: <mcu...@us...> - 2007-08-20 22:32:46
|
Revision: 1096 http://orm.svn.sourceforge.net/orm/?rev=1096&view=rev Author: mcurland Date: 2007-08-20 15:32:49 -0700 (Mon, 20 Aug 2007) Log Message: ----------- Covered additional ORMElementGateway case, extension of work done for [1087] refs #327 Fixed issue adding implied mandatory constraints to non-mandatory preferred identifier roles. refs #330 Modified Paths: -------------- trunk/ORMModel/ObjectModel/ObjectType.cs trunk/Oial/ORMOialBridge/ORMElementGateway.cs Modified: trunk/ORMModel/ObjectModel/ObjectType.cs =================================================================== --- trunk/ORMModel/ObjectModel/ObjectType.cs 2007-08-20 22:30:52 UTC (rev 1095) +++ trunk/ORMModel/ObjectModel/ObjectType.cs 2007-08-20 22:32:49 UTC (rev 1096) @@ -1363,6 +1363,7 @@ { bool canBeIndependent = true; LinkedElementCollection<Role> preferredIdentifierRoles = null; + bool checkedPreferredRoles = false; LinkedElementCollection<Role> playedRoles = PlayedRoleCollection; int playedRoleCount = playedRoles.Count; MandatoryConstraint impliedMandatory = ImpliedMandatoryConstraint; @@ -1404,19 +1405,20 @@ currentRoleIsMandatory = true; bool turnedOffCanBeIndependent = false; // The role must be part of a fact type that has a role in the preferred identifier. - if (preferredIdentifierRoles == null) + if (!checkedPreferredRoles) { + checkedPreferredRoles = true; UniquenessConstraint preferredIdentifier = PreferredIdentifier; - if (preferredIdentifier == null) + if (preferredIdentifier != null) { - canBeIndependent = false; - turnedOffCanBeIndependent = true; - } - else - { preferredIdentifierRoles = preferredIdentifier.RoleCollection; } } + if (preferredIdentifierRoles == null) + { + canBeIndependent = false; + turnedOffCanBeIndependent = true; + } if (canBeIndependent) { RoleBase oppositeRole = playedRole.OppositeRole; @@ -1445,9 +1447,29 @@ } } } - if (!currentRoleIsMandatory) + if (!currentRoleIsMandatory && canBeIndependent) { - seenNonMandatoryRole = true; + bool nonMandatoryRoleInPreferredIdentifier = false; + if (!checkedPreferredRoles) + { + checkedPreferredRoles = true; + UniquenessConstraint preferredIdentifier = PreferredIdentifier; + if (preferredIdentifier != null) + { + preferredIdentifierRoles = preferredIdentifier.RoleCollection; + } + } + if (preferredIdentifierRoles != null) + { + RoleBase oppositeRole = playedRole.OppositeRole; + nonMandatoryRoleInPreferredIdentifier = + null != oppositeRole && + preferredIdentifierRoles.Contains(oppositeRole.Role); + } + if (!nonMandatoryRoleInPreferredIdentifier) + { + seenNonMandatoryRole = true; + } } if (impliedMandatory != null && canBeIndependent) { @@ -1565,7 +1587,7 @@ { if (mandatoryConstraint.IsImplied) { - // The pattern has already been validated. Anything object + // The pattern has already been validated. Any object with // an implied mandatory constraint can be independent. return true; } Modified: trunk/Oial/ORMOialBridge/ORMElementGateway.cs =================================================================== --- trunk/Oial/ORMOialBridge/ORMElementGateway.cs 2007-08-20 22:30:52 UTC (rev 1095) +++ trunk/Oial/ORMOialBridge/ORMElementGateway.cs 2007-08-20 22:32:49 UTC (rev 1096) @@ -70,7 +70,7 @@ foreach (ObjectType objectType in model.ObjectTypeCollection) { if (!IsElementExcluded(objectType) && - !ShouldConsiderObjectType(objectType, null)) + !ShouldConsiderObjectType(objectType, null, false)) { ExcludeObjectType(objectType, abstractionModel, true, notifyExcluded); } @@ -92,9 +92,10 @@ /// markings on its preferred identifier. /// </summary> /// <param name="objectType">The <see cref="ObjectType"/> to test</param> + /// <param name="ignoreFactTypesFilteredForThisObjectType">Don't block consideration of this <paramref name="objectType"/> if a <see cref="FactType"/> is excluded because this <see cref="ObjectType"/> is currently excluded.</param> /// <param name="ignoreFactType">Succeed even if this <see cref="FactType"/> is excluded. Can be <see langword="null"/>.</param> /// <returns><see langword="true"/> if the <paramref name="objectType"/> passes all necessary conditions for consideration.</returns> - private static bool ShouldConsiderObjectType(ObjectType objectType, FactType ignoreFactType) + private static bool ShouldConsiderObjectType(ObjectType objectType, FactType ignoreFactType, bool ignoreFactTypesFilteredForThisObjectType) { // Look at the error states we care about. If any of these error // states are present then we do not consider. @@ -118,10 +119,10 @@ if (factType != ignoreFactType && IsElementExcluded(factType)) { - if (ignoreFactType != null && ShouldConsiderFactType(factType, objectType, true)) + if (ignoreFactTypesFilteredForThisObjectType && ShouldConsiderFactType(factType, objectType, true)) { // This pattern is used only during delay validation. A cleaner model would - // be a delagate callback, but it isn't worth the additional overhead given + // be a delegate callback, but it isn't worth the additional overhead given // that this would be the only code that would ever run there. FilterModifiedFactType(factType, true); } @@ -158,7 +159,7 @@ if (rolePlayer == null || (ignoreRolePlayer != rolePlayer && IsElementExcluded(rolePlayer) && - !(!ignoreRolePlayersFilteredForThisFactType || ShouldConsiderObjectType(rolePlayer, factType)))) + !(!ignoreRolePlayersFilteredForThisFactType || ShouldConsiderObjectType(rolePlayer, factType, true)))) { return false; } @@ -188,7 +189,7 @@ { ModelHasObjectType link = element as ModelHasObjectType; ObjectType objectType = link.ObjectType; - if (ShouldConsiderObjectType(objectType, null)) + if (ShouldConsiderObjectType(objectType, null, false)) { AddObjectType(objectType); } @@ -268,7 +269,7 @@ { ObjectType objectType = (ObjectType)element; ExcludedORMModelElement exclusionLink = ExcludedORMModelElement.GetLinkToAbstractionModel(objectType); - if (ShouldConsiderObjectType(objectType, null)) + if (ShouldConsiderObjectType(objectType, null, true)) { if (exclusionLink != null) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mcu...@us...> - 2007-08-30 17:22:09
|
Revision: 1100 http://orm.svn.sourceforge.net/orm/?rev=1100&view=rev Author: mcurland Date: 2007-08-30 10:21:57 -0700 (Thu, 30 Aug 2007) Log Message: ----------- Provides a basic and intelligent relational schema name generation algorithm, and reruns the algorithm on name changes to the conceptual model. Includes a minor name and access change on FactType. refs #334 Modified Paths: -------------- trunk/ORMModel/ObjectModel/FactType.cs trunk/ORMModel/Shell/ReadingEditor.cs trunk/RelationalModel/OialDcilBridge/ModificationTracker.cs trunk/RelationalModel/OialDcilBridge/OialDcilBridge.AttachRules.cs trunk/RelationalModel/OialDcilBridge/OialDcilBridge.AttachRules.xml trunk/RelationalModel/OialDcilBridge/OialDcilBridge.DeserializationFixupListeners.cs trunk/RelationalModel/OialDcilBridge/OialDcilBridge.csproj Added Paths: ----------- trunk/RelationalModel/OialDcilBridge/NameGeneration.cs Modified: trunk/ORMModel/ObjectModel/FactType.cs =================================================================== --- trunk/ORMModel/ObjectModel/FactType.cs 2007-08-30 17:19:27 UTC (rev 1099) +++ trunk/ORMModel/ObjectModel/FactType.cs 2007-08-30 17:21:57 UTC (rev 1100) @@ -66,7 +66,7 @@ /// it will then create a new ReadingOrder. It operates under the assumption /// that a transaction has already been started. /// </summary> - public ReadingOrder GetReadingOrder(IList<RoleBase> roleOrder) + public ReadingOrder EnsureReadingOrder(IList<RoleBase> roleOrder) { ReadingOrder retVal = FindMatchingReadingOrder(roleOrder); if (retVal == null) @@ -118,7 +118,7 @@ /// the assumption that a transaction has already been started. /// </summary> /// <returns>Should always return a value unless there was an error creating the ReadingOrder</returns> - public ReadingOrder CreateReadingOrder(IList<RoleBase> roleOrder) + private ReadingOrder CreateReadingOrder(IList<RoleBase> roleOrder) { ReadingOrder retval = null; if (roleOrder.Count > 0) Modified: trunk/ORMModel/Shell/ReadingEditor.cs =================================================================== --- trunk/ORMModel/Shell/ReadingEditor.cs 2007-08-30 17:19:27 UTC (rev 1099) +++ trunk/ORMModel/Shell/ReadingEditor.cs 2007-08-30 17:21:57 UTC (rev 1100) @@ -1695,7 +1695,7 @@ myInsertedRow = row; using (Transaction t = store.TransactionManager.BeginTransaction(ResourceStrings.ModelReadingEditorNewReadingTransactionText)) { - ReadingOrder theOrder = myFact.GetReadingOrder(myReadingOrderKeyedCollection[row].RoleOrder); + ReadingOrder theOrder = myFact.EnsureReadingOrder(myReadingOrderKeyedCollection[row].RoleOrder); Debug.Assert(theOrder != null, "A ReadingOrder should have been found or created."); theNewReading = new Reading(store); LinkedElementCollection<Reading> readings = theOrder.ReadingCollection; @@ -2560,7 +2560,7 @@ { if (myReadingOrder == null) //obtain new readingOrder to commit a new reading (in readingOrder is non-existent) { - myReadingOrder = myParentBranch.Fact.GetReadingOrder(this.myRoleOrder); + myReadingOrder = myParentBranch.Fact.EnsureReadingOrder(this.myRoleOrder); } myReadingBranch = new ReadingBranch(myParentBranch.Fact, myReadingOrder, this); return myReadingBranch; Modified: trunk/RelationalModel/OialDcilBridge/ModificationTracker.cs =================================================================== --- trunk/RelationalModel/OialDcilBridge/ModificationTracker.cs 2007-08-30 17:19:27 UTC (rev 1099) +++ trunk/RelationalModel/OialDcilBridge/ModificationTracker.cs 2007-08-30 17:21:57 UTC (rev 1100) @@ -180,6 +180,98 @@ } } #endregion // Bridge element modification rules + #region Name modification rules + /// <summary> + /// ChangeRule: typeof(Neumont.Tools.ORMAbstraction.ConceptType) + /// </summary> + private static void ConceptTypeChangedRule(ElementPropertyChangedEventArgs e) + { + if (e.DomainProperty.Id == ConceptType.NameDomainPropertyId) + { + ValidateTableNameChanged(TableIsPrimarilyForConceptType.GetTable((ConceptType)e.ModelElement)); + } + } + /// <summary> + /// ChangeRule: typeof(Neumont.Tools.ORM.ObjectModel.FactType) + /// </summary> + private static void FactTypeNameChangedRule(ElementPropertyChangedEventArgs e) + { + if (e.DomainProperty.Id == ORMCore.FactType.NameChangedDomainPropertyId) + { + foreach (ConceptTypeChild child in ConceptTypeChildHasPathFactType.GetConceptTypeChild((ORMCore.FactType)e.ModelElement)) + { + ValidateConceptTypeChildNameChanged(child); + } + } + } + /// <summary> + /// ChangeRule: typeof(Neumont.Tools.ORM.ObjectModel.Role) + /// </summary> + private static void RoleNameChangedRule(ElementPropertyChangedEventArgs e) + { + if (e.DomainProperty.Id == ORMCore.Role.NameDomainPropertyId) + { + ORMCore.FactType factType = ((ORMCore.Role)e.ModelElement).FactType; + if (factType != null) + { + foreach (ConceptTypeChild child in ConceptTypeChildHasPathFactType.GetConceptTypeChild(factType)) + { + ValidateConceptTypeChildNameChanged(child); + } + } + } + } + private static void ValidateConceptTypeChildNameChanged(ConceptTypeChild child) + { + if (child != null) + { + FrameworkDomainModel.DelayValidateElement(child, DelayValidateConceptTypeChildNameChanged); + } + } + [DelayValidatePriority(20, DomainModelType = typeof(AbstractionDomainModel), Order = DelayValidatePriorityOrder.AfterDomainModel)] + private static void DelayValidateConceptTypeChildNameChanged(ModelElement element) + { + if (!element.IsDeleted) + { + ConceptTypeChild child = (ConceptTypeChild)element; + foreach (Column column in ColumnHasConceptTypeChild.GetColumn(child)) + { + ValidateSchemaNamesChanged(column.Table.Schema); + break; + } + } + } + private static void ValidateTableNameChanged(Table table) + { + if (table != null) + { + FrameworkDomainModel.DelayValidateElement(table, DelayValidateTableNameChanged); + } + } + [DelayValidatePriority(20, DomainModelType = typeof(AbstractionDomainModel), Order = DelayValidatePriorityOrder.AfterDomainModel)] + private static void DelayValidateTableNameChanged(ModelElement element) + { + if (!element.IsDeleted) + { + ValidateSchemaNamesChanged(((Table)element).Schema); + } + } + private static void ValidateSchemaNamesChanged(Schema schema) + { + if (schema != null) + { + FrameworkDomainModel.DelayValidateElement(schema, DelayValidateSchemaNamesChanged); + } + } + [DelayValidatePriority(30, DomainModelType = typeof(AbstractionDomainModel), Order = DelayValidatePriorityOrder.AfterDomainModel)] + private static void DelayValidateSchemaNamesChanged(ModelElement element) + { + if (!element.IsDeleted) + { + NameGeneration.GenerateAllNames((Schema)element); + } + } + #endregion // Name modification rules } #endregion // Regeneration rule delay validation methods } Added: trunk/RelationalModel/OialDcilBridge/NameGeneration.cs =================================================================== --- trunk/RelationalModel/OialDcilBridge/NameGeneration.cs (rev 0) +++ trunk/RelationalModel/OialDcilBridge/NameGeneration.cs 2007-08-30 17:21:57 UTC (rev 1100) @@ -0,0 +1,508 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Neumont.Tools.ORM.ObjectModel; +using Microsoft.VisualStudio.Modeling; +using Neumont.Tools.ORMAbstraction; +using Neumont.Tools.ORMToORMAbstractionBridge; +using Neumont.Tools.RelationalModels.ConceptualDatabase; +using System.Text.RegularExpressions; +using System.Diagnostics; + +namespace Neumont.Tools.ORMAbstractionToConceptualDatabaseBridge +{ + #region IDatabaseNameGenerator interface + /// <summary> + /// Generate relational names for elements contained in a <see cref="Schema"/> + /// </summary> + public interface IDatabaseNameGenerator + { + /// <summary> + /// Generate a name for the provided <paramref name="table"/> + /// </summary> + /// <param name="table">A <see cref="Table"/> element</param> + /// <param name="longerThan">Generate a more specific name than provided. + /// If this is set, then the passed in name will have been generated by + /// this method on this instance. Can be <see langword="null"/></param> + /// <returns>A name for <paramref name="table"/>.</returns> + string GenerateTableName(Table table, string longerThan); + /// <summary> + /// Generate a name for the provided <paramref name="column"/> + /// </summary> + /// <param name="column">A <see cref="Column"/> element</param> + /// <param name="longerThan">Generate a more specific name than provided. + /// If this is set, then the passed in name will have been generated by + /// this method on this instance. Can be <see langword="null"/></param> + /// <returns>A name for <paramref name="column"/>.</returns> + string GenerateColumnName(Column column, string longerThan); + /// <summary> + /// Generate a name for the provided <paramref name="constraint"/> + /// </summary> + /// <param name="constraint">A <see cref="Constraint"/> element</param> + /// <param name="longerThan">Generate a more specific name than provided. + /// If this is set, then the passed in name will have been generated by + /// this method on this instance. Can be <see langword="null"/></param> + /// <returns>A name for <paramref name="constraint"/>.</returns> + string GenerateConstraintName(Constraint constraint, string longerThan); + } + #endregion // IDatabaseNameGenerator interface + partial class ORMAbstractionToConceptualDatabaseBridgeDomainModel + { + private static class NameGeneration + { + #region GenerateAllNames method + public static void GenerateAllNames(Schema schema) + { + Dictionary<string, ConceptualDatabaseModelElement> tableNames = new Dictionary<string, ConceptualDatabaseModelElement>(); + Dictionary<string, ConceptualDatabaseModelElement> tempNames = new Dictionary<string, ConceptualDatabaseModelElement>(); + LinkedElementCollection<Table> tables = schema.TableCollection; + foreach (Table table in tables) + { + CallGeneratorForTableName(table, tableNames, null); + + //column names + tempNames.Clear(); + LinkedElementCollection<Column> columns = table.ColumnCollection; + foreach (Column column in columns) + { + CallGeneratorForColumnName(column, tempNames, null); + } + + //constraint names + LinkedElementCollection<ReferenceConstraint> constraints; + if ((constraints = table.ReferenceConstraintCollection) != null) + { + tempNames.Clear(); + foreach (ReferenceConstraint constraint in constraints) + { + CallGeneratorForConstraintName(constraint, tempNames, null); + } + } + } + } + #endregion // GenerateAllNames method + #region private helper methods + private static void CallGeneratorForTableName(Table table, Dictionary<string, ConceptualDatabaseModelElement> tableNames, string tableName) + { + CallGenerator(table, tableNames, tableName, + new GeneratorCall(delegate(ConceptualDatabaseModelElement element, string longerThan) + { + return GenerateTableName(element as Table, longerThan); + })); + } + private static void CallGeneratorForColumnName(Column column, Dictionary<string, ConceptualDatabaseModelElement> columnNames, string columnName) + { + CallGenerator(column, columnNames, columnName, + new GeneratorCall(delegate(ConceptualDatabaseModelElement element, string longerThan) + { + return GenerateColumnName(element as Column, longerThan); + })); + } + private static void CallGeneratorForConstraintName(Constraint constraint, Dictionary<string, ConceptualDatabaseModelElement> constraintNames, string constraintName) + { + CallGenerator(constraint, constraintNames, constraintName, + new GeneratorCall(delegate(ConceptualDatabaseModelElement element, string longerThan) + { + return GenerateConstraintName(element as Constraint, longerThan); + })); + } + delegate string GeneratorCall(ConceptualDatabaseModelElement element, string longerThan); + private static void CallGenerator(ConceptualDatabaseModelElement element, Dictionary<string, ConceptualDatabaseModelElement> existingNames, string curName, GeneratorCall generatorCall) + { + ConceptualDatabaseModelElement nameConflictElement = null; + while (true) + { + if (nameConflictElement != null) + { + existingNames[curName] = null; + CallGenerator(nameConflictElement, existingNames, curName, generatorCall); + } + curName = generatorCall(element, curName); + + if (existingNames.ContainsKey(curName)) + { + nameConflictElement = existingNames[curName]; + } + else + { + break; + } + } + existingNames.Add(curName, element); + Table table; + Column column; + Constraint constraint; + if ((constraint = element as Constraint) != null) + { + constraint.Name = curName; + } + else if ((column = element as Column) != null) + { + column.Name = curName; + } + else if ((table = element as Table) != null) + { + table.Name = curName; + } + } + #endregion // private helper methods + #region UNDONE: temporary static imitation of an IDatabaseNameGenerator implementation + private static Regex myReplaceStrings; + private static Regex myIsNumber; + // UNDONE: This field will not remain static when this is moved + // into an object model with additional information + private static Dictionary<string, int> myCounts; + private static string GenerateTableName(Table table, string longerThan) + { + CasingOption tableCase = CasingOption.Pascal; + string tableStringReplace = ""; + + ConceptType primaryConceptType = TableIsPrimarilyForConceptType.GetConceptType(table); + LinkedElementCollection<ConceptType> secondaryConceptTypes = TableIsAlsoForConceptType.GetConceptType(table); + StringBuilder name = new StringBuilder(); + name.Append(primaryConceptType.Name); + if (secondaryConceptTypes != null) + { + foreach (ConceptType conceptType in secondaryConceptTypes) + { + name.Append(conceptType.Name); + if (longerThan == null || FinalizeName(name.ToString(), tableCase, tableStringReplace) != longerThan) + { + break; + } + } + } + + if (myCounts != null) + { + myCounts.Clear(); + } + + string finalName = FinalizeName(name.ToString(), tableCase, tableStringReplace); + while (finalName == longerThan) + { + finalName += "_"; + } + return finalName; + } + private static string GenerateColumnName(Column column, string longerThan) + { + CasingOption columnCasing = CasingOption.Pascal; + string columnStringReplace = ""; + + string finalName; + LinkedElementCollection<ConceptTypeChild> path = ColumnHasConceptTypeChild.GetConceptTypeChildPath(column); + if (path.Count < 1) + { + finalName = FinalizeName(column.Name, columnCasing, columnStringReplace); + return EnsureDiff(finalName, longerThan); + } + + Guid tableObjectTypeID = ConceptTypeIsForObjectType.GetObjectType(TableIsPrimarilyForConceptType.GetConceptType(column.Table)).Id; + StringBuilder name = new StringBuilder(); + + bool hasUnary = false; + int predicateTextCount = 0; + bool alwaysKeepText = false; + bool hasRoleOrHyphenBound = false; + foreach (ConceptTypeChild link in path) + { + LinkedElementCollection<FactType> factTypes = ConceptTypeChildHasPathFactType.GetPathFactTypeCollection(link); + //get a role name for each fact type, or generate one from the reading + foreach (FactType factType in factTypes) + { + string roleName; + LinkedElementCollection<RoleBase> factTypeRoles = factType.RoleCollection; + int? unaryRoleIndex = FactType.GetUnaryRoleIndex(factTypeRoles); + if (unaryRoleIndex.HasValue) + { + Role unaryRole = factTypeRoles[unaryRoleIndex.Value].Role; + //get the role name, if supplied + roleName = unaryRole.Name; + if (string.IsNullOrEmpty(roleName)) + { + if (IsPreferredIdentifierFactType(factType, unaryRole)) + { + alwaysKeepText = true; + //we don't generate a role name from the reading if the fact type participates in the primary reference scheme + continue; + } + + roleName = GetRoleName(factType, factTypeRoles, unaryRole, unaryRoleIndex, ref hasRoleOrHyphenBound); + } + else + { + hasRoleOrHyphenBound = true; + } + hasUnary = true; + } + else + { + RoleBase towardsRoleBase = FactTypeMapsTowardsRole.GetTowardsRole(factType); + RoleBase oppositeRoleBase = towardsRoleBase.OppositeRoleAlwaysResolveProxy; + roleName = oppositeRoleBase.Role.Name; + if (string.IsNullOrEmpty(roleName)) + { + if (IsPreferredIdentifierFactType(factType, towardsRoleBase.Role)) + { + alwaysKeepText = true; + continue; + } + + roleName = GetRoleName(factType, factTypeRoles, oppositeRoleBase, null, ref hasRoleOrHyphenBound); + } + else + { + hasRoleOrHyphenBound = true; + } + } + if (!string.IsNullOrEmpty(roleName)) + { + ++predicateTextCount; + } + name.Append(roleName); + } + + //value type name + InformationTypeFormat informationTypeFormat; + if ((informationTypeFormat = link.Target as InformationTypeFormat) != null) + { + string valueTypeName = ""; + + //check if this value type is the preferred identifier, + //and if so prepend the object type name to the value type name + LinkedElementCollection<ConceptType> types = informationTypeFormat.ConceptTypeCollection; + if (types.Count == 1) + { + ObjectType preferredFor = ConceptTypeIsForObjectType.GetObjectType(types[0]); + LinkedElementCollection<Role> identifiers = preferredFor.ResolvedPreferredIdentifier.RoleCollection; + if (identifiers.Count == 1) + { + if (identifiers[0].RolePlayer.Id == InformationTypeFormatIsForValueType.GetValueType(informationTypeFormat).Id) + { + if (!informationTypeFormat.Name.StartsWith(preferredFor.Name)) + { + valueTypeName = preferredFor.Name + "_"; + } + } + } + } + + valueTypeName += informationTypeFormat.Name; + + if (!hasUnary || (longerThan != null && longerThan == FinalizeName(name.ToString(), columnCasing, columnStringReplace))) + { + if (!(hasRoleOrHyphenBound || alwaysKeepText) && (predicateTextCount == 1 && + (longerThan == null || longerThan != FinalizeName(valueTypeName, columnCasing, columnStringReplace)))) + { + //if the only existing text is a single role name generated from predicate text, remove it + name.Remove(0, name.Length); + name.Append(valueTypeName); + } + else if (!hasRoleOrHyphenBound || FinalizeName(name.ToString(), columnCasing, columnStringReplace) == longerThan) + { + name.Append(valueTypeName); + } + } + } + } + + finalName = FinalizeName(name.ToString(), columnCasing, columnStringReplace); + return EnsureDiff(finalName, longerThan); + } + + private static string GenerateConstraintName(Constraint constraint, string longerThan) + { + ReferenceConstraint refConstraint = constraint as ReferenceConstraint; + if (refConstraint != null) + { + StringBuilder name = new StringBuilder(refConstraint.SourceTable.Name); + name.Append("_FK"); + return EnsureDiff(name.ToString(), longerThan); + } + return constraint.Name; + } + private enum CasingOption + { + Pascal, + Camel, + Flat, + Upper, + } + private static string FinalizeName(string name, CasingOption casing, string spaceReplaceString) + { + for (int i = name.Length; --i > -1; ) + { + if (char.IsUpper(name, i)) + { + name = name.Insert(i, " "); + } + } + + string[] words = name.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); + if (words.Length > 0) + { + switch (casing) + { + case CasingOption.Camel: + words[0] = words[0].ToLowerInvariant(); + CapitalizeWords(words, 1); + break; + case CasingOption.Pascal: + CapitalizeWords(words, 0); + break; + } + StringBuilder builder = new StringBuilder(words[0]); + for (int i = 1; i < words.Length; ++i) + { + builder.Append(spaceReplaceString); + builder.Append(words[i]); + } + name = builder.ToString(); + + switch (casing) + { + case CasingOption.Flat: + name = name.ToLowerInvariant(); + break; + case CasingOption.Upper: + name = name.ToUpperInvariant(); + break; + } + } + else + { + name = ""; + } + + return name; + } + + private static void CapitalizeWords(string[] words, int startIndex) + { + for (int i = startIndex; i < words.Length; ++i) + { + words[i] = System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(words[i]); + } + } + private static string EnsureDiff(string name, string longerThan) + { + if (longerThan != null && longerThan.StartsWith(name)) + { + bool isSame = name == longerThan; + if (!isSame) + { + if (myIsNumber == null) + { + myIsNumber = new Regex(@"\d+", RegexOptions.RightToLeft | RegexOptions.Compiled); + } + string endNumbers = longerThan.Substring(name.Length); + Match longerThanMatches = myIsNumber.Match(endNumbers); + if (longerThanMatches.Success && longerThanMatches.Index + longerThanMatches.Length == endNumbers.Length) + { + isSame = true; + } + } + + if (isSame) + { + if (myCounts == null) + { + myCounts = new Dictionary<string, int>(); + } + int curCount; + if (myCounts.ContainsKey(name)) + { + curCount = myCounts[name]; + ++myCounts[name]; + } + else + { + curCount = 1; + myCounts.Add(name, 2); + } + name += curCount.ToString(); + } + } + return name; + } + private static bool IsPreferredIdentifierFactType(FactType factType, Role role) + { + return role.RolePlayer.ResolvedPreferredIdentifier.FactTypeCollection.Contains(factType); + } + private static ReadingOrder GetReading(FactType factType, Role role, bool isUnary) + { + if (!isUnary) + { + //get the reading in the correct direction, if possible + ReadingOrder readingOrder = factType.FindMatchingReadingOrder(new RoleBase[] { role.OppositeRoleAlwaysResolveProxy, role }); + if (null != readingOrder) + { + return readingOrder; + } + } + + LinkedElementCollection<ReadingOrder> readingOrders = factType.ReadingOrderCollection; + + foreach (ReadingOrder readingOrder in readingOrders) + { + return readingOrder; + } + + //if there is no reading return the object type name + return null; + } + private static string GetRoleName(FactType factType, LinkedElementCollection<RoleBase> factTypeRoles, RoleBase role, int? unaryRoleIndex, ref bool alwaysKeepText) + { + string roleName = role.Role.Name; + if (string.IsNullOrEmpty(roleName)) + { + roleName = GetRoleNameFromPredicateText(factType, factTypeRoles, role, unaryRoleIndex, ref alwaysKeepText); + } + return roleName; + } + private static string GetRoleNameFromPredicateText(FactType factType, LinkedElementCollection<RoleBase> factTypeRoles, RoleBase role, int? unaryRoleIndex, ref bool alwaysKeepText) + { + bool isUnary = unaryRoleIndex.HasValue; + ReadingOrder readingOrder = GetReading(factType, role.Role, isUnary); + string rolePlayerName = role.Role.RolePlayer.Name; + if (readingOrder == null) + { + return rolePlayerName; + } + else + { + IReading reading = readingOrder.PrimaryReading; + // UNDONE: The hyphen binder does a lot of stuff we don't need, including + // building replacement strings for each role and rebuilding the predicate text. + // Add another method to the hyphenBinder to support binding one role only. + VerbalizationHyphenBinder hyphenBinder = new VerbalizationHyphenBinder(reading, factTypeRoles, unaryRoleIndex, "{0}{{0}}{1}"); + string hyphenBoundRolePlayerName = hyphenBinder.HyphenBindRoleReplacement(rolePlayerName, factTypeRoles.IndexOf(role)); + if ((object)hyphenBoundRolePlayerName != (object)rolePlayerName) + { + alwaysKeepText = true; + // The hyphen binder had an opinion + return hyphenBoundRolePlayerName; + } + string text = reading.Text; + if (myReplaceStrings == null) + { + myReplaceStrings = new Regex(@"{\d+}", RegexOptions.Compiled); + } + text = myReplaceStrings.Replace(text, ""); + text = text.Replace(" a ", " ").Replace(" an ", " ").Replace(" the ", " "); + if (!isUnary) + { + text = text.Replace(" has ", " "); + } + else if (text.Trim().ToLowerInvariant() == "has") + { + text = " "; + } + return text; + } + } + #endregion //UNDONE: temporary static immitation of an IDatabaseNameGenerator implementation + } + } +} Modified: trunk/RelationalModel/OialDcilBridge/OialDcilBridge.AttachRules.cs =================================================================== --- trunk/RelationalModel/OialDcilBridge/OialDcilBridge.AttachRules.cs 2007-08-30 17:19:27 UTC (rev 1099) +++ trunk/RelationalModel/OialDcilBridge/OialDcilBridge.AttachRules.cs 2007-08-30 17:21:57 UTC (rev 1100) @@ -38,10 +38,13 @@ typeof(ModificationTracker).GetNestedType("AssimilationMappingAddedRuleClass", BindingFlags.Public | BindingFlags.NonPublic), typeof(ModificationTracker).GetNestedType("AssimilationMappingChangedRuleClass", BindingFlags.Public | BindingFlags.NonPublic), typeof(ModificationTracker).GetNestedType("ConceptTypeAddedRuleClass", BindingFlags.Public | BindingFlags.NonPublic), + typeof(ModificationTracker).GetNestedType("ConceptTypeChangedRuleClass", BindingFlags.Public | BindingFlags.NonPublic), typeof(ModificationTracker).GetNestedType("ConceptTypeChildChangedRuleClass", BindingFlags.Public | BindingFlags.NonPublic), typeof(ModificationTracker).GetNestedType("ConceptTypeDeletedRuleClass", BindingFlags.Public | BindingFlags.NonPublic), + typeof(ModificationTracker).GetNestedType("FactTypeNameChangedRuleClass", BindingFlags.Public | BindingFlags.NonPublic), typeof(ModificationTracker).GetNestedType("InformationTypeFormatAddedRuleClass", BindingFlags.Public | BindingFlags.NonPublic), typeof(ModificationTracker).GetNestedType("InformationTypeFormatDeletedRuleClass", BindingFlags.Public | BindingFlags.NonPublic), + typeof(ModificationTracker).GetNestedType("RoleNameChangedRuleClass", BindingFlags.Public | BindingFlags.NonPublic), typeof(ModificationTracker).GetNestedType("UniquenessDeletedRuleClass", BindingFlags.Public | BindingFlags.NonPublic), typeof(AssimilationMapping).GetNestedType("AssimilationMappingAddedRuleClass", BindingFlags.Public | BindingFlags.NonPublic), typeof(AssimilationMapping).GetNestedType("AssimilationMappingChangedRuleClass", BindingFlags.Public | BindingFlags.NonPublic)}; @@ -78,7 +81,7 @@ { Microsoft.VisualStudio.Modeling.RuleManager ruleManager = store.RuleManager; Type[] disabledRuleTypes = ORMAbstractionToConceptualDatabaseBridgeDomainModel.CustomDomainModelTypes; - for (int i = 0; i < 11; ++i) + for (int i = 0; i < 14; ++i) { ruleManager.EnableRule(disabledRuleTypes[i]); } @@ -199,6 +202,32 @@ Neumont.Tools.Modeling.Diagnostics.TraceUtility.TraceRuleEnd(e.ModelElement.Store, "Neumont.Tools.ORMAbstractionToConceptualDatabaseBridge.ORMAbstractionToConceptualDatabaseBridgeDomainModel.ModificationTracker.ConceptTypeAddedRule"); } } + [Microsoft.VisualStudio.Modeling.RuleOn(typeof(Neumont.Tools.ORMAbstraction.ConceptType))] + private sealed class ConceptTypeChangedRuleClass : Microsoft.VisualStudio.Modeling.ChangeRule + { + [System.Diagnostics.DebuggerStepThrough()] + public ConceptTypeChangedRuleClass() + { + base.IsEnabled = false; + } + /// <summary> + /// Provide the following method in class: + /// Neumont.Tools.ORMAbstractionToConceptualDatabaseBridge.ORMAbstractionToConceptualDatabaseBridgeDomainModel.ModificationTracker + /// /// <summary> + /// /// ChangeRule: typeof(Neumont.Tools.ORMAbstraction.ConceptType) + /// /// </summary> + /// private static void ConceptTypeChangedRule(ElementPropertyChangedEventArgs e) + /// { + /// } + /// </summary> + [System.Diagnostics.DebuggerStepThrough()] + public override void ElementPropertyChanged(Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs e) + { + Neumont.Tools.Modeling.Diagnostics.TraceUtility.TraceRuleStart(e.ModelElement.Store, "Neumont.Tools.ORMAbstractionToConceptualDatabaseBridge.ORMAbstractionToConceptualDatabaseBridgeDomainModel.ModificationTracker.ConceptTypeChangedRule"); + ModificationTracker.ConceptTypeChangedRule(e); + Neumont.Tools.Modeling.Diagnostics.TraceUtility.TraceRuleEnd(e.ModelElement.Store, "Neumont.Tools.ORMAbstractionToConceptualDatabaseBridge.ORMAbstractionToConceptualDatabaseBridgeDomainModel.ModificationTracker.ConceptTypeChangedRule"); + } + } [Microsoft.VisualStudio.Modeling.RuleOn(typeof(Neumont.Tools.ORMAbstraction.ConceptTypeChild))] private sealed class ConceptTypeChildChangedRuleClass : Microsoft.VisualStudio.Modeling.ChangeRule { @@ -251,6 +280,32 @@ Neumont.Tools.Modeling.Diagnostics.TraceUtility.TraceRuleEnd(e.ModelElement.Store, "Neumont.Tools.ORMAbstractionToConceptualDatabaseBridge.ORMAbstractionToConceptualDatabaseBridgeDomainModel.ModificationTracker.ConceptTypeDeletedR... [truncated message content] |
From: <mcu...@us...> - 2007-08-30 17:24:14
|
Revision: 1101 http://orm.svn.sourceforge.net/orm/?rev=1101&view=rev Author: mcurland Date: 2007-08-30 10:24:00 -0700 (Thu, 30 Aug 2007) Log Message: ----------- Improved top-level concept type and non-top-level concept type count detection used by FactTypeMappingPermuter. Various other bug fixes and tweaks. refs #327 Modified Paths: -------------- trunk/ORMModel/ObjectModel/ObjectType.cs trunk/Oial/ORMOialBridge/ORMOialBridgePermuter.cs trunk/Oial/ORMOialBridge/ORMOialBridgeStructures.cs trunk/Oial/ORMOialBridge/OialModelIsForORMModel.cs Modified: trunk/ORMModel/ObjectModel/ObjectType.cs =================================================================== --- trunk/ORMModel/ObjectModel/ObjectType.cs 2007-08-30 17:21:57 UTC (rev 1100) +++ trunk/ORMModel/ObjectModel/ObjectType.cs 2007-08-30 17:24:00 UTC (rev 1101) @@ -1569,6 +1569,20 @@ } } /// <summary> + /// Indicates if this <see cref="ObjectType"/> is implied independent. + /// </summary> + public bool IsImpliedIndependent() + { + return !this.IsIndependent && this.ImpliedMandatoryConstraint == null && this.AllowIsIndependent(false); + } + /// <summary> + /// Indicates if this <see cref="ObjectType"/> is either implied independent or explicity independent. + /// </summary> + public bool IsAnyIndependent() + { + return this.IsIndependent || this.IsImpliedIndependent(); + } + /// <summary> /// Test if the <see cref="IsIndependent"/> property can be set to true. /// </summary> /// <param name="throwIfFalse">Set to <see langword="true"/> to throw an exception instead of returning false.</param> Modified: trunk/Oial/ORMOialBridge/ORMOialBridgePermuter.cs =================================================================== --- trunk/Oial/ORMOialBridge/ORMOialBridgePermuter.cs 2007-08-30 17:21:57 UTC (rev 1100) +++ trunk/Oial/ORMOialBridge/ORMOialBridgePermuter.cs 2007-08-30 17:24:00 UTC (rev 1101) @@ -113,8 +113,14 @@ Chain chain = new Chain(); myChains.Add(chain); + // Assuming ProcessObjectType works correctly, we will never hit an object type a second time, + // so we can clear the Dictionary here and then use it as a record of all object types in the chain. + visitedObjectTypes.Clear(); + ProcessObjectType(factType.RoleCollection[0].Role.RolePlayer, chain, visitedFactTypes, visitedObjectTypes); + // Record all object types that are in the chain. + chain.ObjectTypes.AddRange(visitedObjectTypes.Keys); } } private void ProcessObjectType(ObjectType objectType, Chain chain, Dictionary<FactType, object> visitedFactTypes, Dictionary<ObjectType, object> visitedObjectTypes) @@ -205,22 +211,14 @@ private readonly FactTypeMappingDictionary myDecidedFactTypeMappings; - // Stores a list of object types that had been considered valid top-level, but was later found to be deeply mapped away - private readonly ObjectTypeDictionary myInvalidObjectTypes; - // A single set of possible fact type mappings represented at a given iteration through all possible fact type mappings - private readonly ObjectTypeDictionary myPossibleTopLevelConceptTypes; - private readonly ObjectTypeDictionary myPossibleConceptTypes; - - public FactTypeMappingPermuter(FactTypeMappingDictionary predecidedManyToOneFactTypeMappings, FactTypeMappingDictionary predecidedOneToOneFactTypeMappings, FactTypeMappingListDictionary undecidedOneToOneFactTypeMappings) { myPredecidedManyToOneFactTypeMappings = predecidedManyToOneFactTypeMappings; myPredecidedOneToOneFactTypeMappings = predecidedOneToOneFactTypeMappings; myUndecidedOneToOneFactTypeMappings = undecidedOneToOneFactTypeMappings; - int oneToOneFactTypeCount = predecidedOneToOneFactTypeMappings.Count + undecidedOneToOneFactTypeMappings.Count; - myDecidedFactTypeMappings = new FactTypeMappingDictionary(predecidedManyToOneFactTypeMappings.Count + oneToOneFactTypeCount); + myDecidedFactTypeMappings = new FactTypeMappingDictionary(predecidedManyToOneFactTypeMappings.Count + predecidedOneToOneFactTypeMappings.Count + undecidedOneToOneFactTypeMappings.Count); foreach (KeyValuePair<FactType, FactTypeMapping> pair in predecidedManyToOneFactTypeMappings) { @@ -230,11 +228,6 @@ { myDecidedFactTypeMappings.Add(pair.Key, pair.Value); } - - // Stores a list of object types that had been considered valid top-level, but was later found to be deeply mapped away - myInvalidObjectTypes = new ObjectTypeDictionary(oneToOneFactTypeCount); - myPossibleTopLevelConceptTypes = new ObjectTypeDictionary(oneToOneFactTypeCount); - myPossibleConceptTypes = new ObjectTypeDictionary(oneToOneFactTypeCount); } /// <summary> @@ -248,13 +241,17 @@ private void PermuteFactTypeMappings() { + // UNDONE: We should consider whether we can determine what object types will collapse earlier in the process, which would allow us to + // potentially eliminate multiple permutations that have the same result. (Rationale: When an object type is collapsed, it doesn't matter + // whether the mappings away from it are shallow or deep; they both result in the same output.) + int largestChainCount; // Break up the chains of contiguous one-to-one fact types FactTypeChainer chainer = new FactTypeChainer(myPredecidedManyToOneFactTypeMappings, myPredecidedOneToOneFactTypeMappings, myUndecidedOneToOneFactTypeMappings); largestChainCount = chainer.Run(); // Perform one-time pass of top-level types for the decided mappings - PrecalculateDecidedConceptTypes(); + //PrecalculateDecidedConceptTypes(); // This is used in PermuteFactTypeMappings(). We allocate it once, here, for permformance reasons. FactTypeMappingList newlyDecidedFactTypeMappings = new FactTypeMappingList(largestChainCount); @@ -280,7 +277,7 @@ PermuteFactTypeMappings(chain.PossiblePermutations, chain.UndecidedOneToOneFactTypeMappings, newlyDecidedFactTypeMappings, deeplyMappedObjectTypes, 0); EliminateInvalidPermutations(chain); - CalculateTopLevelConceptTypes(chain); + FindSmallestPermutationsInTermsOfConceptTypes(chain); // Add each mapping from the optimal permutation to the "global" set of decided mappings. foreach (FactTypeMapping optimalMapping in ChooseOptimalPermutation(chain).Mappings) @@ -313,166 +310,165 @@ return null; } - private static Permutation ChooseOptimalPermutation(Chain chain) + private static void FindSmallestPermutationsInTermsOfConceptTypes(Chain chain) { - // UNDONE: This should do something smart! - PermutationList smallestPermutationsList = chain.SmallestPermutations; - Permutation firstFinalMappingState = smallestPermutationsList[0]; - smallestPermutationsList.Clear(); - return firstFinalMappingState; - } + int maxPossibleObjectTypes = chain.ObjectTypes.Count; - private void PrecalculateDecidedConceptTypes() - { - // Calculate decided top-level types (these are *not* final until individual permutations have been considered) - foreach (KeyValuePair<FactType, FactTypeMapping> pair in myDecidedFactTypeMappings) - { - ProcessEntity(new ProcessEntityState(pair.Value, null, null, null)); - } - } + // These object types definitely DO result in concept types, but MAY or MAY NOT result in top-level concept types + Dictionary<ObjectType, object> predecidedObjectTypesThatAreIndependentOrSubtypesOrHaveNonPreferredIdentifierMappingsTowards = new Dictionary<ObjectType, object>(maxPossibleObjectTypes); - /// <summary> - /// An object type (A) is a concept type when: - /// 1. It is independent, or - /// 2. It is a subtype, or - /// 3. Another object type (B) is mapped to it, and - /// a. There exists a role being mapped to object type A on which there are no constraints, or - /// b. There exists a role being mapped to object type A on which there is not a preferred uniqueness. - /// - /// A concept type is a top-level concept type when: - /// 1. It is not deeply mapped towards any other concept type. - /// - /// As this method processes the ObjectType passed in it gradually (and probably not in the same pass) executes each of - /// the above checks to see whether the ObjectType is a concept type or top-level concept type. - /// </summary> - /// <param name="state"></param> - private void ProcessEntity(ProcessEntityState state) - { - ObjectType towards = state.Mapping.TowardsObjectType; - if (myInvalidObjectTypes.ContainsKey(towards)) + // These object types definitely DO NOT result in top-level concept types, but MAY or MAY NOT result in concept types + Dictionary<ObjectType, object> predecidedObjectTypesThatHaveDeepMappingsAway = new Dictionary<ObjectType, object>(maxPossibleObjectTypes); + + // By just examining the predecided mappings, we can determine the specified truth values for the following: + // Object Type is Concept Type {true, unknown} + // Object Type is Top Level Concept Type {false, unknown} + + foreach (FactTypeMapping mapping in chain.PredecidedManyToOneFactTypeMappings) { - return; - } - ObjectType from = state.Mapping.FromObjectType; - Role fromRole = state.Mapping.FromRole; - if (from.IsIndependent && !(fromRole is SubtypeMetaRole) && !myPossibleConceptTypes.ContainsKey(from)) - { - // Add the object type as a concept type if it's independent. - myPossibleConceptTypes.Add(from, true); - if (state.ConceptTypeGarbage != null) + Debug.Assert(mapping.MappingDepth == MappingDepth.Shallow); + if (!mapping.IsFromPreferredIdentifier) { - state.ConceptTypeGarbage.Add(from); + predecidedObjectTypesThatAreIndependentOrSubtypesOrHaveNonPreferredIdentifierMappingsTowards[mapping.TowardsObjectType] = null; } } - // If the |from| OT is a primary identifier, DO NOT add the |towards| OT to the top-level list - // (Note that it doesn't mean it cannot be added earlier/later, but will not if only role played is primary identifier) - if (state.Mapping.IsFromPreferredIdentifier) + + foreach (FactTypeMapping mapping in chain.PredecidedOneToOneFactTypeMappings) { - return; - } - if (!myPossibleConceptTypes.ContainsKey(from)) - { - // All top-level concept types are at least concept types - myPossibleConceptTypes.Add(from, true); - if (state.ConceptTypeGarbage != null && !state.ConceptTypeGarbage.Contains(from)) + if (!mapping.IsFromPreferredIdentifier) { - state.ConceptTypeGarbage.Add(from); + predecidedObjectTypesThatAreIndependentOrSubtypesOrHaveNonPreferredIdentifierMappingsTowards[mapping.TowardsObjectType] = null; } - } - MappingDepth mappingType = state.Mapping.MappingDepth; - // If the |from| OT is mapped away deeply, and has objects mapped to it, remove it and invalidate it as a possible top-level type - if (myPossibleTopLevelConceptTypes.ContainsKey(from) && mappingType == MappingDepth.Deep) - { - myPossibleTopLevelConceptTypes.Remove(from); - myInvalidObjectTypes.Add(from, true); - if (state.Restore != null) + if (mapping.FromRole is SubtypeMetaRole) { - state.Restore.Add(from); + predecidedObjectTypesThatAreIndependentOrSubtypesOrHaveNonPreferredIdentifierMappingsTowards[mapping.FromObjectType] = null; } + if (mapping.MappingDepth == MappingDepth.Deep) + { + predecidedObjectTypesThatHaveDeepMappingsAway[mapping.FromObjectType] = null; + } } - // First clause in there because |from| could equal |towards|, and may be invalidated in prior conditional - if (!myInvalidObjectTypes.ContainsKey(towards) && !myPossibleTopLevelConceptTypes.ContainsKey(towards)) + + foreach (ObjectType objectType in chain.ObjectTypes) { - if (state.Garbage != null) + if (objectType.IsAnyIndependent()) { - state.Garbage.Add(towards); + predecidedObjectTypesThatAreIndependentOrSubtypesOrHaveNonPreferredIdentifierMappingsTowards[objectType] = null; } - myPossibleTopLevelConceptTypes.Add(towards, true); } - } - /// <summary> - /// This method processes concept type and top-level concept type conditions gradually as it iterates over the chain, rather than - /// calculating top-level-ness immediately for every concept type. The final state of each concept type is valid after this - /// method is finished executing. - /// - /// See <see cref="ProcessEntity">ProcessEntity</see> for the algorithm. - /// </summary> - /// <param name="chain"></param> - private void CalculateTopLevelConceptTypes(Chain chain) - { - // The smallest overall mapping that we've found - int smallest = int.MaxValue; - // These dictionaries track the OTs that are temporarily removed or added for each permutation in the list - ObjectTypeList garbage = new ObjectTypeList(myDecidedFactTypeMappings.Count); - ObjectTypeList restore = new ObjectTypeList(myDecidedFactTypeMappings.Count); - ObjectTypeList conceptTypeGarbage = new ObjectTypeList(myDecidedFactTypeMappings.Count); - // Now include the permutations in the calculation of top-level types. - for (int i = 0; i < chain.PossiblePermutations.Count; i++) + Dictionary<ObjectType, object> permutationObjectTypesThatHaveNonPreferredIdentifierMappingsTowards = new Dictionary<ObjectType, object>(maxPossibleObjectTypes); + Dictionary<ObjectType, object> permutationObjectTypesThatHaveDeepMappingsAway = new Dictionary<ObjectType, object>(maxPossibleObjectTypes); + + Dictionary<ObjectType, object> notConceptTypes = new Dictionary<ObjectType, object>(maxPossibleObjectTypes); + Dictionary<ObjectType, object> nonTopLevelConceptTypes = new Dictionary<ObjectType, object>(maxPossibleObjectTypes); + Dictionary<ObjectType, object> topLevelConceptTypes = new Dictionary<ObjectType, object>(maxPossibleObjectTypes); + + PermutationList smallestPermutationsInTermsOfConceptTypes = chain.SmallestPermutationsInTermsOfConceptTypes; + + int minTopLevelConceptTypesCount = int.MaxValue; + int minNonTopLevelConceptTypesCount = int.MaxValue; + + foreach (Permutation permutation in chain.PossiblePermutations) { - garbage.Clear(); - restore.Clear(); - Permutation state = chain.PossiblePermutations[i]; - foreach (FactTypeMapping mapping in state.Mappings) + bool isNotOptimalPermutation = false; + + permutationObjectTypesThatHaveDeepMappingsAway.Clear(); + permutationObjectTypesThatHaveNonPreferredIdentifierMappingsTowards.Clear(); + + notConceptTypes.Clear(); + nonTopLevelConceptTypes.Clear(); + topLevelConceptTypes.Clear(); + + foreach (FactTypeMapping mapping in permutation.Mappings) { - ProcessEntityState entitystate = new ProcessEntityState(mapping, restore, garbage, conceptTypeGarbage); - ProcessEntity(entitystate); - if (myPossibleTopLevelConceptTypes.Count > smallest) + if (!mapping.IsFromPreferredIdentifier) { - break; + permutationObjectTypesThatHaveNonPreferredIdentifierMappingsTowards[mapping.TowardsObjectType] = null; } + if (mapping.MappingDepth == MappingDepth.Deep) + { + permutationObjectTypesThatHaveDeepMappingsAway[mapping.FromObjectType] = null; + } } - // Done for this state, so finalize and clean up - state.TopLevelConceptTypes = myPossibleTopLevelConceptTypes.Count; - state.ConceptTypes = myPossibleConceptTypes.Count; - if (state.TopLevelConceptTypes <= smallest) + + foreach (ObjectType objectType in chain.ObjectTypes) { - smallest = state.TopLevelConceptTypes; - PermutationList smallestList = chain.SmallestPermutations; - if (smallestList.Count > 0) + bool isIndependentOrSubtypeOrHasNonPreferredIdentifierMappingsTowards = predecidedObjectTypesThatAreIndependentOrSubtypesOrHaveNonPreferredIdentifierMappingsTowards.ContainsKey(objectType) || + permutationObjectTypesThatHaveNonPreferredIdentifierMappingsTowards.ContainsKey(objectType); + bool hasDeepMappingsAway = predecidedObjectTypesThatHaveDeepMappingsAway.ContainsKey(objectType) || permutationObjectTypesThatHaveDeepMappingsAway.ContainsKey(objectType); + + if (isIndependentOrSubtypeOrHasNonPreferredIdentifierMappingsTowards) { - if (smallestList[0].TopLevelConceptTypes > state.TopLevelConceptTypes) + if (hasDeepMappingsAway) { - smallestList.Clear(); + nonTopLevelConceptTypes[objectType] = null; + if ((topLevelConceptTypes.Count == minTopLevelConceptTypesCount) && (nonTopLevelConceptTypes.Count > minNonTopLevelConceptTypesCount)) + { + // We now have more non-top-level concept types than the minimum, and the same number of top-level concept types as the minimum, so throw this permutation out. + isNotOptimalPermutation = true; + break; + } } - // Be sure the logic works if you put this |else if| into the primary |if|. - else if (smallestList[0].ConceptTypes > state.ConceptTypes) + else { - smallestList.Clear(); + topLevelConceptTypes[objectType] = null; + if (topLevelConceptTypes.Count > minTopLevelConceptTypesCount) + { + // We now have more top-level concept types than the minimum, so throw this permutation out. + isNotOptimalPermutation = true; + break; + } } } - if (smallestList.Count == 0 || smallestList[0].ConceptTypes == state.ConceptTypes) - { - smallestList.Add(state); - } } - // Restore OTs removed from the |myPossibleTopLevelConceptTypes| collection; remove elements that were added to the collection - foreach (ObjectType ot in garbage) + + if (isNotOptimalPermutation) { - myPossibleTopLevelConceptTypes.Remove(ot); + // This isn't an optimal permutation, so go on to the next one. + continue; } - foreach (ObjectType ot in restore) + + Debug.Assert(topLevelConceptTypes.Count <= minTopLevelConceptTypesCount, "Permutations with greater than the minimum number of top-level concept types should have been rejected inline."); + + if (topLevelConceptTypes.Count < minTopLevelConceptTypesCount) { - myPossibleTopLevelConceptTypes.Add(ot, true); - myInvalidObjectTypes.Remove(ot); + // We have a new minimum number of top-level concept types (and hence a new minimum number of non-top-level concept types as well). + minTopLevelConceptTypesCount = topLevelConceptTypes.Count; + minNonTopLevelConceptTypesCount = nonTopLevelConceptTypes.Count; + smallestPermutationsInTermsOfConceptTypes.Clear(); } - foreach (ObjectType ot in conceptTypeGarbage) + else { - myPossibleConceptTypes.Remove(ot); + // We have the same number of top-level concept types as the minimum, so we need to check the number of non-top-level concept types. + if (nonTopLevelConceptTypes.Count > minTopLevelConceptTypesCount) + { + // This isn't an optimal permutation, so go on to the next one. + continue; + } + else if (nonTopLevelConceptTypes.Count < minNonTopLevelConceptTypesCount) + { + // We have a new minimum number of non-top-level concept type. + minNonTopLevelConceptTypesCount = nonTopLevelConceptTypes.Count; + smallestPermutationsInTermsOfConceptTypes.Clear(); + } } + permutation.SetConceptTypes(topLevelConceptTypes, nonTopLevelConceptTypes); + smallestPermutationsInTermsOfConceptTypes.Add(permutation); } } + + + private static Permutation ChooseOptimalPermutation(Chain chain) + { + // UNDONE: This should do something smart! + PermutationList smallestPermutationsInTermsOfConceptTypes = chain.SmallestPermutationsInTermsOfConceptTypes; + Permutation firstFinalMappingState = smallestPermutationsInTermsOfConceptTypes[0]; + //smallestPermutationsInTermsOfConceptTypes.Clear(); + return firstFinalMappingState; + } + /// <summary> /// Returns the maximum number of <see cref="Permutation"/>s that could result for the specified set of undecided <see cref="FactTypeMapping"/>s. /// </summary> @@ -632,4 +628,4 @@ } } #endregion -} +} \ No newline at end of file Modified: trunk/Oial/ORMOialBridge/ORMOialBridgeStructures.cs =================================================================== --- trunk/Oial/ORMOialBridge/ORMOialBridgeStructures.cs 2007-08-30 17:21:57 UTC (rev 1100) +++ trunk/Oial/ORMOialBridge/ORMOialBridgeStructures.cs 2007-08-30 17:24:00 UTC (rev 1101) @@ -55,7 +55,7 @@ } [Serializable] - [DebuggerDisplay("FactTypeMapping (TowardsRole={FactType.RoleCollection.IndexOf(FromRole)}, Depth={MappingDepth}, FactType={FactType.Name})")] + [DebuggerDisplay("FactTypeMapping (TowardsRole={FactType.RoleCollection.IndexOf(TowardsRoleDebug)}, Depth={MappingDepth}, FactType={FactType.Name})")] sealed class FactTypeMapping { private readonly FactType factType; @@ -106,6 +106,14 @@ get { return towardsRole; } } + /// <summary> + /// Used by the <see cref="DebuggerDisplayAttribute"/> for this type. + /// </summary> + private RoleBase TowardsRoleDebug + { + get { return (RoleBase)towardsRole.Proxy ?? towardsRole; } + } + public MappingDepth MappingDepth { get { return mappingDepth; } @@ -251,8 +259,8 @@ sealed class Permutation { private readonly FactTypeMappingList myMappings; - private int myTopLevelConceptTypes; - private int myConceptTypes; + private Dictionary<ObjectType, object> myTopLevelConceptTypes; + private Dictionary<ObjectType, object> myNonTopLevelConceptTypes; public Permutation(FactTypeMappingList mappings) { @@ -264,17 +272,28 @@ get { return myMappings; } } - public int TopLevelConceptTypes + public void SetConceptTypes(Dictionary<ObjectType, object> topLevelConceptTypes, Dictionary<ObjectType, object> nonTopLevelConceptTypes) { - get { return myTopLevelConceptTypes; } - set { myTopLevelConceptTypes = value; } + Debug.Assert(myTopLevelConceptTypes == null && myNonTopLevelConceptTypes == null); + myTopLevelConceptTypes = new Dictionary<ObjectType,object>(topLevelConceptTypes); + myNonTopLevelConceptTypes = new Dictionary<ObjectType,object>(nonTopLevelConceptTypes); } - public int ConceptTypes + public Dictionary<ObjectType, object> TopLevelConceptTypes { - get { return myConceptTypes; } - set { myConceptTypes = value; } + get + { + return myTopLevelConceptTypes; + } } + + public Dictionary<ObjectType, object> NonTopLevelConceptTypes + { + get + { + return myNonTopLevelConceptTypes; + } + } } [Serializable] @@ -302,19 +321,21 @@ [Serializable] sealed class Chain { + private readonly ObjectTypeList myObjectTypes; private readonly FactTypeMappingList myPredecidedManyToOneFactTypeMappings; private readonly FactTypeMappingList myPredecidedOneToOneFactTypeMappings; private readonly FactTypeMappingListList myUndecidedOneToOneFactTypeMappings; private readonly PermutationList myPossiblePermutations; - private readonly PermutationList mySmallestPermutations; + private readonly PermutationList mySmallestPermutationsInTermsOfConceptTypes; public Chain() { + myObjectTypes = new ObjectTypeList(); myPredecidedManyToOneFactTypeMappings = new FactTypeMappingList(); myPredecidedOneToOneFactTypeMappings = new FactTypeMappingList(); myUndecidedOneToOneFactTypeMappings = new FactTypeMappingListList(); myPossiblePermutations = new PermutationList(); - mySmallestPermutations = new PermutationList(); + mySmallestPermutationsInTermsOfConceptTypes = new PermutationList(); } /// <summary> @@ -329,6 +350,18 @@ } /// <summary> + /// The set of all <see cref="ObjectType"/>s that play a role in a one-to-one <see cref="FactType"/> + /// in this <see cref="Chain"/>. + /// </summary> + public ObjectTypeList ObjectTypes + { + get + { + return myObjectTypes; + } + } + + /// <summary> /// Many-to-one FactTypeMappings that are part of this chain but were decided before the permutation phase. /// </summary> public FactTypeMappingList PredecidedManyToOneFactTypeMappings @@ -367,11 +400,11 @@ } /// <summary> - /// The entries from PossiblePermutations which map to the smallest number of top-level concept types. + /// The entries from PossiblePermutations which map to the smallest number of top-level concept types and overall concept types. /// </summary> - public PermutationList SmallestPermutations + public PermutationList SmallestPermutationsInTermsOfConceptTypes { - get { return mySmallestPermutations; } + get { return mySmallestPermutationsInTermsOfConceptTypes; } } } #endregion Modified: trunk/Oial/ORMOialBridge/OialModelIsForORMModel.cs =================================================================== --- trunk/Oial/ORMOialBridge/OialModelIsForORMModel.cs 2007-08-30 17:21:57 UTC (rev 1100) +++ trunk/Oial/ORMOialBridge/OialModelIsForORMModel.cs 2007-08-30 17:24:00 UTC (rev 1101) @@ -466,13 +466,13 @@ /// <param name="undecidedOneToOneFactTypeMappings">The undecided <see cref="FactTypeMapping"/> possibilities.</param> private void FilterFactTypeMappings(FactTypeMappingDictionary decidedManyToOneFactTypeMappings, FactTypeMappingDictionary decidedOneToOneFactTypeMappings, FactTypeMappingListDictionary undecidedOneToOneFactTypeMappings) { - RemoveImpossiblePotentialFactTypeMappings(decidedOneToOneFactTypeMappings, undecidedOneToOneFactTypeMappings); - - int changeCount = 0; + bool changed; do { - changeCount = MapTrivialOneToOneFactTypesWithTwoMandatories(decidedOneToOneFactTypeMappings, undecidedOneToOneFactTypeMappings); - } while (changeCount > 0); + RemoveImpossiblePotentialFactTypeMappings(decidedOneToOneFactTypeMappings, undecidedOneToOneFactTypeMappings); + + changed = MapTrivialOneToOneFactTypesWithTwoMandatories(decidedOneToOneFactTypeMappings, undecidedOneToOneFactTypeMappings) > 0; + } while (changed); } #region Filter Algorithms Methods @@ -484,17 +484,15 @@ /// <param name="undecidedOneToOneFactTypeMappings">The undecided <see cref="FactTypeMapping"/> possibilities.</param> private void RemoveImpossiblePotentialFactTypeMappings(FactTypeMappingDictionary decidedOneToOneFactTypeMappings, FactTypeMappingListDictionary undecidedOneToOneFactTypeMappings) { - ObjectTypeList deeplyMappedObjectTypes = new ObjectTypeList(); + Dictionary<ObjectType, object> deeplyMappedObjectTypes = new Dictionary<ObjectType,object>(decidedOneToOneFactTypeMappings.Count + undecidedOneToOneFactTypeMappings.Count); // For each decided fact type mapping... - foreach (KeyValuePair<FactType, FactTypeMapping> decidedFactTypeMapping in decidedOneToOneFactTypeMappings) + foreach (FactTypeMapping factTypeMapping in decidedOneToOneFactTypeMappings.Values) { - FactTypeMapping factTypeMapping = decidedFactTypeMapping.Value; - // If it's a deep mapping... if (factTypeMapping.MappingDepth == MappingDepth.Deep) { - deeplyMappedObjectTypes.Add(factTypeMapping.FromObjectType); + deeplyMappedObjectTypes[factTypeMapping.FromObjectType] = null; } } @@ -511,13 +509,15 @@ FactTypeMapping potentialFactTypeMapping = potentialFactTypeMappings[i]; // If it is maped away from an ObjectType that is already determined to be mapped elsewhere... - if (deeplyMappedObjectTypes.Contains(potentialFactTypeMapping.FromObjectType) && potentialFactTypeMapping.MappingDepth == MappingDepth.Deep) + if (potentialFactTypeMapping.MappingDepth == MappingDepth.Deep && deeplyMappedObjectTypes.ContainsKey(potentialFactTypeMapping.FromObjectType)) { // Remove it as a possibility. potentialFactTypeMappings.RemoveAt(i); } } + Debug.Assert(potentialFactTypeMappings.Count > 0); + // If there is only one possibility left... if (potentialFactTypeMappings.Count == 1) { @@ -544,13 +544,12 @@ /// <returns>The number of previously potential one-to-one fact type mappings that are now decided.</returns> private int MapTrivialOneToOneFactTypesWithTwoMandatories(FactTypeMappingDictionary decidedOneToOneFactTypeMappings, FactTypeMappingListDictionary undecidedOneToOneFactTypeMappings) { - int changeCount = 0; - FactTypeList factsPendingDeletion = new FactTypeList(); + FactTypeList factTypesPendingDeletion = new FactTypeList(); - foreach (KeyValuePair<FactType, FactTypeMappingList> undecidedFactTypeMapping in undecidedOneToOneFactTypeMappings) + foreach (KeyValuePair<FactType, FactTypeMappingList> undecidedPair in undecidedOneToOneFactTypeMappings) { - FactType factType = undecidedFactTypeMapping.Key; - FactTypeMappingList potentialFactTypeMappings = undecidedFactTypeMapping.Value; + FactType factType = undecidedPair.Key; + FactTypeMappingList potentialFactTypeMappings = undecidedPair.Value; LinkedElementCollection<RoleBase> roles = factType.RoleCollection; Debug.Assert(roles.Count == 2, "All fact type mappings should be for fact types with exactly two roles."); @@ -559,48 +558,77 @@ Role secondRole = roles[1].Role; ObjectType firstRolePlayer = firstRole.RolePlayer; ObjectType secondRolePlayer = secondRole.RolePlayer; - bool firstRoleIsMandatory = null != firstRole.SingleRoleAlethicMandatoryConstraint; - bool secondRoleIsMandatory = null != secondRole.SingleRoleAlethicMandatoryConstraint; // If this is a one-to-one fact type with two simple alethic mandatories... - if (firstRoleIsMandatory && secondRoleIsMandatory) + if (firstRole.SingleRoleAlethicMandatoryConstraint != null && secondRole.SingleRoleAlethicMandatoryConstraint != null) { + FactTypeMapping deepMappingTowardsFirstRole = null; + FactTypeMapping deepMappingTowardsSecondRole = null; + + // Find our potential deep mappings. + foreach (FactTypeMapping potentialFactTypeMapping in potentialFactTypeMappings) + { + if (potentialFactTypeMapping.MappingDepth == MappingDepth.Deep) + { + if (potentialFactTypeMapping.TowardsRole == firstRole) + { + deepMappingTowardsFirstRole = potentialFactTypeMapping; + } + else + { + Debug.Assert(potentialFactTypeMapping.TowardsRole == secondRole); + deepMappingTowardsSecondRole = potentialFactTypeMapping; + } + ... [truncated message content] |
From: <mcu...@us...> - 2007-08-30 17:30:28
|
Revision: 1104 http://orm.svn.sourceforge.net/orm/?rev=1104&view=rev Author: mcurland Date: 2007-08-30 10:30:26 -0700 (Thu, 30 Aug 2007) Log Message: ----------- Changeset [1101] began setting ConceptTypeAssimilatesConceptType.IsPreferredForTarget, which was never set before. The conceptual database bridge crashes when this property is set, so ignore it for now. Temporary fix so the rest of us can keep working. refs #327 Modified Paths: -------------- trunk/ORMModel/ObjectModel/ObjectType.cs trunk/Oial/ORMOialBridge/ORMOialBridgePermuter.cs trunk/Oial/ORMOialBridge/OialModelIsForORMModel.cs trunk/RelationalModel/OialDcilBridge/OialDcilBridge.DeserializationFixupListeners.cs Modified: trunk/ORMModel/ObjectModel/ObjectType.cs =================================================================== --- trunk/ORMModel/ObjectModel/ObjectType.cs 2007-08-30 17:27:46 UTC (rev 1103) +++ trunk/ORMModel/ObjectModel/ObjectType.cs 2007-08-30 17:30:26 UTC (rev 1104) @@ -1569,20 +1569,17 @@ } } /// <summary> - /// Indicates if this <see cref="ObjectType"/> is implied independent. + /// Indicates if this <see cref="ObjectType"/> is either explicitly marked as <see cref="IsIndependent">independent</see> + /// or is implicitly independent because it plays no roles outside of its preferred identifier. /// </summary> - public bool IsImpliedIndependent() + public bool TreatAsIndependent { - return !this.IsIndependent && this.ImpliedMandatoryConstraint == null && this.AllowIsIndependent(false); + get + { + return this.IsIndependent || (this.ImpliedMandatoryConstraint == null && this.AllowIsIndependent(false)); + } } /// <summary> - /// Indicates if this <see cref="ObjectType"/> is either implied independent or explicity independent. - /// </summary> - public bool IsAnyIndependent() - { - return this.IsIndependent || this.IsImpliedIndependent(); - } - /// <summary> /// Test if the <see cref="IsIndependent"/> property can be set to true. /// </summary> /// <param name="throwIfFalse">Set to <see langword="true"/> to throw an exception instead of returning false.</param> Modified: trunk/Oial/ORMOialBridge/ORMOialBridgePermuter.cs =================================================================== --- trunk/Oial/ORMOialBridge/ORMOialBridgePermuter.cs 2007-08-30 17:27:46 UTC (rev 1103) +++ trunk/Oial/ORMOialBridge/ORMOialBridgePermuter.cs 2007-08-30 17:30:26 UTC (rev 1104) @@ -352,7 +352,7 @@ foreach (ObjectType objectType in chain.ObjectTypes) { - if (objectType.IsAnyIndependent()) + if (objectType.TreatAsIndependent) { predecidedObjectTypesThatAreIndependentOrSubtypesOrHaveNonPreferredIdentifierMappingsTowards[objectType] = null; } Modified: trunk/Oial/ORMOialBridge/OialModelIsForORMModel.cs =================================================================== --- trunk/Oial/ORMOialBridge/OialModelIsForORMModel.cs 2007-08-30 17:27:46 UTC (rev 1103) +++ trunk/Oial/ORMOialBridge/OialModelIsForORMModel.cs 2007-08-30 17:30:26 UTC (rev 1104) @@ -1109,7 +1109,7 @@ private bool ObjectTypeIsConceptType(ObjectType objectType, FactTypeMappingDictionary factTypeMappings) { // If objectType is independent... - if (objectType.IsAnyIndependent()) + if (objectType.TreatAsIndependent) { return true; } Modified: trunk/RelationalModel/OialDcilBridge/OialDcilBridge.DeserializationFixupListeners.cs =================================================================== --- trunk/RelationalModel/OialDcilBridge/OialDcilBridge.DeserializationFixupListeners.cs 2007-08-30 17:27:46 UTC (rev 1103) +++ trunk/RelationalModel/OialDcilBridge/OialDcilBridge.DeserializationFixupListeners.cs 2007-08-30 17:30:26 UTC (rev 1104) @@ -587,7 +587,7 @@ foreach (ConceptTypeAssimilatesConceptType conceptTypeAssimilatesConceptType in ConceptTypeAssimilatesConceptType.GetLinksToAssimilatorConceptTypeCollection(conceptType)) { - if (conceptTypeAssimilatesConceptType.IsPreferredForTarget) + if (false && conceptTypeAssimilatesConceptType.IsPreferredForTarget) { prefferedConceptTypeChildrenList.Add(conceptTypeAssimilatesConceptType); break; @@ -658,7 +658,7 @@ TableIsPrimarilyForConceptType.GetTable(assimilation.AssimilatorConceptType).UniquenessConstraintCollection.Add(mappedConstraint); } - else if (assimilation.IsPreferredForTarget) + else if (false && assimilation.IsPreferredForTarget) { if (isPreferredForChildFound == false) { @@ -879,7 +879,7 @@ } foreach (ConceptTypeAssimilatesConceptType conceptTypeAssimilatesConceptType in ConceptTypeAssimilatesConceptType.GetLinksToAssimilatorConceptTypeCollection(conceptType)) { - if (conceptTypeAssimilatesConceptType.IsPreferredForTarget) + if (false && conceptTypeAssimilatesConceptType.IsPreferredForTarget) { foreach (Column target in ColumnHasConceptTypeChild.GetColumn((ConceptTypeChild)conceptTypeAssimilatesConceptType)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mcu...@us...> - 2007-08-30 17:36:21
|
Revision: 1105 http://orm.svn.sourceforge.net/orm/?rev=1105&view=rev Author: mcurland Date: 2007-08-30 10:36:21 -0700 (Thu, 30 Aug 2007) Log Message: ----------- Added preview abstraction and relational models to setup and increased version to 2007-08 CTP for pending drop. refs #193 Also updated batch files to pick up doc comment files from referencing projects. Modified Paths: -------------- trunk/ORMModel/Shell/catalog.xml trunk/Oial/ORMOialBridge/ORMOialBridge.csproj trunk/Oial/OialModel/Install.bat trunk/Oial/OialModel/OialModel.csproj trunk/RelationalModel/DcilModel/DcilModel.csproj trunk/RelationalModel/DcilModel/Install.bat trunk/RelationalModel/OialDcilBridge/Install.bat trunk/RelationalModel/OialDcilBridge/OialDcilBridge.csproj trunk/Setup/ComponentGroups.wxs trunk/Setup/Components.wxs trunk/VersionGenerator.exe.config trunk/install.bat Modified: trunk/ORMModel/Shell/catalog.xml =================================================================== --- trunk/ORMModel/Shell/catalog.xml 2007-08-30 17:30:26 UTC (rev 1104) +++ trunk/ORMModel/Shell/catalog.xml 2007-08-30 17:36:21 UTC (rev 1105) @@ -1,4 +1,10 @@ <?xml version="1.0" encoding="utf-8"?> <SchemaCatalog xmlns="http://schemas.microsoft.com/xsd/catalog"> <Schema targetNamespace="http://schemas.neumont.edu/ORM/DesignerSettings" href="ORMDesignerSettings.xsd"/> + <Schema targetNamespace="http://schemas.neumont.edu/ORM/Preview/CustomProperties" href="CustomProperties.xsd"/> + <Schema targetNamespace="http://schemas.neumont.edu/ORM/Abstraction/2007-06/Core" href="ORMAbstraction.xsd"/> + <Schema targetNamespace="http://schemas.neumont.edu/ORM/Abstraction/2007-06/DataTypes/Core" href="ORMAbstractionDataTypes.xsd"/> + <Schema targetNamespace="http://schemas.neumont.edu/ORM/Bridge/2007-06/ORMToORMAbstraction" href="ORMToORMAbstraction.xsd"/> + <Schema targetNamespace="http://schemas.neumont.edu/ORM/Relational/2007-06/ConceptualDatabase" href="ConceptualDatabase.xsd"/> + <Schema targetNamespace="http://schemas.neumont.edu/ORM/Bridge/2007-06/ORMAbstractionToConceptualDatabase" href="ORMAbstractionToConceptualDatabase.xsd"/> </SchemaCatalog> \ No newline at end of file Modified: trunk/Oial/ORMOialBridge/ORMOialBridge.csproj =================================================================== --- trunk/Oial/ORMOialBridge/ORMOialBridge.csproj 2007-08-30 17:30:26 UTC (rev 1104) +++ trunk/Oial/ORMOialBridge/ORMOialBridge.csproj 2007-08-30 17:36:21 UTC (rev 1105) @@ -22,7 +22,7 @@ <Optimize>true</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>TRACE;DEBUG</DefineConstants> - <DocumentationFile>bin\Debug\Neumont.Tools.ORMOialBridge.xml</DocumentationFile> + <DocumentationFile>bin\Debug\Neumont.Tools.ORMToORMAbstractionBridge.xml</DocumentationFile> <ErrorReport>prompt</ErrorReport> <NoWarn>1607</NoWarn> <UseVSHostingProcess>false</UseVSHostingProcess> @@ -32,7 +32,7 @@ <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> - <DocumentationFile>bin\Release\Neumont.Tools.ORMOialBridge.xml</DocumentationFile> + <DocumentationFile>bin\Release\Neumont.Tools.ORMToORMAbstractionBridge.xml</DocumentationFile> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <NoWarn>1607</NoWarn> Modified: trunk/Oial/OialModel/Install.bat =================================================================== --- trunk/Oial/OialModel/Install.bat 2007-08-30 17:30:26 UTC (rev 1104) +++ trunk/Oial/OialModel/Install.bat 2007-08-30 17:36:21 UTC (rev 1105) @@ -7,6 +7,7 @@ XCOPY /Y /D /V /Q "%RootDir%\%BuildOutDir%\Neumont.Tools.ORMAbstraction.dll" "%NORMAExtensionsDir%\" XCOPY /Y /D /V /Q "%RootDir%\%BuildOutDir%\Neumont.Tools.ORMAbstraction.pdb" "%NORMAExtensionsDir%\" +XCOPY /Y /D /V /Q "%RootDir%\%BuildOutDir%\Neumont.Tools.ORMAbstraction.xml" "%NORMAExtensionsDir%\" REG ADD "HKLM\%VSRegistryRoot%\Neumont\ORM Architect\Extensions\http://schemas.neumont.edu/ORM/Abstraction/2007-06/Core" /v "Class" /d "Neumont.Tools.ORMAbstraction.AbstractionDomainModel" /f 1>NUL REG ADD "HKLM\%VSRegistryRoot%\Neumont\ORM Architect\Extensions\http://schemas.neumont.edu/ORM/Abstraction/2007-06/Core" /v "CodeBase" /d "%NORMAExtensionsDir%\Neumont.Tools.ORMAbstraction.dll" /f 1>NUL Modified: trunk/Oial/OialModel/OialModel.csproj =================================================================== --- trunk/Oial/OialModel/OialModel.csproj 2007-08-30 17:30:26 UTC (rev 1104) +++ trunk/Oial/OialModel/OialModel.csproj 2007-08-30 17:36:21 UTC (rev 1105) @@ -22,7 +22,7 @@ <Optimize>true</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>TRACE;DEBUG</DefineConstants> - <DocumentationFile>bin\Debug\Neumont.Tools.Oial.xml</DocumentationFile> + <DocumentationFile>bin\Debug\Neumont.Tools.ORMAbstraction.xml</DocumentationFile> <ErrorReport>prompt</ErrorReport> <NoWarn>1607</NoWarn> <UseVSHostingProcess>false</UseVSHostingProcess> @@ -32,7 +32,7 @@ <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> - <DocumentationFile>bin\Release\Neumont.Tools.Oial.xml</DocumentationFile> + <DocumentationFile>bin\Release\Neumont.Tools.ORMAbstraction.xml</DocumentationFile> <ErrorReport>prompt</ErrorReport> <NoWarn>1607</NoWarn> <UseVSHostingProcess>false</UseVSHostingProcess> Modified: trunk/RelationalModel/DcilModel/DcilModel.csproj =================================================================== --- trunk/RelationalModel/DcilModel/DcilModel.csproj 2007-08-30 17:30:26 UTC (rev 1104) +++ trunk/RelationalModel/DcilModel/DcilModel.csproj 2007-08-30 17:36:21 UTC (rev 1105) @@ -22,7 +22,7 @@ <Optimize>true</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>TRACE;DEBUG</DefineConstants> - <DocumentationFile>bin\Debug\Neumont.Tools.Dil.Dcil.xml</DocumentationFile> + <DocumentationFile>bin\Debug\Neumont.Tools.RelationalModels.xml</DocumentationFile> <ErrorReport>prompt</ErrorReport> <NoWarn>1607</NoWarn> <UseVSHostingProcess>false</UseVSHostingProcess> @@ -32,7 +32,7 @@ <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> - <DocumentationFile>bin\Release\Neumont.Tools.Dil.Dcil.xml</DocumentationFile> + <DocumentationFile>bin\Release\Neumont.Tools.RelationalModels.xml</DocumentationFile> <ErrorReport>prompt</ErrorReport> <NoWarn>1607</NoWarn> <UseVSHostingProcess>false</UseVSHostingProcess> Modified: trunk/RelationalModel/DcilModel/Install.bat =================================================================== --- trunk/RelationalModel/DcilModel/Install.bat 2007-08-30 17:30:26 UTC (rev 1104) +++ trunk/RelationalModel/DcilModel/Install.bat 2007-08-30 17:36:21 UTC (rev 1105) @@ -7,6 +7,7 @@ XCOPY /Y /D /V /Q "%RootDir%\%BuildOutDir%\Neumont.Tools.RelationalModels.dll" "%NORMAExtensionsDir%\" XCOPY /Y /D /V /Q "%RootDir%\%BuildOutDir%\Neumont.Tools.RelationalModels.pdb" "%NORMAExtensionsDir%\" +XCOPY /Y /D /V /Q "%RootDir%\%BuildOutDir%\Neumont.Tools.RelationalModels.xml" "%NORMAExtensionsDir%\" REG ADD "HKLM\%VSRegistryRoot%\Neumont\ORM Architect\Extensions\http://schemas.neumont.edu/ORM/Relational/2007-06/ConceptualDatabase" /v "Class" /d "Neumont.Tools.RelationalModels.ConceptualDatabase.ConceptualDatabaseDomainModel" /f 1>NUL REG ADD "HKLM\%VSRegistryRoot%\Neumont\ORM Architect\Extensions\http://schemas.neumont.edu/ORM/Relational/2007-06/ConceptualDatabase" /v "CodeBase" /d "%NORMAExtensionsDir%\Neumont.Tools.RelationalModels.dll" /f 1>NUL Modified: trunk/RelationalModel/OialDcilBridge/Install.bat =================================================================== --- trunk/RelationalModel/OialDcilBridge/Install.bat 2007-08-30 17:30:26 UTC (rev 1104) +++ trunk/RelationalModel/OialDcilBridge/Install.bat 2007-08-30 17:36:21 UTC (rev 1105) @@ -7,6 +7,7 @@ XCOPY /Y /D /V /Q "%RootDir%\%BuildOutDir%\Neumont.Tools.ORMAbstractionToConceptualDatabaseBridge.dll" "%NORMAExtensionsDir%\" XCOPY /Y /D /V /Q "%RootDir%\%BuildOutDir%\Neumont.Tools.ORMAbstractionToConceptualDatabaseBridge.pdb" "%NORMAExtensionsDir%\" +XCOPY /Y /D /V /Q "%RootDir%\%BuildOutDir%\Neumont.Tools.ORMAbstractionToConceptualDatabaseBridge.xml" "%NORMAExtensionsDir%\" REG ADD "HKLM\%VSRegistryRoot%\Neumont\ORM Architect\Extensions\http://schemas.neumont.edu/ORM/Bridge/2007-06/ORMAbstractionToConceptualDatabase" /v "Class" /d "Neumont.Tools.ORMAbstractionToConceptualDatabaseBridge.ORMAbstractionToConceptualDatabaseBridgeDomainModel" /f 1>NUL REG ADD "HKLM\%VSRegistryRoot%\Neumont\ORM Architect\Extensions\http://schemas.neumont.edu/ORM/Bridge/2007-06/ORMAbstractionToConceptualDatabase" /v "CodeBase" /d "%NORMAExtensionsDir%\Neumont.Tools.ORMAbstractionToConceptualDatabaseBridge.dll" /f 1>NUL Modified: trunk/RelationalModel/OialDcilBridge/OialDcilBridge.csproj =================================================================== --- trunk/RelationalModel/OialDcilBridge/OialDcilBridge.csproj 2007-08-30 17:30:26 UTC (rev 1104) +++ trunk/RelationalModel/OialDcilBridge/OialDcilBridge.csproj 2007-08-30 17:36:21 UTC (rev 1105) @@ -32,7 +32,7 @@ <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> - <DocumentationFile>bin\Release\Neumont.Tools.Dil.OialDcilBridge.xml</DocumentationFile> + <DocumentationFile>bin\Release\Neumont.Tools.ORMAbstractionToConceptualDatabaseBridge.xml</DocumentationFile> <ErrorReport>prompt</ErrorReport> <NoWarn>1607</NoWarn> <UseVSHostingProcess>false</UseVSHostingProcess> Modified: trunk/Setup/ComponentGroups.wxs =================================================================== --- trunk/Setup/ComponentGroups.wxs 2007-08-30 17:30:26 UTC (rev 1104) +++ trunk/Setup/ComponentGroups.wxs 2007-08-30 17:36:21 UTC (rev 1105) @@ -39,7 +39,21 @@ <ComponentRef Id="NORMAVSOIALModelExtensionComponent"/> <ComponentRef Id="NORMAVSRelationalViewExtensionComponent"/> <ComponentRef Id="NORMAVSCustomPropertiesExtensionComponent"/> + <ComponentRef Id="NORMAVSCustomPropertiesGACComponent"/> + <ComponentRef Id="NORMAVSCustomPropertiesSchemaComponent"/> <ComponentRef Id="NORMAVSCustomPropertiesVerbalizationComponent"/> + <ComponentRef Id="NORMAVSORMAbstractionExtensionComponent"/> + <ComponentRef Id="NORMAVSORMAbstractionGACComponent"/> + <ComponentRef Id="NORMAVSORMAbstractionSchemaComponent"/> + <ComponentRef Id="NORMAVSORMToORMAbstractionExtensionComponent"/> + <ComponentRef Id="NORMAVSORMToORMAbstractionGACComponent"/> + <ComponentRef Id="NORMAVSORMToORMAbstractionSchemaComponent"/> + <ComponentRef Id="NORMAVSRelationalModelsExtensionComponent"/> + <ComponentRef Id="NORMAVSRelationalModelsGACComponent"/> + <ComponentRef Id="NORMAVSRelationalModelsSchemaComponent"/> + <ComponentRef Id="NORMAVSORMAbstractionToConceptualDatabaseExtensionComponent"/> + <ComponentRef Id="NORMAVSORMAbstractionToConceptualDatabaseGACComponent"/> + <ComponentRef Id="NORMAVSORMAbstractionToConceptualDatabaseSchemaComponent"/> <ComponentRef Id="ORMSchemaCatalogComponent"/> <ComponentRef Id="ORMSchemasComponent"/> <ComponentRef Id="ORMSchemasLocalCatalogComponent"/> Modified: trunk/Setup/Components.wxs =================================================================== --- trunk/Setup/Components.wxs 2007-08-30 17:30:26 UTC (rev 1104) +++ trunk/Setup/Components.wxs 2007-08-30 17:36:21 UTC (rev 1105) @@ -23,6 +23,26 @@ <File Id="Neumont.Tools.ORM.dll_GAC" Name="ORM.dll" LongName="Neumont.Tools.ORM.dll" src="..\ORMModel\bin\$(var.BuildConfiguration)\Neumont.Tools.ORM.dll" DefaultVersion="$(var.ProductVersion)" DefaultLanguage="0" KeyPath="yes" Vital="yes" Assembly=".net" AssemblyManifest="Neumont.Tools.ORM.dll_GAC" ProcessorArchitecture="msil"/> </Component> + <Component Id="NORMAVSCustomPropertiesGACComponent" Guid="0772D284-812E-4ECC-$(var.VersionGuidSuffix)" DiskId="1" Win64="$(var.Win64)"> + <File Id="Neumont.Tools.ORM.CustomProperties.dll_GAC" Name="ORMCstPr.dll" LongName="Neumont.Tools.ORM.CustomProperties.dll" src="..\CustomProperties\bin\$(var.BuildConfiguration)\Neumont.Tools.ORM.CustomProperties.dll" + DefaultVersion="$(var.ProductVersion)" DefaultLanguage="0" KeyPath="yes" Assembly=".net" AssemblyManifest="Neumont.Tools.ORM.CustomProperties.dll_GAC" ProcessorArchitecture="msil"/> + </Component> + <Component Id="NORMAVSORMAbstractionGACComponent" Guid="287179E2-73E9-4685-$(var.VersionGuidSuffix)" DiskId="1" Win64="$(var.Win64)"> + <File Id="Neumont.Tools.ORMAbstraction.dll_GAC" Name="ORMAbstr.dll" LongName="Neumont.Tools.ORMAbstraction.dll" src="..\Oial\OialModel\bin\$(var.BuildConfiguration)\Neumont.Tools.ORMAbstraction.dll" + DefaultVersion="$(var.ProductVersion)" DefaultLanguage="0" KeyPath="yes" Assembly=".net" AssemblyManifest="Neumont.Tools.ORMAbstraction.dll_GAC" ProcessorArchitecture="msil"/> + </Component> + <Component Id="NORMAVSORMToORMAbstractionGACComponent" Guid="83ACCC60-19F4-4BBE-$(var.VersionGuidSuffix)" DiskId="1" Win64="$(var.Win64)"> + <File Id="Neumont.Tools.ORMToORMAbstractionBridge.dll_GAC" Name="ORMAbsBr.dll" LongName="Neumont.Tools.ORMToORMAbstractionBridge.dll" src="..\Oial\ORMOialBridge\bin\$(var.BuildConfiguration)\Neumont.Tools.ORMToORMAbstractionBridge.dll" + DefaultVersion="$(var.ProductVersion)" DefaultLanguage="0" KeyPath="yes" Assembly=".net" AssemblyManifest="Neumont.Tools.ORMToORMAbstractionBridge.dll_GAC" ProcessorArchitecture="msil"/> + </Component> + <Component Id="NORMAVSRelationalModelsGACComponent" Guid="8877E891-60A3-454C-$(var.VersionGuidSuffix)" DiskId="1" Win64="$(var.Win64)"> + <File Id="Neumont.Tools.RelationalModels.dll_GAC" Name="RelMods.dll" LongName="Neumont.Tools.RelationalModels.dll" src="..\RelationalModel\DcilModel\bin\$(var.BuildConfiguration)\Neumont.Tools.RelationalModels.dll" + DefaultVersion="$(var.ProductVersion)" DefaultLanguage="0" KeyPath="yes" Assembly=".net" AssemblyManifest="Neumont.Tools.RelationalModels.dll_GAC" ProcessorArchitecture="msil"/> + </Component> + <Component Id="NORMAVSORMAbstractionToConceptualDatabaseGACComponent" Guid="B14BF95A-EC48-49EE-$(var.VersionGuidSuffix)" DiskId="1" Win64="$(var.Win64)"> + <File Id="Neumont.Tools.ORMAbstractionToConceptualDatabaseBridge.dll_GAC" Name="CDBBr.dll" LongName="Neumont.Tools.ORMAbstractionToConceptualDatabaseBridge.dll" src="..\RelationalModel\OialDcilBridge\bin\$(var.BuildConfiguration)\Neumont.Tools.ORMAbstractionToConceptualDatabaseBridge.dll" + DefaultVersion="$(var.ProductVersion)" DefaultLanguage="0" KeyPath="yes" Assembly=".net" AssemblyManifest="Neumont.Tools.ORMAbstractionToConceptualDatabaseBridge.dll_GAC" ProcessorArchitecture="msil"/> + </Component> </Directory> <Directory Id="$(var.ProgramFilesFolder)"> @@ -59,6 +79,9 @@ <Registry Action="createKeyAndRemoveKeyOnUninstall" Root="HKLM" Key="SOFTWARE\Microsoft\.NETFramework\v2.0.50727\AssemblyFoldersEx\NORMAVS"> <Registry Type="string" Value="[BINDIR]"/> </Registry> + <Registry Action="createKeyAndRemoveKeyOnUninstall" Root="HKLM" Key="SOFTWARE\Microsoft\.NETFramework\v2.0.50727\AssemblyFoldersEx\NORMAVSExtensions"> + <Registry Type="string" Value="[EXTENSIONSDIR]"/> + </Registry> <Registry Action="createKeyAndRemoveKeyOnUninstall" Root="HKLM" Key="$(var.NORMARegRoot)"> <Registry Type="string" Name="InstallDir" Value="[$(var.DefaultShortProductDir)]"/> <Registry Type="string" Name="ProductVersion" Value="$(var.ProductVersion)"/> @@ -150,8 +173,7 @@ </Registry> </Component> - <Directory Id="Extensions" Name="Ext" LongName="Extenions"> - + <Directory Id="EXTENSIONSDIR" Name="Ext" LongName="Extensions"> <Component Id="NORMAVSOIALModelExtensionComponent" Guid="27157B36-345A-4E11-$(var.VersionGuidSuffix)" DiskId="1" Win64="$(var.Win64)"> <File Id="Neumont.Tools.ORM.OIALModel.dll" Name="OIALModl.dll" LongName="Neumont.Tools.ORM.OIALModel.dll" src="..\OIALModel\bin\$(var.BuildConfiguration)\Neumont.Tools.ORM.OIALModel.dll" DefaultVersion="$(var.ProductVersion)" DefaultLanguage="0" KeyPath="yes" Assembly=".net" AssemblyManifest="Neumont.Tools.ORM.OIALModel.dll" AssemblyApplication="Neumont.Tools.ORM.OIALModel.dll" ProcessorArchitecture="msil"/> @@ -188,6 +210,61 @@ </Registry> </Component> + <Component Id="NORMAVSORMAbstractionExtensionComponent" Guid="2AF4858D-43CC-4107-$(var.VersionGuidSuffix)" DiskId="1" Win64="$(var.Win64)"> + <File Id="Neumont.Tools.ORMAbstraction.dll" Name="ORMAbstr.dll" LongName="Neumont.Tools.ORMAbstraction.dll" src="..\Oial\OialModel\bin\$(var.BuildConfiguration)\Neumont.Tools.ORMAbstraction.dll" + DefaultVersion="$(var.ProductVersion)" DefaultLanguage="0" KeyPath="yes" Assembly=".net" AssemblyManifest="Neumont.Tools.ORMAbstraction.dll" AssemblyApplication="Neumont.Tools.ORMAbstraction.dll" ProcessorArchitecture="msil"/> + <File Id="Neumont.Tools.ORMAbstraction.pdb" Name="ORMAbstr.pdb" LongName="Neumont.Tools.ORMAbstraction.pdb" src="..\Oial\OialModel\bin\$(var.BuildConfiguration)\Neumont.Tools.ORMAbstraction.pdb" + DefaultLanguage="0" CompanionFile="Neumont.Tools.ORMAbstraction.dll"/> + <File Id="Neumont.Tools.ORMAbstraction.xml" Name="ORMAbstr.xml" LongName="Neumont.Tools.ORMAbstraction.xml" src="..\Oial\OialModel\bin\$(var.BuildConfiguration)\Neumont.Tools.ORMAbstraction.xml" + DefaultLanguage="0" CompanionFile="Neumont.Tools.ORMAbstraction.dll"/> + <Registry Action="createKeyAndRemoveKeyOnUninstall" Root="HKLM" Key="$(var.NORMAVSExtensionsRegRoot)\http://schemas.neumont.edu/ORM/Abstraction/2007-06/Core"> + <Registry Type="string" Name="Class" Value="Neumont.Tools.ORMAbstraction.AbstractionDomainModel"/> + <Registry Type="string" Name="Assembly" Value="Neumont.Tools.ORMAbstraction, $(var.BaseAssemblyName)"/> + <Registry Type="string" Name="CodeBase" Value="[#Neumont.Tools.ORMAbstraction.dll]"/> + </Registry> + </Component> + + <Component Id="NORMAVSORMToORMAbstractionExtensionComponent" Guid="C6CED0EA-97CA-40AA-$(var.VersionGuidSuffix)" DiskId="1" Win64="$(var.Win64)"> + <File Id="Neumont.Tools.ORMToORMAbstractionBridge.dll" Name="ORMAbsBr.dll" LongName="Neumont.Tools.ORMToORMAbstractionBridge.dll" src="..\Oial\ORMOialBridge\bin\$(var.BuildConfiguration)\Neumont.Tools.ORMToORMAbstractionBridge.dll" + DefaultVersion="$(var.ProductVersion)" DefaultLanguage="0" KeyPath="yes" Assembly=".net" AssemblyManifest="Neumont.Tools.ORMToORMAbstractionBridge.dll" AssemblyApplication="Neumont.Tools.ORMToORMAbstractionBridge.dll" ProcessorArchitecture="msil"/> + <File Id="Neumont.Tools.ORMToORMAbstractionBridge.pdb" Name="ORMAbsBr.pdb" LongName="Neumont.Tools.ORMToORMAbstractionBridge.pdb" src="..\Oial\ORMOialBridge\bin\$(var.BuildConfiguration)\Neumont.Tools.ORMToORMAbstractionBridge.pdb" + DefaultLanguage="0" CompanionFile="Neumont.Tools.ORMToORMAbstractionBridge.dll"/> + <File Id="Neumont.Tools.ORMToORMAbstractionBridge.xml" Name="ORMAbsBr.xml" LongName="Neumont.Tools.ORMToORMAbstractionBridge.xml" src="..\Oial\ORMOialBridge\bin\$(var.BuildConfiguration)\Neumont.Tools.ORMToORMAbstractionBridge.xml" + DefaultLanguage="0" CompanionFile="Neumont.Tools.ORMToORMAbstractionBridge.dll"/> + <Registry Action="createKeyAndRemoveKeyOnUninstall" Root="HKLM" Key="$(var.NORMAVSExtensionsRegRoot)\http://schemas.neumont.edu/ORM/Bridge/2007-06/ORMToORMAbstraction"> + <Registry Type="string" Name="Class" Value="Neumont.Tools.ORMToORMAbstractionBridge.ORMToORMAbstractionBridgeDomainModel"/> + <Registry Type="string" Name="Assembly" Value="Neumont.Tools.ORMToORMAbstractionBridge, $(var.BaseAssemblyName)"/> + <Registry Type="string" Name="CodeBase" Value="[#Neumont.Tools.ORMToORMAbstractionBridge.dll]"/> + </Registry> + </Component> + + <Component Id="NORMAVSRelationalModelsExtensionComponent" Guid="8CA7B2DB-1669-427B-$(var.VersionGuidSuffix)" DiskId="1" Win64="$(var.Win64)"> + <File Id="Neumont.Tools.RelationalModels.dll" Name="RelMods.dll" LongName="Neumont.Tools.RelationalModels.dll" src="..\RelationalModel\DcilModel\bin\$(var.BuildConfiguration)\Neumont.Tools.RelationalModels.dll" + DefaultVersion="$(var.ProductVersion)" DefaultLanguage="0" KeyPath="yes" Assembly=".net" AssemblyManifest="Neumont.Tools.RelationalModels.dll" AssemblyApplication="Neumont.Tools.RelationalModels.dll" ProcessorArchitecture="msil"/> + <File Id="Neumont.Tools.RelationalModels.pdb" Name="RelMods.pdb" LongName="Neumont.Tools.RelationalModels.pdb" src="..\RelationalModel\DcilModel\bin\$(var.BuildConfiguration)\Neumont.Tools.RelationalModels.pdb" + DefaultLanguage="0" CompanionFile="Neumont.Tools.RelationalModels.dll"/> + <File Id="Neumont.Tools.RelationalModels.xml" Name="RelMods.xml" LongName="Neumont.Tools.RelationalModels.xml" src="..\RelationalModel\DcilModel\bin\$(var.BuildConfiguration)\Neumont.Tools.RelationalModels.xml" + DefaultLanguage="0" CompanionFile="Neumont.Tools.RelationalModels.dll"/> + <Registry Action="createKeyAndRemoveKeyOnUninstall" Root="HKLM" Key="$(var.NORMAVSExtensionsRegRoot)\http://schemas.neumont.edu/ORM/Relational/2007-06/ConceptualDatabase"> + <Registry Type="string" Name="Class" Value="Neumont.Tools.RelationalModels.ConceptualDatabase.ConceptualDatabaseDomainModel"/> + <Registry Type="string" Name="Assembly" Value="Neumont.Tools.RelationalModels, $(var.BaseAssemblyName)"/> + <Registry Type="string" Name="CodeBase" Value="[#Neumont.Tools.RelationalModels.dll]"/> + </Registry> + </Component> + + <Component Id="NORMAVSORMAbstractionToConceptualDatabaseExtensionComponent" Guid="2D11803B-91D7-446E-$(var.VersionGuidSuffix)" DiskId="1" Win64="$(var.Win64)"> + <File Id="Neumont.Tools.ORMAbstractionToConceptualDatabaseBridge.dll" Name="CDBBr.dll" LongName="Neumont.Tools.ORMAbstractionToConceptualDatabaseBridge.dll" src="..\RelationalModel\OialDcilBridge\bin\$(var.BuildConfiguration)\Neumont.Tools.ORMAbstractionToConceptualDatabaseBridge.dll" + DefaultVersion="$(var.ProductVersion)" DefaultLanguage="0" KeyPath="yes" Assembly=".net" AssemblyManifest="Neumont.Tools.ORMAbstractionToConceptualDatabaseBridge.dll" AssemblyApplication="Neumont.Tools.ORMAbstractionToConceptualDatabaseBridge.dll" ProcessorArchitecture="msil"/> + <File Id="Neumont.Tools.ORMAbstractionToConceptualDatabaseBridge.pdb" Name="CDBBr.pdb" LongName="Neumont.Tools.ORMAbstractionToConceptualDatabaseBridge.pdb" src="..\RelationalModel\OialDcilBridge\bin\$(var.BuildConfiguration)\Neumont.Tools.ORMAbstractionToConceptualDatabaseBridge.pdb" + DefaultLanguage="0" CompanionFile="Neumont.Tools.ORMAbstractionToConceptualDatabaseBridge.dll"/> + <File Id="Neumont.Tools.ORMAbstractionToConceptualDatabaseBridge.xml" Name="CDBBr.xml" LongName="Neumont.Tools.ORMAbstractionToConceptualDatabaseBridge.xml" src="..\RelationalModel\OialDcilBridge\bin\$(var.BuildConfiguration)\Neumont.Tools.ORMAbstractionToConceptualDatabaseBridge.xml" + DefaultLanguage="0" CompanionFile="Neumont.Tools.ORMAbstractionToConceptualDatabaseBridge.dll"/> + <Registry Action="createKeyAndRemoveKeyOnUninstall" Root="HKLM" Key="$(var.NORMAVSExtensionsRegRoot)\http://schemas.neumont.edu/ORM/Bridge/2007-06/ORMAbstractionToConceptualDatabase"> + <Registry Type="string" Name="Class" Value="Neumont.Tools.ORMAbstractionToConceptualDatabaseBridge.ORMAbstractionToConceptualDatabaseBridgeDomainModel"/> + <Registry Type="string" Name="Assembly" Value="Neumont.Tools.ORMAbstractionToConceptualDatabaseBridge, $(var.BaseAssemblyName)"/> + <Registry Type="string" Name="CodeBase" Value="[#Neumont.Tools.ORMAbstractionToConceptualDatabaseBridge.dll]"/> + </Registry> + </Component> </Directory> </Directory> @@ -211,6 +288,28 @@ <File Id="ORMDesignerSettings.xsd" Name="DsgnrStg.xsd" LongName="ORMDesignerSettings.xsd" src="..\ORMModel\Shell\ORMDesignerSettings.xsd" DefaultLanguage="0" CompanionFile="Neumont.Tools.ORM.dll"/> </Component> + <Component Id="NORMAVSCustomPropertiesSchemaComponent" Guid="27EB4413-1888-4038-$(var.VersionGuidSuffix)" DiskId="1" Win64="$(var.Win64)" KeyPath="yes"> + <File Id="CustomProperties.xsd" Name="ORMCstPr.xsd" LongName="CustomProperties.xsd" src="..\CustomProperties\CustomProperties.xsd" + DefaultLanguage="0" CompanionFile="Neumont.Tools.ORM.CustomProperties.dll"/> + </Component> + <Component Id="NORMAVSORMAbstractionSchemaComponent" Guid="1AFB3357-16AC-4A2B-$(var.VersionGuidSuffix)" DiskId="1" Win64="$(var.Win64)" KeyPath="yes"> + <File Id="ORMAbstraction.xsd" Name="ORMAbstr.xsd" LongName="ORMAbstraction.xsd" src="..\Oial\OialModel\OIAL.xsd" + DefaultLanguage="0" CompanionFile="Neumont.Tools.ORMAbstraction.dll"/> + <File Id="ORMAbstractionDataTypes.xsd" Name="ORMAbsDT.xsd" LongName="ORMAbstractionDataTypes.xsd" src="..\Oial\OialModel\OIALDatatypes.xsd" + DefaultLanguage="0" CompanionFile="Neumont.Tools.ORMAbstraction.dll"/> + </Component> + <Component Id="NORMAVSORMToORMAbstractionSchemaComponent" Guid="D79F2881-1707-4499-$(var.VersionGuidSuffix)" DiskId="1" Win64="$(var.Win64)" KeyPath="yes"> + <File Id="ORMToORMAbstraction.xsd" Name="ORMAbsBr.xsd" LongName="ORMToORMAbstraction.xsd" src="..\Oial\ORMOialBridge\ORMToORMAbstraction.xsd" + DefaultLanguage="0" CompanionFile="Neumont.Tools.ORMToORMAbstractionBridge.dll"/> + </Component> + <Component Id="NORMAVSRelationalModelsSchemaComponent" Guid="5D8B0055-6336-4226-$(var.VersionGuidSuffix)" DiskId="1" Win64="$(var.Win64)" KeyPath="yes"> + <File Id="ConceptualDatabase.xsd" Name="CDB.xsd" LongName="ConceptualDatabase.xsd" src="..\RelationalModel\DcilModel\ConceptualDatabase.xsd" + DefaultLanguage="0" CompanionFile="Neumont.Tools.RelationalModels.dll"/> + </Component> + <Component Id="NORMAVSORMAbstractionToConceptualDatabaseSchemaComponent" Guid="F3ECE70B-A746-4FDA-$(var.VersionGuidSuffix)" DiskId="1" Win64="$(var.Win64)" KeyPath="yes"> + <File Id="ORMAbstractionToConceptualDatabase.xsd" Name="CDBBr.xsd" LongName="ORMAbstractionToConceptualDatabase.xsd" src="..\RelationalModel\OialDcilBridge\ORMAbstractionToConceptualDatabase.xsd" + DefaultLanguage="0" CompanionFile="Neumont.Tools.ORMAbstractionToConceptualDatabaseBridge.dll"/> + </Component> </Directory> <Directory Id="Transforms" Name="Trnsfrms" LongName="Transforms"> <!-- XSLTs specific to NORMA for VS go here. Anything potentially applicable to other programs should go under ORMCOMMONTRANSFORMSDIR or DILCOMMONTRANSFORMSDIR. --> Modified: trunk/VersionGenerator.exe.config =================================================================== --- trunk/VersionGenerator.exe.config 2007-08-30 17:30:26 UTC (rev 1104) +++ trunk/VersionGenerator.exe.config 2007-08-30 17:36:21 UTC (rev 1105) @@ -2,7 +2,7 @@ <configuration> <appSettings> <add key="RevisionStartYearMonth" value="2006-01"/> - <add key="ReleaseYearMonth" value="2007-06"/> + <add key="ReleaseYearMonth" value="2007-08"/> <!-- ReleaseType: "CTP" or "RTM" --> <add key="ReleaseType" value="CTP"/> <!-- Changes to the major and/or minor version numbers have extreme effects across every part of the product. --> Modified: trunk/install.bat =================================================================== --- trunk/install.bat 2007-08-30 17:30:26 UTC (rev 1104) +++ trunk/install.bat 2007-08-30 17:36:21 UTC (rev 1105) @@ -41,6 +41,12 @@ XCOPY /Y /D /V /Q "%RootDir%\catalog.xml" "%ORMDir%\Schemas\" XCOPY /Y /D /V /Q "%RootDir%\ORMModel\Shell\ORMDesignerSettings.xsd" "%NORMADir%\Xml\Schemas\" +XCOPY /Y /D /V /Q "%RootDir%\CustomProperties\CustomProperties.xsd" "%NORMADir%\Xml\Schemas\" +ECHO F | XCOPY /Y /D /V /Q "%RootDir%\Oial\OialModel\OIAL.xsd" "%NORMADir%\Xml\Schemas\ORMAbstraction.xsd" +ECHO F | XCOPY /Y /D /V /Q "%RootDir%\Oial\OialModel\OIALDatatypes.xsd" "%NORMADir%\Xml\Schemas\ORMAbstractionDataTypes.xsd" +XCOPY /Y /D /V /Q "%RootDir%\Oial\ORMOialBridge\ORMToORMAbstraction.xsd" "%NORMADir%\Xml\Schemas\" +XCOPY /Y /D /V /Q "%RootDir%\RelationalModel\DcilModel\ConceptualDatabase.xsd" "%NORMADir%\Xml\Schemas\" +XCOPY /Y /D /V /Q "%RootDir%\RelationalModel\OialDcilBridge\ORMAbstractionToConceptualDatabase.xsd" "%NORMADir%\Xml\Schemas\" XCOPY /Y /D /V /Q "%RootDir%\ORMModel\Shell\catalog.xml" "%NORMADir%\Xml\Schemas\" XCOPY /Y /D /V /Q "%RootDir%\ORMModel\Shell\ORMDesignerSettings.xml" "%NORMADir%\" XCOPY /Y /D /V /Q "%RootDir%\ORMModel\Shell\Converters\*.xslt" "%NORMADir%\Xml\Transforms\Converters\" @@ -98,6 +104,9 @@ REG ADD "HKLM\%VSRegistryRoot%\XmlDesigners\{EDA9E282-8FC6-4AE4-AF2C-C224FD3AE49B}" /v "LogicalView" /d "7651A702-06E5-11D1-8EBD-00A0C90F26EA" /f 1>NUL REG ADD "HKLM\%VSRegistryRoot%\XmlDesigners\{EDA9E282-8FC6-4AE4-AF2C-C224FD3AE49B}" /v "Namespace" /d "http://schemas.neumont.edu/ORM/2006-04/ORMRoot" /f 1>NUL +REG ADD "HKLM\SOFTWARE\Microsoft\.NETFramework\v2.0.50727\AssemblyFoldersEx\NORMAVS" /ve /d "%NORMADir%\bin" /f 1>NUL +REG ADD "HKLM\SOFTWARE\Microsoft\.NETFramework\v2.0.50727\AssemblyFoldersEx\NORMAVSExtensions" /ve /d "%NORMADir%\bin\Extensions" /f 1>NUL + REG ADD "HKCR\MIME\Database\Content Type\application/orm+xml" /v "Extension" /d ".orm" /f 1>NUL REG ADD "HKCR\.orm" /ve /d "ormfile" /f 1>NUL REG ADD "HKCR\.orm" /v "Content Type" /d "application/orm+xml" /f 1>NUL This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mcu...@us...> - 2007-08-30 17:58:08
|
Revision: 1106 http://orm.svn.sourceforge.net/orm/?rev=1106&view=rev Author: mcurland Date: 2007-08-30 10:58:08 -0700 (Thu, 30 Aug 2007) Log Message: ----------- Fixed crash introduced in [1100] refs #334 Also updated install case missed in [1105] Modified Paths: -------------- trunk/Oial/ORMOialBridge/Install.bat trunk/RelationalModel/OialDcilBridge/NameGeneration.cs Modified: trunk/Oial/ORMOialBridge/Install.bat =================================================================== --- trunk/Oial/ORMOialBridge/Install.bat 2007-08-30 17:36:21 UTC (rev 1105) +++ trunk/Oial/ORMOialBridge/Install.bat 2007-08-30 17:58:08 UTC (rev 1106) @@ -7,6 +7,7 @@ XCOPY /Y /D /V /Q "%RootDir%\%BuildOutDir%\Neumont.Tools.ORMToORMAbstractionBridge.dll" "%NORMAExtensionsDir%\" XCOPY /Y /D /V /Q "%RootDir%\%BuildOutDir%\Neumont.Tools.ORMToORMAbstractionBridge.pdb" "%NORMAExtensionsDir%\" +XCOPY /Y /D /V /Q "%RootDir%\%BuildOutDir%\Neumont.Tools.ORMToORMAbstractionBridge.xml" "%NORMAExtensionsDir%\" REG ADD "HKLM\%VSRegistryRoot%\Neumont\ORM Architect\Extensions\http://schemas.neumont.edu/ORM/Bridge/2007-06/ORMToORMAbstraction" /v "Class" /d "Neumont.Tools.ORMToORMAbstractionBridge.ORMToORMAbstractionBridgeDomainModel" /f 1>NUL REG ADD "HKLM\%VSRegistryRoot%\Neumont\ORM Architect\Extensions\http://schemas.neumont.edu/ORM/Bridge/2007-06/ORMToORMAbstraction" /v "CodeBase" /d "%NORMAExtensionsDir%\Neumont.Tools.ORMToORMAbstractionBridge.dll" /f 1>NUL Modified: trunk/RelationalModel/OialDcilBridge/NameGeneration.cs =================================================================== --- trunk/RelationalModel/OialDcilBridge/NameGeneration.cs 2007-08-30 17:36:21 UTC (rev 1105) +++ trunk/RelationalModel/OialDcilBridge/NameGeneration.cs 2007-08-30 17:58:08 UTC (rev 1106) @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Text; using Neumont.Tools.ORM.ObjectModel; +using ORMCore = Neumont.Tools.ORM.ObjectModel; using Microsoft.VisualStudio.Modeling; using Neumont.Tools.ORMAbstraction; using Neumont.Tools.ORMToORMAbstractionBridge; @@ -274,17 +275,16 @@ LinkedElementCollection<ConceptType> types = informationTypeFormat.ConceptTypeCollection; if (types.Count == 1) { - ObjectType preferredFor = ConceptTypeIsForObjectType.GetObjectType(types[0]); - LinkedElementCollection<Role> identifiers = preferredFor.ResolvedPreferredIdentifier.RoleCollection; - if (identifiers.Count == 1) + ObjectType preferredFor; + ORMCore.UniquenessConstraint preferredIdentifier; + LinkedElementCollection<Role> identifiers; + if (null != (preferredFor = ConceptTypeIsForObjectType.GetObjectType(types[0])) && + null != (preferredIdentifier = preferredFor.ResolvedPreferredIdentifier) && + 1 == (identifiers = preferredIdentifier.RoleCollection).Count && + identifiers[0].RolePlayer == InformationTypeFormatIsForValueType.GetValueType(informationTypeFormat) && + !informationTypeFormat.Name.StartsWith(preferredFor.Name)) { - if (identifiers[0].RolePlayer.Id == InformationTypeFormatIsForValueType.GetValueType(informationTypeFormat).Id) - { - if (!informationTypeFormat.Name.StartsWith(preferredFor.Name)) - { - valueTypeName = preferredFor.Name + "_"; - } - } + valueTypeName = preferredFor.Name + "_"; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mcu...@us...> - 2007-09-10 22:50:48
|
Revision: 1112 http://orm.svn.sourceforge.net/orm/?rev=1112&view=rev Author: mcurland Date: 2007-09-10 15:50:51 -0700 (Mon, 10 Sep 2007) Log Message: ----------- Added delete propagation to ReferenceConstraint and so that on reloading of the model we don't retain non-bound foreign keys. Implemented a change in the Oial Model to better check on a UniquenessConstraint if all children map towards the appropriate ObjectType. refs #327. Added additional code into the handling of separations so that when a separation is acting on a ConceptType that is being partitioned into assimilated ConceptTypes, it properly maps to them. refs #328. Modified Paths: -------------- trunk/Oial/ORMOialBridge/OialModelIsForORMModel.cs trunk/RelationalModel/DcilModel/DcilModel.dsl trunk/RelationalModel/DcilModel/GeneratedCode/DomainModel.cs trunk/RelationalModel/DcilModel/GeneratedCode/DomainRelationships.cs trunk/RelationalModel/OialDcilBridge/OialDcilBridge.DeserializationFixupListeners.cs Modified: trunk/Oial/ORMOialBridge/OialModelIsForORMModel.cs =================================================================== --- trunk/Oial/ORMOialBridge/OialModelIsForORMModel.cs 2007-09-01 19:13:42 UTC (rev 1111) +++ trunk/Oial/ORMOialBridge/OialModelIsForORMModel.cs 2007-09-10 22:50:51 UTC (rev 1112) @@ -936,7 +936,7 @@ } FactTypeMapping factTypeMapping = factTypeMappings[binarizedFactType]; - if (factTypeMapping.TowardsObjectType != objectType) + if (factTypeMapping.TowardsRole != childRole.OppositeRoleAlwaysResolveProxy.Role) { allChildrenMapTowardObjectType = false; break; Modified: trunk/RelationalModel/DcilModel/DcilModel.dsl =================================================================== --- trunk/RelationalModel/DcilModel/DcilModel.dsl 2007-09-01 19:13:42 UTC (rev 1111) +++ trunk/RelationalModel/DcilModel/DcilModel.dsl 2007-09-10 22:50:51 UTC (rev 1112) @@ -544,7 +544,7 @@ </DomainRole> </Source> <Target> - <DomainRole Id="6DAA73B4-E37E-4BE1-BB3C-DAFBCFD51343" Name="ReferenceConstraint" PropertyName="SourceTable" Multiplicity="One"> + <DomainRole Id="6DAA73B4-E37E-4BE1-BB3C-DAFBCFD51343" Name="ReferenceConstraint" PropertyName="SourceTable" Multiplicity="One" PropagatesDelete="true"> <RolePlayer> <DomainClassMoniker Name="ReferenceConstraint"/> </RolePlayer> @@ -653,7 +653,7 @@ </DomainRole> </Source> <Target> - <DomainRole Id="32200848-28E3-4D35-9A61-F592903B52BF" Name="Column" IsPropertyGenerator="false" Multiplicity="ZeroMany"> + <DomainRole Id="32200848-28E3-4D35-9A61-F592903B52BF" Name="Column" PropertyName="UniquenessConstraints" IsPropertyGenerator="false" Multiplicity="ZeroMany"> <RolePlayer> <DomainClassMoniker Name="Column"/> </RolePlayer> @@ -670,14 +670,14 @@ </ClrAttribute> </Attributes> <Source> - <DomainRole Id="22F748A4-8086-46C4-A323-E93574438D16" Name="ReferenceConstraint" PropertyName="TargetTable" Multiplicity="One"> + <DomainRole Id="22F748A4-8086-46C4-A323-E93574438D16" Name="ReferenceConstraint" PropertyName="TargetTable" Multiplicity="One" PropagatesDelete="true"> <RolePlayer> <DomainClassMoniker Name="ReferenceConstraint"/> </RolePlayer> </DomainRole> </Source> <Target> - <DomainRole Id="3EFFDDB4-4B20-4EB4-8A79-271240574413" Name="TargetTable" IsPropertyGenerator="false" Multiplicity="ZeroMany"> + <DomainRole Id="3EFFDDB4-4B20-4EB4-8A79-271240574413" Name="TargetTable" PropertyName="ReferenceConstraints" IsPropertyGenerator="false" Multiplicity="ZeroMany"> <RolePlayer> <DomainClassMoniker Name="Table"/> </RolePlayer> Modified: trunk/RelationalModel/DcilModel/GeneratedCode/DomainModel.cs =================================================================== --- trunk/RelationalModel/DcilModel/GeneratedCode/DomainModel.cs 2007-09-01 19:13:42 UTC (rev 1111) +++ trunk/RelationalModel/DcilModel/GeneratedCode/DomainModel.cs 2007-09-10 22:50:51 UTC (rev 1112) @@ -409,9 +409,11 @@ DomainRoles.Add(global::Neumont.Tools.RelationalModels.ConceptualDatabase.TableContainsColumn.ColumnDomainRoleId, true); DomainRoles.Add(global::Neumont.Tools.RelationalModels.ConceptualDatabase.TableContainsConstraint.ConstraintDomainRoleId, true); DomainRoles.Add(global::Neumont.Tools.RelationalModels.ConceptualDatabase.TableContainsUniquenessConstraint.UniquenessConstraintDomainRoleId, true); + DomainRoles.Add(global::Neumont.Tools.RelationalModels.ConceptualDatabase.TableContainsReferenceConstraint.ReferenceConstraintDomainRoleId, true); DomainRoles.Add(global::Neumont.Tools.RelationalModels.ConceptualDatabase.TableContainsCheckConstraint.CheckConstraintDomainRoleId, true); DomainRoles.Add(global::Neumont.Tools.RelationalModels.ConceptualDatabase.DomainContainsCheckConstraint.CheckConstraintDomainRoleId, true); DomainRoles.Add(global::Neumont.Tools.RelationalModels.ConceptualDatabase.ColumnHasPredefinedDataType.PredefinedDataTypeDomainRoleId, true); + DomainRoles.Add(global::Neumont.Tools.RelationalModels.ConceptualDatabase.ReferenceConstraintTargetsTable.ReferenceConstraintDomainRoleId, true); DomainRoles.Add(global::Neumont.Tools.RelationalModels.ConceptualDatabase.ReferenceConstraintContainsColumnReference.ColumnReferenceDomainRoleId, true); #endregion } Modified: trunk/RelationalModel/DcilModel/GeneratedCode/DomainRelationships.cs =================================================================== --- trunk/RelationalModel/DcilModel/GeneratedCode/DomainRelationships.cs 2007-09-01 19:13:42 UTC (rev 1111) +++ trunk/RelationalModel/DcilModel/GeneratedCode/DomainRelationships.cs 2007-09-10 22:50:51 UTC (rev 1112) @@ -1800,7 +1800,7 @@ /// </summary> [DslDesign::DisplayNameResource("Neumont.Tools.RelationalModels.ConceptualDatabase.TableContainsReferenceConstraint/ReferenceConstraint.DisplayName", typeof(global::Neumont.Tools.RelationalModels.ConceptualDatabase.ConceptualDatabaseDomainModel), "Neumont.Tools.RelationalModels.ConceptualDatabase.GeneratedCode.DomainModelResx")] [DslDesign::DescriptionResource("Neumont.Tools.RelationalModels.ConceptualDatabase.TableContainsReferenceConstraint/ReferenceConstraint.Description", typeof(global::Neumont.Tools.RelationalModels.ConceptualDatabase.ConceptualDatabaseDomainModel), "Neumont.Tools.RelationalModels.ConceptualDatabase.GeneratedCode.DomainModelResx")] - [DslModeling::DomainRole(DslModeling::DomainRoleOrder.Target, PropertyName = "SourceTable", PropertyDisplayNameKey="Neumont.Tools.RelationalModels.ConceptualDatabase.TableContainsReferenceConstraint/ReferenceConstraint.PropertyDisplayName", Multiplicity = DslModeling::Multiplicity.One)] + [DslModeling::DomainRole(DslModeling::DomainRoleOrder.Target, PropertyName = "SourceTable", PropertyDisplayNameKey="Neumont.Tools.RelationalModels.ConceptualDatabase.TableContainsReferenceConstraint/ReferenceConstraint.PropertyDisplayName", PropagatesDelete = true, Multiplicity = DslModeling::Multiplicity.One)] [DslModeling::DomainObjectId("6daa73b4-e37e-4be1-bb3c-dafbcfd51343")] public virtual ReferenceConstraint ReferenceConstraint { @@ -2551,13 +2551,13 @@ } #endregion - #region Static methods to access Columns of a Domain + #region Static methods to access columns of a Domain /// <summary> - /// Gets a list of Columns. + /// Gets a list of columns. /// </summary> [global::System.Diagnostics.DebuggerStepThrough] [global::System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1011")] - public static DslModeling::LinkedElementCollection<Column> GetColumns(Domain element) + public static DslModeling::LinkedElementCollection<Column> Getcolumns(Domain element) { return new DslModeling::LinkedElementCollection<Column>(element, DomainDomainRoleId); } @@ -2576,7 +2576,7 @@ /// </summary> [DslDesign::DisplayNameResource("Neumont.Tools.RelationalModels.ConceptualDatabase.ColumnHasDomain/Domain.DisplayName", typeof(global::Neumont.Tools.RelationalModels.ConceptualDatabase.ConceptualDatabaseDomainModel), "Neumont.Tools.RelationalModels.ConceptualDatabase.GeneratedCode.DomainModelResx")] [DslDesign::DescriptionResource("Neumont.Tools.RelationalModels.ConceptualDatabase.ColumnHasDomain/Domain.Description", typeof(global::Neumont.Tools.RelationalModels.ConceptualDatabase.ConceptualDatabaseDomainModel), "Neumont.Tools.RelationalModels.ConceptualDatabase.GeneratedCode.DomainModelResx")] - [DslModeling::DomainRole(DslModeling::DomainRoleOrder.Target, PropertyName = "Columns", PropertyDisplayNameKey="Neumont.Tools.RelationalModels.ConceptualDatabase.ColumnHasDomain/Domain.PropertyDisplayName", Multiplicity = DslModeling::Multiplicity.ZeroMany)] + [DslModeling::DomainRole(DslModeling::DomainRoleOrder.Target, PropertyName = "columns", PropertyDisplayNameKey="Neumont.Tools.RelationalModels.ConceptualDatabase.ColumnHasDomain/Domain.PropertyDisplayName", Multiplicity = DslModeling::Multiplicity.ZeroMany)] [DslModeling::DomainObjectId("8049efc1-7e4f-4965-82e7-d0b376424c57")] public virtual Domain Domain { @@ -2640,7 +2640,7 @@ /// </summary> [global::System.Diagnostics.DebuggerStepThrough] [global::System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1011")] - public static global::System.Collections.ObjectModel.ReadOnlyCollection<global::Neumont.Tools.RelationalModels.ConceptualDatabase.ColumnHasDomain> GetLinksToColumns ( global::Neumont.Tools.RelationalModels.ConceptualDatabase.Domain domainInstance ) + public static global::System.Collections.ObjectModel.ReadOnlyCollection<global::Neumont.Tools.RelationalModels.ConceptualDatabase.ColumnHasDomain> GetLinksTocolumns ( global::Neumont.Tools.RelationalModels.ConceptualDatabase.Domain domainInstance ) { return DslModeling::DomainRoleInfo.GetElementLinks<global::Neumont.Tools.RelationalModels.ConceptualDatabase.ColumnHasDomain>(domainInstance, global::Neumont.Tools.RelationalModels.ConceptualDatabase.ColumnHasDomain.DomainDomainRoleId); } @@ -3519,7 +3519,7 @@ /// </summary> [DslDesign::DisplayNameResource("Neumont.Tools.RelationalModels.ConceptualDatabase.ReferenceConstraintTargetsTable/ReferenceConstraint.DisplayName", typeof(global::Neumont.Tools.RelationalModels.ConceptualDatabase.ConceptualDatabaseDomainModel), "Neumont.Tools.RelationalModels.ConceptualDatabase.GeneratedCode.DomainModelResx")] [DslDesign::DescriptionResource("Neumont.Tools.RelationalModels.ConceptualDatabase.ReferenceConstraintTargetsTable/ReferenceConstraint.Description", typeof(global::Neumont.Tools.RelationalModels.ConceptualDatabase.ConceptualDatabaseDomainModel), "Neumont.Tools.RelationalModels.ConceptualDatabase.GeneratedCode.DomainModelResx")] - [DslModeling::DomainRole(DslModeling::DomainRoleOrder.Source, PropertyName = "TargetTable", PropertyDisplayNameKey="Neumont.Tools.RelationalModels.ConceptualDatabase.ReferenceConstraintTargetsTable/ReferenceConstraint.PropertyDisplayName", Multiplicity = DslModeling::Multiplicity.One)] + [DslModeling::DomainRole(DslModeling::DomainRoleOrder.Source, PropertyName = "TargetTable", PropertyDisplayNameKey="Neumont.Tools.RelationalModels.ConceptualDatabase.ReferenceConstraintTargetsTable/ReferenceConstraint.PropertyDisplayName", PropagatesDelete = true, Multiplicity = DslModeling::Multiplicity.One)] [DslModeling::DomainObjectId("22f748a4-8086-46c4-a323-e93574438d16")] public virtual ReferenceConstraint ReferenceConstraint { Modified: trunk/RelationalModel/OialDcilBridge/OialDcilBridge.DeserializationFixupListeners.cs =================================================================== --- trunk/RelationalModel/OialDcilBridge/OialDcilBridge.DeserializationFixupListeners.cs 2007-09-01 19:13:42 UTC (rev 1111) +++ trunk/RelationalModel/OialDcilBridge/OialDcilBridge.DeserializationFixupListeners.cs 2007-09-10 22:50:51 UTC (rev 1112) @@ -511,11 +511,9 @@ List<ConceptTypeChild> preferredConceptTypeChildList = GetPreferredConceptTypeChildrenForConceptType(conceptType); List<Column> columnsForConceptType = new List<Column>(); - List<ConceptTypeChild> tester = new List<ConceptTypeChild>(); foreach (ConceptTypeChild conceptTypeChild in ConceptTypeChild.GetLinksToTargetCollection(conceptType)) { - tester.Add(conceptTypeChild); if (!(conceptTypeChild is ConceptTypeAssimilatesConceptType)) { columnsForConceptType.AddRange(GetColumnsForConceptTypeChild(conceptTypeChild, new List<ConceptTypeChild>())); @@ -1075,6 +1073,29 @@ } } } + else + { + // If the seperation is further partitioned then it will not have a secondary child table, further assimilations or seperations are ok though. + ReadOnlyCollection<ConceptTypeAssimilatesConceptType> childAssimilations = ConceptTypeAssimilatesConceptType.GetLinksToAssimilatedConceptTypeCollection(assimilation.AssimilatedConceptType); + bool isPartitioned = false; + foreach (ConceptTypeAssimilatesConceptType possiblePartition in childAssimilations) + { + if (AssimilationMapping.GetAssimilationMappingFromAssimilation(possiblePartition).AbsorptionChoice == AssimilationAbsorptionChoice.Partition) + { + isPartitioned = true; + break; + } + } + if (isPartitioned) + { + bool prefered = false; + foreach (ConceptTypeAssimilatesConceptType partition in childAssimilations) + { + DoSeparation(partition, ref prefered); + prefered = false; + } + } + } } /// <summary> @@ -1198,18 +1219,47 @@ } else if (AssimilationMapping.GetAbsorptionChoiceFromAssimilation(conceptTypeAssimilatesConceptType) == AssimilationAbsorptionChoice.Separate) { - Table targetTable = TableIsPrimarilyForConceptType.GetTable(conceptTypeAssimilatesConceptType.AssimilatedConceptType); + // UNDONE: Problem occuring with A is partitioned to B, C; C is partitioned to D, E. Setting A-C to Partition + ReadOnlyCollection<ConceptTypeAssimilatesConceptType> childCollection = ConceptTypeAssimilatesConceptType.GetLinksToAssimilatedConceptTypeCollection(conceptTypeAssimilatesConceptType.AssimilatedConceptType); - foreach (Column target in targetTable.ColumnCollection) + /**/ + bool containsPartitions = false; + foreach (ConceptTypeAssimilatesConceptType act in childCollection) { - foreach (ConceptTypeChild conceptTypeChild in ColumnHasConceptTypeChild.GetConceptTypeChildPath(target)) + if (AssimilationMapping.GetAssimilationMappingFromAssimilation(act).AbsorptionChoice == AssimilationAbsorptionChoice.Partition) { - if (ColumnHasConceptTypeChild.GetConceptTypeChildPath(target).Contains(conceptTypeChild) && target != column) + + containsPartitions = true; + break; + } + } + /**/ + /**/ + if (!containsPartitions) + { + /**/ + Table targetTable = TableIsPrimarilyForConceptType.GetTable(conceptTypeAssimilatesConceptType.AssimilatedConceptType); + + foreach (Column target in targetTable.ColumnCollection) + { + foreach (ConceptTypeChild conceptTypeChild in ColumnHasConceptTypeChild.GetConceptTypeChildPath(target)) { - columns.Add(target); + if (ColumnHasConceptTypeChild.GetConceptTypeChildPath(target).Contains(conceptTypeChild) && target != column) + { + columns.Add(target); + } } } + /**/ } + else + { + foreach (ConceptTypeAssimilatesConceptType act in childCollection) + { + columns.AddRange(ConceptTypeHasPrimaryIdentifierColumns(column, act.AssimilatedConceptType)); + } + } + /**/ } } @@ -1440,9 +1490,11 @@ /// <param name="conceptType">The <see cref="ConceptType"/>.</param> private static void CreateUniquenessConstraints(ConceptType conceptType) { + // UNDONE: Look here for possible problems with ring contstraints Table isPrimarilyForTable = TableIsPrimarilyForConceptType.GetTable(conceptType); if (isPrimarilyForTable != null) { + List<Uniqueness> alreadyDone = new List<Uniqueness>(); foreach (Uniqueness uniqueness in conceptType.UniquenessCollection) { UniquenessConstraint uniquenessConstraint = new UniquenessConstraint(uniqueness.Store, new PropertyAssignment[] { new PropertyAssignment(UniquenessConstraint.NameDomainPropertyId, uniqueness.Name) }); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mcu...@us...> - 2007-09-10 23:09:49
|
Revision: 1122 http://orm.svn.sourceforge.net/orm/?rev=1122&view=rev Author: mcurland Date: 2007-09-10 16:09:52 -0700 (Mon, 10 Sep 2007) Log Message: ----------- Relational name generation is looping, get a less fragile algorithm. refs #338 Also changed prefix for old oial model, the serializer does not handle duplicate preferred prefixes. Modified Paths: -------------- trunk/OIALModel/OIALModel.SerializationExtensions.cs trunk/OIALModel/OIALModel.SerializationExtensions.xml trunk/RelationalModel/OialDcilBridge/NameGeneration.cs Modified: trunk/OIALModel/OIALModel.SerializationExtensions.cs =================================================================== --- trunk/OIALModel/OIALModel.SerializationExtensions.cs 2007-09-10 23:07:39 UTC (rev 1121) +++ trunk/OIALModel/OIALModel.SerializationExtensions.cs 2007-09-10 23:09:52 UTC (rev 1122) @@ -34,7 +34,7 @@ { get { - return "oial"; + return "oial0"; } } string ICustomSerializedDomainModel.DefaultElementPrefix @@ -48,7 +48,7 @@ protected static string[,] GetCustomElementNamespaces() { string[,] ret = new string[1, 3]; - ret[0, 0] = "oial"; + ret[0, 0] = "oial0"; ret[0, 1] = "http://schemas.neumont.edu/ORM/2006-01/OIALModel"; ret[0, 2] = "OIALModel.xsd"; return ret; Modified: trunk/OIALModel/OIALModel.SerializationExtensions.xml =================================================================== --- trunk/OIALModel/OIALModel.SerializationExtensions.xml 2007-09-10 23:07:39 UTC (rev 1121) +++ trunk/OIALModel/OIALModel.SerializationExtensions.xml 2007-09-10 23:09:52 UTC (rev 1122) @@ -19,7 +19,7 @@ </se:Copyright> <se:DomainModel Class="OIALDomainModel"> <se:Namespaces> - <se:Namespace Prefix="oial" URI="http://schemas.neumont.edu/ORM/2006-01/OIALModel" SchemaFile="OIALModel.xsd" DefaultPrefix="true"/> + <se:Namespace Prefix="oial0" URI="http://schemas.neumont.edu/ORM/2006-01/OIALModel" SchemaFile="OIALModel.xsd" DefaultPrefix="true"/> </se:Namespaces> <se:RootElements> <se:RootElement Class="OIALModel" Name="Model"/> Modified: trunk/RelationalModel/OialDcilBridge/NameGeneration.cs =================================================================== --- trunk/RelationalModel/OialDcilBridge/NameGeneration.cs 2007-09-10 23:07:39 UTC (rev 1121) +++ trunk/RelationalModel/OialDcilBridge/NameGeneration.cs 2007-09-10 23:09:52 UTC (rev 1122) @@ -10,6 +10,7 @@ using System.Text.RegularExpressions; using System.Diagnostics; using System.Globalization; +using System.Collections; namespace Neumont.Tools.ORMAbstractionToConceptualDatabaseBridge { @@ -55,107 +56,347 @@ #region GenerateAllNames method public static void GenerateAllNames(Schema schema) { - Dictionary<string, ConceptualDatabaseModelElement> tableNames = new Dictionary<string, ConceptualDatabaseModelElement>(); - Dictionary<string, ConceptualDatabaseModelElement> tempNames = new Dictionary<string, ConceptualDatabaseModelElement>(); + UniqueNameGenerator uniqueChecker = new UniqueNameGenerator(); + LinkedElementCollection<Table> tables = schema.TableCollection; + + // Generate table names + uniqueChecker.GenerateUniqueElementNames( + tables, + delegate(object element, string longerThan) + { + return GenerateTableName((Table)element, longerThan); + }, + delegate(object element, string longerThan) + { + ((Table)element).Name = longerThan; + }); + foreach (Table table in tables) { - //table names - CallGeneratorForTableName(table, tableNames, null); - //column names - tempNames.Clear(); - LinkedElementCollection<Column> columns = table.ColumnCollection; - foreach (Column column in columns) - { - CallGeneratorForColumnName(column, tempNames, null); - } + uniqueChecker.GenerateUniqueElementNames( + table.ColumnCollection, + delegate(object element, string longerThan) + { + return GenerateColumnName((Column)element, longerThan); + }, + delegate(object element, string longerThan) + { + ((Column)element).Name = longerThan; + }); //constraint names LinkedElementCollection<ReferenceConstraint> constraints; - if (null != (constraints = table.ReferenceConstraintCollection)) + if (0 != (constraints = table.ReferenceConstraintCollection).Count) { - tempNames.Clear(); - foreach (ReferenceConstraint constraint in constraints) - { - CallGeneratorForConstraintName(constraint, tempNames, null); - } + uniqueChecker.GenerateUniqueElementNames( + constraints, + delegate(object element, string longerThan) + { + return GenerateConstraintName((Constraint)element, longerThan); + }, + delegate(object element, string longerThan) + { + ((Constraint)element).Name = longerThan; + }); } } } #endregion // GenerateAllNames method - #region private helper methods - private static void CallGeneratorForTableName(Table table, Dictionary<string, ConceptualDatabaseModelElement> tableNames, string tableName) + #region Unique name generation algorithm + /// <summary> + /// Generate a candidate name for the given <paramref name="element"/> + /// </summary> + /// <param name="element">The element to generate a candidate name for</param> + /// <param name="longerThan">A previously generated name. Generate a longer form of the name. Generate a shorter name if this is null.</param> + /// <returns>The candidate name, or <see langword="null"/> if a longer name is not available.</returns> + private delegate string GenerateCandidateElementNameCallback(object element, string longerThan); + /// <summary> + /// Set the name for the given element. Used by GenerateUniqueElementNames + /// </summary> + private delegate void SetElementNameCallback(object element, string elementName); + private struct UniqueNameGenerator { - CallGenerator(table, tableNames, tableName, - new GeneratorCall(delegate(ConceptualDatabaseModelElement element, string longerThan) + #region ElementNode class + /// <summary> + /// A linked list node class. LinkedList{} is too hard to modify during iteration, + /// and a LinkedListNode{} requires a LinkedList, so we rolled our own. + /// </summary> + private class ElementNode + { + private object myElement; + private ElementNode myNext; + private ElementNode myPrev; + public ElementNode(object element) { - return GenerateTableName(element as Table, longerThan); - })); - } - private static void CallGeneratorForColumnName(Column column, Dictionary<string, ConceptualDatabaseModelElement> columnNames, string columnName) - { - CallGenerator(column, columnNames, columnName, - new GeneratorCall(delegate(ConceptualDatabaseModelElement element, string longerThan) + myElement = element; + } + /// <summary> + /// Set the next element + /// </summary> + /// <param name="next">Next element. If next has a previous element, then the head of the next element is inserted.</param> + /// <param name="head">Reference to head node</param> + public void SetNext(ElementNode next, ref ElementNode head) { - return GenerateColumnName(element as Column, longerThan); - })); - } - private static void CallGeneratorForConstraintName(Constraint constraint, Dictionary<string, ConceptualDatabaseModelElement> constraintNames, string constraintName) - { - CallGenerator(constraint, constraintNames, constraintName, - new GeneratorCall(delegate(ConceptualDatabaseModelElement element, string longerThan) + Debug.Assert(next != null); + if (next.myPrev != null) + { + next.myPrev.SetNext(GetHead(), ref head); + return; + } + if (myNext != null) + { + myNext.myPrev = next.GetTail(); + } + if (myPrev == null) + { + head = this; + } + myNext = next; + next.myPrev = this; + } + /// <summary> + /// The element passed to the constructor + /// </summary> + public object Element { - return GenerateConstraintName(element as Constraint, longerThan); - })); - } - delegate string GeneratorCall(ConceptualDatabaseModelElement element, string longerThan); - private static void CallGenerator(ConceptualDatabaseModelElement element, Dictionary<string, ConceptualDatabaseModelElement> existingNames, string curName, GeneratorCall generatorCall) - { - ConceptualDatabaseModelElement nameConflictElement = null; - while (true) + get + { + return myElement; + } + } + /// <summary> + /// Get the next node + /// </summary> + public ElementNode Next + { + get + { + return myNext; + } + } + /// <summary> + /// Get the previous node + /// </summary> + public ElementNode Previous + { + get + { + return myPrev; + } + } + /// <summary> + /// Get the head element in the linked list + /// </summary> + public ElementNode GetHead() + { + ElementNode retVal = this; + ElementNode prev; + while (null != (prev = retVal.myPrev)) + { + retVal = prev; + } + return retVal; + } + /// <summary> + /// Get the tail element in the linked list + /// </summary> + public ElementNode GetTail() + { + ElementNode retVal = this; + ElementNode next; + while (null != (next = retVal.myNext)) + { + retVal = next; + } + return retVal; + } + /// <summary> + /// Detach the current node + /// </summary> + /// <param name="headNode"></param> + public void Detach(ref ElementNode headNode) + { + if (myPrev == null) + { + headNode = myNext; + } + else + { + myPrev.myNext = myNext; + } + if (myNext != null) + { + myNext.myPrev = myPrev; + } + myNext = null; + myPrev = null; + } + } + #endregion // ElementNode class + #region Fields + /// <summary> + /// Map already generated names into a dictionary that contains either one of the element + /// objects or a linked list of objects. Linked lists contain duplicate nodes + /// </summary> + private Dictionary<string, object> myNameMappingDictionary; + /// <summary> + /// A dictionary of unresolved names, corresponds to keys in the nameMappingDictionary + /// </summary> + Dictionary<string, string> myUnresolvedNames; + #endregion // Fields + #region Public methods + public void GenerateUniqueElementNames(IEnumerable elements, GenerateCandidateElementNameCallback generateName, SetElementNameCallback setName) { - if (null != nameConflictElement) + if (myNameMappingDictionary != null) { - //set the value in the collection to null so this element does not have yet another name generated - existingNames[curName] = null; - //generate a new name for this element as well - CallGenerator(nameConflictElement, existingNames, curName, generatorCall); + myNameMappingDictionary.Clear(); } + else + { + myNameMappingDictionary = new Dictionary<string, object>(); + } + if (myUnresolvedNames != null) + { + myUnresolvedNames.Clear(); + } + // Generate initial names + foreach (object element in elements) + { + string elementName = generateName(element, null); + if (elementName != null) + { + AddElement(element, elementName); + } + } - curName = generatorCall(element, curName); + Dictionary<string, object> nameMappingDictionary = myNameMappingDictionary; + while (myUnresolvedNames != null && 0 != myUnresolvedNames.Count) + { + // Walk the existing unresolved names and attempt to resolve them further. + // Iterate until we can't resolve any more + Dictionary<string, string> unresolvedNames = myUnresolvedNames; + myUnresolvedNames = null; - if (existingNames.ContainsKey(curName)) + foreach (string currentName in unresolvedNames.Values) + { + // If we've added this name as unresolved during this pass, then take it back out + // We'll a + if (myUnresolvedNames != null && myUnresolvedNames.ContainsKey(currentName)) + { + myUnresolvedNames.Remove(currentName); + } + ElementNode startHeadNode = (ElementNode)nameMappingDictionary[currentName]; + ElementNode headNode = startHeadNode; + ElementNode nextNode = headNode; + while (nextNode != null) + { + ElementNode currentNode = nextNode; + nextNode = currentNode.Next; + + object element = currentNode.Element; + string newName = generateName(element, currentName); + // Name generation can return null if the longerThan condition cannot be satisfied + if (newName != null && newName.Length > currentName.Length) + { + currentNode.Detach(ref headNode); + // UNDONE: Is it worth reusing the old node? + AddElement(element, newName); + } + } + + // Manage the remains of the list in the dictionary + if (headNode == null) + { + // Everything detached from this name, remove the key + nameMappingDictionary.Remove(currentName); + } + else if (headNode != startHeadNode) + { + nameMappingDictionary[currentName] = headNode; + } + } + } + + // Walk the set, appending additional numbers as needed, and set the names + foreach (KeyValuePair<string, object> pair in nameMappingDictionary) { - //mark the conflicting element to have a new name generated as well - nameConflictElement = existingNames[curName]; + object element = pair.Value; + ElementNode node = element as ElementNode; + if (node != null) + { + // We added these in reverse order, so walk backwards to number them + ElementNode tail = node.GetTail(); + if (node == tail) + { + setName(node.Element, pair.Key); + } + else + { + // We need to resolve further + string baseName = pair.Key; + int currentIndex = 0; + ElementNode nextNode = tail; + while (nextNode != null) + { + element = nextNode.Element; + nextNode = nextNode.Previous; // We started at the tail, walk backwards + + string candidateName; + do + { + ++currentIndex; + candidateName = baseName + currentIndex.ToString(); + } while (nameMappingDictionary.ContainsKey(candidateName)); + + // If we get out of the loop, then we finally have a unique name + setName(element, candidateName); + } + } + } + else + { + setName(element, pair.Key); + } } + } + #endregion // Public methods + #region Helper methods + private void AddElement(object element, string elementName) + { + object existing; + Dictionary<string, object> nameMappingDictionary = myNameMappingDictionary; + if (nameMappingDictionary.TryGetValue(elementName, out existing)) + { + // Note: We use LinkedListNode here directly instead of a LinkedList + // to facilitate dynamically adding/removing elements during iteration + ElementNode node = existing as ElementNode; + if (node == null) + { + // Record the unresolvedName + if (myUnresolvedNames == null) + { + myUnresolvedNames = new Dictionary<string, string>(); + } + myUnresolvedNames[elementName] = elementName; + + // Create a node for the original element + node = new ElementNode(existing); + } + + ElementNode newNode = new ElementNode(element); + newNode.SetNext(node, ref node); + nameMappingDictionary[elementName] = newNode; + } else { - //no conflict, so we are done - break; + nameMappingDictionary[elementName] = element; } } - existingNames.Add(curName, element); - - //set the name - Table table; - Column column; - Constraint constraint; - if (null != (constraint = element as Constraint)) - { - constraint.Name = curName; - } - else if (null != (column = element as Column)) - { - column.Name = curName; - } - else if (null != (table = element as Table)) - { - table.Name = curName; - } + #endregion // Helper methods } - #endregion // private helper methods + #endregion // Unique name generation algorithm #region UNDONE: temporary static imitation of an IDatabaseNameGenerator implementation private static Regex myReplaceFieldsPattern; private static Regex myNumberPattern; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mcu...@us...> - 2007-09-10 23:46:56
|
Revision: 1124 http://orm.svn.sourceforge.net/orm/?rev=1124&view=rev Author: mcurland Date: 2007-09-10 16:46:57 -0700 (Mon, 10 Sep 2007) Log Message: ----------- Added ability to allow generators to require extensions from the ORM designer. The UI is a little clunky (you need to open the ORM designer to add extensions), but the large amount of additional work to do this without opening the designer file coupled with the small usability gain makes the designer-free extension enabling a low priority feature. refs #339 Modified Paths: -------------- trunk/ORMModel/Shell/ExtensionManager.cs trunk/ORMModel/Shell/ORMDocData.cs trunk/Tools/ORMCustomTool/Extender.cs trunk/Tools/ORMCustomTool/IORMGenerator.cs trunk/Tools/ORMCustomTool/ORMCustomTool.cs trunk/Tools/ORMCustomTool/ORMCustomTool.csproj trunk/Tools/ORMCustomTool/UI/MainBranch.cs trunk/Tools/ORMCustomTool/UI/ORMGeneratorSelectionControl.cs trunk/Tools/ORMCustomTool/XslORMGenerator.cs Added Paths: ----------- trunk/Tools/ORMCustomTool/ORMExtensionManager.cs Modified: trunk/ORMModel/Shell/ExtensionManager.cs =================================================================== --- trunk/ORMModel/Shell/ExtensionManager.cs 2007-09-10 23:11:55 UTC (rev 1123) +++ trunk/ORMModel/Shell/ExtensionManager.cs 2007-09-10 23:46:57 UTC (rev 1124) @@ -77,47 +77,8 @@ checkedTypes.Add((ORMExtensionType)listViewItem.Tag); } - IList<ORMExtensionType> allExtensionTypes = extensionManager._allExtensionTypes; + AddRequiredExtensions(checkedTypes, extensionManager._allExtensionTypes); - List<Guid> loadedDomainModelIds = new List<Guid>(4 + checkedTypes.Count); - loadedDomainModelIds.Add(CoreDomainModel.DomainModelId); - loadedDomainModelIds.Add(Microsoft.VisualStudio.Modeling.Diagrams.CoreDesignSurfaceDomainModel.DomainModelId); - loadedDomainModelIds.Add(ObjectModel.ORMCoreDomainModel.DomainModelId); - loadedDomainModelIds.Add(ShapeModel.ORMShapeDomainModel.DomainModelId); - foreach (ORMExtensionType extensionType in checkedTypes) - { - loadedDomainModelIds.Add(extensionType.Type.GUID); - } - - for (int i = 0; i < checkedTypes.Count; i++) - { - foreach (ExtendsDomainModelAttribute extendsDomainModelAttribute in checkedTypes[i].Type.GetCustomAttributes(typeof(ExtendsDomainModelAttribute), false)) - { - Guid extendedModelId = extendsDomainModelAttribute.ExtendedModelId; - if (!loadedDomainModelIds.Contains(extendedModelId)) - { - // Find the missing domain model - foreach (ORMExtensionType candidateExtensionType in allExtensionTypes) - { - object[] domainObjectIdAttributes = candidateExtensionType.Type.GetCustomAttributes(typeof(DomainObjectIdAttribute), false); - if (domainObjectIdAttributes.Length <= 0) - { - continue; - } - Guid candidateModelId = ((DomainObjectIdAttribute)domainObjectIdAttributes[0]).Id; - if (extendedModelId.Equals(candidateModelId)) - { - loadedDomainModelIds.Add(candidateModelId); - checkedTypes.Add(candidateExtensionType); - break; - } - } - // If we didn't find the requested domain model, we don't need to worry about doing anything here, - // since the Store will throw later when they try to load the requesting domain model. - } - } - } - Stream stream = null; try { @@ -140,6 +101,50 @@ } } /// <summary> + /// Given a current list of extensions and all available extensions, add additional required extensions to the list + /// </summary> + public static void AddRequiredExtensions(IList<ORMExtensionType> extensions, IList<ORMExtensionType> allExtensions) + { + Dictionary<Guid, object> loadedDomainModelIds = new Dictionary<Guid, object>(4 + allExtensions.Count); + loadedDomainModelIds.Add(CoreDomainModel.DomainModelId, null); + loadedDomainModelIds.Add(Microsoft.VisualStudio.Modeling.Diagrams.CoreDesignSurfaceDomainModel.DomainModelId, null); + loadedDomainModelIds.Add(ObjectModel.ORMCoreDomainModel.DomainModelId, null); + loadedDomainModelIds.Add(ShapeModel.ORMShapeDomainModel.DomainModelId, null); + foreach (ORMExtensionType extensionType in extensions) + { + loadedDomainModelIds.Add(extensionType.Type.GUID, null); + } + + for (int i = 0; i < extensions.Count; i++) // The count check here is correct, we're growing the list as we go + { + foreach (ExtendsDomainModelAttribute extendsDomainModelAttribute in extensions[i].Type.GetCustomAttributes(typeof(ExtendsDomainModelAttribute), false)) + { + Guid extendedModelId = extendsDomainModelAttribute.ExtendedModelId; + if (!loadedDomainModelIds.ContainsKey(extendedModelId)) + { + // Find the missing domain model + foreach (ORMExtensionType candidateExtensionType in allExtensions) + { + object[] domainObjectIdAttributes = candidateExtensionType.Type.GetCustomAttributes(typeof(DomainObjectIdAttribute), false); + if (domainObjectIdAttributes.Length <= 0) + { + continue; + } + Guid candidateModelId = ((DomainObjectIdAttribute)domainObjectIdAttributes[0]).Id; + if (extendedModelId.Equals(candidateModelId)) + { + loadedDomainModelIds.Add(candidateModelId, null); + extensions.Add(candidateExtensionType); + break; + } + } + // If we didn't find the requested domain model, we don't need to worry about doing anything here, + // since the Store will throw later when they try to load the requesting domain model. + } + } + } + } + /// <summary> /// This is a custom callback class for the XSLT file that is /// responsible for adding or removing the custom extension namespaces to the ORM document. /// </summary> @@ -225,7 +230,7 @@ /// <param name="stream">The file stream that contains the ORM file.</param> /// <param name="extensionTypes">A list of extension types.</param> /// <returns>The cleaned stream.</returns> - private static Stream CleanupStream(Stream stream, IList<ORMExtensionType> extensionTypes) + public static Stream CleanupStream(Stream stream, IList<ORMExtensionType> extensionTypes) { MemoryStream outputStream = new MemoryStream((int)stream.Length); XsltArgumentList argList = new XsltArgumentList(); Modified: trunk/ORMModel/Shell/ORMDocData.cs =================================================================== --- trunk/ORMModel/Shell/ORMDocData.cs 2007-09-10 23:11:55 UTC (rev 1123) +++ trunk/ORMModel/Shell/ORMDocData.cs 2007-09-10 23:46:57 UTC (rev 1124) @@ -35,6 +35,7 @@ using System.Xml.Schema; using System.Collections.ObjectModel; using Neumont.Tools.Modeling.Shell.DynamicSurveyTreeGrid; +using System.Runtime.InteropServices; namespace Neumont.Tools.ORM.Shell { @@ -690,6 +691,120 @@ #endregion // Tab Restoration Hack #region Automation support /// <summary> + /// Class used for the document extensibility layer. Request + /// the "ORMExtensionManager" extension object. + /// </summary> + [ComVisible(true)] + [ClassInterface(ClassInterfaceType.AutoDispatch)] + public class ORMExtensionManagerAutomationObject + { + private ORMDesignerDocData myDocData; + /// <summary> + /// Create a new <see cref="ORMExtensionManagerAutomationObject"/> for the specific <paramref name="docData"/> + /// </summary> + /// <param name="docData">An <see cref="ORMDesignerDocData"/> instance</param> + public ORMExtensionManagerAutomationObject(ORMDesignerDocData docData) + { + myDocData = docData; + } + /// <summary> + /// Retrieve a string array of loaded extension names + /// </summary> + public string[] GetLoadedExtensions() + { + IList<ORMExtensionType> availableExtensions = ORMDesignerPackage.GetAvailableCustomExtensions(); + List<string> extensionNames = new List<string>(); + foreach (DomainModel domainModel in myDocData.Store.DomainModels) + { + Type domainModelType = domainModel.GetType(); + foreach (ORMExtensionType extensionInfo in availableExtensions) + { + if (extensionInfo.Type == domainModelType) + { + extensionNames.Add(extensionInfo.NamespaceUri); + break; + } + } + } + return extensionNames.ToArray(); + } + /// <summary> + /// Verify that the requested extensions are loaded in the current designer instance + /// </summary> + public void EnsureExtensions(string[] extensions) + { + int ensureCount; + if (extensions != null && (ensureCount = extensions.Length) != 0) + { + string[] clonedExtensions = (string[])extensions.Clone(); + IList<ORMExtensionType> availableExtensions = ORMDesignerPackage.GetAvailableCustomExtensions(); + List<ORMExtensionType> loadedExtensions = null; + foreach (DomainModel domainModel in myDocData.Store.DomainModels) + { + Type domainModelType = domainModel.GetType(); + foreach (ORMExtensionType extensionInfo in availableExtensions) + { + if (extensionInfo.Type == domainModelType) + { + string namespaceUri = extensionInfo.NamespaceUri; + for (int i = 0; i < clonedExtensions.Length; ++i) + { + if (clonedExtensions[i] == namespaceUri) + { + --ensureCount; + if (ensureCount == 0) + { + return; // Nothing to do, everything we need is already loaded + } + if (loadedExtensions == null) + { + loadedExtensions = new List<ORMExtensionType>(); + } + loadedExtensions.Add(extensionInfo); + clonedExtensions[i] = null; + } + } + break; + } + } + } + for (int i = 0; i < clonedExtensions.Length; ++i) + { + string newExtension = clonedExtensions[i]; + if (newExtension != null) + { + --ensureCount; + foreach (ORMExtensionType extensionInfo in availableExtensions) + { + if (extensionInfo.NamespaceUri == newExtension) + { + if (loadedExtensions == null) + { + loadedExtensions = new List<ORMExtensionType>(); + } + loadedExtensions.Add(extensionInfo); + break; + } + } + if (ensureCount == 0) + { + break; + } + } + } + Object streamObj; + (myDocData as EnvDTE.IExtensibleObject).GetAutomationObject("ORMXmlStream", null, out streamObj); + Stream stream = streamObj as Stream; + + Debug.Assert(stream != null); + + ExtensionManager.AddRequiredExtensions(loadedExtensions, availableExtensions); + stream = ExtensionManager.CleanupStream(stream, loadedExtensions); + myDocData.ReloadFromStream(stream); + } + } + } + /// <summary> /// Implements IExtensibleObject.GetAutomationObject. Returns the ORM XML stream for /// the "ORMXmlStream" object name and the this object for everything else. /// </summary> @@ -703,6 +818,14 @@ result = stream; return; } + else if ("ORMExtensionManager" == name) + { + // This returns an object with two methods: + // GetLoadedExtensions returns an array of current loaded extension objects + // EnsureExtensions accepts an array of extensions that need to be loaded + result = new ORMExtensionManagerAutomationObject(this); + return; + } result = this; } void IExtensibleObject.GetAutomationObject(string Name, IExtensibleObjectSite pParent, out object ppDisp) Modified: trunk/Tools/ORMCustomTool/Extender.cs =================================================================== --- trunk/Tools/ORMCustomTool/Extender.cs 2007-09-10 23:11:55 UTC (rev 1123) +++ trunk/Tools/ORMCustomTool/Extender.cs 2007-09-10 23:46:57 UTC (rev 1124) @@ -17,6 +17,7 @@ using System.Runtime.InteropServices; using System.ComponentModel; using System.Drawing.Design; +using System.Diagnostics; namespace Neumont.Tools.ORM.ORMCustomTool { @@ -78,6 +79,15 @@ /// </summary> ~Extender() { + NotifyDeleteCookie(); + } + /// <summary> + /// Helper method to prevent the debugger from breaking when a common + /// exception is thrown deleting the cookie. + /// </summary> + [DebuggerStepThrough] + private void NotifyDeleteCookie() + { // Wrap this call in a try-catch to avoid any failure code the // Site may return. For instance, since this object is GC'ed, // the Site may have already let go of its Cookie. @@ -88,7 +98,7 @@ mySite.NotifyDelete(myCookie); } } - catch + catch { } } Modified: trunk/Tools/ORMCustomTool/IORMGenerator.cs =================================================================== --- trunk/Tools/ORMCustomTool/IORMGenerator.cs 2007-09-10 23:11:55 UTC (rev 1123) +++ trunk/Tools/ORMCustomTool/IORMGenerator.cs 2007-09-10 23:46:57 UTC (rev 1124) @@ -93,6 +93,14 @@ } /// <summary> + /// Get required extensions for an associated input format. The extensions ensure that the input formats + /// meet additional content requirements not expressible based solely on file format. + /// </summary> + /// <param name="inputFormat">The official name of the required input format, retrieved from <see cref="RequiresInputFormats"/>.</param> + /// <returns>An enumerable of required extensions. The extensions must be enabled by the generator chosen to produce the given input format.</returns> + IEnumerable<string> GetRequiredExtensionsForInputFormat(string inputFormat); + + /// <summary> /// Returns the default name of the file generated for a specific source file name. /// </summary> /// <param name="sourceFileName">A <see cref="String"/> containing the name (without file extension) of the source ORM file.</param> Modified: trunk/Tools/ORMCustomTool/ORMCustomTool.cs =================================================================== --- trunk/Tools/ORMCustomTool/ORMCustomTool.cs 2007-09-10 23:11:55 UTC (rev 1123) +++ trunk/Tools/ORMCustomTool/ORMCustomTool.cs 2007-09-10 23:46:57 UTC (rev 1124) @@ -517,9 +517,15 @@ ormStream = new MemoryStream(Encoding.UTF8.GetBytes(bstrInputFileContents), false); } + // Switch the ormStream to a readonly stream so we can reuse it multiple times + ormStream = new ReadOnlyStream(ormStream); + // Add the input ORM file Stream... - outputFormatStreams.Add(ORMOutputFormat.ORM, new ReadOnlyStream(ormStream)); + outputFormatStreams.Add(ORMOutputFormat.ORM, ormStream); + ORMExtensionManager ormExtensionManager = new ORMExtensionManager(projectItemDocument, ormStream); + string[] ormExtensions = null; // Delay populated if a requires is made + // Null out bstrInputFileContents to prevent its usage beyond this point. bstrInputFileContents = null; @@ -572,8 +578,30 @@ Stream readonlyOutputStream = null; try { - ormGenerator.GenerateOutput(buildItem, outputStream, readonlyOutputFormatStreams, wszDefaultNamespace); - readonlyOutputStream = new ReadOnlyStream(outputStream); + // UNDONE: Extension checking should happen in the current generator + // going back to the generator that produced the input file. We're only + // extending ORM files right now, and the ORM file doesn't have a generator, + // so we just do it here. + bool extensionsSatisfied = true; + foreach (string extension in ormGenerator.GetRequiredExtensionsForInputFormat("ORM")) + { + if (null == ormExtensions) + { + ormExtensions = ormExtensionManager.GetLoadedExtensions(); + } + if (Array.BinarySearch<string>(ormExtensions, extension) < 0) + { + extensionsSatisfied = false; + // UNDONE: Localize error messages. + message = string.Format(CultureInfo.InvariantCulture, "The extension '{0}' in the '{1}' is required for generation of the '{2}' file. The existing contents of '{3}' will not be modified. Open the 'ORM Generator Selection' dialog and choose 'Save Changes' to automatically add required extensions.", extension, "ORM", ormGenerator.OfficialName, buildItem.FinalItemSpec); + report(message, ReportType.Error, null); + } + } + if (extensionsSatisfied) + { + ormGenerator.GenerateOutput(buildItem, outputStream, readonlyOutputFormatStreams, wszDefaultNamespace); + readonlyOutputStream = new ReadOnlyStream(outputStream); + } } catch (Exception ex) { Modified: trunk/Tools/ORMCustomTool/ORMCustomTool.csproj =================================================================== --- trunk/Tools/ORMCustomTool/ORMCustomTool.csproj 2007-09-10 23:11:55 UTC (rev 1123) +++ trunk/Tools/ORMCustomTool/ORMCustomTool.csproj 2007-09-10 23:46:57 UTC (rev 1124) @@ -74,6 +74,7 @@ <Reference Include="VSLangProj80, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> </ItemGroup> <ItemGroup> + <Compile Include="ORMExtensionManager.cs" /> <Compile Include="Extender.cs" /> <Compile Include="ExtenderProvider.cs" /> <Compile Include="UI\BranchBase.cs"> Added: trunk/Tools/ORMCustomTool/ORMExtensionManager.cs =================================================================== --- trunk/Tools/ORMCustomTool/ORMExtensionManager.cs (rev 0) +++ trunk/Tools/ORMCustomTool/ORMExtensionManager.cs 2007-09-10 23:46:57 UTC (rev 1124) @@ -0,0 +1,237 @@ +#region Common Public License Copyright Notice +/**************************************************************************\ +* Neumont Object-Role Modeling Architect for Visual Studio * +* * +* Copyright \xA9 Neumont University. All rights reserved. * +* * +* The use and distribution terms for this software are covered by the * +* Common Public License 1.0 (http://opensource.org/licenses/cpl) which * +* can be found in the file CPL.txt at the root of this distribution. * +* By using this software in any fashion, you are agreeing to be bound by * +* the terms of this license. * +* * +* You must not remove this notice, or any other, from this software. * +\**************************************************************************/ +#endregion + +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using Microsoft.VisualStudio.Shell; +using Microsoft.VisualStudio.Shell.Interop; +using System.Reflection; +using System.Xml; +using System.Windows.Forms; + +namespace Neumont.Tools.ORM.ORMCustomTool +{ + /// <summary> + /// Extensions are additional named requirements for a given document format. + /// The extensions are treated as required content within a document format. + /// UNDONE: In the longer run, individual generators will be asked to ensure that + /// a given set of extensions are present in a returned document. For now, we + /// are not treating the document retrieved from the ORM designer as a true generator, + /// so we're just hacking this in. + /// </summary> + internal class ORMExtensionManager + { + private string[] myLoadedExtensions; + private EnvDTE.Document myDocument; + private EnvDTE.ProjectItem myProjectItem; + private Stream myStream; + public ORMExtensionManager(EnvDTE.Document document, Stream stream) + { + myDocument = document; + myStream = stream; + } + public ORMExtensionManager(EnvDTE.ProjectItem projectItem) + { + myProjectItem = projectItem; + } + /// <summary> + /// Return a sorted array of loaded extensions + /// </summary> + public string[] GetLoadedExtensions() + { + string[] retVal = myLoadedExtensions; + if (retVal == null) + { + if (myDocument == null && myProjectItem != null) + { + myDocument = myProjectItem.Document; + } + + object documentExtensionManager; + MethodInfo methodInfo; + if (null != myDocument && + null != (documentExtensionManager = myDocument.Object("ORMExtensionManager")) && + null != (methodInfo = documentExtensionManager.GetType().GetMethod("GetLoadedExtensions", Type.EmptyTypes))) + { + retVal = methodInfo.Invoke(documentExtensionManager, null) as string[]; + myDocument = null; // No longer needed + } + Stream stream = null; + if (null == retVal) + { + // First used the passed in stream + stream = myStream; + + // Next use an open text document. Note that this will already have provided + // an extension manager if this is an open ORM designer + if (stream == null && myDocument != null) + { + EnvDTE.TextDocument textDoc = myDocument.Object("TextDocument") as EnvDTE.TextDocument; + if (textDoc != null) + { + // Note that the stream will be closed with the default reader settings of the XmlReader below + stream = new MemoryStream(Encoding.UTF8.GetBytes(textDoc.StartPoint.CreateEditPoint().GetText(textDoc.EndPoint)), false); + } + } + + // Try the file directly from the project item + if (stream == null && myProjectItem != null) + { + // Note that the stream will be closed with the default reader settings of the XmlReader below + stream = new FileStream(myProjectItem.get_FileNames(0), FileMode.Open); + } + } + if (stream != null) + { + myStream = null; // No longer needed + // Attempt to open the stream as an Xml file to + // get the required extensions from the Xml + string[] namespaces = null; + int namespaceCount = 0; + try + { + XmlReaderSettings readerSettings = new XmlReaderSettings(); + readerSettings.CloseInput = true; + using (XmlReader reader = XmlReader.Create(stream, readerSettings)) + { + reader.MoveToContent(); + if (reader.NodeType == XmlNodeType.Element) + { + int attributeCount = reader.AttributeCount; + if (attributeCount != 0) + { + namespaces = new string[attributeCount]; + if (reader.MoveToFirstAttribute()) + { + do + { + if (reader.Prefix == "xmlns" || reader.Name == "xmlns") + { + // Note that some of these are standard, not extensions, but it + // isn't worth the trouble to add extra ORM knowledge here to figure it out + string value = reader.Value; + if (!string.IsNullOrEmpty(value)) + { + namespaces[namespaceCount] = reader.Value; + ++namespaceCount; + } + } + } while (reader.MoveToNextAttribute()); + } + } + } + } + } + catch (XmlException) + { + // Nothing to do + } + if (namespaceCount != 0) + { + if (namespaceCount != namespaces.Length) + { + Array.Resize(ref namespaces, namespaceCount); + } + retVal = namespaces; + } + } + if (retVal == null) + { + retVal = new string[0]; + } + else + { + Array.Sort<string>(retVal); + } + myLoadedExtensions = retVal; + } + return retVal; + } + /// <summary> + /// Ensure that the current project item has the required extensions loaded. + /// This is only called after verifying that the current project item does + /// not satisfy the requirements. + /// </summary> + /// <param name="projectItem">The <see cref="EnvDTE.ProjectItem"/> to modify</param> + /// <param name="extensions">An <see cref="T:ICollection{System.String}"/> of additional required extensions</param> + public static bool EnsureExtensions(EnvDTE.ProjectItem projectItem, ICollection<string> extensions) + { + ServiceProvider provider = new ServiceProvider((Microsoft.VisualStudio.OLE.Interop.IServiceProvider)projectItem.DTE); + // UNDONE: Localize message strings in here + if ((int)DialogResult.No == VsShellUtilities.ShowMessageBox( + provider, + "Additional extensions are required to support the chosen generators. Would you like to load the required extensions now?", + "ORM Generator Selection", + OLEMSGICON.OLEMSGICON_QUERY, + OLEMSGBUTTON.OLEMSGBUTTON_YESNO, + OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST)) + { + return false; + } + EnvDTE.Document document = projectItem.Document; + bool secondPass = false; + bool tryDocument = true; + while (tryDocument) + { + object documentExtensionManager; + MethodInfo methodInfo; + if (null != document && + null != (documentExtensionManager = document.Object("ORMExtensionManager")) && + null != (methodInfo = documentExtensionManager.GetType().GetMethod("EnsureExtensions", new Type[] { typeof(string[]) }))) + { + string[] extensionsArray = new string[extensions.Count]; + extensions.CopyTo(extensionsArray, 0); + methodInfo.Invoke(documentExtensionManager, new object[] { extensionsArray }); + return true; + } + + if (secondPass) + { + return false; + } + tryDocument = false; + secondPass = true; + + // UNDONE: Localize message strings in here + if ((int)DialogResult.No == VsShellUtilities.ShowMessageBox( + provider, + "The .ORM file must be open in the default designer to add extensions. Would you like to open or reopen the document now?", + "ORM Generator Selection", + OLEMSGICON.OLEMSGICON_QUERY, + OLEMSGBUTTON.OLEMSGBUTTON_YESNO, + OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST)) + { + return false; + } + + if (document != null) + { + document.Close(EnvDTE.vsSaveChanges.vsSaveChangesPrompt); + document = projectItem.Document; + } + if (document == null) + { + projectItem.Open(Guid.Empty.ToString("B")).Visible = true; + document = projectItem.Document; + tryDocument = true; + } + } + return false; + } + } +} Modified: trunk/Tools/ORMCustomTool/UI/MainBranch.cs =================================================================== --- trunk/Tools/ORMCustomTool/UI/MainBranch.cs 2007-09-10 23:11:55 UTC (rev 1123) +++ trunk/Tools/ORMCustomTool/UI/MainBranch.cs 2007-09-10 23:46:57 UTC (rev 1124) @@ -69,6 +69,21 @@ } } + public IEnumerable<IORMGenerator> SelectedGenerators + { + get + { + foreach (OutputFormatBranch branch in _branches.Values) + { + IORMGenerator selectedGenerator = branch.SelectedORMGenerator; + if (selectedGenerator != null) + { + yield return selectedGenerator; + } + } + } + } + public bool IsPrimaryDisplayItem(int index) { OutputFormatBranch branch = _branches.Values[index]; Modified: trunk/Tools/ORMCustomTool/UI/ORMGeneratorSelectionControl.cs =================================================================== --- trunk/Tools/ORMCustomTool/UI/ORMGeneratorSelectionControl.cs 2007-09-10 23:11:55 UTC (rev 1123) +++ trunk/Tools/ORMCustomTool/UI/ORMGeneratorSelectionControl.cs 2007-09-10 23:46:57 UTC (rev 1124) @@ -206,6 +206,42 @@ { if (_savedChanges) { + // Make sure the current document has the necessary + // extensions loaded. + // UNDONE: We should be able to do this with the document + // closed or open as text as well via a registered service + // on the ORMDesignerPackage, but this is sufficient for now. + Dictionary<string, string> requiredExtensions = null; + string[] loadedExtensions = null; + foreach (IORMGenerator selectedGenerator in _mainBranch.SelectedGenerators) + { + foreach (string requiredExtension in selectedGenerator.GetRequiredExtensionsForInputFormat("ORM")) + { + if (loadedExtensions == null) + { + loadedExtensions = (new ORMExtensionManager(_projectItem)).GetLoadedExtensions(); + } + if (Array.BinarySearch<string>(loadedExtensions, requiredExtension) < 0) + { + if (requiredExtensions == null) + { + requiredExtensions = new Dictionary<string, string>(); + } + else if (requiredExtensions.ContainsKey(requiredExtension)) + { + continue; + } + requiredExtensions.Add(requiredExtension, requiredExtension); + } + } + } + if (requiredExtensions != null) + { + _savedChanges = ORMExtensionManager.EnsureExtensions(_projectItem, requiredExtensions.Values); + } + } + if (_savedChanges) + { // Delete the removed items from the project if (_removedItems != null) { Modified: trunk/Tools/ORMCustomTool/XslORMGenerator.cs =================================================================== --- trunk/Tools/ORMCustomTool/XslORMGenerator.cs 2007-09-10 23:11:55 UTC (rev 1123) +++ trunk/Tools/ORMCustomTool/XslORMGenerator.cs 2007-09-10 23:46:57 UTC (rev 1124) @@ -64,17 +64,27 @@ this._generatesSupportFile = Convert.ToBoolean((int)generatorKey.GetValue("GeneratesSupportFile", 0)); this._customTool = generatorKey.GetValue("CustomTool", null) as string; - string sourceInputFormat = this._sourceInputFormat = generatorKey.GetValue("SourceInputFormat", null) as string; + Dictionary<string, IEnumerable<string>> extensions = null; + string sourceInputFormat = generatorKey.GetValue("SourceInputFormat", null) as string; Debug.Assert(sourceInputFormat != null); - string[] referenceInputFormats = this._referenceInputFormats = generatorKey.GetValue("ReferenceInputFormats", EmptyStringArray) as string[]; + string[] referenceInputFormats = generatorKey.GetValue("ReferenceInputFormats", EmptyStringArray) as string[]; string[] prequisiteInputFormats = generatorKey.GetValue("PrequisiteInputFormats", EmptyStringArray) as string[]; List<string> requiresInputFormats; requiresInputFormats = new List<string>(referenceInputFormats.Length + prequisiteInputFormats.Length + 1); - requiresInputFormats.Add(sourceInputFormat); - requiresInputFormats.AddRange(referenceInputFormats); - requiresInputFormats.AddRange(prequisiteInputFormats); + requiresInputFormats.Add(sourceInputFormat = StripFormatExtensions(sourceInputFormat, ref extensions)); + for (int i = 0; i < referenceInputFormats.Length; ++i)... [truncated message content] |
From: <mcu...@us...> - 2007-09-12 00:21:42
|
Revision: 1127 http://orm.svn.sourceforge.net/orm/?rev=1127&view=rev Author: mcurland Date: 2007-09-11 17:21:45 -0700 (Tue, 11 Sep 2007) Log Message: ----------- We didn't end up doing a 2007-08 drop, switch to 2007-09. refs #193 Also changed Model Browser header to 'Relational Schema' from 'Relational Schemas' Modified Paths: -------------- trunk/RelationalModel/DcilModel/Catalog.resx trunk/VersionGenerator.exe.config Modified: trunk/RelationalModel/DcilModel/Catalog.resx =================================================================== --- trunk/RelationalModel/DcilModel/Catalog.resx 2007-09-12 00:17:14 UTC (rev 1126) +++ trunk/RelationalModel/DcilModel/Catalog.resx 2007-09-12 00:21:45 UTC (rev 1127) @@ -200,7 +200,7 @@ <value>Tables</value> </data> <data name="SurveySchemaType.Schema" xml:space="preserve"> - <value>Relational Schemas</value> + <value>Relational Schema</value> </data> <data name="SurveyTableChildType.Column" xml:space="preserve"> <value>Columns</value> Modified: trunk/VersionGenerator.exe.config =================================================================== --- trunk/VersionGenerator.exe.config 2007-09-12 00:17:14 UTC (rev 1126) +++ trunk/VersionGenerator.exe.config 2007-09-12 00:21:45 UTC (rev 1127) @@ -2,7 +2,7 @@ <configuration> <appSettings> <add key="RevisionStartYearMonth" value="2006-01"/> - <add key="ReleaseYearMonth" value="2007-08"/> + <add key="ReleaseYearMonth" value="2007-09"/> <!-- ReleaseType: "CTP" or "RTM" --> <add key="ReleaseType" value="CTP"/> <!-- Changes to the major and/or minor version numbers have extreme effects across every part of the product. --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mcu...@us...> - 2007-09-20 20:46:19
|
Revision: 1137 http://orm.svn.sourceforge.net/orm/?rev=1137&view=rev Author: mcurland Date: 2007-09-20 13:46:20 -0700 (Thu, 20 Sep 2007) Log Message: ----------- Do some additional work on the database importer. The import works fine for a DB with one schema, but does not allow tables from multiple schemas to be imported, which is a fundamental issue that will take some redesign. Also, our layout on import is not looking very good. Decline adding to setup for now until these issues are fixed. refs #305 Modified Paths: -------------- trunk/ORMModel/Shell/ORMGeneralTemplateWizard.cs trunk/ORMModel/Shell/PackageResources/PackageResources.cs trunk/ORMModel/Shell/PackageResources/VSPackage.resx trunk/Tools/DatabaseImport/Install.bat trunk/Tools/DatabaseImport/ORMDatabaseImportWizard.cs trunk/Tools/DatabaseImport/SqlServer2005DcilSchemaProvider.cs Added Paths: ----------- trunk/Tools/DatabaseImport/ProjectItems/ trunk/Tools/DatabaseImport/ProjectItems/CSharp.zip trunk/Tools/DatabaseImport/ProjectItems/General.zip trunk/Tools/DatabaseImport/ProjectItems/JSharp.zip trunk/Tools/DatabaseImport/ProjectItems/VisualBasic.zip trunk/Tools/DatabaseImport/ProjectItems/VisualC.zip trunk/Tools/DatabaseImport/ProjectItems/Web/ trunk/Tools/DatabaseImport/ProjectItems/Web/CSharp.zip trunk/Tools/DatabaseImport/ProjectItems/Web/JSharp.zip trunk/Tools/DatabaseImport/ProjectItems/Web/VisualBasic.zip Removed Paths: ------------- trunk/Tools/DatabaseImport/OrmDatabaseImportTemplate.zip Modified: trunk/ORMModel/Shell/ORMGeneralTemplateWizard.cs =================================================================== --- trunk/ORMModel/Shell/ORMGeneralTemplateWizard.cs 2007-09-20 20:41:26 UTC (rev 1136) +++ trunk/ORMModel/Shell/ORMGeneralTemplateWizard.cs 2007-09-20 20:46:20 UTC (rev 1137) @@ -37,6 +37,7 @@ // Given that we can't make a non-nested class 'private', 'internal' is at least better than 'public'. internal sealed class ORMGeneralTemplateWizard : IWizard { + // This code is duplicated in Tools/DatabaseImport/ORMDatabaseImportWizard.cs (ORMDatabaseImportGeneralProjectWizard class) private static bool? TemplateWizardIsOrcasOrLater; /// <summary> Modified: trunk/ORMModel/Shell/PackageResources/PackageResources.cs =================================================================== --- trunk/ORMModel/Shell/PackageResources/PackageResources.cs 2007-09-20 20:41:26 UTC (rev 1136) +++ trunk/ORMModel/Shell/PackageResources/PackageResources.cs 2007-09-20 20:46:20 UTC (rev 1137) @@ -21,6 +21,11 @@ public const int AboutBoxIcon = 110; public const int ORMFileIcon = 111; + // Favor for the DatabaseImport project, the resources + // need to be in a package. + // public const int ORMFileDBImportDisplayName = 112; + // public const int ORMFileDBImportDescription = 113; + public const int ToolWindowIcons = 125; public const int PackageLoadKey = 150; Modified: trunk/ORMModel/Shell/PackageResources/VSPackage.resx =================================================================== --- trunk/ORMModel/Shell/PackageResources/VSPackage.resx 2007-09-20 20:41:26 UTC (rev 1136) +++ trunk/ORMModel/Shell/PackageResources/VSPackage.resx 2007-09-20 20:46:20 UTC (rev 1137) @@ -106,6 +106,14 @@ <value>../../Resources/ORM.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <comment>PackageResources.Id.ORMFileIcon</comment> </data> + <data name="112"> + <value>Object-Role Modeling (DB Import)</value> + <comment>PackageResources.Id.ORMFileDBImportDisplayName</comment> + </data> + <data name="113"> + <value>Object-Role Modeling File for Neumont ORM Architect (Reverse Engineer from Database)</value> + <comment>PackageResources.Id.ORMFileDBImportDescription</comment> + </data> <data name="125" type="System.Resources.ResXFileRef, System.Windows.Forms"> <value>../../Resources/ToolWindowIcons.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <comment>PackageResources.Id.ToolWindowIcons and IDB_TOOLWINDOWICONS</comment> Modified: trunk/Tools/DatabaseImport/Install.bat =================================================================== --- trunk/Tools/DatabaseImport/Install.bat 2007-09-20 20:41:26 UTC (rev 1136) +++ trunk/Tools/DatabaseImport/Install.bat 2007-09-20 20:46:20 UTC (rev 1137) @@ -3,4 +3,5 @@ SET RootDir=%~dp0. CALL "%RootDir%\..\..\SetupEnvironment.bat" %* -XCOPY /Y /D /V /Q "%RootDir%\OrmDatabaseImportTemplate.zip" "%VSItemTemplatesDir%\CSharp\" +FOR %%A IN ("%RootDir%\ProjectItems\*.zip") DO ECHO F | XCOPY /Y /D /V /Q "%%~fA" "%VSItemTemplatesDir%\%%~nA\ORMModelFromDatabase.zip" +FOR %%A IN ("%RootDir%\ProjectItems\Web\*.zip") DO ECHO F | XCOPY /Y /D /V /Q "%%~fA" "%VSItemTemplatesDir%\Web\%%~nA\ORMModelFromDatabase.zip" Modified: trunk/Tools/DatabaseImport/ORMDatabaseImportWizard.cs =================================================================== --- trunk/Tools/DatabaseImport/ORMDatabaseImportWizard.cs 2007-09-20 20:41:26 UTC (rev 1136) +++ trunk/Tools/DatabaseImport/ORMDatabaseImportWizard.cs 2007-09-20 20:46:20 UTC (rev 1137) @@ -3,6 +3,7 @@ using System.Data; using System.Diagnostics; using System.Text; +using Microsoft.VisualStudio; using Microsoft.VisualStudio.TemplateWizard; using Microsoft.VisualStudio.Data; using Microsoft.VisualStudio.Shell; @@ -20,28 +21,56 @@ /// <summary> /// Wizard interface used when loading a DcilREFromDB template /// </summary> + [CLSCompliant(false)] + [TemplateWizardDisallowUserTemplatesSecurity(true)] public class ORMDatabaseImportWizard : IWizard { #region Member variables - private bool myAddToProject = true; + private bool myAddToProject = false; #endregion // Member variables #region IWizard Members + /// <summary> + /// Implements <see cref="IWizard.BeforeOpeningFile"/> + /// </summary> + protected void BeforeOpeningFile(EnvDTE.ProjectItem projectItem) + { + } void IWizard.BeforeOpeningFile(EnvDTE.ProjectItem projectItem) { + BeforeOpeningFile(projectItem); } + /// <summary> + /// Implements <see cref="IWizard.ProjectFinishedGenerating"/> + /// </summary> + protected void ProjectFinishedGenerating(EnvDTE.Project project) + { + } void IWizard.ProjectFinishedGenerating(EnvDTE.Project project) { + ProjectFinishedGenerating(project); } + /// <summary> + /// Implements <see cref="IWizard.ProjectItemFinishedGenerating"/> + /// </summary> + protected void ProjectItemFinishedGenerating(EnvDTE.ProjectItem projectItem) + { + } void IWizard.ProjectItemFinishedGenerating(EnvDTE.ProjectItem projectItem) { - + ProjectItemFinishedGenerating(projectItem); + } + /// <summary> + /// Implements <see cref="IWizard.RunFinished"/> + /// </summary> + protected void RunFinished() + { } - void IWizard.RunFinished() { + RunFinished(); } /// <summary> @@ -55,7 +84,10 @@ return ((provider != null) ? provider.GetService(serviceType) as T : null) ?? Package.GetGlobalService(serviceType) as T; } - void IWizard.RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) + /// <summary> + /// Implements <see cref="IWizard.RunStarted"/> + /// </summary> + protected void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { IOleServiceProvider oleServiceProvider = automationObject as IOleServiceProvider; ServiceProvider serviceProvider = (oleServiceProvider != null) ? new ServiceProvider(oleServiceProvider) : null; @@ -120,14 +152,189 @@ replacementsDictionary.Add("$DcilFile$", replacementString); } } - } + myAddToProject = true; + } } + void IWizard.RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) + { + RunStarted(automationObject, replacementsDictionary, runKind, customParams); + } - bool IWizard.ShouldAddProjectItem(string filePath) + /// <summary> + /// Implements <see cref="IWizard.ShouldAddProjectItem"/> + /// </summary> + protected bool ShouldAddProjectItem(string filePath) { return myAddToProject; } - + bool IWizard.ShouldAddProjectItem(string filePath) + { + return ShouldAddProjectItem(filePath); + } #endregion } + // Following code is lifted directly from ORMModel/Shell/ORMGeneralTemplateWizard.cs + + /// <summary> + /// Works around Visual Studio bugs in order to allow <c>.vstemplate</c> files + /// to be used for the "<c>General</c>" <c>ProjectType</c>. + /// </summary> + [CLSCompliant(false)] + public class ORMDatabaseImportGeneralProjectWizard : ORMDatabaseImportWizard, IWizard + { + private static bool? TemplateWizardIsOrcasOrLater; + + /// <summary> + /// Prevents the pre-Orcas version of <c>Microsoft.VisualStudio.TemplateWizard.Wizard</c> from crashing in <c>OpenNotedItems</c>. + /// </summary> + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + protected new void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) + { + base.RunStarted(automationObject, replacementsDictionary, runKind, customParams); + if (!base.ShouldAddProjectItem(null)) + { + return; + } + const int OrcasMajorVersionNumber = 9; + const string TemplateWizardAssemblyName = "Microsoft.VisualStudio.TemplateWizard"; + const string SuppressOpeningItems = "$__suppress_opening_items__$"; + + bool? templateWizardIsOrcasOrLater = TemplateWizardIsOrcasOrLater; + + // If we haven't yet determined whether we are being called by the pre-Orcas version of TemplateWizard or not, do so now. + if (!templateWizardIsOrcasOrLater.HasValue) + { + System.Reflection.Assembly callingAssembly = System.Reflection.Assembly.GetCallingAssembly(); + + // UNDONE: This is asserting at this point, figure out how to determine if we're Whidbey or Orcas + //Debug.Assert(callingAssembly != null && callingAssembly.FullName.StartsWith(TemplateWizardAssemblyName, StringComparison.Ordinal)); + + // If for any reason we can't tell what version we're running under, we assume it is pre-Orcas. + templateWizardIsOrcasOrLater = TemplateWizardIsOrcasOrLater = + (callingAssembly != null && (callingAssembly.GetName().Version.Major >= OrcasMajorVersionNumber)); + } + + if (templateWizardIsOrcasOrLater.GetValueOrDefault()) + { + // The Orcas version of TemplateWizard correctly checks Project.FullName for null / empty string before + // trying to create a Uri from it. Therefore, this workaround is only needed for pre-Orcas versions. + return; + } + + Debug.Assert(runKind == WizardRunKind.AsNewItem); + + if (replacementsDictionary == null) + { + // If we don't have a replacements dictionary, we can't do anything anyway, so just bail out. + return; + } + + if (!replacementsDictionary.ContainsKey(SuppressOpeningItems)) + { + // The value that we add doesn't really matter (only the key does), + // but just in case they start doing anything with it, we'll use "true". + replacementsDictionary.Add(SuppressOpeningItems, "true"); + } + } + void IWizard.RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) + { + RunStarted(automationObject, replacementsDictionary, runKind, customParams); + } + + /// <summary> + /// Ensures that only the file name portion of the new <see cref="ProjectItem"/>'s path is used as the + /// title for the document window. + /// </summary> + protected new void ProjectItemFinishedGenerating(ProjectItem projectItem) + { + base.ProjectItemFinishedGenerating(projectItem); + + // UNDONE: This may or may not be needed for Orcas. This needs to be tested, and if it is not needed, + // the following code block should be uncommented. + //Debug.Assert(TemplateWizardIsOrcasOrLater.HasValue, "RunStarted should have been called before ProjectItemFinishedGenerating is called."); + //if (TemplateWizardIsOrcasOrLater.GetValueOrDefault()) + //{ + // return; + //} + + if (projectItem == null) + { + throw new ArgumentNullException("projectItem"); + } + + DTE application = projectItem.DTE; + if (application == null) + { + // If we can't get the DTE, just bail out. + return; + } + + Document document = projectItem.Document; + if (document == null) + { + // At the point this is called, the ProjectItem seems to not have the Document associated with it yet. + // In that case, we need to look through the documents to find it. We'll try ActiveDocument first... + document = application.ActiveDocument; + if (document.ProjectItem != projectItem) + { + document = null; + Documents documents = application.Documents; + if (documents != null) + { + foreach (Document potentialDocument in documents) + { + if (potentialDocument.ProjectItem == projectItem) + { + document = potentialDocument; + break; + } + } + } + } + } + + if (document != null) + { + IOleServiceProvider oleServiceProvider = application as IOleServiceProvider; + if (oleServiceProvider == null) + { + // If we can't get an IOleServiceProvider, just bail out. + return; + } + + IVsUIHierarchy uiHierarchy; + uint itemId; + IVsWindowFrame windowFrame; + bool documentIsOpen = VsShellUtilities.IsDocumentOpen(new ServiceProvider(oleServiceProvider), document.FullName, Guid.Empty, out uiHierarchy, out itemId, out windowFrame); + Debug.Assert(documentIsOpen); + + if (windowFrame != null) + { + object pVar; + ErrorHandler.ThrowOnFailure(uiHierarchy.GetProperty(itemId, (int)__VSHPROPID.VSHPROPID_Caption, out pVar)); + string caption = pVar as string; + if (!string.IsNullOrEmpty(caption)) + { + try + { + caption = Path.GetFileName(caption); + } + catch (ArgumentException) + { + // Ignore any ArgumentException (which can occur if the caption contains characters invalid in a path). + return; + } + // Set the new caption on the backend document. + ErrorHandler.ThrowOnFailure(uiHierarchy.SetProperty(itemId, (int)__VSHPROPID.VSHPROPID_Caption, caption)); + // Set the new caption on the window. + ErrorHandler.ThrowOnFailure(windowFrame.SetProperty((int)__VSFPROPID.VSFPROPID_OwnerCaption, caption)); + } + } + } + } + void IWizard.ProjectItemFinishedGenerating(ProjectItem projectItem) + { + ProjectItemFinishedGenerating(projectItem); + } + } } Deleted: trunk/Tools/DatabaseImport/OrmDatabaseImportTemplate.zip =================================================================== (Binary files differ) Added: trunk/Tools/DatabaseImport/ProjectItems/CSharp.zip =================================================================== (Binary files differ) Property changes on: trunk/Tools/DatabaseImport/ProjectItems/CSharp.zip ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/Tools/DatabaseImport/ProjectItems/General.zip =================================================================== (Binary files differ) Property changes on: trunk/Tools/DatabaseImport/ProjectItems/General.zip ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/Tools/DatabaseImport/ProjectItems/JSharp.zip =================================================================== (Binary files differ) Property changes on: trunk/Tools/DatabaseImport/ProjectItems/JSharp.zip ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/Tools/DatabaseImport/ProjectItems/VisualBasic.zip =================================================================== (Binary files differ) Property changes on: trunk/Tools/DatabaseImport/ProjectItems/VisualBasic.zip ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/Tools/DatabaseImport/ProjectItems/VisualC.zip =================================================================== (Binary files differ) Property changes on: trunk/Tools/DatabaseImport/ProjectItems/VisualC.zip ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/Tools/DatabaseImport/ProjectItems/Web/CSharp.zip =================================================================== (Binary files differ) Property changes on: trunk/Tools/DatabaseImport/ProjectItems/Web/CSharp.zip ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/Tools/DatabaseImport/ProjectItems/Web/JSharp.zip =================================================================== (Binary files differ) Property changes on: trunk/Tools/DatabaseImport/ProjectItems/Web/JSharp.zip ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/Tools/DatabaseImport/ProjectItems/Web/VisualBasic.zip =================================================================== (Binary files differ) Property changes on: trunk/Tools/DatabaseImport/ProjectItems/Web/VisualBasic.zip ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/Tools/DatabaseImport/SqlServer2005DcilSchemaProvider.cs =================================================================== --- trunk/Tools/DatabaseImport/SqlServer2005DcilSchemaProvider.cs 2007-09-20 20:41:26 UTC (rev 1136) +++ trunk/Tools/DatabaseImport/SqlServer2005DcilSchemaProvider.cs 2007-09-20 20:46:20 UTC (rev 1137) @@ -143,15 +143,12 @@ _conn.Open(); IDbCommand cmd = _conn.CreateCommand(); cmd.CommandType = CommandType.Text; - string commandText = "SELECT COLUMN_NAME, IS_NULLABLE, COLUMNPROPERTY(OBJECT_ID(TABLE_NAME), COLUMN_NAME, 'IsIdentity') IS_IDENTITY, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, COALESCE(NUMERIC_PRECISION, DATETIME_PRECISION), NUMERIC_SCALE FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME IS NOT NULL"; - if (!String.IsNullOrEmpty(schemaName)) - { - commandText += " AND TABLE_SCHEMA = '" + schemaName + "'"; - } - if (!String.IsNullOrEmpty(tableName)) - { - commandText += " AND TABLE_NAME = '" + tableName + "'"; - } + bool haveSchema = !string.IsNullOrEmpty(schemaName); + string commandText = "SELECT COLUMN_NAME, IS_NULLABLE, COLUMNPROPERTY(OBJECT_ID(" + + (haveSchema ? "TABLE_SCHEMA + '.' + " : "") + + "TABLE_NAME), COLUMN_NAME, 'IsIdentity') IS_IDENTITY, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, COALESCE(NUMERIC_PRECISION, DATETIME_PRECISION), NUMERIC_SCALE FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME IS NOT NULL" + + (haveSchema ? " AND TABLE_SCHEMA = '" + schemaName + "'" : "") + + " AND TABLE_NAME = '" + tableName + "'"; cmd.CommandText = commandText; using (IDataReader reader = cmd.ExecuteReader(CommandBehavior.Default)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mcu...@us...> - 2007-09-20 20:48:20
|
Revision: 1138 http://orm.svn.sourceforge.net/orm/?rev=1138&view=rev Author: mcurland Date: 2007-09-20 13:48:24 -0700 (Thu, 20 Sep 2007) Log Message: ----------- Block property descriptor changes on model-browser selected roles of unary fact types. refs #296 Fixed warning introduced in [1137]. refs #305 Modified Paths: -------------- trunk/ORMModel/ObjectModel/Design/RoleTypeDescriptor.cs trunk/Tools/DatabaseImport/ORMDatabaseImportWizard.cs Modified: trunk/ORMModel/ObjectModel/Design/RoleTypeDescriptor.cs =================================================================== --- trunk/ORMModel/ObjectModel/Design/RoleTypeDescriptor.cs 2007-09-20 20:46:20 UTC (rev 1137) +++ trunk/ORMModel/ObjectModel/Design/RoleTypeDescriptor.cs 2007-09-20 20:48:24 UTC (rev 1138) @@ -75,10 +75,24 @@ /// </summary> protected override bool IsPropertyDescriptorReadOnly(ElementPropertyDescriptor propertyDescriptor) { - if (propertyDescriptor.DomainPropertyInfo.Id == Role.ValueRangeTextDomainPropertyId) + Guid propertyId = propertyDescriptor.DomainPropertyInfo.Id; + if (propertyId == Role.ValueRangeTextDomainPropertyId) { return !ModelElement.IsValueRole; } + else if (propertyId == Role.IsMandatoryDomainPropertyId || + propertyId == Role.RolePlayerDisplayDomainPropertyId || + propertyId == Role.MandatoryConstraintModalityDomainPropertyId || + propertyId == Role.MultiplicityDomainPropertyId) + { + Role role = ModelElement; + if (role is SubtypeMetaRole || + role is SupertypeMetaRole || + null != role.FactType.UnaryRole) + { + return true; + } + } return base.IsPropertyDescriptorReadOnly(propertyDescriptor); } } Modified: trunk/Tools/DatabaseImport/ORMDatabaseImportWizard.cs =================================================================== --- trunk/Tools/DatabaseImport/ORMDatabaseImportWizard.cs 2007-09-20 20:46:20 UTC (rev 1137) +++ trunk/Tools/DatabaseImport/ORMDatabaseImportWizard.cs 2007-09-20 20:48:24 UTC (rev 1138) @@ -196,7 +196,7 @@ return; } const int OrcasMajorVersionNumber = 9; - const string TemplateWizardAssemblyName = "Microsoft.VisualStudio.TemplateWizard"; + // UNDONE: See assert where this is used const string TemplateWizardAssemblyName = "Microsoft.VisualStudio.TemplateWizard"; const string SuppressOpeningItems = "$__suppress_opening_items__$"; bool? templateWizardIsOrcasOrLater = TemplateWizardIsOrcasOrLater; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mcu...@us...> - 2007-10-15 06:33:07
|
Revision: 1153 http://orm.svn.sourceforge.net/orm/?rev=1153&view=rev Author: mcurland Date: 2007-10-14 23:33:06 -0700 (Sun, 14 Oct 2007) Log Message: ----------- Added DatabaseImport to build batch files. refs #305 Added additional build options. refs #337 Modified Paths: -------------- trunk/Main.proj trunk/TestSuites/TestSample/TestSample.csproj trunk/Tools/DatabaseImport/DatabaseImport.csproj Added Paths: ----------- trunk/BuildAll.bat trunk/BuildReadme.txt trunk/FirstTimeBuildAll.bat trunk/Setup/ReadMe.txt Added: trunk/BuildAll.bat =================================================================== --- trunk/BuildAll.bat (rev 0) +++ trunk/BuildAll.bat 2007-10-15 06:33:06 UTC (rev 1153) @@ -0,0 +1,9 @@ +@ECHO OFF +SETLOCAL +SET RootDir=%~dp0. +CALL "%RootDir%\SetupEnvironment.bat" %* + +MSBuild.exe /nologo "%RootDir%\Setup.proj" %* +MSBuild.exe /nologo "%RootDir%\Tests.proj" %* + +GOTO:EOF Added: trunk/BuildReadme.txt =================================================================== --- trunk/BuildReadme.txt (rev 0) +++ trunk/BuildReadme.txt 2007-10-15 06:33:06 UTC (rev 1153) @@ -0,0 +1,20 @@ +The build is broken into several pieces to support multiple Visual Studio targeted versions and parts of the project. + +The batch files perform as follows: +1) Build.bat builds all of the NORMA tools and extension projects. The test build helper, libary, and setup pieces are not built. + +2) BuildDevTools.bat builds the (relatively static) NUBuild MSBuild extensions and DSLTools directive processors. CalFled by FirstTimeBuild.bat + +3) FirstTimeBuild.bat should be run the first time the tool is used in a development environment. Does not do test or setup. + +4) BuildTests.bat builds testing tools and samples. Requires XML Diff Patch and nunit2.2.9 installation as discussed in README.txt in this directory. + +5) BuildSetup.bat builds everything included in setup. Requires install of WIX 3.0 as discussed in the README.txt file. + +6) BuildAll.bat builds everything except the development tools + +7) FirstTimeBuildAll.bat builds everything including the development tools + +To build for an Visual Studio 2008 (Orcas) version: +Before running, set the following environment variable: +set TargetVisualStudioVersion=v9.0 Added: trunk/FirstTimeBuildAll.bat =================================================================== --- trunk/FirstTimeBuildAll.bat (rev 0) +++ trunk/FirstTimeBuildAll.bat 2007-10-15 06:33:06 UTC (rev 1153) @@ -0,0 +1,14 @@ +@ECHO OFF +SETLOCAL +SET RootDir=%~dp0. +CALL "%RootDir%\SetupEnvironment.bat" %* + +CALL "%RootDir%\BuildDevTools.bat" %* +CALL "%RootDir%\BuildSetup.bat" %* +CALL "%RootDir%\BuildTests.bat" %* + +ECHO. +ECHO Running 'devenv.exe /RootSuffix "%VSRegistryRootSuffix%" /Setup'... This may take a few minutes... +"%VSEnvironmentPath%" /RootSuffix "%VSRegistryRootSuffix%" /Setup + +GOTO:EOF Modified: trunk/Main.proj =================================================================== --- trunk/Main.proj 2007-10-15 06:29:06 UTC (rev 1152) +++ trunk/Main.proj 2007-10-15 06:33:06 UTC (rev 1153) @@ -9,6 +9,7 @@ <ProjectReference Include="RelationalModel\Dil.sln"/> <ProjectReference Include="CustomProperties\CustomProperties.sln"/> <ProjectReference Include="Tools\ORMCustomTool\ORMCustomTool.sln"/> + <ProjectReference Include="Tools\DatabaseImport\DatabaseImport.sln"/> </ItemGroup> <Import Project="Default.targets"/> </Project> \ No newline at end of file Added: trunk/Setup/ReadMe.txt =================================================================== --- trunk/Setup/ReadMe.txt (rev 0) +++ trunk/Setup/ReadMe.txt 2007-10-15 06:33:06 UTC (rev 1153) @@ -0,0 +1 @@ +See ..\README.txt for information on the WIX version required to build this project. \ No newline at end of file Modified: trunk/TestSuites/TestSample/TestSample.csproj =================================================================== --- trunk/TestSuites/TestSample/TestSample.csproj 2007-10-15 06:29:06 UTC (rev 1152) +++ trunk/TestSuites/TestSample/TestSample.csproj 2007-10-15 06:33:06 UTC (rev 1153) @@ -11,6 +11,7 @@ <AssemblyName>TestSample</AssemblyName> <SignAssembly>true</SignAssembly> <AssemblyOriginatorKeyFile>..\..\ORMPackage.snk</AssemblyOriginatorKeyFile> + <DisableAllPreprocessing>true</DisableAllPreprocessing> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> Modified: trunk/Tools/DatabaseImport/DatabaseImport.csproj =================================================================== --- trunk/Tools/DatabaseImport/DatabaseImport.csproj 2007-10-15 06:29:06 UTC (rev 1152) +++ trunk/Tools/DatabaseImport/DatabaseImport.csproj 2007-10-15 06:33:06 UTC (rev 1153) @@ -14,6 +14,7 @@ <AssemblyOriginatorKeyFile>..\..\ORMPackage.snk</AssemblyOriginatorKeyFile> <RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent> <InstallInGac>true</InstallInGac> + <TrunkDir Condition=" '$(TrunkDir)' == '' ">$(MSBuildProjectDirectory)\..\..</TrunkDir> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> @@ -36,18 +37,19 @@ <NoWarn>1607</NoWarn> <UseVSHostingProcess>false</UseVSHostingProcess> </PropertyGroup> + <Import Project="$(MSBuildExtensionsPath)\Neumont\VisualStudio\Neumont.Build.VisualStudio.Multitargeting.targets" /> <ItemGroup> <Reference Include="EnvDTE, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <SpecificVersion>False</SpecificVersion> </Reference> - <Reference Include="Microsoft.VisualStudio.Data, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> - <SpecificVersion>False</SpecificVersion> + <Reference Include="Microsoft.VisualStudio.Data, Version=$(TargetVisualStudioAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> <Private>False</Private> </Reference> <Reference Include="Microsoft.VisualStudio.OLE.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <SpecificVersion>False</SpecificVersion> </Reference> - <Reference Include="Microsoft.VisualStudio.Shell, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> + <!-- As of Visual Studio 2008 Beta 2, Microsoft.VisualStudio.Shell.9.0 is still versioned as 2.0.0.0. --> + <Reference Include="Microsoft.VisualStudio.Shell$(TargetVisualStudioFrameworkAssemblySuffix), Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> </Reference> <Reference Include="Microsoft.VisualStudio.Shell.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> @@ -97,7 +99,7 @@ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildExtensionsPath)\Neumont\Neumont.Build.targets" /> <PropertyGroup> - <PostBuildEvent>"$(SolutionDir)Install.bat" "$(OutputPath)"</PostBuildEvent> - <PreBuildEvent>"$(SolutionDir)..\..\VersionGenerator.exe"</PreBuildEvent> + <PreBuildEvent>"$(TrunkDir)\VersionGenerator.exe"</PreBuildEvent> + <PostBuildEvent>"$(MSBuildProjectDirectory)\Install.bat" "$(OutputPath)"</PostBuildEvent> </PropertyGroup> </Project> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mcu...@us...> - 2007-10-15 06:35:04
|
Revision: 1154 http://orm.svn.sourceforge.net/orm/?rev=1154&view=rev Author: mcurland Date: 2007-10-14 23:35:07 -0700 (Sun, 14 Oct 2007) Log Message: ----------- Switch xsl:variable to xsl:param in OIALtoORM.xslt. Fixes error from [1152]. refs #305 Modified Paths: -------------- trunk/BuildReadme.txt trunk/ORMModel/Shell/Converters/OIALtoORM.xslt trunk/README.txt Modified: trunk/BuildReadme.txt =================================================================== --- trunk/BuildReadme.txt 2007-10-15 06:33:06 UTC (rev 1153) +++ trunk/BuildReadme.txt 2007-10-15 06:35:07 UTC (rev 1154) @@ -3,13 +3,13 @@ The batch files perform as follows: 1) Build.bat builds all of the NORMA tools and extension projects. The test build helper, libary, and setup pieces are not built. -2) BuildDevTools.bat builds the (relatively static) NUBuild MSBuild extensions and DSLTools directive processors. CalFled by FirstTimeBuild.bat +2) BuildDevTools.bat builds the (relatively static) NUBuild MSBuild extensions and DSLTools directive processors. Called by FirstTimeBuild.bat 3) FirstTimeBuild.bat should be run the first time the tool is used in a development environment. Does not do test or setup. 4) BuildTests.bat builds testing tools and samples. Requires XML Diff Patch and nunit2.2.9 installation as discussed in README.txt in this directory. -5) BuildSetup.bat builds everything included in setup. Requires install of WIX 3.0 as discussed in the README.txt file. +5) BuildSetup.bat builds everything included in setup. Requires install of WIX 3 as discussed in the README.txt file. 6) BuildAll.bat builds everything except the development tools Modified: trunk/ORMModel/Shell/Converters/OIALtoORM.xslt =================================================================== --- trunk/ORMModel/Shell/Converters/OIALtoORM.xslt 2007-10-15 06:33:06 UTC (rev 1153) +++ trunk/ORMModel/Shell/Converters/OIALtoORM.xslt 2007-10-15 06:35:07 UTC (rev 1154) @@ -19,7 +19,7 @@ xmlns:oil="http://schemas.orm.net/OIAL" extension-element-prefixes="exsl" exclude-result-prefixes="odt oil"> - <xsl:variable name="RequireReadingModification" select="false()"/> + <xsl:param name="RequireReadingModification" select="false()"/> <xsl:output method="xml" encoding="utf-8" media-type="text/xml" indent="no"/> <xsl:template match="oil:model"> <xsl:variable name="dirtyOrmIdsFragment"> Modified: trunk/README.txt =================================================================== --- trunk/README.txt 2007-10-15 06:33:06 UTC (rev 1153) +++ trunk/README.txt 2007-10-15 06:35:07 UTC (rev 1154) @@ -19,7 +19,7 @@ Additional components used by other portions of this software include: Windows Installer XML (WiX) toolset - Homepage: http://wix.sourceforge.net + Homepage: http://wix.sourceforge.net (use version 3) Microsoft XML Diff and Patch 1.0 Homepage: http://apps.gotdotnet.com/xmltools/xmldiff This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mcu...@us...> - 2007-10-15 06:49:36
|
Revision: 1157 http://orm.svn.sourceforge.net/orm/?rev=1157&view=rev Author: mcurland Date: 2007-10-14 23:49:40 -0700 (Sun, 14 Oct 2007) Log Message: ----------- Pull hyphens from collapsed predicate text and added notes on better future name generation implementations. refs #338 Updated version to 2007-10 CTP. refs #193 Modified Paths: -------------- trunk/RelationalModel/OialDcilBridge/NameGeneration.cs trunk/VersionGenerator.exe.config Modified: trunk/RelationalModel/OialDcilBridge/NameGeneration.cs =================================================================== --- trunk/RelationalModel/OialDcilBridge/NameGeneration.cs 2007-10-15 06:48:28 UTC (rev 1156) +++ trunk/RelationalModel/OialDcilBridge/NameGeneration.cs 2007-10-15 06:49:40 UTC (rev 1157) @@ -55,13 +55,22 @@ private static class NameGeneration { #region GenerateAllNames method - private static IDatabaseNameGenerator nameGenerator; - public static void GenerateAllNames(Schema schema) + private static IDatabaseNameGenerator myNameGenerator; + private static IDatabaseNameGenerator NameGenerator { - if (null == nameGenerator) + get { - nameGenerator = new DefaultDatabaseNameGenerator(); + IDatabaseNameGenerator retVal = myNameGenerator; + if (null == retVal) + { + myNameGenerator = retVal = new DefaultDatabaseNameGenerator(); + } + return retVal; } + } + public static void GenerateAllNames(Schema schema) + { + IDatabaseNameGenerator nameGenerator = NameGenerator; UniqueNameGenerator uniqueChecker = new UniqueNameGenerator(); LinkedElementCollection<Table> tables = schema.TableCollection; @@ -571,6 +580,22 @@ if (createRoleName && !createRoleNameSecond) { //generate a role name from the predicate text and prepend it + + // UNDONE: Matt Curland (Oct 13, 2007) + // The predicate text can be used to generate a much better name + // than just prepending it. There are several things to consider here. + // This is not a spec, just things we should look at. + // 1) If we do generate a role name that ends up being unique, then there + // really is no reason to use the role player name at all if we use a reading + // that ends with the opposite role. + // 2) The generated text here should use the opposite role as a predicate + // replacement if it starts the format string and the near role ends the format + // string. In other words, we prefer to find a reading that is the forward reading + // for the near role, but we need to respect the order if we don't find it. + // 3) The 'longerThan' approach may be too simplistic. We may look at other ways + // to track 'refinement level' that allows us to know what we have tried already + // and to jump immediately to other alternatives. Refinements are not necessary longer. + AddToNameCollection(ref singleName, ref nameCollection, GetRoleNameFromPredicateText(mainFactType, towardsRole, oppositeRole, isUnary, columnSpace), 0); @@ -939,8 +964,8 @@ //get rid of string replace fields string text = myReplaceFieldsPattern.Replace(reading.Text, " "); text = " " + CultureInfo.CurrentCulture.TextInfo.ToLower(text) + " "; - //remove articles - text = text.Replace(" a ", " ").Replace(" an ", " ").Replace(" the ", " "); + //remove articles and hyphens + text = text.Replace(" a ", " ").Replace(" an ", " ").Replace(" the ", " ").Replace("- ", " ").Replace(" -", " "); if (!isUnary && text.Trim() != "has") { text = text.Replace(" has ", " "); Modified: trunk/VersionGenerator.exe.config =================================================================== --- trunk/VersionGenerator.exe.config 2007-10-15 06:48:28 UTC (rev 1156) +++ trunk/VersionGenerator.exe.config 2007-10-15 06:49:40 UTC (rev 1157) @@ -2,7 +2,7 @@ <configuration> <appSettings> <add key="RevisionStartYearMonth" value="2006-01"/> - <add key="ReleaseYearMonth" value="2007-09"/> + <add key="ReleaseYearMonth" value="2007-10"/> <!-- ReleaseType: "CTP" or "RTM" --> <add key="ReleaseType" value="CTP"/> <!-- Changes to the major and/or minor version numbers have extreme effects across every part of the product. --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |