Example #1
0
 public CompareItem(GroupId sourceId, GroupId targetId, string memo, string weight)
 {
     this.SourceId = sourceId;
     this.TargetId = targetId;
     Memo = memo;
     Weight = weight;
 }
Example #2
0
 private GroupId FindParentConceptSchemeIdByVariableId(List<StudyUnitVM> studyUnits, GroupId variableId)
 {
     StudyUnitVM studyUnit = StudyUnitVM.Find(studyUnits, variableId.StudyUnitId);
     ConceptScheme conceptScheme = studyUnit.StudyUnitModel.FindConceptSchemeByVariableId(variableId.Id);
     return new GroupId(variableId.StudyUnitId, conceptScheme.Id);
 }
Example #3
0
 private CompareRowVM CreateRow(Dictionary<string, CompareRowVM> rowMap, GroupId groupId, string title)
 {
     //タイトルに該当する行を作成したかどうかを覚えておくためのマップ
     CompareRowVM row = null;
     if (rowMap.ContainsKey(title))
     {
         row = rowMap[title];
         row.AddGroupId(groupId);
         return null;
     }
     row = new CompareRowVM(StudyUnitVM.GetStudyUnitGuids(StudyUnits))
     {
         Title = title,
         Parent = this
     };
     row.AddGroupId(groupId);
     rowMap[title] = row;
     return row;
 }
Example #4
0
 public void AddGroupId(GroupId groupId)
 {
     rowModel.RowGroupIds.Add(groupId);
 }
Example #5
0
        private static CompareItem CreateVariableCompareItem(XElement variableMapElem, List<StudyUnit> studyUnits)
        {
            string rawVariableId = (string)variableMapElem.Element(cm + TAG_SOURCE_ITEM);
            if (rawVariableId == null)
            {
                return null;
            }
            string sourceVariableId = CompareItem.ToOrigId(rawVariableId);
            StudyUnit sourceStudyUnit = StudyUnit.FindByVariableId(studyUnits, sourceVariableId);
            if (sourceStudyUnit == null)
            {
                return null;
            }
            Variable sourceVariable = sourceStudyUnit.FindVariable(sourceVariableId);

            string rawTargetVariableId = (string)variableMapElem.Element(cm + TAG_TARGET_ITEM);
            if (rawTargetVariableId == null)
            {
                return null;
            }
            string targetVariableId = CompareItem.ToOrigId(rawTargetVariableId);
            StudyUnit targetStudyUnit = StudyUnit.FindByVariableId(studyUnits, targetVariableId);
            if (targetStudyUnit == null)
            {
                return null;
            }
            Variable targetVariable = targetStudyUnit.FindVariable(targetVariableId);
            if (targetVariable == null)
            {
                return null;
            }

            XElement correspondenceElem = variableMapElem.Element(cm + TAG_CORRESPONDENCE);
            if (correspondenceElem == null)
            {
                return null;
            }

            string weightStr = (string)correspondenceElem.Element(cm + TAG_COMMONALITY_WEIGHT);
            if (string.IsNullOrEmpty(weightStr))
            {
                return null;
            }
            double weight = 0;
            if (!double.TryParse(weightStr, out weight))
            {
                return null;
            }
            bool validWeight = weight > 0;
            if (!validWeight)
            {
                return null;
            }
            string memo = (string)correspondenceElem.Element(cm + TAG_COMMONALITY);
            GroupId sourceId = new GroupId(sourceStudyUnit.Id, sourceVariableId);
            GroupId targetId = new GroupId(targetStudyUnit.Id, targetVariableId);
            CompareItem compareItem = new CompareItem(sourceId, targetId, memo, weightStr);
            compareItem.SourceTitle = sourceVariable.Title;
            compareItem.TargetTitle = targetVariable.Title;
            return compareItem;
        }
Example #6
0
        private static CompareItem CreateConceptSchemeCompareItem(XElement conceptMapElem, List<StudyUnit> studyUnits)
        {
            string sourceSchemeId = ReadReferenceID(conceptMapElem, cm + TAG_SOURCE_SCHEME_REFERENCE);
            if (sourceSchemeId == null) {
                return null;
            }
            StudyUnit sourceStudyUnit = StudyUnit.FindByConceptSchemeId(studyUnits, sourceSchemeId);
            if (sourceStudyUnit == null)
            {
                return null;
            }
            ConceptScheme sourceConceptScheme = sourceStudyUnit.FindConceptScheme(sourceSchemeId);

            string targetSchemeId = ReadReferenceID(conceptMapElem, cm + TAG_TARGET_SCHEME_REFERENCE);
            if (targetSchemeId == null)
            {
                return null;
            }
            StudyUnit targetStudyUnit = StudyUnit.FindByConceptSchemeId(studyUnits, targetSchemeId);
            if (targetStudyUnit == null)
            {
                return null;
            }
            ConceptScheme targetConceptScheme = targetStudyUnit.FindConceptScheme(targetSchemeId);
            if (targetConceptScheme == null)
            {
                return null;
            }

            XElement correspondenceElem = conceptMapElem.Element(cm + TAG_CORRESPONDENCE);
            if (correspondenceElem == null)
            {
                return null;
            }

            string weightStr = (string)correspondenceElem.Element(cm + TAG_COMMONALITY_WEIGHT);
            if (string.IsNullOrEmpty(weightStr))
            {
                return null;
            }
            double weight = 0;
            if (!double.TryParse(weightStr, out weight))
            {
                return null;
            }
            bool validWeight = weight > 0;
            if (!validWeight) {
                return null;
            }
            string memo = (string)correspondenceElem.Element(cm + TAG_COMMONALITY);
            GroupId sourceId = new GroupId(sourceStudyUnit.Id, sourceSchemeId);
            GroupId targetId = new GroupId(targetStudyUnit.Id, targetSchemeId);
            CompareItem compareItem = new CompareItem(sourceId, targetId, memo, weightStr);
            compareItem.SourceTitle = sourceConceptScheme.Title;
            compareItem.TargetTitle = targetConceptScheme.Title;
            return compareItem;
        }
Example #7
0
 private static string ToItemId(GroupId id)
 {
     return ITEM_PREFIX + id.Id;
 }
Example #8
0
 private static string ToId(GroupId sourceId, GroupId targetId)
 {
     return sourceId.Id + "_" + targetId.Id;
 }
Example #9
0
 public static CompareItem CreatePartialMatch(GroupId sourceId, GroupId targetId, string memo)
 {
     return new CompareItem(sourceId, targetId, memo, PARTIAL_MATCH_WEIGHT);
 }