2019-05-29 16:47:03 +00:00
|
|
|
from sqlalchemy.types import PickleType
|
|
|
|
from sqlalchemy.ext.compiler import compiles
|
|
|
|
from sqlalchemy.orm import relationship, backref
|
|
|
|
from sqlalchemy import (
|
|
|
|
Column,
|
|
|
|
Date,
|
|
|
|
ForeignKey,
|
|
|
|
Integer,
|
|
|
|
String,
|
|
|
|
Unicode,
|
|
|
|
PrimaryKeyConstraint,
|
|
|
|
Table
|
|
|
|
)
|
|
|
|
|
|
|
|
from model.core import Base, Core
|
|
|
|
|
2019-08-05 18:41:27 +00:00
|
|
|
|
2019-05-29 16:47:03 +00:00
|
|
|
@compiles(String, 'postgresql')
|
|
|
|
def compile_xml(type_, compiler, **kw):
|
2019-08-05 18:41:27 +00:00
|
|
|
return 'XML'
|
|
|
|
|
2019-05-29 16:47:03 +00:00
|
|
|
|
|
|
|
ENTRY_XML = Table(
|
|
|
|
'entry_xml',
|
|
|
|
Base.metadata,
|
|
|
|
Column('cce_id', Integer, ForeignKey('cce.id'), index=True),
|
|
|
|
Column('xml_id', Integer, ForeignKey('xml.id'), index=True)
|
|
|
|
)
|
|
|
|
|
|
|
|
ERROR_XML = Table(
|
|
|
|
'error_entry_xml',
|
|
|
|
Base.metadata,
|
|
|
|
Column('error_cce_id', Integer, ForeignKey('error_cce.id'), index=True),
|
|
|
|
Column('xml_id', Integer, ForeignKey('xml.id'), index=True)
|
|
|
|
)
|
|
|
|
|
2019-08-05 18:41:27 +00:00
|
|
|
|
2019-05-29 16:47:03 +00:00
|
|
|
class XML(Core, Base):
|
|
|
|
__tablename__ = 'xml'
|
|
|
|
id = Column(Integer, primary_key=True)
|
|
|
|
xml_source = Column(String)
|
2019-08-05 18:41:27 +00:00
|
|
|
|
2019-05-29 16:47:03 +00:00
|
|
|
entry = relationship(
|
|
|
|
'CCE',
|
|
|
|
secondary=ENTRY_XML,
|
2019-08-05 18:41:27 +00:00
|
|
|
backref='xml_sources',
|
|
|
|
single_parent=True,
|
|
|
|
cascade='all, delete-orphan'
|
2019-05-29 16:47:03 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
error_entry = relationship(
|
|
|
|
'ErrorCCE',
|
|
|
|
secondary=ERROR_XML,
|
2019-08-05 18:41:27 +00:00
|
|
|
backref='xml_sources',
|
|
|
|
single_parent=True,
|
|
|
|
cascade='all, delete-orphan'
|
2019-05-29 16:47:03 +00:00
|
|
|
)
|