Skip to content

Commit

Permalink
Fix for non updated tenantId on Definitions import
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasponce committed Feb 11, 2016
1 parent 08f6d5a commit 74c88b0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,24 @@ public void setActions(List<ActionDefinition> actions) {
this.actions = actions;
}

public void updateTenant(String tenantId) {
if (triggers != null) {
for (FullTrigger t : triggers) {
if (t.getTrigger() != null) {
t.getTrigger().setTenantId(tenantId);
t.check();
}
}
}
if (actions != null) {
for (ActionDefinition a : actions) {
if (a != null) {
a.setTenantId(tenantId);
}
}
}
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ public void setConditions(List<Condition> conditions) {
checkConditions();
}

public void check() {
checkDampenings();
checkConditions();
}

private void checkDampenings() {
if (trigger != null && !isEmpty(dampenings) && !isEmpty(trigger.getId()) && !isEmpty(trigger.getTenantId())) {
for (Dampening d : dampenings) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2879,6 +2879,7 @@ public Definitions importDefinitions(String tenantId, Definitions definitions, I
if (null == strategy) {
throw new IllegalArgumentException("ImportType startegy must be not null");
}
definitions.updateTenant(tenantId);
Definitions imported = new Definitions();
try {
Collection<Trigger> existingTriggers = selectTriggers(tenantId);
Expand Down

0 comments on commit 74c88b0

Please sign in to comment.