-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1002 from ge-high-assurance/vr/migration-v13
migration: v13 changes
- Loading branch information
Showing
13 changed files
with
1,335 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
|
||
# Copyright (c) 2023, Galois, Inc. | ||
# | ||
# All Rights Reserved | ||
# | ||
# This material is based upon work supported by the Defense Advanced Research | ||
# Projects Agency (DARPA) under Contract No. FA8750-20-C-0203. | ||
# | ||
# Any opinions, findings and conclusions or recommendations expressed in this | ||
# material are those of the author(s) and do not necessarily reflect the views | ||
# of the Defense Advanced Research Projects Agency (DARPA). | ||
|
||
from typing import List | ||
|
||
from migration_helpers.name_space import NameSpace | ||
from ontology_changes import ( | ||
AddClassIsATypeOf, | ||
CreateClass, | ||
) | ||
from ontology_changes.cardinality import Cardinality | ||
from ontology_changes.ontology_change import OntologyChange | ||
from ontology_changes.range_restriction import RangeRestriction | ||
|
||
def create_class_with_type_of( | ||
namespace: NameSpace, | ||
class_id: str, | ||
type_of_namespace: NameSpace, | ||
type_of_class: str, | ||
) -> List[OntologyChange]: | ||
return [ | ||
CreateClass( | ||
name_space=namespace, | ||
class_id=class_id, | ||
), | ||
AddClassIsATypeOf( | ||
name_space=namespace, | ||
class_id=class_id, | ||
range_name_space=type_of_namespace, | ||
range_id=type_of_class, | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Copyright (c) 2023, Galois, Inc. | ||
# | ||
# All Rights Reserved | ||
# | ||
# This material is based upon work supported by the Defense Advanced Research | ||
# Projects Agency (DARPA) under Contract No. FA8750-20-C-0203. | ||
# | ||
# Any opinions, findings and conclusions or recommendations expressed in this | ||
# material are those of the author(s) and do not necessarily reflect the views | ||
# of the Defense Advanced Research Projects Agency (DARPA). | ||
|
||
from typing import List, List | ||
|
||
from migration_helpers.name_space import NameSpace | ||
from ontology_changes import ( | ||
AddRangeRestriction, | ||
ChangeCardinality, | ||
CreateProperty, | ||
) | ||
from ontology_changes.cardinality import Cardinality | ||
from ontology_changes.ontology_change import OntologyChange | ||
from ontology_changes.range_restriction import RangeRestriction | ||
|
||
def create_property_with_cardinality_and_range( | ||
namespace: NameSpace, | ||
class_id: str, | ||
property_id: str, | ||
range: RangeRestriction, | ||
cardinality: Cardinality, | ||
) -> List[OntologyChange]: | ||
return [ | ||
CreateProperty( | ||
name_space=namespace, | ||
class_id=class_id, | ||
property_id=property_id, | ||
), | ||
AddRangeRestriction( | ||
domain_name_space=namespace, | ||
domain_class=class_id, | ||
prop_name_space=namespace, | ||
prop_name=property_id, | ||
restriction=range, | ||
), | ||
ChangeCardinality( | ||
name_space=namespace, | ||
class_id=class_id, | ||
property_id=property_id, | ||
to_cardinality=cardinality, | ||
), | ||
|
||
] |
49 changes: 49 additions & 0 deletions
49
migration/migration_helpers/relocate_class_and_properties.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Copyright (c) 2023, Galois, Inc. | ||
# | ||
# All Rights Reserved | ||
# | ||
# This material is based upon work supported by the Defense Advanced Research | ||
# Projects Agency (DARPA) under Contract No. FA8750-20-C-0203. | ||
# | ||
# Any opinions, findings and conclusions or recommendations expressed in this | ||
# material are those of the author(s) and do not necessarily reflect the views | ||
# of the Defense Advanced Research Projects Agency (DARPA). | ||
|
||
from typing import List | ||
|
||
from migration_helpers.name_space import NameSpace | ||
from ontology_changes import ( | ||
RenameClass, | ||
RenameProperty, | ||
) | ||
from ontology_changes.ontology_change import OntologyChange | ||
|
||
|
||
def relocate_class_and_properties( | ||
from_namespace: NameSpace, | ||
to_namespace: NameSpace, | ||
class_id: str, | ||
properties: List[str], | ||
) -> List[OntologyChange]: | ||
# Explicit type ascriptions to circumvent the fact that List is not | ||
# covariant | ||
rename_class: List[OntologyChange] = [ | ||
RenameClass( | ||
from_name_space=from_namespace, | ||
from_name=class_id, | ||
to_name_space=to_namespace, | ||
to_name=class_id, | ||
) | ||
] | ||
rename_properties: List[OntologyChange] = [ | ||
RenameProperty( | ||
from_name_space=from_namespace, | ||
from_class=class_id, | ||
from_name=property_id, | ||
to_name_space=to_namespace, | ||
to_class=class_id, | ||
to_name=property_id, | ||
) | ||
for property_id in properties | ||
] | ||
return rename_class + rename_properties |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.