/// <summary> /// Creating new custom, user FIS item from an existing FIS rule file or loading project fis /// </summary> /// <param name="fisfilePath"></param> public FISLibraryItem(string fisfilePath, FISLibrary.FISLibraryItemTypes eType) { FISType = eType; FilePath = new FileInfo(fisfilePath); Name = Path.GetFileNameWithoutExtension(fisfilePath); Inputs = new BindingList <FISInputMeta>(); Publications = new naru.ui.SortableBindingList <FISMetaItem>(); ExampleDatasets = new naru.ui.SortableBindingList <FISMetaItem>(); Metadata = new naru.ui.SortableBindingList <FISMetaItem>(); // ensure that the metadata list contains the essential items AddMetadataItem("Contributor"); AddMetadataItem("Contributor Email"); AddMetadataItem("Organization"); AddMetadataItem("Purpose"); AddMetadataItem("URL"); AddMetadataItem("Survey Type"); FileInfo xmlMetaData = new FileInfo(Path.ChangeExtension(fisfilePath, "fis.xml")); if (eType != FISLibrary.FISLibraryItemTypes.System && xmlMetaData.Exists) { try { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(xmlMetaData.FullName); LoadFISFromXML(xmlDoc.DocumentElement.SelectSingleNode("FISLibraryItem")); } catch (Exception ex) { Console.WriteLine(string.Format("Error loading FIS metadata file at {0}\n{1}", xmlMetaData.FullName, ex.Message)); } } }
/// <summary> /// Constructore for loading "unreferenced" system FIS. /// </summary> /// <param name="sName"></param> /// <param name="fiPath"></param> /// <param name="eType"></param> /// <remarks>Unreferenced system FIS are fis files found in the system folder that /// do not have an entry in the system FIS library XML</remarks> public FISLibraryItem(string sName, System.IO.FileInfo fiPath, FISLibrary.FISLibraryItemTypes eType) { FISType = eType; Name = sName; FilePath = fiPath; Inputs = new BindingList <FISInputMeta>(); Publications = new naru.ui.SortableBindingList <FISMetaItem>(); ExampleDatasets = new naru.ui.SortableBindingList <FISMetaItem>(); Metadata = new naru.ui.SortableBindingList <FISMetaItem>(); LoadInputsFromFIS(); }
/// <summary> /// Constructor for project FIS items /// </summary> /// <param name="nodFISItem"></param> public FISLibraryItem(XmlNode nodFISItem, FileInfo projectFISPath) { FISType = FISLibrary.FISLibraryItemTypes.Project; FilePath = projectFISPath; System.Diagnostics.Debug.Assert(FilePath.Exists, "This constructor should only be called if the FIS file actually exists"); Inputs = new BindingList <FISInputMeta>(); Publications = new naru.ui.SortableBindingList <FISMetaItem>(); ExampleDatasets = new naru.ui.SortableBindingList <FISMetaItem>(); Metadata = new naru.ui.SortableBindingList <FISMetaItem>(); LoadFISFromXML(nodFISItem); }
/// <summary> /// /// </summary> /// <param name="nodFISItem"></param> /// <param name="eType">User, system or project</param> /// <param name="libraryRootDir">The root directory of the FIS Library (i.e. folder containing the FIS library XML file)</param> public FISLibraryItem(XmlNode nodFISItem, FISLibrary.FISLibraryItemTypes eType, DirectoryInfo libraryRootDir) { FISType = eType; if (libraryRootDir is System.IO.DirectoryInfo) { // System FIS Library XML stores relative paths to the FIS Library XML manfiest FilePath = new System.IO.FileInfo(System.IO.Path.Combine(libraryRootDir.FullName, nodFISItem.SelectSingleNode("FilePath").InnerText)); } else { // User FIS items store absolute file paths in the custom FIS Library XML FilePath = new System.IO.FileInfo(nodFISItem.SelectSingleNode("FilePath").InnerText); } System.Diagnostics.Debug.Assert(FilePath.Exists, "This constructor should only be called if the FIS file actually exists"); Inputs = new BindingList <FISInputMeta>(); Publications = new naru.ui.SortableBindingList <FISMetaItem>(); ExampleDatasets = new naru.ui.SortableBindingList <FISMetaItem>(); Metadata = new naru.ui.SortableBindingList <FISMetaItem>(); LoadFISFromXML(nodFISItem); }