/// <summary> /// Creates a new instance of SchematronGenerator. /// </summary> /// <param name="rep">The repository (object context) to get the data from.</param> /// <param name="ig">The implementation guide to export schematron for.</param> /// <param name="includeInferred">Indicates whether or not to include inferred templates, in addition to the templates directly owned by the implementation guide</param> public SchematronGenerator(IObjectRepository rep, ImplementationGuide ig, List <Template> templates, bool includeCustom, VocabularyOutputType vocabularyOutputType = VocabularyOutputType.Default, string vocFileName = "voc.xml", List <string> categories = null, string defaultSchematron = "not(.)") { this.rep = rep; this.ig = ig; this.templates = templates; this.vocabularyOutputType = vocabularyOutputType; this.includeCustom = includeCustom; this.vocFileName = vocFileName; this.igTypePlugin = ig.ImplementationGuideType.GetPlugin(); this.categories = categories; this.defaultSchematron = defaultSchematron; constraintNumbers = (from t in templates join tc in rep.TemplateConstraints on t.Id equals tc.TemplateId select new { tc.Id, tc.Template.OwningImplementationGuideId, tc.Number.Value }) .ToDictionary(y => y.Id, y => string.Format("{0}-{1}", y.OwningImplementationGuideId, y.Value)); this.schemaPrefix = ig.ImplementationGuideType.SchemaPrefix; if (!this.schemaPrefix.EndsWith(":")) { this.schemaPrefix += ":"; } }
public ConstraintParser(IObjectRepository tdb, IConstraint constraint, ImplementationGuideType igType, SimpleSchema igTypeSchema, IEnumerable <Template> allTemplates, string valueSetFile = "voc.xml", VocabularyOutputType vocabularyOutputType = VocabularyOutputType.Default) { this.tdb = tdb; this.constraint = constraint; this.valueSetFile = valueSetFile; this.igType = igType; this.igTypeSchema = igTypeSchema; this.allTemplates = allTemplates; this.igTypePlugin = igType.GetPlugin(); if (!string.IsNullOrEmpty(this.constraint.Cardinality)) { this.constraintCardinalityType = CardinalityParser.Parse(this.constraint.Cardinality); } if (!string.IsNullOrEmpty(this.constraint.Conformance)) { this.constraintConformanceType = ConformanceParser.Parse(this.constraint.Conformance); } this.prefix = igType.SchemaPrefix; this.vocabularyOutputType = vocabularyOutputType; }
public AssertionLineBuilder WithinValueSet(string aValueSetOid, string aValueSetFileName, VocabularyOutputType aOutputType = VocabularyOutputType.Default, Boolean aIncludeNullFlavor = false) { _valueSetOid = aValueSetOid; _valueSetFileName = aValueSetFileName; _vocabularyOutputType = aOutputType; _includeValueSetNullFlavor = aIncludeNullFlavor; return(this); }
public static VocabularyOutputType FromInt(int aTypeNum) { string[] values = System.Enum.GetNames(typeof(VocabularyOutputType)); VocabularyOutputType outputType = VocabularyOutputType.Default; if (values.GetLength(0) >= aTypeNum) { outputType = (VocabularyOutputType)aTypeNum; } return(outputType); }
public static string Generate(IObjectRepository rep, ImplementationGuide ig, bool includeCustom, VocabularyOutputType vocabularyOutputType = VocabularyOutputType.Default, string vocFileName = "voc.xml", List <Template> templates = null, List <string> categories = null, string defaultSchematron = "not(.)") { SchematronGenerator generator = new SchematronGenerator(rep, ig, templates, includeCustom, vocabularyOutputType, vocFileName, categories, defaultSchematron); return(generator.Generate()); }
public HttpResponseMessage ExportSchematron(SchematronSettingsModel model) { ImplementationGuide ig = this.tdb.ImplementationGuides.Single(y => y.Id == model.ImplementationGuideId); VocabularyOutputType vocOutputType = GetVocOutputType(model.ValueSetOutputFormat); var templates = (from t in this.tdb.Templates where model.TemplateIds.Contains(t.Id) select t).ToList(); string schematronResult = SchematronGenerator.Generate(tdb, ig, model.IncludeCustomSchematron, vocOutputType, model.VocabularyFileName, templates, model.SelectedCategories, model.DefaultSchematron); byte[] data = ASCIIEncoding.UTF8.GetBytes(schematronResult); string fileName = string.Format("{0}.sch", ig.GetDisplayName(true)); return(GetExportResponse(fileName, XML_MIME_TYPE, data)); }
public ConstraintParser(IObjectRepository tdb, IConstraint constraint, ImplementationGuideType igType, string valueSetFile = "voc.xml", VocabularyOutputType vocabularyOutputType = VocabularyOutputType.Default) { this.tdb = tdb; this.constraint = constraint; this.valueSetFile = valueSetFile; this.igTypePlugin = igType.GetPlugin(); if (this.constraint.ValueSetId != null) { this.constraintValueSet = this.tdb.ValueSets.Single(y => y.Id == constraint.ValueSetId); } if (this.constraint.ValueCodeSystemId != null) { this.constraintCodeSystem = this.tdb.CodeSystems.Single(y => y.Id == constraint.ValueCodeSystemId); } if (!string.IsNullOrEmpty(this.constraint.Cardinality)) { this.constraintCardinalityType = CardinalityParser.Parse(this.constraint.Cardinality); } if (!string.IsNullOrEmpty(this.constraint.Conformance)) { this.constraintConformanceType = ConformanceParser.Parse(this.constraint.Conformance); } if (this.constraint.ContainedTemplateId != null) { this.containedTemplate = this.tdb.Templates.Single(y => y.Id == this.constraint.ContainedTemplateId.Value); } this.prefix = igType.SchemaPrefix; this.vocabularyOutputType = vocabularyOutputType; }
public AssertionLineBuilder WithinValueSet(string aValueSetOid, VocabularyOutputType aOutputType = VocabularyOutputType.Default) { return(WithinValueSet(aValueSetOid, "the_voc.xml", aOutputType)); }
public string ExportImplementationGuide(int implementationGuideId, int maxMembers = 100, VocabularyOutputType format = VocabularyOutputType.Default, string encoding = "UTF-8") { VocabularyService service = new VocabularyService(this.tdb); return(service.GetImplementationGuideVocabulary(implementationGuideId, maxMembers, (int)format, encoding)); }
public string ExportValueSet(string valueSetOid, VocabularyOutputType format = VocabularyOutputType.Default, string encoding = "UTF-8") { VocabularyService service = new VocabularyService(this.tdb); return(service.GetValueSet(valueSetOid, (int)format, encoding)); }
/// <summary> /// Creates a new instance of SchematronGenerator. /// </summary> /// <param name="rep">The repository (object context) to get the data from.</param> /// <param name="ig">The implementation guide to export schematron for.</param> /// <param name="includeInferred">Indicates whether or not to include inferred templates, in addition to the templates directly owned by the implementation guide</param> public SchematronGenerator(IObjectRepository rep, ImplementationGuide ig, List <Template> templates, bool includeCustom, VocabularyOutputType vocabularyOutputType = VocabularyOutputType.Default, string vocFileName = "voc.xml", List <string> categories = null, string defaultSchematron = "not(.)") { var templateIds = templates.Select(y => y.Id).ToList(); this.rep = rep; this.ig = ig; this.igSettings = new IGSettingsManager(rep, ig.Id); this.templates = rep.Templates.Where(y => templateIds.Contains(y.Id)) .Include(y => y.ImpliedTemplate) .Include("ChildConstraints") .Include("ChildConstraints.ValueSet") .Include("ChildConstraints.CodeSystem") .Include("ChildConstraints.References") .Include("ChildConstraints.ChildConstraints") .Include("ChildConstraints.ChildConstraints.ValueSet") .Include("ChildConstraints.ChildConstraints.CodeSystem") .Include("ChildConstraints.ChildConstraints.References") .Include("ChildConstraints.ChildConstraints.ChildConstraints") .Include("ChildConstraints.ChildConstraints.ChildConstraints.ValueSet") .Include("ChildConstraints.ChildConstraints.ChildConstraints.CodeSystem") .Include("ChildConstraints.ChildConstraints.ChildConstraints.References") .Include("ChildConstraints.ChildConstraints.ChildConstraints.ChildConstraints") .Include("ChildConstraints.ChildConstraints.ChildConstraints.ChildConstraints.ValueSet") .Include("ChildConstraints.ChildConstraints.ChildConstraints.ChildConstraints.CodeSystem") .Include("ChildConstraints.ChildConstraints.ChildConstraints.ChildConstraints.References") .Include("ChildConstraints.ChildConstraints.ChildConstraints.ChildConstraints.ChildConstraints") .Include("ChildConstraints.ChildConstraints.ChildConstraints.ChildConstraints.ChildConstraints.ValueSet") .Include("ChildConstraints.ChildConstraints.ChildConstraints.ChildConstraints.ChildConstraints.CodeSystem") .Include("ChildConstraints.ChildConstraints.ChildConstraints.ChildConstraints.ChildConstraints.References") .Include("ChildConstraints.ChildConstraints.ChildConstraints.ChildConstraints.ChildConstraints.ChildConstraints") .Include("ChildConstraints.ChildConstraints.ChildConstraints.ChildConstraints.ChildConstraints.ChildConstraints.ValueSet") .Include("ChildConstraints.ChildConstraints.ChildConstraints.ChildConstraints.ChildConstraints.ChildConstraints.CodeSystem") .Include("ChildConstraints.ChildConstraints.ChildConstraints.ChildConstraints.ChildConstraints.ChildConstraints.References") .ToList(); this.constraintReferences = (from tcr in this.rep.TemplateConstraintReferences // all constraint references join t in this.rep.Templates on tcr.ReferenceIdentifier equals t.Oid // get the template the reference is point to join stc in this.rep.TemplateConstraints on tcr.TemplateConstraintId equals stc.Id // get the constraint that the reference is on join stid in templateIds on stc.TemplateId equals stid // limit constraints to only templates being included in the ig/export select new ConstraintReference() { Bookmark = t.Bookmark, Identifier = t.Oid, Name = t.Name, TemplateConstraintId = tcr.TemplateConstraintId }).ToList(); this.vocabularyOutputType = vocabularyOutputType; this.includeCustom = includeCustom; this.vocFileName = vocFileName; this.categories = categories; this.defaultSchematron = defaultSchematron; this.igTypePlugin = this.ig.ImplementationGuideType.GetPlugin(); this.igTypeSchema = ig.ImplementationGuideType.GetSimpleSchema(); this.templateContextBuilder = new TemplateContextBuilder(this.rep, ig.ImplementationGuideType, this.igTypeSchema); var allConstraint = (from t in templates from tc in t.ChildConstraints select new { tc.Id, tc.Template.OwningImplementationGuideId, tc.Number.Value }) .Distinct(); this.constraintNumbers = allConstraint.ToDictionary(y => y.Id, y => string.Format("{0}-{1}", y.OwningImplementationGuideId, y.Value)); this.schemaPrefix = ig.ImplementationGuideType.SchemaPrefix; if (!this.schemaPrefix.EndsWith(":")) { this.schemaPrefix += ":"; } }
public VocabularyOutputTypeAdapter(VocabularySystems aVocabSystems, VocabularyOutputType aOutputType, Encoding aEncoding) : this(aVocabSystems, aOutputType) { _encoding = aEncoding; }
public VocabularyOutputTypeAdapter(VocabularySystems aVocabSystems, VocabularyOutputType aOutputType) { _vocabOutputType = aOutputType; _vocabSystems = aVocabSystems; _encoding = Encoding.UTF8; }