Skip to content

Commit ead96a3

Browse files
Sahar MehrpourSahar Mehrpour
authored andcommitted
rule generation is added
1 parent 89b4fcd commit ead96a3

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

src/FileChangeManager.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ private void setRuleIndexText(String ruleIndex, String ruleText) {
6666
return;
6767
}
6868
}
69+
70+
// new Rule
71+
this.ruleIndexText.add(new ArrayList<>(Arrays.asList(ruleIndex, ruleText)));
72+
6973
}
7074

7175

@@ -291,6 +295,17 @@ void processReceivedMessages(JsonObject messageAsJson) {
291295

292296
//TODO first add the rule, then write it in the file
293297

298+
String newRuleIndex = Integer.toString(messageAsJson.get("data").getAsJsonObject().get("index").getAsInt());
299+
String newRuleText = messageAsJson.get("data").getAsJsonObject().get("ruleText").getAsJsonObject().toString();
300+
301+
this.setRuleIndexText(newRuleIndex, newRuleText);
302+
this.writeToFile("ruleJson.txt");
303+
304+
// send message
305+
s.sendToAll(MessageProcessor.encodeData(new Object[]{"IDEA", "WEB", "NEW_RULE",
306+
MessageProcessor.encodeModifiedRule(new Object[]{newRuleIndex, newRuleText})
307+
}).toString());
308+
294309
break;
295310

296311
}

0 commit comments

Comments
 (0)