public static void RenameIds(StudyUnit orgStudyUnit, StudyUnit newStudyUnit) { // renumber the ID of newStudyUnit to avoid duplication between ID of newStudyUnit ID and orgStudyUnit List <string> ids = CollectIds(orgStudyUnit); //0. StudyUnit itself RenameIds(newStudyUnit, ids); //1. Event RenameIds(newStudyUnit.Events, ids); //2. Member RenameIds(newStudyUnit.Members, ids, (result) => { Sampling.ChangeMemberId(newStudyUnit.Samplings, result.OldId, result.NewId); }); //3. Organization RenameIds(newStudyUnit.Organizations, ids, (result) => { Member.ChangeOrganizationId(newStudyUnit.Members, result.OldId, result.NewId); Sampling.ChangeMemberId(newStudyUnit.Samplings, result.OldId, result.NewId); }); //4. Abstract RenameIds(newStudyUnit.Abstract, ids); //5. Coverage RenameIds(newStudyUnit.Coverage, ids); //6. Funding Agency RenameIds(newStudyUnit.FundingInfos, ids); RenameIds(newStudyUnit.FundingInfoOrganizations, ids); //Organization of Funding Agency ////7.Universe RenameIds(newStudyUnit.AllUniverses, ids, (result) => { Variable.ChangeUniverseId(newStudyUnit.Variables, result.OldId, result.NewId); }); //8.Sampling RenameIds(newStudyUnit.Samplings, ids); //9. Concept Scheme RenameIds(newStudyUnit.ConceptSchemes, ids); //9-1. Concept RenameIds(ConceptScheme.GetConcepts(newStudyUnit.ConceptSchemes), ids, (result) => { Question.ChangeConceptId(newStudyUnit.Questions, result.OldId, result.NewId); Variable.ChangeConceptId(newStudyUnit.Variables, result.OldId, result.NewId); Book.ChangeMetaDataId(newStudyUnit.Books, result.OldId, result.NewId); }); //10. Question RenameIds(newStudyUnit.Questions, ids, (result) => { ControlConstructScheme.ChangeQuestionId(newStudyUnit.ControlConstructSchemes, result.OldId, result.NewId); Variable.ChangeQuestionId(newStudyUnit.Variables, result.OldId, result.NewId); Book.ChangeMetaDataId(newStudyUnit.Books, result.OldId, result.NewId); }); //11. Category Scheme RenameIds(newStudyUnit.CategorySchemes, ids, (result) => { CategoryScheme.ChangeCategorySchemeId(newStudyUnit.CategorySchemes, result.OldId, result.NewId); }); //11-1. Category RenameIds(CategoryScheme.GetCategories(newStudyUnit.CategorySchemes), ids, (result) => { CodeScheme.ChangeCategoryId(newStudyUnit.CodeSchemes, result.OldId, result.NewId); }); //12. Code Scheme RenameIds(newStudyUnit.CodeSchemes, ids, (result) => { CodeScheme.ChangeCodeSchemeId(newStudyUnit.CodeSchemes, result.OldId, result.NewId); }); //12-1. Code RenameIds(CodeScheme.GetCodes(newStudyUnit.CodeSchemes), ids); //13. Variable Scheme RenameIds(newStudyUnit.VariableScheme, ids); //14. Variable RenameIds(newStudyUnit.Variables, ids, (result) => { DataSet.ChangeVariableId(newStudyUnit.DataSets, result.OldId, result.NewId); Book.ChangeMetaDataId(newStudyUnit.Books, result.OldId, result.NewId); StatisticsInfo.ChangeVariableId(newStudyUnit.StatisticsInfos, result.OldId, result.NewId); }); //15. Dataset RenameIds(newStudyUnit.DataSets, ids, (result) => { DataFile.ChangeDataSetId(newStudyUnit.DataFiles, result.OldId, result.NewId); }); //16. Data File RenameIds(newStudyUnit.DataFiles, ids); //17. Order of Question RenameIds(newStudyUnit.ControlConstructSchemes, ids); //17-1.Sequence RenameIds(ControlConstructScheme.GetSequences(newStudyUnit.ControlConstructSchemes), ids); //17-2.Constructs RenameIds(ControlConstructScheme.GetConstructs(newStudyUnit.ControlConstructSchemes), ids, (result) => { ControlConstructScheme.ChangeControlConstructId(newStudyUnit.ControlConstructSchemes, result.OldId, result.NewId); }); //Related materials RenameIds(newStudyUnit.Books, ids); }