Skip to main content
summaryrefslogtreecommitdiffstats
blob: 7ecb5ee000e6ea49f49b9c275db0c6258a57e78a (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
/*******************************************************************************
 * 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.coverage.test.navigate;

import java.util.Arrays;
import org.eclipse.osee.coverage.editor.CoverageEditor;
import org.eclipse.osee.coverage.editor.CoverageEditorInput;
import org.eclipse.osee.coverage.store.CoverageRelationTypes;
import org.eclipse.osee.coverage.store.OseeCoveragePackageStore;
import org.eclipse.osee.coverage.util.CoverageUtil;
import org.eclipse.osee.coverage.util.dialog.CoveragePackageArtifactListDialog;
import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateComposite.TableLoadOption;
import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateItem;
import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateItemAction;
import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
import org.eclipse.osee.framework.ui.skynet.cm.IOseeCmService;

/**
 * @author Donald G. Dunne
 */
public class CreateWorkProductAction extends XNavigateItemAction {

   public CreateWorkProductAction() {
      super(null, "");
   }

   public CreateWorkProductAction(XNavigateItem parent) {
      super(parent, "Create Work Product Action");
   }

   @Override
   public void run(TableLoadOption... tableLoadOptions) throws Exception {

      IOseeCmService cmService = SkynetGuiPlugin.getInstance().getOseeCmService();
      if (cmService == null) {
         AWorkbench.popup("Can not acquire CM Service");
         return;
      }

      if (!CoverageUtil.getBranchFromUser(false)) {
         return;
      }
      Branch branch = CoverageUtil.getBranch();
      CoveragePackageArtifactListDialog dialog =
         new CoveragePackageArtifactListDialog("Open Coverage Package", "Select Coverage Package");
      dialog.setInput(OseeCoveragePackageStore.getCoveragePackageArtifacts(branch));
      if (dialog.open() == 0) {
         Artifact coveragePackageArtifact = (Artifact) dialog.getResult()[0];
         OseeCoveragePackageStore store = new OseeCoveragePackageStore(coveragePackageArtifact);

         SkynetTransaction transaction = new SkynetTransaction(branch, getName());
         Artifact actionArt =
            cmService.createPcr("Reqts PCR 1001", "Do requirements for PCR 1001", "Improvement", "1", null,
               Arrays.asList("SAW Requirements"));
         actionArt.persist(transaction);
         Artifact reqTeamArt = actionArt.getRelatedArtifact(CoverageRelationTypes.ActionToWorkflow_WorkFlow);
         reqTeamArt.persist(transaction);

         coveragePackageArtifact.addRelation(CoreRelationTypes.SupportingInfo_SupportingInfo, reqTeamArt);
         coveragePackageArtifact.persist(transaction);

         actionArt =
            cmService.createPcr("Code PCR 1001", "Do code for PCR 33201", "Improvement", "1", null,
               Arrays.asList("SAW Code"));
         actionArt.persist(transaction);
         Artifact codeTeamArt = actionArt.getRelatedArtifact(CoverageRelationTypes.ActionToWorkflow_WorkFlow);
         codeTeamArt.persist(transaction);

         coveragePackageArtifact.addRelation(CoreRelationTypes.SupportingInfo_SupportingInfo, codeTeamArt);
         coveragePackageArtifact.persist(transaction);

         actionArt =
            cmService.createPcr("Test PCR 1001", "Do test for PCR 33201", "Improvement", "1", null,
               Arrays.asList("SAW Test"));
         actionArt.persist(transaction);
         Artifact testTeamArt = actionArt.getRelatedArtifact(CoverageRelationTypes.ActionToWorkflow_WorkFlow);
         testTeamArt.persist(transaction);

         coveragePackageArtifact.addRelation(CoreRelationTypes.SupportingInfo_SupportingInfo, testTeamArt);
         coveragePackageArtifact.persist(transaction);

         transaction.execute();

         CoverageEditor.open(new CoverageEditorInput(coveragePackageArtifact.getName(), coveragePackageArtifact, null,
            false));
      }

   }
}

Back to the top