public override LinkChangeAction CreateLinkDeletionAction(string sourceItemUri, string targetArtifactUrl, string linkTypeReferenceName) { ClearQuestRecordArtifactHandler handler = new ClearQuestRecordArtifactHandler(); IArtifact srcArtifact; IArtifact tgtArtifact; if (!handler.TryCreateArtifactFromId(s_sourceArtifactType, sourceItemUri, out srcArtifact) || !handler.TryCreateArtifactFromId(s_targetArtifactType, targetArtifactUrl, out tgtArtifact)) { return(null); } string dispName; if (!ClearQuestRecordArtifactHandler.TryExtractRecordDispName(srcArtifact, out dispName)) { return(null); } ILink link = new ArtifactLink(dispName, srcArtifact, tgtArtifact, string.Empty, this); LinkChangeAction action = new LinkChangeAction(WellKnownChangeActionId.Delete, link, LinkChangeAction.LinkChangeActionStatus.Created, false); return(action); }
/// <summary> /// Adds an artifucat link to a work item by using the <paramref name="artifactLink"/> and optionally setting the links's <paramref name="comment"/>. /// </summary> /// <param name="artifactLink">The artifact link.</param> /// <param name="comment">The (optional) artifact link comment.</param> /// <returns></returns> /// <exception cref="ArgumentNullException">attachmentReference</exception> public virtual WorkItemPatchDocumentBuilder AddArtifactLink(ArtifactLink artifactLink, string comment = "") { if (artifactLink == null) { throw new ArgumentNullException(nameof(artifactLink)); } PatchDocument.Add( new JsonPatchOperation() { Operation = Operation.Add, Path = $"{Constants.WorkItems.RelationsBasePath}/-", Value = new { rel = Constants.WorkItems.RelationReferenceNameForArtifactLinks, url = artifactLink.ReferencedUri, attributes = new { comment = !string.IsNullOrWhiteSpace(comment) ? comment : string.Empty } } }); return(this); }
public override int GetHashCode() { int hash = 1; if (ArtifactLink.Length != 0) { hash ^= ArtifactLink.GetHashCode(); } hash ^= originServerCerts_.GetHashCode(); if (ArtifactSignature.Length != 0) { hash ^= ArtifactSignature.GetHashCode(); } if (SubType.Length != 0) { hash ^= SubType.GetHashCode(); } if (Signature.Length != 0) { hash ^= Signature.GetHashCode(); } if (SignedTimeStamp.Length != 0) { hash ^= SignedTimeStamp.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
private string GetServiceContractName(SCModel.ServiceContract serviceContract) { if (serviceContract != null && serviceContract.ObjectExtender != null) { PropertyInfo pi = serviceContract.ObjectExtender.GetType().GetProperty("ServiceContractName"); if (pi == null) { throw new ArgumentNullException(string.Format( CultureInfo.CurrentCulture, Properties.Resources.ExtenderNotFound, serviceContract.GetType().ToString() ) ); } ArtifactLink alink = GetArtifactLink(serviceContract); if (alink != null) { return(string.Concat(alink.Namespace, ".", pi.GetValue(serviceContract.ObjectExtender, null))); } } return(string.Empty); }
/// <summary> /// Initializes a new instance of the <see cref="XmlSchemaResourceResolver"/> class. /// </summary> /// <param name="link">The link.</param> public XmlSchemaResourceResolver(IArtifactLink link) { Guard.ArgumentNotNull(link, "link"); ArtifactLink alink = link as ArtifactLink; Guard.ArgumentNotNull(alink, "ArtifactLink"); this.modelElement = alink.ModelElement; }
public void ExtractLinkChangeActions( Session session, OAdEntity hostRecord, List <LinkChangeGroup> linkChangeGroups) { string hostRecDispName = CQWrapper.GetEntityDisplayName(hostRecord); string hostRecEntityDefName = CQWrapper.GetEntityDefName(hostRecord); string hostRecMigrItemId = UtilityMethods.CreateCQRecordMigrationItemId(hostRecEntityDefName, hostRecDispName); var linkChangeGroup = new LinkChangeGroup(hostRecMigrItemId, LinkChangeGroup.LinkChangeGroupStatus.Created, false); if (!CQWrapper.HasDuplicates(hostRecord)) { return; } object[] dupRecObjs = CQWrapper.GetDuplicates(hostRecord) as object[]; foreach (object dupRecObj in dupRecObjs) { OAdLink aLink = dupRecObj as OAdLink; if (null != aLink) { OAdEntity childRecord = CQWrapper.GetChildEntity(aLink) as OAdEntity; if (null != childRecord) { string childRecDispName = CQWrapper.GetEntityDisplayName(childRecord); string childRecEntityDefName = CQWrapper.GetEntityDefName(childRecord); string childRecMigrItemId = UtilityMethods.CreateCQRecordMigrationItemId(childRecEntityDefName, childRecDispName); ILink dupLink = new ArtifactLink(hostRecDispName, new Artifact(hostRecMigrItemId, new ClearQuestRecordArtifactType()), new Artifact(childRecMigrItemId, new ClearQuestRecordArtifactType()), string.Empty, this); LinkChangeAction action = new LinkChangeAction(WellKnownChangeActionId.Add, dupLink, LinkChangeAction.LinkChangeActionStatus.Created, false); linkChangeGroup.AddChangeAction(action); } else { // [teyang] TODO replace debug assertion with a conflict? Debug.Assert(false, "null == childRecord"); } } else { // [teyang] TODO replace debug assertion with a conflict? Debug.Assert(false, "null == aLink"); } } linkChangeGroups.Add(linkChangeGroup); }
/// <summary> /// Gets the artifact link. /// </summary> /// <param name="modelElement">The model element.</param> /// <returns></returns> protected ArtifactLink GetArtifactLink(ModelElement modelElement) { ArtifactLink link = ArtifactLinkHelper.GetFirstArtifactLink(modelElement); if (link != null) { return(link); } throw new NotImplementedException(Properties.Resources.ArtifactLinkNotImplemented); }
public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value) { IVsSolution vsSolution = (IVsSolution)ServiceHelper.GetService(provider, typeof(IVsSolution), this); ArtifactLink currentArtifactLink = value as ArtifactLink; if (currentArtifactLink == null) { currentArtifactLink = new TArtifactLink(); } HierarchyNode root = new HierarchyNode(vsSolution); HierarchyNode currentValue = new HierarchyNode(vsSolution, currentArtifactLink.Container); EditValue(provider, root, currentValue); return(currentArtifactLink); }
private string ResolveTypeReference(ModelElement mel) { ArtifactLink alink = GetArtifactLink(mel); if (alink != null) { PropertyInfo property = mel.GetType().GetProperty("Name"); if (property != null) { object value = property.GetValue(mel, null); return(string.Concat(alink.Namespace, ".", value.ToString())); } } return(string.Empty); }
public void ExtractLinkChangeActions(ClearQuestOleServer.Session session, ClearQuestOleServer.OAdEntity hostRecord, List <LinkChangeGroup> linkChangeGroups) { string recordId = CQWrapper.GetFieldValue(CQWrapper.GetEntityFieldValue(hostRecord, CQIdFieldName)); string url = string.Format(m_urlFormat, recordId); var linkChangeGroup = new LinkChangeGroup(recordId, LinkChangeGroup.LinkChangeGroupStatus.Created, false); string hostEntityDefName = CQWrapper.GetEntityDefName(hostRecord); string hostEntityDispName = CQWrapper.GetEntityDisplayName(hostRecord); string hostRecordId = UtilityMethods.CreateCQRecordMigrationItemId(hostEntityDefName, hostEntityDispName); ArtifactLink link = new ArtifactLink(hostRecordId, new Artifact(hostRecordId, s_sourceArtifactType), new Artifact(url, s_targetArtifactType), string.Empty, this); LinkChangeAction action = new LinkChangeAction(WellKnownChangeActionId.Add, link, LinkChangeAction.LinkChangeActionStatus.Created, false); linkChangeGroup.AddChangeAction(action); linkChangeGroups.Add(linkChangeGroup); }
public void ExtractLinkChangeActions( Session session, OAdEntity hostRecord, List <LinkChangeGroup> linkChangeGroups) { string hostRecDispName = CQWrapper.GetEntityDisplayName(hostRecord); string hostRecEntityDefName = CQWrapper.GetEntityDefName(hostRecord); if (string.IsNullOrEmpty(hostRecEntityDefName) || !CQStringComparer.EntityName.Equals(hostRecEntityDefName, this.m_hostRecordType)) { return; } string hostRecMigrItemId = UtilityMethods.CreateCQRecordMigrationItemId(hostRecEntityDefName, hostRecDispName); var linkChangeGroup = new LinkChangeGroup(hostRecMigrItemId, LinkChangeGroup.LinkChangeGroupStatus.Created, false); OAdFieldInfo fldInfo = CQWrapper.GetEntityFieldValue(hostRecord, m_referenceFieldName); int cqFieldType = CQWrapper.GetFieldType(fldInfo); if (cqFieldType == CQConstants.FIELD_REFERENCE) { // get the current entity def handle OAdEntityDef curEntityDef = CQWrapper.GetEntityDef(session, hostRecEntityDefName); OAdEntityDef refEntityDef = CQWrapper.GetFieldReferenceEntityDef(curEntityDef, m_referenceFieldName); string childRecEntityDefName = CQWrapper.GetEntityDefName(refEntityDef); int valueStatus = CQWrapper.GetFieldValueStatus(fldInfo); if (valueStatus == (int)CQConstants.FieldStatus.HAS_VALUE) { // single value required string refFldVal = CQWrapper.GetFieldValue(fldInfo); if (!CQStringComparer.RecordName.Equals(refFldVal, hostRecDispName)) { // NOT a reference to self.. Note TFS cannot have a reference to self OAdEntity childRecord = CQWrapper.GetEntity(session, childRecEntityDefName, refFldVal); if (null != childRecord) { string childRecDispName = CQWrapper.GetEntityDisplayName(childRecord); string childRecMigrItemId = UtilityMethods.CreateCQRecordMigrationItemId( childRecEntityDefName, childRecDispName); ILink refFieldLink = new ArtifactLink( hostRecDispName, new Artifact(hostRecMigrItemId, new ClearQuestRecordArtifactType()), new Artifact(childRecMigrItemId, new ClearQuestRecordArtifactType()), string.Empty, this); LinkChangeAction action = new LinkChangeAction( WellKnownChangeActionId.Add, refFieldLink, LinkChangeAction.LinkChangeActionStatus.Created, false); linkChangeGroup.AddChangeAction(action); } else { // [teyang] TODO replace debug assertion with a conflict? Debug.Assert(false, "null == childRecord"); } } } } linkChangeGroups.Add(linkChangeGroup); }