using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Harlinn.Oracle.DBTool.Types.Common;
using System.Reflection;
using System.ComponentModel;
using Harlinn.Oracle.DBTool.Utils.DB;
namespace Harlinn.Oracle.DBTool.Types.Database
{
public class DBUserView : DBUserObject, IDBTabular
{
private static readonly log4net.ILog sfLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private static void LogException(Exception exc, System.Reflection.MethodBase method)
{
Logger.LogException(sfLog, exc, method);
}
private decimal? textLength;
private string text;
private decimal? typeTextLength;
private string typeText;
private decimal? oidTextLength;
private string oidText;
private string viewTypeOwner;
private string viewType;
private string superviewName;
private string editioningView;
private string readOnly;
public DBUserView()
{
}
public DBUserView(NodeBase parent, ObjectReader reader)
: base(parent, reader)
{
ViewReader viewReader = ViewReader.CreateViewReader(this.Owner, Name);
using (viewReader)
{
if (viewReader.Read())
{
TextLength = viewReader.TextLength;
Text = viewReader.Text;
TypeTextLength = viewReader.TypeTextLength;
TypeText = viewReader.TypeText;
OidTextLength = viewReader.OidTextLength;
OidText = viewReader.OidText;
ViewTypeOwner = viewReader.ViewTypeOwner;
ViewType = viewReader.ViewType;
SuperviewName = viewReader.SuperviewName;
EditioningView = viewReader.EditioningView;
ReadOnly = viewReader.ReadOnly;
}
}
}
[Browsable(false)]
public DBUserViews Views
{
get
{
DBUserViews result = (DBUserViews)Parent;
return result;
}
}
public override DBElementType ElementType
{
get
{
return DBElementType.UserView;
}
}
public override ObjectType GetObjectType()
{
return ObjectType.View;
}
public override void Refresh()
{
base.Refresh();
try
{
string userName = Parent.Parent.Parent.Name;
string qualifiedName = userName + "." + Name;
DBFields fields = new DBFields(this, qualifiedName);
Children.Add(fields);
}
catch (Exception exc)
{
LogException(exc, MethodBase.GetCurrentMethod());
throw;
}
}
[Browsable(false)]
public DBFields Fields
{
get
{
DBFields result = GetChildByName<DBFields>("Fields");
return result;
}
}
public string GetOwner()
{
return Parent.Parent.Parent.Name;
}
public string GetName()
{
return Name;
}
public List<DBField> GetFields()
{
List<DBField> result = new List<DBField>();
DBFields fields = GetChildByName<DBFields>("Fields");
foreach (DBField field in fields.Children)
{
result.Add(field);
}
return result;
}
[Browsable(false)]
public bool IsTable
{
get
{
return false;
}
}
[Browsable(false)]
public bool IsView
{
get
{
return true;
}
}
public List<DBField> GetPrimaryKeyFields()
{
return null;
}
public DBField GetOptimisticLockField()
{
return null;
}
[Description("Length of the view text")]
[DisplayName("Text Length")]
public decimal? TextLength
{
get
{
return textLength;
}
set
{
if (this.textLength == value)
{
return;
}
this.textLength = value;
OnPropertyChanged("TextLength");
}
}
[Description("View text")]
public string Text
{
get
{
return text;
}
set
{
if (this.text == value)
{
return;
}
this.text = value;
OnPropertyChanged("Text");
}
}
[Description("Length of the type clause of the object view")]
[DisplayName("Type Text Length")]
public decimal? TypeTextLength
{
get
{
return typeTextLength;
}
set
{
if (this.typeTextLength == value)
{
return;
}
this.typeTextLength = value;
OnPropertyChanged("TypeTextLength");
}
}
[Description("Type clause of the object view")]
[DisplayName("Type Text")]
public string TypeText
{
get
{
return typeText;
}
set
{
if (this.typeText == value)
{
return;
}
this.typeText = value;
OnPropertyChanged("TypeText");
}
}
[Description("Length of the WITH OBJECT OID clause of the object view")]
[DisplayName("Oid Text Length")]
public decimal? OidTextLength
{
get
{
return oidTextLength;
}
set
{
if (this.oidTextLength == value)
{
return;
}
this.oidTextLength = value;
OnPropertyChanged("OidTextLength");
}
}
[Description("WITH OBJECT OID clause of the object view")]
[DisplayName("Oid Text")]
public string OidText
{
get
{
return oidText;
}
set
{
if (this.oidText == value)
{
return;
}
this.oidText = value;
OnPropertyChanged("OidText");
}
}
[Description("Owner of the type of the view if the view is an object view")]
[DisplayName("View Type Owner")]
public string ViewTypeOwner
{
get
{
return viewTypeOwner;
}
set
{
if (this.viewTypeOwner == value)
{
return;
}
this.viewTypeOwner = value;
OnPropertyChanged("ViewTypeOwner");
}
}
[Description("Type of the view if the view is an object view")]
[DisplayName("View Type")]
public string ViewType
{
get
{
return viewType;
}
set
{
if (this.viewType == value)
{
return;
}
this.viewType = value;
OnPropertyChanged("ViewType");
}
}
[Description("Name of the superview, if view is a subview")]
[DisplayName("Superview Name")]
public string SuperviewName
{
get
{
return superviewName;
}
set
{
if (this.superviewName == value)
{
return;
}
this.superviewName = value;
OnPropertyChanged("SuperviewName");
}
}
[Description("An indicator of whether the view is an Editioning View")]
[DisplayName("Editioning View")]
public string EditioningView
{
get
{
return editioningView;
}
set
{
if (this.editioningView == value)
{
return;
}
this.editioningView = value;
OnPropertyChanged("EditioningView");
}
}
[Description("An indicator of whether the view is a Read Only View")]
[DisplayName("Read Only")]
public string ReadOnly
{
get
{
return readOnly;
}
set
{
if (this.readOnly == value)
{
return;
}
this.readOnly = value;
OnPropertyChanged("ReadOnly");
}
}
}
}