public WorkitemCreationResult CreateWorkitem(Workitem item, ServerConnector.Entities.Workitem closedDuplicate) { item.Description += string.Format("\n\n This is a copy of '{0}' {1}", closedDuplicate.Number, closedDuplicate.TypeName); var workitem = CreateNewWorkitem(item); var url = v1Processor.GetSummaryLink(closedDuplicate); var link = new Link(url, "Previous item"); v1Processor.AddLinkToEntity(workitem, link); return GetWorkitemCreationResult(item, workitem); }
public void AddLinkToWorkitem(Workitem workitem, Link link) { try { if (link != null && !string.IsNullOrEmpty(link.Url)) { AddLinkToAsset(workitem.Asset, link); } } catch (V1Exception ex) { throw new VersionOneException(queryBuilder.Localize(ex.Message)); } catch (Exception ex) { throw new VersionOneException(ex.Message); } }
public void AddLinkToWorkitem() { const string url = "http://qqq.com"; const string title = "Url title"; var workitemAsset = new Asset(new TestOid(new TestAssetType("Workitem"), 100, null)); var workitem = new TestWorkitem(workitemAsset, null); var link = new Link(url, title); var linkAsset = new TestAssetType("Link"); var asset = new Asset(new TestOid(new TestAssetType("Link"), 10, null)); Expect.Call(mockMetaModel.GetAssetType(VersionOneProcessor.LinkType)).Return(linkAsset); Expect.Call(mockQueryBuilder.Query(string.Empty, Filter.Empty())).IgnoreArguments().Return(new AssetList()); Expect.Call(mockServices.New(null, null)).IgnoreArguments().Return(asset); Expect.Call(() => mockServices.Save(asset)); repository.ReplayAll(); processor.AddLinkToWorkitem(workitem, link); repository.VerifyAll(); }
public void AddLinkToWorkitemWithExistingLink() { const string type = "Link"; const string url = "http://qqq.com"; const string title = "Url title"; var workitemAsset = new Asset(new TestOid(new TestAssetType("Workitem"), 100, null)); var workitem = new TestWorkitem(workitemAsset, null); var link = new Link(url, title); var linkAsset = new TestAssetType(type); var definitions = new Dictionary<string, IAttributeDefinition> { {Entity.NameProperty, new TestAttributeDefinition(linkAsset)}, {Link.OnMenuProperty, new TestAttributeDefinition(linkAsset)}, {Link.UrlProperty, new TestAttributeDefinition(linkAsset)}, }; var linkOid = new TestOid(new TestAssetType(type, definitions), 10, null); var existedLink = new Asset(linkOid); Expect.Call(mockMetaModel.GetAssetType(VersionOneProcessor.LinkType)).Return(linkAsset); Expect.Call(mockQueryBuilder.Query(string.Empty, Filter.Empty())).IgnoreArguments().Return(new AssetList { existedLink }); repository.ReplayAll(); processor.AddLinkToWorkitem(workitem, link); repository.VerifyAll(); }
private void AddLinkToWorkitemToOriginalIssue(Workitem item, ServerConnector.Entities.Workitem newWorkitem) { if(item.ExternalLink == null) { return; } var url = item.ExternalLink.Url; var urlTitle = item.ExternalLink.Title; var title = !string.IsNullOrEmpty(urlTitle) ? urlTitle : url; var link = new Link(url, title, true); v1Processor.AddLinkToEntity(newWorkitem, link); }
public void CreateLink(Link link, BaseEntity entity) { processor.AddLinkToEntity(entity, link); }
private void AddLinkToAsset(Asset asset, Link link) { if (asset == null) { return; } var linkType = metaModel.GetAssetType(LinkType); var existedLinks = GetAssetLinks(asset.Oid, Filter.Equal(Link.UrlProperty, link.Url)); if(existedLinks.Count > 0) { logger.Log(LogMessage.SeverityType.Debug, string.Format("No need to create link - it already exists.")); return; } logger.Log(LogMessage.SeverityType.Info, string.Format("Creating new link with title {0} for asset {1}", link.Title, asset.Oid)); var linkAsset = services.New(linkType, asset.Oid.Momentless); linkAsset.SetAttributeValue(linkType.GetAttributeDefinition(Entity.NameProperty), link.Title); linkAsset.SetAttributeValue(linkType.GetAttributeDefinition(Link.OnMenuProperty), link.OnMenu); linkAsset.SetAttributeValue(linkType.GetAttributeDefinition(Link.UrlProperty), link.Url); services.Save(linkAsset); logger.Log(LogMessage.SeverityType.Info, string.Format("{0} link saved", link.Title)); }
// TODO refactor public void UpdateProject(string projectId, Link link) { try { if(link != null && !string.IsNullOrEmpty(link.Url)) { var projectAsset = GetProjectById(projectId); AddLinkToAsset(projectAsset, link); } } catch (V1Exception ex) { throw new VersionOneException(queryBuilder.Localize(ex.Message)); } catch(Exception ex) { throw new VersionOneException(ex.Message); } }
public bool UpdateExternalWorkitem(Workitem workitem) { var primaryWorkitem = v1Processor.GetPrimaryWorkitemByNumber(workitem.Number); if (primaryWorkitem == null) return false; primaryWorkitem.Source = workitem.ExternalSystemName; primaryWorkitem.Reference = workitem.ExternalId; v1Processor.SaveWorkitem(primaryWorkitem); Link link = new Link(workitem.ExternalUrl.Url, workitem.ExternalUrl.Title, true); v1Processor.AddLinkToWorkitem(primaryWorkitem, link); return true; }
private bool Equals(Link other) { return Equals(other.Title, Title) && Equals(other.Url, Url) && other.OnMenu.Equals(OnMenu); }