ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tbeerbo...@apache.org
Subject git commit: AMBARI-6006 - Views: Add <description> to view instance - AMBARI-6013 - Provide <visible> property on view instance
Date Tue, 03 Jun 2014 20:11:51 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 5831b8dd7 -> 1ea7498d7


AMBARI-6006 - Views: Add <description> to view instance - AMBARI-6013 - Provide <visible>
property on view instance


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

Branch: refs/heads/trunk
Commit: 1ea7498d7bbc70e50a5c6a8a710234f6599aac9b
Parents: 5831b8d
Author: tbeerbower <tbeerbower@hortonworks.com>
Authored: Tue Jun 3 11:00:25 2014 -0400
Committer: tbeerbower <tbeerbower@hortonworks.com>
Committed: Tue Jun 3 16:11:11 2014 -0400

----------------------------------------------------------------------
 .../internal/ViewInstanceResourceProvider.java  | 14 ++++++
 .../server/orm/entities/ViewInstanceEntity.java | 46 ++++++++++++++++++++
 .../server/upgrade/UpgradeCatalog161.java       |  6 +++
 .../apache/ambari/server/view/ViewRegistry.java |  4 ++
 .../view/configuration/InstanceConfig.java      | 32 +++++++++++++-
 .../main/resources/Ambari-DDL-MySQL-CREATE.sql  |  2 +-
 .../main/resources/Ambari-DDL-Oracle-CREATE.sql |  2 +-
 .../resources/Ambari-DDL-Postgres-CREATE.sql    |  2 +-
 .../Ambari-DDL-Postgres-EMBEDDED-CREATE.sql     |  2 +-
 .../orm/entities/ViewInstanceEntityTest.java    | 43 ++++++++++++++++++
 .../server/upgrade/UpgradeCatalog161Test.java   | 36 ++++++++++++---
 .../view/configuration/InstanceConfigTest.java  | 37 ++++++++++++++++
 .../view/configuration/ViewConfigTest.java      |  1 +
 .../ambari/view/ViewInstanceDefinition.java     | 22 ++++++++--
 14 files changed, 233 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/1ea7498d/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 af3a549..70e95a2 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
@@ -55,6 +55,8 @@ public class ViewInstanceResourceProvider extends AbstractResourceProvider
{
   public static final String VIEW_VERSION_PROPERTY_ID  = "ViewInstanceInfo/version";
   public static final String INSTANCE_NAME_PROPERTY_ID = "ViewInstanceInfo/instance_name";
   public static final String LABEL_PROPERTY_ID         = "ViewInstanceInfo/label";
+  public static final String DESCRIPTION_PROPERTY_ID   = "ViewInstanceInfo/description";
+  public static final String VISIBLE_PROPERTY_ID       = "ViewInstanceInfo/visible";
   public static final String PROPERTIES_PROPERTY_ID    = "ViewInstanceInfo/properties";
   public static final String DATA_PROPERTY_ID          = "ViewInstanceInfo/instance_data";
   public static final String CONTEXT_PATH_PROPERTY_ID  = "ViewInstanceInfo/context_path";
@@ -84,6 +86,8 @@ public class ViewInstanceResourceProvider extends AbstractResourceProvider
{
     propertyIds.add(VIEW_VERSION_PROPERTY_ID);
     propertyIds.add(INSTANCE_NAME_PROPERTY_ID);
     propertyIds.add(LABEL_PROPERTY_ID);
+    propertyIds.add(DESCRIPTION_PROPERTY_ID);
+    propertyIds.add(VISIBLE_PROPERTY_ID);
     propertyIds.add(PROPERTIES_PROPERTY_ID);
     propertyIds.add(DATA_PROPERTY_ID);
     propertyIds.add(CONTEXT_PATH_PROPERTY_ID);
@@ -201,6 +205,8 @@ public class ViewInstanceResourceProvider extends AbstractResourceProvider
{
     setResourceProperty(resource, VIEW_VERSION_PROPERTY_ID, version, requestedIds);
     setResourceProperty(resource, INSTANCE_NAME_PROPERTY_ID, name, requestedIds);
     setResourceProperty(resource, LABEL_PROPERTY_ID, viewInstanceEntity.getLabel(), requestedIds);
+    setResourceProperty(resource, DESCRIPTION_PROPERTY_ID, viewInstanceEntity.getDescription(),
requestedIds);
+    setResourceProperty(resource, VISIBLE_PROPERTY_ID, viewInstanceEntity.isVisible(), requestedIds);
     Map<String, String> properties = new HashMap<String, String>();
 
     for (ViewInstancePropertyEntity viewInstancePropertyEntity : viewInstanceEntity.getProperties())
{
@@ -257,6 +263,14 @@ public class ViewInstanceResourceProvider extends AbstractResourceProvider
{
       viewInstanceEntity.setLabel(label);
     }
 
+    String description = (String) properties.get(DESCRIPTION_PROPERTY_ID);
+    if (description != null) {
+      viewInstanceEntity.setDescription(description);
+    }
+
+    String visible = (String) properties.get(VISIBLE_PROPERTY_ID);
+    viewInstanceEntity.setVisible(visible==null ? true : Boolean.valueOf(visible));
+
     Collection<ViewInstancePropertyEntity> instanceProperties = new HashSet<ViewInstancePropertyEntity>();
     Collection<ViewInstanceDataEntity>     instanceData       = new HashSet<ViewInstanceDataEntity>();
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/1ea7498d/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 a4900e6..5351a74 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
@@ -78,6 +78,20 @@ public class ViewInstanceEntity implements ViewInstanceDefinition {
   private String label;
 
   /**
+   * The description.
+   */
+  @Column
+  @Basic
+  private String description;
+
+  /**
+   * Visible flag.
+   */
+  @Column
+  @Basic
+  private char visible;
+
+  /**
    * The instance properties.
    */
   @OneToMany(cascade = CascadeType.ALL, mappedBy = "viewInstance")
@@ -147,6 +161,8 @@ public class ViewInstanceEntity implements ViewInstanceDefinition {
     this.instanceConfig = instanceConfig;
     this.view           = view;
     this.viewName       = view.getName();
+    this.description    = instanceConfig.getDescription();
+    this.visible        = instanceConfig.isVisible() ? 'Y' : 'N';
 
     String label = instanceConfig.getLabel();
     this.label = (label == null || label.length()== 0) ? view.getLabel() : label;
@@ -163,6 +179,8 @@ public class ViewInstanceEntity implements ViewInstanceDefinition {
     this.instanceConfig = null;
     this.view           = view;
     this.viewName       = view.getName();
+    this.description    = null;
+    this.visible        = 'Y';
     this.label          = view.getLabel();
   }
 
@@ -213,6 +231,16 @@ public class ViewInstanceEntity implements ViewInstanceDefinition {
     return label;
   }
 
+  @Override
+  public String getDescription() {
+    return description;
+  }
+
+  @Override
+  public boolean isVisible() {
+    return visible == 'y' || visible == 'Y';
+  }
+
 
   // ----- ViewInstanceEntity ------------------------------------------------
 
@@ -253,6 +281,24 @@ public class ViewInstanceEntity implements ViewInstanceDefinition {
   }
 
   /**
+   * Set the description.
+   *
+   * @param description  the description
+   */
+  public void setDescription(String description) {
+    this.description = description;
+  }
+
+  /**
+   * Set the visible flag.
+   *
+   * @param visible  visible flag
+   */
+  public void setVisible(boolean visible) {
+    this.visible = (visible ? 'Y' : 'N');
+  }
+
+  /**
    * Get the instance properties.
    *
    * @return the instance properties

http://git-wip-us.apache.org/repos/asf/ambari/blob/1ea7498d/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog161.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog161.java
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog161.java
index fa1861a..f75278e 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog161.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog161.java
@@ -82,6 +82,12 @@ public class UpgradeCatalog161 extends AbstractUpgradeCatalog {
     dbAccessor.addColumn("viewinstance",
         new DBAccessor.DBColumnInfo("label", String.class, 255, null, true));
 
+    dbAccessor.addColumn("viewinstance",
+        new DBAccessor.DBColumnInfo("description", String.class, 255, null, true));
+
+    dbAccessor.addColumn("viewinstance",
+        new DBAccessor.DBColumnInfo("visible", Character.class, 1, null, true));
+
     // ========================================================================
     // Add constraints
     dbAccessor.addFKConstraint("requestoperationlevel", "FK_req_op_level_req_id",

http://git-wip-us.apache.org/repos/asf/ambari/blob/1ea7498d/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 966f50a..b1c0f4c 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
@@ -439,6 +439,8 @@ public class ViewRegistry {
               version + "/" + instanceName);
         }
         entity.setLabel(instanceEntity.getLabel());
+        entity.setDescription(instanceEntity.getDescription());
+        entity.setVisible(instanceEntity.isVisible());
         entity.setProperties(instanceEntity.getProperties());
         entity.setData(instanceEntity.getData());
 
@@ -815,6 +817,8 @@ public class ViewRegistry {
         } else {
           // apply overrides to the in-memory view instance entities
           instanceDefinition.setLabel(viewInstanceEntity.getLabel());
+          instanceDefinition.setDescription(viewInstanceEntity.getDescription());
+          instanceDefinition.setVisible(viewInstanceEntity.isVisible());
           instanceDefinition.setData(viewInstanceEntity.getData());
           instanceDefinition.setProperties(viewInstanceEntity.getProperties());
           instanceDefinition.setEntities(viewInstanceEntity.getEntities());

http://git-wip-us.apache.org/repos/asf/ambari/blob/1ea7498d/ambari-server/src/main/java/org/apache/ambari/server/view/configuration/InstanceConfig.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/view/configuration/InstanceConfig.java
b/ambari-server/src/main/java/org/apache/ambari/server/view/configuration/InstanceConfig.java
index 95441c6..f37cd80 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/view/configuration/InstanceConfig.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/view/configuration/InstanceConfig.java
@@ -40,6 +40,16 @@ public class InstanceConfig {
   private String label;
 
   /**
+   * The instance description.
+   */
+  private String description;
+
+  /**
+   * Indicates whether or not the instance should be visible.
+   */
+  private boolean visible = true;
+
+  /**
    * The instance properties.
    */
   @XmlElement(name="property")
@@ -55,15 +65,33 @@ public class InstanceConfig {
   }
 
   /**
-   * Get the public view name.
+   * Get the public view instance label.
    *
-   * @return the view label
+   * @return the view instance label
    */
   public String getLabel() {
     return label;
   }
 
   /**
+   * Get the  view instance description.
+   *
+   * @return the view instance description
+   */
+  public String getDescription() {
+    return description;
+  }
+
+  /**
+   * Indicates whether or not the instance should be visible.
+   *
+   * @return true if the instance should be visible; false otherwise
+   */
+  public boolean isVisible() {
+    return visible;
+  }
+
+  /**
    * Get the instance properties.
    *
    * @return the instance properties

http://git-wip-us.apache.org/repos/asf/ambari/blob/1ea7498d/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 67fb846..282c170 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
@@ -64,7 +64,7 @@ CREATE TABLE blueprint_configuration (blueprint_name VARCHAR(255) NOT NULL,
type
 CREATE TABLE hostgroup_configuration (blueprint_name VARCHAR(255) NOT NULL, hostgroup_name
VARCHAR(255) NOT NULL, type_name VARCHAR(255) NOT NULL, config_data TEXT NOT NULL, PRIMARY
KEY(blueprint_name, hostgroup_name, type_name));
 CREATE TABLE viewmain (view_name VARCHAR(255) NOT NULL, label VARCHAR(255), version VARCHAR(255),
archive VARCHAR(255), PRIMARY KEY(view_name));
 CREATE TABLE viewinstancedata (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_name, view_instance_name, name, user_name));
-CREATE TABLE viewinstance (view_name VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, label
VARCHAR(255), PRIMARY KEY(view_name, name));
+CREATE TABLE viewinstance (view_name VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, label
VARCHAR(255), description VARCHAR(255), visible CHAR(1), PRIMARY KEY(view_name, name));
 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(255), required 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));

http://git-wip-us.apache.org/repos/asf/ambari/blob/1ea7498d/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 5ec05fd..e14a174 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
@@ -54,7 +54,7 @@ CREATE TABLE blueprint_configuration (blueprint_name VARCHAR2(255) NOT NULL,
typ
 CREATE TABLE hostgroup_configuration (blueprint_name VARCHAR2(255) NOT NULL, hostgroup_name
VARCHAR2(255) NOT NULL, type_name VARCHAR2(255) NOT NULL, config_data CLOB NOT NULL, PRIMARY
KEY(blueprint_name, hostgroup_name, type_name));
 CREATE TABLE viewmain (view_name VARCHAR(255) NOT NULL, label VARCHAR(255), version VARCHAR(255),
archive VARCHAR(255), PRIMARY KEY(view_name));
 CREATE TABLE viewinstancedata (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_name, view_instance_name, name, user_name));
-CREATE TABLE viewinstance (view_name VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, label
VARCHAR(255), PRIMARY KEY(view_name, name));
+CREATE TABLE viewinstance (view_name VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, label
VARCHAR(255), description VARCHAR(255), visible CHAR(1), PRIMARY KEY(view_name, name));
 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(255), required 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));

http://git-wip-us.apache.org/repos/asf/ambari/blob/1ea7498d/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 72ed1eb..0bce052 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
@@ -87,7 +87,7 @@ CREATE TABLE hostgroup_configuration (blueprint_name VARCHAR(255) NOT NULL,
host
 
 CREATE TABLE viewmain (view_name VARCHAR(255) NOT NULL, label VARCHAR(255), version VARCHAR(255),
archive VARCHAR(255), PRIMARY KEY(view_name));
 CREATE TABLE viewinstancedata (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_name, view_instance_name, name, user_name));
-CREATE TABLE viewinstance (view_name VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, label
VARCHAR(255), PRIMARY KEY(view_name, name));
+CREATE TABLE viewinstance (view_name VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, label
VARCHAR(255), description VARCHAR(255), visible CHAR(1), PRIMARY KEY(view_name, name));
 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(255), required 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));

http://git-wip-us.apache.org/repos/asf/ambari/blob/1ea7498d/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 c2440ce..852ff9c 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
@@ -134,7 +134,7 @@ GRANT ALL PRIVILEGES ON TABLE ambari.hostgroup_configuration TO :username;
 
 CREATE TABLE ambari.viewmain (view_name VARCHAR(255) NOT NULL, label VARCHAR(255), version
VARCHAR(255), archive VARCHAR(255), PRIMARY KEY(view_name));
 CREATE TABLE ambari.viewinstancedata (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_name, view_instance_name, name, user_name));
-CREATE TABLE ambari.viewinstance (view_name VARCHAR(255) NOT NULL, name VARCHAR(255) NOT
NULL, label VARCHAR(255), PRIMARY KEY(view_name, name));
+CREATE TABLE ambari.viewinstance (view_name VARCHAR(255) NOT NULL, name VARCHAR(255) NOT
NULL, label VARCHAR(255), description VARCHAR(255), visible CHAR(1), PRIMARY KEY(view_name,
name));
 CREATE TABLE ambari.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 ambari.viewparameter (view_name VARCHAR(255) NOT NULL, name VARCHAR(255) NOT
NULL, description VARCHAR(255), required CHAR(1), PRIMARY KEY(view_name, name));
 CREATE TABLE ambari.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));

http://git-wip-us.apache.org/repos/asf/ambari/blob/1ea7498d/ambari-server/src/test/java/org/apache/ambari/server/orm/entities/ViewInstanceEntityTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/orm/entities/ViewInstanceEntityTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/orm/entities/ViewInstanceEntityTest.java
index a6653cc..7b3b013 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/orm/entities/ViewInstanceEntityTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/orm/entities/ViewInstanceEntityTest.java
@@ -46,6 +46,13 @@ public class ViewInstanceEntityTest {
       "    <instance>\n" +
       "        <name>INSTANCE1</name>\n" +
       "        <label>My Instance 1!</label>\n" +
+      "        <description>This is an instance description.</description>\n"
+
+      "        <visible>true</visible>\n" +
+      "    </instance>\n" +
+      "    <instance>\n" +
+      "        <name>INSTANCE2</name>\n" +
+      "        <label>My Instance 2!</label>\n" +
+      "        <visible>false</visible>\n" +
       "    </instance>\n" +
       "</view>";
 
@@ -150,6 +157,42 @@ public class ViewInstanceEntityTest {
   }
 
   @Test
+  public void testGetDescription() throws Exception {
+    InstanceConfig instanceConfig = InstanceConfigTest.getInstanceConfigs(xml_with_instance_label).get(0);
+    ViewEntity viewDefinition = ViewEntityTest.getViewEntity();
+    ViewInstanceEntity viewInstanceDefinition = new ViewInstanceEntity(viewDefinition, instanceConfig);
+
+    Assert.assertEquals("This is an instance description.", viewInstanceDefinition.getDescription());
+
+    instanceConfig = InstanceConfigTest.getInstanceConfigs(xml_without_instance_label).get(0);
+    viewDefinition = ViewEntityTest.getViewEntity();
+    viewInstanceDefinition = new ViewInstanceEntity(viewDefinition, instanceConfig);
+
+    Assert.assertNull(viewInstanceDefinition.getDescription());
+  }
+
+  @Test
+  public void testIsVisible() throws Exception {
+    InstanceConfig instanceConfig = InstanceConfigTest.getInstanceConfigs(xml_with_instance_label).get(0);
+    ViewEntity viewDefinition = ViewEntityTest.getViewEntity();
+    ViewInstanceEntity viewInstanceDefinition = new ViewInstanceEntity(viewDefinition, instanceConfig);
+
+    Assert.assertTrue(viewInstanceDefinition.isVisible());
+
+    instanceConfig = InstanceConfigTest.getInstanceConfigs(xml_with_instance_label).get(1);
+    viewDefinition = ViewEntityTest.getViewEntity();
+    viewInstanceDefinition = new ViewInstanceEntity(viewDefinition, instanceConfig);
+
+    Assert.assertFalse(viewInstanceDefinition.isVisible());
+
+    instanceConfig = InstanceConfigTest.getInstanceConfigs(xml_without_instance_label).get(0);
+    viewDefinition = ViewEntityTest.getViewEntity();
+    viewInstanceDefinition = new ViewInstanceEntity(viewDefinition, instanceConfig);
+
+    Assert.assertTrue(viewInstanceDefinition.isVisible());
+  }
+
+  @Test
   public void testAddGetProperty() throws Exception {
     ViewInstanceEntity viewInstanceDefinition = getViewInstanceEntity();
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/1ea7498d/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog161Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog161Test.java
b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog161Test.java
index 9904c0c..b520e1e 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog161Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog161Test.java
@@ -67,10 +67,12 @@ public class UpgradeCatalog161Test {
     Capture<DBAccessor.DBColumnInfo> provisioningStateColumnCapture = new Capture<DBAccessor.DBColumnInfo>();
     Capture<List<DBAccessor.DBColumnInfo>> operationLevelEntityColumnCapture
= new Capture<List<DBAccessor.DBColumnInfo>>();
     Capture<DBAccessor.DBColumnInfo> labelColumnCapture = new Capture<DBAccessor.DBColumnInfo>();
+    Capture<DBAccessor.DBColumnInfo> descriptionColumnCapture = new Capture<DBAccessor.DBColumnInfo>();
+    Capture<DBAccessor.DBColumnInfo> visibleColumnCapture = new Capture<DBAccessor.DBColumnInfo>();
 
     setClustersConfigExpectations(dbAccessor, provisioningStateColumnCapture);    
     setOperationLevelEntityConfigExpectations(dbAccessor, operationLevelEntityColumnCapture);
-    setViewInstanceExpectations(dbAccessor, labelColumnCapture);
+    setViewInstanceExpectations(dbAccessor, labelColumnCapture, descriptionColumnCapture,
visibleColumnCapture);
 
     replay(dbAccessor, configuration);
     AbstractUpgradeCatalog upgradeCatalog = getUpgradeCatalog(dbAccessor);
@@ -84,7 +86,7 @@ public class UpgradeCatalog161Test {
 
     assertClusterColumns(provisioningStateColumnCapture);
     assertOperationLevelEntityColumns(operationLevelEntityColumnCapture);
-    assertViewInstanceColumns(labelColumnCapture);
+    assertViewInstanceColumns(labelColumnCapture, descriptionColumnCapture, visibleColumnCapture);
   }
 
   @SuppressWarnings("unchecked")
@@ -238,22 +240,44 @@ public class UpgradeCatalog161Test {
 
 
   private void setViewInstanceExpectations(DBAccessor dbAccessor,
-                                             Capture<DBAccessor.DBColumnInfo> labelColumnCapture)
throws SQLException {
+                                           Capture<DBAccessor.DBColumnInfo> labelColumnCapture,
+                                           Capture<DBAccessor.DBColumnInfo> descriptionColumnCapture,
+                                           Capture<DBAccessor.DBColumnInfo> visibleColumnCapture)
+      throws SQLException {
 
     dbAccessor.addColumn(eq("viewinstance"),
         capture(labelColumnCapture));
+
+    dbAccessor.addColumn(eq("viewinstance"),
+        capture(descriptionColumnCapture));
+
+    dbAccessor.addColumn(eq("viewinstance"),
+        capture(visibleColumnCapture));
   }
 
   private void assertViewInstanceColumns(
-      Capture<DBAccessor.DBColumnInfo> labelColumnCapture) {
+      Capture<DBAccessor.DBColumnInfo> labelColumnCapture,
+      Capture<DBAccessor.DBColumnInfo> descriptionColumnCapture,
+      Capture<DBAccessor.DBColumnInfo> visibleColumnCapture) {
     DBAccessor.DBColumnInfo column = labelColumnCapture.getValue();
     assertEquals("label", column.getName());
     assertEquals(255, (int) column.getLength());
     assertEquals(String.class, column.getType());
     assertNull(column.getDefaultValue());
     assertTrue(column.isNullable());
-  }
-
 
+    column = descriptionColumnCapture.getValue();
+    assertEquals("description", column.getName());
+    assertEquals(255, (int) column.getLength());
+    assertEquals(String.class, column.getType());
+    assertNull(column.getDefaultValue());
+    assertTrue(column.isNullable());
 
+    column = visibleColumnCapture.getValue();
+    assertEquals("visible", column.getName());
+    assertEquals(1, (int) column.getLength());
+    assertEquals(Character.class, column.getType());
+    assertNull(column.getDefaultValue());
+    assertTrue(column.isNullable());
+  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/1ea7498d/ambari-server/src/test/java/org/apache/ambari/server/view/configuration/InstanceConfigTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/view/configuration/InstanceConfigTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/view/configuration/InstanceConfigTest.java
index a10f321..09fef94 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/view/configuration/InstanceConfigTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/view/configuration/InstanceConfigTest.java
@@ -47,6 +47,24 @@ public class InstanceConfigTest {
       "    </instance>\n" +
       "</view>";
 
+  private static String xml_visible = "<view>\n" +
+      "    <name>MY_VIEW</name>\n" +
+      "    <label>My View!</label>\n" +
+      "    <version>1.0.0</version>\n" +
+      "    <instance>\n" +
+      "        <name>INSTANCE1</name>\n" +
+      "        <visible>true</visible>\n" +
+      "    </instance>\n" +
+      "    <instance>\n" +
+      "        <name>INSTANCE2</name>\n" +
+      "        <visible>false</visible>\n" +
+      "    </instance>\n" +
+      "    <instance>\n" +
+      "        <name>INSTANCE3</name>\n" +
+      "    </instance>\n" +
+      "</view>";
+
+
   @Test
   public void testGetName() throws Exception {
     List<InstanceConfig> instances = getInstanceConfigs();
@@ -66,6 +84,25 @@ public class InstanceConfigTest {
   }
 
   @Test
+  public void testGetDescription() throws Exception {
+    List<InstanceConfig> instances = getInstanceConfigs();
+
+    Assert.assertEquals(2, instances.size());
+    Assert.assertEquals("This is a description.", instances.get(0).getDescription());
+    Assert.assertNull(instances.get(1).getDescription());
+  }
+
+  @Test
+  public void testIsVisible() throws Exception {
+    List<InstanceConfig> instances = getInstanceConfigs(xml_visible);
+
+    Assert.assertEquals(3, instances.size());
+    Assert.assertTrue(instances.get(0).isVisible());
+    Assert.assertFalse(instances.get(1).isVisible());
+    Assert.assertTrue(instances.get(2).isVisible());
+  }
+
+  @Test
   public void testGetProperties() throws Exception {
     List<InstanceConfig> instances = getInstanceConfigs();
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/1ea7498d/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 74f48a8..2a1d8d2 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
@@ -76,6 +76,7 @@ public class ViewConfigTest {
       "    <instance>\n" +
       "        <name>INSTANCE1</name>\n" +
       "        <label>My Instance 1!</label>\n" +
+      "        <description>This is a description.</description>\n" +
       "        <property>\n" +
       "            <key>p1</key>\n" +
       "            <value>v1-1</value>\n" +

http://git-wip-us.apache.org/repos/asf/ambari/blob/1ea7498d/ambari-views/src/main/java/org/apache/ambari/view/ViewInstanceDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-views/src/main/java/org/apache/ambari/view/ViewInstanceDefinition.java
b/ambari-views/src/main/java/org/apache/ambari/view/ViewInstanceDefinition.java
index 5b9b92d..ff9090b 100644
--- a/ambari-views/src/main/java/org/apache/ambari/view/ViewInstanceDefinition.java
+++ b/ambari-views/src/main/java/org/apache/ambari/view/ViewInstanceDefinition.java
@@ -47,6 +47,20 @@ public interface ViewInstanceDefinition {
   public String getLabel();
 
   /**
+   * Get the view instance description.
+   *
+   * @return the description
+   */
+  public String getDescription();
+
+  /**
+   * Indicates whether or not the view instance should be visible.
+   *
+   * @return true if the view instance should be visible; false otherwise
+   */
+  public boolean isVisible();
+
+  /**
    * Get the instance property map.
    *
    * @return the map of instance properties
@@ -54,10 +68,10 @@ public interface ViewInstanceDefinition {
   public Map<String, String> getPropertyMap();
 
   /**
-    * Get the view instance application data.
-    *
-    * @return the view instance application data map
-    */
+   * Get the view instance application data.
+   *
+   * @return the view instance application data map
+   */
   public Map<String, String> getInstanceDataMap();
 
   /**


Mime
View raw message