/// <summary> /// PersistenceCommand for CRUD operations and concurrency support based on the command type. Support multiple objects /// for process identified with a string ID. /// </summary> /// <param name="map"></param> /// <param name="cmdType"></param> /// <param name="providerCommand"></param> /// <param name="objectsForProcess"></param> public PersistenceCommand(Map map, CRUD cmdType, object providerCommand, IDictionary<string,object> objectsForProcess) { _appObjs = objectsForProcess; _providerCommand = providerCommand; _cmdMap = map.GetCommandMap(cmdType.ToString()); SetConcurrencySupport(cmdType); }
/// <summary> /// PersistentSupport for CRUD(insert) operations. /// </summary> /// <param name="map"></param> /// <param name="objectForProcess"></param> /// <param name="providerCommand"></param> public PersistenceCommand(Map map, object objectForProcess, object providerCommand) { _providerCommand = providerCommand; _objectForProcess = objectForProcess; //the new object _cmdMap = map.GetCommandMap(CRUD.Create.ToString()); //must get the proper command instructions from the map }
/// <summary> /// Make an insert command for one single object. /// </summary> /// <param name="map"></param> /// <param name="appObject"></param> /// <returns></returns> protected abstract PersistenceCommand MakeStoreCommand(Map map, object appObject);
/// <summary> /// PersistentObject for CRUD (Update and delete) operations, custom command and concurrency support. /// </summary> /// <param name="map"></param> /// <param name="objectForProcess"></param> /// <param name="providerCommand"></param> /// <param name="cmdType"></param> /// <param name="concurrency"></param> public PersistenceCommand(Map map, IPersistable objectForProcess, object providerCommand, string cmdType, ConcurrencySupportType concurrency) { _providerCommand = providerCommand; _cmdMap = map.GetCommandMap(cmdType); //must get the proper command instruction from the map _pObj = objectForProcess; SetConcurrencySupport(concurrency); }
public SqlServerPersistenceCommand(Map map, SqlCommand command, CRUD cmdType, IDictionary<string,object> objectsForProcess) : base(map, cmdType, command, objectsForProcess) { }
//used for Retrieve and Delete with an OID, a custom command type and concurrency support public SqlServerPersistenceCommand(Map map, ObjectIdentifier oid, SqlCommand command, string cmdType, ConcurrencySupportType concurrency) : base(map, oid, command, cmdType, concurrency) { }
//used for Retrieve and delete with an OID and a well-known command type public SqlServerPersistenceCommand(Map map, ObjectIdentifier oid, SqlCommand command, CRUD cmdType) : base(map, oid, command, cmdType) { }
//Used for Create commands public SqlServerPersistenceCommand(Map map, object objectForProcess, SqlCommand command) : base(map, objectForProcess, command) { }
//transaction command with custom command type and multiple application protected abstract PersistenceCommand MakeTransactionCommand(Map map, string cmdType, bool returnCollection, IDictionary<string,object> appObjs);
//REFACTORING: get commmon code and create a separate procedure //2012.05.19 crr: centralize the get map operation. protected void GetMap(Type objType) { //Get a dematerializer object and the Map with the property-parameter conversion data //Factory Methods: let the subclasses define the creation of concrete objects _map = MakeDematerializer().GetMap(objType); if(_map == null) throw new Exception(NO_MAP); }
//TEST /// <summary> /// PersistentCommand for new records with identifier. /// </summary> /// <param name="map"></param> /// <param name="oid"></param> /// <param name="objectForProcess"></param> /// <param name="providerCommand"></param> public PersistenceCommand(Map map, ObjectIdentifier oid,object objectForProcess, object providerCommand) { _providerCommand = providerCommand; _objectForProcess = objectForProcess; _pObj = MakePersistable(objectForProcess, oid); _cmdMap = map.GetCommandMap(CRUD.Create.ToString()); }
/// <summary> /// PersistenceCommand for CRUD operations and concurrency support based on the command type. /// </summary> /// <param name="map"></param> /// <param name="cmdType"></param> /// <param name="providerCommand"></param> public PersistenceCommand(Map map, CRUD cmdType, object providerCommand) { _providerCommand = providerCommand; _cmdMap = map.GetCommandMap(cmdType.ToString()); SetConcurrencySupport(cmdType); }
/// <summary> /// PersistentCommand for custom commands, concurrency, collection and multiple processed objects support /// </summary> /// <param name="map"></param> /// <param name="cmdTypeIdentifier"></param> /// <param name="providerCommand"></param> /// <param name="concurrency"></param> /// <param name="returnCollection"></param> /// <param name="objectsForProcess"></param> public PersistenceCommand(Map map, string cmdTypeIdentifier, object providerCommand, ConcurrencySupportType concurrency, bool returnCollection, IDictionary<string,object> objectsForProcess) { _providerCommand = providerCommand; _cmdMap = map.GetCommandMap(cmdTypeIdentifier); //get the custom command instruction from the map if(!returnCollection) _pObj = MakePersistable(); _appObjs = objectsForProcess; SetConcurrencySupport(concurrency); }
/// <summary> /// PersistentObject for retrieve operations, custom command and concurrency support. /// </summary> /// <param name="map"></param> /// <param name="oid"></param> /// <param name="providerCommand"></param> /// <param name="cmdType"></param> /// <param name="concurrency"></param> public PersistenceCommand(Map map, ObjectIdentifier oid, object providerCommand, string cmdType, ConcurrencySupportType concurrency) { _providerCommand = providerCommand; _pObj = MakePersistable(null, oid);// Retrieve operations need only the OID _cmdMap = map.GetCommandMap(cmdType); //must get the proper command instruction from the map SetConcurrencySupport(concurrency); }
/// <summary> /// Make an insert command for multiple object properties. /// </summary> /// <param name="map"></param> /// <param name="appObjects"></param> /// <returns></returns> protected abstract PersistenceCommand MakeStoreCommand(Map map, IDictionary<string, object> appObjects);
//update and object with default command type (update) protected abstract PersistenceCommand MakeChangeCommand(Map map, ObjectIdentifier oid, object appObject);
/// <summary> /// Make an insert command for multiple object properties and a custom command identifier. /// </summary> /// <param name="map"></param> /// <param name="cmdIdentifier"></param> /// <param name="appObjects"></param> /// <returns></returns> protected abstract PersistenceCommand MakeStoreCommand(Map map, string cmdTypeIdentifier, IDictionary<string, object> appObjects);
protected abstract PersistenceCommand MakeDeleteCommand(Map map, ObjectIdentifier oid, string cmdType);
//used for Retrieve all operations public SqlServerPersistenceCommand(Map map, CRUD cmdType, SqlCommand command) : base(map, cmdType, command) { }
//retrieve all with default commant type protected abstract PersistenceCommand MakeRetrieveCommand(Map map, Type type);
//Used for Update and Delete commands public SqlServerPersistenceCommand(Map map, IPersistable objectForProcess, SqlCommand command, CRUD cmdType) : base(map, objectForProcess, command, cmdType) { }
//retrieve with oid and custom command protected abstract PersistenceCommand MakeRetrieveCommand(Map map, ObjectIdentifier oid, Type type, string cmdType);
//Used for Updates and Deletes with a persistent object, a custom command and concurrency suppport public SqlServerPersistenceCommand(Map map, IPersistable objectForProcess, SqlCommand command, string cmdType, ConcurrencySupportType concurrency) : base(map, objectForProcess, command, cmdType, concurrency) { }
//retrieve one or multiple with custom command, a single criteria protected abstract PersistenceCommand MakeRetrieveCommand(Map map, object criteria, Type type, string cmdType, bool returnCollection);
//Used for Retrieve custom commands that return collections. public SqlServerPersistenceCommand(Map map, string cmdType, SqlCommand command, ConcurrencySupportType concurrency, bool returnCollection) : base(map, cmdType, command, concurrency, returnCollection) { }
//retrieve one or multiple with cusstom command and multiple criterias protected abstract PersistenceCommand MakeRetrieveCommand(Map map, Type type, string command, bool returnCollection, IList<object> criterias);
public SqlServerPersistenceCommand(Map map, string cmdTypeIdentifier, SqlCommand command, ConcurrencySupportType concurrency, bool returnCollection, IDictionary<string,object> objectsForProcess) : base(map, cmdTypeIdentifier, command, concurrency, returnCollection, objectsForProcess) { }
/// <summary> /// PersistentSupport for CRUD (update and delete) operations and possible concurrency support /// </summary> /// <param name="map"></param> /// <param name="objectForProcess"></param> /// <param name="providerCommand"></param> /// <param name="cmdType"></param> public PersistenceCommand(Map map, IPersistable objectForProcess, object providerCommand, CRUD cmdType) { _providerCommand = providerCommand; _pObj = objectForProcess; //insert,updates and delete need the object for processing. Retrieve operations need only the OID _cmdMap = map.GetCommandMap(cmdType.ToString()); //must get the proper command instructions from the map SetConcurrencySupport(cmdType); }