Skip to main content
summaryrefslogtreecommitdiffstats
blob: 3bfad998c2066919b72be61885e40f15594b4b65 (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*******************************************************************************
 * 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.framework.server.admin.branch;

import org.eclipse.osee.framework.core.operation.Operations;
import org.eclipse.osgi.framework.console.CommandInterpreter;

/**
 * @author Roberto E. Escobar
 */
public class BranchCommands {

   private final BranchExportWorker branchExportWorker;
   private final BranchImportWorker branchImportWorker;
   private final ExchangeIntegrityWorker integrityWorker;

   public BranchCommands() {
      this.branchExportWorker = new BranchExportWorker();
      this.branchExportWorker.setExecutionAllowed(true);

      this.branchImportWorker = new BranchImportWorker();
      this.branchImportWorker.setExecutionAllowed(true);

      this.integrityWorker = new ExchangeIntegrityWorker();
      this.integrityWorker.setExecutionAllowed(true);
   }

   public void startBranchExport(CommandInterpreter ci) {
      if (!this.branchExportWorker.isRunning() && !this.branchImportWorker.isRunning() && !this.integrityWorker.isRunning()) {
         this.branchExportWorker.setCommandInterpreter(ci);
         this.branchExportWorker.setExecutionAllowed(true);
         Operations.executeAsJob(branchExportWorker, false);
      } else {
         if (this.branchExportWorker.isRunning()) {
            ci.println("Branch Export is already running.");
         }
         if (this.branchImportWorker.isRunning()) {
            ci.println("Branch Import is already running.");
         }
         if (this.integrityWorker.isRunning()) {
            ci.println("Branch Integrity Check is already running.");
         }
      }
   }

   public void stopBranchExport(CommandInterpreter ci) {
      if (this.branchExportWorker.isRunning()) {
         this.branchExportWorker.setExecutionAllowed(false);
      } else {
         ci.println("Branch Export is not running.");
      }
   }

   public void startBranchImport(CommandInterpreter ci) {
      if (!this.branchExportWorker.isRunning() && !this.branchImportWorker.isRunning() && !this.integrityWorker.isRunning()) {
         this.branchImportWorker.setCommandInterpreter(ci);
         this.branchImportWorker.setExecutionAllowed(true);
         Operations.executeAsJob(branchImportWorker, false);
      } else {
         if (this.branchExportWorker.isRunning()) {
            ci.println("Branch Export is already running.");
         }
         if (this.branchImportWorker.isRunning()) {
            ci.println("Branch Import is already running.");
         }
         if (this.integrityWorker.isRunning()) {
            ci.println("Branch Integrity Check is already running.");
         }
      }
   }

   public void stopBranchImport(CommandInterpreter ci) {
      if (this.branchImportWorker.isRunning()) {
         this.branchImportWorker.setExecutionAllowed(false);
      } else {
         ci.println("Branch Import is not running.");
      }
   }

   public void startBranchIntegrityCheck(CommandInterpreter ci) {
      if (!this.branchExportWorker.isRunning() && !this.branchImportWorker.isRunning() && !this.integrityWorker.isRunning()) {
         this.integrityWorker.setCommandInterpreter(ci);
         this.integrityWorker.setExecutionAllowed(true);
         Operations.executeAsJob(integrityWorker, false);
      } else {
         if (this.branchExportWorker.isRunning()) {
            ci.println("Branch Export is already running.");
         }
         if (this.branchImportWorker.isRunning()) {
            ci.println("Branch Import is already running.");
         }
         if (this.integrityWorker.isRunning()) {
            ci.println("Branch Integrity Check is already running.");
         }
      }
   }

   public void stopBranchIntegrityCheck(CommandInterpreter ci) {
      if (this.integrityWorker.isRunning()) {
         this.integrityWorker.setExecutionAllowed(false);
      } else {
         ci.println("Branch Integrity Check is not running.");
      }
   }
}

Back to the top