/// <summary> /// Retrieve a specific definition for an object including all property definitions /// </summary> /// <param name="objectName">Name of the object to retrieve the definition for</param> /// <param name="shouldGetProperties">Defines whether or not to get a list of properties associated with each object</param> /// <param name="shouldGetRelations">Defines whether or not to get a list of relations with each object such as foreign keys</param> /// <returns>Definition of the requested object</returns> public IObjectDefinition RetrieveObjectDefinition(string objectName, bool shouldGetProperties, bool shouldGetRelations) { ObjectDefinition objectDefinition = null; //log the trace for the method execution using (new LogMethodExecution(Globals.ConnectorName, "GetObjectDefinition")) { //get the list of tables DataTable tableDefinitions = _metadataAccess.GetTableList(); //add each table to the object definition list foreach (DataRow table in tableDefinitions.Rows) { if (table["TABLE_NAME"].ToString() != objectName) { continue; } //create a new object defining the name of the table and //description using the information returned from metadata objectDefinition = new ObjectDefinition { Name = table["TABLE_NAME"].ToString(), FullName = table["TABLE_NAME"].ToString(), Description = GetTableDescription(table["TABLE_NAME"].ToString()), RelationshipDefinitions = new List <IRelationshipDefinition>(), PropertyDefinitions = new List <IPropertyDefinition>() }; //Set the hidden attribute to true if this is the change history table. //Note: this is how to set items to not recommended for replication in the UI objectDefinition.Hidden = objectDefinition.Name == Globals.ChangeHistoryTableName; } if (objectDefinition != null) { if (shouldGetProperties) { //retrieve the list of properties for this object objectDefinition.PropertyDefinitions = GetTableProperties(objectDefinition.Name); } if (shouldGetRelations) { //retrieve the list of relationships for this object objectDefinition.RelationshipDefinitions = GetTableRelations(objectDefinition.Name); } //Create a new list of supported actions and include the known query action if it is supported in the connector objectDefinition.SupportedActionFullNames = new List <string> { KnownActionNames.Query }; //Add each of the operations defined in this connector to the list of supported actions //Note: These will also need to be added to the global list of supported actions //Note: Certain permissions may prevent some actions for the logged in user, this should be reflected here. foreach (Globals.OperationType supportActionEnum in Enum.GetValues(typeof(Globals.OperationType)).Cast <Globals.OperationType>()) { //do not add the None operation, this is for internal use only if (supportActionEnum == Globals.OperationType.None) { continue; } objectDefinition.SupportedActionFullNames.Add(supportActionEnum.ToString()); } } } return(objectDefinition); }