Exemplo n.º 1
0
        internal void CreateEdges(FieldList fields, IndexList indexes, ScreenList screens)
        {
            foreach (var database in databases.Values)
            {
                var databaseInfo = database.Database;
                var databaseNode = FindDatabaseNode(databaseInfo);
                if (databaseNode != null)
                {
                    foreach (var fieldInfo in databaseInfo.FieldInfoCollection.Values)
                    {
                        var fieldNode = fields.FindFieldNode(databaseInfo, fieldInfo.Tag);
                        if (fieldInfo.IsLinked)
                        {
                            LinkFieldNodeToDatabaseNode(databaseNode, fieldNode);
                            var linkedFieldNode = fields.FindFieldNode(databaseInfo, fieldInfo.LinkRefTag);
                            if (fieldNode != null && linkedFieldNode != null)
                            {
                                AddEdge(fieldNode, AdlibEdgeType.UsesLinkRef, linkedFieldNode);
                                foreach (var indexNode in indexes.FindIndexNodes(databaseInfo, fieldInfo.LinkRefTag))
                                {
                                    AddEdge(linkedFieldNode, AdlibEdgeType.IndexedIn, indexNode);
                                }
                            }
                            screens.LinkScreenToNode(databaseInfo, fieldNode, fieldInfo.LinkScreen, AdlibEdgeType.UsesLinkScreen);
                            screens.LinkScreenToNode(databaseInfo, fieldNode, fieldInfo.ZoomScreen, AdlibEdgeType.UsesZoomScreen);
                            screens.LinkScreenToNode(databaseInfo, fieldNode, fieldInfo.EditScreen, AdlibEdgeType.UsesEditScreen);
                        }

                        if (!fieldInfo.IsLinkRef)
                        {
                            LinkFieldNodeToDatabaseNode(databaseNode, fieldNode);
                            foreach (var indexNode in indexes.FindIndexNodes(databaseInfo, fieldInfo.Tag))
                            {
                                AddEdge(fieldNode, AdlibEdgeType.IndexedIn, indexNode);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void CreateEdges(DataSourceList datasources, MethodList methods, ScreenList screens, DatabaseList databases, FieldList fields, IndexList indexes)
        {
            foreach (var applicationNode in applications.Values)
            {
                applicationNode.Application.DataSourceList.ForEach((dataSourceInfo) =>
                                                                   AddDataSourceEdgeToApplicationNode(applicationNode, dataSourceInfo, datasources, methods, screens, databases, fields, indexes));
            }

            foreach (var applicationNode in applications.Values)
            {
                ColorEdges(applicationNode);
            }
        }
Exemplo n.º 3
0
        internal void LinkScreensToDataSourceNode(ApplicationInfo applicationInfo, DatabaseList databases, FieldList fields, IndexList indexes,
                                                  Adlib.Setup.ScreenList screenList, string databasePath)
        {
            foreach (var screen in screenList)
            {
                if (!string.IsNullOrWhiteSpace(screen))
                {
                    string path = ScreenPath(applicationInfo, screen);
                    if (screens.ContainsKey(path))
                    {
                        var screenNode = screens[path];
                        if (screenNode != null && screenNode.Screen != null)
                        {
                            // Link the fields that are used on the screen to the screen
                            foreach (var field in screenNode.Screen.FieldList)
                            {
                                if (field.Type == ScreenObjectType.Data || field.Type == ScreenObjectType.HtmlField || field.Type == ScreenObjectType.Image)
                                {
                                    var fieldNode = fields.FindFieldNode(databasePath + '\\' + field.Tag);
                                    if (fieldNode != null)
                                    {
                                        AddEdge(screenNode, AdlibEdgeType.ScreenUsesField, fieldNode);

                                        var databaseNode = databases[databasePath];
                                        AddEdge(fieldNode, AdlibEdgeType.FieldOf, databaseNode);

                                        foreach (var indexNode in indexes.FindIndexNodes(fieldNode.Field.DatabaseInfo, fieldNode.Field.Tag))
                                        {
                                            AddEdge(fieldNode, AdlibEdgeType.IndexedIn, indexNode);
                                            AddEdge(indexNode, AdlibEdgeType.IndexOf, databaseNode);
                                        }

                                        if (fieldNode.Field.IsLinked)
                                        {
                                            // this is a linked screen, add the linkref field and create an edge to the database
                                            var fieldInfo          = fieldNode.Field;
                                            var linkedDatabasePath = DatabaseNode.DatabasePath(fieldInfo.LinkedDatabaseInfo);
                                            var linkedDatabaseNode = databases[linkedDatabasePath];

                                            var linkRefTag = fieldInfo.LinkRefTag;
                                            if (!string.IsNullOrWhiteSpace(linkRefTag))
                                            {
                                                var linkRefFieldPath = FieldNode.FieldPath(fieldInfo.DatabaseInfo, linkRefTag);
                                                var linkRefFieldNode = fields.FindFieldNode(linkRefFieldPath);
                                                if (linkRefFieldNode == null)
                                                {
                                                    Console.WriteLine($"Application ERROR: link ref tag '{linkRefTag}' not defined in database '{fieldInfo.DatabaseInfo.BaseName}'");
                                                }
                                                else
                                                {
                                                    AddEdge(fieldNode, AdlibEdgeType.UsesLinkRef, linkRefFieldNode);
                                                    AddEdge(linkRefFieldNode, AdlibEdgeType.FieldOf, linkedDatabaseNode);

                                                    foreach (var indexNode in indexes.FindIndexNodes(linkRefFieldNode.Field.DatabaseInfo, linkRefFieldNode.Field.Tag))
                                                    {
                                                        AddEdge(linkRefFieldNode, AdlibEdgeType.IndexedIn, indexNode);
                                                        AddEdge(indexNode, AdlibEdgeType.IndexOf, linkedDatabaseNode);
                                                    }
                                                }
                                            }

                                            // we also need to add the term field for the linked database
                                            var linkIndexTag = fieldInfo.LinkIndexTag;
                                            if (!string.IsNullOrWhiteSpace(linkIndexTag))
                                            {
                                                var linkIndexFieldPath = fieldNode.FieldPath(applicationInfo, fieldInfo.LinkedDatabaseInfo, linkIndexTag);
                                                var linkIndexFieldNode = fields.FindFieldNode(linkIndexFieldPath);
                                                if (linkIndexFieldNode != null)
                                                {
                                                    AddEdge(fieldNode, AdlibEdgeType.UsesLinkField, linkIndexFieldNode);

                                                    // create an edge from the linkindexfield to the database node
                                                    AddEdge(linkIndexFieldNode, AdlibEdgeType.FieldOf, linkedDatabaseNode);

                                                    foreach (var indexNode in indexes.FindIndexNodes(linkIndexFieldNode.Field.DatabaseInfo, linkIndexFieldNode.Field.Tag))
                                                    {
                                                        AddEdge(linkIndexFieldNode, AdlibEdgeType.IndexedIn, indexNode);
                                                        AddEdge(indexNode, AdlibEdgeType.IndexOf, linkedDatabaseNode);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
        void AddDataSourceEdgeToApplicationNode(ApplicationNode applicationNode, DataSourceInfo dataSourceInfo,
                                                DataSourceList datasources, MethodList methods, ScreenList screens, DatabaseList databases, FieldList fields, IndexList indexes)
        {
            var applicationInfo = applicationNode.Application;

            if (dataSourceInfo.DatabaseType == DatabaseType.NormalDatabase)
            {
                var dataSourceNode = datasources.FindDataSourceNode(applicationInfo, dataSourceInfo);

                AddEdge(applicationNode, AdlibEdgeType.HasDataSource, dataSourceNode);

                dataSourceInfo.ListScreenList.ForEach(screenName =>
                                                      screens.LinkScreenToNode(applicationInfo, dataSourceNode, screenName, AdlibEdgeType.UsesListScreen));
                dataSourceInfo.DetailScreenList.ForEach(screenName =>
                                                        screens.LinkScreenToNode(applicationInfo, dataSourceNode, screenName, AdlibEdgeType.UsesDetailScreen));
                dataSourceInfo.MethodList.ForEach(methodInfo =>
                                                  methods.LinkMethodToNode(applicationInfo, dataSourceNode, methodInfo, screens));

                var databasePath = DatabasePath(applicationInfo, dataSourceInfo);

                screens.LinkScreensToDataSourceNode(applicationInfo, databases, fields, indexes, dataSourceInfo.DetailScreenList, databasePath);
                screens.LinkScreensToDataSourceNode(applicationInfo, databases, fields, indexes, dataSourceInfo.ListScreenList, databasePath);
            }
        }