@Deprecated public PolicySummary(ApplicationSummary application, EntityLocal entity, Policy policy) { this(entity, policy); assert application.getId().equals(entity.getApplicationId()); } protected PolicySummary(Entity entity, Policy policy) {
public PolicyConfigSummary(EntityLocal entity, Policy policy, ConfigKey<?> config) { super(config); String applicationUri = "/v1/applications/" + entity.getApplicationId(); String entityUri = applicationUri + "/entities/" + entity.getId(); String policyUri = entityUri + "/policies/" + policy.getId(); this.links = ImmutableMap.<String, URI>builder() .put("self", URI.create(policyUri + "/config/" + config.getName())) .put("application", URI.create(applicationUri)) .put("entity", URI.create(entityUri)) .put("policy", URI.create(policyUri)) .build(); }
public PolicyConfigSummary(ApplicationSummary application, EntityLocal entity, Policy policy, ConfigKey<?> config) { this(entity, policy, config); if (!entity.getApplicationId().equals(application.getInstance().getId())) throw new IllegalStateException("Application "+application+" does not match app "+entity.getApplication()+" of "+entity); }
/** generates a representation for a given config key, * with label inferred from annoation in the entity class, * and links pointing to the entity and the applicaiton */ public static EntityConfigSummary fromEntity(EntityLocal entity, ConfigKey<?> config) { /* * following code nearly there to get the @CatalogConfig annotation * in the class and use that to populate a label */ // EntityDynamicType typeMap = // ((AbstractEntity)entity).getMutableEntityType(); // // above line works if we can cast; line below won't work, but there should some way // // to get back the handle to the spec from an entity local, which then *would* work // EntityTypes.getDefinedEntityType(entity.getClass()); // String label = typeMap.getConfigKeyField(config.getName()); String label = null; Double priority = null; String applicationUri = "/v1/applications/" + entity.getApplicationId(); String entityUri = applicationUri + "/entities/" + entity.getId(); Map<String,URI> links = ImmutableMap.<String, URI>builder() .put("self", URI.create(entityUri + "/config/" + config.getName())) .put("application", URI.create(applicationUri)) .put("entity", URI.create(entityUri)) .build(); return new EntityConfigSummary(config, label, priority, links); }
/** generates a representation for a given config key, * with label inferred from annoation in the entity class, * and links pointing to the entity and the applicaiton */ public static EntityConfigSummary entityConfigSummary(EntityLocal entity, ConfigKey<?> config) { /* * following code nearly there to get the @CatalogConfig annotation * in the class and use that to populate a label */ // EntityDynamicType typeMap = // ((AbstractEntity)entity).getMutableEntityType(); // // above line works if we can cast; line below won't work, but there should some way // // to get back the handle to the spec from an entity local, which then *would* work // EntityTypes.getDefinedEntityType(entity.getClass()); // String label = typeMap.getConfigKeyField(config.getName()); String label = null; Double priority = null; String applicationUri = "/v1/applications/" + entity.getApplicationId(); String entityUri = applicationUri + "/entities/" + entity.getId(); Map<String,URI> links = ImmutableMap.<String, URI>builder() .put("self", URI.create(entityUri + "/config/" + config.getName())) .put("application", URI.create(applicationUri)) .put("entity", URI.create(entityUri)) .build(); return entityConfigSummary(config, label, priority, links); }
public static PolicyConfigSummary policyConfigSummary(BrooklynRestResourceUtils utils, EntityLocal entity, Policy policy, ConfigKey<?> config) { String applicationUri = "/v1/applications/" + entity.getApplicationId(); String entityUri = applicationUri + "/entities/" + entity.getId(); String policyUri = entityUri + "/policies/" + policy.getId(); Map<String, URI> links = ImmutableMap.<String, URI>builder() .put("self", URI.create(policyUri + "/config/" + config.getName())) .put("application", URI.create(applicationUri)) .put("entity", URI.create(entityUri)) .put("policy", URI.create(policyUri)) .build(); return new PolicyConfigSummary(config.getName(), config.getTypeName(), config.getDescription(), PolicyConfigResource.getStringValueForDisplay(utils, policy, config.getDefaultValue()), config.isReconfigurable(), links); }
public static EffectorSummary effectorSummary(EntityLocal entity, Effector<?> effector) { String applicationUri = "/v1/applications/" + entity.getApplicationId(); String entityUri = applicationUri + "/entities/" + entity.getId(); return new EffectorSummary(effector.getName(), effector.getReturnTypeName(), ImmutableSet.copyOf(Iterables.transform(effector.getParameters(), new Function<ParameterType<?>, EffectorSummary.ParameterSummary>() { @Override public EffectorSummary.ParameterSummary apply(@Nullable ParameterType<?> parameterType) { return parameterSummary(parameterType); } })), effector.getDescription(), ImmutableMap.of( "self", URI.create(entityUri + "/effectors/" + effector.getName()), "entity", URI.create(entityUri), "application", URI.create(applicationUri) )); }
protected EffectorSummary(EntityLocal entity, Effector<?> effector) { this.name = effector.getName(); this.description = effector.getDescription(); this.returnType = effector.getReturnTypeName(); this.parameters = ImmutableSet.copyOf(Iterables.transform(effector.getParameters(), new Function<ParameterType<?>, ParameterSummary>() { @Override public ParameterSummary apply(@Nullable ParameterType<?> parameterType) { return new ParameterSummary(parameterType); } })); String applicationUri = "/v1/applications/" + entity.getApplicationId(); String entityUri = applicationUri + "/entities/" + entity.getId(); this.links = ImmutableMap.of( "self", URI.create(entityUri + "/effectors/" + effector.getName()), "entity", URI.create(entityUri), "application", URI.create(applicationUri) ); }