コード例 #1
0
 private void btnGenerate_Click(object sender, EventArgs e)
 {
     if (Directory.Exists(txtOutputDirectory.Text))
     {
         VerbalizationReportContent           reportContent = 0;
         CheckedListBox.CheckedItemCollection checkedItems  = chkLbOptions.CheckedItems;
         int itemCount = checkedItems.Count;
         for (int i = 0; i < itemCount; ++i)
         {
             reportContent |= (VerbalizationReportContent)checkedItems[i];
         }
         ObjectModel.Verbalization.VerbalizationReportGenerator.GenerateReport(myModel, reportContent, txtOutputDirectory.Text);
         System.Diagnostics.Process.Start(txtOutputDirectory.Text);
         DialogResult = DialogResult.OK;
     }
     else
     {
         DialogResult = DialogResult.None;
     }
 }
コード例 #2
0
ファイル: VerbalizationReport.cs プロジェクト: cjheath/NORMA
			/// <summary>
			/// Initializes a new instance of ObjectTypePageReport
			/// </summary>
			public ObjectTypePageReport(ObjectType objectType, VerbalizationReportContent reportContent, IVerbalizationSets<ReportVerbalizationSnippetType> snippets)
			{
				myObjectType = objectType;
				myReportContent = reportContent;
				mySnippets = snippets;
			}
コード例 #3
0
ファイル: VerbalizationReport.cs プロジェクト: cjheath/NORMA
			/// <summary>
			/// Initializes a new instance of ObjectTypeListReport
			/// </summary>
			/// <param name="model">The model for the report</param>
			/// <param name="objectTypeList">The object type list.</param>
			/// <param name="snippets">The snippets.</param>
			/// <param name="headerSnippet">The header snippet.</param>
			/// <param name="footerSnippet">The footer snippet.</param>
			/// <param name="reportContent">Content of the report.</param>
			public ObjectTypeListReport(
				ORMModel model,
				IList<ObjectType> objectTypeList,
				IVerbalizationSets<ReportVerbalizationSnippetType> snippets,
				ReportVerbalizationSnippetType headerSnippet,
				ReportVerbalizationSnippetType footerSnippet,
				VerbalizationReportContent reportContent)
			{
				myModel = model;
				myObjectTypeList = objectTypeList;
				mySnippets = snippets;
				myHeaderSnippet = headerSnippet;
				myFooterSnippet = footerSnippet;
				myReportContent = reportContent;
			}
コード例 #4
0
ファイル: VerbalizationReport.cs プロジェクト: cjheath/NORMA
		/// <summary>
		/// Retrieves a dictionary of all Constraints for the given Fact Type list, filtered by the specified VerbalizationReportContent, indexed by ConstraintType
		/// </summary>
		/// <param name="factTypeList">The Fact Types to retrieve constraints for</param>
		/// <param name="reportContent">The VerbalizationReportContent to filter constraints</param>
		/// <returns>dictionary of all Constraints for the given Fact Type, filtered by the specified VerbalizationReportContent, indexed by ConstraintType</returns>
		protected static IDictionary<ConstraintType, IList<IConstraint>> GetConstraintsFromFactType(IList<FactType> factTypeList, VerbalizationReportContent reportContent)
		{
			IDictionary<ConstraintType, IList<IConstraint>> constraintList = GetConstraintDictionary(reportContent);

			int factCount = factTypeList.Count;
			for (int i = 0; i < factCount; ++i)
			{
				ProcessFactTypeConstraints(factTypeList[i], reportContent, constraintList);
			}

			return constraintList;
		}
コード例 #5
0
ファイル: VerbalizationReport.cs プロジェクト: cjheath/NORMA
		/// <summary>
		/// Retrieves a dictionary of constraint lists based on the given filter
		/// </summary>
		private static IDictionary<ConstraintType, IList<IConstraint>> GetConstraintDictionary(VerbalizationReportContent reportContent)
		{
			IDictionary<ConstraintType, IList<IConstraint>> constraintList = new Dictionary<ConstraintType, IList<IConstraint>>();

			if ((reportContent & VerbalizationReportContent.DisjunctiveMandatoryConstraints) != 0)
			{
				constraintList.Add(ConstraintType.DisjunctiveMandatory, new List<IConstraint>());
			}
			if ((reportContent & VerbalizationReportContent.EqualityConstraints) != 0)
			{
				constraintList.Add(ConstraintType.Equality, new List<IConstraint>());
			}
			if ((reportContent & VerbalizationReportContent.ExclusionConstraints) != 0)
			{
				constraintList.Add(ConstraintType.Exclusion, new List<IConstraint>());
			}
			if ((reportContent & VerbalizationReportContent.ExternalUniquenessConstraints) != 0)
			{
				constraintList.Add(ConstraintType.ExternalUniqueness, new List<IConstraint>());
			}
			if ((reportContent & VerbalizationReportContent.FrequencyConstraints) != 0)
			{
				constraintList.Add(ConstraintType.Frequency, new List<IConstraint>());
			}
			if ((reportContent & VerbalizationReportContent.InternalUniquenessConstraints) != 0)
			{
				constraintList.Add(ConstraintType.InternalUniqueness, new List<IConstraint>());
			}
			if ((reportContent & VerbalizationReportContent.RingConstraints) != 0)
			{
				constraintList.Add(ConstraintType.Ring, new List<IConstraint>());
			}
			if ((reportContent & VerbalizationReportContent.SimpleMandatoryConstraints) != 0)
			{
				constraintList.Add(ConstraintType.SimpleMandatory, new List<IConstraint>());
			}
			if ((reportContent & VerbalizationReportContent.SubsetConstraints) != 0)
			{
				constraintList.Add(ConstraintType.Subset, new List<IConstraint>());
			}

			return constraintList;
		}
コード例 #6
0
ファイル: VerbalizationReport.cs プロジェクト: cjheath/NORMA
		/// <summary>
		/// Retrieves a dictionary of all Constraints for the given Fact Type, filtered by the specified VerbalizationReportContent, indexed by ConstraintType
		/// </summary>
		/// <param name="factType">The Fact Type to retrieve constraints for</param>
		/// <param name="reportContent">The VerbalizationReportContent to filter constraints</param>
		/// <returns>dictionary of all Constraints for the given Fact Type, filtered by the specified VerbalizationReportContent, indexed by ConstraintType</returns>
		protected static IDictionary<ConstraintType, IList<IConstraint>> GetConstraintsFromFactType(FactType factType, VerbalizationReportContent reportContent)
		{
			IDictionary<ConstraintType, IList<IConstraint>> constraintList = GetConstraintDictionary(reportContent);
			ProcessFactTypeConstraints(factType, reportContent, constraintList);
			return constraintList;
		}
コード例 #7
0
ファイル: VerbalizationReport.cs プロジェクト: cjheath/NORMA
		/// <summary>
		/// Processes the specified FactType and adds the appropriate constraints based on the specified filter
		/// </summary>
		private static void ProcessFactTypeConstraints(FactType factType, VerbalizationReportContent reportContent, IDictionary<ConstraintType, IList<IConstraint>> typedConstraintLists)
		{
			foreach (IFactConstraint factConstraint in factType.FactConstraintCollection)
			{
				IConstraint constraint = factConstraint.Constraint;
				ConstraintType constraintType = constraint.ConstraintType;
				VerbalizationReportContent allowedContent;
				switch (constraintType)
				{
					case ConstraintType.DisjunctiveMandatory:
						allowedContent = VerbalizationReportContent.DisjunctiveMandatoryConstraints;
						break;
					case ConstraintType.Equality:
						allowedContent = VerbalizationReportContent.EqualityConstraints;
						break;
					case ConstraintType.Exclusion:
						allowedContent = VerbalizationReportContent.ExclusionConstraints;
						break;
					case ConstraintType.ExternalUniqueness:
						allowedContent = VerbalizationReportContent.ExternalUniquenessConstraints;
						break;
					case ConstraintType.Frequency:
						allowedContent = VerbalizationReportContent.FrequencyConstraints;
						break;
					case ConstraintType.InternalUniqueness:
						allowedContent = VerbalizationReportContent.InternalUniquenessConstraints;
						break;
					case ConstraintType.Ring:
						allowedContent = VerbalizationReportContent.RingConstraints;
						break;
					case ConstraintType.SimpleMandatory:
						allowedContent = VerbalizationReportContent.SimpleMandatoryConstraints;
						break;
					case ConstraintType.Subset:
						allowedContent = VerbalizationReportContent.SubsetConstraints;
						break;
					default:
						continue;
				}
				if (0 != (reportContent & allowedContent))
				{
					IList<IConstraint> typedList = typedConstraintLists[constraintType];
					if (!typedList.Contains(constraint))
					{
						typedList.Add(constraint);
					}
				}
			}
		}
コード例 #8
0
ファイル: VerbalizationReport.cs プロジェクト: cjheath/NORMA
		/// <summary>
		/// Generates a report of the Verbalizations
		/// </summary>
		/// <param name="model">The model to report on</param>
		/// <param name="reportContent">The filter to apply to the report</param>
		/// <param name="baseDir">The base directory to output the report</param>
		public static void GenerateReport(ORMModel model, VerbalizationReportContent reportContent, string baseDir)
		{
			#region Member Variable
			const VerbalizationSign sign = VerbalizationSign.Positive | VerbalizationSign.AttemptOppositeSign;
			IORMToolServices toolServices = (IORMToolServices)model.Store;
			IDictionary<Type, IVerbalizationSets> snippetsDictionary = toolServices.GetVerbalizationSnippetsDictionary(HtmlReport.HtmlReportTargetName);
			IVerbalizationSets<ReportVerbalizationSnippetType> snippets = (IVerbalizationSets<ReportVerbalizationSnippetType>)snippetsDictionary[typeof(ReportVerbalizationSnippetType)];
			IExtensionVerbalizerService extensionVerbalizer = toolServices.ExtensionVerbalizerService;
			Dictionary<IVerbalize, IVerbalize> alreadyVerbalized;
			Dictionary<object, object> locallyVerbalized = new Dictionary<object, object>();
			Stream fileStream;
			TextWriter textWriter;
			VerbalizationCallbackWriter writer;
			#endregion // Member Variable
			#region ObjectType Reports
			ObjectType[] objectTypeList = null;
			if (0 != (reportContent & VerbalizationReportContent.ObjectTypes))
			{
				alreadyVerbalized = new Dictionary<IVerbalize, IVerbalize>();
				objectTypeList = model.ObjectTypeCollection.ToArray();

				int objectTypeCount = objectTypeList.Length;
				if (objectTypeCount != 0)
				{
					Array.Sort<ObjectType>(objectTypeList, NamedElementComparer<ObjectType>.CurrentCulture);
					#region Object Type List Report
					fileStream = new FileStream(Path.Combine(baseDir, "ObjectTypeList.html"), FileMode.Create, FileAccess.ReadWrite);
					textWriter = new StreamWriter(fileStream);
					writer = new VerbalizationReportCallbackWriter(snippetsDictionary, textWriter);
					bool firstCall = true;

					IVerbalizeCustomChildren objectTypeListReport = new ObjectTypeListReport(model, objectTypeList, snippets, ReportVerbalizationSnippetType.ObjectTypeListHeader, ReportVerbalizationSnippetType.ObjectTypeListFooter, reportContent);
					VerbalizationHelper.VerbalizeChildren(
						objectTypeListReport.GetCustomChildVerbalizations(null, sign),
						null,
						snippetsDictionary,
						extensionVerbalizer,
						HtmlReport.HtmlReportTargetName,
						alreadyVerbalized,
						locallyVerbalized,
						sign,
						writer,
						false,
						ref firstCall);

					if (!firstCall)
					{
						writer.WriteDocumentFooter();
					}

					textWriter.Flush();
					textWriter.Close();
					#endregion // Object Type List Report
					string objectTypeDir = Path.Combine(baseDir, "ObjectTypes");
					if (!Directory.Exists(objectTypeDir))
					{
						Directory.CreateDirectory(objectTypeDir);
					}
					#region Individual ObjectType Pages
					for (int i = 0; i < objectTypeCount; ++i)
					{
						bool firstCallPending = true;
						locallyVerbalized.Clear();
						ObjectType objectType = objectTypeList[i];

						fileStream = new FileStream(Path.Combine(objectTypeDir, AsFileName(objectType.Name) + ".html"), FileMode.Create, FileAccess.ReadWrite);
						textWriter = new StreamWriter(fileStream);
						writer = new VerbalizationReportCallbackWriter(snippetsDictionary, textWriter);

						ObjectTypePageReport objectTypePageReport = new ObjectTypePageReport(objectType, reportContent, snippets);
						VerbalizationHelper.VerbalizeChildren(
							((IVerbalizeCustomChildren)objectTypePageReport).GetCustomChildVerbalizations(objectTypePageReport, sign),
							null,
							snippetsDictionary,
							extensionVerbalizer,
							HtmlReport.HtmlReportTargetName,
							alreadyVerbalized,
							locallyVerbalized,
							sign,
							writer,
							false,
							ref firstCallPending);

						if (!firstCallPending)
						{
							writer.WriteDocumentFooter();
						}
						textWriter.Flush();
						textWriter.Close();
					}
					#endregion // Individual ObjectType Pages
				}
			}
			#endregion // ObjectType Reports
			#region Individual FactType Page Reports
			FactType[] factTypeList = null;
			if (0 != (VerbalizationReportContent.FactTypes & reportContent))
			{
				factTypeList = model.FactTypeCollection.ToArray();
				alreadyVerbalized = new Dictionary<IVerbalize, IVerbalize>();

				int factCount = factTypeList.Length;
				if (factCount != 0)
				{
					string factTypeDir = Path.Combine(baseDir, "FactTypes");
					if (!Directory.Exists(factTypeDir))
					{
						Directory.CreateDirectory(factTypeDir);
					}

					Array.Sort<FactType>(factTypeList, NamedElementComparer<FactType>.CurrentCulture);
					for (int i = 0; i < factCount; ++i)
					{
						bool firstCallPending = true;
						alreadyVerbalized.Clear();
						locallyVerbalized.Clear();
						fileStream = new FileStream(Path.Combine(factTypeDir, AsFileName(factTypeList[i].Name) + ".html"), FileMode.Create, FileAccess.ReadWrite);
						textWriter = new StreamWriter(fileStream);
						writer = new VerbalizationReportCallbackWriter(snippetsDictionary, textWriter);

						FactTypePageReport factTypePageReport = new FactTypePageReport(factTypeList[i], reportContent, snippets);
						VerbalizationHelper.VerbalizeChildren(
							((IVerbalizeCustomChildren)factTypePageReport).GetCustomChildVerbalizations(factTypePageReport, sign),
							null,
							snippetsDictionary,
							extensionVerbalizer,
							HtmlReport.HtmlReportTargetName,
							alreadyVerbalized,
							locallyVerbalized,
							sign,
							writer,
							false,
							ref firstCallPending);

						if (!firstCallPending)
						{
							writer.WriteDocumentFooter();
						}
						textWriter.Flush();
						textWriter.Close();
					}
				}
			}
			#endregion // Individual FactType Page Reports
			#region Constraint Validation Report
			if (0 != (reportContent & VerbalizationReportContent.ValidationReport))
			{
				alreadyVerbalized = new Dictionary<IVerbalize, IVerbalize>();
				bool firstCall = true;
				if (factTypeList == null)
				{
					factTypeList = model.FactTypeCollection.ToArray();
					Array.Sort<FactType>(factTypeList, NamedElementComparer<FactType>.CurrentCulture);
				}

				if (factTypeList.Length != 0)
				{
					fileStream = new FileStream(Path.Combine(baseDir, "ConstraintValidationReport.html"), FileMode.Create, FileAccess.ReadWrite);
					textWriter = new StreamWriter(fileStream);
					writer = new VerbalizationReportCallbackWriter(snippetsDictionary, textWriter);

					FactTypeConstraintValidationListReport factTypeConstraintValidationReport = new FactTypeConstraintValidationListReport(model, factTypeList, reportContent, snippets);
					VerbalizationHelper.VerbalizeChildren(
						((IVerbalizeCustomChildren)factTypeConstraintValidationReport).GetCustomChildVerbalizations(factTypeConstraintValidationReport, sign),
						null,
						snippetsDictionary,
						extensionVerbalizer,
						HtmlReport.HtmlReportTargetName,
						alreadyVerbalized,
						null,
						sign,
						writer,
						false,
						ref firstCall);

					if (!firstCall)
					{
						writer.WriteDocumentFooter();
					}

					textWriter.Flush();
					textWriter.Close();
				}
			}
			#endregion // Constraint Validation Report
		}
コード例 #9
0
ファイル: VerbalizationReport.cs プロジェクト: cjheath/NORMA
			/// <summary>
			/// Initializes a new instance of ConstraintValidationSection
			/// </summary>
			public ConstraintValidationSection(VerbalizationReportContent reportContent, IDictionary<ConstraintType, IList<IConstraint>> constraintList)
			{
				myReportContent = reportContent;
				myConstraintList = constraintList;
			}
コード例 #10
0
ファイル: VerbalizationReport.cs プロジェクト: cjheath/NORMA
			/// <summary>
			/// Initializes a new instance of FactTypeConstraintValidationListReport
			/// </summary>
			/// <param name="model">Context model</param>
			/// <param name="factTypeList">The fact type list.</param>
			/// <param name="reportContent">Content of the report.</param>
			/// <param name="snippets">The snippets.</param>
			public FactTypeConstraintValidationListReport(ORMModel model, IList<FactType> factTypeList, VerbalizationReportContent reportContent, IVerbalizationSets<ReportVerbalizationSnippetType> snippets)
			{
				myModel = model;
				myFactTypeList = factTypeList;
				mySnippets = snippets;
				myReportContent = reportContent;
			}
コード例 #11
0
ファイル: VerbalizationReport.cs プロジェクト: cjheath/NORMA
			/// <summary>
			/// Initializes a new instance of VerbalizationReportTableOfContentsWrapper
			/// </summary>
			public VerbalizationReportTableOfContentsWrapper(VerbalizationReportContent reportContent, IVerbalizationSets<ReportVerbalizationSnippetType> snippets)
			{
				myReportContent = reportContent;
				mySnippets = snippets;
			}
コード例 #12
0
ファイル: VerbalizationReport.cs プロジェクト: cjheath/NORMA
			/// <summary>
			/// Initializes a new instance of FactTypePageReport
			/// </summary>
			public FactTypePageReport(FactType factType, VerbalizationReportContent reportContent, IVerbalizationSets<ReportVerbalizationSnippetType> snippets)
			{
				myFactType = factType;
				myReportContent = reportContent;
				mySnippets = snippets;
			}