E2E Automation

Modifications to operation policy with additional model related IDs

Change-Id: Ic99b0646814a64682c7ea90c9a3638993e9d9c5c
Issue-ID: CLAMP-309
Signed-off-by: ThamlurRaju <TR00568434@TechMahindra.com>
diff --git a/src/main/resources/META-INF/resources/designer/partials/portfolios/operational_policy_window.html b/src/main/resources/META-INF/resources/designer/partials/portfolios/operational_policy_window.html
index 53f1d94..82b4803 100644
--- a/src/main/resources/META-INF/resources/designer/partials/portfolios/operational_policy_window.html
+++ b/src/main/resources/META-INF/resources/designer/partials/portfolios/operational_policy_window.html
@@ -197,8 +197,8 @@
 								<option value="APPC">APPC</option>
 								<option value="SO">SO</option>
 								<option value="VFC">VFC</option>
-								<option value="SDNC">SDNC</option>°
-								<option value="SDNR">SDNR</option>°
+								<option value="SDNC">SDNC</option>°
+								<option value="SDNR">SDNR</option>°
 							</select>
 						</div>
 
@@ -282,12 +282,55 @@
 							Target ResourceId</label>
 						<div class="col-sm-8">
 							<select class="form-control" name="resourceId" id="resourceId"
-								enableFilter="true" ng-model="resourceId">
+								enableFilter="true" ng-click="changeTargetResourceId()"
+								ng-model="resourceId">
 								<option value=""></option>
 								<option value="Other:">Other:</option>
 							</select>
 						</div>
 					</div>
+					<div id="metadata">
+						<div class="form-group clearfix">
+							<label for="modelInvariantId" class="col-sm-4 control-label">
+								Model Invariant Id</label>
+							<div class="col-sm-8">
+								<input class="form-control" name="modelInvariantId"
+									id="modelInvariantId" readonly />
+							</div>
+						</div>
+						<div class="form-group clearfix">
+							<label for="modelVersionId" class="col-sm-4 control-label">
+								Model Version Id</label>
+							<div class="col-sm-8">
+								<input class="form-control" name="modelVersionId"
+									id="modelVersionId" readonly />
+							</div>
+						</div>
+						<div class="form-group clearfix">
+							<label for="modelName" class="col-sm-4 control-label">
+								Model Name</label>
+							<div class="col-sm-8">
+								<input class="form-control" name="modelName" id="modelName"
+									readonly />
+							</div>
+						</div>
+						<div class="form-group clearfix">
+							<label for="modelVersion" class="col-sm-4 control-label">
+								Model Version</label>
+							<div class="col-sm-8">
+								<input class="form-control" name="modelVersion"
+									id="modelVersion" readonly />
+							</div>
+						</div>
+						<div class="form-group clearfix">
+							<label for="modelCustomizationId" class="col-sm-4 control-label">
+								Model Customization Id</label>
+							<div class="col-sm-8">
+								<input class="form-control" name="modelCustomizationId"
+									id="modelCustomizationId" readonly />
+							</div>
+						</div>
+					</div>
 				</form>
 				<div class="form-group clearfix">
 					<label for="enableGuardPolicy" class="col-sm-4 control-label">
diff --git a/src/main/resources/META-INF/resources/designer/scripts/OperationalPolicyCtrl.js b/src/main/resources/META-INF/resources/designer/scripts/OperationalPolicyCtrl.js
index 922220b..e7c5d93 100644
--- a/src/main/resources/META-INF/resources/designer/scripts/OperationalPolicyCtrl.js
+++ b/src/main/resources/META-INF/resources/designer/scripts/OperationalPolicyCtrl.js
@@ -209,6 +209,11 @@
 
 			var type = $(event.target).val();
 			
+			$("#modelName").val("");
+			$("#modelInvariantId").val("");
+			$("#modelVersionId").val("");
+			$("#modelVersion").val("");
+			$("#modelCustomizationId").val("");
 			$('#resourceId').empty();
 			$("#resourceId")
 					.append(
@@ -217,6 +222,9 @@
 			$("#resourceId").append(
 					$('<option></option>').val("Other:")
 							.html("Other:"));
+			if (type == "VM" || type == "" || type == "VNF" ) {
+				$("#metadata *").prop('disabled',true);
+			}
 			
 			var resourceVnf = getResourceDetailsProperty();
 			if (type == "VNF"
@@ -244,17 +252,57 @@
 						}
 					}
 				} 
-		        else 
+		        else
 		        {
 		          for ( var prop in resourceVfc) {
-				          var name = resourceVfc[prop]["name"];
-		    					$("#resourceId").append(
-		    							$('<option></option>')
-		    									.val(name).html(name));
+				     var name = resourceVfc[prop]["name"];
+		    	      $("#resourceId").append(
+		    		     $('<option></option>')
+		    			    .val(name).html(name));
 		    			}
-					} 
-		}
+					}
+				}
+	    }	
 
+		$scope.changeTargetResourceId = function() {
+			$("#modelName").val("");
+			$("#modelInvariantId").val("");
+			$("#modelVersionId").val("");
+			$("#modelVersion").val("");
+			$("#modelCustomizationId").val("");
+			var resourceVfc = getResourceDetailsVfcProperty();
+			var type = $("#type").val();
+			var recipe = $("#recipe").val();
+			vfBaseName = $(event.target).val();
+			if (type == "VFC"
+					&& (null !== resourceVfc || undefined !== resourceVfc)
+					&& (recipe == 'VF Module Create' || recipe == 'VF Module Delete')) {
+				for ( var prop in resourceVfc) {
+					var name = resourceVfc[prop]["name"];
+					if (name == vfBaseName) {
+						var vfModuleModelName = resourceVfc[prop]["name"];
+						$("#modelName").val(
+								vfModuleModelName);
+						var vfModuleModelInvariantUUID = resourceVfc[prop]["invariantUUID"];
+						$("#modelInvariantId").val(
+								vfModuleModelInvariantUUID);
+						var vfModuleModelUUID = resourceVfc[prop]["UUID"];
+						$("#modelVersionId").val(
+								vfModuleModelUUID);
+						var vfModuleModelVersion = resourceVfc[prop]["version"];
+						$("#modelVersion").val(
+								vfModuleModelVersion);
+						var vfModuleModelCustomizationUUID = resourceVfc[prop]["customizationUUID"];
+						$("#modelCustomizationId")
+								.val(
+										vfModuleModelCustomizationUUID);
+					}
+				}
+			}
+			else {
+				$("#metadata *").prop('disabled',true);
+			}
+		}
 
 	    $scope.changeGuardPolicyType = function() {