Skip to content

Commit

Permalink
Merge pull request #57 from fabrizio-turchi/issue-#16
Browse files Browse the repository at this point in the history
Fix #16 issue, adding MobileAccountFacet class
  • Loading branch information
ajnelson-nist authored May 28, 2024
2 parents 608f462 + 37c6af8 commit 4ac2cf1
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 0 deletions.
28 changes: 28 additions & 0 deletions case.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -1555,6 +1555,34 @@
}
}
]
},
{
"@id": "kb:dce632ef-83f0-5481-9b10-d38455d155be",
"@type": "uco-observable:ObservableObject",
"uco-core:hasFacet": [
{
"@id": "kb:3a19b98a-0be3-5c59-a9ba-bf82784ea379",
"@type": "uco-observable:MobileAccountFacet",
"uco-observable:IMSI": "22210",
"uco-observable:MSISDN": "00493879166532",
"uco-observable:MSISDNType": "GSM"
}
]
},
{
"@id": "kb:9404f6f3-0348-5e14-bbf4-cb15562899bf",
"@type": "uco-observable:ObservableRelationship",
"uco-core:isDirectional": {
"@type": "xsd:boolean",
"@value": true
},
"uco-core:kindOfRelationship": "Has_Account",
"uco-core:source": {
"@id": "kb:a7b7ae64-d607-5f2a-a4ea-8722062f52a1"
},
"uco-core:target": {
"@id": "kb:dce632ef-83f0-5481-9b10-d38455d155be"
}
}
]
}
28 changes: 28 additions & 0 deletions case_mapping/uco/observable.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,34 @@ def __init__(self, identifier=None, is_active=True, issuer_id=None):
)


class FacetMobileAccount(FacetEntity):
def __init__(
self,
IMSI: Optional[str] = None,
MSISDN: Optional[str] = None,
MSISDN_type: Optional[str] = None,
):
"""
A mobile account facet is a grouping of characteristics unique to an arrangement
with an entity to enable and control the provision of some capability or service
on a portable computing device.
:param IMSI: An International Mobile Subscriber Identity (IMSI) is a unique identification
associated with all GSM and UMTS network mobile phone users.
:param MSISDN: Mobile Station International Subscriber Directory Number (MSISDN) is a number
used to identify a mobile phone number internationally.
:param MSISDN_type: The network mobile phone (GMS or UMTS)
"""
super().__init__()
self["@type"] = "uco-observable:MobileAccountFacet"
self._str_vars(
**{
"uco-observable:IMSI": IMSI,
"uco-observable:MSISDN": MSISDN,
"uco-observable:MSISDNType": MSISDN_type,
}
)


class FacetContentData(FacetEntity):
def __init__(
self,
Expand Down
21 changes: 21 additions & 0 deletions example.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,27 @@ def _next_timestamp() -> datetime:
calendar_object.append_facets(calendar_facet)
bundle.append_to_uco_object(calendar_object)

##########################
# Adding a MobileAccount #
##########################

mobile_account_object = uco.observable.ObservableObject()
mobile_account_facet = uco.observable.FacetMobileAccount(
IMSI="22210",
MSISDN="00493879166532",
MSISDN_type="GSM",
)
mobile_account_object.append_facets(mobile_account_facet)
bundle.append_to_uco_object(mobile_account_object)

account_relation = uco.observable.ObservableRelationship(
source=device_object,
target=mobile_account_object,
kind_of_relationship="Has_Account",
directional=True,
)
bundle.append_to_uco_object(account_relation)

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

0 comments on commit 4ac2cf1

Please sign in to comment.