public Trigger getTopParent() { Trigger tmp = this; while (tmp.getParent() != null) { tmp = tmp.getParent(); } return tmp; }
private List<String> convertTriggersToNames(List<Trigger> triggers) { List<String> names = new ArrayList<String>(); for (Trigger t : triggers) { names.add(t.getName()); } return names; }
private String getTableTriggerId(Trigger g) { if (g == null) return null; String id = g.getName().replace(".", "-"); Trigger group = g; while ((group = group.getParent()) != null) { id = group.getName().replace(".", "-") + "." + id; } return id; }
/** * Used by Core-TriggerDaemon to determine when to store TriggerUnits file Used by * Core-ScriptDaemon to determine when to delete TriggerUnits file * * @return */ public boolean hasAnyParentScript() { Trigger tmp = this.getParent(); while (tmp != null) { if (tmp.getScript() != null) { return true; } else { tmp = tmp.getParent(); } } return false; }
private void getTrigger(Unittype unittype, List<TableElement> list, Trigger trigger, Integer nbsp) throws IllegalArgumentException, SecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException { String tableTriggerId = getTableTriggerId(trigger); Integer str = nbsp; if (trigger != null && trigger.getChildren().size() > 0) { list.add(new TableElement(tableTriggerId, str, trigger, true)); List<String> childrenTriggernames = convertTriggersToNames(trigger.getChildren()); Collections.sort(childrenTriggernames, String.CASE_INSENSITIVE_ORDER); for (String childrenTriggername : childrenTriggernames) { Trigger g = unittype.getTriggers().getByName(childrenTriggername); getTrigger(unittype, list, g, nbsp + WebConstants.PARAMETERS_NEXT_INDENTATION); } } else list.add(new TableElement(tableTriggerId, str, trigger, false)); }
private List<Trigger> getAllChildrenRec(Trigger g) { List<Trigger> groups = new ArrayList<Trigger>(); for (Trigger childrenGroup : g.getChildren()) { groups.add(childrenGroup); groups.addAll(getAllChildrenRec(childrenGroup)); } return groups; }
public void setParent(Trigger newParent) { if (this.parent != null) parent.removeChild(this); if (newParent == null) { this.parent = newParent; return; } if (newParent.getTriggerType() == TRIGGER_TYPE_BASIC) throw new IllegalArgumentException("Parent trigger must be a COMPOSITE trigger"); Trigger tmpParent = newParent; while (tmpParent != null) { if (tmpParent.getId().equals(this.getId())) { throw new IllegalArgumentException( "Parent reference loop occurred for " + tmpParent.getName() + " (" + tmpParent.getId() + ")"); } tmpParent = tmpParent.getParent(); } this.parent = newParent; this.parent.addChild(this); }