Changeset 2287 for trunk/autoquest-ui-core/src/main/java/de/ugoe/cs
- Timestamp:
- 01/28/20 15:59:17 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-ui-core/src/main/java/de/ugoe/cs/autoquest/commands/sequences/CMDcheckEventTimestamps.java
r1438 r2287 18 18 import java.util.LinkedList; 19 19 import java.util.List; 20 import java.util.ListIterator; 20 21 import java.util.logging.Level; 21 22 … … 84 85 Console.println("sequences with timestamp issues listed"); 85 86 } 87 else if ("sort".equals(command)) { 88 sortEventsUsingTimestamps(sequences, newSequencesName); 89 } 86 90 else if ("delete".equals(command)) { 87 91 deleteSequencesWithInvalidTimestamps(sequences, newSequencesName); … … 156 160 } 157 161 } 162 } 163 } 164 165 /** 166 * <p> 167 * sorts events in sequences with invalid timestamps from the provided collection of sequences and 168 * stores them under new name 169 * </p> 170 * 171 * @param sequences the collection of sequences to sort the events in 172 * @param newSequencesName the name for the new corrected collection of sequences 173 */ 174 private void sortEventsUsingTimestamps(Collection<List<Event>> sequences, 175 String newSequencesName) 176 { 177 Collection<List<Event>> newSequences = new LinkedList<List<Event>>(); 178 179 for (List<Event> sequence : sequences) { 180 181 List<Event> newSequence = new LinkedList<>(); 182 183 for (Event currentEvent : sequence) { 184 boolean added = false; 185 186 ListIterator<Event> iterator = newSequence.listIterator(); 187 188 while (iterator.hasNext()) { 189 if (iterator.next().getTimestamp() > currentEvent.getTimestamp()) { 190 iterator.previous(); 191 iterator.add(currentEvent); 192 added = true; 193 break; 194 }; 195 } 196 197 if (!added) { 198 newSequence.add(currentEvent); 199 } 200 201 } 202 203 newSequences.add(newSequence); 204 } 205 206 Console.traceln(Level.WARNING, sequences.size() + 207 " sequences sorted based on event timestamps"); 208 209 if (GlobalDataContainer.getInstance().addData(newSequencesName, newSequences)) { 210 CommandHelpers.dataOverwritten(newSequencesName); 158 211 } 159 212 }
Note: See TracChangeset
for help on using the changeset viewer.