public ControlConstructSchemeVM(ControlConstructScheme controlConstructScheme) { this.controlConstructScheme = controlConstructScheme; constructModels = new List<IConstruct>(); constructs = new ObservableCollection<ConstructVM>(); //モデルでは、質問文、説明文、分岐それぞれの配列として保持している。 //VMでは全てを抽象クラスのコレクションとして保持している。 //このため他の画面のようにModelSyncherは使えない。操作するごとにUpdateModelを呼び出す。 }
/// <summary> /// デフォルト設定を適用したStudyUnitを作成します。minimunをtrueにすると、最低限の設定のみを行ったStudyUnitを返します。 /// </summary> /// <param name="minimum">設定を最低限にするかどうか</param> /// <returns>デフォルト設定を適用したStudyUnit</returns> public static StudyUnit CreateDefault(bool minimum = false) { StudyUnit studyUnit = new StudyUnit(); int i = 1; if (!minimum) { foreach (Option option in Options.EventTypes) { studyUnit.Events.Add(new Event() { Title = option.Label, No = i++ }); } studyUnit.FundingInfos.Add(new FundingInfo()); studyUnit.Samplings.Add(new Sampling()); studyUnit.ConceptSchemes.Add(new ConceptScheme()); ControlConstructScheme scheme = new ControlConstructScheme(); studyUnit.ControlConstructSchemes.Add(scheme); studyUnit.DefaultControlConstructSchemeId = scheme.Id; DataSet dataSet = new DataSet(); dataSet.Title = EDOConstants.LABEL_ALL; dataSet.Memo = Resources.AllDataSet; //All variables studyUnit.DefaultDataSetId = dataSet.Id; studyUnit.DataSets.Add(dataSet); dataSet.IsCreatedDataFile = true; DataFile dataFile = DataFile.createDataFile(); dataFile.DataSetId = dataSet.Id; studyUnit.DataFiles.Add(dataFile); studyUnit.CreateBinaryCodeScheme(); } studyUnit.Coverage = Coverage.CreateDefault(); return(studyUnit); }
private XElement CreateControlConstructSchemes(ControlConstructScheme schemeModel) { //d:ControlConstructScheme if (!schemeModel.HasConstruct) { return null; } XElement scheme = new XElement(d + TAG_CONTROL_CONSTRUCT_SCHEME, CreateIDAttribute(schemeModel.Id), CreateVersionAttribute(), CreateAgencyAttribute(), CreateNullable(d + TAG_CONTROL_CONSTRUCT_SCHEME_NAME, schemeModel.Title) //ControlConstructSchemeName* ); //d:ControlConstruct+ //d:QuestionConstruct 質問 foreach (QuestionConstruct constructModel in schemeModel.QuestionConstructs) { XElement questionConstruct = new XElement(d + TAG_QUESTION_CONSTRUCT, CreateIDAttribute(constructModel.Id), CreateNullable(r + TAG_LABEL, constructModel.No), //r:Label* CreateReferenceID(d + TAG_QUESTION_REFERENCE, constructModel.QuestionId, QuestionSchemeId()) //QuestionReference ); scheme.Add(questionConstruct); } //質問グループ foreach (QuestionGroupConstruct constructModel in schemeModel.QuestionGroupConstructs) { XElement questionConstruct = new XElement(d + TAG_QUESTION_CONSTRUCT, CreateIDAttribute(constructModel.Id), CreateNullable(r + TAG_LABEL, constructModel.No), //r:Label* CreateReferenceID(d + TAG_QUESTION_REFERENCE, constructModel.QuestionGroupId, QuestionSchemeId()) //QuestionReference ); scheme.Add(questionConstruct); } //d:StatementItem 説明文 foreach (Statement statementModel in schemeModel.Statements) { XElement statement = new XElement(d + TAG_STATEMENT_ITEM, CreateIDAttribute(statementModel.Id), new XElement(r + TAG_LABEL, statementModel.No),//r:Label* new XElement(d + TAG_DISPLAY_TEXT,// DisplayText+ new XElement(d + TAG_LITERAL_TEXT, //LiteralText+ new XElement(d + TAG_TEXT, statementModel.Text))) //Text+ ); scheme.Add(statement); } //d:IfThenElse 分岐 foreach (IfThenElse ifThenElseModel in schemeModel.IfThenElses) { XElement ifThenElse = new XElement(d + TAG_IF_THEN_ELSE, CreateIDAttribute(ifThenElseModel.Id)); scheme.Add(ifThenElse); //IfCondition XElement ifCondition = new XElement(d + TAG_IF_CONDITION, new XElement(r + TAG_CODE, ifThenElseModel.IfCondition.Code), //Code+ CreateReferenceID(r + TAG_SOURCE_QUESTION_REFERENCE, ifThenElseModel.IfCondition.QuestionId, QuestionSchemeId()) //SourceQuestionReference* ); ifThenElse.Add(ifCondition); //ThenConstructReference ifThenElse.Add(CreateReferenceID(d + TAG_THEN_CONSTRUCT_REFERENCE, ifThenElseModel.ThenConstructId, schemeModel.Id)); //ElseIf* foreach (ElseIf elseIfModel in ifThenElseModel.ElseIfs) { XElement elseIf = new XElement(d + TAG_ELSE_IF); ifThenElse.Add(elseIf); //IfCondition XElement elseIfCondition = new XElement(d + TAG_IF_CONDITION, new XElement(r + TAG_CODE, elseIfModel.IfCondition.Code), CreateReferenceID(r + TAG_SOURCE_QUESTION_REFERENCE, elseIfModel.IfCondition.QuestionId, QuestionSchemeId()) ); elseIf.Add(elseIfCondition); //ThenConstructReference elseIf.Add(CreateReferenceID(d + TAG_THEN_CONSTRUCT_REFERENCE, elseIfModel.ThenConstructId, schemeModel.Id)); } //ElseConstructReference? ifThenElse.Add(CreateReferenceID(d + TAG_ELSE_CONSTRUCT_REFERENCE, ifThenElseModel.ElseConstructId, schemeModel.Id)); } // Sequence 順序 XElement sequence = new XElement(d + TAG_SEQUENCE, CreateIDAttribute(schemeModel.Sequence.Id)); scheme.Add(sequence); foreach (string id in schemeModel.Sequence.ControlConstructIds) { //ControlConstructReference* XElement controlConstruct = CreateReferenceID(d + TAG_CONTROL_CONSTRUCT_REFERENCE, id, schemeModel.Id); sequence.Add(controlConstruct); } return scheme; }
public static ControlConstructScheme CreateControlConstructScheme(XElement controlConstructSchemeElem, StudyUnit studyUnit) { string id = (string)controlConstructSchemeElem.Attribute(ATTR_ID); if (id == null) { return null; } ControlConstructScheme controlConstructSchemeModel = new ControlConstructScheme(); controlConstructSchemeModel.Title = (string)controlConstructSchemeElem.Element(d + TAG_CONTROL_CONSTRUCT_SCHEME_NAME); IEnumerable<XElement> questionConstructElems = controlConstructSchemeElem.Elements(d + TAG_QUESTION_CONSTRUCT); foreach (XElement questionConstructElem in questionConstructElems) { string questionConstructId = (string)questionConstructElem.Attribute(ATTR_ID); if (questionConstructId == null) { continue; } string questionId = ReadReferenceID(questionConstructElem, d + TAG_QUESTION_REFERENCE); if (questionId == null) { continue; } string no = (string)questionConstructElem.Element(r + TAG_LABEL); if (no == null) { continue; } if (studyUnit.FindQuestion(questionId) != null) { QuestionConstruct questionConstruct = new QuestionConstruct(); questionConstruct.Id = questionConstructId; questionConstruct.No = no; questionConstruct.QuestionId = questionId; controlConstructSchemeModel.QuestionConstructs.Add(questionConstruct); } else if (studyUnit.FindQuestionGroup(questionId) != null) { QuestionGroupConstruct questionGroupConstruct = new QuestionGroupConstruct(); questionGroupConstruct.Id = questionConstructId; questionGroupConstruct.No = no; questionGroupConstruct.QuestionGroupId = questionId; controlConstructSchemeModel.QuestionGroupConstructs.Add(questionGroupConstruct); } } IEnumerable<XElement> statementItemElems = controlConstructSchemeElem.Elements(d + TAG_STATEMENT_ITEM); foreach (XElement statementItemElem in statementItemElems) { string statementId = (string)statementItemElem.Attribute(ATTR_ID); if (statementId == null) { continue; } string no = (string)statementItemElem.Attribute(r + TAG_LABEL); if (no == null) { continue; } Statement statement = new Statement(); statement.Id = statementId; statement.No = no; XElement textElem = statementItemElem.Descendants(d + TAG_TEXT).FirstOrDefault(); if (textElem != null) { statement.Text = textElem.Value; } controlConstructSchemeModel.Statements.Add(statement); } IEnumerable<XElement> ifThenElseElems = controlConstructSchemeElem.Elements(d + TAG_IF_THEN_ELSE); foreach (XElement ifThenElseElem in ifThenElseElems) { string ifThenElseId = (string)ifThenElseElem.Attribute(ATTR_ID); if (ifThenElseId == null) { continue; } XElement ifConditionElem = ifThenElseElem.Element(d + TAG_IF_CONDITION); if (ifConditionElem == null) { continue; } string thenConstructId = ReadReferenceID(ifThenElseElem, d + TAG_THEN_CONSTRUCT_REFERENCE); if (thenConstructId == null) { continue; } IfThenElse ifThenElse = new IfThenElse(); ifThenElse.Id = ifThenElseId; ifThenElse.No = ControlConstructScheme.IFTHENELSE_NO; ifThenElse.IfCondition.Code = (string)ifConditionElem.Element(r + TAG_CODE); ifThenElse.IfCondition.QuestionId = ReadReferenceID(ifConditionElem, r + TAG_SOURCE_QUESTION_REFERENCE); ifThenElse.ThenConstructId = thenConstructId; controlConstructSchemeModel.IfThenElses.Add(ifThenElse); IEnumerable<XElement> elseIfElems = ifThenElseElem.Elements(d + TAG_ELSE_IF); foreach (XElement elseIfElem in elseIfElems) { XElement ifConditionElem2 = elseIfElem.Element(d + TAG_IF_CONDITION); if (ifConditionElem2 == null) { continue; } string thenConstructId2 = ReadReferenceID(elseIfElem, d + TAG_THEN_CONSTRUCT_REFERENCE); if (thenConstructId2 == null) { continue; } ElseIf elseIf = new ElseIf(); elseIf.IfCondition.Code = (string)ifConditionElem2.Element(r + TAG_CODE); elseIf.IfCondition.QuestionId = ReadReferenceID(ifConditionElem2, r + TAG_SOURCE_QUESTION_REFERENCE); elseIf.ThenConstructId = thenConstructId2; ifThenElse.ElseIfs.Add(elseIf); } } XElement sequenceElem = controlConstructSchemeElem.Element(d + TAG_SEQUENCE); if (sequenceElem != null) { controlConstructSchemeModel.Sequence.Id = (string)sequenceElem.Attribute(ATTR_ID); IEnumerable<XElement> controlConstructReferenceElems = sequenceElem.Elements(d + TAG_CONTROL_CONSTRUCT_REFERENCE); foreach (XElement controlConstructReferenceElem in controlConstructReferenceElems) { string controlConstructId = (string)controlConstructReferenceElem.Element(r + TAG_ID); if (controlConstructId != null) { controlConstructSchemeModel.Sequence.ControlConstructIds.Add(controlConstructId); } } } return controlConstructSchemeModel; }
public static StudyUnit CreateDefault() { StudyUnit studyUnit = new StudyUnit(); int i = 1; foreach (Option option in Options.EventTypes) { studyUnit.Events.Add(new Event() { Title = option.Label, No = i++}); } studyUnit.Coverage = Coverage.CreateDefault(); studyUnit.FundingInfos.Add(new FundingInfo()); studyUnit.Samplings.Add(new Sampling()); studyUnit.ConceptSchemes.Add(new ConceptScheme()); ControlConstructScheme scheme = new ControlConstructScheme(); studyUnit.ControlConstructSchemes.Add(scheme); studyUnit.DefaultControlConstructSchemeId = scheme.Id; DataSet dataSet = new DataSet(); dataSet.Title = EDOConstants.LABEL_ALL; dataSet.Memo = Resources.AllDataSet; //変数全体のデータセットです studyUnit.DefaultDataSetId = dataSet.Id; studyUnit.DataSets.Add(dataSet); dataSet.IsCreatedDataFile = true; DataFile dataFile = DataFile.createDataFile(); dataFile.DataSetId = dataSet.Id; studyUnit.DataFiles.Add(dataFile); return studyUnit; }