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.ats.config.demo.config;
import static org.eclipse.osee.framework.core.enums.DeletionFlag.EXCLUDE_DELETED;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.logging.Level;
import org.eclipse.osee.ats.config.demo.artifact.DemoCodeTeamWorkflowArtifact;
import org.eclipse.osee.ats.config.demo.internal.OseeAtsConfigDemoActivator;
import org.eclipse.osee.ats.util.AtsUtil;
import org.eclipse.osee.framework.core.data.IArtifactType;
import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.exception.OseeWrappedException;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.skynet.core.User;
import org.eclipse.osee.framework.skynet.core.UserManager;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
import org.eclipse.osee.framework.ui.plugin.util.Result;
import org.eclipse.osee.support.test.util.DemoUsers;
/**
* @author Donald G. Dunne
*/
public class DemoDbUtil {
public static String INTERFACE_INITIALIZATION = "Interface Initialization";
private static List<DemoCodeTeamWorkflowArtifact> codeArts;
public static List<DemoCodeTeamWorkflowArtifact> getSampleCodeWorkflows() throws OseeCoreException {
if (codeArts == null) {
codeArts = new ArrayList<DemoCodeTeamWorkflowArtifact>();
for (String actionName : new String[] {
"SAW (committed) Reqt Changes for Diagram View",
"SAW (uncommitted) More Reqt Changes for Diagram View"}) {
DemoCodeTeamWorkflowArtifact codeArt = null;
for (Artifact art : ArtifactQuery.getArtifactListFromName(actionName, AtsUtil.getAtsBranch(),
EXCLUDE_DELETED)) {
if (art instanceof DemoCodeTeamWorkflowArtifact) {
codeArt = (DemoCodeTeamWorkflowArtifact) art;
codeArts.add(codeArt);
}
}
}
}
return codeArts;
}
public static void sleep(long milliseconds) throws OseeCoreException {
OseeLog.log(OseeAtsConfigDemoActivator.class, Level.INFO, "Sleeping " + milliseconds);
try {
Thread.sleep(milliseconds);
} catch (Exception ex) {
throw new OseeWrappedException(ex);
}
OseeLog.log(OseeAtsConfigDemoActivator.class, Level.INFO, "Awake");
}
public static Result isDbPopulatedWithDemoData(Branch branch) throws OseeCoreException {
if (DemoDbUtil.getSoftwareRequirements(SoftwareRequirementStrs.Robot, branch).size() != 6) {
return new Result(
"Expected at least 6 Software Requirements with word \"Robot\". Database is not be populated with demo data.");
}
return Result.TrueResult;
}
public static Collection<Artifact> getSoftwareRequirements(SoftwareRequirementStrs str, Branch branch) throws OseeCoreException {
return getArtTypeRequirements(CoreArtifactTypes.SoftwareRequirement, str.name(), branch);
}
public static Collection<Artifact> getArtTypeRequirements(IArtifactType artifactType, String artifactNameStr, Branch branch) throws OseeCoreException {
OseeLog.log(OseeAtsConfigDemoActivator.class, Level.INFO,
"Getting \"" + artifactNameStr + "\" requirement(s) from Branch " + branch.getName());
Collection<Artifact> arts =
ArtifactQuery.getArtifactListFromTypeAndName(artifactType, "%" + artifactNameStr + "%", branch);
OseeLog.log(OseeAtsConfigDemoActivator.class, Level.INFO, "Found " + arts.size() + " Artifacts");
return arts;
}
public static enum SoftwareRequirementStrs {
Robot,
CISST,
daVinci,
Functional,
Event,
Haptic
};
public static String HAPTIC_CONSTRAINTS_REQ = "Haptic Constraints";
public static Artifact getInterfaceInitializationSoftwareRequirement(Branch branch) throws OseeCoreException {
OseeLog.log(OseeAtsConfigDemoActivator.class, Level.INFO,
"Getting \"" + INTERFACE_INITIALIZATION + "\" requirement.");
return ArtifactQuery.getArtifactFromTypeAndName(CoreArtifactTypes.SoftwareRequirement, INTERFACE_INITIALIZATION,
branch);
}
public static User getDemoUser(DemoUsers demoUser) throws OseeCoreException {
return UserManager.getUserByName(demoUser.getName());
}
}
|