Exemplo n.º 1
0
 public ObjectReferenceLinker(IBuiltComponentMapping mapping, Workspace workspace, IArdoqSession session, IMaintainenceSession maintainenceSession)
 {
     _mapping             = mapping;
     _workspace           = workspace;
     _session             = session;
     _maintainenceSession = maintainenceSession;
 }
Exemplo n.º 2
0
        private void LinkBySearch(IEnumerable <ParentChildRelation> relations, IArdoqSession session)
        {
            foreach (var mapping in _builder.ComponentMappings.Where(cm => cm.SearchReferenceBuilders.Any()))
            {
                var rels = relations.Where(obj => obj.Child.GetType() == mapping.SourceType).ToList();
                if (!rels.Any())
                {
                    return;
                }

                foreach (var builder in mapping.SearchReferenceBuilders)
                {
                    var linkageService = new SearchLinkageService(
                        _reader,
                        _writer,
                        session,
                        _searcher,
                        mapping,
                        builder.Item1,
                        _logger);

                    linkageService.LinkBySearch(builder.Item2, rels);
                }
            }
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
 private void LinkExternally(IEnumerable <ParentChildRelation> relations, IArdoqSession session)
 {
     foreach (var mapping in _builder.ComponentMappings.Where(cm => cm.ExternalReferenceSpecifications.Any()))
     {
         var rels = relations.Where(obj => obj.Child.GetType() == mapping.SourceType).ToList();
         foreach (var referenceSpecification in mapping.ExternalReferenceSpecifications)
         {
             _externalLinkageService.LinkAll(referenceSpecification, rels, session, this);
         }
     }
 }
Exemplo n.º 5
0
 public void LinkAll(
     IExternalReferenceSpecification referenceSpecification,
     IEnumerable <ParentChildRelation> relations,
     IArdoqSession sourceWorkspaceSession,
     IMaintainenceSession maintainenceSession)
 {
     foreach (var rel in relations)
     {
         Link(referenceSpecification, rel, sourceWorkspaceSession, maintainenceSession);
     }
 }
Exemplo n.º 6
0
 public SearchLinkageService(
     IArdoqReader reader,
     IArdoqWriter writer,
     IArdoqSession session,
     IArdoqSearcher searcher,
     IBuiltComponentMapping mapping,
     string ardoqReferenceName,
     ILogger logger)
 {
     _reader = reader;
     _writer = writer;
     _sourceWorkspaceSession = session;
     _searcher           = searcher;
     _mapping            = mapping;
     _ardoqReferenceName = ardoqReferenceName;
     _logger             = logger;
 }
Exemplo n.º 7
0
        private void LinkByTags(IEnumerable <ParentChildRelation> relations, IArdoqSession session)
        {
            var linker = new TagLinkageService(session, _reader, _writer);

            foreach (var mapping in _builder.ComponentMappings.Where(cm => cm.TagReferenceGetters.Any()))
            {
                var rels = relations.Where(rel => rel.Child.GetType() == mapping.SourceType).ToList();
                foreach (var tagReferenceGetter in mapping.TagReferenceGetters)
                {
                    foreach (var rel in rels)
                    {
                        var tuple = tagReferenceGetter.GetTags(rel.Child);
                        if (tuple.Item1)
                        {
                            linker.Link(rel, tuple.Item2, mapping, tagReferenceGetter.ArdoqReferenceName,
                                        tagReferenceGetter.GetSearchFolder());
                        }
                    }
                }
            }
        }
 public TagLinkageService(IArdoqSession session, IArdoqReader reader, IArdoqWriter writer)
 {
     _session = session;
     _reader  = reader;
     _writer  = writer;
 }
Exemplo n.º 9
0
        private void LinkInternally(IEnumerable <ParentChildRelation> allRelations, Workspace workspace, IArdoqSession session)
        {
            _logger.LogMessage("Starting internal linkage phase.");

            var createdCount = 0;
            var removedCount = 0;

            foreach (var mapping in _builder.ComponentMappings)
            {
                var linker = new ObjectReferenceLinker(mapping, workspace, session, this);
                var tuple  = linker.LinkAll(allRelations, allRelations.Where(o => o.Child.GetType() == mapping.SourceType));
                createdCount += tuple.Item1;
                removedCount += tuple.Item2;
            }

            _logger.LogMessage($"Internal linkage phase complete. References added: {createdCount} Removed: {removedCount}");
        }
 public ComponentHierarchyMaintainer(IDictionary <Type, IBuiltComponentMapping> mappings, IArdoqSession session)
 {
     _mappings = mappings;
     _session  = session;
 }