public override void Initialize(XElement configRoot) { // name var nameAttribute = configRoot.Attribute("name"); if (nameAttribute == null) throw new Exception("Missing 'name' attribute on element CollectionProvider"); Name = nameAttribute.Value; var identityAttribute = configRoot.Attribute("identifier"); if (identityAttribute == null) throw new Exception("Missing 'identifier' attribute on element CollectionProvider"); Identity = identityAttribute.Value; // description var descriptionAttribute = configRoot.Attribute("description"); if (descriptionAttribute == null) { // log warning Logging.LogWarning(0, "No description element for collection {0}", Name); } else { Description = descriptionAttribute.Value; } // dsn var dsnElement = configRoot.Elements("DsnConnection").FirstOrDefault(); if (dsnElement == null) { throw new Exception("Missing 'DsnConnection' element as child of CollectionProvider"); } _dataSourceConnectionString = dsnElement.Value.Trim(); // publishing definitions foreach (var xElement in configRoot.Descendants("Definition")) { // add each definition to the collection var def = new ResourcePublishingDefinition { ResourcePrefix = new Uri(GetElementValue(xElement, "ResourcePrefix")), UriTemplate = new UriTemplate(GetElementValue(xElement, "UriTemplate")) }; if (DoesElementExist(xElement, "SuppressFragmentsFeed")) { def.SuppressFragmentsFeed = bool.Parse(GetElementValue(xElement, "SuppressFragmentsFeed")); } if (DoesElementExist(xElement, "FragmentsQuery")) { def.FragmentsQuery = GetElementValue(xElement, "FragmentsQuery"); if (DoesElementExist(xElement, "SourceDataInLocalTime")) def.SourceDataInLocalTime = bool.Parse(GetElementValue(xElement, "SourceDataInLocalTime")); } else { def.NoTimeStampInData = true; def.HashValueTable = GetElementValue(xElement, "HashValueTable"); // Axel was here if (DoesElementExist(xElement, "HashValueFileName")) def.HashValueFileName = GetElementValue(xElement, "HashValueFileName"); def.EntityIdColumn = GetElementValue(xElement, "EntityIdColumn"); def.HashValueKeyColumns = GetElementValues(xElement, "HashValueKeyColumn"); def.ValueCheckInterval = GetElementValue(xElement, "UpdateFrequency"); } if (DoesElementExist(xElement, "EncodeIdForResourceId")) { def.EncodeIdForResourceId = bool.Parse(GetElementValue(xElement, "EncodeIdForResourceId")); } // get FragmentGenerationDefinitions foreach (var fragmentGenerationDefinition in xElement.Descendants("FragmentGenerationDefinition")) { var fragDef = new FragmentGenerationDefinition { SnapshotQuery = GetElementValue(fragmentGenerationDefinition, "SnapshotQuery"), FragmentQuery = GetElementValue(fragmentGenerationDefinition, "FragmentQuery") }; // get generic exclude columns var rdfTemplatesElem = xElement.Descendants("RdfTemplates").FirstOrDefault(); if (rdfTemplatesElem.Attribute("genericExcludes") != null) { fragDef.GenericTemplateExcludeColumns = new List<string>(rdfTemplatesElem.Attribute("genericExcludes").Value.Split(',')); } // get lines var patternLines = new List<string>(); foreach (var lineElement in fragmentGenerationDefinition.Descendants("li")) { patternLines.Add(lineElement.Value.Replace("{{", "<").Replace("}}", ">")); } fragDef.RdfTemplateLines = patternLines; def.FragmentGenerationDefinitions.Add(fragDef); } _publishingDefinitions.Add(def); } RawConfig = configRoot.ToString(); IsEnabled = true; }
public override void Initialize(XElement configRoot) { // name var nameAttribute = configRoot.Attribute("name"); if (nameAttribute == null) { throw new Exception("Missing 'name' attribute on element CollectionProvider"); } Name = nameAttribute.Value; var identityAttribute = configRoot.Attribute("identifier"); if (identityAttribute == null) { throw new Exception("Missing 'identifier' attribute on element CollectionProvider"); } Identity = identityAttribute.Value; // description var descriptionAttribute = configRoot.Attribute("description"); if (descriptionAttribute == null) { // log warning Logging.LogWarning(0, "No description element for collection {0}", Name); } else { Description = descriptionAttribute.Value; } // dsn var dsnElement = configRoot.Elements("DsnConnection").FirstOrDefault(); if (dsnElement == null) { throw new Exception("Missing 'DsnConnection' element as child of CollectionProvider"); } _dataSourceConnectionString = dsnElement.Value.Trim(); // publishing definitions foreach (var xElement in configRoot.Descendants("Definition")) { // add each definition to the collection var def = new ResourcePublishingDefinition { ResourcePrefix = new Uri(GetElementValue(xElement, "ResourcePrefix")), UriTemplate = new UriTemplate(GetElementValue(xElement, "UriTemplate")) }; if (DoesElementExist(xElement, "SuppressFragmentsFeed")) { def.SuppressFragmentsFeed = bool.Parse(GetElementValue(xElement, "SuppressFragmentsFeed")); } if (DoesElementExist(xElement, "FragmentsQuery")) { def.FragmentsQuery = GetElementValue(xElement, "FragmentsQuery"); if (DoesElementExist(xElement, "SourceDataInLocalTime")) { def.SourceDataInLocalTime = bool.Parse(GetElementValue(xElement, "SourceDataInLocalTime")); } } else { def.NoTimeStampInData = true; def.HashValueTable = GetElementValue(xElement, "HashValueTable"); // Axel was here if (DoesElementExist(xElement, "HashValueFileName")) { def.HashValueFileName = GetElementValue(xElement, "HashValueFileName"); } def.EntityIdColumn = GetElementValue(xElement, "EntityIdColumn"); def.HashValueKeyColumns = GetElementValues(xElement, "HashValueKeyColumn"); def.ValueCheckInterval = GetElementValue(xElement, "UpdateFrequency"); } if (DoesElementExist(xElement, "EncodeIdForResourceId")) { def.EncodeIdForResourceId = bool.Parse(GetElementValue(xElement, "EncodeIdForResourceId")); } // get FragmentGenerationDefinitions foreach (var fragmentGenerationDefinition in xElement.Descendants("FragmentGenerationDefinition")) { var fragDef = new FragmentGenerationDefinition { SnapshotQuery = GetElementValue(fragmentGenerationDefinition, "SnapshotQuery"), FragmentQuery = GetElementValue(fragmentGenerationDefinition, "FragmentQuery") }; // get generic exclude columns var rdfTemplatesElem = xElement.Descendants("RdfTemplates").FirstOrDefault(); if (rdfTemplatesElem.Attribute("genericExcludes") != null) { fragDef.GenericTemplateExcludeColumns = new List <string>(rdfTemplatesElem.Attribute("genericExcludes").Value.Split(',')); } // get lines var patternLines = new List <string>(); foreach (var lineElement in fragmentGenerationDefinition.Descendants("li")) { patternLines.Add(lineElement.Value.Replace("{{", "<").Replace("}}", ">")); } fragDef.RdfTemplateLines = patternLines; def.FragmentGenerationDefinitions.Add(fragDef); } _publishingDefinitions.Add(def); } RawConfig = configRoot.ToString(); IsEnabled = true; }