brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rich...@apache.org
Subject [2/7] git commit: Add delegate entity link
Date Fri, 13 Jun 2014 16:45:15 GMT
Add delegate entity link


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

Branch: refs/heads/master
Commit: eaea8a8608c790d4bb9772b2847275970ccaa3e1
Parents: 501a71b
Author: Andrew Donald Kennedy <grkvlt@apache.org>
Authored: Thu Jun 12 18:02:56 2014 +0100
Committer: Andrew Donald Kennedy <grkvlt@apache.org>
Committed: Thu Jun 12 18:02:56 2014 +0100

----------------------------------------------------------------------
 .../entity/basic/AbstractGroupImpl.java         |  2 +-
 .../brooklyn/entity/basic/DelegateEntity.java   |  5 +++--
 .../entity/basic/DelegateEntityImpl.java        | 23 ++++++++++++++++++--
 3 files changed, 25 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/eaea8a86/core/src/main/java/brooklyn/entity/basic/AbstractGroupImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/basic/AbstractGroupImpl.java b/core/src/main/java/brooklyn/entity/basic/AbstractGroupImpl.java
index 4697f9f..5bab83b 100644
--- a/core/src/main/java/brooklyn/entity/basic/AbstractGroupImpl.java
+++ b/core/src/main/java/brooklyn/entity/basic/AbstractGroupImpl.java
@@ -90,7 +90,7 @@ public abstract class AbstractGroupImpl extends AbstractEntity implements
Abstra
 	                if (!result.isPresent()) {
 		                DelegateEntity child = addChild(EntitySpec.create(DelegateEntity.class)
 		                		.configure(DelegateEntity.DELEGATE_ENTITY, member)
-		                		.displayName(member.getDisplayName()));
+		                		.displayName(String.format("(%s)", member.getDisplayName())));
 		                Entities.manage(child);
 	                }
                 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/eaea8a86/core/src/main/java/brooklyn/entity/basic/DelegateEntity.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/basic/DelegateEntity.java b/core/src/main/java/brooklyn/entity/basic/DelegateEntity.java
index d8b3d8c..528f3cd 100644
--- a/core/src/main/java/brooklyn/entity/basic/DelegateEntity.java
+++ b/core/src/main/java/brooklyn/entity/basic/DelegateEntity.java
@@ -1,8 +1,9 @@
 package brooklyn.entity.basic;
 
-import brooklyn.config.ConfigKey;
 import brooklyn.entity.Entity;
+import brooklyn.entity.Group;
 import brooklyn.entity.proxying.ImplementedBy;
+import brooklyn.event.basic.AttributeSensorAndConfigKey;
 
 /**
  * A delegate entity for use as a {@link Group} child proxy for members.
@@ -10,6 +11,6 @@ import brooklyn.entity.proxying.ImplementedBy;
 @ImplementedBy(DelegateEntityImpl.class)
 public interface DelegateEntity extends Entity {
 
-    ConfigKey<Entity> DELEGATE_ENTITY = ConfigKeys.newConfigKey(Entity.class, "delegate.entity",
"The delegate entity");
+    AttributeSensorAndConfigKey<Entity, Entity> DELEGATE_ENTITY = ConfigKeys.newSensorAndConfigKey(Entity.class,
"delegate.entity", "The delegate entity");
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/eaea8a86/core/src/main/java/brooklyn/entity/basic/DelegateEntityImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/basic/DelegateEntityImpl.java b/core/src/main/java/brooklyn/entity/basic/DelegateEntityImpl.java
index 596f5ce..6d565b7 100644
--- a/core/src/main/java/brooklyn/entity/basic/DelegateEntityImpl.java
+++ b/core/src/main/java/brooklyn/entity/basic/DelegateEntityImpl.java
@@ -1,10 +1,12 @@
 package brooklyn.entity.basic;
 
-import com.google.common.base.Preconditions;
-
+import brooklyn.config.render.RendererHints;
 import brooklyn.enricher.Enrichers;
 import brooklyn.entity.Entity;
 
+import com.google.common.base.Function;
+import com.google.common.base.Preconditions;
+
 public class DelegateEntityImpl extends AbstractEntity implements DelegateEntity {
     
     public DelegateEntityImpl() { }
@@ -12,6 +14,7 @@ public class DelegateEntityImpl extends AbstractEntity implements DelegateEntity
     @Override
     public void init() {
     	Entity delegate = getConfig(DELEGATE_ENTITY);
+    	setAttribute(DELEGATE_ENTITY, delegate);
     	Preconditions.checkNotNull(delegate, "delegate");
     	addEnricher(Enrichers.builder()
     			.propagatingAll()
@@ -19,4 +22,20 @@ public class DelegateEntityImpl extends AbstractEntity implements DelegateEntity
     			.build());
     }
 
+	static {
+		RendererHints.register(DELEGATE_ENTITY, new RendererHints.NamedActionWithUrl("Open",
+				new Function<Object, String>() {
+					@Override
+					public String apply(Object input) {
+						if (input instanceof Entity) {
+							Entity entity = (Entity) input;
+							String url = String.format("#/v1/applications/%s/entities/%s", entity.getApplicationId(),
entity.getId());
+							return url;
+						} else {
+							return null;
+						}
+					}
+				}));
+	}
 }
+


Mime
View raw message