1 | /** |
---|
2 | * Visualize Controller |
---|
3 | * |
---|
4 | * This controller enables the user to visualize his data |
---|
5 | * |
---|
6 | * @author robert@thehyve.nl |
---|
7 | * @since 20110825 |
---|
8 | * @package dbnp.visualization |
---|
9 | * |
---|
10 | * Revision information: |
---|
11 | * $Rev$ |
---|
12 | * $Author$ |
---|
13 | * $Date$ |
---|
14 | */ |
---|
15 | package dbnp.visualization |
---|
16 | |
---|
17 | import dbnp.studycapturing.*; |
---|
18 | import grails.converters.JSON |
---|
19 | import org.dbnp.gdt.TemplateField |
---|
20 | |
---|
21 | class VisualizeController { |
---|
22 | def authenticationService |
---|
23 | |
---|
24 | /** |
---|
25 | * Shows the visualization screen |
---|
26 | */ |
---|
27 | def index = { |
---|
28 | [ studies: Study.giveReadableStudies( authenticationService.getLoggedInUser() )] |
---|
29 | } |
---|
30 | |
---|
31 | def getStudies = { |
---|
32 | def studies = Study.giveReadableStudies( authenticationService.getLoggedInUser() ); |
---|
33 | |
---|
34 | render studies as JSON |
---|
35 | } |
---|
36 | |
---|
37 | def getFields = { |
---|
38 | def entities = [ Study, Subject, Event, SamplingEvent, Sample, Assay ] |
---|
39 | def fields = []; |
---|
40 | |
---|
41 | entities.each { entity -> |
---|
42 | def entityFields = TemplateField.findAll( "from TemplateField where entity = ?", [ entity ] ); |
---|
43 | |
---|
44 | println "Entity " + entity + " -> " + entityFields |
---|
45 | |
---|
46 | def domainFields = entity.giveDomainFields(); |
---|
47 | |
---|
48 | ( domainFields + entityFields ).each { field -> |
---|
49 | fields << [ "id": field.name, "source": "GSCF", "category": entity.toString(), "name": field.name ] |
---|
50 | } |
---|
51 | } |
---|
52 | |
---|
53 | render fields as JSON |
---|
54 | } |
---|
55 | |
---|
56 | def getVisualizationTypes = { |
---|
57 | def types = [ [ "id": "barchart", "name": "Barchart"] ]; |
---|
58 | render types as JSON |
---|
59 | } |
---|
60 | |
---|
61 | def getData = { |
---|
62 | def data = [[3,7,9,1,4,6,8,2,5]]; |
---|
63 | |
---|
64 | render data as JSON |
---|
65 | } |
---|
66 | |
---|
67 | } |
---|