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; }
public CategorySchemeVM(CategoryScheme categoryScheme) { this.categoryScheme = categoryScheme; categories = new ObservableCollection<CategoryVM>(); foreach (Category categoryModel in categoryScheme.Categories) { CategoryVM category = new CategoryVM(categoryModel); category.Parent = this; categories.Add(category); } modelSyncher = new ModelSyncher<CategoryVM, Category>(this, categories, categoryScheme.Categories); modelSyncher.AddActionHandler = (param) => { param.CategorySchemeId = Id; }; }
private XElement CreateCategoryScheme(CategoryScheme categorySchemeModel) { //l:CategoryScheme XElement categoryScheme = new XElement(l + TAG_CATEGORY_SCHEME, CreateIDAttribute(categorySchemeModel.Id), CreateVersionAttribute(), CreateAgencyAttribute(), CreateLabel(categorySchemeModel.Title), //r:Label* CreateNullableDescription(categorySchemeModel.Memo));// r:Description* //l:Category* foreach (Category categoryModel in categorySchemeModel.Categories) { XAttribute missing = null; if (categoryModel.IsMissingValue) { missing = new XAttribute(ATTR_MISSING, "1"); } XElement category = new XElement(l + TAG_CATEGORY, CreateIDAttribute(categoryModel.Id), missing, CreateLabel(categoryModel.Title),//r:Label* CreateNullableDescription(categoryModel.Memo));// r:Description* categoryScheme.Add(category); } return categoryScheme; }
public CategoryScheme FindCategorySchemeByCategoryId(string categoryId) { return(CategoryScheme.FindByCategoryId(CategorySchemes, categoryId)); }
public CategoryScheme FindCategoryScheme(string categorySchemeId) { return(CategoryScheme.Find(CategorySchemes, categorySchemeId)); }
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; }
private CategoryScheme CloneCategoryScheme(CategoryScheme categoryScheme) { CategoryScheme newCategoryScheme = (CategoryScheme)categoryScheme.Clone(); newCategoryScheme.Id = IDUtils.NewGuid(); newCategoryScheme.Categories = new List<Category>(); return newCategoryScheme; }
public static CategoryScheme CreateCategoryScheme(XElement categorySchemeElem) { string id = (string)categorySchemeElem.Attribute(ATTR_ID); if (id == null) { return null; } CategoryScheme categorySchemeModel = new CategoryScheme(); categorySchemeModel.Id = id; categorySchemeModel.Title = (string)categorySchemeElem.Element(r + TAG_LABEL); categorySchemeModel.Memo = (string)categorySchemeElem.Element(r + TAG_DESCRIPTION); IEnumerable<XElement> elements = categorySchemeElem.Elements(l + TAG_CATEGORY); foreach (XElement categoryElem in elements) { string categoryId = (string)categoryElem.Attribute(ATTR_ID); if (categoryId == null) { continue; } Category categoryModel = new Category(); if (IsAttrMissingValid((string)categoryElem.Attribute(ATTR_MISSING))) { categoryModel.IsMissingValue = true; } categoryModel.Id = categoryId; categoryModel.Title = (string)categoryElem.Element(r + TAG_LABEL); categoryModel.Memo = (string)categoryElem.Element(r + TAG_DESCRIPTION); categorySchemeModel.Categories.Add(categoryModel); } return categorySchemeModel; }
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); }
public CategorySchemeItem(CategoryScheme categoryScheme, CodeScheme codeScheme) { CategoryScheme = categoryScheme; CodeScheme = codeScheme; }
public void AddCategoryScheme() { InputDialog dlg = new InputDialog(); dlg.Title = Resources.InputCategorySchemeName; //選択肢群の名前を入力してください dlg.Owner = Application.Current.MainWindow; dlg.ShowDialog(); if (dlg.DialogResult == true) { CategoryScheme categorySchemeModel = new CategoryScheme() { Title = dlg.textBox.Text }; CategorySchemeVM categoryScheme = new CategorySchemeVM(categorySchemeModel); categorySchemes.Add(categoryScheme); if (SelectedCategoryScheme == null) { SelectedCategoryScheme = categoryScheme; } Memorize(); } }