Ejemplo n.º 1
0
        public List <Code> FindCodes(string codeSchemeId)
        {
            CodeScheme codeScheme = FindCodeScheme(codeSchemeId);

            if (codeScheme == null)
            {
                return(new List <Code>());
            }
            return(codeScheme.Codes);
        }
Ejemplo n.º 2
0
 public CodeSchemeVM(CodeScheme codeScheme, ObservableCollection<CodeVM> codes)
 {
     this.codeScheme = codeScheme;
     this.codes = codes;
     foreach (CodeVM code in codes)
     {
         code.Parent = this;
     }
     modelSyncher = new ModelSyncher<CodeVM, Code>(this, codes, codeScheme.Codes);
     modelSyncher.AddActionHandler = (param) => {
         param.CodeSchemeId = codeScheme.Id;
     };
 }
Ejemplo n.º 3
0
        public void CreateBinaryCodeScheme()
        {
            if (FindBinaryCodeScheme != null)
            {
                return;
            }

            CodeScheme codeScheme = new CodeScheme();

            codeScheme.Title = Resources.SelectUnselect;

            CategoryScheme categoryScheme = new CategoryScheme();

            categoryScheme.Title = codeScheme.Title;

            Category selectedCategory = new Category();

            selectedCategory.Title            = Resources.Select;
            selectedCategory.CategorySchemeId = categoryScheme.Id;

            Category unselectedCategory = new Category();

            unselectedCategory.Title            = Resources.Unselect;
            unselectedCategory.CategorySchemeId = categoryScheme.Id;

            categoryScheme.Categories.Add(selectedCategory);
            categoryScheme.Categories.Add(unselectedCategory);

            Code selectedCode = new Code();

            selectedCode.Value        = EDOConstants.SELECTED_CODE_VALUE;
            selectedCode.CategoryId   = selectedCategory.Id;
            selectedCode.CodeSchemeId = codeScheme.Id;
            codeScheme.Codes.Add(selectedCode);

            Code unselectedCode = new Code();

            unselectedCode.Value        = EDOConstants.UNSELECTED_CODE_VALUE;
            unselectedCode.CategoryId   = unselectedCategory.Id;
            unselectedCode.CodeSchemeId = codeScheme.Id;
            codeScheme.Codes.Add(unselectedCode);


            CategorySchemes.Insert(0, categoryScheme);
            CodeSchemes.Insert(0, codeScheme);

            BinaryCodeSchemeId     = codeScheme.Id;
            BinaryCategorySchemeId = categoryScheme.Id;
        }
Ejemplo n.º 4
0
 private XElement CreateCodeScheme(CodeScheme codeSchemeModel)
 {
     //l:CodeScheme
     XElement codeScheme = new XElement(l + TAG_CODE_SCHEME,
         CreateIDAttribute(codeSchemeModel.Id),
         CreateVersionAttribute(),
         CreateAgencyAttribute(),
         CreateLabel(codeSchemeModel.Title),//r:Label*
         CreateNullableDescription(codeSchemeModel.Memo)); //r:Description*,
     //Code*
     foreach (Code codeModel in codeSchemeModel.Codes)
     {
         XElement code = new XElement(l + TAG_CODE,
             CreateReferenceID(l + TAG_CATEGORY_REFERENCE, codeModel.CategoryId, CategorySchemeId(codeModel.CategoryId)), //CategoryReference
             new XElement(l + TAG_VALUE, codeModel.Value)); //Value
         codeScheme.Add(code);
     }
     return codeScheme;
 }
Ejemplo n.º 5
0
 public CodeScheme FindCodeScheme(string codeSchemeId)
 {
     return(CodeScheme.Find(CodeSchemes, codeSchemeId));
 }
Ejemplo n.º 6
0
        public bool Read(string path, StudyUnitVM studyUnit)
        {
            Debug.Assert(!string.IsNullOrEmpty(path));
            StudyUnit studyUnitModel = studyUnit.StudyUnitModel;
            FileStream stream = File.OpenRead(path);
            SavFileParser parser = new SavFileParser(stream);
            List<Variable> variables = new List<Variable>();
            foreach (SpssLib.SpssDataset.Variable v in parser.Variables)
            {
                Variable variable = new Variable();
                variable.Title = v.Name;
                variable.Label = v.Label;
                variables.Add(variable);
                if (v.Type == SpssLib.SpssDataset.DataType.Text)
                {
                    variable.Response.TypeCode = Options.RESPONSE_TYPE_FREE_CODE;
                }
                else
                {
                    if (v.ValueLabels.Count > 0)
                    {
                        CategoryScheme categoryScheme = new CategoryScheme();
                        categoryScheme.Title = v.Label;
                        studyUnitModel.CategorySchemes.Add(categoryScheme);
                        CodeScheme codeScheme = new CodeScheme();
                        codeScheme.Title = v.Label; ;
                        studyUnitModel.CodeSchemes.Add(codeScheme);

                        variable.Response.TypeCode = Options.RESPONSE_TYPE_CHOICES_CODE;
                        variable.Response.CodeSchemeId = codeScheme.Id;
                        // 選択肢の作成
                        foreach (KeyValuePair<double, string> pair in v.ValueLabels)
                        {
                            Category category = new Category();
                            categoryScheme.Categories.Add(category);
                            category.Title = pair.Value;
                            category.CategorySchemeId = categoryScheme.Id;

                            Code code = new Code();
                            codeScheme.Codes.Add(code);
                            code.CategoryId = category.Id;
                            code.CodeSchemeId = codeScheme.Id;
                            code.Value = pair.Key.ToString();
                        }
                        // 欠損値の追加
                        if (v.MissingValues.Count > 0)
                        {
                            foreach (double missingValue in v.MissingValues)
                            {
                                string missingValueStr = missingValue.ToString();
                                if (ExistValue(codeScheme, missingValueStr))
                                {
                                    continue;
                                }
                                Category category = new Category();
                                categoryScheme.Categories.Add(category);
                                category.Title = Resources.MissingValue; //欠損値
                                category.IsMissingValue = true;
                                category.CategorySchemeId = categoryScheme.Id;

                                Code code = new Code();
                                codeScheme.Codes.Add(code);
                                code.CategoryId = category.Id;
                                code.CodeSchemeId = codeScheme.Id;
                                code.Value = missingValueStr;
                            }
                        }
                    }
                    else
                    {
                        variable.Response.TypeCode = Options.RESPONSE_TYPE_NUMBER_CODE;
                    }
                }
            }

            if (variables.Count > 0)
            {
                ConceptScheme conceptScheme = new ConceptScheme();
                conceptScheme.Title = EDOUtils.UniqueLabel(ConceptScheme.GetTitles(studyUnitModel.ConceptSchemes), Resources.ImportVariable); //インポートした変数
                string name = Path.GetFileName(path);
                conceptScheme.Memo = EDOUtils.UniqueLabel(ConceptScheme.GetMemos(studyUnitModel.ConceptSchemes), string.Format(Resources.ImportVariableFrom, name)); //{0}からインポートした変数

                Concept concept = new Concept();
                concept.Title = EDOUtils.UniqueLabel(ConceptScheme.GetConceptTitles(studyUnitModel.ConceptSchemes), Resources.ImportVariable);//インポートした変数
                concept.Content = EDOUtils.UniqueLabel(ConceptScheme.GetConceptContents(studyUnitModel.ConceptSchemes), string.Format(Resources.ImportVariableFrom, name));//{0}からインポートした変数
                conceptScheme.Concepts.Add(concept);
                studyUnitModel.ConceptSchemes.Add(conceptScheme);

                foreach (Variable variable in variables)
                {
                    Question question = new Question();
                    question.Title = variable.Label;
                    question.ConceptId = concept.Id;
                    question.Response.TypeCode = variable.Response.TypeCode;
                    question.Response.CodeSchemeId = variable.Response.CodeSchemeId;
                    studyUnitModel.Questions.Add(question);

                    variable.ConceptId = concept.Id;
                    variable.QuestionId = question.Id;
                    studyUnitModel.Variables.Add(variable);

                }
            }
            return true;
        }
Ejemplo n.º 7
0
 public CodeSchemeVM(CodeScheme codeScheme)
     : this(codeScheme, new ObservableCollection<CodeVM>())
 {
 }
Ejemplo n.º 8
0
 private CodeScheme CloneCodeScheme(CodeScheme codeScheme)
 {
     CodeScheme newCodeScheme = (CodeScheme)codeScheme.Clone();
     newCodeScheme.Id = IDUtils.NewGuid();
     newCodeScheme.Codes = new List<Code>();
     foreach (Code code in codeScheme.Codes)
     {
         Code newCode = (Code)code.Clone();
         newCode.CodeSchemeId = newCodeScheme.Id;
         newCodeScheme.Codes.Add(newCode);
     }
     return newCodeScheme;
 }
Ejemplo n.º 9
0
 static bool ExistValue(CodeScheme codeScheme, string missingValue)
 {
     //とりあえずdoubleの文字列表現で比較(εで比較する必要があるかも)。
     string missingValueStr = missingValue.ToString();
     foreach (Code existCode in codeScheme.Codes)
     {
         if (existCode.Value == missingValueStr)
         {
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 10
0
        public static CodeScheme CreateCodeScheme(XElement codeSchemeElem)
        {
            string id = (string)codeSchemeElem.Attribute(ATTR_ID);
            if (id == null)
            {
                return null;
            }
            CodeScheme codeSchemeModel = new CodeScheme();
            codeSchemeModel.Id = id;
            codeSchemeModel.Title = (string)codeSchemeElem.Element(r + TAG_LABEL);
            codeSchemeModel.Memo = (string)codeSchemeElem.Element(r + TAG_DESCRIPTION);

            IEnumerable<XElement> elements = codeSchemeElem.Elements(l + TAG_CODE);
            foreach (XElement codeElem in elements)
            {
                //string codeId = (string)codeElem.Attribute(ATTR_ID);
                //if (codeId == null)
                //{
                //    continue;
                //}
                Code codeModel = new Code();
                //codeModel.Id = codeId;
                codeModel.CategoryId = ReadReferenceID(codeElem, l + TAG_CATEGORY_REFERENCE);
                codeModel.Value = (string)codeElem.Element(l + TAG_VALUE);
                codeSchemeModel.Codes.Add(codeModel);
            }

            return codeSchemeModel;
        }
Ejemplo n.º 11
0
 private CodeSchemeVM CreateCodeScheme(CodeScheme codeSchemeModel)
 {
     ObservableCollection<CodeVM> codes = new ObservableCollection<CodeVM>();
     foreach (Code codeModel in codeSchemeModel.Codes)
     {
         CategoryVM category = StudyUnit.FindCategory(codeModel.CategoryId);
         CodeVM code = new CodeVM(codeModel, category);
         codes.Add(code);
     }
     CodeSchemeVM codeScheme = new CodeSchemeVM(codeSchemeModel, codes)
     {
         Parent = this
     };
     return codeScheme;
 }
Ejemplo n.º 12
0
 public void AddCodeScheme()
 {
     InputDialog dlg = new InputDialog();
     dlg.Title = Resources.InputCodeSchemeName; // コード群の名前を入力してください;
     dlg.Info = Resources.CodeFormHelpMessage; //※コード群作成後は、「選択肢群から追加」、「選択肢を追加」ボタンを押してコードを割り当ててください。;
     dlg.Owner = Application.Current.MainWindow;
     dlg.ShowDialog();
     if (dlg.DialogResult == true)
     {
         CodeScheme codeSchemeModel = new CodeScheme() {Title = dlg.textBox.Text};
         CodeSchemeVM newCodeScheme = new CodeSchemeVM(codeSchemeModel);
         codeSchemes.Add(newCodeScheme);
         if (SelectedCodeScheme == null)
         {
             SelectedCodeScheme = newCodeScheme;
         }
         Memorize();
     }
 }
Ejemplo n.º 13
0
        private static CategorySchemeItem CreateCategorySchemeItem(XElement varElem, Variable variable)
        {
            XElement catgryGrpElem = varElem.Element(cb + TAG_CATGRY_GRP);
            if (catgryGrpElem == null)
            {
                return null;
            }
            string title = (string)catgryGrpElem.Element(cb + TAG_LABL);
            if (string.IsNullOrEmpty(title))
            {
                return null;
            }
            string memo = (string)catgryGrpElem.Element(cb + TAG_TXT);
            CategoryScheme categoryScheme = new CategoryScheme()
            {
                Title = title,
                Memo = memo
            };
            CodeScheme codeScheme = new CodeScheme()
            {
                Title = title,
                Memo = memo
            };
            IEnumerable<XElement> catgryElems = varElem.Elements(cb + TAG_CATGRY);
            foreach (XElement catgryElem in catgryElems)
            {
                title = (string)catgryElem.Element(cb + TAG_LABL);
                memo = (string)catgryElem.Element(cb + TAG_TXT);
                string v = (string)catgryElem.Element(cb + TAG_CAT_VALU);

                Category category = new Category() {
                    Title = title,
                    Memo = memo
                };
                category.CategorySchemeId = categoryScheme.Id;
                categoryScheme.Categories.Add(category);

                Code code = new Code()
                {
                    Value = v
                };
                code.CodeSchemeId = codeScheme.Id;
                code.CategoryId = category.Id;
                codeScheme.Codes.Add(code);
            }
            variable.Response.CodeSchemeId = codeScheme.Id;
            return new CategorySchemeItem(categoryScheme, codeScheme);
        }
Ejemplo n.º 14
0
 public CategorySchemeItem(CategoryScheme categoryScheme, CodeScheme codeScheme)
 {
     CategoryScheme = categoryScheme;
     CodeScheme = codeScheme;
 }