private void Link(IExternalReferenceSpecification referenceSpecification, ParentChildRelation rel, IArdoqSession sourceWorkspaceSession, IMaintainenceSession maintainenceSession) { var targetWorkspace = GetWorkspace(referenceSpecification.WorkspaceName); var sourceComponent = sourceWorkspaceSession.GetChildComponent(rel); var targetComponentType = referenceSpecification.TargetComponentType; var targetComponentKey = referenceSpecification.GetTargetComponentKey(rel.Child); if (targetComponentKey == null) { return; } var targetSession = GetSession(targetWorkspace, referenceSpecification); var targetComponent = targetSession.GetComponentsOfType(targetComponentType) .Single(c => c.Name == targetComponentKey); var refType = sourceWorkspaceSession.GetReferenceTypeForName(referenceSpecification.ReferenceName); var existingReferences = sourceWorkspaceSession.GetAllSourceReferencesFromChild(rel) .Where(r => r.TargetWorkspace == targetWorkspace.Id && r.Target == targetComponent.Id && r.Type == refType); if (existingReferences.Any()) { return; } targetSession.AddReference(refType, sourceComponent, targetComponent); }
public ObjectReferenceLinker(IBuiltComponentMapping mapping, Workspace workspace, IArdoqSession session, IMaintainenceSession maintainenceSession) { _mapping = mapping; _workspace = workspace; _session = session; _maintainenceSession = maintainenceSession; }
public void LinkAll( IExternalReferenceSpecification referenceSpecification, IEnumerable <ParentChildRelation> relations, IArdoqSession sourceWorkspaceSession, IMaintainenceSession maintainenceSession) { foreach (var rel in relations) { Link(referenceSpecification, rel, sourceWorkspaceSession, maintainenceSession); } }