当前位置: 首页>>代码示例>>Python>>正文


Python IonObject._id方法代码示例

本文整理汇总了Python中pyon.public.IonObject._id方法的典型用法代码示例。如果您正苦于以下问题:Python IonObject._id方法的具体用法?Python IonObject._id怎么用?Python IonObject._id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyon.public.IonObject的用法示例。


在下文中一共展示了IonObject._id方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _convert_negotiations_to_requests

# 需要导入模块: from pyon.public import IonObject [as 别名]
# 或者: from pyon.public.IonObject import _id [as 别名]
    def _convert_negotiations_to_requests(self, negotiations=None, user_info_id='', org_id=''):
        assert isinstance(negotiations, list)

        orgs,_ = self.clients.resource_registry.find_resources(restype=RT.Org)

        ret_list = []
        for neg in negotiations:

            request = IonObject(OT.OrgUserNegotiationRequest, ts_updated=neg.ts_updated, negotiation_id=neg._id,
                negotiation_type=NegotiationTypeEnum._str_map[neg.negotiation_type],
                negotiation_status=NegotiationStatusEnum._str_map[neg.negotiation_status],
                originator=ProposalOriginatorEnum._str_map[neg.proposals[-1].originator],
                request_type=neg.proposals[-1].type_,
                description=neg.description, reason=neg.reason,
                user_id=user_info_id)

            # since this is a proxy for the Negotiation object, simulate its id to help the UI deal with it
            request._id = neg._id

            org_request = [ o for o in orgs if o._id == neg.proposals[-1].provider ]
            if org_request:
                request.org_id = org_request[0]._id
                request.name = org_request[0].name

            ret_list.append(request)

        return ret_list
开发者ID:ednad,项目名称:coi-services,代码行数:29,代码来源:identity_management_service.py

示例2: test_createDataProduct_and_DataProducer_with_id_BadRequest

# 需要导入模块: from pyon.public import IonObject [as 别名]
# 或者: from pyon.public.IonObject import _id [as 别名]
 def test_createDataProduct_and_DataProducer_with_id_BadRequest(self):
     # setup
     self.resource_registry.find_resources.return_value = ([], 'do not care')
     self.resource_registry.create.return_value = ('SOME_RR_ID1', 'Version_1')
     self.data_acquisition_management.create_data_producer.side_effect = BadRequest("Create cannot create document with ID: ")
     # Data Product
     dpt_obj = IonObject(RT.DataProduct, 
                         name='DPT_X', 
                         description='some new data product')
     # Data Producer
     dpr_obj = IonObject(RT.DataProducer, 
                         name='DP_X', 
                         description='some new data producer')
     dpr_obj._id = "SOME_OTHER_RR_ID"
     
     # test call
     with self.assertRaises(BadRequest) as cm:
         dp_id = self.data_product_management_service.create_data_product(dpt_obj, dpr_obj)
     
     # check results
     self.resource_registry.find_resources.assert_called_once_with(RT.DataProduct, None, dpt_obj.name, True)
     self.resource_registry.create.assert_called_once_with(dpt_obj)
     self.data_acquisition_management.create_data_producer.assert_called_once_with(dpr_obj)
     ex = cm.exception
     self.assertEqual(ex.message, "Create cannot create document with ID: ")
开发者ID:tgiguere,项目名称:coi-services,代码行数:27,代码来源:test_data_product_management_service.py

示例3: create_resource_commitment

# 需要导入模块: from pyon.public import IonObject [as 别名]
# 或者: from pyon.public.IonObject import _id [as 别名]
    def create_resource_commitment(self, org_id="", actor_id="", resource_id="", exclusive=False, expiration=0):
        """Creates a Commitment for the specified resource for a specified actor within
        the specified Org. Once shared, the resource is committed to the actor.
        """
        org_obj = self._validate_resource_id("org_id", org_id, RT.Org, optional=True)
        actor_obj = self._validate_resource_id("actor_id", actor_id, RT.ActorIdentity)
        resource_obj = self._validate_resource_id("resource_id", resource_id)

        if org_id:
            # Check that resource is shared in Org?
            pass

        res_commitment = IonObject(OT.ResourceCommitment, resource_id=resource_id, exclusive=exclusive)

        commitment = IonObject(RT.Commitment, name="", provider=org_id, consumer=actor_id, commitment=res_commitment,
                               description="Resource Commitment", expiration=str(expiration))

        commitment._id, commitment._rev = self.rr.create(commitment)

        # Creating associations to all related objects
        self.rr.create_association(actor_id, PRED.hasCommitment, commitment._id)
        self.rr.create_association(commitment._id, PRED.hasTarget, resource_id)

        if org_id:
            self.rr.create_association(org_id, PRED.hasCommitment, commitment._id)

            self.event_pub.publish_event(event_type=OT.ResourceCommitmentCreatedEvent,
                                         origin=org_id, origin_type="Org", sub_type=resource_obj.type_,
                                         description="The resource has been committed by the Org",
                                         resource_id=resource_id, org_name=org_obj.name,
                                         commitment_id=commitment._id, commitment_type=commitment.commitment.type_)

        return commitment._id
开发者ID:edwardhunter,项目名称:scioncc,代码行数:35,代码来源:org_management_service.py

示例4: _create_association

# 需要导入模块: from pyon.public import IonObject [as 别名]
# 或者: from pyon.public.IonObject import _id [as 别名]
    def _create_association(self, subject=None, predicate=None, obj=None, support_bulk=False):
        """
        Create an association between two IonObjects with a given predicate.
        Supports bulk mode
        """
        if self.bulk and support_bulk:
            if not subject or not predicate or not obj:
                raise BadRequest("Association must have all elements set: %s/%s/%s" % (subject, predicate, obj))
            if isinstance(subject, basestring):
                subject = self._get_resource_obj(subject)
            if "_id" not in subject:
                raise BadRequest("Subject id not available")
            subject_id = subject._id
            st = subject.type_

            if isinstance(obj, basestring):
                obj = self._get_resource_obj(obj)
            if "_id" not in obj:
                raise BadRequest("Object id not available")
            object_id = obj._id
            ot = obj.type_

            assoc_id = create_unique_association_id()
            assoc_obj = IonObject("Association",
                s=subject_id, st=st,
                p=predicate,
                o=object_id, ot=ot,
                ts=get_ion_ts())
            assoc_obj._id = assoc_id
            self.bulk_associations[assoc_id] = assoc_obj
            return assoc_id, '1-norev'
        else:
            return self.rr.create_association(subject, predicate, obj)
开发者ID:crchemist,项目名称:scioncc,代码行数:35,代码来源:preload.py

示例5: acquire_resource

# 需要导入模块: from pyon.public import IonObject [as 别名]
# 或者: from pyon.public.IonObject import _id [as 别名]
    def acquire_resource(self, sap=None):
        """Creates a Commitment Resource for the specified resource for a specified user withing the specified Org as defined in the
        proposal. Once shared, the resource is committed to the user. Throws a NotFound exception if none of the ids are found.

        @param proposal    AcquireResourceProposal
        @retval commitment_id    str
        @throws NotFound    object with specified id does not exist
        """
        param_objects = self._validate_parameters(org_id=sap.provider, user_id=sap.consumer, resource_id=sap.resource)

        if sap.type_ == OT.AcquireResourceExclusiveProposal:
            exclusive = True
        else:
            exclusive = False

        res_commitment = IonObject(OT.ResourceCommitment, resource_id=sap.resource, exclusive=exclusive)

        commitment = IonObject(RT.Commitment, name='', provider=sap.provider, consumer=sap.consumer, commitment=res_commitment,
             description='Resource Commitment', expiration=sap.expiration)

        commitment_id, commitment_rev = self.clients.resource_registry.create(commitment)
        commitment._id = commitment_id
        commitment._rev = commitment_rev

        #Creating associations to all objects
        self.clients.resource_registry.create_association(sap.provider, PRED.hasCommitment, commitment_id)
        self.clients.resource_registry.create_association(sap.consumer, PRED.hasCommitment, commitment_id)
        self.clients.resource_registry.create_association(sap.resource, PRED.hasCommitment, commitment_id)
        self.clients.resource_registry.create_association(sap.negotiation_id, PRED.hasContract, commitment_id)

        #TODO - publish some kind of event for creating a commitment

        return commitment_id
开发者ID:tomoreilly,项目名称:coi-services,代码行数:35,代码来源:org_management_service.py

示例6: load_mock_events

# 需要导入模块: from pyon.public import IonObject [as 别名]
# 或者: from pyon.public.IonObject import _id [as 别名]
    def load_mock_events(self, event_list):
        is_first = len(self.events) == 0

        for cnt, event_entry in enumerate(event_list):
            origin = event_entry.get('o', None)
            origin_type = event_entry.get('ot', None)
            sub_type = event_entry.get('st', None)
            attr = event_entry.get('attr', {})
            evt_obj = IonObject(event_entry['et'], origin=origin, origin_type=origin_type, sub_type=sub_type, ts_created=get_ion_ts(), **attr)
            evt_obj._id = str(cnt)
            self.events.append(evt_obj)

        if is_first:
            self.container_mock.event_repository.find_events = Mock()
            def side_effect(event_type=None, **kwargs):
                return [(evt._id, None, evt) for evt in reversed(self.events) if evt.type_ == event_type]
            self.container_mock.event_repository.find_events.side_effect = side_effect
开发者ID:MauriceManning,项目名称:coi-services,代码行数:19,代码来源:mockutil.py

示例7: load_mock_associations

# 需要导入模块: from pyon.public import IonObject [as 别名]
# 或者: from pyon.public.IonObject import _id [as 别名]
    def load_mock_associations(self, assoc_list):
        for assoc_entry in assoc_list:
            sid = assoc_entry[0]
            oid = assoc_entry[2]
            st = self.res_objs[sid]._get_type()
            ot = self.res_objs[oid]._get_type()
            ass_obj = IonObject('Association', s=sid, st=st, o=oid, ot=ot, p=assoc_entry[1], ts=get_ion_ts())
            ass_obj._id = "%s_%s_%s" % (sid, assoc_entry[1], oid)
            self.associations.append(ass_obj)

        self.container_mock.resource_registry.find_associations = Mock()
        def side_effect(subject=None, predicate=None, obj=None, **kwargs):
            if predicate:
                assocs = [assoc for assoc in self.associations if assoc.p == predicate]
            else:
                assocs = self.associations
            return assocs
        self.container_mock.resource_registry.find_associations.side_effect = side_effect
开发者ID:MauriceManning,项目名称:coi-services,代码行数:20,代码来源:mockutil.py

示例8: load_mock_resources

# 需要导入模块: from pyon.public import IonObject [as 别名]
# 或者: from pyon.public.IonObject import _id [as 别名]
    def load_mock_resources(self, res_list):
        for res_entry in res_list:
            name = res_entry.get('name', 'NO_NAME')
            lcstate = res_entry.get('lcstate', 'DEPLOYED_AVAILABLE')
            attr = res_entry.get('attr', {})
            res_id = create_unique_resource_id()
            res_id = res_entry.get('_id', res_id)
            res_obj = IonObject(res_entry['rt'], name=name, **attr)
            res_obj._id = res_id
            res_obj.lcstate = lcstate
            res_obj.ts_created = get_ion_ts()
            res_obj.ts_updated = res_obj.ts_created

            self.res_objs[res_id] = res_obj
            self.res_id_list.append(res_id)

        self.container_mock.resource_registry.read_mult = Mock()
        def side_effect(res_id_list):
            return [self.res_objs[res_id] for res_id in res_id_list]
        self.container_mock.resource_registry.read_mult.side_effect = side_effect
开发者ID:blazetopher,项目名称:coi-services,代码行数:22,代码来源:mockutil.py

示例9: process_new_resource

# 需要导入模块: from pyon.public import IonObject [as 别名]
# 或者: from pyon.public.IonObject import _id [as 别名]
def process_new_resource(restype):
    try:
        restype = str(restype)
        res = IonObject(restype)
        res._id = "NEW"
        for k,v in request.args.iteritems():
            if '.' in k:
                key = None
                obj = res
                attrs = k.split('.')
                while len(attrs):
                    key = attrs.pop(0)
                    if not len(attrs):
                        if hasattr(obj,key):
                            setattr(obj,key,v)
                            break
                    if hasattr(obj,key):
                        obj = getattr(obj,key)
                    else:
                        break

            elif hasattr(res,k):
                setattr(res,k,v)

        fragments = [
            build_standard_menu(),
            "<h1>Create New %s</h1>" % (build_type_link(restype)),
            "<form name='edit' action='/cmd/update?rid=NEW&restype=%s' method='post'>" % restype,
        ]
        fragments.extend(build_editable_resource(res, is_new=True))
        fragments.append("<p><input type='reset'/> <input type='submit' value='Create'/></p>")
        fragments.append("</form>")
        fragments.append("<p>%s</p>" % build_link("Back to List Page", "/list/%s" % restype)),

        content = "\n".join(fragments)
        return build_page(content)

    except NotFound:
        return flask.redirect("/")
    except Exception as e:
        return build_error_page(traceback.format_exc())
开发者ID:mkl-,项目名称:scioncc,代码行数:43,代码来源:admin_ui.py

示例10: acquire_resource

# 需要导入模块: from pyon.public import IonObject [as 别名]
# 或者: from pyon.public.IonObject import _id [as 别名]
    def acquire_resource(self, org_id='', user_id='', resource_id=''):
        """Acquire the specified resource for a specified user withing the specified Org. Once shared, the resource is
        committed to the user. Throws a NotFound exception if none of the ids are found.

        @param org_id    str
        @param user_id    str
        @param resource_id    str
        @retval success    bool
        @throws NotFound    object with specified id does not exist
        """
        param_objects = self._validate_parameters(org_id=org_id, user_id=user_id, resource_id=resource_id)

        commitment = IonObject(RT.ResourceCommitment, name='', org_id=org_id, user_id=user_id, resource_id=resource_id,
            description='Resource Commitment')

        commitment_id, commitment_rev = self.clients.resource_registry.create(commitment)
        commitment._id = commitment_id
        commitment._rev = commitment_rev
        self.clients.resource_registry.create_association(user_id, PRED.hasCommitment, commitment)
        self.clients.resource_registry.create_association(resource_id, PRED.hasCommitment, commitment)

        return True
开发者ID:seman,项目名称:coi-services,代码行数:24,代码来源:org_management_service.py

示例11: process_new_resource

# 需要导入模块: from pyon.public import IonObject [as 别名]
# 或者: from pyon.public.IonObject import _id [as 别名]
def process_new_resource(restype):
    try:
        restype = str(restype)
        res = IonObject(restype)
        res._id = "NEW"

        fragments = [
            build_standard_menu(),
            "<h1>Create New %s</h1>" % (build_type_link(restype)),
            "<form name='edit' action='/cmd/update?rid=NEW&restype=%s' method='post'>" % restype,
        ]
        fragments.extend(build_editable_resource(res, is_new=True))
        fragments.append("<p><input type='reset'/> <input type='submit' value='Create'/></p>")
        fragments.append("</form>")
        fragments.append("<p>%s</p>" % build_link("Back to List Page", "/list/%s" % restype)),

        content = "\n".join(fragments)
        return build_page(content)

    except NotFound:
        return flask.redirect("/")
    except Exception, e:
        return build_error_page(traceback.format_exc())
开发者ID:ooici-eoi,项目名称:coi-services,代码行数:25,代码来源:containerui.py

示例12: create_resource_commitment

# 需要导入模块: from pyon.public import IonObject [as 别名]
# 或者: from pyon.public.IonObject import _id [as 别名]
    def create_resource_commitment(self, org_id='', actor_id='', resource_id='', exclusive=False, expiration=0):
        """Creates a Commitment Resource for the specified resource for a specified actor withing the specified Org. Once shared,
        the resource is committed to the actor. Throws a NotFound exception if none of the ids are found.

        @param org_id    str
        @param actor_id    str
        @param resource_id    str
        @param exclusive    bool
        @param expiration    int
        @retval commitment_id    str
        @throws NotFound    object with specified id does not exist
        """
        param_objects = self._validate_parameters(org_id=org_id, actor_id=actor_id, resource_id=resource_id)
        org = param_objects['org']
        actor = param_objects['actor']
        resource = param_objects['resource']

        res_commitment = IonObject(OT.ResourceCommitment, resource_id=resource_id, exclusive=exclusive)

        commitment = IonObject(RT.Commitment, name='', provider=org_id, consumer=actor_id, commitment=res_commitment,
             description='Resource Commitment', expiration=str(expiration))

        commitment_id, commitment_rev = self.clients.resource_registry.create(commitment)
        commitment._id = commitment_id
        commitment._rev = commitment_rev

        #Creating associations to all related objects
        self.clients.resource_registry.create_association(org_id, PRED.hasCommitment, commitment_id)
        self.clients.resource_registry.create_association(actor_id, PRED.hasCommitment, commitment_id)
        self.clients.resource_registry.create_association(resource_id, PRED.hasCommitment, commitment_id)

        self.event_pub.publish_event(event_type=OT.ResourceCommitmentCreatedEvent, origin=org_id, origin_type='Org', sub_type=resource.type_,
            description='The resource has been committed by the Org', resource_id=resource_id, org_name=org.name,
            commitment_id=commitment._id, commitment_type=commitment.commitment.type_)

        return commitment_id
开发者ID:MauriceManning,项目名称:coi-services,代码行数:38,代码来源:org_management_service.py


注:本文中的pyon.public.IonObject._id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。