Ejemplo n.º 1
0
		public void VisitDataObjectReference(OracleDataObjectReference objectReference)
		{
			if (TryBuildSchemaTooltip(objectReference))
			{
				return;
			}

			if (objectReference.Type == ReferenceType.SchemaObject)
			{
				var schemaObject = objectReference.SchemaObject.GetTargetSchemaObject();
				if (schemaObject == null)
				{
					return;
				}

				TableDetailsModel dataModel;

				var databaseModel = objectReference.Container.SemanticModel.DatabaseModel;
				var toolTipText = GetFullSchemaObjectToolTip(objectReference.SchemaObject);

				switch (schemaObject.Type)
				{
					case OracleObjectType.MaterializedView:
						var materializedView = (OracleMaterializedView)schemaObject;
						dataModel =
							new MaterializedViewDetailsModel
							{
								MaterializedViewTitle = toolTipText,
								Title = GetObjectTitle(OracleObjectIdentifier.Create(materializedView.Owner, materializedView.TableName), OracleObjectType.Table.ToLower()),
								MaterializedView = materializedView
							};

						SetPartitionKeys(dataModel);

						databaseModel.UpdateTableDetailsAsync(schemaObject.FullyQualifiedName, dataModel, CancellationToken.None);
						ToolTip =
							new ToolTipMaterializedView
							{
								ScriptExtractor = databaseModel.ObjectScriptExtractor,
								DataContext = dataModel
							};

						break;

					case OracleObjectType.Table:
						dataModel =
							new TableDetailsModel
							{
								Title = toolTipText,
								Table = (OracleTable)schemaObject
							};

						SetPartitionKeys(dataModel);

						databaseModel.UpdateTableDetailsAsync(schemaObject.FullyQualifiedName, dataModel, CancellationToken.None);

						ToolTip =
							new ToolTipTable
							{
								ScriptExtractor = databaseModel.ObjectScriptExtractor,
								DataContext = dataModel
							};

						break;

					case OracleObjectType.View:
						var objectDetailModel =
							new ObjectDetailsModel
							{
								Title = toolTipText,
								Object = schemaObject
							};

						DocumentationDataDictionaryObject documentation;
						if (TryGetDataDictionaryObjectDocumentation(schemaObject.FullyQualifiedName, out documentation) && !String.IsNullOrWhiteSpace(documentation.Value))
						{
							objectDetailModel.Comment = documentation.Value;
						}
						else
						{
							databaseModel.UpdateViewDetailsAsync(schemaObject.FullyQualifiedName, objectDetailModel, CancellationToken.None);
						}

						ToolTip =
							new ToolTipView
							{
								IsExtractDdlVisible = true,
								ScriptExtractor = databaseModel.ObjectScriptExtractor,
								DataContext = objectDetailModel
							};
						
						break;

					case OracleObjectType.Sequence:
						ToolTip = new ToolTipSequence(toolTipText, (OracleSequence)schemaObject);
						break;
				}
			}
			else
			{
				ToolTip =
					new ToolTipObject
					{
						DataContext = $"{objectReference.FullyQualifiedObjectName.ToLabel()} ({objectReference.Type.ToCategoryLabel()})"
					};
			}
		}
        public void VisitDataObjectReference(OracleDataObjectReference objectReference)
        {
            if (TryBuildSchemaTooltip(objectReference))
            {
                return;
            }

            if (objectReference.Type == ReferenceType.SchemaObject)
            {
                var schemaObject = objectReference.SchemaObject.GetTargetSchemaObject();
                if (schemaObject == null)
                {
                    return;
                }

                TableDetailsModel dataModel;

                var databaseModel = objectReference.Container.SemanticModel.DatabaseModel;
                var toolTipText   = GetFullSchemaObjectToolTip(objectReference.SchemaObject);

                switch (schemaObject.Type)
                {
                case OracleObjectType.MaterializedView:
                    var materializedView = (OracleMaterializedView)schemaObject;
                    dataModel =
                        new MaterializedViewDetailsModel
                    {
                        MaterializedViewTitle = toolTipText,
                        Title            = GetObjectTitle(OracleObjectIdentifier.Create(materializedView.Owner, materializedView.TableName), OracleObjectType.Table.ToLower()),
                        MaterializedView = materializedView
                    };

                    SetPartitionKeys(dataModel);

                    databaseModel.UpdateTableDetailsAsync(schemaObject.FullyQualifiedName, dataModel, CancellationToken.None);
                    ToolTip =
                        new ToolTipMaterializedView
                    {
                        ScriptExtractor = databaseModel.ObjectScriptExtractor,
                        DataContext     = dataModel
                    };

                    break;

                case OracleObjectType.Table:
                    dataModel =
                        new TableDetailsModel
                    {
                        Title = toolTipText,
                        Table = (OracleTable)schemaObject
                    };

                    SetPartitionKeys(dataModel);

                    databaseModel.UpdateTableDetailsAsync(schemaObject.FullyQualifiedName, dataModel, CancellationToken.None);

                    ToolTip =
                        new ToolTipTable
                    {
                        ScriptExtractor = databaseModel.ObjectScriptExtractor,
                        DataContext     = dataModel
                    };

                    break;

                case OracleObjectType.View:
                    var objectDetailModel =
                        new ObjectDetailsModel
                    {
                        Title  = toolTipText,
                        Object = schemaObject
                    };

                    DocumentationDataDictionaryObject documentation;
                    if (TryGetDataDictionaryObjectDocumentation(schemaObject.FullyQualifiedName, out documentation) && !String.IsNullOrWhiteSpace(documentation.Value))
                    {
                        objectDetailModel.Comment = documentation.Value;
                    }
                    else
                    {
                        databaseModel.UpdateViewDetailsAsync(schemaObject.FullyQualifiedName, objectDetailModel, CancellationToken.None);
                    }

                    ToolTip =
                        new ToolTipView
                    {
                        IsExtractDdlVisible = true,
                        ScriptExtractor     = databaseModel.ObjectScriptExtractor,
                        DataContext         = objectDetailModel
                    };

                    break;

                case OracleObjectType.Sequence:
                    ToolTip = new ToolTipSequence(toolTipText, (OracleSequence)schemaObject);
                    break;
                }
            }
            else
            {
                ToolTip =
                    new ToolTipObject
                {
                    DataContext = $"{objectReference.FullyQualifiedObjectName.ToLabel()} ({objectReference.Type.ToCategoryLabel()})"
                };
            }
        }