<commit_before>package brooklyn.web.console

import grails.converters.JSON
import grails.plugins.springsecurity.Secured

import brooklyn.entity.Entity
import brooklyn.web.console.entity.EntitySummary
import brooklyn.web.console.entity.LocationSummary
import brooklyn.location.Location
import brooklyn.location.basic.AbstractLocation

import brooklyn.web.console.entity.JsTreeNode
import brooklyn.web.console.EntityService.NoSuchEntity
import brooklyn.entity.Effector

@Secured(['ROLE_ADMIN'])
class EntityController {

    // Injected
    def entityService

    def index = {}

    def circles = {
    }

    def list = {
        render(toEntitySummaries(entityService.getAllEntities()) as JSON)
    }

    def info = {
        String id = params.id
        if (id) {
            Entity entity = entityService.getEntity(id)
            if (entity != null) {
                render(toEntitySummary(entity) as JSON)
            } else {
                render(status: 404,
                       text: '{message: "Cannot retrieve info: Entity with specified id '+ params.id + ' does not exist"}')
            }
        } else {
            render(status: 400, text: '{message: "You must provide an entity id"}')
        }
    }
<commit_msg>ENGR-1703 Added circles controller.<commit_after>package brooklyn.web.console

import grails.converters.JSON
import grails.plugins.springsecurity.Secured

import brooklyn.entity.Entity
import brooklyn.web.console.entity.EntitySummary
import brooklyn.web.console.entity.LocationSummary
import brooklyn.location.Location
import brooklyn.location.basic.AbstractLocation

import brooklyn.web.console.entity.JsTreeNode
import brooklyn.web.console.EntityService.NoSuchEntity
import brooklyn.entity.Effector

@Secured(['ROLE_ADMIN'])
class EntityController {

    // Injected
    def entityService

    def index = {}

    def circles = {
        Map<Location, Integer> ls = entityService.entityCountsAtLocatedLocations()
        def forJSON = ls.collect { l, count -> [ lat: l.getLocationProperty("latitude"),
                                                 long: l.getLocationProperty("longitude"),
                                                 radius: 100000 * count ] }
        render(forJSON as JSON)
    }

    def list = {
        render(toEntitySummaries(entityService.getAllEntities()) as JSON)
    }

    def info = {
        String id = params.id
        if (id) {
            Entity entity = entityService.getEntity(id)
            if (entity != null) {
                render(toEntitySummary(entity) as JSON)
            } else {
                render(status: 404,
                       text: '{message: "Cannot retrieve info: Entity with specified id '+ params.id + ' does not exist"}')
            }
        } else {
            render(status: 400, text: '{message: "You must provide an entity id"}')
        }
    }

{'fraction_non_alphanumeric': 0.0948065528058557, 'fraction_numerical': 0.007668177065179505, 'mean_word_length': 2.376470588235294, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2018807', 'n_tokens_mistral': 818, 'n_tokens_neox': 774, 'n_words': 184}