Skip to content

Commit

Permalink
Merge pull request #55 from fabrizio-turchi/issue-#54
Browse files Browse the repository at this point in the history
Fix #54 issue, adding CellSiteFacet class
  • Loading branch information
ajnelson-nist authored May 23, 2024
2 parents c4076f5 + b9db2ed commit 9c595ac
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 0 deletions.
52 changes: 52 additions & 0 deletions case.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -1357,6 +1357,58 @@
"uco-core:target": {
"@id": "kb:1208b420-82c9-5a38-bbee-701dcaae2536"
}
},
{
"@id": "kb:bb4a4ffd-30b3-5b89-9a2d-4c1f14842dfd",
"@type": "uco-observable:ObservableObject",
"uco-core:hasFacet": [
{
"@id": "kb:47573040-97b8-5038-b7e3-5e2c84c4acba",
"@type": "uco-observable:CellSiteFacet",
"uco-observable:cellSiteCountryCode": "310",
"uco-observable:cellSiteIdentifier": "187589293",
"uco-observable:cellSiteLocationAreaCode": "2953",
"uco-observable:cellSiteNetworkCode": "410",
"uco-observable:cellSiteType": "GSM"
}
]
},
{
"@id": "kb:54767cee-39df-5622-a260-d0ddaae87d30",
"@type": "uco-observable:ObservableObject",
"uco-core:hasFacet": [
{
"@id": "kb:ed1c65f8-cbb7-55f8-b544-371f4717e6a0",
"@type": "uco-location:LatLongCoordinatesFacet",
"uco-location:latitude": {
"@type": "xsd:decimal",
"@value": "36.16585393"
},
"uco-location:longitude": {
"@type": "xsd:decimal",
"@value": "-86.77639682"
},
"uco-location:altitude": {
"@type": "xsd:decimal",
"@value": "0.0"
}
}
]
},
{
"@id": "kb:77e011a5-5b27-52dc-a233-13b50c76a22f",
"@type": "uco-observable:ObservableRelationship",
"uco-core:isDirectional": {
"@type": "xsd:boolean",
"@value": true
},
"uco-core:kindOfRelationship": "Located_At",
"uco-core:source": {
"@id": "kb:bb4a4ffd-30b3-5b89-9a2d-4c1f14842dfd"
},
"uco-core:target": {
"@id": "kb:54767cee-39df-5622-a260-d0ddaae87d30"
}
}
]
}
35 changes: 35 additions & 0 deletions case_mapping/uco/observable.py
Original file line number Diff line number Diff line change
Expand Up @@ -1369,6 +1369,41 @@ def __init__(
self._bool_vars(**{"uco-observable:isDisabled": disabled})


class FacetCellSite(FacetEntity):
def __init__(
self,
cell_site_country_code: Optional[str] = None,
cell_site_identifier: Optional[str] = None,
cell_site_location_area_code: Optional[str] = None,
cell_site_network_code: Optional[str] = None,
cell_site_type: Optional[str] = None,
):
"""
A cell site facet contains the metadata surrounding the cell site.
:param cell_site_country_code: he country code represents the country of the
cell site. For GSM, this is the Mobile Country Code (MCC).
:param cell_site_identifier: Specifies the unique number used to identify each
Cell Site within a location area code.
:param cell_site_location_area_code: The location area code is a unique number
of current location area of the cell site.
:param cell_site_network_code: This code identifies the mobile operator of
the cell site.
:param cell_site_type: Specifies the technology used by the Cell Site
(e.g., GSM, CDMA, or LTE).
"""
super().__init__()
self["@type"] = "uco-observable:CellSiteFacet"
self._str_vars(
**{
"uco-observable:cellSiteCountryCode": cell_site_country_code,
"uco-observable:cellSiteIdentifier": cell_site_identifier,
"uco-observable:cellSiteLocationAreaCode": cell_site_location_area_code,
"uco-observable:cellSiteNetworkCode": cell_site_network_code,
"uco-observable:cellSiteType": cell_site_type,
}
)


class FacetWirelessNetworkConnection(FacetEntity):
def __init__(
self,
Expand Down
31 changes: 31 additions & 0 deletions example.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,37 @@ def _next_timestamp() -> datetime:
)
bundle.append_to_uco_object(geo_relation)

#####################
# Adding a CellSite #
#####################
cell_site_object = uco.observable.ObservableObject()
cell_site_facet = uco.observable.FacetCellSite(
cell_site_country_code="310",
cell_site_identifier="187589293",
cell_site_location_area_code="2953",
cell_site_network_code="410",
cell_site_type="GSM",
)
cell_site_object.append_facets(cell_site_facet)
bundle.append_to_uco_object(cell_site_object)

geo_location_object = uco.observable.ObservableObject()
geo_location_facet = uco.location.FacetLocation(
latitude=36.16585393,
longitude=-86.77639682,
altitude=0.0,
)
geo_location_object.append_facets(geo_location_facet)
bundle.append_to_uco_object(geo_location_object)

geo_relation = uco.observable.ObservableRelationship(
source=cell_site_object,
target=geo_location_object,
kind_of_relationship="Located_At",
directional=True,
)
bundle.append_to_uco_object(geo_relation)

##################
# Print the case #
##################
Expand Down

0 comments on commit 9c595ac

Please sign in to comment.