Add a new trigger
        :param trigger: The Trigger object
        :type  trigger: Trigger
165892
def add_trigger(self, trigger):
        
        # Make sure triggers are re-sorted before a new reply can be requested
        self.sorted = False

        # If no trigger with this priority level has been defined yet, create a new list
        if trigger.priority not in self._triggers:
            self._triggers[trigger.priority] = [trigger]
            return

        # Otherwise, add this trigger to an existing priority list
        self._triggers[trigger.priority].append(trigger)
1362140
def save(self, *args, **kwargs):
        
        try:
            prev_instance = self.__class__.objects.get(pk=self.pk)
        except self.DoesNotExist:
            prev_instance = None

        if prev_instance is None or (not prev_instance.is_active and self.is_active or
                                     self.schedule != prev_instance.schedule):
            self.update_next_trigger_at()

        super(ScheduleMixin, self).save(*args, **kwargs)
1193920
def set_trigger_event(type, new_val)
      raise JSS::InvalidDataError, "Trigger type must be one of #{TRIGGER_EVENTS.keys.join(', ')}" unless TRIGGER_EVENTS.key?(type)
      if type == :custom
        raise JSS::InvalidDataError, 'Custom triggers must be Strings' unless new_val.is_a? String
      else
        raise JSS::InvalidDataError, 'Non-custom triggers must be true or false' unless JSS::TRUE_FALSE.include? new_val
      end
      @trigger_events[TRIGGER_EVENTS[type]] = new_val
      @need_to_update = true
    end
529265
public TriggerContext on(Collection<Trigger> triggers) {
        if (triggers != null) {
            addedTriggers.addAll(triggers);
        }

        // Stay in the same context and re-use the same instance because no type has changed
        return this;
    }
1358232
public DataProviderContext on(final Trigger... triggers) {
        if (triggers != null) {
            Collections.addAll(registeredTriggers, triggers);
        }
        return this;
    }
394939
public function editTrigger($trigger_id = null)
    {
        $this->setTrigger($trigger_id);
        $this->setTitleEditTrigger();
        $this->setBreadcrumbEditTrigger();

        $this->setData('trigger', $this->data_trigger);
        $this->setData('can_delete', $this->canDeleteTrigger());
        $this->setData('conditions', $this->condition->getHandlers());
        $this->setData('operators', $this->condition->getOperators());

        $this->submitEditTrigger();

        $this->setDataEditTrigger();
        $this->outputEditTrigger();
    }
1294791
def add_event(self, event, prepend=False):
        
        if prepend:
            self._events.insert(0, event)
        else:
            self._events.append(event)
355452
private static void addTriggers()
   {
      if (!PERSISTENCE_ENABLED)
      {
         return;
      }
      Runtime.getRuntime().addShutdownHook(new Thread("JCRStatisticsManager-Hook")
      {
         @Override
         public void run()
         {
            printData();
         }
      });
      Thread t = new Thread("JCRStatisticsManager-Writer")
      {
         @Override
         public void run()
         {
            while (true)
            {
               try
               {
                  sleep(PERSISTENCE_TIMEOUT);
               }
               catch (InterruptedException e)
               {
                  LOG.debug("InterruptedException", e);
               }
               printData();
            }
         }
      };
      t.setDaemon(true);
      t.start();
   }
69970
def trigger(self, *args, **kwargs):
		
		current = self.name.split('/')
		while current:
			name = '/'.join(current)
			current.pop()
			if name in self.context.handlers:
				self.all_handlers += [(name, h) for h in self.context.handlers[name]] 
				if name == self.name:
					self.handlers += self.context.handlers[name]

		for name, handler in self.all_handlers:
			res = handler(self, *args, **kwargs)
			self.all_executed += 1
			self.all_result.append(res)
			if name == self.name:
				self.executed += 1
				self.result.append(res)
			if self.stopped:
				break

		self.all_handlers = [h for name, h in self.all_handlers]
1354243
def trigger(self, target: str, trigger: str, parameters: Dict[str, Any]={}):
		
		pass
525964
protected function wizardAddTrigger()
    {
        $this->validatePrompt('name', $this->text('Name'), 'trigger');
        $this->validatePrompt('store_id', $this->text('Store'), 'trigger');
        $this->validatePromptList('data.conditions', $this->text('Conditions'), 'trigger');
        $this->validatePrompt('status', $this->text('Status'), 'trigger', 0);
        $this->validatePrompt('weight', $this->text('Weight'), 'trigger', 0);
        $this->setSubmittedList('data.conditions');

        $this->validateComponent('trigger');
        $this->addTrigger();
    }
740757
def update_group(self, group_id, trigger):
        
        data = self._serialize_object(trigger)
        self._put(self._service_url(['triggers', 'groups', group_id]), data, parse_json=False)
379589
private void hookToTrigger(final T trigger) {
        // Hook to trigger only if not already done (the same trigger adatper will be used if it was already hooked)
        if (!triggersToTriggerAdapters.containsKey(trigger)) {
            final TriggerListener triggerAdapter = new TriggerAdapter(trigger);
            triggersToTriggerAdapters.put(trigger, triggerAdapter);
            trigger.addTriggerListener(triggerAdapter);
        }
    }
298808
@Override
  public synchronized void addTrigger(final Trigger t) throws TriggerLoaderException {
    logger.info("Inserting trigger " + t.toString() + " into db.");

    final SQLTransaction<Long> insertAndGetLastID = transOperator -> {
      transOperator.update(ADD_TRIGGER, DateTime.now().getMillis());
      // This commit must be called in order to unlock trigger table and have last insert ID.
      transOperator.getConnection().commit();
      return transOperator.getLastInsertId();
    };

    try {
      final long id = this.dbOperator.transaction(insertAndGetLastID);
      t.setTriggerId((int) id);
      updateTrigger(t);
      logger.info("uploaded trigger " + t.getDescription());
    } catch (final SQLException ex) {
      logger.error("Adding Trigger " + t.getTriggerId() + " failed.");
      throw new TriggerLoaderException("trigger id is not properly created.", ex);
    }
  }
594624
protected function updateTrigger()
    {
        $this->controlAccess('trigger_edit');

        if ($this->trigger->update($this->data_trigger['trigger_id'], $this->getSubmitted())) {
            $this->redirect('admin/settings/trigger', $this->text('Trigger has been updated'), 'success');
        }

        $this->redirect('', $this->text('Trigger has not been updated'), 'warning');
    }
1266606
function(type, originalEvent) {
//		this.debug("_trigger(" + type + ")", ctx);
		var ctx = this._makeHookContext(this, originalEvent),
			res = this.widget._trigger(type, originalEvent, ctx);

		if(res !== false && ctx.result !== undefined){
			return ctx.result;
		}
		return res;
	}
1015820
public void setTriggers(List<Trigger> triggers) {
        this.triggers.clear();
        if (triggers != null) {
            this.triggers.addAll(triggers);
        }
    }