示例#1
0
        //Launch Daod Intent in browse mode
        private void BrowseSuccess(IExternalDataSubsetIdentifier t, IExploreConfig exploreConfig)
        {
            var newConfig = mExploreConfigBuilder
                            .StartNew()
                            .SetDataSource(exploreConfig.DataSource)
                            .SetExternalDataSubsetIdentifier(t)
                            .Build();

            var browseSearchIntent = mExplorationIntentFactory.CreateExploreIntent(newConfig);
            // Open the tab next to the current one
            var openTabOptions = new OpenTabOptions
            {
                Location = OpenTabLocation.OpenNearCurrent
            };

            mIntentManager.Run(browseSearchIntent, openTabOptions);
        }
示例#2
0
        private void ProcessJsonIntent(string data)
        {
            var jsonIntent = mJsonSerializerWrapper.Deserialize <JsonSubsetIntent>(data);

            var dataSource = mDataSourcesAndSchema.DataSources.SingleOrDefault(x => x.Id.Equals(jsonIntent.DataSourceId));

            if (dataSource == null)
            {
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture,
                                                          "Unable to find datasource with id '{0}'",
                                                          jsonIntent.DataSourceId));
            }

            var token = new ExternalDataSubsetIdentifier(jsonIntent.Token, jsonIntent.SubsetName);

            IIntent intent;

            // Switch based on the string defined in the DomainTools.html
            switch (jsonIntent.PortalIntentToLaunch)
            {
            case "VisualQuery":
                var networkSearchConfig = mNetworkSearchConfigBuilder
                                          .StartNew()
                                          .SetDataSource(dataSource)
                                          .SetExternalDataSubsetIdentifier(token)
                                          .Build();

                intent = new OpenNetworkSearchWithConfig(networkSearchConfig, false);
                break;

            case "Browse":
                var exploreConfig = mExploreConfigBuilder
                                    .StartNew()
                                    .SetDataSource(dataSource)
                                    .SetExternalDataSubsetIdentifier(token)
                                    .Build();

                intent = mExplorationIntentFactory.CreateExploreIntent(exploreConfig);
                break;

            default:
                throw new ArgumentException("Unknown portal intent to launch: " + jsonIntent.PortalIntentToLaunch);
            }

            // Open the tab next to the current one
            var openTabOptions = new OpenTabOptions
            {
                Location = OpenTabLocation.OpenNearCurrent
            };

            mIntentManager.Run(intent, openTabOptions);
        }
        private void RunDisplayItemDetailsTabIntent()
        {
            var item = mCommandsContext.SelectedModels.Single().OriginalItem;

            // If we got here, then there must be at least one card that
            // contains data from the example source, so just take the first.
            var subsettingExampleOriginIdentifier = GetProvenancesFromItemForExampleDataSource(item)
                                                    .Select(x => mSubsettingExampleOriginIdentifierFactory.Create(x.OriginIdentifier))
                                                    .First();

            var intent = new ItemDetailsTabIntent(subsettingExampleOriginIdentifier.Id,
                                                  subsettingExampleOriginIdentifier.Source);

            mIntentManager.Run(intent);
        }
        private void ProcessJsonIntent(string data)
        {
            // We are expecting to receive strings that represent serialized
            // JsonSubsetIntent classes.
            var jsonIntent = mJsonSerializerWrapper.Deserialize <JsonSubsetIntent>(data);

            // Determine which data source the intent refers to.
            var dataSource = mDataSourcesAndSchema.DataSources.SingleOrDefault(x => x.Id.Equals(jsonIntent.DataSourceId));

            if (dataSource == null)
            {
                // No data source matched the intent, so throw an exception.
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture,
                                                          "Unable to find data source with ID '{0}'",
                                                          jsonIntent.DataSourceId));
            }

            // Generate a subset identifier from the token and the name in the
            // intent. The identifier ensures that any Browse or Visual Query
            // operation runs over the subset that the token defines. The name
            // is displayed to the user to identify which subset they are
            // working with.
            var externalDataSubsetIdentifier = new ExternalDataSubsetIdentifier(jsonIntent.Token, jsonIntent.SubsetName);

            IIntent intent;

            // Generate an appropriate intent, according to the analytic
            // operation that the user selected in SubsettingHtml.html.
            switch (jsonIntent.PortalIntentToLaunch)
            {
            case VisualQueryIntentType:
                var networkSearchConfig = mNetworkSearchConfigBuilder
                                          .StartNew()
                                          .SetDataSource(dataSource)
                                          .SetExternalDataSubsetIdentifier(externalDataSubsetIdentifier)
                                          .Build();

                intent = new OpenNetworkSearchWithConfig(networkSearchConfig, false);
                break;

            case BrowseIntentType:
                var exploreConfig = mExploreConfigBuilder
                                    .StartNew()
                                    .SetDataSource(dataSource)
                                    .SetExternalDataSubsetIdentifier(externalDataSubsetIdentifier)
                                    .Build();

                intent = mExplorationIntentFactory.CreateExploreIntent(exploreConfig);
                break;

            default:
                throw new ArgumentException("Unknown Portal intent: " + jsonIntent.PortalIntentToLaunch);
            }

            // Open the tab for the results, next to the current tab.
            var openTabOptions = new OpenTabOptions
            {
                Location = OpenTabLocation.OpenNearCurrent
            };

            // Fire off the intent.
            mIntentManager.Run(intent, openTabOptions);
        }