snapshot current state before gitea sync
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
from DataVaultGenerator.Components import DataVaultEntity, DataVaultEntityAttribute, ErrorCollection
|
||||
|
||||
|
||||
class PIT(DataVaultEntity):
|
||||
def __init__(self, model, filename, definition: dict = None):
|
||||
DataVaultEntity.__init__(self, model, filename, definition)
|
||||
|
||||
self.baseentity = self._definition.get('baseentity')
|
||||
self.snapshotmode = self._definition.get('snapshotmode')
|
||||
self.snapshottable = self._definition.get('snapshottable')
|
||||
self.snapshottableattribute = self._definition.get('snapshottableattribute')
|
||||
|
||||
|
||||
def include_ledts(self):
|
||||
return self._definition.get('include_ledts')
|
||||
|
||||
@property
|
||||
def snapshotattribute(self):
|
||||
return DataVaultEntityAttribute(self, self._definition['snapshotattribute'])
|
||||
|
||||
@property
|
||||
def snapshotquery(self):
|
||||
return self.model.get_parsed_query(self, self.rawsnapshotquery)
|
||||
|
||||
def get_snaphotquery_entities(self):
|
||||
return self.model.get_query_entities(self.rawsnapshotquery)
|
||||
|
||||
@property
|
||||
def rawsnapshotquery(self):
|
||||
return self._definition.get('snapshotquery', '')
|
||||
|
||||
@property
|
||||
def query(self):
|
||||
return self.model.get_parsed_query(self, self.query)
|
||||
|
||||
def get_query_entities(self):
|
||||
return self.model.get_query_entities(self.rawquery)
|
||||
|
||||
@property
|
||||
def rawquery(self):
|
||||
return self._definition.get('query', '')
|
||||
|
||||
def get_base_entity(self):
|
||||
return self.model.get_entity(self.baseentity)
|
||||
|
||||
def get_satellites(self):
|
||||
return [self.model.get_entity(sat) for sat in self._definition.get('satellites')]
|
||||
|
||||
def has_attributes(self):
|
||||
return True if self._definition.get('pitattributes') else False
|
||||
|
||||
def get_pitattributes(self):
|
||||
attributes = []
|
||||
|
||||
for attr in self._definition.get('pitattributes', []):
|
||||
attributes.append(self.model.get_entity(attr[0]).get_attribute(attr[1]))
|
||||
# attributes.append({'attribute': self.model.get_entity(attr[1]).get_attribute(attr[2])
|
||||
# , 'alias': attr[0]})
|
||||
return attributes
|
||||
|
||||
def validate(self):
|
||||
|
||||
errors = ErrorCollection()
|
||||
|
||||
# Validating entity references:
|
||||
if self._definition.get('snapshotquery'):
|
||||
for name, e in self.get_snaphotquery_entities().items():
|
||||
if e is None:
|
||||
errors.add("VALIDATION ERROR",
|
||||
(self.filename, "PIT", "<" + self.name + ">"),
|
||||
f'query-entity <{name}> not found.')
|
||||
|
||||
if self._definition.get('query'):
|
||||
for name, e in self.get_query_entities().items():
|
||||
if e is None:
|
||||
errors.add("VALIDATION ERROR",
|
||||
(self.filename, "PIT", "<" + self.name + ">"),
|
||||
f'query-entity <{name}> not found.')
|
||||
|
||||
return errors
|
||||
|
||||
def get_component_entities(self):
|
||||
c = [{'entity': self, 'component': c, 'type': c.type} for c in self.get_snaphotquery_entities().values()]
|
||||
c.extend([{'entity': self, 'component': c, 'type': c.type} for c in self.get_query_entities().values()])
|
||||
c.extend([{'entity': self, 'component': c, 'type': c.type} for c in self.get_satellites()])
|
||||
c.extend([{'entity': self, 'component': self.get_base_entity(), 'type': self.get_base_entity().type}])
|
||||
|
||||
return c
|
||||
Reference in New Issue
Block a user