Skip to content

Commit

Permalink
Fill ConditionDataStorage.isSafeToDelete()
Browse files Browse the repository at this point in the history
Fix #107
  • Loading branch information
renyuneyun committed May 20, 2018
1 parent 59338a3 commit a2e4f30
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,25 @@ public static ConditionDataStorage getInstance(Context context) {

@Override
boolean isSafeToDelete(String name) {
ScriptDataStorage scriptDataStorage = ScriptDataStorage.getInstance(context);
for (String scriptName : scriptDataStorage.list()) {
ScriptStructure script = scriptDataStorage.get(scriptName);
if (script.isCondition()) {
if (script.getCondition().getName().equals(name)) {
return false;
}
}
}
ScenarioDataStorage scenarioDataStorage = ScenarioDataStorage.getInstance(context);
for (String scenarioName : scenarioDataStorage.list()) {
ScenarioStructure scenario = scenarioDataStorage.get(scenarioName);
EventData eventData = scenario.getEventData();
if (eventData instanceof ConditionEventEventData) {
if (name.equals(((ConditionEventEventData) eventData).conditionName)) {
return false;
}
}
}
return true;
}

Expand Down

0 comments on commit a2e4f30

Please sign in to comment.