-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
86 lines (76 loc) · 3.2 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
from google.appengine.ext import ndb
class PublicationInfo(ndb.Model):
name = ndb.StringProperty()
journal = ndb.StringProperty()
class AnnotationInfo(ndb.Model):
database = ndb.StringProperty()
databaseID = ndb.StringProperty()
class ContentInfo(ndb.Model):
content = ndb.BlobKeyProperty() #BlobInfo(blobkey)
date = ndb.DateTimeProperty(auto_now_add=True)
contactMap = ndb.BlobKeyProperty()
contactMapJson = ndb.JsonProperty()
processMap = ndb.BlobKeyProperty()
timeSeries = ndb.BlobKeyProperty()
timeSeriesJson = ndb.JsonProperty()
processMapJson = ndb.JsonProperty()
@classmethod
def create(cls, params, doc_id):
content = cls(content=params['content'])
if 'timeSeries' in params:
content.timeSeries = params['timeSeries']
content.timeSeriesJson = params['timeSeriesJson']
if 'processMap' in params:
content.processMap=params['processMap']
content.processMapJson=params['processMapJson']
if 'contactMap' in params:
content.contactMap=params['contactMap']
content.contactMapJson=params['contactMapJson']
return content
class ModelInfo(ndb.Model):
"""Models an individual Guestbook entry with author, content, and date."""
author = ndb.StringProperty(repeated=True)
'''
content = ndb.BlobKeyProperty() #BlobInfo(blobkey)
contactMap = ndb.BlobKeyProperty()
contactMapJson = ndb.JsonProperty()
processMap = ndb.BlobKeyProperty()
timeSeries = ndb.BlobKeyProperty()
timeSeriesJson = ndb.JsonProperty()
processMapJson = ndb.JsonProperty()
'''
contentHistory = ndb.StructuredProperty(ContentInfo,repeated=True)
name = ndb.StringProperty()
description = ndb.StringProperty()
date = ndb.DateTimeProperty(auto_now_add=True)
publication = ndb.StructuredProperty(PublicationInfo)
fileFormat = ndb.StringProperty(choices=set(["bngl","kappa"]))
submitter = ndb.StringProperty()
annotationInfo = ndb.KeyProperty(kind=AnnotationInfo,repeated=True)
tags = ndb.StringProperty(repeated=True)
structuredTags = ndb.StringProperty(repeated=True)
privacy = ndb.StringProperty()
notes = ndb.StringProperty()
doc_id = ndb.StringProperty()
def update_core(self, params, doc_id):
"""Update 'core' values from the given params dict and doc_id."""
self.populate(doc_id=doc_id)
@classmethod
def create(cls, params, doc_id):
"""Create a new product entity from a subset of the given params dict
values, and the given doc_id."""
prod = cls(id=doc_id,
content=params['content'], doc_id=doc_id,name=params['name'],
submitter=params['submitter'],privacy=params['privacy'],tags=params['tags'],
structuredTags=params['structuredTags'],author=params['author']
)
if 'notes' in params:
prod.notes = params['notes']
if 'tags' in params:
prod.tags=params['tags']
content = ContentInfo.create(params)
prod.contentHistory = [content]
#if 'structuredTags' in params:
# prod.structuredTags=params['structuredTags'],
#prod.put()
return prod