From 961975c4678ef964a66d362df2da12e1e7cee830 Mon Sep 17 00:00:00 2001
From: Mathis Neumann <mathis@simpletechs.net>
Date: Wed, 22 Jun 2016 16:51:03 +0200
Subject: [PATCH] use fixtures instead of server to allow deployment on heroku

---
 app/adapters/_baseAdapter.js                  |  3 +-
 .../component.js                              |  1 +
 app/models/communication.js                   | 75 ++++++++++++++++-
 app/models/communicationinstance.js           | 81 ++++++++++++++++++-
 app/models/node.js                            | 56 ++++++++++++-
 app/models/nodegroup.js                       | 17 +++-
 app/models/service.js                         | 57 ++++++++++++-
 app/models/serviceinstance.js                 | 75 ++++++++++++++++-
 app/models/system.js                          | 12 ++-
 package.json                                  |  1 +
 10 files changed, 370 insertions(+), 8 deletions(-)

diff --git a/app/adapters/_baseAdapter.js b/app/adapters/_baseAdapter.js
index a78d44b..e9850c6 100644
--- a/app/adapters/_baseAdapter.js
+++ b/app/adapters/_baseAdapter.js
@@ -1,7 +1,8 @@
 import Ember from 'ember';
 import RESTAdapter from 'ember-data/adapters/rest';
+import FixtureAdapter from 'ember-data-fixture-adapter';
 
-export default RESTAdapter.extend({
+export default FixtureAdapter.extend({
     host: 'http://localhost:8080', // TODO: replace with live url
     namespace: 'v1',
     session: Ember.inject.service()
diff --git a/app/components/architecture-visualisation-cytoscape/component.js b/app/components/architecture-visualisation-cytoscape/component.js
index f07e150..e72a6b9 100644
--- a/app/components/architecture-visualisation-cytoscape/component.js
+++ b/app/components/architecture-visualisation-cytoscape/component.js
@@ -41,6 +41,7 @@ export default Ember.Component.extend({
             // padding: 6,
             // ungrabifyWhileSimulating: true,
             // infinite: false
+            // TODO: avoidOverlap: true has shaky behavior (enabled by default). Find workaround
           }
         });
 
diff --git a/app/models/communication.js b/app/models/communication.js
index 7be2d6c..eba5c33 100644
--- a/app/models/communication.js
+++ b/app/models/communication.js
@@ -1,9 +1,82 @@
 import BaseEntity from './baseentity';
 import attr from 'ember-data/attr';
 
-export default BaseEntity.extend({
+const Model = BaseEntity.extend({    
     technology: attr('string'),
     sourceId: attr('string'),
     targetId: attr('string'),
     workload: attr('number')
 });
+
+Model.reopenClass({
+    FIXTURES: [
+       {
+          "type":"communication",
+          "id":"test-system123-communication-1",
+          "changelogSequence":0,
+          "lastUpdate":"2016-06-20T12:46:29.818+02:00",
+          "revisionNumber":0,
+          "systemId":"system123",
+          "sourceId":"test-system123-service-1",
+          "targetId":"test-system123-service-2",
+          "technology":"REST"
+       },
+       {
+          "type":"communication",
+          "id":"test-system123-communication-2",
+          "changelogSequence":0,
+          "lastUpdate":"2016-06-20T12:46:29.818+02:00",
+          "revisionNumber":0,
+          "systemId":"system123",
+          "sourceId":"test-system123-service-2",
+          "targetId":"test-system123-service-3",
+          "technology":"TCP/IP"
+       },
+       {
+          "type":"communication",
+          "id":"test-system123-communication-3",
+          "changelogSequence":0,
+          "lastUpdate":"2016-06-20T12:46:29.818+02:00",
+          "revisionNumber":0,
+          "systemId":"system123",
+          "sourceId":"test-system123-service-3",
+          "targetId":"test-system123-service-4",
+          "technology":"TCP/IP"
+       },
+       {
+          "type":"communication",
+          "id":"test-system123-communication-4",
+          "changelogSequence":0,
+          "lastUpdate":"2016-06-20T12:46:29.818+02:00",
+          "revisionNumber":0,
+          "systemId":"system123",
+          "sourceId":"test-system123-service-3",
+          "targetId":"test-system123-service-5",
+          "technology":"TCP/IP"
+       },
+       {
+          "type":"communication",
+          "id":"test-system123-communication-5",
+          "changelogSequence":0,
+          "lastUpdate":"2016-06-20T12:46:29.818+02:00",
+          "revisionNumber":0,
+          "systemId":"system123",
+          "sourceId":"test-system123-service-4",
+          "targetId":"test-system123-service-5",
+          "technology":"TCP/IP"
+       },
+       {
+          "type":"communication",
+          "id":"test-system123-communication-6",
+          "changelogSequence":0,
+          "lastUpdate":"2016-06-20T12:46:29.818+02:00",
+          "revisionNumber":0,
+          "systemId":"system123",
+          "sourceId":"test-system123-service-5",
+          "targetId":"test-system123-service-6",
+          "technology":"TCP/IP"
+       }
+    ]
+});
+
+export default Model;
diff --git a/app/models/communicationinstance.js b/app/models/communicationinstance.js
index df39e8e..bbda258 100644
--- a/app/models/communicationinstance.js
+++ b/app/models/communicationinstance.js
@@ -1,9 +1,88 @@
 import BaseEntity from './baseentity';
 import attr from 'ember-data/attr';
 
-export default BaseEntity.extend({
+const Model = BaseEntity.extend({
     sourceId: attr('string'),
     targetId: attr('string'),
     communicationId: attr('string'),
     workload: attr('number')
 });
+
+Model.reopenClass({
+    FIXTURES: [
+      {
+        "type": "communicationInstance",
+        "id": "test-system123-communicationInstance-1",
+        "changelogSequence": 0,
+        "lastUpdate": "2016-06-22T16:49:49.146+02:00",
+        "revisionNumber": 0,
+        "systemId": "system123",
+        "communicationId": "test-system123-communication-1",
+        "sourceId": "test-system123-serviceInstance-1",
+        "targetId": "test-system123-serviceInstance-2",
+        "workload": 10
+      },
+      {
+        "type": "communicationInstance",
+        "id": "test-system123-communicationInstance-2",
+        "changelogSequence": 0,
+        "lastUpdate": "2016-06-22T16:49:49.146+02:00",
+        "revisionNumber": 0,
+        "systemId": "system123",
+        "communicationId": "test-system123-communication-2",
+        "sourceId": "test-system123-serviceInstance-2",
+        "targetId": "test-system123-serviceInstance-3",
+        "workload": 20
+      },
+      {
+        "type": "communicationInstance",
+        "id": "test-system123-communicationInstance-3",
+        "changelogSequence": 0,
+        "lastUpdate": "2016-06-22T16:49:49.146+02:00",
+        "revisionNumber": 0,
+        "systemId": "system123",
+        "communicationId": "test-system123-communication-3",
+        "sourceId": "test-system123-serviceInstance-3",
+        "targetId": "test-system123-serviceInstance-4",
+        "workload": 10
+      },
+      {
+        "type": "communicationInstance",
+        "id": "test-system123-communicationInstance-4",
+        "changelogSequence": 0,
+        "lastUpdate": "2016-06-22T16:49:49.146+02:00",
+        "revisionNumber": 0,
+        "systemId": "system123",
+        "communicationId": "test-system123-communication-4",
+        "sourceId": "test-system123-serviceInstance-3",
+        "targetId": "test-system123-serviceInstance-5",
+        "workload": 15
+      },
+      {
+        "type": "communicationInstance",
+        "id": "test-system123-communicationInstance-5",
+        "changelogSequence": 0,
+        "lastUpdate": "2016-06-22T16:49:49.146+02:00",
+        "revisionNumber": 0,
+        "systemId": "system123",
+        "communicationId": "test-system123-communication-5",
+        "sourceId": "test-system123-serviceInstance-4",
+        "targetId": "test-system123-serviceInstance-5",
+        "workload": 10
+      },
+      {
+        "type": "communicationInstance",
+        "id": "test-system123-communicationInstance-6",
+        "changelogSequence": 0,
+        "lastUpdate": "2016-06-22T16:49:49.146+02:00",
+        "revisionNumber": 0,
+        "systemId": "system123",
+        "communicationId": "test-system123-communication-6",
+        "sourceId": "test-system123-serviceInstance-5",
+        "targetId": "test-system123-serviceInstance-6",
+        "workload": 15
+      }
+    ]
+});
+
+export default Model;
diff --git a/app/models/node.js b/app/models/node.js
index 8d50dbc..595993f 100644
--- a/app/models/node.js
+++ b/app/models/node.js
@@ -1,9 +1,63 @@
 import BaseEntity from './baseentity';
 import attr from 'ember-data/attr';
 
-export default BaseEntity.extend({
+const Model = BaseEntity.extend({
     name: attr('string'),
     ip: attr('string'),
     hostname: attr('string'),
     nodeGroupId: attr('string')
 });
+
+Model.reopenClass({
+    FIXTURES: [{
+        "type":"node",
+        "id":"test-system123-node-2",
+        "changelogSequence":0,
+        "lastUpdate":"2016-06-20T12:46:29.818+02:00",
+        "revisionNumber":0,
+        "systemId":"system123",
+        "hostname":"host2",
+        "ip":"10.0.0.2",
+        "name":"Logicnode FIXTURE",
+        "nodeGroupId":"test-system123-nodeGroup-1"
+    },
+    {
+        "type":"node",
+        "id":"test-system123-node-3",
+        "changelogSequence":0,
+        "lastUpdate":"2016-06-20T12:46:29.818+02:00",
+        "revisionNumber":0,
+        "systemId":"system123",
+        "hostname":"host3",
+        "ip":"10.0.0.2",
+        "name":"Adapter",
+        "nodeGroupId":"test-system123-nodeGroup-1"
+    },
+    {
+        "type":"node",
+        "id":"test-system123-node-4",
+        "changelogSequence":0,
+        "lastUpdate":"2016-06-20T12:46:29.818+02:00",
+        "revisionNumber":0,
+        "systemId":"system123",
+        "hostname":"host4",
+        "ip":"10.0.0.2",
+        "name":"Database",
+        "nodeGroupId":"test-system123-nodeGroup-1"
+    },
+    {
+        "type":"node",
+        "id":"test-system123-node-1",
+        "changelogSequence":0,
+        "lastUpdate":"2016-06-20T12:46:29.818+02:00",
+        "revisionNumber":0,
+        "systemId":"system123",
+        "hostname":"test hostname",
+        "ip":"10.0.0.1",
+        "name":"WebNode",
+        "nodeGroupId":"test-system123-nodeGroup-1"
+    }]
+
+})
+
+export default Model;
\ No newline at end of file
diff --git a/app/models/nodegroup.js b/app/models/nodegroup.js
index eb8d434..41b2125 100644
--- a/app/models/nodegroup.js
+++ b/app/models/nodegroup.js
@@ -1,7 +1,22 @@
 import BaseEntity from './baseentity';
 import attr from 'ember-data/attr';
 
-export default BaseEntity.extend({
+const Model = BaseEntity.extend({
     name: attr('string')
+});
 
+Model.reopenClass({
+    FIXTURES: [
+       {
+          "type":"nodeGroup",
+          "id":"test-system123-nodeGroup-1",
+          "changelogSequence":0,
+          "lastUpdate":"2016-06-20T12:46:29.818+02:00",
+          "revisionNumber":0,
+          "systemId":"system123",
+          "name":"CoCoMe"
+       }
+    ]
 });
+
+export default Model;
\ No newline at end of file
diff --git a/app/models/service.js b/app/models/service.js
index 572f4e3..a6a1232 100644
--- a/app/models/service.js
+++ b/app/models/service.js
@@ -1,7 +1,62 @@
 import BaseEntity from './baseentity';
 import attr from 'ember-data/attr';
 
-export default BaseEntity.extend({
+const Model = BaseEntity.extend({
     name: attr('string'),
     description: attr('string')
 });
+
+Model.reopenClass({
+    FIXTURES: [
+       {
+          "type":"service",
+          "id":"test-system123-service-1",
+          "changelogSequence":0,
+          "lastUpdate":"2016-06-20T12:46:29.818+02:00",
+          "revisionNumber":0,
+          "systemId":"system123"
+       },
+       {
+          "type":"service",
+          "id":"test-system123-service-2",
+          "changelogSequence":0,
+          "lastUpdate":"2016-06-20T12:46:29.818+02:00",
+          "revisionNumber":0,
+          "systemId":"system123"
+       },
+       {
+          "type":"service",
+          "id":"test-system123-service-3",
+          "changelogSequence":0,
+          "lastUpdate":"2016-06-20T12:46:29.818+02:00",
+          "revisionNumber":0,
+          "systemId":"system123"
+       },
+       {
+          "type":"service",
+          "id":"test-system123-service-4",
+          "changelogSequence":0,
+          "lastUpdate":"2016-06-20T12:46:29.818+02:00",
+          "revisionNumber":0,
+          "systemId":"system123"
+       },
+       {
+          "type":"service",
+          "id":"test-system123-service-5",
+          "changelogSequence":0,
+          "lastUpdate":"2016-06-20T12:46:29.818+02:00",
+          "revisionNumber":0,
+          "systemId":"system123"
+       },
+       {
+          "type":"service",
+          "id":"test-system123-service-6",
+          "changelogSequence":0,
+          "lastUpdate":"2016-06-20T12:46:29.818+02:00",
+          "revisionNumber":0,
+          "systemId":"system123"
+       }
+    ]
+});
+
+export default Model;
\ No newline at end of file
diff --git a/app/models/serviceinstance.js b/app/models/serviceinstance.js
index ca04171..60c4e70 100644
--- a/app/models/serviceinstance.js
+++ b/app/models/serviceinstance.js
@@ -1,8 +1,81 @@
 import BaseEntity from './baseentity';
 import attr from 'ember-data/attr';
 
-export default BaseEntity.extend({
+const Model = BaseEntity.extend({
     name: attr('string'),
     nodeId: attr('string'),
     serviceId: attr('string')
 });
+
+Model.reopenClass({
+    FIXTURES: [
+       {
+          "type":"serviceInstance",
+          "id":"test-system123-serviceInstance-4",
+          "changelogSequence":0,
+          "lastUpdate":"2016-06-20T12:46:29.818+02:00",
+          "revisionNumber":0,
+          "systemId":"system123",
+          "name":"Inventory",
+          "nodeId":"test-system123-node-2",
+          "serviceId":"test-system123-service-4"
+       },
+       {
+          "type":"serviceInstance",
+          "id":"test-system123-serviceInstance-5",
+          "changelogSequence":0,
+          "lastUpdate":"2016-06-20T12:46:29.818+02:00",
+          "revisionNumber":0,
+          "systemId":"system123",
+          "name":"Data",
+          "nodeId":"test-system123-node-3",
+          "serviceId":"test-system123-service-5"
+       },
+       {
+          "type":"serviceInstance",
+          "id":"test-system123-serviceInstance-6",
+          "changelogSequence":0,
+          "lastUpdate":"2016-06-20T12:46:29.818+02:00",
+          "revisionNumber":0,
+          "systemId":"system123",
+          "name":"PostgreSQL",
+          "nodeId":"test-system123-node-4",
+          "serviceId":"test-system123-service-6"
+       },
+       {
+          "type":"serviceInstance",
+          "id":"test-system123-serviceInstance-1",
+          "changelogSequence":0,
+          "lastUpdate":"2016-06-20T12:46:29.818+02:00",
+          "revisionNumber":0,
+          "systemId":"system123",
+          "name":"FrontEnd",
+          "nodeId":"test-system123-node-1",
+          "serviceId":"test-system123-service-1"
+       },
+       {
+          "type":"serviceInstance",
+          "id":"test-system123-serviceInstance-2",
+          "changelogSequence":0,
+          "lastUpdate":"2016-06-20T12:46:29.818+02:00",
+          "revisionNumber":0,
+          "systemId":"system123",
+          "name":"WebService",
+          "nodeId":"test-system123-node-2",
+          "serviceId":"test-system123-service-2"
+       },
+       {
+          "type":"serviceInstance",
+          "id":"test-system123-serviceInstance-3",
+          "changelogSequence":0,
+          "lastUpdate":"2016-06-20T12:46:29.818+02:00",
+          "revisionNumber":0,
+          "systemId":"system123",
+          "name":"CashDesk",
+          "nodeId":"test-system123-node-2",
+          "serviceId":"test-system123-service-3"
+       }
+    ]
+});
+
+export default Model;
\ No newline at end of file
diff --git a/app/models/system.js b/app/models/system.js
index fc06057..037318c 100644
--- a/app/models/system.js
+++ b/app/models/system.js
@@ -1,6 +1,16 @@
 import BaseEntity from './baseentity';
 import attr from 'ember-data/attr';
 
-export default BaseEntity.extend({
+const Model = BaseEntity.extend({
     name: attr('string')
 });
+
+Model.reopenClass({
+    FIXTURES: [{
+      "type": "system",
+      "id": "system123",
+      "name": "Test System"
+    }]
+});
+
+export default Model;
\ No newline at end of file
diff --git a/package.json b/package.json
index 9ee82e6..14e3fa5 100644
--- a/package.json
+++ b/package.json
@@ -38,6 +38,7 @@
     "ember-cli-uglify": "^1.2.0",
     "ember-cli-yuidoc": "0.8.3",
     "ember-data": "^2.4.0",
+    "ember-data-fixture-adapter": "1.13.0",
     "ember-data-url-templates": "0.1.1",
     "ember-debug-logger": "0.2.0",
     "ember-disable-proxy-controllers": "^1.0.1",
-- 
GitLab