function(oAnnotations, oMockServer) {
			// callback function to update draft specific properties post creation
			var fnNewDraftPost = function(oEvent) {
				var oNewEntity = oEvent.getParameter("oEntity");
				oNewEntity.IsActiveEntity = false;
				oNewEntity.HasActiveEntity = false;
				oNewEntity.HasDraftEntity = false;
			};
			// callback function to update draft specific properties pre deletion
			var fnDraftDelete = function(oEvent) {
				var oXhr = oEvent.getParameter("oXhr");
				var oEntry = jQuery.sap.sjax({
					url: oXhr.url,
					dataType: "json"
				}).data.d;
				// navigate to draft nodes and delete nodes
				for (var i = 0; i < this._oDraftMetadata.draftNodes.length; i++) {
					for (var navprop in this._mEntitySets[this._oDraftMetadata.draftRootName].navprops) {
						if (this._mEntitySets[this._oDraftMetadata.draftRootName].navprops[navprop].to.entitySet === this._oDraftMetadata.draftNodes[i]) {
							var oResponse = jQuery.sap.sjax({
								url: oEntry[navprop].__deferred.uri,
								dataType: "json"
							});
							if (oResponse.data && oResponse.data.d && oResponse.data.d.results) {
								var oNode;
								for (var j = 0; j < oResponse.data.d.results.length; j++) {
									oNode = oResponse.data.d.results[j];
									jQuery.sap.sjax({
										url: oNode.__metadata.uri,
										type: "DELETE"
									});
								}
							}
						}
					}
				}
			};
			if (oAnnotations && oAnnotations.EntityContainer) {
				var oEntitySetsAnnotations = oAnnotations.EntityContainer[Object.keys(oAnnotations.EntityContainer)[0]];
				//iterate over entitysets annotations
				for (var sEntityset in oEntitySetsAnnotations) {
					//get entity set annotations and look for DraftRoot annotation
					var oEntitySetAnnotations = oEntitySetsAnnotations[sEntityset];
					if (oEntitySetAnnotations[this._oConstants.COM_SAP_VOCABULARIES_COMMON_V1_DRAFTROOT]) {
						this._oDraftMetadata.draftRootName = sEntityset;
						this._oDraftMetadata.annotations = oAnnotations;
						this._oDraftMetadata.mockServerRootUri = oMockServer.getRootUri();
						if (oEntitySetAnnotations[this._oConstants.COM_SAP_VOCABULARIES_COMMON_V1_DRAFTROOT][this._oConstants.ACTIVATION_ACTION]){
							this._oDraftMetadata.draftRootActivationName = oEntitySetAnnotations[this._oConstants.COM_SAP_VOCABULARIES_COMMON_V1_DRAFTROOT][this
								._oConstants.ACTIVATION_ACTION
								].String;
						}
						if (this._oDraftMetadata.draftRootActivationName) {
							this._oDraftMetadata.draftRootActivationName = this._oDraftMetadata.draftRootActivationName.substring(this._oDraftMetadata.draftRootActivationName
								.lastIndexOf("/") + 1);
						}
						this._oDraftMetadata.draftRootEditName = oEntitySetAnnotations[this._oConstants.COM_SAP_VOCABULARIES_COMMON_V1_DRAFTROOT][this
							._oConstants.EDIT_ACTION
						];
						this._oDraftMetadata.draftRootEditName = this._oDraftMetadata.draftRootEditName ? this._oDraftMetadata.draftRootEditName.String :
							undefined;
						if (this._oDraftMetadata.draftRootEditName) {
							this._oDraftMetadata.draftRootEditName = this._oDraftMetadata.draftRootEditName.substring(this._oDraftMetadata.draftRootEditName
								.lastIndexOf("/") + 1);
						}
						this._oDraftMetadata.draftRootValidationName = oEntitySetAnnotations[this._oConstants.COM_SAP_VOCABULARIES_COMMON_V1_DRAFTROOT][this
							._oConstants.VALIDATE_ACTION
						];
						this._oDraftMetadata.draftRootValidationName = this._oDraftMetadata.draftRootValidationName ? this._oDraftMetadata.draftRootValidationName
							.String : undefined;
						if (this._oDraftMetadata.draftRootValidationName) {
							this._oDraftMetadata.draftRootValidationName = this._oDraftMetadata.draftRootValidationName.substring(this._oDraftMetadata.draftRootValidationName
								.lastIndexOf("/") + 1);
						}
						this._oDraftMetadata.draftRootPreparationtionName = oEntitySetAnnotations[this._oConstants.COM_SAP_VOCABULARIES_COMMON_V1_DRAFTROOT]
						[this
							._oConstants.PREPARE_ACTION
						];
						this._oDraftMetadata.draftRootPreparationtionName = this._oDraftMetadata.draftRootPreparationtionName ? this._oDraftMetadata.draftRootPreparationtionName
							.String : undefined;
						if (this._oDraftMetadata.draftRootPreparationtionName) {
							this._oDraftMetadata.draftRootPreparationtionName = this._oDraftMetadata.draftRootPreparationtionName.substring(this._oDraftMetadata
								.draftRootPreparationtionName
								.lastIndexOf("/") + 1);
						}
						// extend the mockserver with addtional draft functionality encapsulated in this file
						jQuery.extend(oMockServer, this);
						// A new draft is created with a POST request on the entity set for the root entities.
						oMockServer.attachAfter(MockServer.HTTPMETHOD.POST, fnNewDraftPost, this._oDraftMetadata.draftRootName);
						// A new draft can be deleted with a DELETE request to the root entity of the new draft; the root entity and all dependent entities will be deleted
						oMockServer.attachBefore(MockServer.HTTPMETHOD.DELETE, fnDraftDelete, this._oDraftMetadata.draftRootName);
						// Active documents without a related draft should return null for DraftAdministrativeData
						oMockServer.attachAfter(MockServer.HTTPMETHOD.GET, this._fnDraftAdministrativeData, this._oDraftMetadata.draftRootName);
					}
				}
			}
		}
function(oAnnotations, oMockServer) {
			// callback function to update draft specific properties post creation
			var fnNewDraftPost = function(oEvent) {
				var oNewEntity = oEvent.getParameter("oEntity");
				oNewEntity.IsActiveEntity = false;
				oNewEntity.HasActiveEntity = false;
				oNewEntity.HasDraftEntity = false;
			};
			// callback function to update draft specific properties pre deletion
			var fnDraftDelete = function(oEvent) {
				var oXhr = oEvent.getParameter("oXhr");
				var oEntry = jQuery.sap.sjax({
					url: oXhr.url,
					dataType: "json"
				}).data.d;
				// navigate to draft nodes and delete nodes
				for (var i = 0; i < this._oDraftMetadata.draftNodes.length; i++) {
					for (var navprop in this._mEntitySets[this._oDraftMetadata.draftRootName].navprops) {
						if (this._mEntitySets[this._oDraftMetadata.draftRootName].navprops[navprop].to.entitySet === this._oDraftMetadata.draftNodes[i]) {
							var oResponse = jQuery.sap.sjax({
								url: oEntry[navprop].__deferred.uri,
								dataType: "json"
							});
							if (oResponse.data && oResponse.data.d && oResponse.data.d.results) {
								var oNode;
								for (var j = 0; j < oResponse.data.d.results.length; j++) {
									oNode = oResponse.data.d.results[j];
									jQuery.sap.sjax({
										url: oNode.__metadata.uri,
										type: "DELETE"
									});
								}
							}
						}
					}
				}
			};
			if (oAnnotations && oAnnotations.EntityContainer) {
				var oEntitySetsAnnotations = oAnnotations.EntityContainer[Object.keys(oAnnotations.EntityContainer)[0]];
				//iterate over entitysets annotations
				for (var sEntityset in oEntitySetsAnnotations) {
					//get entity set annotations and look for DraftRoot annotation
					var oEntitySetAnnotations = oEntitySetsAnnotations[sEntityset];
					if (oEntitySetAnnotations[this._oConstants.COM_SAP_VOCABULARIES_COMMON_V1_DRAFTROOT]) {
						this._oDraftMetadata.draftRootName = sEntityset;
						this._oDraftMetadata.annotations = oAnnotations;
						this._oDraftMetadata.mockServerRootUri = oMockServer.getRootUri();
						if (oEntitySetAnnotations[this._oConstants.COM_SAP_VOCABULARIES_COMMON_V1_DRAFTROOT][this._oConstants.ACTIVATION_ACTION]){
							this._oDraftMetadata.draftRootActivationName = oEntitySetAnnotations[this._oConstants.COM_SAP_VOCABULARIES_COMMON_V1_DRAFTROOT][this
								._oConstants.ACTIVATION_ACTION
								].String;
						}
						if (this._oDraftMetadata.draftRootActivationName) {
							this._oDraftMetadata.draftRootActivationName = this._oDraftMetadata.draftRootActivationName.substring(this._oDraftMetadata.draftRootActivationName
								.lastIndexOf("/") + 1);
						}
						this._oDraftMetadata.draftRootEditName = oEntitySetAnnotations[this._oConstants.COM_SAP_VOCABULARIES_COMMON_V1_DRAFTROOT][this
							._oConstants.EDIT_ACTION
						];
						this._oDraftMetadata.draftRootEditName = this._oDraftMetadata.draftRootEditName ? this._oDraftMetadata.draftRootEditName.String :
							undefined;
						if (this._oDraftMetadata.draftRootEditName) {
							this._oDraftMetadata.draftRootEditName = this._oDraftMetadata.draftRootEditName.substring(this._oDraftMetadata.draftRootEditName
								.lastIndexOf("/") + 1);
						}
						this._oDraftMetadata.draftRootValidationName = oEntitySetAnnotations[this._oConstants.COM_SAP_VOCABULARIES_COMMON_V1_DRAFTROOT][this
							._oConstants.VALIDATE_ACTION
						];
						this._oDraftMetadata.draftRootValidationName = this._oDraftMetadata.draftRootValidationName ? this._oDraftMetadata.draftRootValidationName
							.String : undefined;
						if (this._oDraftMetadata.draftRootValidationName) {
							this._oDraftMetadata.draftRootValidationName = this._oDraftMetadata.draftRootValidationName.substring(this._oDraftMetadata.draftRootValidationName
								.lastIndexOf("/") + 1);
						}
						this._oDraftMetadata.draftRootPreparationtionName = oEntitySetAnnotations[this._oConstants.COM_SAP_VOCABULARIES_COMMON_V1_DRAFTROOT]
						[this
							._oConstants.PREPARE_ACTION
						];
						this._oDraftMetadata.draftRootPreparationtionName = this._oDraftMetadata.draftRootPreparationtionName ? this._oDraftMetadata.draftRootPreparationtionName
							.String : undefined;
						if (this._oDraftMetadata.draftRootPreparationtionName) {
							this._oDraftMetadata.draftRootPreparationtionName = this._oDraftMetadata.draftRootPreparationtionName.substring(this._oDraftMetadata
								.draftRootPreparationtionName
								.lastIndexOf("/") + 1);
						}
						// extend the mockserver with addtional draft functionality encapsulated in this file
						jQuery.extend(oMockServer, this);
						// A new draft is created with a POST request on the entity set for the root entities.
						oMockServer.attachAfter(MockServer.HTTPMETHOD.POST, fnNewDraftPost, this._oDraftMetadata.draftRootName);
						// A new draft can be deleted with a DELETE request to the root entity of the new draft; the root entity and all dependent entities will be deleted
						oMockServer.attachBefore(MockServer.HTTPMETHOD.DELETE, fnDraftDelete, this._oDraftMetadata.draftRootName);
						// Active documents without a related draft should return null for DraftAdministrativeData
						oMockServer.attachAfter(MockServer.HTTPMETHOD.GET, this._fnDraftAdministrativeData, this._oDraftMetadata.draftRootName);
					}
				}
			}
		}
function ( oAnnotations , oMockServer ) { // callback function to update draft specific properties post creation var fnNewDraftPost = function ( oEvent ) { var oNewEntity = oEvent . getParameter ( "oEntity" ) ; oNewEntity . IsActiveEntity = false ; oNewEntity . HasActiveEntity = false ; oNewEntity . HasDraftEntity = false ; } ; // callback function to update draft specific properties pre deletion var fnDraftDelete = function ( oEvent ) { var oXhr = oEvent . getParameter ( "oXhr" ) ; var oEntry = jQuery . sap . sjax ( { url : oXhr . url , dataType : "json" } ) . data . d ; // navigate to draft nodes and delete nodes for ( var i = 0 ; i < this . _oDraftMetadata . draftNodes . length ; i ++ ) { for ( var navprop in this . _mEntitySets [ this . _oDraftMetadata . draftRootName ] . navprops ) { if ( this . _mEntitySets [ this . _oDraftMetadata . draftRootName ] . navprops [ navprop ] . to . entitySet === this . _oDraftMetadata . draftNodes [ i ] ) { var oResponse = jQuery . sap . sjax ( { url : oEntry [ navprop ] . __deferred . uri , dataType : "json" } ) ; if ( oResponse . data && oResponse . data . d && oResponse . data . d . results ) { var oNode ; for ( var j = 0 ; j < oResponse . data . d . results . length ; j ++ ) { oNode = oResponse . data . d . results [ j ] ; jQuery . sap . sjax ( { url : oNode . __metadata . uri , type : "DELETE" } ) ; } } } } } } ; if ( oAnnotations && oAnnotations . EntityContainer ) { var oEntitySetsAnnotations = oAnnotations . EntityContainer [ Object . keys ( oAnnotations . EntityContainer ) [ 0 ] ] ; //iterate over entitysets annotations for ( var sEntityset in oEntitySetsAnnotations ) { //get entity set annotations and look for DraftRoot annotation var oEntitySetAnnotations = oEntitySetsAnnotations [ sEntityset ] ; if ( oEntitySetAnnotations [ this . _oConstants . COM_SAP_VOCABULARIES_COMMON_V1_DRAFTROOT ] ) { this . _oDraftMetadata . draftRootName = sEntityset ; this . _oDraftMetadata . annotations = oAnnotations ; this . _oDraftMetadata . mockServerRootUri = oMockServer . getRootUri ( ) ; if ( oEntitySetAnnotations [ this . _oConstants . COM_SAP_VOCABULARIES_COMMON_V1_DRAFTROOT ] [ this . _oConstants . ACTIVATION_ACTION ] ) { this . _oDraftMetadata . draftRootActivationName = oEntitySetAnnotations [ this . _oConstants . COM_SAP_VOCABULARIES_COMMON_V1_DRAFTROOT ] [ this . _oConstants . ACTIVATION_ACTION ] . String ; } if ( this . _oDraftMetadata . draftRootActivationName ) { this . _oDraftMetadata . draftRootActivationName = this . _oDraftMetadata . draftRootActivationName . substring ( this . _oDraftMetadata . draftRootActivationName . lastIndexOf ( "/" ) + 1 ) ; } this . _oDraftMetadata . draftRootEditName = oEntitySetAnnotations [ this . _oConstants . COM_SAP_VOCABULARIES_COMMON_V1_DRAFTROOT ] [ this . _oConstants . EDIT_ACTION ] ; this . _oDraftMetadata . draftRootEditName = this . _oDraftMetadata . draftRootEditName ? this . _oDraftMetadata . draftRootEditName . String : undefined ; if ( this . _oDraftMetadata . draftRootEditName ) { this . _oDraftMetadata . draftRootEditName = this . _oDraftMetadata . draftRootEditName . substring ( this . _oDraftMetadata . draftRootEditName . lastIndexOf ( "/" ) + 1 ) ; } this . _oDraftMetadata . draftRootValidationName = oEntitySetAnnotations [ this . _oConstants . COM_SAP_VOCABULARIES_COMMON_V1_DRAFTROOT ] [ this . _oConstants . VALIDATE_ACTION ] ; this . _oDraftMetadata . draftRootValidationName = this . _oDraftMetadata . draftRootValidationName ? this . _oDraftMetadata . draftRootValidationName . String : undefined ; if ( this . _oDraftMetadata . draftRootValidationName ) { this . _oDraftMetadata . draftRootValidationName = this . _oDraftMetadata . draftRootValidationName . substring ( this . _oDraftMetadata . draftRootValidationName . lastIndexOf ( "/" ) + 1 ) ; } this . _oDraftMetadata . draftRootPreparationtionName = oEntitySetAnnotations [ this . _oConstants . COM_SAP_VOCABULARIES_COMMON_V1_DRAFTROOT ] [ this . _oConstants . PREPARE_ACTION ] ; this . _oDraftMetadata . draftRootPreparationtionName = this . _oDraftMetadata . draftRootPreparationtionName ? this . _oDraftMetadata . draftRootPreparationtionName . String : undefined ; if ( this . _oDraftMetadata . draftRootPreparationtionName ) { this . _oDraftMetadata . draftRootPreparationtionName = this . _oDraftMetadata . draftRootPreparationtionName . substring ( this . _oDraftMetadata . draftRootPreparationtionName . lastIndexOf ( "/" ) + 1 ) ; } // extend the mockserver with addtional draft functionality encapsulated in this file jQuery . extend ( oMockServer , this ) ; // A new draft is created with a POST request on the entity set for the root entities. oMockServer . attachAfter ( MockServer . HTTPMETHOD . POST , fnNewDraftPost , this . _oDraftMetadata . draftRootName ) ; // A new draft can be deleted with a DELETE request to the root entity of the new draft; the root entity and all dependent entities will be deleted oMockServer . attachBefore ( MockServer . HTTPMETHOD . DELETE , fnDraftDelete , this . _oDraftMetadata . draftRootName ) ; // Active documents without a related draft should return null for DraftAdministrativeData oMockServer . attachAfter ( MockServer . HTTPMETHOD . GET , this . _fnDraftAdministrativeData , this . _oDraftMetadata . draftRootName ) ; } } } }
Enriches MockServer with draft capabilities based on the given OData service annotations.
@param {object} oAnnotations annotation object of sap.ui.model.odata.ODataModel
@param {object} oMockServer
Enriches MockServer with draft capabilities based on the given OData service annotations .
Updates the draft specific properties