public void Delete(int jamaProjectId, int jamaReleaseId) { ReleaseMappingData.ReleaseMappingRow dataRow = GetFromJamaId(jamaProjectId, jamaReleaseId); if (dataRow != null) { dataRow.Delete(); dataRow.AcceptChanges(); } }
/// <summary> /// Adds a new mapping entry /// </summary> /// <param name="spiraProjectId">The id of the spira project</param> /// <param name="spiraReleaseId">The id of the spira release</param> /// <param name="jamaProjectId">The id of the jama project</param> /// <param name="jamaReleaseId">The id of the jama release</param> public void Add(int spiraProjectId, int spiraReleaseId, int jamaProjectId, int jamaReleaseId) { //Create a new data row if (this.releaseMappingData != null) { ReleaseMappingData.ReleaseMappingRow dataRow = this.releaseMappingData.ReleaseMapping.AddReleaseMappingRow( spiraProjectId, spiraReleaseId, jamaProjectId, jamaReleaseId ); dataRow.AcceptChanges(); } }
/// <summary>Generates a remote requirement from the specified item.</summary> /// <param name="jamaItem">The Jama item to create the requirement from.</param> /// <param name="existingReq">Pass an existing requirement to update, leave null to create new</param> /// <returns>RemoteRequirement</returns> private SpiraSoapService.RemoteRequirement GenerateOrUpdateRequirement(JamaItem jamaItem, SpiraSoapService.RemoteRequirement existingReq) { SpiraSoapService.RemoteRequirement newReq; if (existingReq == null) { newReq = new SpiraSoapService.RemoteRequirement(); newReq.CustomProperties = new List <RemoteArtifactCustomProperty>(); } else { newReq = existingReq; } if (String.IsNullOrEmpty(jamaItem.Name)) { newReq.Name = "Unknown (Null)"; } else { newReq.Name = jamaItem.Name; } newReq.Description = jamaItem.Description; newReq.RequirementTypeId = (int)SpiraProject.RequirementType.Feature; if (jamaItem.CreatedDate.HasValue) { newReq.CreationDate = jamaItem.CreatedDate.Value; } if (jamaItem.ModifiedDate.HasValue) { newReq.LastUpdateDate = jamaItem.ModifiedDate.Value; } if (existingReq == null) { //Set the concurrent Date for new items newReq.ConcurrencyDate = DateTime.UtcNow; } //Get the other fields bool documentKeyFound = false; foreach (KeyValuePair <string, object> field in jamaItem.Fields) { //Handle the known fields //Priority if (field.Key == "priority") { if (field.Value != null && field.Value is Int32) { int jamaPriorityId = (int)field.Value; switch ((JamaProjectInfo.Priority)jamaPriorityId) { case JamaProjectInfo.Priority.High: newReq.ImportanceId = (int)SpiraProject.Importance.High; break; case JamaProjectInfo.Priority.Medium: newReq.ImportanceId = (int)SpiraProject.Importance.Medium; break; case JamaProjectInfo.Priority.Low: newReq.ImportanceId = (int)SpiraProject.Importance.Low; break; } } } //Status if (field.Key == "status") { if (field.Value != null && field.Value is Int32) { int jamaStatusId = (int)field.Value; switch ((JamaProjectInfo.Status)jamaStatusId) { case JamaProjectInfo.Status.Draft: newReq.StatusId = (int)SpiraProject.Status.Requested; break; case JamaProjectInfo.Status.Approved: newReq.StatusId = (int)SpiraProject.Status.Accepted; break; case JamaProjectInfo.Status.Completed: newReq.StatusId = (int)SpiraProject.Status.Completed; break; case JamaProjectInfo.Status.Rejected: newReq.StatusId = (int)SpiraProject.Status.Rejected; break; } } } //Document Key if (field.Key == "documentKey") { if (field.Value != null && field.Value is String) { string documentKey = (string)field.Value; if (!String.IsNullOrWhiteSpace(documentKey)) { string jamaItemKey = jamaItem.Id.ToString(); RemoteArtifactCustomProperty customProp = new RemoteArtifactCustomProperty(); customProp.PropertyNumber = 2; customProp.StringValue = documentKey; newReq.CustomProperties.Add(customProp); documentKeyFound = true; } } } //Release if (field.Key == "release") { if (field.Value != null && field.Value is Int32) { int jamaReleaseId = (int)field.Value; //See if we have a mapping for this release ReleaseMappingData.ReleaseMappingRow dataRow = this._releaseDataMapping.GetFromJamaId(this._JamaProject.ProjectNum, jamaReleaseId); if (dataRow == null) { newReq.ReleaseId = null; } else { newReq.ReleaseId = dataRow.SpiraReleaseId; } } } } //Now get the item document type and item document type category and store in text custom properties if (jamaItem.ItemTypeId.HasValue) { int itemTypeId = jamaItem.ItemTypeId.Value; JamaItemType itemType = this._jamaClient.GetItemType(itemTypeId); if (itemType != null) { { RemoteArtifactCustomProperty customProp = new RemoteArtifactCustomProperty(); customProp.PropertyNumber = 1; customProp.StringValue = itemType.Display; newReq.CustomProperties.Add(customProp); } //Also map to the nearest equivalent requirement type switch ((JamaProjectInfo.Type)itemTypeId) { case JamaProjectInfo.Type.Feature: newReq.RequirementTypeId = (int)SpiraProject.RequirementType.Feature; break; case JamaProjectInfo.Type.Requirement: case JamaProjectInfo.Type.Epic: newReq.RequirementTypeId = (int)SpiraProject.RequirementType.Need; break; case JamaProjectInfo.Type.UseCase: case JamaProjectInfo.Type.UsageScenario: newReq.RequirementTypeId = (int)SpiraProject.RequirementType.UseCase; break; case JamaProjectInfo.Type.UserStory: newReq.RequirementTypeId = (int)SpiraProject.RequirementType.UserStory; break; default: newReq.RequirementTypeId = (int)SpiraProject.RequirementType.Feature; break; } //Also we need to add the jama ID as the Custom 02 custom property //using format: <project-short-name>-<Jama item type key>-<number> if (!documentKeyFound) { if (!String.IsNullOrWhiteSpace(this._projectShortName)) { string jamaItemKey = jamaItem.Id.ToString(); RemoteArtifactCustomProperty customProp = new RemoteArtifactCustomProperty(); customProp.PropertyNumber = 2; customProp.StringValue = this._projectShortName + "-" + itemType.TypeKey + "-" + jamaItemKey; newReq.CustomProperties.Add(customProp); } } if (!String.IsNullOrEmpty(itemType.Category)) { RemoteArtifactCustomProperty customProp = new RemoteArtifactCustomProperty(); customProp.PropertyNumber = 3; customProp.StringValue = itemType.Category; newReq.CustomProperties.Add(customProp); } } } return(newReq); }
/// <summary> /// Processes a Jama release, importing into SpiraTeam if necessary /// </summary> /// <param name="jamaRelease">The jama release</param> /// <returns></returns> private FinalStatusEnum ProcessRelease(StreamWriter streamWriter, JamaRelease jamaRelease) { FinalStatusEnum retStatus = FinalStatusEnum.OK; try { //Insert/update the release in SpiraTeam //See if the item is already mapped to an item in Spira int jamaReleaseId = (int)jamaRelease.Id; int jamaProjectId = this._JamaProject.ProjectNum; ReleaseMappingData.ReleaseMappingRow dataRow = this._releaseDataMapping.GetFromJamaId(jamaProjectId, jamaReleaseId); if (dataRow == null) { //We need to insert a new release RemoteRelease remoteRelease = new RemoteRelease(); if (String.IsNullOrEmpty(jamaRelease.Name)) { remoteRelease.Name = "Unknown (Null)"; } else { remoteRelease.Name = jamaRelease.Name; } if (!String.IsNullOrEmpty(jamaRelease.Name) && jamaRelease.Name.Length <= 10) { //If we have a release name that is short enough, use it for the version number //otherwise let Spira auto-generate it remoteRelease.VersionNumber = jamaRelease.Name; } else { //Currently "" denotes that we need to create a new version number //in future versions of the API it should also support passing null remoteRelease.VersionNumber = ""; } remoteRelease.Description = jamaRelease.Description; remoteRelease.ReleaseStatusId = (jamaRelease.Active) ? (int)SpiraProject.ReleaseStatusEnum.Planned : (int)SpiraProject.ReleaseStatusEnum.Completed; remoteRelease.ReleaseTypeId = (int)SpiraProject.ReleaseTypeEnum.MajorRelease; if (jamaRelease.ReleaseDate.HasValue) { //We assume that the release lasts 1-month by default remoteRelease.StartDate = jamaRelease.ReleaseDate.Value.AddMonths(-1).Date; remoteRelease.EndDate = jamaRelease.ReleaseDate.Value.Date; } else { //Just create a start/end date based on the current date remoteRelease.StartDate = DateTime.UtcNow.Date; remoteRelease.EndDate = DateTime.UtcNow.AddMonths(1).Date; } //Create the release remoteRelease = this._spiraClient.Release_Create(remoteRelease, null); this._releaseDataMapping.Add( this._SpiraProject.ProjectNum, remoteRelease.ReleaseId.Value, jamaProjectId, jamaReleaseId ); } else { //We need to update an existing release (we leave the dates alone) int spiraReleaseId = dataRow.SpiraReleaseId; RemoteRelease remoteRelease = this._spiraClient.Release_RetrieveById(spiraReleaseId); if (remoteRelease == null) { //Could not find release and it was mapped. retStatus = FinalStatusEnum.Warning; } else { //Update the release in Spira if (!String.IsNullOrEmpty(jamaRelease.Name)) { remoteRelease.Name = jamaRelease.Name; if (jamaRelease.Name.Length <= 10) { //If we have a release name that is short enough, use it for the version number //otherwise let Spira auto-generate it remoteRelease.VersionNumber = jamaRelease.Name; } } remoteRelease.Description = jamaRelease.Description; remoteRelease.Active = jamaRelease.Active; this._spiraClient.Release_Update(remoteRelease); } } if (ProcessThread.WantCancel) { return(FinalStatusEnum.Error); } } catch (Exception ex) { streamWriter.WriteLine("Unable to complete import: " + ex.Message); retStatus = FinalStatusEnum.Error; } return(retStatus); }