} // end of Initialize /// <summary> /// Starts the actual schema migration followed by data migration /// </summary> public void Convert() { Session cqSession = m_cqConnection.GetUserSession(); OAdQuerydef qryDef = m_cqConnection.QueryDefinition; // get the base entity definition to analyze string baseEntityDefName = CQWrapper.GetPrimaryEntityDefName(qryDef); Debug.Assert(baseEntityDefName != null); Logger.WritePerf(LogSource.CQ, "Start Analyze"); // set o/p directory only if it is not specified in the CQConfig file.. // otherwise its already set / created in Initialize section if (String.IsNullOrEmpty(m_convParams.OutputDirectory)) { CQConverterUtil.SetOutputDirectory(baseEntityDefName, m_convParams.ConfigFile); } if (baseEntityDefName != null) { string[] refEntities = CQConverterUtil.GetReferencedEntityDefNames(cqSession, baseEntityDefName, m_convParams.ConfigFile); StringBuilder infoMsg1 = new StringBuilder(UtilityMethods.Format(CQResource.CQ_ENTITY_MIGRATED)); foreach (string str in refEntities) { infoMsg1.Append(str); infoMsg1.Append(", "); // REVIEW - GautamG: String not localized } infoMsg1.Remove(infoMsg1.Length - 2, 1); // remove last comma infoMsg1.Append(Environment.NewLine); Logger.Write(LogSource.CQ, TraceLevel.Info, infoMsg1.ToString()); Display.DisplayMessage(infoMsg1.ToString()); // create the schema map file so that for each WITD xml generation // the entries are added in schema map WITSchemaMappings schemaMap = new WITSchemaMappings(); int reportEntityIndex = 0; ConverterMain.MigrationReport.Summary.SourceAndDestination.WorkItemTypes.WorkItemTypeTypes = new WorkItemTypeTypes[refEntities.Length]; foreach (string entityToMigrate in refEntities) { if (entityToMigrate != null) { // process the given entity definition and generate xml for each entity // one for the base entity and one for each of referenced entities OAdEntityDef entityDef = CQWrapper.GetEntityDef(cqSession, entityToMigrate); string entityDefName = entityDef.GetName(); string schemaXmlFile = entityDefName + ".xml"; // get the file name prepended with the path.. to be generated under base entity name folder schemaXmlFile = CQConverterUtil.GetFileNameWithPath(schemaXmlFile); string fieldMapXmlFile = entityDefName + CQConstants.FieldMapFileSuffix; fieldMapXmlFile = CQConverterUtil.GetFileNameWithPath(fieldMapXmlFile); // add the default map to schema schemaMap.Mappings.AddSchemaMap(entityDefName, entityDefName, schemaXmlFile, fieldMapXmlFile); ConverterMain.MigrationReport.AddOutput(CQResource.Witd, schemaXmlFile); ConverterMain.MigrationReport.AddOutput(CQResource.WitFieldMap, fieldMapXmlFile); WITDXMLGenerator currEntityXML = new WITDXMLGenerator(schemaXmlFile, fieldMapXmlFile, cqSession, entityDef, m_vstsConn); currEntityXML.GenerateSchemaXml(); // add the entity information in migration report WorkItemTypeTypes wiType = new WorkItemTypeTypes(); wiType.From = wiType.To = entityDefName; ConverterMain.MigrationReport.Summary.SourceAndDestination.WorkItemTypes.WorkItemTypeTypes[reportEntityIndex++] = wiType; // add the link type mappings MapLinkTypes(refEntities, entityToMigrate, entityDef); } } // foreach (string entityToMigrate in refEntities) Display.NewLine(); // generated the schemas and the corresponding field maps // finally serialize the schema map file string schemaMapFile = CQConverterUtil.GetFileNameWithPath(CQConstants.SchemaMapFile); string userMapFile = CQConverterUtil.GetFileNameWithPath(CQConstants.UserMapFile); ConverterMain.MigrationReport.AddOutput(CQResource.SchemaMap, schemaMapFile); ConverterMain.MigrationReport.AddOutput(CQResource.UserMap, userMapFile); schemaMap.GenerateSchemaMappings(schemaMapFile, userMapFile); GenerateDefaultUserMaps(userMapFile); ConverterMain.MigrationReport.Statistics.NumberOfItems = refEntities.Length; // generate the link type mapping file GenerateLinkTypeMappings(); } Logger.WritePerf(LogSource.CQ, "End Analyze"); } // end of Convert()