本文整理汇总了Python中interface.services.sa.iobservatory_management_service.ObservatoryManagementServiceClient.assign_resource_to_observatory_org方法的典型用法代码示例。如果您正苦于以下问题:Python ObservatoryManagementServiceClient.assign_resource_to_observatory_org方法的具体用法?Python ObservatoryManagementServiceClient.assign_resource_to_observatory_org怎么用?Python ObservatoryManagementServiceClient.assign_resource_to_observatory_org使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类interface.services.sa.iobservatory_management_service.ObservatoryManagementServiceClient
的用法示例。
在下文中一共展示了ObservatoryManagementServiceClient.assign_resource_to_observatory_org方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestObservatoryManagementServiceIntegration
# 需要导入模块: from interface.services.sa.iobservatory_management_service import ObservatoryManagementServiceClient [as 别名]
# 或者: from interface.services.sa.iobservatory_management_service.ObservatoryManagementServiceClient import assign_resource_to_observatory_org [as 别名]
#.........这里部分代码省略.........
"""
the tree we're creating (observatory, sites, platforms, instruments)
rows are lettered, colums numbered.
- first row is implied a
- first column is implied 1
- site Z, just because
O--Sz
|
S--S2--P3--I4
|
Sb-Pb2-Ib3
|
P--I2 <- PlatformDevice, InstrumentDevice2
|
Pb <- PlatformDevice b
|
I <- InstrumentDevice
"""
org_id = self.OMS.create_marine_facility(any_old(RT.Org))
def create_under_org(resource_type):
obj = any_old(resource_type)
if RT.InstrumentDevice == resource_type:
resource_id = self.IMS.create_instrument_device(obj)
else:
resource_id, _ = self.RR.create(obj)
self.OMS.assign_resource_to_observatory_org(resource_id=resource_id, org_id=org_id)
return resource_id
#stuff we control
observatory_id = create_under_org(RT.Observatory)
subsite_id = create_under_org(RT.Subsite)
subsite2_id = create_under_org(RT.Subsite)
subsiteb_id = create_under_org(RT.Subsite)
subsitez_id = create_under_org(RT.Subsite)
platform_site_id = create_under_org(RT.PlatformSite)
platform_siteb_id = create_under_org(RT.PlatformSite)
platform_siteb2_id = create_under_org(RT.PlatformSite)
platform_site3_id = create_under_org(RT.PlatformSite)
instrument_site_id = create_under_org(RT.InstrumentSite)
instrument_site2_id = create_under_org(RT.InstrumentSite)
instrument_siteb3_id = create_under_org(RT.InstrumentSite)
instrument_site4_id = create_under_org(RT.InstrumentSite)
#stuff we associate to
instrument_device_id = create_under_org(RT.InstrumentDevice)
instrument_device2_id = create_under_org(RT.InstrumentDevice)
platform_device_id = create_under_org(RT.PlatformDevice)
platform_deviceb_id = create_under_org(RT.PlatformDevice)
instrument_model_id, _ = self.RR.create(any_old(RT.InstrumentModel))
platform_model_id, _ = self.RR.create(any_old(RT.PlatformModel))
deployment_id, _ = self.RR.create(any_old(RT.Deployment))
#observatory
self.RR.create_association(observatory_id, PRED.hasSite, subsite_id)
self.RR.create_association(observatory_id, PRED.hasSite, subsitez_id)
#site
self.RR.create_association(subsite_id, PRED.hasSite, subsite2_id)
示例2: TestObservatoryManagementServiceIntegration
# 需要导入模块: from interface.services.sa.iobservatory_management_service import ObservatoryManagementServiceClient [as 别名]
# 或者: from interface.services.sa.iobservatory_management_service.ObservatoryManagementServiceClient import assign_resource_to_observatory_org [as 别名]
#.........这里部分代码省略.........
"""
the tree we're creating (observatory, sites, platforms, instruments)
rows are lettered, colums numbered.
- first row is implied a
- first column is implied 1
- site Z, just because
O--Sz
|
S--S2--P3--I4
|
Sb-Pb2-Ib3
|
P--I2 <- PlatformDevice, InstrumentDevice2
|
Pb <- PlatformDevice b
|
I <- InstrumentDevice
"""
org_id = self.OMS.create_marine_facility(any_old(RT.Org))
def create_under_org(resource_type, extra_fields=None):
obj = any_old(resource_type, extra_fields)
if RT.InstrumentDevice == resource_type:
resource_id = self.IMS.create_instrument_device(obj)
else:
resource_id, _ = self.RR.create(obj)
self.OMS.assign_resource_to_observatory_org(resource_id=resource_id, org_id=org_id)
return resource_id
#stuff we control
observatory_id = create_under_org(RT.Observatory)
subsite_id = create_under_org(RT.Subsite)
subsite2_id = create_under_org(RT.Subsite)
subsiteb_id = create_under_org(RT.Subsite)
subsitez_id = create_under_org(RT.Subsite)
platform_site_id = create_under_org(RT.PlatformSite)
platform_siteb_id = create_under_org(RT.PlatformSite)
platform_siteb2_id = create_under_org(RT.PlatformSite)
platform_site3_id = create_under_org(RT.PlatformSite)
instrument_site_id = create_under_org(RT.InstrumentSite)
instrument_site2_id = create_under_org(RT.InstrumentSite)
instrument_siteb3_id = create_under_org(RT.InstrumentSite)
instrument_site4_id = create_under_org(RT.InstrumentSite)
#stuff we associate to
instrument_device_id = create_under_org(RT.InstrumentDevice)
instrument_device2_id = create_under_org(RT.InstrumentDevice)
platform_device_id = create_under_org(RT.PlatformDevice)
platform_deviceb_id = create_under_org(RT.PlatformDevice)
instrument_model_id, _ = self.RR.create(any_old(RT.InstrumentModel))
platform_model_id, _ = self.RR.create(any_old(RT.PlatformModel))
deployment_id, _ = self.RR.create(any_old(RT.Deployment))
#observatory
self.RR.create_association(observatory_id, PRED.hasSite, subsite_id)
self.RR.create_association(observatory_id, PRED.hasSite, subsitez_id)
#site
self.RR.create_association(subsite_id, PRED.hasSite, subsite2_id)
示例3: TestObservatoryManagementServiceIntegration
# 需要导入模块: from interface.services.sa.iobservatory_management_service import ObservatoryManagementServiceClient [as 别名]
# 或者: from interface.services.sa.iobservatory_management_service.ObservatoryManagementServiceClient import assign_resource_to_observatory_org [as 别名]
#.........这里部分代码省略.........
ret.platform_siteb_id = platform_siteb_id
ret.platform_siteb2_id = platform_siteb2_id
ret.platform_site3_id = platform_site3_id
ret.instrument_site_id = instrument_site_id
ret.instrument_site2_id = instrument_site2_id
ret.instrument_siteb3_id = instrument_siteb3_id
ret.instrument_site4_id = instrument_site4_id
return ret
#@unittest.skip("targeting")
def test_create_observatory(self):
observatory_obj = IonObject(RT.Observatory,
name='TestFacility',
description='some new mf')
self.OMS.create_observatory(observatory_obj)
#@unittest.skip("targeting")
def test_find_observatory_org(self):
org_obj = IonObject(RT.Org,
name='TestOrg',
description='some new mf org')
org_id = self.OMS.create_marine_facility(org_obj)
observatory_obj = IonObject(RT.Observatory,
name='TestObservatory',
description='some new obs')
observatory_id = self.OMS.create_observatory(observatory_obj)
#make association
self.OMS.assign_resource_to_observatory_org(observatory_id, org_id)
#find association
org_objs = self.OMS.find_org_by_observatory(observatory_id)
self.assertEqual(1, len(org_objs))
self.assertEqual(org_id, org_objs[0]._id)
print("org_id=<" + org_id + ">")
#create a subsite with parent Observatory
subsite_obj = IonObject(RT.Subsite,
name= 'TestSubsite',
description = 'sample subsite')
subsite_id = self.OMS.create_subsite(subsite_obj, observatory_id)
self.assertIsNotNone(subsite_id, "Subsite not created.")
# verify that Subsite is linked to Observatory
mf_subsite_assoc = self.RR.get_association(observatory_id, PRED.hasSite, subsite_id)
self.assertIsNotNone(mf_subsite_assoc, "Subsite not connected to Observatory.")
# add the Subsite as a resource of this Observatory
self.OMS.assign_resource_to_observatory_org(resource_id=subsite_id, org_id=org_id)
# verify that Subsite is linked to Org
org_subsite_assoc = self.RR.get_association(org_id, PRED.hasResource, subsite_id)
self.assertIsNotNone(org_subsite_assoc, "Subsite not connected as resource to Org.")
#create a logical platform with parent Subsite
platform_site_obj = IonObject(RT.PlatformSite,
name= 'TestPlatformSite',