From 11d33f571eb7be8682ed58d0668b71159a6551a5 Mon Sep 17 00:00:00 2001
From: Steve Reis <stevereis93@gmail.com>
Date: Thu, 14 Oct 2021 16:26:30 +0200
Subject: [PATCH] Add new dummy connector

---
 .../connectors/datashield/main.connector.ts   |  30 +----
 .../engine/connectors/local/main.connector.ts | 110 ++++++++++++++++++
 api/src/engine/models/group.model.ts          |  12 +-
 api/src/schema.gql                            |   4 +-
 4 files changed, 124 insertions(+), 32 deletions(-)
 create mode 100644 api/src/engine/connectors/local/main.connector.ts

diff --git a/api/src/engine/connectors/datashield/main.connector.ts b/api/src/engine/connectors/datashield/main.connector.ts
index 3ee3fbb..829147f 100644
--- a/api/src/engine/connectors/datashield/main.connector.ts
+++ b/api/src/engine/connectors/datashield/main.connector.ts
@@ -47,33 +47,11 @@ export default class DataShieldService implements IEngineService {
   }
 
   getDomains(): Domain[] {
-    return [
-      {
-        id: 'Dummy',
-        label: 'Dummy',
-        datasets: [{ id: 'DummyDataSet' }],
-        groups: [
-          {
-            id: 'DummyGroup',
-            variables: ['DummyVar'],
-            groups: [],
-          },
-        ],
-        rootGroup: { id: 'DummyGroup', variables: [], groups: [] },
-        variables: [{ id: 'DummyVar', type: 'string' }],
-      },
-    ];
+    throw new Error('Method not implemented.');
   }
 
   getActiveUser(): string {
-    const dummyUser = {
-      username: 'anonymous',
-      subjectId: 'anonymousId',
-      fullname: 'anonymous',
-      email: 'anonymous@anonymous.com',
-      agreeNDA: true,
-    };
-    return JSON.stringify(dummyUser);
+    throw new Error('Method not implemented.');
   }
 
   editActiveUser(): Observable<string> {
@@ -101,10 +79,10 @@ export default class DataShieldService implements IEngineService {
   }
 
   getExperiments(): string {
-    return '[]';
+    throw new Error('Method not implemented.');
   }
 
   getAlgorithmsREST(): string {
-    return '[]';
+    throw new Error('Method not implemented.');
   }
 }
diff --git a/api/src/engine/connectors/local/main.connector.ts b/api/src/engine/connectors/local/main.connector.ts
new file mode 100644
index 0000000..2ff1a44
--- /dev/null
+++ b/api/src/engine/connectors/local/main.connector.ts
@@ -0,0 +1,110 @@
+import { Observable } from 'rxjs';
+import { IEngineService } from 'src/engine/engine.interfaces';
+import { Domain } from 'src/engine/models/domain.model';
+import { ExperimentCreateInput } from 'src/engine/models/experiment/input/experiment-create.input';
+import {
+  Experiment,
+  PartialExperiment,
+} from 'src/engine/models/experiment/experiment.model';
+import { ListExperiments } from 'src/engine/models/experiment/list-experiments.model';
+import { ExperimentEditInput } from 'src/engine/models/experiment/input/experiment-edit.input';
+import { Algorithm } from 'src/engine/models/experiment/algorithm.model';
+
+export default class LocalService implements IEngineService {
+  getAlgorithms(): Algorithm[] | Promise<Algorithm[]> {
+    throw new Error('Method not implemented.');
+  }
+
+  createExperiment(
+    data: ExperimentCreateInput,
+    isTransient: boolean,
+  ): Experiment | Promise<Experiment> {
+    throw new Error('Method not implemented.');
+  }
+
+  listExperiments(
+    page: number,
+    name: string,
+  ): ListExperiments | Promise<ListExperiments> {
+    throw new Error('Method not implemented.');
+  }
+
+  getExperiment(uuid: string): Experiment | Promise<Experiment> {
+    throw new Error('Method not implemented.');
+  }
+
+  removeExperiment(
+    uuid: string,
+  ): PartialExperiment | Promise<PartialExperiment> {
+    throw new Error('Method not implemented.');
+  }
+
+  editExperient(
+    uuid: string,
+    expriment: ExperimentEditInput,
+  ): Experiment | Promise<Experiment> {
+    throw new Error('Method not implemented.');
+  }
+
+  getDomains(): Domain[] {
+    return [
+      {
+        id: 'Dummy',
+        label: 'Dummy',
+        datasets: [{ id: 'DummyDataset', label: 'DummyDataset' }],
+        groups: [
+          {
+            id: 'DummyGroup',
+            variables: ['DummyVar'],
+            groups: [],
+          },
+        ],
+        rootGroup: { id: 'DummyGroup' },
+        variables: [{ id: 'DummyVar', type: 'string' }],
+      },
+    ];
+  }
+
+  getActiveUser(): string {
+    const dummyUser = {
+      username: 'anonymous',
+      subjectId: 'anonymousId',
+      fullname: 'anonymous',
+      email: 'anonymous@anonymous.com',
+      agreeNDA: true,
+    };
+    return JSON.stringify(dummyUser);
+  }
+
+  editActiveUser(): Observable<string> {
+    throw new Error('Method not implemented.');
+  }
+
+  getExperimentREST(): Observable<string> {
+    throw new Error('Method not implemented.');
+  }
+
+  deleteExperiment(): Observable<string> {
+    throw new Error('Method not implemented.');
+  }
+
+  editExperimentREST(): Observable<string> {
+    throw new Error('Method not implemented.');
+  }
+
+  startExperimentTransient(): Observable<string> {
+    throw new Error('Method not implemented.');
+  }
+
+  startExperiment(): Observable<string> {
+    throw new Error('Method not implemented.');
+  }
+
+  getExperiments(): string {
+    return '[]';
+  }
+
+  getAlgorithmsREST(): string {
+    return '[]';
+  }
+}
diff --git a/api/src/engine/models/group.model.ts b/api/src/engine/models/group.model.ts
index 0cb97a4..6c48802 100644
--- a/api/src/engine/models/group.model.ts
+++ b/api/src/engine/models/group.model.ts
@@ -6,9 +6,13 @@ export class Group extends Entity {
   @Field({ nullable: true })
   description?: string;
 
-  @Field(() => [Group])
-  groups: Group[];
+  @Field(() => [Group], { defaultValue: [], nullable: true })
+  groups?: Group[];
 
-  @Field(() => [String], { description: "List of variable's ids" })
-  variables: string[];
+  @Field(() => [String], {
+    description: "List of variable's ids",
+    defaultValue: [],
+    nullable: true,
+  })
+  variables?: string[];
 }
diff --git a/api/src/schema.gql b/api/src/schema.gql
index ee828b1..c906a19 100644
--- a/api/src/schema.gql
+++ b/api/src/schema.gql
@@ -11,10 +11,10 @@ type Group {
   id: String!
   label: String
   description: String
-  groups: [Group!]!
+  groups: [Group!]
 
   """List of variable's ids"""
-  variables: [String!]!
+  variables: [String!]
 }
 
 type Variable {
-- 
GitLab