28
28
import javax .swing .SwingUtilities ;
29
29
30
30
import ca .phon .app .log .BufferPanel ;
31
+ import ca .phon .app .log .LogUtil ;
31
32
import ca .phon .app .project .SessionMerger ;
32
33
import ca .phon .project .Project ;
33
34
import ca .phon .session .DateFormatter ;
37
38
import ca .phon .session .SessionFactory ;
38
39
import ca .phon .session .SessionPath ;
39
40
import ca .phon .ui .decorations .DialogHeader ;
41
+ import ca .phon .ui .wizard .BreadcrumbWizardFrame ;
40
42
import ca .phon .ui .wizard .WizardFrame ;
41
43
import ca .phon .ui .wizard .WizardStep ;
42
44
import ca .phon .worker .PhonWorker ;
@@ -171,25 +173,6 @@ public void run() {
171
173
*/
172
174
private void doMerge () throws IOException {
173
175
final PrintWriter out = new PrintWriter (new OutputStreamWriter (console .getLogBuffer ().getStdOutStream (), "UTF-8" ));
174
- // org.apache.logging.log4j.LogManager.getLogger("ca.phon").addHandler( new Handler() {
175
- //
176
- // @Override
177
- // public void publish(LogRecord record) {
178
- // out.println(record.getMessage());
179
- // out.flush();
180
- // }
181
- //
182
- // @Override
183
- // public void flush() {
184
- // }
185
- //
186
- // @Override
187
- // public void close() throws SecurityException {
188
- //
189
- // }
190
- //
191
- // });
192
-
193
176
String corpus = step1 .getMergedCorpusName ();
194
177
String session = step1 .getMergedSessionName ();
195
178
@@ -200,24 +183,29 @@ private void doMerge() throws IOException {
200
183
// first make sure we have a corpus
201
184
if (!project .getCorpora ().contains (step1 .getMergedCorpusName ())) {
202
185
203
- LOGGER .info ("Creating corpus '" + corpus + "'" );
186
+ out .println ("Creating corpus '" + corpus + "'" );
187
+ out .flush ();
204
188
try {
205
189
project .addCorpus (corpus , "" );
206
190
} catch (IOException e ) {
207
- LOGGER .error ( e .getLocalizedMessage (), e );
191
+ out .println (e .getLocalizedMessage ());
192
+ out .flush ();
193
+ LogUtil .severe ( e .getLocalizedMessage (), e );
208
194
return ;
209
195
}
210
196
211
197
}
212
198
213
199
// check session name
214
200
if (project .getCorpusSessions (corpus ).contains (session )) {
215
- LOGGER .error ("A session with name '" + corpus + "." + session + "' already exists." );
201
+ out .println ("A session with name '" + corpus + "." + session + "' already exists." );
202
+ out .flush ();
216
203
return ;
217
204
}
218
205
219
206
// create the new session
220
- LOGGER .info ("Creating session '" + corpus + "." + session + "'" );
207
+ out .println ("Creating session '" + corpus + "." + session + "'" );
208
+ out .flush ();
221
209
final SessionFactory factory = SessionFactory .newFactory ();
222
210
try {
223
211
final SessionMerger merger = new SessionMerger (project );
@@ -243,14 +231,16 @@ private void doMerge() throws IOException {
243
231
final Session t = step2 .getSessionAtLocation (loc );
244
232
final RecordFilter filter = step2 .getFilterForLocation (loc );
245
233
246
- LOGGER .info ("Merging data from session '" + loc .getCorpus () + "." + loc .getSession () + "'" );
234
+ out .println ("Merging data from session '" + loc .getCorpus () + "." + loc .getSession () + "'" );
235
+ out .flush ();
247
236
if (checkDate ) {
248
237
String tDate = pdf .format (t .getDate ());
249
238
if (mergedDate == null ) {
250
239
mergedDate = tDate ;
251
240
} else {
252
241
if (!mergedDate .equals (tDate )) {
253
- LOGGER .warn ("Session dates do not match, setting merged session date to today." );
242
+ out .println ("Session dates do not match, setting merged session date to today." );
243
+ out .flush ();
254
244
mergedDate = pdf .format (LocalDate .now ());
255
245
checkDate = false ;
256
246
}
@@ -262,7 +252,8 @@ private void doMerge() throws IOException {
262
252
mergedMedia = t .getMediaLocation ();
263
253
} else {
264
254
if (!mergedMedia .equals (t .getMediaLocation ())) {
265
- LOGGER .warn ("Session media locations do not match, leaving media field blank." );
255
+ out .println ("Session media locations do not match, leaving media field blank." );
256
+ out .flush ();
266
257
mergedMedia = "" ;
267
258
checkMedia = false ;
268
259
}
@@ -283,19 +274,23 @@ private void doMerge() throws IOException {
283
274
if (mergedMedia != null ) {
284
275
mergedSession .setMediaLocation (mergedMedia );
285
276
}
286
-
287
- LOGGER .info ("Saving session..." );
277
+
278
+ out .println ("Saving session..." );
279
+ out .flush ();
288
280
289
281
// save
290
282
final UUID writeLock = project .getSessionWriteLock (mergedSession );
291
283
project .saveSession (mergedSession , writeLock );
292
284
project .releaseSessionWriteLock (mergedSession , writeLock );
293
285
294
- LOGGER .info ("Finished. New session has " + mergedSession .getRecordCount () + " records." );
286
+ out .println ("Finished. New session has " + mergedSession .getRecordCount () + " records." );
287
+ out .flush ();
295
288
} catch (IOException e ) {
296
- LOGGER .error ( e .getLocalizedMessage (), e );
289
+ out .println (e .getLocalizedMessage ());
290
+ LogUtil .severe (e );
297
291
throw e ;
298
292
} finally {
293
+ out .flush ();
299
294
out .close ();
300
295
}
301
296
0 commit comments