Skip to main content
summaryrefslogtreecommitdiffstats
blob: c5da6e3f18d5e40871af51f16504d1b0a227293d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*******************************************************************************
 * Copyright (c) 2004, 2007 Boeing.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Boeing - initial API and implementation
 *******************************************************************************/
package org.eclipse.osee.define.traceability.operations;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.osee.define.traceability.data.TraceMark;
import org.eclipse.osee.define.traceability.data.TraceUnit;
import org.eclipse.osee.framework.core.util.XResultData;
import org.eclipse.osee.framework.jdk.core.util.AHTML;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.framework.ui.skynet.results.XResultDataUI;

/**
 * @author Roberto E. Escobar
 */
public final class TraceUnitReportProcessor implements ITraceUnitProcessor {
   private long startTime;
   private long startMemory;
   private final XResultData resultData;

   public TraceUnitReportProcessor() {
      this.resultData = new XResultData();
      startTime = System.currentTimeMillis();
      startMemory = Runtime.getRuntime().totalMemory();
   }

   @Override
   public void clear() {
      startTime = 0;
      startMemory = 0;
   }

   @Override
   public void initialize(IProgressMonitor monitor) {
      resultData.addRaw(AHTML.beginMultiColumnTable(95, 1));
      resultData.addRaw(AHTML.addHeaderRowMultiColumnTable(new String[] {
         "Test Unit Type",
         "Test Unit Name",
         "Trace Type",
         "Trace Mark"}));
   }

   @Override
   public void process(IProgressMonitor monitor, TraceUnit testUnit) {
      if (testUnit != null) {
         for (String traceTypes : testUnit.getTraceMarkTypes()) {
            for (TraceMark traceMark : testUnit.getTraceMarksByType(traceTypes)) {
               if (monitor.isCanceled()) {
                  break;
               }
               resultData.addRaw(AHTML.addRowMultiColumnTable(testUnit.getTraceUnitType().getName(),
                  testUnit.getName(), traceMark.getTraceType(), traceMark.getRawTraceMark()));
            }
         }
      }
   }

   @Override
   public void onComplete(IProgressMonitor monitor) {
      resultData.addRaw(AHTML.endMultiColumnTable());
      System.out.println(String.format("Completed in: %s", Lib.getElapseString(startTime)));
      System.out.println(String.format("Memory Leaked: %s", Runtime.getRuntime().totalMemory() - startMemory));
      XResultDataUI.report(resultData,"Report");
   }
}

Back to the top