Exemple #1
0
 def __init__(self, row, domain: bool = None, range_: bool = None) -> None:
     from openatlas.models.entity import EntityMapper
     self.id = row.id
     self.description = row.description
     self.property = g.properties[row.property_code]
     self.domain = domain if domain else EntityMapper.get_by_id(
         row.domain_id)
     self.range = range_ if range_ else EntityMapper.get_by_id(row.range_id)
     self.type = g.nodes[row.type_id] if row.type_id else None
     self.nodes = dict()  # type: Dict
     if hasattr(row, 'type_id') and row.type_id:
         self.nodes[g.nodes[row.type_id]] = None
     if hasattr(row, 'begin_from'):
         self.begin_from = DateMapper.timestamp_to_datetime64(
             row.begin_from)
         self.begin_to = DateMapper.timestamp_to_datetime64(row.begin_to)
         self.begin_comment = row.begin_comment
         self.end_from = DateMapper.timestamp_to_datetime64(row.end_from)
         self.end_to = DateMapper.timestamp_to_datetime64(row.end_to)
         self.end_comment = row.end_comment
         self.first = DateForm.format_date(
             self.begin_from, 'year') if self.begin_from else None
         self.last = DateForm.format_date(self.end_from,
                                          'year') if self.end_from else None
         self.last = DateForm.format_date(
             self.end_to, 'year') if self.end_to else self.last
    def __init__(self, row: NamedTupleCursor.Record) -> None:
        from openatlas.forms.date import DateForm

        self.id = row.id
        self.nodes: Dict['Node', str] = {}
        if hasattr(row, 'nodes') and row.nodes:
            for node in row.nodes:
                self.nodes[g.nodes[node['f1']]] = node[
                    'f2']  # f1 = node id, f2 = value
        self.aliases: Dict[int, str] = {}
        if hasattr(row, 'aliases') and row.aliases:
            for alias in row.aliases:
                self.aliases[alias['f1']] = alias[
                    'f2']  # f1 = alias id, f2 = alias name
            self.aliases = OrderedDict(
                sorted(self.aliases.items(), key=lambda kv: (kv[1], kv[0])))
        self.name = row.name
        self.description = row.description if row.description else ''
        self.system_type = row.system_type
        self.created = row.created
        self.modified = row.modified
        self.begin_from = None
        self.begin_to = None
        self.begin_comment = None
        self.end_from = None
        self.end_to = None
        self.end_comment = None
        self.note: Optional[
            str] = None  # User specific, private note for an entity
        self.origin_id: Optional[int] = None
        if hasattr(row, 'begin_from'):
            self.begin_from = DateMapper.timestamp_to_datetime64(
                row.begin_from)
            self.begin_to = DateMapper.timestamp_to_datetime64(row.begin_to)
            self.begin_comment = row.begin_comment
            self.end_from = DateMapper.timestamp_to_datetime64(row.end_from)
            self.end_to = DateMapper.timestamp_to_datetime64(row.end_to)
            self.end_comment = row.end_comment
            self.first = DateForm.format_date(
                self.begin_from, 'year') if self.begin_from else None
            self.last = DateForm.format_date(self.end_from,
                                             'year') if self.end_from else None
            self.last = DateForm.format_date(
                self.end_to, 'year') if self.end_to else self.last
        self.class_ = g.classes[row.class_code]
        self.view_name = ''  # Used to build URLs
        self.external_references: List[Link] = []
        if self.system_type == 'file':
            self.view_name = 'file'
        elif self.class_.code == 'E33' and self.system_type == 'source translation':
            self.view_name = 'translation'
        elif self.class_.code in app.config['CODE_CLASS']:
            self.view_name = app.config['CODE_CLASS'][self.class_.code]
        self.table_name = self.view_name  # Used to build tables
        if self.view_name == 'place':
            self.table_name = self.system_type.replace(' ', '-')
Exemple #3
0
 def __init__(self, row) -> None:
     if not row:
         logger.log('error', 'model', 'invalid id')
         abort(418)
     self.id = row.id
     self.nodes = {}  # type: Dict
     if hasattr(row, 'nodes') and row.nodes:
         for node in row.nodes:
             self.nodes[g.nodes[node['f1']]] = node[
                 'f2']  # f1 = node id, f2 = value
     self.aliases = {}  # type: Dict
     if hasattr(row, 'aliases') and row.aliases:
         for alias in row.aliases:
             self.aliases[alias['f1']] = alias[
                 'f2']  # f1 = alias id, f2 = alias name
         self.aliases = OrderedDict(
             sorted(self.aliases.items(), key=lambda kv: (kv[1], kv[0])))
     self.name = row.name
     self.root = None  # type: Optional[list]
     self.description = row.description if row.description else ''
     self.system_type = row.system_type
     self.created = row.created
     self.modified = row.modified
     self.begin_from = None
     self.begin_to = None
     self.begin_comment = None
     self.end_from = None
     self.end_to = None
     self.end_comment = None
     self.note = None  # type: Optional[str]  # private, user specific note for an entity
     self.origin_id = None  # type: Optional[int]
     if hasattr(row, 'begin_from'):
         self.begin_from = DateMapper.timestamp_to_datetime64(
             row.begin_from)
         self.begin_to = DateMapper.timestamp_to_datetime64(row.begin_to)
         self.begin_comment = row.begin_comment
         self.end_from = DateMapper.timestamp_to_datetime64(row.end_from)
         self.end_to = DateMapper.timestamp_to_datetime64(row.end_to)
         self.end_comment = row.end_comment
         self.first = DateForm.format_date(
             self.begin_from, 'year') if self.begin_from else None
         self.last = DateForm.format_date(self.end_from,
                                          'year') if self.end_from else None
         self.last = DateForm.format_date(
             self.end_to, 'year') if self.end_to else self.last
     self.class_ = g.classes[row.class_code]
     self.view_name = None  # view_name is used to build urls
     self.external_references = []  # type: list
     if self.system_type == 'file':
         self.view_name = 'file'
     elif self.class_.code in app.config['CODE_CLASS']:
         self.view_name = app.config['CODE_CLASS'][self.class_.code]
     self.table_name = self.view_name  # table_name is used to build tables
     if self.view_name == 'place':
         self.table_name = self.system_type.replace(' ', '-')
Exemple #4
0
 def __init__(self, row) -> None:
     if not row:
         logger.log('error', 'model', 'invalid id')
         abort(418)
     self.id = row.id
     self.nodes = {}  # type: Dict
     if hasattr(row, 'nodes') and row.nodes:
         for node in row.nodes:
             self.nodes[g.nodes[node['f1']]] = node['f2']  # f1 = node id, f2 = value
     self.aliases = {}  # type: Dict
     if hasattr(row, 'aliases') and row.aliases:
         for alias in row.aliases:
             self.aliases[alias['f1']] = alias['f2']  # f1 = alias id, f2 = alias name
         self.aliases = OrderedDict(sorted(self.aliases.items(), key=lambda kv: (kv[1], kv[0])))
     self.name = row.name
     self.root = None  # type: Optional[list]
     self.description = row.description if row.description else ''
     self.system_type = row.system_type
     self.created = row.created
     self.modified = row.modified
     self.begin_from = None
     self.begin_to = None
     self.begin_comment = None
     self.end_from = None
     self.end_to = None
     self.end_comment = None
     self.origin_id = None  # type: Optional[int]
     if hasattr(row, 'begin_from'):
         self.begin_from = DateMapper.timestamp_to_datetime64(row.begin_from)
         self.begin_to = DateMapper.timestamp_to_datetime64(row.begin_to)
         self.begin_comment = row.begin_comment
         self.end_from = DateMapper.timestamp_to_datetime64(row.end_from)
         self.end_to = DateMapper.timestamp_to_datetime64(row.end_to)
         self.end_comment = row.end_comment
         self.first = DateForm.format_date(self.begin_from, 'year') if self.begin_from else None
         self.last = DateForm.format_date(self.end_from, 'year') if self.end_from else None
         self.last = DateForm.format_date(self.end_to, 'year') if self.end_to else self.last
     self.class_ = g.classes[row.class_code]
     self.view_name = None  # view_name is used to build urls
     self.external_references = []  # type: list
     if self.system_type == 'file':
         self.view_name = 'file'
     elif self.class_.code in app.config['CODE_CLASS']:
         self.view_name = app.config['CODE_CLASS'][self.class_.code]
     self.table_name = self.view_name  # table_name is used to build tables
     if self.view_name == 'place':
         self.table_name = self.system_type.replace(' ', '-')
Exemple #5
0
 def __init__(self, row):
     if not row:
         logger.log('error', 'model', 'invalid id')
         abort(418)
     self.id = row.id
     self.nodes = dict()
     if hasattr(row, 'nodes') and row.nodes:
         for node in row.nodes:
             self.nodes[g.nodes[node['f1']]] = node['f2']  # f1 = node id, f2 = value
     self.name = row.name
     self.root = None
     self.description = row.description if row.description else ''
     self.system_type = row.system_type
     self.created = row.created
     self.modified = row.modified
     self.begin_from = None
     self.begin_to = None
     self.begin_comment = None
     self.end_from = None
     self.end_to = None
     self.end_comment = None
     if hasattr(row, 'begin_from'):
         self.begin_from = DateMapper.timestamp_to_datetime64(row.begin_from)
         self.begin_to = DateMapper.timestamp_to_datetime64(row.begin_to)
         self.begin_comment = row.begin_comment
         self.end_from = DateMapper.timestamp_to_datetime64(row.end_from)
         self.end_to = DateMapper.timestamp_to_datetime64(row.end_to)
         self.end_comment = row.end_comment
         self.first = DateForm.format_date(self.begin_from, 'year') if self.begin_from else None
         self.last = DateForm.format_date(self.end_from, 'year') if self.end_from else None
         self.last = DateForm.format_date(self.end_to, 'year') if self.end_to else self.last
     self.class_ = g.classes[row.class_code]
     self.view_name = None  # view_name is used to build urls
     self.external_references = []  # Used in view info tab for display
     if self.system_type == 'file':
         self.view_name = 'file'
     elif self.class_.code in app.config['CODE_CLASS']:
         self.view_name = app.config['CODE_CLASS'][self.class_.code]
     self.table_name = self.view_name  # table_name is used to build tables
     if self.view_name == 'place':
         self.table_name = self.system_type.replace(' ', '-')
Exemple #6
0
 def __init__(self, row, domain=None, range_=None):
     from openatlas.models.entity import EntityMapper
     self.id = row.id
     self.description = row.description
     self.property = g.properties[row.property_code]
     self.domain = domain if domain else EntityMapper.get_by_id(row.domain_id)
     self.range = range_ if range_ else EntityMapper.get_by_id(row.range_id)
     self.type = g.nodes[row.type_id] if row.type_id else None
     self.nodes = dict()
     if hasattr(row, 'type_id') and row.type_id:
         self.nodes[g.nodes[row.type_id]] = None
     if hasattr(row, 'begin_from'):
         self.begin_from = DateMapper.timestamp_to_datetime64(row.begin_from)
         self.begin_to = DateMapper.timestamp_to_datetime64(row.begin_to)
         self.begin_comment = row.begin_comment
         self.end_from = DateMapper.timestamp_to_datetime64(row.end_from)
         self.end_to = DateMapper.timestamp_to_datetime64(row.end_to)
         self.end_comment = row.end_comment
         self.first = DateForm.format_date(self.begin_from, 'year') if self.begin_from else None
         self.last = DateForm.format_date(self.end_from, 'year') if self.end_from else None
         self.last = DateForm.format_date(self.end_to, 'year') if self.end_to else self.last