Beispiel #1
0
 public static EDOModel createDefault()
 {
     EDOModel data = new EDOModel();
     StudyUnit study1 = StudyUnit.CreateDefault();
     data.StudyUnits.Add(study1);
     return data;
 }
Beispiel #2
0
        public static EDOModel createDefault(bool minimum = false)
        {
            EDOModel  data   = new EDOModel();
            StudyUnit study1 = StudyUnit.CreateDefault(minimum);

            data.StudyUnits.Add(study1);
            return(data);
        }
Beispiel #3
0
 public UndoManager()
 {
     infos = new List<UndoInfo>();
     curIndex = -1;
     curModel = null;
     stateProvider = null;
     IsEnabled = true;
     transactions = new List<UndoTransaction>();
 }
        public SelectStudyUnitWindowVM(EDOModel fromModel, EDOModel toModel, StudyUnit curStudyUnit, DDIImportOption importOption)
        {
            this.fromModel = fromModel;
            this.toModel = toModel;
            fromStudyUnits = new ObservableCollection<StudyUnit>(fromModel.StudyUnits);
            this.FromStudyUnit = fromModel.StudyUnits.FirstOrDefault();
            toStudyUnits = new ObservableCollection<StudyUnit>(toModel.StudyUnits);
            this.ToStudyUnit = curStudyUnit;

            this.importOption = importOption;
        }
 public static bool ImportDDI(StudyUnitVM studyUnit, EDOModel edoModel)
 {
     FileDialogResult result = IOUtils.QueryOpenPathNameEx(DDI_FILE_FILTER);
     if (result == null)
     {
         return false;
     }
     if (result.FilterIndex == DDI3_FILTER_INDEX)
     {
         DDI3Reader reader = new DDI3Reader();
         return reader.Read(studyUnit, edoModel, result.FileName);
     }
     else if (result.FilterIndex == DDI2_FILTER_INDEX)
     {
         DDI2Reader reader = new DDI2Reader();
         return reader.Read(studyUnit, edoModel, result.FileName);
     }
     return false;
 }
Beispiel #6
0
        public bool Read(StudyUnitVM curStudyUnit, EDOModel curEdoModel, string path)
        {
            Debug.Assert(!string.IsNullOrEmpty(path));
            if (!Validate(path))
            {
                return false;
            }

            EDOModel newEdoModel = null;
            ClearError();
            XmlReaderSettings settings = new XmlReaderSettings();
            using (XmlReader reader = XmlReader.Create(path, settings))
            {
                XDocument doc = XDocument.Load(reader);
                XElement codebookElem = doc.Element(cb + TAG_CODEBOOK);
                if (codebookElem != null)
                {
                    newEdoModel = CreateSingleModel(codebookElem);
                }
            }
            if (newEdoModel == null)
            {
                return false;
            }

            DDI2ImportOption importOption = new DDI2ImportOption();
            SelectStudyUnitWindowVM vm = new SelectStudyUnitWindowVM(newEdoModel, curEdoModel, curStudyUnit.StudyUnitModel, importOption);
            SelectStudyUnitWindow window = new SelectStudyUnitWindow(vm);
            window.Owner = Application.Current.MainWindow;
            bool? result = window.ShowDialog();
            if (result != true)
            {
                return false;
            }
            StudyUnit fromStudyUnit = newEdoModel.StudyUnits[0];
            StudyUnit toStudyUnit = curEdoModel.StudyUnits[0];
            MergeStudyUnit(fromStudyUnit, toStudyUnit, vm.ImportOption);
            return true;
        }
Beispiel #7
0
        public UndoInfo Undo()
        {
            if (!CanUndo)
            {
                return null;
            }
            Debug.Assert(curIndex > 0);
            curIndex--;

            UndoInfo info = infos[curIndex].Copy();
            curModel = info.Model;
            return info;
        }
Beispiel #8
0
        private static void InitCompareTable(XElement comparisonElem, EDOModel model)
        {
            IEnumerable<XElement> conceptMapElems = comparisonElem.Elements(cm + TAG_CONCEPT_MAP);
            List<CompareItem> conceptSchemeItems = new List<CompareItem>();
            List<CompareItem> conceptItems = new List<CompareItem>();
            List<CompareItem> variableItems = new List<CompareItem>();
            foreach (XElement conceptMapElem in conceptMapElems)
            {
                CompareItem compareItem = CreateConceptSchemeCompareItem(conceptMapElem, model.StudyUnits);
                if (compareItem != null)
                {
                    conceptSchemeItems.Add(compareItem);
                }
                IEnumerable<XElement> itemMapElems = conceptMapElem.Elements(cm + TAG_ITEM_MAP);
                foreach (XElement itemMapElem in itemMapElems)
                {
                    CompareItem conceptItem = CreateConceptCompareItem(itemMapElem, model.StudyUnits);
                    if (conceptItem != null)
                    {
                        conceptItems.Add(conceptItem);
                    }
                }
            }
            IEnumerable<XElement> variableMapElems = comparisonElem.Elements(cm + TAG_VARIABLE_MAP);
            foreach (XElement variableMapElem in variableMapElems)
            {
                IEnumerable<XElement> itemMapElems = variableMapElem.Elements(cm + TAG_ITEM_MAP);
                foreach (XElement itemMapElem in itemMapElems)
                {
                    CompareItem variableItem = CreateVariableCompareItem(itemMapElem, model.StudyUnits);
                    if (variableItem != null)
                    {
                        variableItems.Add(variableItem);
                    }
                }
            }

            ICollection<CompareRow> conceptSchemeCompareRows = CreateCompareRows(conceptSchemeItems);
            model.Group.ConceptSchemeCompareTable.Rows.AddRange(conceptSchemeCompareRows);
            ICollection<CompareRow> conceptCompareRows = CreateCompareRows(conceptItems);
            model.Group.ConceptCompareTable.Rows.AddRange(conceptCompareRows);
            ICollection<CompareRow> variableCompareRows = CreateCompareRows(variableItems);
            model.Group.VariableCompareTable.Rows.AddRange(variableCompareRows);
        }
Beispiel #9
0
 public void Init(EDOModel edoModel, IStatefullVM stateProvider)
 {
     this.curModel = edoModel;
     this.stateProvider = stateProvider;
     curIndex = -1;
     IsEnabled = true;
     infos.Clear();
     transactions.Clear();
     Memorize();
 }
Beispiel #10
0
 public UndoInfo Redo()
 {
     if (!CanRedo)
     {
         return null;
     }
     Debug.Assert(curIndex < infos.Count - 1);
     curIndex++;
     UndoInfo info = infos[curIndex].Copy();
     curModel = info.Model;
     return info;
 }
Beispiel #11
0
 public void OpenStudyUnit()
 {
     StudyUnit studyUnit = EDOSerializer.LoadStudyUnit();
     if (studyUnit == null) {
         return;
     }
     EDOModel newEdoModel = new EDOModel();
     newEdoModel.StudyUnits.Add(studyUnit);
     createViewModels(newEdoModel);
 }
Beispiel #12
0
        private void createViewModels(EDOModel newEdoModel)
        {
            if (newEdoModel == null)
            {
                return;
            }
            edoUnits.Clear();
            this.edoModel = newEdoModel;
            if (edoModel.Group != null)
            {
                edoUnits.Add(createGroup(edoModel.Group));
            }
            foreach (StudyUnit studyUnit in edoModel.StudyUnits)
            {
                edoUnits.Add(createStudyUnit(studyUnit));
            }
            this.SelectedItem = this.DefaultSelectedItem;
            this.IsCategory = false;
            this.IsCode = false;

            //createStudyUnitでStudyUnitのタイトルが変わったりするので念のため
            //ハッシュを保存するのはこのメソッドの最後で行う。
            loadHash = EDOSerializer.ComputeHash(newEdoModel);
        }
Beispiel #13
0
 public UndoInfo(EDOModel edoModel, VMState state)
 {
     this.edoModel = edoModel;
     this.state = state;
 }
Beispiel #14
0
 private static void InitGroup(XElement groupElem, EDOModel model)
 {
     string id = (string)groupElem.Attribute(ATTR_ID);
     if (id == null)
     {
         return;
     }
     Group group = Group.CreateDefault();
     model.Group = group;
     group.Id = id;
     group.DataSetCode = (string)groupElem.Attribute(ATTR_DATA_SET);
     group.GeographyCode = (string)groupElem.Attribute(ATTR_GEOGRAPHY);
     group.InstrumentCode = (string)groupElem.Attribute(ATTR_INSTRUMENT);
     group.LanguageCode = (string)groupElem.Attribute(ATTR_LANGUAGE);
     group.PanelCode = (string)groupElem.Attribute(ATTR_PANEL);
     group.TimeCode = (string)groupElem.Attribute(ATTR_TIME);
     XElement purposeElem = groupElem.Element(g + TAG_PURPOSE);
     if (purposeElem != null)
     {
         group.PurposeId = (string)purposeElem.Attribute(ATTR_ID);
         group.Purpose = (string)purposeElem.Element(r + TAG_CONTENT);
     }
     XElement comparisonElem = groupElem.Element(cm + TAG_COMPARISON);
     if (comparisonElem != null)
     {
         InitCompareTable(comparisonElem, model);
     }
 }
Beispiel #15
0
        public bool Read(StudyUnitVM curStudyUnit, EDOModel curEdoModel, string path)
        {
            Debug.Assert(!string.IsNullOrEmpty(path));
            if (!Validate(path))
            {
                return false;
            }

            EDOModel newEdoModel = null;

            ClearError();
            XmlReaderSettings settings = new XmlReaderSettings();
            using (XmlReader reader = XmlReader.Create(path, settings))
            {
                XDocument doc = XDocument.Load(reader);
                XElement groupElem = doc.Descendants(g + TAG_GROUP).FirstOrDefault();
                if (groupElem != null)
                {
                    newEdoModel = CreateGroupModel(groupElem);
                }
                else
                {
                    XElement studyUnitElem = doc.Descendants(s + TAG_STUDY_UNIT).FirstOrDefault();
                    if (studyUnitElem != null)
                    {
                        newEdoModel = CreateSingleModel(studyUnitElem);
                    }
                }
            }
            if (newEdoModel == null)
            {
                return false;
            }
            DDI3ImportOption importOption = new DDI3ImportOption();
            SelectStudyUnitWindowVM vm = new SelectStudyUnitWindowVM(newEdoModel, curEdoModel, curStudyUnit.StudyUnitModel, importOption);
            SelectStudyUnitWindow window = new SelectStudyUnitWindow(vm);
            window.Owner = Application.Current.MainWindow;
            bool? result = window.ShowDialog();
            if (result != true)
            {
                return false;
            }
            MergeStudyUnit(vm.FromStudyUnit, vm.ToStudyUnit, vm.ImportOption);
            return true;
        }
Beispiel #16
0
 private static EDOModel CreateSingleModel(XElement studyUnitElem)
 {
     EDOModel model = new EDOModel();
     StudyUnit studyUnit = CreateStudyUnit(studyUnitElem);
     if (studyUnit != null)
     {
         model.StudyUnits.Add(studyUnit);
     }
     return model;
 }
Beispiel #17
0
 private static EDOModel CreateGroupModel(XElement groupElem)
 {
     EDOModel model = new EDOModel();
     IEnumerable<XElement> elements = groupElem.Descendants(s + TAG_STUDY_UNIT);
     foreach (XElement studyUnitElem in elements)
     {
         StudyUnit studyUnit = CreateStudyUnit(studyUnitElem);
         if (studyUnit != null)
         {
             if (Group.IsSharedStudyUnit(studyUnit))
             {
                 model.Group.SharedStudyUnit = studyUnit;
             }
             else
             {
                 model.StudyUnits.Add(studyUnit);
             }
         }
     }
     InitGroup(groupElem, model);
     return model;
 }