commit e0a53a48b947120ae3c9ee50a89c4f1ea4848658
Author: Martin Matas <nouzovekonto@gmail.com>
Date:   Thu May 16 20:14:39 2019 +0200

    Laoding data from IMiGEr REST API, timeline design adjustment (refs #7464)

diff --git a/sources/imiger-core/src/main/webapp/timeline/css/styles.css b/sources/imiger-core/src/main/webapp/timeline/css/styles.css
index d1c75ac..c628537 100644
--- a/sources/imiger-core/src/main/webapp/timeline/css/styles.css
+++ b/sources/imiger-core/src/main/webapp/timeline/css/styles.css
@@ -450,7 +450,7 @@
   position: fixed;
   top: 0;
   left: 0;
-  right: 400px;
+  right: 0;
   overflow-x: hidden;
   overflow-y: hidden;
   bottom: 0;
diff --git a/sources/imiger-core/src/main/webapp/timeline/data/BandsDistribution.js b/sources/imiger-core/src/main/webapp/timeline/data/BandsDistribution.js
index 9397719..1839929 100644
--- a/sources/imiger-core/src/main/webapp/timeline/data/BandsDistribution.js
+++ b/sources/imiger-core/src/main/webapp/timeline/data/BandsDistribution.js
@@ -1,104 +1,27 @@
 define([ 
-    'cz/kajda/timeline/render/BandItemRenderer', 
-    'cz/kajda/timeline/render/SplitBandItemRenderer',
-    'cz/kajda/timeline/render/DumbbellItemRenderer'
+    'cz/kajda/timeline/render/BandItemRenderer',
 ],
 
-function(BandItemRenderer, SplitBandItemRenderer, DumbbellItemRenderer){
+function(BandItemRenderer){
 
-    var BandsDistribution = new Class("BandsDistribution", {
+    return new Class("BandsDistribution", {
     
-    _constructor : function() {
-    },
-    bands : [
-          {
-               id: "place",
-               label: "Místa",
-               itemRenderer: new BandItemRenderer("#7DD968"),
-               color: "#f5f5f5"
-          },
-           {
-               id: "person",
-               label: "Lidé",
-               itemRenderer: new BandItemRenderer("#FFB182"),
-               color: "#fafafa"
-           },
-        //    {
-        //        id: "event",
-        //        label: "Události",
-        //        itemRenderer: new BandItemRenderer("#F2BC53"),
-        //        color: "#f5f5f5"
-        //    },
-        //    {
-        //        id: "item",
-        //        label: "Objekty",
-        //        itemRenderer: new BandItemRenderer("#78B4FF"),
-        //        color: "#fafafa"
-        //    },
-           /* FIALA */
+        _constructor : function() {},
+        bands : [
+            {
+                id: "person",
+                label: "Lidé",
+                itemRenderer: new BandItemRenderer("#FFB182"),
+                color: "#fafafa"
+            },
+            {
+                id: "item",
+                label: "Objekty",
+                itemRenderer: new BandItemRenderer("#78B4FF"),
+                color: "#fafafa"
+            }
+        ]
 
-           /* Funcki verze */
-           // {
-           //     id: "split-event",
-           //     label: "Rozdeleni",
-           //     types: [
-           //         {"split-event":"SplitBandItemRenderer"}
-           //     ],
-           //     itemRenderer: new SplitBandItemRenderer("#03f945"),
-           //     color: "#fafafa"
-           // },
-           // {
-           //     id: "dumbbell-entity",
-           //     label: "Cinka",
-           //     itemRenderer: new DumbbellItemRenderer("#03f945"),
-           //     color: "#fafafa"
-
-           // }
-           /** Testovaci verze */
-        //    {
-        //        id: "Rozdeleni",
-        //        label: "Rozdeleni",
-        //        types: [
-        //             {
-        //                 id: "split-event", 
-        //                 itemRenderer: new SplitBandItemRenderer("#03f945")
-        //             },
-        //             {
-        //                 id: "dumbbell-entity", 
-        //                 itemRenderer: new DumbbellItemRenderer("#03f945")
-        //             }
-        //                ],
-        //        // itemRenderer: new SplitBandItemRenderer("#03f945"),
-        //        // color: "#fafafa"
-        //    },
-        /** SJEDNOCENI VSECH */
-           {
-               id: "Sjednoceny pruh",
-               label: "Sjednoceni",
-               types: [
-                   {
-                         id: "event",
-                         itemRenderer: new BandItemRenderer("#F2BC53"),
-                         color: "#f5f5f5"
-                    },
-                    {
-                         id: "item",
-                         itemRenderer: new BandItemRenderer("#78B4FF"),
-                         color: "#fafafa"
-                    },
-                    {
-                         id: "split-event", 
-                         itemRenderer: new SplitBandItemRenderer("#03f945")
-                    },
-                    {
-                         id: "dumbbell-entity", 
-                         itemRenderer: new DumbbellItemRenderer("#03f945")
-                    }
-               ]
-           }
-
-           
-       ],    
     });
-    return BandsDistribution;
+
 });
\ No newline at end of file
diff --git a/sources/imiger-core/src/main/webapp/timeline/data/questions.js b/sources/imiger-core/src/main/webapp/timeline/data/questions.js
new file mode 100644
index 0000000..759f1d0
--- /dev/null
+++ b/sources/imiger-core/src/main/webapp/timeline/data/questions.js
@@ -0,0 +1,26 @@
+/**
+ * @author Michal Fiala
+ * @version 1.0
+ */
+define([],function(){
+    return{
+        questions : [
+            {
+                "text" : "Kdo byl prvni kral?",
+                "answer" : "Karel"
+            },
+            {
+                "text" : "Kdo je Karel?",
+                "answer" : "Karel"
+            },
+            // {
+            //     "text" : "Kdo byl prvni Přemyslovec?",
+            //     "answer" : "Bořivoj I."
+            // },
+            // {
+            //     "text" : "Kdo byl první z dynastie Mojmírovců?",
+            //     "answer" : "Mojmír I."
+            // },
+        ]
+    }
+});
\ No newline at end of file
diff --git a/sources/imiger-core/src/main/webapp/timeline/index.html b/sources/imiger-core/src/main/webapp/timeline/index.html
index e1f2843..41e5d66 100644
--- a/sources/imiger-core/src/main/webapp/timeline/index.html
+++ b/sources/imiger-core/src/main/webapp/timeline/index.html
@@ -26,141 +26,6 @@
                 <div class="timeline-pane">
                     <div id="timeline" tabindex="0"></div>
                 </div>
-          
-                <div role="tabpanel" class="sidebar" id="sidebar">
-                    <ul class="nav nav-pills tab-list" role="tablist">
-                        <li role="presentation" class="active"><a role="tab" data-toggle="tab" href="#home">Záznamy</a></li>
-                        <li role="presentation"><a role="tab" data-toggle="tab" href="#widgeting">Rozhraní widgetu</a></li>
-                        <li role="presentation"><a role="tab" data-toggle="tab" href="#testing">Test widgetu</a></li>
-                    </ul>
-                    <div class="tab-content">
-                        <div role="tabpanel" class="tab-pane active" id="home">
-                            <div id="item_detail_pane" class="hidden">
-                                <div id="item_image">
-                                    <div class="helper"><img alt="náhled"></div>
-                                </div>
-                                <div class="padded">
-                                    <h1 id="item_title"></h1>
-                                    <p class="small" id="item_timerange"></p>
-                                    <p class="small" id="item_description"></p>
-                                    <h4>Související</h4>
-                                </div>
-                                <table id="item_relations" class="table table-condensed small table-striped">
-                                </table>
-                            </div>
-                            <div id="item_search">
-                                <div class="row">
-                                <div class="text-center col-xs-8 col-xs-offset-2">
-                                    <p>Zadejte část názvu hledaného záznamu</p>
-                                    <input type="search" id="item_search_term" class="form-control input-sm">
-                                    <div class="text-center text-muted padded-top">nebo</div>
-                                    <p class="padded-top text-center">klepněte na některý ze záznamů v ose a zobrazte jeho detail.</p>
-                                </div>
-                                </div>
-                                <div class="padded-top">
-                                    <table id="item_search_result" class="table table-condensed small table-striped">
-                                        <tr>
-                                            <td><em>Žádné nálezy...</em></td>
-                                        </tr>
-                                    </table>
-                                </div>
-                            </div>
-                        </div>
-                        <div role="tabpanel" class="tab-pane" id="widgeting">
-                            <div class="padded">
-                                <h1>Rozhraní widgetu</h1>
-                            </div>
-                            <table class="table small table-condensed table-striped">
-                                <tr>
-                                    <td><strong>středový čas</strong></td>
-                                    <td class="text-right" id="center_time_td">?</td>
-                                </tr>
-                                <tr>
-                                    <td><strong>rozsah průhledu</strong></td>
-                                    <td class="text-right" id="viewport_range_td">?<div>?</div></td>
-                                </tr>
-                                <tr>
-                                    <td><strong>úroveň přiblížení</strong></td>
-                                    <td class="text-right" id="zoom_level_td">?<div>?</div></td>
-                                </tr>
-                                <tr>
-                                    <td><strong>vybraný záznam</strong></td>
-                                    <td class="text-right"><div style="white-space: nowrap; text-overflow: ellipsis; overflow: hidden" id="focused_entity_td"><em>žádný</em></div></td>
-                                </tr>
-                            </table>
-                            <div class="padded">
-                                <div>
-                                    <div class="btn-group btn-group-justified">
-                                        <a class="btn btn-default" id="zoomin_btn">Přiblížit</a>
-                                        <a class="btn btn-default" id="zoomout_btn">Oddálit</a>
-                                    </div>
-                                    <div class="btn-group btn-group-justified">
-                                        <a class="btn btn-default" id="slideLeft_btn">Posun vzad</a>
-                                        <a class="btn btn-default" id="slideRight_btn">Posun vpřed</a>
-                                    </div>
-                                    <div class="btn-group btn-group-justified">
-                                        <a class="btn btn-default" id="jump_ad_btn">Přejít na počátek letopočtu</a>
-                                    </div>
-                                    <div class="form-group">
-                                        <div class="checkbox">
-                                            <label for="bandLabels_chb">
-                                                <input type="checkbox" checked id="bandLabels_chb">Zobrazit popisky pásů
-                                            </label>
-                                        </div>
-                                        <div class="checkbox">
-                                            <label for="zoombar_chb">
-                                                <input type="checkbox" checked id="zoombar_chb">Zobrazit zoom panel
-                                            </label>
-                                        </div>
-                                        <div class="checkbox">
-                                            <label for="timepointer_chb">
-                                                <input type="checkbox" checked id="timepointer_chb">Zobrazit ukazatel středového času
-                                            </label>
-                                        </div>
-                                        <div class="checkbox">
-                                            <label for="popover_chb">
-                                                <input type="checkbox" checked id="popover_chb">Zobrazovat náhledy záznamů a vztahů
-                                            </label>
-                                        </div>
-                                        <div class="checkbox">
-                                            <label for="guidelines_chb">
-                                                <input type="checkbox" checked id="guidelines_chb">Zobrazovat vodící linky záznamů
-                                            </label>
-                                        </div>
-                                        <div class="checkbox">
-                                            <label for="relations_chb">
-                                                <input type="checkbox" checked id="relations_chb">Zobrazovat vztahy mezi záznamy
-                                            </label>
-                                        </div>
-                                    </div>
-                                </div>
-                            </div>
-                        </div>
-                        <div role="tabpanel" class="tab-pane" id="testing">
-                            <!-- FIALA Test tool  -->
-                            <div class="padded" id="testing_content">
-                                <div style="display: none;"> 
-                                    <h2 id="question_label">Otázka</h2>
-                                    <h4 id="questions_done_label"> 1/10</h4>
-                                    <div id="answer_fgroup_label" class="form-group">
-                                        <label for="answer">Odpověď</label>
-                                        <input type="text" class="form-control" id="answer_text">
-                                    </div>
-                                </div>
-                                <div style="display: none;" class="btn-group btn-group-justified">
-                                    <a class="btn btn-default" id="confirm_btn">Potvrdit</a>
-                                </div>
-                                <div class="btn-group btn-group-justified">
-                                    <a class="btn btn-default" id="start_test_btn">Začít test</a>
-                                </div>
-                            </div>
-                            <div class="padded" style="display: none; color: red;" id="wrong_anser_content">
-                                <h2>Špatná odpověď</h2>
-                            </div>
-                            
-                        </div>
-                    </div>
-                </div>
             </div>
         </div>
   </body>
diff --git a/sources/imiger-core/src/main/webapp/timeline/js/auxiliary/App.js b/sources/imiger-core/src/main/webapp/timeline/js/auxiliary/App.js
index 9cdb895..807c93c 100644
--- a/sources/imiger-core/src/main/webapp/timeline/js/auxiliary/App.js
+++ b/sources/imiger-core/src/main/webapp/timeline/js/auxiliary/App.js
@@ -8,12 +8,11 @@ define([
     'cz/kajda/common/Observable',
     'cz/kajda/data/Entity',
     'cz/kajda/data/Relation',
-    'auxiliary/RandSource',
-    'auxiliary/StaticSource',
+    'auxiliary/RestSource',
     'momentjs',
     'auxiliary/QuestionTool',
 ],
-function(DataWizard, Observable, Entity, Relation, RandSource, StaticSource, moment, QuestionTool) {
+function(DataWizard, Observable, Entity, Relation, RestSource, moment, QuestionTool) {
     
 /**
  * Demo application support for the widget.
@@ -48,32 +47,13 @@ var App = new Class("App", {
      *  @author Michal Fiala
      */
     _questionTool : null,
-    
-    
-    /**
-     * Launch data wizard that invokes REST request to obtain data.
-	 * @param {String} url REST service url
-     */
-    startDataWizard : function(url) {
-        new DataWizard(url, new Closure(this, this._sourceReady));
-    },
+
     
     /**
      * Creates data source using static JSON object 
      */
     createSource : function() {
-        this._source = new StaticSource(Entity, Relation);
-        this._source.addListener("dataLoaded", new Closure(this, this._sourceReady));
-        this._source.loadData();
-    },
-    
-    /**
-     * Creates data source generating data randomly.
-     * @param {Object} conf
-     */
-    createRandSource : function(conf) {
-        this._source = new RandSource(conf, Entity, Relation);
-        this._source.setTimeRange(moment.utc("-002000-01-01T00:00:00"), moment.utc("2000-12-31T23:59:00"));
+        this._source = new RestSource(Entity, Relation, "http://localhost:8080/imiger/", null);
         this._source.addListener("dataLoaded", new Closure(this, this._sourceReady));
         this._source.loadData();
     },
diff --git a/sources/imiger-core/src/main/webapp/timeline/js/auxiliary/RestSource.js b/sources/imiger-core/src/main/webapp/timeline/js/auxiliary/RestSource.js
index ce128e0..89c1216 100644
--- a/sources/imiger-core/src/main/webapp/timeline/js/auxiliary/RestSource.js
+++ b/sources/imiger-core/src/main/webapp/timeline/js/auxiliary/RestSource.js
@@ -68,20 +68,58 @@ var RestSource = new Class("cz.kajda.data.RestSource", {
         /** @see cz.kajda.data.AbstractDataSource#loadData */
         loadData : function(callback) {
             var mapClosure = new Closure(this, this._map);
-            this._client.post("importances", {
-                "query" : {
-                    "from" : this._timeRange.start.utc().format(),
-                    "to" : this._timeRange.end.format(),
-                    "nodeImportance" : this._entityPriors,
-                    "edgeImportance" : this._relationPriors,
-                    "properties" : {}
-                }
-            }, new Closure(this, function(data) {
-                this._map(data);
+            this._client.get("api/load-graph-data", new Closure(this, function(data) {
+                var json = JSON.parse(data.graph_json);
+                var graph = this._convertGraph(json);
+                this._map(graph);
                 this._fireEvent("dataLoaded", this);
             }));
         },
 
+        _convertGraph : function(data) {
+            var archetypes = data.vertexArchetypes;
+            var nodes = new Array(data.vertices.length), edges = new Array(data.edges.length);
+
+            for(var i = 0; i < data.vertices.length; i++) {
+                var v = data.vertices[i];
+                var prop = {
+                    startPrecision: "none",
+                    endPrecision: "none"
+                };
+                var archetype = archetypes[v.archetype].name.toLowerCase();
+                if (archetype !== 'person') {
+                    archetype = 'item';
+                }
+                var node = {
+                    id: v.id, 
+                    name: v.name, 
+                    description: v.text,
+                    stereotype: archetype,
+                    properties: prop,
+                    begin: v.attributes[1][1],
+                    end: typeof v.attributes[2] === 'undefined' ? null : v.attributes[2][1]
+                }
+                nodes[i] = node;
+            }
+
+            for(var i = 0; i < data.edges.length; i++) {
+                var e = data.edges[i];
+                var edge = {
+                    id: e.id, 
+                    name: e.text, 
+                    from: e.from,
+                    stereotype: "relationship",
+                    to: e.to
+                }
+                edges[i] = edge;
+            }
+
+            return {
+                nodes: nodes,
+                edges: edges
+            }
+        },
+
         /** @see cz.kajda.data.AbstractDataSource#_map */
         _map : function(data) {
             var entities = new Collection(),
diff --git a/sources/imiger-core/src/main/webapp/timeline/js/auxiliary/StaticSource.js b/sources/imiger-core/src/main/webapp/timeline/js/auxiliary/StaticSource.js
deleted file mode 100644
index 05111e3..0000000
--- a/sources/imiger-core/src/main/webapp/timeline/js/auxiliary/StaticSource.js
+++ /dev/null
@@ -1,119 +0,0 @@
-/**
- * @author Bc. Michal Kacerovský
- * @version 1.0
- */
-
-define([
-    'cz/kajda/data/AbstractDataSource',
-    'cz/kajda/data/Collection',
-    '../../data/data',
-    /** FIALA */
-    'cz/kajda/data/SubEntity'
-],
-function(AbstractDataSource, Collection, __data, SubEntity) {
-    
-
-/**
- * Data source used for test purpose.
- * gets data from a JSON variable.
- */
-var StaticSource = new Class("StaticSource", {
-   
-    _extends : AbstractDataSource,
-
-    /**
-     * @constructor
-     * @param {Class} T_entity object that entities should be mapped to
-     * @param {Class} T_relation object that relations should be mapped to
-     */
-    _constructor: function(T_entity, T_relation) {
-        AbstractDataSource.call(this, T_entity, T_relation);
-    },
-    /**
-     * @author Michal Fiala
-     * All mapped entities
-     */
-    _allMappedEntities : null,
-
-    //<editor-fold defaultstate="collapsed" desc="overridden">
-
-        /** @see cz.kajda.data.AbstractDataSource#loadData */
-        loadData : function() {
-            this._map(__data);
-            this._fireEvent("dataLoaded", this);
-        },
-
-        /** 
-         * @see cz.kajda.data.AbstractDataSource#_map 
-         * @author Bc. Michal Kacerovský
-         * @author Michal Fiala
-         */
-        _map : function(data) {
-            // All entities (Entity for BandItem)
-            var entities = new Collection(),
-                relations = new Collection();
-            // All mapped entities (Entity and SubEntity)
-            var allMappedEntities = new Collection();    
-            // Map all entities 
-            for(var i = 0; i < data.nodes.length; i++)
-                this._createEntity(data.nodes[i], entities, allMappedEntities);
-
-            // Map relations
-            for(var i = 0; i < data.edges.length; i++) {
-                var edge = data.edges[i],
-                    edgeObj = new this._objectMapping.relation(edge); // mapped object
-                // Find relation and add relation in all entities include SubEntity
-                if(!allMappedEntities.get(edge.from).hasRelation(edgeObj.getId()))
-                    allMappedEntities.get(edge.from).addRelation(edge.id);
-                if(!allMappedEntities.get(edge.to).hasRelation(edgeObj.getId()))
-                    allMappedEntities.get(edge.to).addRelation(edge.id);
-                
-                relations.add(edgeObj);
-            }
-            this._allMappedEntities = allMappedEntities;
-            this._entities = entities;
-            this._relations = relations;
-        },
-        /**
-         * @author Michal Fiala
-         * @author Bc. Michal Kacerovský
-         * Create Entity and adds it in Collections       
-         * Create SubEntities of Entity and adds it in Collection
-         * @param {JSON} dataNode
-         * @param {Collection} entities contain only Entity
-         * @param {Collection} allMappedEntities contain Entity and SubEntity
-         */
-        _createEntity : function(dataNode, entities, allMappedEntities)
-        {
-            var entity = new this._objectMapping.entity(dataNode);
-            
-            entities.add(entity);
-            allMappedEntities.add(entity);
-            // Has SubEntities
-            if(dataNode.subItems)
-                for(var i =0; i < dataNode.subItems.length; i++)
-                {
-                    // Create SubEntity
-                    var subEntity = new SubEntity(dataNode.subItems[i], entity);
-                    // Add SubEntity in Entity
-                    entity.addSubEntity(subEntity);
-                    // Add in all mapped entities
-                    allMappedEntities.add(subEntity);
-                }
-        },
-        
-        /**
-         * @author Michal Fiala
-         * Returns all mapped entities
-         */
-        getAllMappedEntities : function()
-        {
-            return this._allMappedEntities;
-        },
-    //</editor-fold>
-    
-});
-    
-return StaticSource;
-});
-
diff --git a/sources/imiger-core/src/main/webapp/timeline/js/cz/kajda/timeline/Timeline.js b/sources/imiger-core/src/main/webapp/timeline/js/cz/kajda/timeline/Timeline.js
index 81d3604..ca99ff3 100644
--- a/sources/imiger-core/src/main/webapp/timeline/js/cz/kajda/timeline/Timeline.js
+++ b/sources/imiger-core/src/main/webapp/timeline/js/cz/kajda/timeline/Timeline.js
@@ -501,7 +501,7 @@ var Timeline = Class("cz.kajda.timeline.Timeline", {
 
             _handleIMiGErClick : function(e) {
                 var entity = this.getEntities().get(e.detail);
-                    bandItem = this._bandGroup.getBand("Sjednoceny pruh").getBandItem(entity.getId());
+                    bandItem = this._bandGroup.getBand("person").getBandItem(entity.getId());
                 
                 this.focusItem(bandItem.getEntity(), false);
                 this._fireEvent("itemClick", entity);
diff --git a/sources/imiger-core/src/main/webapp/timeline/js/main.js b/sources/imiger-core/src/main/webapp/timeline/js/main.js
index fcea351..1d2fd19 100644
--- a/sources/imiger-core/src/main/webapp/timeline/js/main.js
+++ b/sources/imiger-core/src/main/webapp/timeline/js/main.js
@@ -136,9 +136,9 @@ function($, App, Timeline, BandsDistribution) {
     
     // creates static data source using JSON
     app.createSource();
-    var event = $.Event( "imigerClick" );
-    event.detail = 34;
-    $(document).trigger( event );
+    /*var event = $.Event( "imigerClick" );
+    event.detail = 66;
+    $(document).trigger( event );*/
     // creates data source using REST server request
     //app.startDataWizard("http://localhost:8080/timeline-rest/");
     
diff --git a/sources/imiger-core/src/main/webapp/timeline/less/styles.less b/sources/imiger-core/src/main/webapp/timeline/less/styles.less
index 3eeafb4..20e5226 100644
--- a/sources/imiger-core/src/main/webapp/timeline/less/styles.less
+++ b/sources/imiger-core/src/main/webapp/timeline/less/styles.less
@@ -104,7 +104,7 @@
     position: fixed;
     top: 0;
     left: 0;
-    right: 400px;
+    right: 0;
     overflow-x: hidden;
     overflow-y: hidden;
     bottom: 0;
