ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tbeerbo...@apache.org
Subject ambari git commit: AMBARI-8519 - Views: Add new view parameter fields. (tbeerbower)
Date Wed, 03 Dec 2014 22:36:07 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk b87c52aeb -> a4b48f2ad


AMBARI-8519 - Views: Add new view parameter fields. (tbeerbower)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/a4b48f2a
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/a4b48f2a
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/a4b48f2a

Branch: refs/heads/trunk
Commit: a4b48f2ad71bf3bcdbc500314c7f403e383894b2
Parents: b87c52a
Author: tbeerbower <tbeerbower@hortonworks.com>
Authored: Wed Dec 3 17:35:20 2014 -0500
Committer: tbeerbower <tbeerbower@hortonworks.com>
Committed: Wed Dec 3 17:35:20 2014 -0500

----------------------------------------------------------------------
 .../internal/ViewInstanceResourceProvider.java  | 15 +---
 .../server/orm/entities/ViewInstanceEntity.java | 16 +++--
 .../orm/entities/ViewParameterEntity.java       | 75 +++++++++++++++++++-
 .../server/upgrade/UpgradeCatalog200.java       |  5 ++
 .../apache/ambari/server/view/ViewRegistry.java |  3 +
 .../view/configuration/ParameterConfig.java     | 44 ++++++++++++
 .../main/resources/Ambari-DDL-MySQL-CREATE.sql  |  3 +
 .../main/resources/Ambari-DDL-Oracle-CREATE.sql |  3 +
 .../resources/Ambari-DDL-Postgres-CREATE.sql    |  3 +
 .../Ambari-DDL-Postgres-EMBEDDED-CREATE.sql     |  3 +
 .../resources/Ambari-DDL-SQLServer-CREATE.sql   |  2 +-
 .../ViewInstanceResourceProviderTest.java       | 39 +++-------
 .../server/upgrade/UpgradeCatalog200Test.java   | 39 +++++++++-
 .../ambari/server/view/ViewContextImplTest.java | 11 ++-
 .../view/configuration/ParameterConfigTest.java | 27 +++++++
 .../view/configuration/ViewConfigTest.java      |  3 +
 ambari-server/src/test/resources/test_view.xml  |  3 +
 ambari-views/src/main/resources/view.xsd        | 15 ++++
 18 files changed, 256 insertions(+), 53 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/a4b48f2a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewInstanceResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewInstanceResourceProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewInstanceResourceProvider.java
index a944e95..12a8bee 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewInstanceResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewInstanceResourceProvider.java
@@ -33,8 +33,6 @@ import org.apache.ambari.server.controller.utilities.PropertyHelper;
 import org.apache.ambari.server.orm.entities.ViewEntity;
 import org.apache.ambari.server.orm.entities.ViewInstanceDataEntity;
 import org.apache.ambari.server.orm.entities.ViewInstanceEntity;
-import org.apache.ambari.server.orm.entities.ViewInstancePropertyEntity;
-import org.apache.ambari.server.orm.entities.ViewParameterEntity;
 import org.apache.ambari.server.view.ViewRegistry;
 import org.apache.ambari.server.view.validation.InstanceValidationResultImpl;
 import org.apache.ambari.server.view.validation.ValidationResultImpl;
@@ -232,19 +230,8 @@ public class ViewInstanceResourceProvider extends AbstractResourceProvider
{
 
     // only allow an admin to access the view properties
     if (ViewRegistry.getInstance().checkAdmin()) {
-
-      Map<String, String> properties = new HashMap<String, String>();
-
-      for (ViewInstancePropertyEntity viewInstancePropertyEntity : viewInstanceEntity.getProperties())
{
-        properties.put(viewInstancePropertyEntity.getName(), viewInstancePropertyEntity.getValue());
-      }
-      for (ViewParameterEntity viewParameterEntity : viewEntity.getParameters()) {
-        if (!properties.containsKey(viewParameterEntity.getName())) {
-          properties.put(viewParameterEntity.getName(), null);
-        }
-      }
       setResourceProperty(resource, PROPERTIES_PROPERTY_ID,
-          properties, requestedIds);
+          viewInstanceEntity.getPropertyMap(), requestedIds);
     }
 
     Map<String, String> applicationData = new HashMap<String, String>();

http://git-wip-us.apache.org/repos/asf/ambari/blob/a4b48f2a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ViewInstanceEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ViewInstanceEntity.java
b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ViewInstanceEntity.java
index 1dd1b5a..54a96ea 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ViewInstanceEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ViewInstanceEntity.java
@@ -272,9 +272,15 @@ public class ViewInstanceEntity implements ViewInstanceDefinition {
   public Map<String, String> getPropertyMap() {
     Map<String, String> propertyMap = new HashMap<String, String>();
 
-    for (ViewInstancePropertyEntity viewInstancePropertyEntity : properties) {
+    for (ViewInstancePropertyEntity viewInstancePropertyEntity : getProperties()) {
       propertyMap.put(viewInstancePropertyEntity.getName(), viewInstancePropertyEntity.getValue());
     }
+    for (ViewParameterEntity viewParameterEntity : view.getParameters()) {
+      String parameterName = viewParameterEntity.getName();
+      if (!propertyMap.containsKey(parameterName)) {
+        propertyMap.put(parameterName, viewParameterEntity.getDefaultValue());
+      }
+    }
     return propertyMap;
   }
 
@@ -751,9 +757,11 @@ public class ViewInstanceEntity implements ViewInstanceDefinition {
           requiredParameterNames.add(parameter.getName());
         }
       }
-      Collection<ViewInstancePropertyEntity> propertyEntities = getProperties();
-      for (ViewInstancePropertyEntity property : propertyEntities) {
-        requiredParameterNames.remove(property.getName());
+      Map<String, String> propertyMap = getPropertyMap();
+      for (Map.Entry<String, String> entry : propertyMap.entrySet()) {
+        if (entry.getValue() != null) {
+          requiredParameterNames.remove(entry.getKey());
+        }
       }
       // required but missing instance properties...
       for (String requiredParameterName : requiredParameterNames) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/a4b48f2a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ViewParameterEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ViewParameterEntity.java
b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ViewParameterEntity.java
index 0c4c70f..a8ddcdb 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ViewParameterEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ViewParameterEntity.java
@@ -47,11 +47,28 @@ public class ViewParameterEntity {
   /**
    * The parameter description.
    */
-  @Column
-  @Basic
+  @Column(name = "description")
   private String description;
 
   /**
+   * The parameter label.
+   */
+  @Column(name = "label")
+  private String label;
+
+  /**
+   * The placeholder.
+   */
+  @Column(name = "placeholder")
+  private String placeholder;
+
+  /**
+   * The default value.
+   */
+  @Column(name = "default_value")
+  private String defaultValue;
+
+  /**
    * Indicates whether or not the parameter is required.
    */
   @Column
@@ -178,4 +195,58 @@ public class ViewParameterEntity {
   public void setViewEntity(ViewEntity view) {
     this.view = view;
   }
+
+  /**
+   * Get the parameter label.
+   *
+   * @return the label
+   */
+  public String getLabel() {
+    return label;
+  }
+
+  /**
+   * Set the parameter label.
+   *
+   * @param label  the label
+   */
+  public void setLabel(String label) {
+    this.label = label;
+  }
+
+  /**
+   * Get the parameter placeholder.
+   *
+   * @return the placeholder
+   */
+  public String getPlaceholder() {
+    return placeholder;
+  }
+
+  /**
+   * Set the parameter placeholder.
+   *
+   * @param placeholder  the placeholder
+   */
+  public void setPlaceholder(String placeholder) {
+    this.placeholder = placeholder;
+  }
+
+  /**
+   * Get the parameter default value.
+   *
+   * @return the default value
+   */
+  public String getDefaultValue() {
+    return defaultValue;
+  }
+
+  /**
+   * Set the parameter default value.
+   *
+   * @param defaultValue  the parameter default value
+   */
+  public void setDefaultValue(String defaultValue) {
+    this.defaultValue = defaultValue;
+  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/a4b48f2a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog200.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog200.java
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog200.java
index 6d7c0bf..487b216 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog200.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog200.java
@@ -138,6 +138,11 @@ public class UpgradeCatalog200 extends AbstractUpgradeCatalog {
     dbAccessor.addColumn(ALERT_TARGET_TABLE, new DBColumnInfo("is_global",
         Short.class, 1, 0, false));
 
+    // add viewparameter columns
+    dbAccessor.addColumn("viewparameter", new DBColumnInfo("label", String.class, 255, null,
true));
+    dbAccessor.addColumn("viewparameter", new DBColumnInfo("placeholder", String.class, 255,
null, true));
+    dbAccessor.addColumn("viewparameter", new DBColumnInfo("default_value", String.class,
2000, null, true));
+
     // create alert_target_states table
     ArrayList<DBColumnInfo> columns = new ArrayList<DBColumnInfo>();
     columns.add(new DBColumnInfo("target_id", Long.class, null, null, false));

http://git-wip-us.apache.org/repos/asf/ambari/blob/a4b48f2a/ambari-server/src/main/java/org/apache/ambari/server/view/ViewRegistry.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/view/ViewRegistry.java b/ambari-server/src/main/java/org/apache/ambari/server/view/ViewRegistry.java
index 77c7c60..55f3a75 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/view/ViewRegistry.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/view/ViewRegistry.java
@@ -829,6 +829,9 @@ public class ViewRegistry {
       viewParameterEntity.setViewName(viewName);
       viewParameterEntity.setName(parameterConfiguration.getName());
       viewParameterEntity.setDescription(parameterConfiguration.getDescription());
+      viewParameterEntity.setLabel(parameterConfiguration.getLabel());
+      viewParameterEntity.setPlaceholder(parameterConfiguration.getPlaceholder());
+      viewParameterEntity.setDefaultValue(parameterConfiguration.getDefaultValue());
       viewParameterEntity.setRequired(parameterConfiguration.isRequired());
       viewParameterEntity.setMasked(parameterConfiguration.isMasked());
       viewParameterEntity.setViewEntity(viewDefinition);

http://git-wip-us.apache.org/repos/asf/ambari/blob/a4b48f2a/ambari-server/src/main/java/org/apache/ambari/server/view/configuration/ParameterConfig.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/view/configuration/ParameterConfig.java
b/ambari-server/src/main/java/org/apache/ambari/server/view/configuration/ParameterConfig.java
index 827b5e7..e983609 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/view/configuration/ParameterConfig.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/view/configuration/ParameterConfig.java
@@ -20,6 +20,7 @@ package org.apache.ambari.server.view.configuration;
 
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
 
 /**
  * View parameter configuration.
@@ -37,6 +38,22 @@ public class ParameterConfig {
   private String description;
 
   /**
+   * The parameter label.
+   */
+  private String label;
+
+  /**
+   * The parameter placeholder.
+   */
+  private String placeholder;
+
+  /**
+   * The parameter default value.
+   */
+  @XmlElement(name="default-value")
+  private String defaultValue;
+
+  /**
    * Indicates whether or not the parameter is required.
    */
   private boolean required;
@@ -65,6 +82,33 @@ public class ParameterConfig {
   }
 
   /**
+   * Get the parameter label.
+   *
+   * @return the label
+   */
+  public String getLabel() {
+    return label;
+  }
+
+  /**
+   * Get the parameter placeholder.
+   *
+   * @return the placeholder
+   */
+  public String getPlaceholder() {
+    return placeholder;
+  }
+
+  /**
+   * Get the parameter default value.
+   *
+   * @return the default value
+   */
+  public String getDefaultValue() {
+    return defaultValue;
+  }
+
+  /**
    * Indicates whether or not the parameter is required.
    *
    * @return true if the parameter is required; false otherwise

http://git-wip-us.apache.org/repos/asf/ambari/blob/a4b48f2a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
index 0de8fe5..e09a0c2 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
@@ -447,6 +447,9 @@ CREATE TABLE viewparameter (
   view_name VARCHAR(255) NOT NULL,
   name VARCHAR(255) NOT NULL,
   description VARCHAR(2048),
+  label VARCHAR(255),
+  placeholder VARCHAR(255),
+  default_value VARCHAR(2000),
   required CHAR(1),
   masked CHAR(1),
   PRIMARY KEY(view_name, name));

http://git-wip-us.apache.org/repos/asf/ambari/blob/a4b48f2a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
index edf3a0f..0b3c831 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
@@ -438,6 +438,9 @@ CREATE TABLE viewparameter (
   view_name VARCHAR(255) NOT NULL,
   name VARCHAR(255) NOT NULL,
   description VARCHAR(2048),
+  label VARCHAR(255),
+  placeholder VARCHAR(255),
+  default_value VARCHAR(2000),
   required CHAR(1),
   masked CHAR(1),
   PRIMARY KEY(view_name, name));

http://git-wip-us.apache.org/repos/asf/ambari/blob/a4b48f2a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
index 30908ce..203b5bb 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
@@ -438,6 +438,9 @@ CREATE TABLE viewparameter (
   view_name VARCHAR(255) NOT NULL,
   name VARCHAR(255) NOT NULL,
   description VARCHAR(2048),
+  label VARCHAR(255),
+  placeholder VARCHAR(255),
+  default_value VARCHAR(2000),
   required CHAR(1),
   masked CHAR(1),
   PRIMARY KEY(view_name, name));

http://git-wip-us.apache.org/repos/asf/ambari/blob/a4b48f2a/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
index 638862f..e311276 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
@@ -494,6 +494,9 @@ CREATE TABLE ambari.viewparameter (
   view_name VARCHAR(255) NOT NULL,
   name VARCHAR(255) NOT NULL,
   description VARCHAR(2048),
+  label VARCHAR(255),
+  placeholder VARCHAR(255),
+  default_value VARCHAR(2000),
   required CHAR(1),
   masked CHAR(1),
   PRIMARY KEY(view_name, name));

http://git-wip-us.apache.org/repos/asf/ambari/blob/a4b48f2a/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
index 8773fdc..bf4bf80 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
@@ -75,7 +75,7 @@ CREATE TABLE viewmain (view_name VARCHAR(255) NOT NULL, label VARCHAR(255),
desc
 CREATE TABLE viewinstancedata (view_instance_id BIGINT, view_name VARCHAR(255) NOT NULL,
view_instance_name VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, user_name VARCHAR(255)
NOT NULL, value VARCHAR(2000) NOT NULL, PRIMARY KEY(view_instance_id, name, user_name));
 CREATE TABLE viewinstance (view_instance_id BIGINT, resource_id BIGINT NOT NULL, view_name
VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, label VARCHAR(255), description VARCHAR(2048),
visible CHAR(1), icon VARCHAR(255), icon64 VARCHAR(255), xml_driven CHAR(1), PRIMARY KEY(view_instance_id));
 CREATE TABLE viewinstanceproperty (view_name VARCHAR(255) NOT NULL, view_instance_name VARCHAR(255)
NOT NULL, name VARCHAR(255) NOT NULL, value VARCHAR(2000) NOT NULL, PRIMARY KEY(view_name,
view_instance_name, name));
-CREATE TABLE viewparameter (view_name VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL,
description VARCHAR(2048), required CHAR(1), masked CHAR(1), PRIMARY KEY(view_name, name));
+CREATE TABLE viewparameter (view_name VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL,
description VARCHAR(2048), label VARCHAR(255), placeholder VARCHAR(255), default_value VARCHAR(2000),
required CHAR(1), masked CHAR(1), PRIMARY KEY(view_name, name));
 CREATE TABLE viewresource (view_name VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, plural_name
VARCHAR(255), id_property VARCHAR(255), subResource_names VARCHAR(255), provider VARCHAR(255),
service VARCHAR(255), resource VARCHAR(255), PRIMARY KEY(view_name, name));
 CREATE TABLE viewentity (id BIGINT NOT NULL, view_name VARCHAR(255) NOT NULL, view_instance_name
VARCHAR(255) NOT NULL, class_name VARCHAR(255) NOT NULL, id_property VARCHAR(255), PRIMARY
KEY(id));
 CREATE TABLE adminresourcetype (resource_type_id INTEGER NOT NULL, resource_type_name VARCHAR(255)
NOT NULL, PRIMARY KEY(resource_type_id));

http://git-wip-us.apache.org/repos/asf/ambari/blob/a4b48f2a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ViewInstanceResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ViewInstanceResourceProviderTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ViewInstanceResourceProviderTest.java
index 023cba5..31c65c3 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ViewInstanceResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ViewInstanceResourceProviderTest.java
@@ -26,8 +26,6 @@ import org.apache.ambari.server.controller.utilities.PropertyHelper;
 import org.apache.ambari.server.orm.entities.ViewEntity;
 import org.apache.ambari.server.orm.entities.ViewInstanceDataEntity;
 import org.apache.ambari.server.orm.entities.ViewInstanceEntity;
-import org.apache.ambari.server.orm.entities.ViewInstancePropertyEntity;
-import org.apache.ambari.server.orm.entities.ViewParameterEntity;
 import org.apache.ambari.server.view.ViewRegistry;
 import org.apache.ambari.server.view.configuration.ViewConfig;
 import org.apache.ambari.view.ViewDefinition;
@@ -36,7 +34,6 @@ import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
-import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -69,26 +66,19 @@ public class ViewInstanceResourceProviderTest {
     ViewEntity viewEntity = createNiceMock(ViewEntity.class);
     expect(viewInstanceEntity.getViewEntity()).andReturn(viewEntity).anyTimes();
 
-    ViewInstancePropertyEntity propertyEntity1 = createNiceMock(ViewInstancePropertyEntity.class);
-    expect(propertyEntity1.getName()).andReturn("par1").anyTimes();
-    expect(propertyEntity1.getValue()).andReturn("val1").anyTimes();
-    ViewInstancePropertyEntity propertyEntity3 = createNiceMock(ViewInstancePropertyEntity.class);
-    expect(propertyEntity3.getName()).andReturn("par3").anyTimes();
-    expect(propertyEntity3.getValue()).andReturn("val3").anyTimes();
-    expect(viewInstanceEntity.getProperties()).andReturn(Arrays.asList(propertyEntity1, propertyEntity3));
+    Map<String, String> propertyMap = new HashMap<String, String>();
 
-    ViewParameterEntity parameter1 = createNiceMock(ViewParameterEntity.class);
-    expect(parameter1.getName()).andReturn("par1").anyTimes();
-    ViewParameterEntity parameter2 = createNiceMock(ViewParameterEntity.class);
-    expect(parameter2.getName()).andReturn("par2").anyTimes();
-    expect(viewEntity.getParameters()).andReturn(Arrays.asList(parameter1, parameter2));
+    propertyMap.put("par1", "val1");
+    propertyMap.put("par2", "val2");
+
+    expect(viewInstanceEntity.getPropertyMap()).andReturn(propertyMap);
 
     expect(viewInstanceEntity.getData()).andReturn(Collections.<ViewInstanceDataEntity>emptyList()).anyTimes();
 
     expect(singleton.checkAdmin()).andReturn(true);
     expect(singleton.checkAdmin()).andReturn(false);
 
-    replay(singleton, viewEntity, viewInstanceEntity, parameter1, parameter2, propertyEntity1,
propertyEntity3);
+    replay(singleton, viewEntity, viewInstanceEntity);
 
     // as admin
     Resource resource = provider.toResource(viewInstanceEntity, propertyIds);
@@ -96,10 +86,9 @@ public class ViewInstanceResourceProviderTest {
     assertEquals(1, properties.size());
     Map<String, Object> props = properties.get("ViewInstanceInfo/properties");
     assertNotNull(props);
-    assertEquals(3, props.size());
+    assertEquals(2, props.size());
     assertEquals("val1", props.get("par1"));
-    assertEquals("val3", props.get("par3"));
-    assertNull(props.get("par2"));
+    assertEquals("val2", props.get("par2"));
 
     // as non-admin
     resource = provider.toResource(viewInstanceEntity, propertyIds);
@@ -107,7 +96,7 @@ public class ViewInstanceResourceProviderTest {
     props = properties.get("ViewInstanceInfo/properties");
     assertNull(props);
 
-    verify(singleton);
+    verify(singleton, viewEntity, viewInstanceEntity);
   }
 
   @Test
@@ -294,16 +283,6 @@ public class ViewInstanceResourceProviderTest {
   public void testDeleteResources_viewNotLoaded() throws Exception {
     ViewInstanceResourceProvider provider = new ViewInstanceResourceProvider();
 
-    Set<Map<String, Object>> properties = new HashSet<Map<String, Object>>();
-
-    Map<String, Object> propertyMap = new HashMap<String, Object>();
-
-    propertyMap.put(ViewInstanceResourceProvider.VIEW_NAME_PROPERTY_ID, "V1");
-    propertyMap.put(ViewInstanceResourceProvider.VIEW_VERSION_PROPERTY_ID, "1.0.0");
-    propertyMap.put(ViewInstanceResourceProvider.INSTANCE_NAME_PROPERTY_ID, "I1");
-
-    properties.add(propertyMap);
-
     PredicateBuilder predicateBuilder = new PredicateBuilder();
     Predicate predicate =
         predicateBuilder.property(ViewInstanceResourceProvider.VIEW_NAME_PROPERTY_ID).equals("V1").toPredicate();

http://git-wip-us.apache.org/repos/asf/ambari/blob/a4b48f2a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog200Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog200Test.java
b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog200Test.java
index 3c27559..4cf1b40 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog200Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog200Test.java
@@ -117,6 +117,11 @@ public class UpgradeCatalog200Test {
     Capture<DBAccessor.DBColumnInfo> hostComponentStateColumnCapture = new Capture<DBAccessor.DBColumnInfo>();
     Capture<DBAccessor.DBColumnInfo> hostComponentStateSecurityStateColumnCapture =
new Capture<DBAccessor.DBColumnInfo>();
     Capture<DBAccessor.DBColumnInfo> hostComponentDesiredStateSecurityStateColumnCapture
= new Capture<DBAccessor.DBColumnInfo>();
+
+    Capture<DBAccessor.DBColumnInfo> viewparameterLabelColumnCapture = new Capture<DBAccessor.DBColumnInfo>();
+    Capture<DBAccessor.DBColumnInfo> viewparameterPlaceholderColumnCapture = new Capture<DBAccessor.DBColumnInfo>();
+    Capture<DBAccessor.DBColumnInfo> viewparameterDefaultValueColumnCapture = new Capture<DBAccessor.DBColumnInfo>();
+
     Capture<DBAccessor.DBColumnInfo> serviceDesiredStateSecurityStateColumnCapture
= new Capture<DBAccessor.DBColumnInfo>();
     Capture<List<DBAccessor.DBColumnInfo>> clusterVersionCapture = new Capture<List<DBAccessor.DBColumnInfo>>();
     Capture<List<DBAccessor.DBColumnInfo>> hostVersionCapture = new Capture<List<DBAccessor.DBColumnInfo>>();
@@ -154,6 +159,10 @@ public class UpgradeCatalog200Test {
     dbAccessor.addColumn(eq("hostcomponentdesiredstate"),
         capture(hostComponentDesiredStateSecurityStateColumnCapture));
 
+    dbAccessor.addColumn(eq("viewparameter"), capture(viewparameterLabelColumnCapture));
+    dbAccessor.addColumn(eq("viewparameter"), capture(viewparameterPlaceholderColumnCapture));
+    dbAccessor.addColumn(eq("viewparameter"), capture(viewparameterDefaultValueColumnCapture));
+
     // Service Desired State: security State
     dbAccessor.addColumn(eq("servicedesiredstate"),
         capture(serviceDesiredStateSecurityStateColumnCapture));
@@ -213,6 +222,9 @@ public class UpgradeCatalog200Test {
     verifyComponentSecurityStateColumn(hostComponentDesiredStateSecurityStateColumnCapture);
     verifyServiceSecurityStateColumn(serviceDesiredStateSecurityStateColumnCapture);
 
+    verifyViewParameterColumns(viewparameterLabelColumnCapture, viewparameterPlaceholderColumnCapture,
+        viewparameterDefaultValueColumnCapture);
+
     // Verify capture group sizes
     assertEquals(8, clusterVersionCapture.getValue().size());
     assertEquals(5, hostVersionCapture.getValue().size());
@@ -340,7 +352,7 @@ public class UpgradeCatalog200Test {
   /**
    * Verifies new description column for alert definition.
    *
-   * @param alertDefinitionIgnoreColumnCapture
+   * @param alertDefinitionDescriptionColumnCapture
    */
   private void verifyAlertDefinitionDescriptionColumn(
       Capture<DBAccessor.DBColumnInfo> alertDefinitionDescriptionColumnCapture) {
@@ -401,6 +413,31 @@ public class UpgradeCatalog200Test {
     Assert.assertEquals("security_state", column.getName());
   }
 
+  private void verifyViewParameterColumns(
+      Capture<DBAccessor.DBColumnInfo> labelColumnCapture,
+      Capture<DBAccessor.DBColumnInfo> placeholderColumnCapture,
+      Capture<DBAccessor.DBColumnInfo> defaultValueColumnCapture) {
+
+
+    DBColumnInfo column = labelColumnCapture.getValue();
+    assertNull(column.getDefaultValue());
+    Assert.assertEquals(Integer.valueOf(255), column.getLength());
+    Assert.assertEquals(String.class, column.getType());
+    Assert.assertEquals("label", column.getName());
+
+    column = placeholderColumnCapture.getValue();
+    assertNull(column.getDefaultValue());
+    Assert.assertEquals(Integer.valueOf(255), column.getLength());
+    Assert.assertEquals(String.class, column.getType());
+    Assert.assertEquals("placeholder", column.getName());
+
+    column = defaultValueColumnCapture.getValue();
+    assertNull(column.getDefaultValue());
+    Assert.assertEquals(Integer.valueOf(2000), column.getLength());
+    Assert.assertEquals(String.class, column.getType());
+    Assert.assertEquals("default_value", column.getName());
+  }
+
   @Test
   public void testGetSourceVersion() {
     final DBAccessor dbAccessor = createNiceMock(DBAccessor.class);

http://git-wip-us.apache.org/repos/asf/ambari/blob/a4b48f2a/ambari-server/src/test/java/org/apache/ambari/server/view/ViewContextImplTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/view/ViewContextImplTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/view/ViewContextImplTest.java
index 519d010..94d5458 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/view/ViewContextImplTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/view/ViewContextImplTest.java
@@ -22,6 +22,7 @@ import org.apache.ambari.server.controller.spi.Resource;
 import org.apache.ambari.server.orm.entities.ViewEntity;
 import org.apache.ambari.server.orm.entities.ViewEntityTest;
 import org.apache.ambari.server.orm.entities.ViewInstanceEntity;
+import org.apache.ambari.server.orm.entities.ViewParameterEntity;
 import org.apache.ambari.server.view.configuration.InstanceConfig;
 import org.apache.ambari.server.view.configuration.InstanceConfigTest;
 import org.apache.ambari.server.view.configuration.ViewConfigTest;
@@ -29,6 +30,7 @@ import org.apache.ambari.view.ResourceProvider;
 import org.junit.Assert;
 import org.junit.Test;
 
+import java.util.Arrays;
 import java.util.Map;
 
 import static org.easymock.EasyMock.createMockBuilder;
@@ -93,7 +95,14 @@ public class ViewContextImplTest {
     expect(viewDefinition.getCommonName()).andReturn("View").times(2);
     expect(viewDefinition.getClassLoader()).andReturn(ViewContextImplTest.class.getClassLoader()).anyTimes();
     expect(viewDefinition.getConfiguration()).andReturn(ViewConfigTest.getConfig()).anyTimes();
-    replay(viewDefinition);
+
+    ViewParameterEntity parameter1 = createNiceMock(ViewParameterEntity.class);
+    expect(parameter1.getName()).andReturn("p1").anyTimes();
+    ViewParameterEntity parameter2 = createNiceMock(ViewParameterEntity.class);
+    expect(parameter2.getName()).andReturn("p2").anyTimes();
+    expect(viewDefinition.getParameters()).andReturn(Arrays.asList(parameter1, parameter2)).anyTimes();
+
+    replay(viewDefinition, parameter1, parameter2);
     ViewInstanceEntity viewInstanceDefinition = createMockBuilder(ViewInstanceEntity.class)
         .addMockedMethod("getUsername")
         .addMockedMethod("getName")

http://git-wip-us.apache.org/repos/asf/ambari/blob/a4b48f2a/ambari-server/src/test/java/org/apache/ambari/server/view/configuration/ParameterConfigTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/view/configuration/ParameterConfigTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/view/configuration/ParameterConfigTest.java
index e3350bc..278e441 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/view/configuration/ParameterConfigTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/view/configuration/ParameterConfigTest.java
@@ -47,6 +47,33 @@ public class ParameterConfigTest {
   }
 
   @Test
+  public void testGetLabel() throws Exception {
+    List<ParameterConfig> parameters = getParameterConfigs();
+
+    Assert.assertEquals(2, parameters.size());
+    Assert.assertEquals("Label 1.", parameters.get(0).getLabel());
+    Assert.assertNull(parameters.get(1).getLabel());
+  }
+
+  @Test
+  public void testGetPlaceholder() throws Exception {
+    List<ParameterConfig> parameters = getParameterConfigs();
+
+    Assert.assertEquals(2, parameters.size());
+    Assert.assertEquals("Placeholder 1.", parameters.get(0).getPlaceholder());
+    Assert.assertNull(parameters.get(1).getPlaceholder());
+  }
+
+  @Test
+  public void testGetDefaultValue() throws Exception {
+    List<ParameterConfig> parameters = getParameterConfigs();
+
+    Assert.assertEquals(2, parameters.size());
+    Assert.assertNull(parameters.get(0).getDefaultValue());
+    Assert.assertEquals("Default value 1.", parameters.get(1).getDefaultValue());
+  }
+
+  @Test
   public void testIsRequired() throws Exception {
     List<ParameterConfig> parameters = getParameterConfigs();
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/a4b48f2a/ambari-server/src/test/java/org/apache/ambari/server/view/configuration/ViewConfigTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/view/configuration/ViewConfigTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/view/configuration/ViewConfigTest.java
index 04cbe2b..50a1223 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/view/configuration/ViewConfigTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/view/configuration/ViewConfigTest.java
@@ -58,11 +58,14 @@ public class ViewConfigTest {
       "    <parameter>\n" +
       "        <name>p1</name>\n" +
       "        <description>Parameter 1.</description>\n" +
+      "        <label>Label 1.</label>\n" +
+      "        <placeholder>Placeholder 1.</placeholder>\n" +
       "        <required>true</required>\n" +
       "    </parameter>\n" +
       "    <parameter>\n" +
       "        <name>p2</name>\n" +
       "        <description>Parameter 2.</description>\n" +
+      "        <default-value>Default value 1.</default-value>\n" +
       "        <required>false</required>\n" +
       "        <masked>true</masked>" +
       "    </parameter>\n" +

http://git-wip-us.apache.org/repos/asf/ambari/blob/a4b48f2a/ambari-server/src/test/resources/test_view.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/resources/test_view.xml b/ambari-server/src/test/resources/test_view.xml
index 5742bfe..cabede8 100644
--- a/ambari-server/src/test/resources/test_view.xml
+++ b/ambari-server/src/test/resources/test_view.xml
@@ -27,6 +27,9 @@
   <parameter>
     <name>parameter1</name>
     <description>str1234</description>
+    <label>str1234</label>
+    <placeholder>str1234</placeholder>
+    <default-value>str1234</default-value>
     <required>true</required>
     <masked>true</masked>
   </parameter>

http://git-wip-us.apache.org/repos/asf/ambari/blob/a4b48f2a/ambari-views/src/main/resources/view.xsd
----------------------------------------------------------------------
diff --git a/ambari-views/src/main/resources/view.xsd b/ambari-views/src/main/resources/view.xsd
index a9e5b12..f4d65c4 100644
--- a/ambari-views/src/main/resources/view.xsd
+++ b/ambari-views/src/main/resources/view.xsd
@@ -33,6 +33,21 @@
           <xs:documentation>The description of the configuration parameter.</xs:documentation>
         </xs:annotation>
       </xs:element>
+      <xs:element type="xs:string" name="label" minOccurs="0" maxOccurs="1">
+        <xs:annotation>
+          <xs:documentation>The label for the configuration parameter.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element type="xs:string" name="placeholder" minOccurs="0" maxOccurs="1">
+        <xs:annotation>
+          <xs:documentation>The placeholder for the configuration parameter.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element type="xs:string" name="default-value" minOccurs="0" maxOccurs="1">
+        <xs:annotation>
+          <xs:documentation>The default value of the configuration parameter.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
       <xs:element type="xs:boolean" name="required" minOccurs="0" maxOccurs="1" default="false">
         <xs:annotation>
           <xs:documentation>If true, the configuration parameter is required in order
to create a view instance.  The default is false (not required).</xs:documentation>


Mime
View raw message