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 void LinkAll( IExternalReferenceSpecification referenceSpecification, IEnumerable <ParentChildRelation> relations, IArdoqSession sourceWorkspaceSession, IMaintainenceSession maintainenceSession) { foreach (var rel in relations) { Link(referenceSpecification, rel, sourceWorkspaceSession, maintainenceSession); } }
private IArdoqSession GetSession(Workspace workspace, IExternalReferenceSpecification referenceSpecification) { if (_sessions.ContainsKey(workspace.Id)) { return(_sessions[workspace.Id]); } var session = new ArdoqSession(workspace.Id, _reader, _writer); _sessions[workspace.Id] = session; return(session); }