Skip to content

Commit 5ee8bb2

Browse files
committed
Merge remote-tracking branch 'origin/281-user-friendly-decommutation-of-received-reports' into 324-testing-ci
2 parents 6c42449 + a4ab73b commit 5ee8bb2

File tree

18 files changed

+450
-340
lines changed

18 files changed

+450
-340
lines changed

anms-core/anms/components/schemas/ARIs/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,5 @@
5353
from .registered_agent import RegisteredAgentInDBBase
5454
from .rpt_entry import RptEntry
5555
from .rpt_entry import RptEntryName
56+
from .rpt_entry import RptEntryFull
5657
from .rpt_entry import RptEntryBaseInDBBase

anms-core/anms/components/schemas/ARIs/rpt_entry.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,26 @@ class RptEntryBase(BaseModel):
3232
class Config:
3333
arbitrary_types_allowed = True
3434

35-
ari_rptset_id: Optional[str] = None
36-
reference_time: Optional[datetime] = None
37-
report_list: Optional[str] = None
38-
agent_id: Optional[int] = None
39-
35+
ari_rptset_id: Optional[int] = None
36+
reference_time: Optional[datetime] = None
37+
mgr_time: Optional[datetime] = None
38+
nonce_cbor: Optional[str] = None
39+
time_offset: Optional[datetime] = None
40+
report_source: Optional[str] = None
41+
report_items: Optional[list] = None
42+
report_item_indexes: Optional[list] = None
43+
44+
# Shared properties
45+
class RptEntryFull(RptEntryBase):
46+
class Config:
47+
arbitrary_types_allowed = True
48+
orm_mode = True
4049

50+
agent_id: Optional[int] = None
51+
ari_rptlist_id: Optional[int] = None
52+
53+
54+
4155
class RptEntryBaseInDBBase(RptEntryBase):
4256
class Config:
4357
orm_mode = True
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
#
4+
# Copyright (c) 2023 The Johns Hopkins University Applied Physics
5+
# Laboratory LLC.
6+
#
7+
# This file is part of the Asynchronous Network Management System (ANMS).
8+
#
9+
# Licensed under the Apache License, Version 2.0 (the "License");
10+
# you may not use this file except in compliance with the License.
11+
# You may obtain a copy of the License at
12+
# http://www.apache.org/licenses/LICENSE-2.0
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
#
19+
# This work was performed for the Jet Propulsion Laboratory, California
20+
# Institute of Technology, sponsored by the United States Government under
21+
# the prime contract 80NM0018D0004 between the Caltech and NASA under
22+
# subcontract 1658085.
23+
#
24+
from typing import Any
25+
from typing import Dict
26+
27+
from anms.models.relational import Model
28+
from sqlalchemy import Column
29+
from sqlalchemy import Integer
30+
from sqlalchemy import String
31+
32+
# class for vw_ctrl_definition used for build ari
33+
class Const(Model):
34+
__tablename__ = 'vw_const_actual'
35+
obj_actual_definition_id = Column(Integer, primary_key=True)
36+
data_type = Column(String)
37+
data_value = Column(String)
38+
use_desc = Column(String)
39+
obj_metadata_id = Column(Integer)
40+
data_model_name = Column(String)
41+
namespace = Column(String)
42+
data_type_id = Column(Integer)
43+
name = Column(String)
44+
data_model_id = Column(Integer)
45+
object_enumeration = Column(Integer)
46+
status = Column(String)
47+
reference = Column(String)
48+
description = Column(String)
49+
50+
def __repr__(self) -> str:
51+
return self.as_dict().__repr__()
52+
53+
def as_dict(self) -> Dict[str, Any]:
54+
dict_obj = {
55+
c.name: getattr(self, c.name) for c in self.__table__.columns
56+
}
57+
58+
return dict_obj

anms-core/anms/models/relational/execution_set.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from sqlalchemy import Integer
3030
from sqlalchemy import String
3131
from sqlalchemy import LargeBinary
32+
from anms.shared.transmogrifier import TRANSMORGIFIER
3233

3334

3435
# class for vw_ctrl_definition used for build ari
@@ -47,7 +48,7 @@ def __repr__(self) -> str:
4748
def as_dict(self) -> Dict[str, Any]:
4849
dict_obj = {
4950
'execution_set_id': getattr(self, 'execution_set_id'),
50-
'nonce_cbor': getattr(self, 'nonce_cbor'),
51+
'nonce_cbor': TRANSMORGIFIER._ace_transcode_just_cbor("0x"+getattr(self, 'nonce_cbor').hex()),
5152
'use_desc': getattr(self, 'use_desc'),
5253
'agent_id': getattr(self, 'agent_id'),
5354
'num_entries': getattr(self, 'num_entries'),

anms-core/anms/models/relational/report.py

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,33 +24,49 @@
2424
from typing import Any
2525
from typing import Dict
2626

27+
from anms.shared.transmogrifier import TRANSMORGIFIER
2728
from anms.models.relational import Model
2829
from sqlalchemy import Column
2930
from sqlalchemy import Integer
30-
from sqlalchemy import String
31+
from sqlalchemy import DateTime
32+
from sqlalchemy import ARRAY
3133
from sqlalchemy import LargeBinary
32-
34+
from sqlalchemy import orm
3335

3436
# class for vw_ctrl_definition used for build ari
3537
class Report(Model):
36-
__tablename__ = 'ari_rptset'
37-
ari_rptset_id = Column(Integer, primary_key=True)
38-
nonce_cbor = Column(LargeBinary)
39-
reference_time = Column(Integer)
40-
report_list = Column(String)
41-
report_list_cbor = Column(LargeBinary)
42-
agent_id = Column(Integer)
38+
__tablename__ = 'vw_ari_rpt_set'
39+
ari_rptset_id = Column(Integer, primary_key=True)
40+
mgr_time = Column(DateTime)
41+
reference_time = Column(DateTime)
42+
nonce_cbor = Column(LargeBinary)
43+
agent_id = Column(Integer)
44+
ari_rptset_cbor = Column(LargeBinary)
45+
ari_rptlist_id = Column(Integer)
46+
time_offset = Column(DateTime)
47+
report_source = Column(LargeBinary)
48+
report_items = Column(ARRAY(LargeBinary) )#bytea[] NULL
49+
report_item_indexes = Column(ARRAY(Integer))
50+
# processing the raw cbor into an ari object
51+
@orm.reconstructor
52+
def init_on_load(self):
53+
self.nonce_cbor = TRANSMORGIFIER.transcode("0x"+getattr(self, 'nonce_cbor').hex())['uri']
54+
self.report_source = TRANSMORGIFIER.transcode("0x"+getattr(self, 'report_source').hex())['uri']
55+
self.report_items = [TRANSMORGIFIER.transcode("0x"+x.hex())['uri'] for x in getattr(self, 'report_items')]
56+
4357
def __repr__(self) -> str:
4458
return self.as_dict().__repr__()
4559

4660
def as_dict(self) -> Dict[str, Any]:
4761
dict_obj = {
4862
'ari_rptset_id': getattr(self, 'ari_rptset_id'),
49-
'nonce_cbor': getattr(self, 'nonce_cbor'),
5063
'reference_time': getattr(self, 'reference_time'),
51-
'report_list': getattr(self, 'report_list'),
52-
'report_list_cbor': getattr(self, 'report_list_cbor'),
53-
'agent_id': getattr(self, 'agent_id')
64+
'nonce_cbor': getattr(self, 'nonce_cbor'),
65+
'agent_id': getattr(self, 'agent_id'),
66+
'ari_rptlist_id': getattr(self, 'ari_rptlist_id'),
67+
'time_offset': getattr(self, 'time_offset'),
68+
'report_source': getattr(self, 'report_source'),
69+
'report_items': getattr(self, 'report_items'),
70+
'report_item_indexes': getattr(self, 'report_item_indexes')
5471
}
55-
5672
return dict_obj

0 commit comments

Comments
 (0)