Beispiel #1
0
        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);
        }
Beispiel #2
0
 public ObjectReferenceLinker(IBuiltComponentMapping mapping, Workspace workspace, IArdoqSession session, IMaintainenceSession maintainenceSession)
 {
     _mapping             = mapping;
     _workspace           = workspace;
     _session             = session;
     _maintainenceSession = maintainenceSession;
 }
Beispiel #3
0
 public void LinkAll(
     IExternalReferenceSpecification referenceSpecification,
     IEnumerable <ParentChildRelation> relations,
     IArdoqSession sourceWorkspaceSession,
     IMaintainenceSession maintainenceSession)
 {
     foreach (var rel in relations)
     {
         Link(referenceSpecification, rel, sourceWorkspaceSession, maintainenceSession);
     }
 }