public ConceptSchemeVM(ConceptScheme conceptScheme)
 {
     this.conceptScheme = conceptScheme;
     concepts = new ObservableCollection<ConceptVM>();
     foreach (Concept conceptModel in conceptScheme.Concepts) {
         ConceptVM conceptVM = new ConceptVM(conceptModel);
         conceptVM.Parent = this;
         concepts.Add(conceptVM);
     }
     modelSyncher = new ModelSyncher<ConceptVM, Concept>(this, concepts, conceptScheme.Concepts);
     string message = Properties.Resources.ConceptFormHelpMessage1;
     TestMessage = message;
 }
Exemple #2
0
 public ConceptScheme FindConceptSchemeByConceptId(string conceptId)
 {
     return(ConceptScheme.FindConceptSchemeByConceptId(ConceptSchemes, conceptId));
 }
Exemple #3
0
 public Concept FindConcept(string conceptId)
 {
     return(ConceptScheme.FindConcept(ConceptSchemes, conceptId));
 }
Exemple #4
0
 public ConceptScheme FindConceptScheme(string conceptSchemeId)
 {
     return(ConceptScheme.FindConceptScheme(ConceptSchemes, conceptSchemeId));
 }
Exemple #5
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;
        }
Exemple #6
0
 private ConceptScheme CloneConceptScheme(ConceptScheme orgConceptScheme)
 {
     ConceptScheme newConceptScheme = (ConceptScheme)orgConceptScheme.Clone();
     newConceptScheme.Id = IDUtils.NewGuid();
     newConceptScheme.Concepts = new List<Concept>();
     return newConceptScheme;
 }
Exemple #7
0
        public static ConceptScheme CreateConceptScheme(XElement conceptSchemeElem)
        {
            string id = (string)conceptSchemeElem.Attribute(ATTR_ID);
            if (id == null)
            {
                return null;
            }
            ConceptScheme conceptSchemeModel = new ConceptScheme();
            conceptSchemeModel.Id = id;
            conceptSchemeModel.Title = (string)conceptSchemeElem.Element(r + TAG_LABEL);
            conceptSchemeModel.Memo = (string)conceptSchemeElem.Element(r + TAG_DESCRIPTION);

            IEnumerable<XElement> elements = conceptSchemeElem.Descendants(c + TAG_CONCEPT);
            foreach (XElement conceptElem in elements)
            {
                string conceptId = (string)conceptElem.Attribute(ATTR_ID);
                if (conceptId == null)
                {
                    continue;
                }
                Concept conceptModel = new Concept();
                conceptModel.Id = conceptId;
                conceptModel.Title = (string)conceptElem.Element(r + TAG_LABEL);
                conceptModel.Content = (string)conceptElem.Element(r + TAG_DESCRIPTION);
                conceptSchemeModel.Concepts.Add(conceptModel);
            }
            return conceptSchemeModel;
        }
Exemple #8
0
 private string JoinConceptIds(ConceptScheme conceptScheme)
 {
     List<string> ids = Concept.GetIds(conceptScheme.Concepts);
     List<string> safeIds = new List<string>();
     foreach (string id in ids)
     {
         safeIds.Add(ConvertId(id));
     }
     return string.Join(" ", safeIds);
 }
Exemple #9
0
        private static void CreateConceptSchemes(XElement codebookElem, StudyUnit studyUnit, ReaderContext context)
        {
            XElement dataDscrElem = codebookElem.Element(cb + TAG_DATA_DSCR);
            if (dataDscrElem == null)
            {
                return;
            }

            Dictionary<string, List<string>> conceptIds = new Dictionary<string, List<string>>();

            List<ConceptScheme> allConceptSchemes = new List<ConceptScheme>();
            List<Concept> allConcepts = new List<Concept>();

            IEnumerable<XElement> varGrpElems = dataDscrElem.Elements(cb + TAG_VAR_GRP);
            foreach (XElement varGrpElem in varGrpElems)
            {
                string varGrpStr = (string)varGrpElem.Attribute(ATTR_VAR_GRP);
                if (!string.IsNullOrEmpty(varGrpStr))
                {
                    //大分類(ConceptScheme)
                    ConceptScheme conceptScheme = new ConceptScheme();
                    allConceptSchemes.Add(conceptScheme);

                    conceptScheme.Title = (string)varGrpElem.Element(cb + TAG_CONCEPT);
                    conceptScheme.Memo = (string)varGrpElem.Element(cb + TAG_DEFNTH);

                    List<string> ids = SplitIds(varGrpStr);
                    conceptIds[conceptScheme.Id] = ids;
                }
                else
                {
                    string id = (string)varGrpElem.Attribute(ATTR_ID);
                    if (!string.IsNullOrEmpty(id))
                    {
                        //イメージ(Concept)
                        Concept concept = new Concept();
                        concept.Id = id;
                        concept.Title = (string)varGrpElem.Element(cb + TAG_CONCEPT);
                        concept.Content = (string)varGrpElem.Element(cb + TAG_DEFNTH);
                        allConcepts.Add(concept);

                        string varStr = (string)varGrpElem.Attribute(ATTR_VAR);
                        List<string> ids = SplitIds(varStr);
                        context.VarIds[concept.Id] = ids; //コンセプトごとの変数IDを記憶(変数読み込み時に変数にconceptIdを設定するのに使う)
                    }
                }
            }

            foreach (ConceptScheme conceptScheme in allConceptSchemes)
            {
                List<string> ids = conceptIds[conceptScheme.Id];
                conceptScheme.Concepts = Concept.FindAll(allConcepts, ids);
            }

            if (allConceptSchemes.Count > 0)
            {
                studyUnit.ConceptSchemes = allConceptSchemes;
            }
        }