Beispiel #1
0
    def operation(self):
        """
        Goal of this function is to check all the InternalTip
        and create the Tips for the receiver needing.

        Create the ReceiverTip only, because WhistleBlowerTip is
        created when submission is finalized, along with the receipt
        exchange.

        Only the Receiver marked as first tier receiver has a Tip now,
        the receiver marked as tier 2 (if configured in the context)
        had their Tip only when the escalation_threshold has reached 
        the requested value.
        """
        log.debug("[D]", self.__class__, 'operation', datetime.today().ctime())

        internaltip_iface = InternalTip()
        receivertip_iface = ReceiverTip()

        internal_id_list = yield internaltip_iface.get_newly_generated()

        if len(internal_id_list):
            log.debug("TipSched: found %d new Tip: %s" % (len(internal_id_list), str(internal_id_list)))

        for id in internal_id_list:
            yield receivertip_iface.create_receiver_tips(id, 1)
            yield internaltip_iface.flip_mark(id, u'first')

        # loops over the InternalTip and checks the escalation threshold
        # It may require the creation of second-step Tips
        escalated_id_list = yield internaltip_iface.get_newly_escalated()

        if len(escalated_id_list):
            log.debug("TipSched: %d Tip are escalated: %s" % (len(escalated_id_list), str(escalated_id_list)))

            # This event would be notified as system Comment
            comment_iface = Comment()

            for id in escalated_id_list:
                # yield comment_iface.add_comment(id, u"Escalation threshold has been reached", u'system')
                yield receivertip_iface.create_receiver_tips(id, 2)
                yield internaltip_iface.flip_mark(id, u'second')
Beispiel #2
0
    def tip_creation(self):

        store = self.getStore()

        internaltip_iface = InternalTip(store)
        receiver_iface = Receiver(store)

        internal_tip_list = internaltip_iface.get_itips_by_maker(u'new', False)

        if len(internal_tip_list):
            print "TipSched: found %d new Tip" % len(internal_tip_list)

        for internaltip_desc in internal_tip_list:

            for receiver_gus in internaltip_desc['receivers']:

                try:
                    receiver_desc = receiver_iface.get_single(receiver_gus)
                except ReceiverGusNotFound:
                    # Log error, a receiver has been removed before get the Tip
                    continue

                # check if the Receiver Tier is the first
                if int(receiver_desc['receiver_level']) != 1:
                    continue

                receivertip_obj = ReceiverTip(store)
                receivertip_desc = receivertip_obj.new(internaltip_desc, receiver_desc)
                print "Created rTip", receivertip_desc['tip_gus'], "for", receiver_desc['name'], \
                    "in", internaltip_desc['context_gus']

            internaltip_iface.flip_mark(internaltip_desc['internaltip_id'], internaltip_iface._marker[1])

        # Escalation is not working at the moment, may be well engineered the function
        # before, permitting various layer of receivers.
        #
        # loops over the InternalTip and checks the escalation threshold
        # It may require the creation of second-step Tips
        escalated_itip_list = internaltip_iface.get_itips_by_maker(internaltip_iface._marker[1], True)

        if len(escalated_itip_list):
            print "TipSched: %d Tip are escalated" % len(escalated_itip_list)

        for eitip in escalated_itip_list:
            eitip_id = int(eitip['internaltip_id'])

            # This event has to be notified as system Comment
            Comment(store).new(eitip_id, u"Escalation threshold has been reached", u'system')

            for receiver_gus in eitip['receivers']:

                try:
                    receiver_desc = receiver_iface.get_single(receiver_gus)
                except ReceiverGusNotFound:
                    # Log error, a receiver has been removed before get the Tip
                    continue

                # check if the Receiver Tier is the second
                if int(receiver_desc['receiver_level']) != 2:
                    continue

                receivertip_obj = ReceiverTip(store)
                receivertip_desc = receivertip_obj.new(eitip, receiver_desc)
                print "Created 2nd tir rTip", receivertip_desc['tip_gus'], "for", receiver_desc['name'], \
                    "in", eitip['context_gus']

            internaltip_iface.flip_mark(eitip_id, internaltip_iface._marker[2])
Beispiel #3
0
    def operation(self):
        """
        Goal of this function is to check all the InternalTip
        and create the Tips for the receiver needing.

        Create the ReceiverTip only, because WhistleBlowerTip is
        created when submission is finalized, along with the receipt
        exchange.

        Only the Receiver marked as first tier receiver has a Tip now,
        the receiver marked as tier 2 (if configured in the context)
        had their Tip only when the escalation_threshold has reached 
        the requested value.
        """

        internaltip_iface = InternalTip()
        receivertip_iface = ReceiverTip()
        receiver_iface = Receiver()

        internal_tip_list = yield internaltip_iface.get_itips_by_maker(u'new', False)

        # TODO for each itip
            # TODO get file status


        if len(internal_tip_list):
            log.debug("TipSched: found %d new Tip" % len(internal_tip_list) )

        for internaltip_desc in internal_tip_list:

            for receiver_gus in internaltip_desc['receivers']:

                receiver_desc = yield receiver_iface.get_single(receiver_gus)

                # check if the Receiver Tier is the first
                if int(receiver_desc['receiver_level']) != 1:
                    continue

                receivertip_desc = yield receivertip_iface.new(internaltip_desc, receiver_desc)
                print "Created rTip", receivertip_desc['tip_gus'], "for", receiver_desc['name']

            try:
                # switch the InternalTip.mark for the tier supplied
                yield internaltip_iface.flip_mark(internaltip_desc['internaltip_id'], internaltip_iface._marker[1])
            except:
                # ErrorTheWorldWillEndSoon("Goodbye and thanks for all the fish")
                print "Internal error"
                raise


        # Escalation is not working at the moment, may be well engineered the function
        # before, permitting various layer of receivers.
        #
        # loops over the InternalTip and checks the escalation threshold
        # It may require the creation of second-step Tips
        escalated_itip_list = yield internaltip_iface.get_itips_by_maker(internaltip_iface._marker[1], True)

        if len(escalated_itip_list):
            log.debug("TipSched: %d Tip are escalated" % len(escalated_itip_list) )

        # This event has to be notified as system Comment
        comment_iface = Comment()

        for itip in escalated_itip_list:
            itip_id = int(itip['internaltip_id'])

            yield comment_iface.add_comment(itip_id, u"Escalation threshold has been reached", u'system')
            # XXX missing part new
            yield internaltip_iface.flip_mark(itip_id, internaltip_iface._marker[2])
            log.debug("TipSched: escalated %d ReceiverTip for the iTip %d" % (receivertip_created, itip_id))