@Override public boolean visitSchemaRuleCommand(Command.SchemaRuleCommand command) throws IOException { Collection<DynamicRecord> recordsBefore = new ArrayList<>(); readDynamicRecords(recordsBefore, COLLECTION_DYNAMIC_RECORD_ADDER); Collection<DynamicRecord> recordsAfter = new ArrayList<>(); readDynamicRecords(recordsAfter, COLLECTION_DYNAMIC_RECORD_ADDER); byte isCreated = channel.get(); if (1 == isCreated) { for (DynamicRecord record : recordsAfter) { record.setCreated(); } } // read and ignore transaction id which is not used anymore channel.getLong(); SchemaRule rule = first(recordsAfter).inUse() ? readSchemaRule(recordsAfter) : readSchemaRule(recordsBefore); command.init(recordsBefore, recordsAfter, rule); return false; }
private Collection<DynamicRecord> serialize( SchemaRule rule, long id, boolean inUse, boolean created) { RecordSerializer serializer = new RecordSerializer(); serializer = serializer.append(rule); DynamicRecord record = new DynamicRecord(id); record.setData(serializer.serialize()); if (created) { record.setCreated(); } if (inUse) { record.setInUse(true); } return Arrays.asList(record); }