private OAdEntity CreateTestEntity(OAdEntity record, ClearQuestMigrationContext migrationContext) { string entityName = CQWrapper.GetEntityDefName(record); if (m_perEntityTypeTestEntities.ContainsKey(entityName)) { return(m_perEntityTypeTestEntities[entityName]); } var aTestEntity = CQWrapper.BuildEntity(migrationContext.UserSession, entityName); m_perEntityTypeTestEntities.Add(entityName, aTestEntity); return(aTestEntity); }
public int AddWorkItem(string type, string title, string description) { OAdEntity entity = CQWrapper.BuildEntity(m_session, m_workItemType); SetFieldValue(entity, "headline", title); SetFieldValue(entity, "Description", description); SetFieldValue(entity, "Severity", "1-Critical"); SaveWorkItem(entity); int dbid = entity.GetDbId(); if (WorkItemAdded != null) { WorkItemAdded(this, new WorkItemAddedEventArgs(dbid)); } return(dbid); }
private void AddRecord(IMigrationAction action, ConversionResult convRslt) { string recordType = UtilityMethods.ExtractRecordType(action); OAdEntity newRecord = CQWrapper.BuildEntity(m_userSession, recordType); string validationRsltString = string.Empty; List <string> processedFields = new List <string>(); #region add new record with MANDATORY field values if (!SetMandatoryFields(action, ref newRecord, out processedFields)) { return; } bool unResolvedConflictExists = false; bool validationErrorExists = false; validationRsltString = CQWrapper.Validate(newRecord); if (!string.IsNullOrEmpty(validationRsltString)) { validationErrorExists = true; IEnumerable <CQTextParser.RecordValidationResult> validationResults; if (CQTextParser.RecordValidationTextParser.TryParse(validationRsltString, out validationResults)) { foreach (CQTextParser.RecordValidationResult rslt in validationResults) { MigrationConflict conflict = ClearQuestInvalidFieldValueConflictType.CreateConflict(rslt, action); List <MigrationAction> actions; var resolutionRslt = m_conflictManagerService.TryResolveNewConflict(m_conflictManagerService.SourceId, conflict, out actions); if (!resolutionRslt.Resolved) { unResolvedConflictExists = true; break; } } } else { throw new InvalidOperationException(validationRsltString); } } if (unResolvedConflictExists) { return; } else if (validationErrorExists) { // All conflicts are resolved. Try re-applying the changes newRecord.Revert(); SetRecordEditable(newRecord); if (!SetMandatoryFields(action, ref newRecord, out processedFields)) { return; } else { validationRsltString = CQWrapper.Validate(newRecord); if (!string.IsNullOrEmpty(validationRsltString)) { IEnumerable <CQTextParser.RecordValidationResult> validationResults; if (CQTextParser.RecordValidationTextParser.TryParse(validationRsltString, out validationResults) && validationResults.Count() > 0) { CQTextParser.RecordValidationResult rslt = validationResults.First(); MigrationConflict conflict = ClearQuestInvalidFieldValueConflictType.CreateConflict(rslt, action); m_conflictManagerService.BacklogUnresolvedConflict(m_conflictManagerService.SourceId, conflict, false); return; } else { throw new InvalidOperationException(validationRsltString); } } } } validationRsltString = CQWrapper.Commmit(newRecord); if (!string.IsNullOrEmpty(validationRsltString)) { // [teyang] TODO: invalid update conflict handling throw new InvalidOperationException(validationRsltString); } string newRecordDisplayName = CQWrapper.GetEntityDisplayName(newRecord); if (action.State == ActionState.Pending) { action.State = ActionState.Complete; } UpdateConversionHistory(action, newRecordDisplayName, ClearQuestRecordItem.NewRecordVersion, convRslt); #endregion #region update the new record with remaining field values ModifyRecordContent(newRecord, action, convRslt, processedFields); #endregion }