-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fe6664a
commit 21291fa
Showing
13 changed files
with
147 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,39 @@ | ||
import json | ||
|
||
from marshmallow import Schema, fields | ||
from marshmallow_jsonschema import JSONSchema | ||
from neomodel import StringProperty, StructuredNode, UniqueIdProperty | ||
from neomodel import StringProperty, StructuredNode, UniqueIdProperty, config | ||
|
||
from src.Models.DataObject.v0_0_2.SerializeClass import SerializeClass | ||
|
||
class DataObject(StructuredNode): | ||
uid = UniqueIdProperty() | ||
name = StringProperty(unique_index=True, required=True) | ||
|
||
def toJSON(self): | ||
return json.dumps(self, default=lambda o: o.__dict__) | ||
|
||
def getSchema(self): | ||
data_object_schema = DataObjectSchema() | ||
json_schema = JSONSchema() | ||
return json_schema.dump(data_object_schema) | ||
config.DATABASE_URL = 'bolt://neo4j:password@localhost:7687' | ||
#from src.GCF.utils.db import clean_database | ||
#clean_database() | ||
|
||
|
||
class DataObjectSchema(Schema): | ||
uid = fields.String() | ||
name = fields.String(required=True) | ||
|
||
|
||
class DataObject(StructuredNode, SerializeClass, Schema): | ||
name = StringProperty(unique_index=True, required=True) | ||
uid = UniqueIdProperty() | ||
|
||
# def __init__(self, *args, **kwargs): | ||
# super().__init__(*args, **kwargs) | ||
# SerializeClass.__init__(self, schema=DataObjectSchema()) | ||
# self.list.extend([self.uid, self.name]) | ||
|
||
def __init__(self, schema, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
SerializeClass.__init__(self, schema=DataObjectSchema()) | ||
self.list.extend([self.uid, self.name]) | ||
|
||
|
||
#ola =DataObject(name="ola").save() | ||
# #ola.getSchema() | ||
# print(ola.toJSON()) | ||
# ola.nodes.get(name="ola") | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,20 @@ | ||
import json | ||
|
||
from marshmallow import Schema, fields | ||
from marshmallow_jsonschema import JSONSchema | ||
from neomodel import DateTimeProperty | ||
|
||
from src.Models.DataObject.v0_0_2 import SerializeClass | ||
from src.Models.DataObject.v0_0_2.Date import Date | ||
|
||
|
||
class IntervalSchema(Schema): | ||
startDateValue = fields.Date(required=True) | ||
endDateValue = fields.Date(required=True) | ||
|
||
|
||
class Interval(Date): | ||
super(SerializeClass).__init__(IntervalSchema) | ||
startDateValue = DateTimeProperty(unique_index=True, required=True) | ||
endDateValue = DateTimeProperty(unique_index=True, required=True) | ||
|
||
def toJSON(self): | ||
return json.dumps(self, default=lambda o: o.__dict__) | ||
|
||
def getSchema(self): | ||
interval_schema = IntervalSchema() | ||
json_schema = JSONSchema() | ||
return json_schema.dump(interval_schema) | ||
|
||
|
||
class IntervalSchema(Schema): | ||
startDateValue = fields.Date(required=True) | ||
endDateValue = fields.Date(required=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import json | ||
from marshmallow import Schema, fields | ||
from marshmallow_jsonschema import JSONSchema | ||
|
||
|
||
class SerializeClass: | ||
def __init__(self, schema): | ||
self.list = [] | ||
self.schema = schema | ||
|
||
def getSchema(self): | ||
json_schema = JSONSchema() | ||
return json_schema.dump(self.schema) | ||
|
||
def toJSON(self): | ||
return json.dumps(self.list, default=lambda o: o.__dict__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,27 @@ | ||
import json | ||
|
||
from marshmallow import Schema, fields | ||
from marshmallow_jsonschema import JSONSchema | ||
from neomodel import StringProperty | ||
from src.Models.DataObject.v0_0_2.DataObject import DataObject | ||
from src.Models.DataObject.v0_0_2.SerializeClass import SerializeClass | ||
|
||
|
||
class StringSchema(Schema): | ||
stringValue = fields.String(required=True) | ||
|
||
|
||
# class String(DataObject): | ||
# stringValue = StringProperty(unique_index=True, required=True) | ||
# | ||
# def __init__(self, *args, **kwargs): | ||
# super().__init__(*args, **kwargs) | ||
# self.list.append(self.stringValue) | ||
|
||
class String(DataObject): | ||
stringValue = StringProperty(unique_index=True, required=True) | ||
|
||
def toJSON(self): | ||
return json.dumps(self, default=lambda o: o.__dict__) | ||
|
||
def getSchema(self): | ||
string_schema = StringSchema() | ||
json_schema = JSONSchema() | ||
return json_schema.dump(string_schema) | ||
def __init__(self, *args, **kwargs): | ||
super().__init__(StringSchema(), *args, **kwargs) | ||
self.list.append(self.stringValue) | ||
|
||
|
||
class StringSchema(Schema): | ||
stringValue = fields.String(required=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters