Skip to content
Snippets Groups Projects
Commit d13292b8 authored by John Schihada's avatar John Schihada
Browse files

Adjustments for fetching scrolls

parent e43aad57
Branches
No related tags found
No related merge requests found
...@@ -57,6 +57,8 @@ void Start() ...@@ -57,6 +57,8 @@ void Start()
IEnumerator getScrollsfromServer() { IEnumerator getScrollsfromServer() {
UnityWebRequest request = UnityWebRequest.Get(CommunicationEvents.ServerAdress + "/scroll/list"); UnityWebRequest request = UnityWebRequest.Get(CommunicationEvents.ServerAdress + "/scroll/list");
//Postman-Echo-Mock
//UnityWebRequest request = UnityWebRequest.Get("https://019a8ea5-843a-498b-8d0c-778669aef987.mock.pstmn.io/get");
request.method = UnityWebRequest.kHttpVerbGET; request.method = UnityWebRequest.kHttpVerbGET;
yield return request.Send(); yield return request.Send();
if (request.isNetworkError || request.isHttpError) if (request.isNetworkError || request.isHttpError)
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
using System.Linq; using System.Linq;
using System; using System;
using UnityEngine; using UnityEngine;
using static JSONManager;
using Newtonsoft.Json;
/* /*
...@@ -44,12 +46,18 @@ public class Scroll : LightScroll ...@@ -44,12 +46,18 @@ public class Scroll : LightScroll
public static List<Scroll> FromJSON(string json) public static List<Scroll> FromJSON(string json)
{ {
List<Scroll> scrolls = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Scroll>>(json); List<Scroll> scrolls = JsonConvert.DeserializeObject<List<Scroll>>(json, new JsonSerializerSettings
{
TypeNameHandling = TypeNameHandling.Auto
});
return scrolls; return scrolls;
} }
public static string ToJSON(FilledScroll scroll) public static string ToJSON(FilledScroll scroll)
{ {
string json = Newtonsoft.Json.JsonConvert.SerializeObject(scroll); string json = Newtonsoft.Json.JsonConvert.SerializeObject(scroll, new JsonSerializerSettings
{
TypeNameHandling = TypeNameHandling.Auto
});
return json; return json;
} }
...@@ -129,15 +137,28 @@ public FilledScroll(LightScroll scroll, List<ScrollAssignment> assignments) ...@@ -129,15 +137,28 @@ public FilledScroll(LightScroll scroll, List<ScrollAssignment> assignments)
public class ScrollFact public class ScrollFact
{ {
public string uri; public string uri;
public string kind;
public string label; public string label;
public FactBody tp;
public JSONManager.MMTTerm df;
} }
public class FactBody /**
* Class used for deserializing incoming symbol-declarations from mmt
*/
public class ScrollSymbolFact : ScrollFact
{
public MMTTerm tp;
public MMTTerm df;
}
/**
* Class used for deserializing incoming value-declarations from mmt
*/
public class ScrollValueFact : ScrollFact
{ {
public JSONManager.MMTTerm original; MMTTerm lhs;
public JSONManager.MMTTerm simplified; MMTTerm valueTp;
MMTTerm value;
MMTTerm proof;
} }
} }
......
...@@ -94,7 +94,7 @@ public static string ToJson(MMTDeclaration mmtDecl) ...@@ -94,7 +94,7 @@ public static string ToJson(MMTDeclaration mmtDecl)
/** /**
* MMTSymbolDeclaration: Class for facts without values, e.g. Points * MMTSymbolDeclaration: Class for facts without values, e.g. Points
**/ */
public class MMTSymbolDeclaration : MMTDeclaration public class MMTSymbolDeclaration : MMTDeclaration
{ {
public string kind = "general"; public string kind = "general";
...@@ -102,6 +102,9 @@ public class MMTSymbolDeclaration : MMTDeclaration ...@@ -102,6 +102,9 @@ public class MMTSymbolDeclaration : MMTDeclaration
public MMTTerm tp; public MMTTerm tp;
public MMTTerm df; public MMTTerm df;
/**
* Constructor used for sending new declarations to mmt
*/
public MMTSymbolDeclaration(string label, MMTTerm tp, MMTTerm df) public MMTSymbolDeclaration(string label, MMTTerm tp, MMTTerm df)
{ {
this.label = label; this.label = label;
...@@ -112,7 +115,7 @@ public MMTSymbolDeclaration(string label, MMTTerm tp, MMTTerm df) ...@@ -112,7 +115,7 @@ public MMTSymbolDeclaration(string label, MMTTerm tp, MMTTerm df)
/** /**
* MMTValueDeclaration: Class for facts with values, e.g. Distances or Angles * MMTValueDeclaration: Class for facts with values, e.g. Distances or Angles
**/ */
public class MMTValueDeclaration : MMTDeclaration public class MMTValueDeclaration : MMTDeclaration
{ {
public string kind = "veq"; public string kind = "veq";
...@@ -121,6 +124,9 @@ public class MMTValueDeclaration : MMTDeclaration ...@@ -121,6 +124,9 @@ public class MMTValueDeclaration : MMTDeclaration
public MMTTerm valueTp; public MMTTerm valueTp;
public MMTTerm value; public MMTTerm value;
/**
* Constructor used for sending new declarations to mmt
*/
public MMTValueDeclaration(string label, MMTTerm lhs, MMTTerm valueTp, MMTTerm value) public MMTValueDeclaration(string label, MMTTerm lhs, MMTTerm valueTp, MMTTerm value)
{ {
this.label = label; this.label = label;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment