ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From swa...@apache.org
Subject ambari git commit: Revert "AMBARI-11149. Widgets: attempted to move/add/delete a widget causes exception. Unit test failure."
Date Fri, 15 May 2015 02:58:27 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 9b6223b90 -> 94ba7c0f9


Revert "AMBARI-11149. Widgets: attempted to move/add/delete a widget causes exception. Unit
test failure."

This reverts commit 501afc0f58c65eaeccf6c388ae6100c2c3d31048.


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

Branch: refs/heads/trunk
Commit: 94ba7c0f9904e6c6834a36f8b4de982f86cc94c7
Parents: 9b6223b
Author: Siddharth Wagle <swagle@hortonworks.com>
Authored: Thu May 14 19:56:31 2015 -0700
Committer: Siddharth Wagle <swagle@hortonworks.com>
Committed: Thu May 14 19:58:10 2015 -0700

----------------------------------------------------------------------
 .../internal/WidgetLayoutResourceProvider.java  |  9 --------
 .../entities/WidgetLayoutUserWidgetEntity.java  |  8 ++++---
 .../WidgetLayoutResourceProviderTest.java       | 23 ++++----------------
 3 files changed, 9 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/94ba7c0f/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/WidgetLayoutResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/WidgetLayoutResourceProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/WidgetLayoutResourceProvider.java
index 174a106..8f068d5 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/WidgetLayoutResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/WidgetLayoutResourceProvider.java
@@ -286,15 +286,6 @@ public class WidgetLayoutResourceProvider extends AbstractControllerResourceProv
 
           Set widgetsSet = (LinkedHashSet) propertyMap.get(WIDGETLAYOUT_WIDGETS_PROPERTY_ID);
 
-          //Remove old relations from widget entities
-          for (WidgetLayoutUserWidgetEntity widgetLayoutUserWidgetEntity : entity.getListWidgetLayoutUserWidgetEntity())
{
-            widgetLayoutUserWidgetEntity.getWidget().getListWidgetLayoutUserWidgetEntity()
-                    .remove(widgetLayoutUserWidgetEntity);
-            widgetDAO.merge(widgetLayoutUserWidgetEntity.getWidget());
-          }
-          entity.setListWidgetLayoutUserWidgetEntity(new LinkedList<WidgetLayoutUserWidgetEntity>());
-          widgetLayoutDAO.merge(entity);
-
           List<WidgetLayoutUserWidgetEntity> widgetLayoutUserWidgetEntityList = new
LinkedList<WidgetLayoutUserWidgetEntity>();
           int order=0;
           for (Object widgetObject : widgetsSet) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/94ba7c0f/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/WidgetLayoutUserWidgetEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/WidgetLayoutUserWidgetEntity.java
b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/WidgetLayoutUserWidgetEntity.java
index dbae31b..1d6e1b5 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/WidgetLayoutUserWidgetEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/WidgetLayoutUserWidgetEntity.java
@@ -17,7 +17,6 @@
  */
 package org.apache.ambari.server.orm.entities;
 
-import javax.persistence.CascadeType;
 import javax.persistence.Column;
 import javax.persistence.Entity;
 import javax.persistence.Id;
@@ -44,7 +43,7 @@ public class WidgetLayoutUserWidgetEntity {
   @JoinColumn(name = "widget_layout_id", referencedColumnName = "id")
   private WidgetLayoutEntity widgetLayout;
 
-  @ManyToOne(cascade = {CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH})
+  @ManyToOne
   @JoinColumn(name = "widget_id", referencedColumnName = "id")
   private WidgetEntity widget;
 
@@ -98,7 +97,10 @@ public class WidgetLayoutUserWidgetEntity {
 
     WidgetLayoutUserWidgetEntity that = (WidgetLayoutUserWidgetEntity) o;
 
-    return (widgetLayout.equals(that.widgetLayout) && widget.equals(that.widget));
+    if (widgetLayout.getId() != that.widgetLayout.getId()) return false;
+    if (widget.getId() != that.widget.getId()) return false;
+
+    return true;
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/ambari/blob/94ba7c0f/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/WidgetLayoutResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/WidgetLayoutResourceProviderTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/WidgetLayoutResourceProviderTest.java
index 8184d34..1a9e230 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/WidgetLayoutResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/WidgetLayoutResourceProviderTest.java
@@ -221,15 +221,7 @@ public class WidgetLayoutResourceProviderTest {
     dao.create(capture(entityCapture));
     expectLastCall();
 
-    WidgetEntity widgetEntity = new WidgetEntity();
-    widgetEntity.setId(1L);
-    widgetEntity.setListWidgetLayoutUserWidgetEntity(new ArrayList<WidgetLayoutUserWidgetEntity>());
-    WidgetEntity widgetEntity2 = new WidgetEntity();
-    widgetEntity2.setId(2L);
-    widgetEntity2.setListWidgetLayoutUserWidgetEntity(new ArrayList<WidgetLayoutUserWidgetEntity>());
-    expect(widgetDAO.findById(1L)).andReturn(widgetEntity).atLeastOnce();
-
-    replay(amc, clusters, cluster, dao, widgetDAO);
+    replay(amc, clusters, cluster, dao);
 
     Map<String, Object> requestProps = new HashMap<String, Object>();
     requestProps.put(WidgetLayoutResourceProvider.WIDGETLAYOUT_CLUSTER_NAME_PROPERTY_ID,
"c1");
@@ -239,9 +231,6 @@ public class WidgetLayoutResourceProviderTest {
     requestProps.put(WidgetLayoutResourceProvider.WIDGETLAYOUT_USERNAME_PROPERTY_ID, "admin");
     requestProps.put(WidgetLayoutResourceProvider.WIDGETLAYOUT_SCOPE_PROPERTY_ID, "CLUSTER");
     Set widgetsInfo = new LinkedHashSet();
-    Map<String, String> widget = new HashMap<String, String>();
-    widget.put("id","1");
-    widgetsInfo.add(widget);
     requestProps.put(WidgetLayoutResourceProvider.WIDGETLAYOUT_WIDGETS_PROPERTY_ID, widgetsInfo);
 
     Request request = PropertyHelper.getCreateRequest(
@@ -266,19 +255,15 @@ public class WidgetLayoutResourceProviderTest {
     String oldLayoutName = entity.getLayoutName();
     String oldScope = entity.getScope();
 
-    resetToStrict(dao, widgetDAO);
+    resetToStrict(dao);
     expect(dao.findById(1L)).andReturn(entity).anyTimes();
     expect(dao.merge((WidgetLayoutEntity) anyObject())).andReturn(entity).anyTimes();
-    expect(widgetDAO.merge(widgetEntity)).andReturn(widgetEntity).anyTimes();
-    expect(widgetDAO.findById(2L)).andReturn(widgetEntity2).anyTimes();
-    replay(dao, widgetDAO);
+    replay(dao);
 
     requestProps = new HashMap<String, Object>();
     requestProps.put(WidgetLayoutResourceProvider.WIDGETLAYOUT_LAYOUT_NAME_PROPERTY_ID, "layout_name_new");
     requestProps.put(WidgetLayoutResourceProvider.WIDGETLAYOUT_SCOPE_PROPERTY_ID, "USER");
     requestProps.put(WidgetLayoutResourceProvider.WIDGETLAYOUT_ID_PROPERTY_ID, "1");
-    widget.put("id","2");
-    widgetsInfo.add(widget);
     requestProps.put(WidgetLayoutResourceProvider.WIDGETLAYOUT_WIDGETS_PROPERTY_ID, widgetsInfo);
 
     request = PropertyHelper.getUpdateRequest(requestProps, null);
@@ -288,7 +273,7 @@ public class WidgetLayoutResourceProviderTest {
     Assert.assertFalse(oldLayoutName.equals(entity.getLayoutName()));
     Assert.assertFalse(oldScope.equals(entity.getScope()));
 
-    verify(amc, clusters, cluster, dao, widgetDAO);
+    verify(amc, clusters, cluster, dao);
   }
 
   /**


Mime
View raw message