Convert get_schema methods to use JSON Schema
This commit is contained in:
parent
2692f86cd6
commit
6f0119288b
@ -5,6 +5,7 @@
|
|||||||
# Copyright (C) 2010 Michiel D. Nauta
|
# Copyright (C) 2010 Michiel D. Nauta
|
||||||
# Copyright (C) 2011 Tim G L Lyons
|
# Copyright (C) 2011 Tim G L Lyons
|
||||||
# Copyright (C) 2013 Doug Blank <doug.blank@gmail.com>
|
# Copyright (C) 2013 Doug Blank <doug.blank@gmail.com>
|
||||||
|
# Copyright (C) 2017 Nick Hall
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -80,6 +81,38 @@ class Address(SecondaryObject, PrivacyBase, CitationBase, NoteBase, DateBase,
|
|||||||
LocationBase.unserialize(self, location)
|
LocationBase.unserialize(self, location)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_schema(cls):
|
||||||
|
"""
|
||||||
|
Returns the JSON Schema for this class.
|
||||||
|
|
||||||
|
:returns: Returns a dict containing the schema.
|
||||||
|
:rtype: dict
|
||||||
|
"""
|
||||||
|
from .date import Date
|
||||||
|
return {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"_class": {"enum": [cls.__name__]},
|
||||||
|
"private": {"type": "boolean"},
|
||||||
|
"citation_list": {"type": "array",
|
||||||
|
"items": {"type": "string",
|
||||||
|
"maxLength": 50}},
|
||||||
|
"note_list": {"type": "array",
|
||||||
|
"items": {"type": "string",
|
||||||
|
"maxLength": 50}},
|
||||||
|
"date": {"oneOf": [{"type": "null"}, Date.get_schema()]},
|
||||||
|
"street": {"type": "string"},
|
||||||
|
"locality": {"type": "string"},
|
||||||
|
"city": {"type": "string"},
|
||||||
|
"county": {"type": "string"},
|
||||||
|
"state": {"type": "string"},
|
||||||
|
"country": {"type": "string"},
|
||||||
|
"postal": {"type": "string"},
|
||||||
|
"phone": {"type": "string"}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
def get_text_data_list(self):
|
def get_text_data_list(self):
|
||||||
"""
|
"""
|
||||||
Return the list of all textual attributes of the object.
|
Return the list of all textual attributes of the object.
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||||
# Copyright (C) 2010 Michiel D. Nauta
|
# Copyright (C) 2010 Michiel D. Nauta
|
||||||
# Copyright (C) 2011 Tim G L Lyons
|
# Copyright (C) 2011 Tim G L Lyons
|
||||||
|
# Copyright (C) 2017 Nick Hall
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -220,6 +221,30 @@ class Attribute(AttributeRoot, CitationBase, NoteBase):
|
|||||||
self.type.unserialize(the_type)
|
self.type.unserialize(the_type)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_schema(cls):
|
||||||
|
"""
|
||||||
|
Returns the JSON Schema for this class.
|
||||||
|
|
||||||
|
:returns: Returns a dict containing the schema.
|
||||||
|
:rtype: dict
|
||||||
|
"""
|
||||||
|
return {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"_class": {"enum": [cls.__name__]},
|
||||||
|
"private": {"type": "boolean"},
|
||||||
|
"citation_list": {"type": "array",
|
||||||
|
"items": {"type": "string",
|
||||||
|
"maxLength": 50}},
|
||||||
|
"note_list": {"type": "array",
|
||||||
|
"items": {"type": "string",
|
||||||
|
"maxLength": 50}},
|
||||||
|
"type": AttributeType.get_schema(),
|
||||||
|
"value": {"type": "string"}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
def get_referenced_handles(self):
|
def get_referenced_handles(self):
|
||||||
"""
|
"""
|
||||||
Return the list of (classname, handle) tuples for all directly
|
Return the list of (classname, handle) tuples for all directly
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
# Copyright (C) 2010 Michiel D. Nauta
|
# Copyright (C) 2010 Michiel D. Nauta
|
||||||
# Copyright (C) 2011 Tim G L Lyons
|
# Copyright (C) 2011 Tim G L Lyons
|
||||||
# Copyright (C) 2013 Doug Blank <doug.blank@gmail.com>
|
# Copyright (C) 2013 Doug Blank <doug.blank@gmail.com>
|
||||||
|
# Copyright (C) 2017 Nick Hall
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -36,7 +37,6 @@ from .notebase import NoteBase
|
|||||||
from .refbase import RefBase
|
from .refbase import RefBase
|
||||||
from .childreftype import ChildRefType
|
from .childreftype import ChildRefType
|
||||||
from .const import IDENTICAL, EQUAL, DIFFERENT
|
from .const import IDENTICAL, EQUAL, DIFFERENT
|
||||||
from .handle import Handle
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -90,6 +90,32 @@ class ChildRef(SecondaryObject, PrivacyBase, CitationBase, NoteBase, RefBase):
|
|||||||
self.mrel.unserialize(mrel)
|
self.mrel.unserialize(mrel)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_schema(cls):
|
||||||
|
"""
|
||||||
|
Returns the JSON Schema for this class.
|
||||||
|
|
||||||
|
:returns: Returns a dict containing the schema.
|
||||||
|
:rtype: dict
|
||||||
|
"""
|
||||||
|
return {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"_class": {"enum": [cls.__name__]},
|
||||||
|
"private": {"type": "boolean"},
|
||||||
|
"citation_list": {"type": "array",
|
||||||
|
"items": {"type": "string",
|
||||||
|
"maxLength": 50}},
|
||||||
|
"note_list": {"type": "array",
|
||||||
|
"items": {"type": "string",
|
||||||
|
"maxLength": 50}},
|
||||||
|
"ref": {"type": "string",
|
||||||
|
"maxLength": 50},
|
||||||
|
"frel": ChildRefType.get_schema(),
|
||||||
|
"mrel": ChildRefType.get_schema()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
def get_text_data_list(self):
|
def get_text_data_list(self):
|
||||||
"""
|
"""
|
||||||
Return the list of all textual attributes of the object.
|
Return the list of all textual attributes of the object.
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||||
# Copyright (C) 2010 Michiel D. Nauta
|
# Copyright (C) 2010 Michiel D. Nauta
|
||||||
# Copyright (C) 2011 Tim G L Lyons
|
# Copyright (C) 2011 Tim G L Lyons
|
||||||
|
# Copyright (C) 2017 Nick Hall
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -43,7 +44,6 @@ from .datebase import DateBase
|
|||||||
from .tagbase import TagBase
|
from .tagbase import TagBase
|
||||||
from .attrbase import SrcAttributeBase
|
from .attrbase import SrcAttributeBase
|
||||||
from .citationbase import IndirectCitationBase
|
from .citationbase import IndirectCitationBase
|
||||||
from .handle import Handle
|
|
||||||
|
|
||||||
LOG = logging.getLogger(".citation")
|
LOG = logging.getLogger(".citation")
|
||||||
|
|
||||||
@ -82,23 +82,41 @@ class Citation(MediaBase, NoteBase, SrcAttributeBase, IndirectCitationBase,
|
|||||||
@classmethod
|
@classmethod
|
||||||
def get_schema(cls):
|
def get_schema(cls):
|
||||||
"""
|
"""
|
||||||
Return the schema as a dictionary for this class.
|
Returns the JSON Schema for this class.
|
||||||
|
|
||||||
|
:returns: Returns a dict containing the schema.
|
||||||
|
:rtype: dict
|
||||||
"""
|
"""
|
||||||
from .srcattribute import SrcAttribute
|
from .srcattribute import SrcAttribute
|
||||||
|
from .mediaref import MediaRef
|
||||||
from .date import Date
|
from .date import Date
|
||||||
return {
|
return {
|
||||||
"handle": Handle("Citation", "CITATION-HANDLE"),
|
"type": "object",
|
||||||
"gramps_id": str,
|
"properties": {
|
||||||
"date": Date,
|
"_class": {"enum": [cls.__name__]},
|
||||||
"page": str,
|
"handle": {"type": "string",
|
||||||
"confidence": str,
|
"maxLength": 50},
|
||||||
"source_handle": Handle("Source", "SOURCE-HANDLE"),
|
"gramps_id": {"type": "string"},
|
||||||
"note_list": [Handle("Note", "NOTE-HANDLE")],
|
"date": {"oneOf": [{"type": "null"}, Date.get_schema()]},
|
||||||
"media_list": [Handle("Media", "MEDIA-HANDLE")],
|
"page": {"type": "string"},
|
||||||
"srcattr_list": [SrcAttribute],
|
"confidence": {"type": "integer",
|
||||||
"change": int,
|
"minimum": 0,
|
||||||
"tag_list": [Handle("Tag", "TAG-HANDLE")],
|
"maximum": 4},
|
||||||
"private": bool,
|
"source_handle": {"type": "string",
|
||||||
|
"maxLength": 50},
|
||||||
|
"note_list": {"type": "array",
|
||||||
|
"items": {"type": "string",
|
||||||
|
"maxLength": 50}},
|
||||||
|
"media_list": {"type": "array",
|
||||||
|
"items": MediaRef.get_schema()},
|
||||||
|
"srcattr_list": {"type": "array",
|
||||||
|
"items": SrcAttribute.get_schema()},
|
||||||
|
"change": {"type": "integer"},
|
||||||
|
"tag_list": {"type": "array",
|
||||||
|
"items": {"type": "string",
|
||||||
|
"maxLength": 50}},
|
||||||
|
"private": {"type": "boolean"}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
# Copyright (C) 2009-2013 Douglas S. Blank
|
# Copyright (C) 2009-2013 Douglas S. Blank
|
||||||
# Copyright (C) 2013 Paul Franklin
|
# Copyright (C) 2013 Paul Franklin
|
||||||
# Copyright (C) 2013-2014 Vassilii Khachaturov
|
# Copyright (C) 2013-2014 Vassilii Khachaturov
|
||||||
|
# Copyright (C) 2017 Nick Hall
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -692,6 +693,29 @@ class Date:
|
|||||||
raise DateError("Invalid date to unserialize")
|
raise DateError("Invalid date to unserialize")
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_schema(cls):
|
||||||
|
"""
|
||||||
|
Returns the JSON Schema for this class.
|
||||||
|
|
||||||
|
:returns: Returns a dict containing the schema.
|
||||||
|
:rtype: dict
|
||||||
|
"""
|
||||||
|
return {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"_class": {"enum": [cls.__name__]},
|
||||||
|
"calendar": {"type": "integer"},
|
||||||
|
"modifier": {"type": "integer"},
|
||||||
|
"quality": {"type": "integer"},
|
||||||
|
"dateval": {"type": "array",
|
||||||
|
"items": {"type": ["integer", "boolean"]}},
|
||||||
|
"text": {"type": "string"},
|
||||||
|
"sortval": {"type": "integer"},
|
||||||
|
"newyear": {"type": "integer"}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
def copy(self, source):
|
def copy(self, source):
|
||||||
"""
|
"""
|
||||||
Copy all the attributes of the given Date instance to the present
|
Copy all the attributes of the given Date instance to the present
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||||
# Copyright (C) 2010 Michiel D. Nauta
|
# Copyright (C) 2010 Michiel D. Nauta
|
||||||
# Copyright (C) 2011 Tim G L Lyons
|
# Copyright (C) 2011 Tim G L Lyons
|
||||||
|
# Copyright (C) 2017 Nick Hall
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -45,7 +46,6 @@ from .datebase import DateBase
|
|||||||
from .placebase import PlaceBase
|
from .placebase import PlaceBase
|
||||||
from .tagbase import TagBase
|
from .tagbase import TagBase
|
||||||
from .eventtype import EventType
|
from .eventtype import EventType
|
||||||
from .handle import Handle
|
|
||||||
|
|
||||||
LOG = logging.getLogger(".citation")
|
LOG = logging.getLogger(".citation")
|
||||||
|
|
||||||
@ -121,28 +121,42 @@ class Event(CitationBase, NoteBase, MediaBase, AttributeBase,
|
|||||||
@classmethod
|
@classmethod
|
||||||
def get_schema(cls):
|
def get_schema(cls):
|
||||||
"""
|
"""
|
||||||
Return the schema as a dictionary for this class.
|
Returns the JSON Schema for this class.
|
||||||
|
|
||||||
|
:returns: Returns a dict containing the schema.
|
||||||
|
:rtype: dict
|
||||||
"""
|
"""
|
||||||
from .attribute import Attribute
|
from .attribute import Attribute
|
||||||
from .citation import Citation
|
|
||||||
from .note import Note
|
|
||||||
from .date import Date
|
from .date import Date
|
||||||
from .tag import Tag
|
from .mediaref import MediaRef
|
||||||
from .media import Media
|
|
||||||
return {
|
return {
|
||||||
"handle": Handle("Event", "EVENT-HANDLE"),
|
"type": "object",
|
||||||
"gramps_id": str,
|
"properties": {
|
||||||
"type": EventType,
|
"_class": {"enum": [cls.__name__]},
|
||||||
"date": Date,
|
"handle": {"type": "string",
|
||||||
"description": str,
|
"maxLength": 50},
|
||||||
"place": Handle("Place", "PLACE-HANDLE"),
|
"gramps_id": {"type": "string"},
|
||||||
"citation_list": [Citation],
|
"type": EventType.get_schema(),
|
||||||
"note_list": [Note],
|
"date": {"oneOf": [{"type": "null"}, Date.get_schema()]},
|
||||||
"media_list": [Media],
|
"description": {"type": "string"},
|
||||||
"attribute_list": [Attribute],
|
"place": {"type": ["string", "null"],
|
||||||
"change": int,
|
"maxLength": 50},
|
||||||
"tag_list": [Tag],
|
"citation_list": {"type": "array",
|
||||||
"private": bool,
|
"items": {"type": "string",
|
||||||
|
"maxLength": 50}},
|
||||||
|
"note_list": {"type": "array",
|
||||||
|
"items": {"type": "string",
|
||||||
|
"maxLength": 50}},
|
||||||
|
"media_list": {"type": "array",
|
||||||
|
"items": MediaRef.get_schema()},
|
||||||
|
"attribute_list": {"type": "array",
|
||||||
|
"items": Attribute.get_schema()},
|
||||||
|
"change": {"type": "integer"},
|
||||||
|
"tag_list": {"type": "array",
|
||||||
|
"items": {"type": "string",
|
||||||
|
"maxLength": 50}},
|
||||||
|
"private": {"type": "boolean"},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
# Copyright (C) 2010 Michiel D. Nauta
|
# Copyright (C) 2010 Michiel D. Nauta
|
||||||
# Copyright (C) 2011 Tim G L Lyons
|
# Copyright (C) 2011 Tim G L Lyons
|
||||||
# Copyright (C) 2013 Doug Blank <doug.blank@gmail.com>
|
# Copyright (C) 2013 Doug Blank <doug.blank@gmail.com>
|
||||||
|
# Copyright (C) 2017 Nick Hall
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -38,7 +39,6 @@ from .refbase import RefBase
|
|||||||
from .eventroletype import EventRoleType
|
from .eventroletype import EventRoleType
|
||||||
from .const import IDENTICAL, EQUAL, DIFFERENT
|
from .const import IDENTICAL, EQUAL, DIFFERENT
|
||||||
from .citationbase import IndirectCitationBase
|
from .citationbase import IndirectCitationBase
|
||||||
from .handle import Handle
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -82,18 +82,26 @@ class EventRef(PrivacyBase, NoteBase, AttributeBase, RefBase,
|
|||||||
@classmethod
|
@classmethod
|
||||||
def get_schema(cls):
|
def get_schema(cls):
|
||||||
"""
|
"""
|
||||||
Returns the schema for EventRef.
|
Returns the JSON Schema for this class.
|
||||||
|
|
||||||
:returns: Returns a dict containing the fields to types.
|
:returns: Returns a dict containing the schema.
|
||||||
:rtype: dict
|
:rtype: dict
|
||||||
"""
|
"""
|
||||||
from .attribute import Attribute
|
from .attribute import Attribute
|
||||||
return {
|
return {
|
||||||
"private": bool,
|
"type": "object",
|
||||||
"note_list": [Handle("Note", "NOTE-HANDLE")],
|
"properties": {
|
||||||
"attribute_list": [Attribute],
|
"_class": {"enum": [cls.__name__]},
|
||||||
"ref": Handle("Event", "EVENT-HANDLE"),
|
"private": {"type": "boolean"},
|
||||||
"role": EventRoleType,
|
"note_list": {"type": "array",
|
||||||
|
"items": {"type": "string",
|
||||||
|
"maxLength": 50}},
|
||||||
|
"attribute_list": {"type": "array",
|
||||||
|
"items": Attribute.get_schema()},
|
||||||
|
"ref": {"type": "string",
|
||||||
|
"maxLength": 50},
|
||||||
|
"role": EventRoleType.get_schema(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#
|
#
|
||||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||||
# Copyright (C) 2010 Michiel D. Nauta
|
# Copyright (C) 2010 Michiel D. Nauta
|
||||||
# Copyright (C) 2010 Nick Hall
|
# Copyright (C) 2010,2017 Nick Hall
|
||||||
# Copyright (C) 2011 Tim G L Lyons
|
# Copyright (C) 2011 Tim G L Lyons
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
@ -49,7 +49,6 @@ from .tagbase import TagBase
|
|||||||
from .childref import ChildRef
|
from .childref import ChildRef
|
||||||
from .familyreltype import FamilyRelType
|
from .familyreltype import FamilyRelType
|
||||||
from .const import IDENTICAL, EQUAL, DIFFERENT
|
from .const import IDENTICAL, EQUAL, DIFFERENT
|
||||||
from .handle import Handle
|
|
||||||
|
|
||||||
LOG = logging.getLogger(".citation")
|
LOG = logging.getLogger(".citation")
|
||||||
|
|
||||||
@ -129,26 +128,50 @@ class Family(CitationBase, NoteBase, MediaBase, AttributeBase, LdsOrdBase,
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_schema(cls):
|
def get_schema(cls):
|
||||||
|
"""
|
||||||
|
Returns the JSON Schema for this class.
|
||||||
|
|
||||||
|
:returns: Returns a dict containing the schema.
|
||||||
|
:rtype: dict
|
||||||
|
"""
|
||||||
from .mediaref import MediaRef
|
from .mediaref import MediaRef
|
||||||
from .ldsord import LdsOrd
|
from .ldsord import LdsOrd
|
||||||
from .childref import ChildRef
|
from .childref import ChildRef
|
||||||
from .attribute import Attribute
|
from .attribute import Attribute
|
||||||
return {
|
return {
|
||||||
"handle": Handle("Family", "FAMILY-HANDLE"),
|
"type": "object",
|
||||||
"gramps_id": str,
|
"properties": {
|
||||||
"father_handle": Handle("Person", "PERSON-HANDLE"),
|
"_class": {"enum": [cls.__name__]},
|
||||||
"mother_handle": Handle("Person", "PERSON-HANDLE"),
|
"handle": {"type": "string",
|
||||||
"child_ref_list": [ChildRef],
|
"maxLength": 50},
|
||||||
"type": FamilyRelType,
|
"gramps_id": {"type": "string"},
|
||||||
"event_ref_list": [EventRef],
|
"father_handle": {"type": ["string", "null"],
|
||||||
"media_list": [MediaRef],
|
"maxLength": 50},
|
||||||
"attribute_list": [Attribute],
|
"mother_handle": {"type": ["string", "null"],
|
||||||
"lds_ord_list": [LdsOrd],
|
"maxLength": 50},
|
||||||
"citation_list": [Handle("Citation", "CITATION-HANDLE")],
|
"child_ref_list": {"type": "array",
|
||||||
"note_list": [Handle("Note", "NOTE-HANDLE")],
|
"items": ChildRef.get_schema()},
|
||||||
"change": int,
|
"type": FamilyRelType.get_schema(),
|
||||||
"tag_list": [Handle("Tag", "TAG-HANDLE")],
|
"event_ref_list": {"type": "array",
|
||||||
"private": bool
|
"items": EventRef.get_schema()},
|
||||||
|
"media_list": {"type": "array",
|
||||||
|
"items": MediaRef.get_schema()},
|
||||||
|
"attribute_list": {"type": "array",
|
||||||
|
"items": Attribute.get_schema()},
|
||||||
|
"lds_ord_list": {"type": "array",
|
||||||
|
"items": LdsOrd.get_schema()},
|
||||||
|
"citation_list": {"type": "array",
|
||||||
|
"items": {"type": "string",
|
||||||
|
"maxLength": 50}},
|
||||||
|
"note_list": {"type": "array",
|
||||||
|
"items": {"type": "string",
|
||||||
|
"maxLength": 50}},
|
||||||
|
"change": {"type": "integer"},
|
||||||
|
"tag_list": {"type": "array",
|
||||||
|
"items": {"type": "string",
|
||||||
|
"maxLength": 50}},
|
||||||
|
"private": {"type": "boolean"}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
# Gramps - a GTK+/GNOME based genealogy program
|
# Gramps - a GTK+/GNOME based genealogy program
|
||||||
#
|
#
|
||||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||||
|
# Copyright (C) 2017 Nick Hall
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -207,6 +208,22 @@ class GrampsType(object, metaclass=GrampsTypeMeta):
|
|||||||
"""Convert the object to a serialized tuple of data. """
|
"""Convert the object to a serialized tuple of data. """
|
||||||
return (self.__value, self.__string)
|
return (self.__value, self.__string)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_schema(cls):
|
||||||
|
"""
|
||||||
|
Returns the JSON Schema for this class.
|
||||||
|
|
||||||
|
:returns: Returns a dict containing the schema.
|
||||||
|
:rtype: dict
|
||||||
|
"""
|
||||||
|
return {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"_class": {"enum": [cls.__name__]},
|
||||||
|
"string": {"type": "string"},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_labels(cls, _):
|
def get_labels(cls, _):
|
||||||
return {
|
return {
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
# Copyright (C) 2010 Michiel D. Nauta
|
# Copyright (C) 2010 Michiel D. Nauta
|
||||||
# Copyright (C) 2011 Tim G L Lyons
|
# Copyright (C) 2011 Tim G L Lyons
|
||||||
# Copyright (C) 2013 Doug Blank <doug.blank@gmail.com>
|
# Copyright (C) 2013 Doug Blank <doug.blank@gmail.com>
|
||||||
|
# Copyright (C) 2017 Nick Hall
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -155,6 +156,35 @@ class LdsOrd(SecondaryObject, CitationBase, NoteBase,
|
|||||||
DateBase.unserialize(self, date)
|
DateBase.unserialize(self, date)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_schema(cls):
|
||||||
|
"""
|
||||||
|
Returns the JSON Schema for this class.
|
||||||
|
|
||||||
|
:returns: Returns a dict containing the schema.
|
||||||
|
:rtype: dict
|
||||||
|
"""
|
||||||
|
from .date import Date
|
||||||
|
return {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"_class": {"enum": [cls.__name__]},
|
||||||
|
"citation_list": {"type": "array",
|
||||||
|
"items": {"type": "string",
|
||||||
|
"maxLength": 50}},
|
||||||
|
"note_list": {"type": "array",
|
||||||
|
"items": {"type": "string",
|
||||||
|
"maxLength": 50}},
|
||||||
|
"date": {"oneOf": [{"type": "null"}, Date.get_schema()]},
|
||||||
|
"type": {"type": "integer"},
|
||||||
|
"place": {"type": "string"},
|
||||||
|
"famc": {"type": ["null", "string"]},
|
||||||
|
"temple": {"type": "string"},
|
||||||
|
"status": {"type": "integer"},
|
||||||
|
"private": {"type": "boolean"}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
def get_text_data_list(self):
|
def get_text_data_list(self):
|
||||||
"""
|
"""
|
||||||
Return the list of all textual attributes of the object.
|
Return the list of all textual attributes of the object.
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||||
# Copyright (C) 2010 Michiel D. Nauta
|
# Copyright (C) 2010 Michiel D. Nauta
|
||||||
# Copyright (C) 2013 Doug Blank <doug.blank@gmail.com>
|
# Copyright (C) 2013 Doug Blank <doug.blank@gmail.com>
|
||||||
|
# Copyright (C) 2017 Nick Hall
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -71,6 +72,30 @@ class Location(SecondaryObject, LocationBase):
|
|||||||
LocationBase.unserialize(self, lbase)
|
LocationBase.unserialize(self, lbase)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_schema(cls):
|
||||||
|
"""
|
||||||
|
Returns the JSON Schema for this class.
|
||||||
|
|
||||||
|
:returns: Returns a dict containing the schema.
|
||||||
|
:rtype: dict
|
||||||
|
"""
|
||||||
|
return {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"_class": {"enum": [cls.__name__]},
|
||||||
|
"street": {"type": "string"},
|
||||||
|
"locality": {"type": "string"},
|
||||||
|
"city": {"type": "string"},
|
||||||
|
"county": {"type": "string"},
|
||||||
|
"state": {"type": "string"},
|
||||||
|
"country": {"type": "string"},
|
||||||
|
"postal": {"type": "string"},
|
||||||
|
"phone": {"type": "string"},
|
||||||
|
"parish": {"type": "string"}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
def get_text_data_list(self):
|
def get_text_data_list(self):
|
||||||
"""
|
"""
|
||||||
Return the list of all textual attributes of the object.
|
Return the list of all textual attributes of the object.
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#
|
#
|
||||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||||
# Copyright (C) 2010 Michiel D. Nauta
|
# Copyright (C) 2010 Michiel D. Nauta
|
||||||
# Copyright (C) 2010 Nick Hall
|
# Copyright (C) 2010,2017 Nick Hall
|
||||||
# Copyright (C) 2011 Tim G L Lyons
|
# Copyright (C) 2011 Tim G L Lyons
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
@ -45,7 +45,6 @@ from .notebase import NoteBase
|
|||||||
from .datebase import DateBase
|
from .datebase import DateBase
|
||||||
from .attrbase import AttributeBase
|
from .attrbase import AttributeBase
|
||||||
from .tagbase import TagBase
|
from .tagbase import TagBase
|
||||||
from .handle import Handle
|
|
||||||
|
|
||||||
LOG = logging.getLogger(".citation")
|
LOG = logging.getLogger(".citation")
|
||||||
|
|
||||||
@ -121,27 +120,38 @@ class Media(CitationBase, NoteBase, DateBase, AttributeBase,
|
|||||||
@classmethod
|
@classmethod
|
||||||
def get_schema(cls):
|
def get_schema(cls):
|
||||||
"""
|
"""
|
||||||
Returns the schema for EventRef.
|
Returns the JSON Schema for this class.
|
||||||
|
|
||||||
:returns: Returns a dict containing the fields to types.
|
:returns: Returns a dict containing the schema.
|
||||||
:rtype: dict
|
:rtype: dict
|
||||||
"""
|
"""
|
||||||
from .attribute import Attribute
|
from .attribute import Attribute
|
||||||
from .date import Date
|
from .date import Date
|
||||||
return {
|
return {
|
||||||
"handle": Handle("Media", "MEDIA-HANDLE"),
|
"type": "object",
|
||||||
"gramps_id": str,
|
"properties": {
|
||||||
"path": str,
|
"_class": {"enum": [cls.__name__]},
|
||||||
"mime": str,
|
"handle": {"type": "string",
|
||||||
"desc": str,
|
"maxLength": 50},
|
||||||
"checksum": str,
|
"gramps_id": {"type": "string"},
|
||||||
"attribute_list": [Attribute],
|
"path": {"type": "string"},
|
||||||
"citation_list": [Handle("Citation", "CITATION-HANDLE")],
|
"mime": {"type": "string"},
|
||||||
"note_list": [Handle("Note", "NOTE-HANDLE")],
|
"desc": {"type": "string"},
|
||||||
"change": int,
|
"checksum": {"type": "string"},
|
||||||
"date": Date,
|
"attribute_list": {"type": "array",
|
||||||
"tag_list": [Handle("Tag", "TAG-HANDLE")],
|
"items": Attribute.get_schema()},
|
||||||
"private": bool,
|
"citation_list": {"type": "array",
|
||||||
|
"items": {"type": "string",
|
||||||
|
"maxLength": 50}},
|
||||||
|
"note_list": {"type": "array",
|
||||||
|
"items": {"type": "string"}},
|
||||||
|
"change": {"type": "integer"},
|
||||||
|
"date": {"oneOf": [{"type": "null"}, Date.get_schema()]},
|
||||||
|
"tag_list": {"type": "array",
|
||||||
|
"items": {"type": "string",
|
||||||
|
"maxLength": 50}},
|
||||||
|
"private": {"type": "boolean"}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
# Copyright (C) 2010 Michiel D. Nauta
|
# Copyright (C) 2010 Michiel D. Nauta
|
||||||
# Copyright (C) 2011 Tim G L Lyons
|
# Copyright (C) 2011 Tim G L Lyons
|
||||||
# Copyright (C) 2013 Doug Blank <doug.blank@gmail.com>
|
# Copyright (C) 2013 Doug Blank <doug.blank@gmail.com>
|
||||||
|
# Copyright (C) 2017 Nick Hall
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -37,7 +38,6 @@ from .notebase import NoteBase
|
|||||||
from .refbase import RefBase
|
from .refbase import RefBase
|
||||||
from .attrbase import AttributeBase
|
from .attrbase import AttributeBase
|
||||||
from .const import IDENTICAL, EQUAL, DIFFERENT
|
from .const import IDENTICAL, EQUAL, DIFFERENT
|
||||||
from .handle import Handle
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -73,21 +73,33 @@ class MediaRef(SecondaryObject, PrivacyBase, CitationBase, NoteBase, RefBase,
|
|||||||
@classmethod
|
@classmethod
|
||||||
def get_schema(cls):
|
def get_schema(cls):
|
||||||
"""
|
"""
|
||||||
Returns the schema for MediaRef.
|
Returns the JSON Schema for this class.
|
||||||
|
|
||||||
:returns: Returns a dict containing the fields to types.
|
:returns: Returns a dict containing the schema.
|
||||||
:rtype: dict
|
:rtype: dict
|
||||||
"""
|
"""
|
||||||
from .attribute import Attribute
|
from .attribute import Attribute
|
||||||
from .citation import Citation
|
|
||||||
from .note import Note
|
|
||||||
return {
|
return {
|
||||||
"private": bool,
|
"type": "object",
|
||||||
"citation_list": [Citation],
|
"properties": {
|
||||||
"note_list": [Note],
|
"_class": {"enum": [cls.__name__]},
|
||||||
"attribute_list": [Attribute],
|
"private": {"type": "boolean"},
|
||||||
"ref": Handle("Media", "MEDIA-HANDLE"),
|
"citation_list": {"type": "array",
|
||||||
"rect": tuple, # or None if (0,0,0,0)
|
"items": {"type": "string",
|
||||||
|
"maxLength": 50}},
|
||||||
|
"note_list": {"type": "array",
|
||||||
|
"items": {"type": "string",
|
||||||
|
"maxLength": 50}},
|
||||||
|
"attribute_list": {"type": "array",
|
||||||
|
"items": Attribute.get_schema()},
|
||||||
|
"ref": {"type": "string",
|
||||||
|
"maxLength": 50},
|
||||||
|
"rect": {"oneOf": [{"type": "null"},
|
||||||
|
{"type": "array",
|
||||||
|
"items": {"type": "integer"},
|
||||||
|
"minItems": 4,
|
||||||
|
"maxItems": 4}]}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def unserialize(self, data):
|
def unserialize(self, data):
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
# Copyright (C) 2010 Michiel D. Nauta
|
# Copyright (C) 2010 Michiel D. Nauta
|
||||||
# Copyright (C) 2011 Tim G L Lyons
|
# Copyright (C) 2011 Tim G L Lyons
|
||||||
# Copyright (C) 2013 Doug Blank <doug.blank@gmail.com>
|
# Copyright (C) 2013 Doug Blank <doug.blank@gmail.com>
|
||||||
|
# Copyright (C) 2017 Nick Hall
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -37,7 +38,6 @@ from .notebase import NoteBase
|
|||||||
from .datebase import DateBase
|
from .datebase import DateBase
|
||||||
from .surnamebase import SurnameBase
|
from .surnamebase import SurnameBase
|
||||||
from .nametype import NameType
|
from .nametype import NameType
|
||||||
from .handle import Handle
|
|
||||||
from .const import IDENTICAL, EQUAL, DIFFERENT
|
from .const import IDENTICAL, EQUAL, DIFFERENT
|
||||||
from .date import Date
|
from .date import Date
|
||||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||||
@ -152,23 +152,38 @@ class Name(SecondaryObject, PrivacyBase, SurnameBase, CitationBase, NoteBase,
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_schema(cls):
|
def get_schema(cls):
|
||||||
|
"""
|
||||||
|
Returns the JSON Schema for this class.
|
||||||
|
|
||||||
|
:returns: Returns a dict containing the schema.
|
||||||
|
:rtype: dict
|
||||||
|
"""
|
||||||
from .surname import Surname
|
from .surname import Surname
|
||||||
return {
|
return {
|
||||||
"private": bool,
|
"type": "object",
|
||||||
"citation_list": [Handle("Citation", "CITATION-HANDLE")],
|
"properties": {
|
||||||
"note_list": [Handle("Note", "NOTE-HANDLE")],
|
"_class": {"enum": [cls.__name__]},
|
||||||
"date": Date,
|
"private": {"type": "boolean"},
|
||||||
"first_name": str,
|
"citation_list": {"type": "array",
|
||||||
"surname_list": [Surname],
|
"items": {"type": "string",
|
||||||
"suffix": str,
|
"maxLength": 50}},
|
||||||
"title": str,
|
"note_list": {"type": "array",
|
||||||
"type": NameType,
|
"items": {"type": "string",
|
||||||
"group_as": str,
|
"maxLength": 50}},
|
||||||
"sort_as": str,
|
"date": {"oneOf": [{"type": "null"}, Date.get_schema()]},
|
||||||
"display_as": str,
|
"first_name": {"type": "string"},
|
||||||
"call": str,
|
"surname_list": {"type": "array",
|
||||||
"nick": str,
|
"items": Surname.get_schema()},
|
||||||
"famnick": str,
|
"suffix": {"type": "string"},
|
||||||
|
"title": {"type": "string"},
|
||||||
|
"type": NameType.get_schema(),
|
||||||
|
"group_as": {"type": "string"},
|
||||||
|
"sort_as": {"type": "integer"},
|
||||||
|
"display_as": {"type": "integer"},
|
||||||
|
"call": {"type": "string"},
|
||||||
|
"nick": {"type": "string"},
|
||||||
|
"famnick": {"type": "string"}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def is_empty(self):
|
def is_empty(self):
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#
|
#
|
||||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||||
# Copyright (C) 2010 Michiel D. Nauta
|
# Copyright (C) 2010 Michiel D. Nauta
|
||||||
# Copyright (C) 2010 Nick Hall
|
# Copyright (C) 2010,2017 Nick Hall
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -34,7 +34,6 @@ from .tagbase import TagBase
|
|||||||
from .notetype import NoteType
|
from .notetype import NoteType
|
||||||
from .styledtext import StyledText
|
from .styledtext import StyledText
|
||||||
from .styledtexttagtype import StyledTextTagType
|
from .styledtexttagtype import StyledTextTagType
|
||||||
from .handle import Handle
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -98,17 +97,27 @@ class Note(BasicPrimaryObject):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def get_schema(cls):
|
def get_schema(cls):
|
||||||
"""
|
"""
|
||||||
The schema for Note.
|
Returns the JSON Schema for this class.
|
||||||
|
|
||||||
|
:returns: Returns a dict containing the schema.
|
||||||
|
:rtype: dict
|
||||||
"""
|
"""
|
||||||
return {
|
return {
|
||||||
"handle": Handle("Note", "NOTE-HANDLE"),
|
"type": "object",
|
||||||
"gramps_id": str,
|
"properties": {
|
||||||
"text": StyledText,
|
"_class": {"enum": [cls.__name__]},
|
||||||
"format": int,
|
"handle": {"type": "string",
|
||||||
"type": NoteType,
|
"maxLength": 50},
|
||||||
"change": int,
|
"gramps_id": {"type": "string"},
|
||||||
"tag_list": [Handle("Tag", "TAG-HANDLE")],
|
"text": StyledText.get_schema(),
|
||||||
"private": bool,
|
"format": {"type": "integer"},
|
||||||
|
"type": NoteType.get_schema(),
|
||||||
|
"change": {"type": "integer"},
|
||||||
|
"tag_list": {"type": "array",
|
||||||
|
"items": {"type": "string",
|
||||||
|
"maxLength": 50}},
|
||||||
|
"private": {"type": "boolean"}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#
|
#
|
||||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||||
# Copyright (C) 2010 Michiel D. Nauta
|
# Copyright (C) 2010 Michiel D. Nauta
|
||||||
# Copyright (C) 2010 Nick Hall
|
# Copyright (C) 2010,2017 Nick Hall
|
||||||
# Copyright (C) 2011 Tim G L Lyons
|
# Copyright (C) 2011 Tim G L Lyons
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
@ -46,7 +46,6 @@ from .attrtype import AttributeType
|
|||||||
from .eventroletype import EventRoleType
|
from .eventroletype import EventRoleType
|
||||||
from .attribute import Attribute
|
from .attribute import Attribute
|
||||||
from .const import IDENTICAL, EQUAL, DIFFERENT
|
from .const import IDENTICAL, EQUAL, DIFFERENT
|
||||||
from .handle import Handle
|
|
||||||
from ..const import GRAMPS_LOCALE as glocale
|
from ..const import GRAMPS_LOCALE as glocale
|
||||||
_ = glocale.translation.gettext
|
_ = glocale.translation.gettext
|
||||||
|
|
||||||
@ -187,34 +186,62 @@ class Person(CitationBase, NoteBase, AttributeBase, MediaBase,
|
|||||||
@classmethod
|
@classmethod
|
||||||
def get_schema(cls):
|
def get_schema(cls):
|
||||||
"""
|
"""
|
||||||
Return the schema as a dictionary for this class.
|
Returns the JSON Schema for this class.
|
||||||
|
|
||||||
|
:returns: Returns a dict containing the schema.
|
||||||
|
:rtype: dict
|
||||||
"""
|
"""
|
||||||
from .mediaref import MediaRef
|
from .mediaref import MediaRef
|
||||||
from .address import Address
|
from .address import Address
|
||||||
from .url import Url
|
from .url import Url
|
||||||
from .ldsord import LdsOrd
|
from .ldsord import LdsOrd
|
||||||
return {
|
return {
|
||||||
"handle": Handle("Person", "PERSON-HANDLE"),
|
"type": "object",
|
||||||
"gramps_id": str,
|
"properties": {
|
||||||
"gender": int,
|
"_class": {"enum": [cls.__name__]},
|
||||||
"primary_name": Name,
|
"handle": {"type": "string",
|
||||||
"alternate_names": [Name],
|
"maxLength": 50},
|
||||||
"death_ref_index": int,
|
"gramps_id": {"type": "string"},
|
||||||
"birth_ref_index": int,
|
"gender": {"type": "integer",
|
||||||
"event_ref_list": [EventRef],
|
"minimum": 0,
|
||||||
"family_list": [Handle("Family", "FAMILY-HANDLE")],
|
"maximum": 2},
|
||||||
"parent_family_list": [Handle("Family", "FAMILY-HANDLE")],
|
"primary_name": Name.get_schema(),
|
||||||
"media_list": [MediaRef],
|
"alternate_names": {"type": "array",
|
||||||
"address_list": [Address],
|
"items": Name.get_schema()},
|
||||||
"attribute_list": [Attribute],
|
"death_ref_index": {"type": "integer"},
|
||||||
"urls": [Url],
|
"birth_ref_index": {"type": "integer"},
|
||||||
"lds_ord_list": [LdsOrd],
|
"event_ref_list": {"type": "array",
|
||||||
"citation_list": [Handle("Citation", "CITATION-HANDLE")],
|
"items": EventRef.get_schema()},
|
||||||
"note_list": [Handle("Note", "NOTE-HANDLE")],
|
"family_list": {"type": "array",
|
||||||
"change": int,
|
"items": {"type": "string",
|
||||||
"tag_list": [Handle("Tag", "TAG-HANDLE")],
|
"maxLength": 50}},
|
||||||
"private": bool,
|
"parent_family_list": {"type": "array",
|
||||||
"person_ref_list": [PersonRef]
|
"items": {"type": "string",
|
||||||
|
"maxLength": 50}},
|
||||||
|
"media_list": {"type": "array",
|
||||||
|
"items": MediaRef.get_schema()},
|
||||||
|
"address_list": {"type": "array",
|
||||||
|
"items": Address.get_schema()},
|
||||||
|
"attribute_list": {"type": "array",
|
||||||
|
"items": Attribute.get_schema()},
|
||||||
|
"urls": {"type": "array",
|
||||||
|
"items": Url.get_schema()},
|
||||||
|
"lds_ord_list": {"type": "array",
|
||||||
|
"items": LdsOrd.get_schema()},
|
||||||
|
"citation_list": {"type": "array",
|
||||||
|
"items": {"type": "string",
|
||||||
|
"maxLength": 50}},
|
||||||
|
"note_list": {"type": "array",
|
||||||
|
"items": {"type": "string",
|
||||||
|
"maxLength": 50}},
|
||||||
|
"change": {"type": "integer"},
|
||||||
|
"tag_list": {"type": "array",
|
||||||
|
"items": {"type": "string",
|
||||||
|
"maxLength": 50}},
|
||||||
|
"private": {"type": "boolean"},
|
||||||
|
"person_ref_list": {"type": "array",
|
||||||
|
"items": PersonRef.get_schema()}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def unserialize(self, data):
|
def unserialize(self, data):
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
# Copyright (C) 2010 Michiel D. Nauta
|
# Copyright (C) 2010 Michiel D. Nauta
|
||||||
# Copyright (C) 2011 Tim G L Lyons
|
# Copyright (C) 2011 Tim G L Lyons
|
||||||
# Copyright (C) 2013 Doug Blank <doug.blank@gmail.com>
|
# Copyright (C) 2013 Doug Blank <doug.blank@gmail.com>
|
||||||
|
# Copyright (C) 2017 Nick Hall
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -36,7 +37,6 @@ from .citationbase import CitationBase
|
|||||||
from .notebase import NoteBase
|
from .notebase import NoteBase
|
||||||
from .refbase import RefBase
|
from .refbase import RefBase
|
||||||
from .const import IDENTICAL, EQUAL, DIFFERENT
|
from .const import IDENTICAL, EQUAL, DIFFERENT
|
||||||
from .handle import Handle
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -83,6 +83,31 @@ class PersonRef(SecondaryObject, PrivacyBase, CitationBase, NoteBase, RefBase):
|
|||||||
RefBase.unserialize(self, ref)
|
RefBase.unserialize(self, ref)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_schema(cls):
|
||||||
|
"""
|
||||||
|
Returns the JSON Schema for this class.
|
||||||
|
|
||||||
|
:returns: Returns a dict containing the schema.
|
||||||
|
:rtype: dict
|
||||||
|
"""
|
||||||
|
return {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"_class": {"enum": [cls.__name__]},
|
||||||
|
"private": {"type": "boolean"},
|
||||||
|
"citation_list": {"type": "array",
|
||||||
|
"items": {"type": "string",
|
||||||
|
"maxLength": 50}},
|
||||||
|
"note_list": {"type": "array",
|
||||||
|
"items": {"type": "string",
|
||||||
|
"maxLength": 50}},
|
||||||
|
"ref": {"type": "string",
|
||||||
|
"maxLength": 50},
|
||||||
|
"rel": {"type": "string"}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
def get_text_data_list(self):
|
def get_text_data_list(self):
|
||||||
"""
|
"""
|
||||||
Return the list of all textual attributes of the object.
|
Return the list of all textual attributes of the object.
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
# Copyright (C) 2010 Michiel D. Nauta
|
# Copyright (C) 2010 Michiel D. Nauta
|
||||||
# Copyright (C) 2011 Tim G L Lyons
|
# Copyright (C) 2011 Tim G L Lyons
|
||||||
# Copyright (C) 2013 Doug Blank <doug.blank@gmail.com>
|
# Copyright (C) 2013 Doug Blank <doug.blank@gmail.com>
|
||||||
|
# Copyright (C) 2017 Nick Hall
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -40,7 +41,6 @@ from .mediabase import MediaBase
|
|||||||
from .urlbase import UrlBase
|
from .urlbase import UrlBase
|
||||||
from .tagbase import TagBase
|
from .tagbase import TagBase
|
||||||
from .location import Location
|
from .location import Location
|
||||||
from .handle import Handle
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -142,28 +142,48 @@ class Place(CitationBase, NoteBase, MediaBase, UrlBase, PrimaryObject):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def get_schema(cls):
|
def get_schema(cls):
|
||||||
"""
|
"""
|
||||||
Return the schema as a dictionary for this class.
|
Returns the JSON Schema for this class.
|
||||||
|
|
||||||
|
:returns: Returns a dict containing the schema.
|
||||||
|
:rtype: dict
|
||||||
"""
|
"""
|
||||||
from .url import Url
|
from .url import Url
|
||||||
|
from .mediaref import MediaRef
|
||||||
return {
|
return {
|
||||||
"handle": Handle("Place", "PLACE-HANDLE"),
|
"type": "object",
|
||||||
"gramps_id": str,
|
"properties": {
|
||||||
"title": str,
|
"_class": {"enum": [cls.__name__]},
|
||||||
"long": str,
|
"handle": {"type": "string",
|
||||||
"lat": str,
|
"maxLength": 50},
|
||||||
"placeref_list": [PlaceRef],
|
"gramps_id": {"type": "string"},
|
||||||
"name": PlaceName,
|
"title": {"type": "string"},
|
||||||
"alt_names": [PlaceName],
|
"long": {"type": "string"},
|
||||||
"place_type": PlaceType,
|
"lat": {"type": "string"},
|
||||||
"code": str,
|
"placeref_list": {"type": "array",
|
||||||
"alt_loc": [Location],
|
"items": PlaceRef.get_schema()},
|
||||||
"urls": [Url],
|
"name": PlaceName.get_schema(),
|
||||||
"media_list": [Handle("Media", "MEDIA-HANDLE")],
|
"alt_names": {"type": "array",
|
||||||
"citation_list": [Handle("Citation", "CITATION-HANDLE")],
|
"items": PlaceName.get_schema()},
|
||||||
"note_list": [Handle("Note", "NOTE-HANDLE")],
|
"place_type": PlaceType.get_schema(),
|
||||||
"change": int,
|
"code": {"type": "string"},
|
||||||
"tag_list": [Handle("Tag", "TAG-HANDLE")],
|
"alt_loc": {"type": "array",
|
||||||
"private": bool
|
"items": Location.get_schema()},
|
||||||
|
"urls": {"type": "array",
|
||||||
|
"items": Url.get_schema()},
|
||||||
|
"media_list": {"type": "array",
|
||||||
|
"items": MediaRef.get_schema()},
|
||||||
|
"citation_list": {"type": "array",
|
||||||
|
"items": {"type": "string",
|
||||||
|
"maxLength": 50}},
|
||||||
|
"note_list": {"type": "array",
|
||||||
|
"items": {"type": "string",
|
||||||
|
"maxLength": 50}},
|
||||||
|
"change": {"type": "integer"},
|
||||||
|
"tag_list": {"type": "array",
|
||||||
|
"items": {"type": "string",
|
||||||
|
"maxLength": 50}},
|
||||||
|
"private": {"type": "boolean"}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def unserialize(self, data):
|
def unserialize(self, data):
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# Gramps - a GTK+/GNOME based genealogy program
|
# Gramps - a GTK+/GNOME based genealogy program
|
||||||
#
|
#
|
||||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||||
# Copyright (C) 2015 Nick Hall
|
# Copyright (C) 2015,2017 Nick Hall
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -79,6 +79,25 @@ class PlaceName(SecondaryObject, DateBase):
|
|||||||
DateBase.unserialize(self, date)
|
DateBase.unserialize(self, date)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_schema(cls):
|
||||||
|
"""
|
||||||
|
Returns the JSON Schema for this class.
|
||||||
|
|
||||||
|
:returns: Returns a dict containing the schema.
|
||||||
|
:rtype: dict
|
||||||
|
"""
|
||||||
|
from .date import Date
|
||||||
|
return {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"_class": {"enum": [cls.__name__]},
|
||||||
|
"value": {"type": "string"},
|
||||||
|
"date": {"oneOf": [{"type": "null"}, Date.get_schema()]},
|
||||||
|
"lang": {"type": "string"}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
def get_text_data_list(self):
|
def get_text_data_list(self):
|
||||||
"""
|
"""
|
||||||
Return the list of all textual attributes of the object.
|
Return the list of all textual attributes of the object.
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# Gramps - a GTK+/GNOME based genealogy program
|
# Gramps - a GTK+/GNOME based genealogy program
|
||||||
#
|
#
|
||||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||||
# Copyright (C) 2013 Nick Hall
|
# Copyright (C) 2013,2017 Nick Hall
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -32,7 +32,6 @@ from .secondaryobj import SecondaryObject
|
|||||||
from .refbase import RefBase
|
from .refbase import RefBase
|
||||||
from .datebase import DateBase
|
from .datebase import DateBase
|
||||||
from .const import IDENTICAL, EQUAL, DIFFERENT
|
from .const import IDENTICAL, EQUAL, DIFFERENT
|
||||||
from .handle import Handle
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -72,6 +71,25 @@ class PlaceRef(RefBase, DateBase, SecondaryObject):
|
|||||||
DateBase.unserialize(self, date)
|
DateBase.unserialize(self, date)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_schema(cls):
|
||||||
|
"""
|
||||||
|
Returns the JSON Schema for this class.
|
||||||
|
|
||||||
|
:returns: Returns a dict containing the schema.
|
||||||
|
:rtype: dict
|
||||||
|
"""
|
||||||
|
from .date import Date
|
||||||
|
return {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"_class": {"enum": [cls.__name__]},
|
||||||
|
"ref": {"type": "string",
|
||||||
|
"maxLength": 50},
|
||||||
|
"date": {"oneOf": [{"type": "null"}, Date.get_schema()]}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
def get_text_data_list(self):
|
def get_text_data_list(self):
|
||||||
"""
|
"""
|
||||||
Return the list of all textual attributes of the object.
|
Return the list of all textual attributes of the object.
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||||
# Copyright (C) 2010 Michiel D. Nauta
|
# Copyright (C) 2010 Michiel D. Nauta
|
||||||
# Copyright (C) 2011 Tim G L Lyons
|
# Copyright (C) 2011 Tim G L Lyons
|
||||||
|
# Copyright (C) 2017 Nick Hall
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -35,7 +36,6 @@ from .addressbase import AddressBase
|
|||||||
from .urlbase import UrlBase
|
from .urlbase import UrlBase
|
||||||
from .tagbase import TagBase
|
from .tagbase import TagBase
|
||||||
from .repotype import RepositoryType
|
from .repotype import RepositoryType
|
||||||
from .handle import Handle
|
|
||||||
from .citationbase import IndirectCitationBase
|
from .citationbase import IndirectCitationBase
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
@ -87,21 +87,35 @@ class Repository(NoteBase, AddressBase, UrlBase, IndirectCitationBase,
|
|||||||
@classmethod
|
@classmethod
|
||||||
def get_schema(cls):
|
def get_schema(cls):
|
||||||
"""
|
"""
|
||||||
Return the schema as a dictionary for this class.
|
Returns the JSON Schema for this class.
|
||||||
|
|
||||||
|
:returns: Returns a dict containing the schema.
|
||||||
|
:rtype: dict
|
||||||
"""
|
"""
|
||||||
from .address import Address
|
from .address import Address
|
||||||
from .url import Url
|
from .url import Url
|
||||||
return {
|
return {
|
||||||
"handle": Handle("Repository", "REPOSITORY-HANDLE"),
|
"type": "object",
|
||||||
"gramps_id": str,
|
"properties": {
|
||||||
"type": RepositoryType,
|
"_class": {"enum": [cls.__name__]},
|
||||||
"name": str,
|
"handle": {"type": "string",
|
||||||
"note_list": [Handle("Note", "NOTE-HANDLE")],
|
"maxLength": 50},
|
||||||
"address_list": [Address],
|
"gramps_id": {"type": "string"},
|
||||||
"urls": [Url],
|
"type": RepositoryType.get_schema(),
|
||||||
"change": int,
|
"name": {"type": "string"},
|
||||||
"tag_list": [Handle("Tag", "TAG-HANDLE")],
|
"note_list": {"type": "array",
|
||||||
"private": bool
|
"items": {"type": "string",
|
||||||
|
"maxLength": 50}},
|
||||||
|
"address_list": {"type": "array",
|
||||||
|
"items": Address.get_schema()},
|
||||||
|
"urls": {"type": "array",
|
||||||
|
"items": Url.get_schema()},
|
||||||
|
"change": {"type": "integer"},
|
||||||
|
"tag_list": {"type": "array",
|
||||||
|
"items": {"type": "string",
|
||||||
|
"maxLength": 50}},
|
||||||
|
"private": {"type": "boolean"}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def unserialize(self, data):
|
def unserialize(self, data):
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||||
# Copyright (C) 2010 Michiel D. Nauta
|
# Copyright (C) 2010 Michiel D. Nauta
|
||||||
# Copyright (C) 2013 Doug Blank <doug.blank@gmail.com>
|
# Copyright (C) 2013 Doug Blank <doug.blank@gmail.com>
|
||||||
|
# Copyright (C) 2017 Nick Hall
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -35,7 +36,6 @@ from .notebase import NoteBase
|
|||||||
from .refbase import RefBase
|
from .refbase import RefBase
|
||||||
from .srcmediatype import SourceMediaType
|
from .srcmediatype import SourceMediaType
|
||||||
from .const import IDENTICAL, EQUAL, DIFFERENT
|
from .const import IDENTICAL, EQUAL, DIFFERENT
|
||||||
from .handle import Handle
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -81,6 +81,29 @@ class RepoRef(SecondaryObject, PrivacyBase, NoteBase, RefBase):
|
|||||||
RefBase.unserialize(self, ref)
|
RefBase.unserialize(self, ref)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_schema(cls):
|
||||||
|
"""
|
||||||
|
Returns the JSON Schema for this class.
|
||||||
|
|
||||||
|
:returns: Returns a dict containing the schema.
|
||||||
|
:rtype: dict
|
||||||
|
"""
|
||||||
|
return {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"_class": {"enum": [cls.__name__]},
|
||||||
|
"note_list": {"type": "array",
|
||||||
|
"items": {"type": "string",
|
||||||
|
"maxLength": 50}},
|
||||||
|
"ref": {"type": "string",
|
||||||
|
"maxLength": 50},
|
||||||
|
"call_number": {"type": "string"},
|
||||||
|
"media_type": SourceMediaType.get_schema(),
|
||||||
|
"private": {"type": "boolean"}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
def get_text_data_list(self):
|
def get_text_data_list(self):
|
||||||
"""
|
"""
|
||||||
Return the list of all textual attributes of the object.
|
Return the list of all textual attributes of the object.
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
# Copyright (C) 2010 Michiel D. Nauta
|
# Copyright (C) 2010 Michiel D. Nauta
|
||||||
# Copyright (C) 2011 Tim G L Lyons
|
# Copyright (C) 2011 Tim G L Lyons
|
||||||
# Copyright (C) 2013 Doug Blank <doug.blank@gmail.com>
|
# Copyright (C) 2013 Doug Blank <doug.blank@gmail.com>
|
||||||
|
# Copyright (C) 2017 Nick Hall
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -37,7 +38,6 @@ from .tagbase import TagBase
|
|||||||
from .attrbase import SrcAttributeBase
|
from .attrbase import SrcAttributeBase
|
||||||
from .reporef import RepoRef
|
from .reporef import RepoRef
|
||||||
from .const import DIFFERENT, EQUAL, IDENTICAL
|
from .const import DIFFERENT, EQUAL, IDENTICAL
|
||||||
from .handle import Handle
|
|
||||||
from .citationbase import IndirectCitationBase
|
from .citationbase import IndirectCitationBase
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
@ -100,25 +100,40 @@ class Source(MediaBase, NoteBase, SrcAttributeBase, IndirectCitationBase,
|
|||||||
@classmethod
|
@classmethod
|
||||||
def get_schema(cls):
|
def get_schema(cls):
|
||||||
"""
|
"""
|
||||||
Return the schema as a dictionary for this class.
|
Returns the JSON Schema for this class.
|
||||||
|
|
||||||
|
:returns: Returns a dict containing the schema.
|
||||||
|
:rtype: dict
|
||||||
"""
|
"""
|
||||||
from .srcattribute import SrcAttribute
|
from .srcattribute import SrcAttribute
|
||||||
from .reporef import RepoRef
|
from .reporef import RepoRef
|
||||||
from .url import Url
|
from .mediaref import MediaRef
|
||||||
return {
|
return {
|
||||||
"handle": Handle("Source", "SOURCE-HANDLE"),
|
"type": "object",
|
||||||
"gramps_id": str,
|
"properties": {
|
||||||
"title": str,
|
"_class": {"enum": [cls.__name__]},
|
||||||
"author": str,
|
"handle": {"type": "string",
|
||||||
"pubinfo": str,
|
"maxLength": 50},
|
||||||
"note_list": [Handle("Note", "NOTE-HANDLE")],
|
"gramps_id": {"type": "string"},
|
||||||
"media_list": [Handle("Media", "MEDIA-HANDLE")],
|
"title": {"type": "string"},
|
||||||
"abbrev": str,
|
"author": {"type": "string"},
|
||||||
"change": int,
|
"pubinfo": {"type": "string"},
|
||||||
"srcattr_list": [SrcAttribute],
|
"note_list": {"type": "array",
|
||||||
"reporef_list": [RepoRef],
|
"items": {"type": "string",
|
||||||
"tag_list": [Handle("Tag", "")],
|
"maxLength": 50}},
|
||||||
"private": bool
|
"media_list": {"type": "array",
|
||||||
|
"items": MediaRef.get_schema()},
|
||||||
|
"abbrev": {"type": "string"},
|
||||||
|
"change": {"type": "integer"},
|
||||||
|
"srcattr_list": {"type": "array",
|
||||||
|
"items": SrcAttribute.get_schema()},
|
||||||
|
"reporef_list": {"type": "array",
|
||||||
|
"items": RepoRef.get_schema()},
|
||||||
|
"tag_list": {"type": "array",
|
||||||
|
"items": {"type": "string",
|
||||||
|
"maxLength": 50}},
|
||||||
|
"private": {"type": "boolean"}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def unserialize(self, data):
|
def unserialize(self, data):
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
# Gramps - a GTK+/GNOME based genealogy program
|
# Gramps - a GTK+/GNOME based genealogy program
|
||||||
#
|
#
|
||||||
# Copyright (C) 2013 Benny Malengier
|
# Copyright (C) 2013 Benny Malengier
|
||||||
|
# Copyright (C) 2017 Nick Hall
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -53,3 +54,21 @@ class SrcAttribute(AttributeRoot):
|
|||||||
else:
|
else:
|
||||||
self.type = SrcAttributeType()
|
self.type = SrcAttributeType()
|
||||||
self.value = ""
|
self.value = ""
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_schema(cls):
|
||||||
|
"""
|
||||||
|
Returns the JSON Schema for this class.
|
||||||
|
|
||||||
|
:returns: Returns a dict containing the schema.
|
||||||
|
:rtype: dict
|
||||||
|
"""
|
||||||
|
return {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"_class": {"enum": [cls.__name__]},
|
||||||
|
"private": {"type": "boolean"},
|
||||||
|
"type": SrcAttributeType.get_schema(),
|
||||||
|
"value": {"type": "string"}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#
|
#
|
||||||
# Copyright (C) 2008 Zsolt Foldvari
|
# Copyright (C) 2008 Zsolt Foldvari
|
||||||
# Copyright (C) 2013 Doug Blank <doug.blank@gmail.com>
|
# Copyright (C) 2013 Doug Blank <doug.blank@gmail.com>
|
||||||
|
# Copyright (C) 2017 Nick Hall
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -291,11 +292,19 @@ class StyledText:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def get_schema(cls):
|
def get_schema(cls):
|
||||||
"""
|
"""
|
||||||
The schema for StyledText.
|
Returns the JSON Schema for this class.
|
||||||
|
|
||||||
|
:returns: Returns a dict containing the schema.
|
||||||
|
:rtype: dict
|
||||||
"""
|
"""
|
||||||
return {
|
return {
|
||||||
"string": str,
|
"type": "object",
|
||||||
"tags": [StyledTextTag],
|
"properties": {
|
||||||
|
"_class": {"enum": [cls.__name__]},
|
||||||
|
"string": {"type": "string"},
|
||||||
|
"tags": {"type": "array",
|
||||||
|
"items": StyledTextTag.get_schema()}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#
|
#
|
||||||
# Copyright (C) 2008 Zsolt Foldvari
|
# Copyright (C) 2008 Zsolt Foldvari
|
||||||
# Copyright (C) 2013 Doug Blank <doug.blank@gmail.com>
|
# Copyright (C) 2013 Doug Blank <doug.blank@gmail.com>
|
||||||
|
# Copyright (C) 2017 Nick Hall
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -84,3 +85,25 @@ class StyledTextTag:
|
|||||||
self.name = StyledTextTagType()
|
self.name = StyledTextTagType()
|
||||||
self.name.unserialize(the_name)
|
self.name.unserialize(the_name)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_schema(cls):
|
||||||
|
"""
|
||||||
|
Returns the JSON Schema for this class.
|
||||||
|
|
||||||
|
:returns: Returns a dict containing the schema.
|
||||||
|
:rtype: dict
|
||||||
|
"""
|
||||||
|
return {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"_class": {"enum": [cls.__name__]},
|
||||||
|
"name": StyledTextTagType.get_schema(),
|
||||||
|
"value": {"type": ["null", "string", "integer"]},
|
||||||
|
"ranges": {"type": "array",
|
||||||
|
"items": {"type": "array",
|
||||||
|
"items": {"type": "integer"},
|
||||||
|
"minItems": 2,
|
||||||
|
"maxItems": 2}}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#
|
#
|
||||||
# Copyright (C) 2010 Benny Malengier
|
# Copyright (C) 2010 Benny Malengier
|
||||||
# Copyright (C) 2013 Doug Blank <doug.blank@gmail.com>
|
# Copyright (C) 2013 Doug Blank <doug.blank@gmail.com>
|
||||||
|
# Copyright (C) 2017 Nick Hall
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -73,12 +74,22 @@ class Surname(SecondaryObject):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_schema(cls):
|
def get_schema(cls):
|
||||||
|
"""
|
||||||
|
Returns the JSON Schema for this class.
|
||||||
|
|
||||||
|
:returns: Returns a dict containing the schema.
|
||||||
|
:rtype: dict
|
||||||
|
"""
|
||||||
return {
|
return {
|
||||||
"surname": str,
|
"type": "object",
|
||||||
"prefix": str,
|
"properties": {
|
||||||
"primary": str,
|
"_class": {"enum": [cls.__name__]},
|
||||||
"origintype": NameOriginType,
|
"surname": {"type": "string"},
|
||||||
"connector": str
|
"prefix": {"type": "string"},
|
||||||
|
"primary": {"type": "boolean"},
|
||||||
|
"origintype": NameOriginType.get_schema(),
|
||||||
|
"connector": {"type": "string"}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# Gramps - a GTK+/GNOME based genealogy program
|
# Gramps - a GTK+/GNOME based genealogy program
|
||||||
#
|
#
|
||||||
# Copyright (C) 2010 Nick Hall
|
# Copyright (C) 2010,2017 Nick Hall
|
||||||
# Copyright (C) 2013 Doug Blank <doug.blank@gmail.com>
|
# Copyright (C) 2013 Doug Blank <doug.blank@gmail.com>
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
@ -195,14 +195,21 @@ class TableObject(BaseObject):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def get_secondary_fields(cls):
|
def get_secondary_fields(cls):
|
||||||
"""
|
"""
|
||||||
Return all seconday fields and their types
|
Return all secondary fields and their types
|
||||||
"""
|
"""
|
||||||
from .handle import HandleClass
|
result = []
|
||||||
return ([(key.lower(), value)
|
for (key, value) in cls.get_schema()["properties"].items():
|
||||||
for (key, value) in cls.get_schema().items()
|
schema_type = value.get("type")
|
||||||
if value in [str, int, float, bool] or
|
if isinstance(schema_type, list):
|
||||||
isinstance(value, HandleClass)] +
|
schema_type.remove("null")
|
||||||
cls.get_extra_secondary_fields())
|
schema_type = schema_type[0]
|
||||||
|
elif isinstance(schema_type, dict):
|
||||||
|
schema_type = None
|
||||||
|
if schema_type in ("string", "integer", "number", "boolean"):
|
||||||
|
result.append((key.lower(),
|
||||||
|
schema_type,
|
||||||
|
value.get("maxLength")))
|
||||||
|
return result
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_label(cls, field, _):
|
def get_label(cls, field, _):
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# Gramps - a GTK+/GNOME based genealogy program
|
# Gramps - a GTK+/GNOME based genealogy program
|
||||||
#
|
#
|
||||||
# Copyright (C) 2010 Nick Hall
|
# Copyright (C) 2010,2017 Nick Hall
|
||||||
# Copyright (C) 2013 Doug Blank <doug.blank@gmail.com>
|
# Copyright (C) 2013 Doug Blank <doug.blank@gmail.com>
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
@ -29,7 +29,6 @@ Tag object for Gramps.
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
from .tableobj import TableObject
|
from .tableobj import TableObject
|
||||||
from .handle import Handle
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -104,14 +103,24 @@ class Tag(TableObject):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def get_schema(cls):
|
def get_schema(cls):
|
||||||
"""
|
"""
|
||||||
Return the schema for Tag
|
Returns the JSON Schema for this class.
|
||||||
|
|
||||||
|
:returns: Returns a dict containing the schema.
|
||||||
|
:rtype: dict
|
||||||
"""
|
"""
|
||||||
return {
|
return {
|
||||||
"handle": Handle("Tag", "TAG-HANDLE"),
|
"type": "object",
|
||||||
"name": str,
|
"properties": {
|
||||||
"color": str,
|
"_class": {"enum": [cls.__name__]},
|
||||||
"priority": int,
|
"handle": {"type": "string",
|
||||||
"change": int,
|
"maxLength": 50},
|
||||||
|
"name": {"type": "string"},
|
||||||
|
"color": {"type": "string",
|
||||||
|
"maxLength": 13},
|
||||||
|
"priority": {"type": "integer",
|
||||||
|
"minimum": 0},
|
||||||
|
"change": {"type": "integer"}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#
|
#
|
||||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||||
# Copyright (C) 2009-2013 Doug Blank <doug.blank@gmail.com>
|
# Copyright (C) 2009-2013 Doug Blank <doug.blank@gmail.com>
|
||||||
|
# Copyright (C) 2017 Nick Hall
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -72,6 +73,25 @@ class Url(SecondaryObject, PrivacyBase):
|
|||||||
self.type.unserialize(type_value)
|
self.type.unserialize(type_value)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_schema(cls):
|
||||||
|
"""
|
||||||
|
Returns the JSON Schema for this class.
|
||||||
|
|
||||||
|
:returns: Returns a dict containing the schema.
|
||||||
|
:rtype: dict
|
||||||
|
"""
|
||||||
|
return {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"_class": {"enum": [cls.__name__]},
|
||||||
|
"private": {"type": "boolean"},
|
||||||
|
"path": {"type": "string"},
|
||||||
|
"desc": {"type": "string"},
|
||||||
|
"type": UrlType.get_schema()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
def get_text_data_list(self):
|
def get_text_data_list(self):
|
||||||
"""
|
"""
|
||||||
Return the list of all textual attributes of the object.
|
Return the list of all textual attributes of the object.
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# Gramps - a GTK+/GNOME based genealogy program
|
# Gramps - a GTK+/GNOME based genealogy program
|
||||||
#
|
#
|
||||||
# Copyright (C) 2015-2016 Douglas S. Blank <doug.blank@gmail.com>
|
# Copyright (C) 2015-2016 Douglas S. Blank <doug.blank@gmail.com>
|
||||||
# Copyright (C) 2016 Nick Hall
|
# Copyright (C) 2016-2017 Nick Hall
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -891,19 +891,19 @@ class DBAPI(DbGeneric):
|
|||||||
surname_list.append(row[0])
|
surname_list.append(row[0])
|
||||||
return surname_list
|
return surname_list
|
||||||
|
|
||||||
def _sql_type(self, python_type):
|
def _sql_type(self, schema_type, max_length):
|
||||||
"""
|
"""
|
||||||
Given a schema type, return the SQL type for
|
Given a schema type, return the SQL type for
|
||||||
a new column.
|
a new column.
|
||||||
"""
|
"""
|
||||||
from gramps.gen.lib.handle import HandleClass
|
if schema_type == 'string':
|
||||||
if isinstance(python_type, HandleClass):
|
if max_length:
|
||||||
return "VARCHAR(50)"
|
return "VARCHAR(%s)" % max_length
|
||||||
elif python_type == str:
|
else:
|
||||||
return "TEXT"
|
return "TEXT"
|
||||||
elif python_type in [bool, int]:
|
elif schema_type in ['boolean', 'integer']:
|
||||||
return "INTEGER"
|
return "INTEGER"
|
||||||
elif python_type in [float]:
|
elif schema_type == 'number':
|
||||||
return "REAL"
|
return "REAL"
|
||||||
else:
|
else:
|
||||||
return "BLOB"
|
return "BLOB"
|
||||||
@ -918,11 +918,10 @@ class DBAPI(DbGeneric):
|
|||||||
"get_secondary_fields"):
|
"get_secondary_fields"):
|
||||||
continue
|
continue
|
||||||
table_name = table.lower()
|
table_name = table.lower()
|
||||||
for field_pair in self.get_table_func(
|
for field, schema_type, max_length in self.get_table_func(
|
||||||
table, "class_func").get_secondary_fields():
|
table, "class_func").get_secondary_fields():
|
||||||
field, python_type = field_pair
|
|
||||||
field = self._hash_name(table, field)
|
field = self._hash_name(table, field)
|
||||||
sql_type = self._sql_type(python_type)
|
sql_type = self._sql_type(schema_type, max_length)
|
||||||
try:
|
try:
|
||||||
# test to see if it exists:
|
# test to see if it exists:
|
||||||
self.dbapi.execute("SELECT %s FROM %s LIMIT 1"
|
self.dbapi.execute("SELECT %s FROM %s LIMIT 1"
|
||||||
@ -944,7 +943,7 @@ class DBAPI(DbGeneric):
|
|||||||
"""
|
"""
|
||||||
table = obj.__class__.__name__
|
table = obj.__class__.__name__
|
||||||
fields = self.get_table_func(table, "class_func").get_secondary_fields()
|
fields = self.get_table_func(table, "class_func").get_secondary_fields()
|
||||||
fields = [field for (field, direction) in fields]
|
fields = [field for (field, schema_type, max_length) in fields]
|
||||||
sets = []
|
sets = []
|
||||||
values = []
|
values = []
|
||||||
for field in fields:
|
for field in fields:
|
||||||
|
Loading…
Reference in New Issue
Block a user