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
114
115
|
/*******************************************************************************
* Copyright (c) 2013 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.impl.internal.workitem;
import java.rmi.activation.Activator;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.logging.Level;
import org.eclipse.osee.ats.api.IAtsConfigObject;
import org.eclipse.osee.ats.api.data.AtsAttributeTypes;
import org.eclipse.osee.ats.api.data.AtsRelationTypes;
import org.eclipse.osee.ats.api.user.IAtsUser;
import org.eclipse.osee.ats.impl.internal.AtsServerService;
import org.eclipse.osee.framework.core.data.IAttributeType;
import org.eclipse.osee.framework.core.data.IRelationTypeSide;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.orcs.data.ArtifactReadable;
/**
* @author Donald G Dunne
*/
public abstract class AtsConfigObject extends org.eclipse.osee.ats.core.model.impl.AtsObject implements IAtsConfigObject {
protected final ArtifactReadable artifact;
public AtsConfigObject(ArtifactReadable artifact) {
super(artifact.getGuid(), artifact.getName());
this.artifact = artifact;
}
public void setFullName(String fullName) {
OseeLog.log(TeamDefinition.class, Level.SEVERE, "TeamDefinition.setFullName not implemented");
}
public abstract String getTypeName();
public String getFullName() {
return getTypeName();
}
public void setActionable(boolean actionable) {
OseeLog.log(TeamDefinition.class, Level.SEVERE, "TeamDefinition.setActionable not implemented");
}
public boolean isActionable() {
return getAttributeValue(AtsAttributeTypes.Actionable, false);
}
@SuppressWarnings("unchecked")
protected <T> T getAttributeValue(IAttributeType attributeType, Object defaultValue) {
T value = null;
try {
value = (T) artifact.getSoleAttributeValue(attributeType, defaultValue);
} catch (OseeCoreException ex) {
OseeLog.log(Activator.class, Level.SEVERE, ex);
}
return value;
}
public void setActive(boolean active) {
OseeLog.log(TeamDefinition.class, Level.SEVERE, "TeamDefinition.setActive not implemented");
}
public boolean isActive() {
return getAttributeValue(AtsAttributeTypes.Active, false);
}
public Collection<String> getStaticIds() {
Collection<String> results = Collections.emptyList();
try {
results = artifact.getAttributeValues(CoreAttributeTypes.StaticId);
} catch (OseeCoreException ex) {
OseeLog.log(Activator.class, Level.SEVERE, ex);
}
return results;
}
public Collection<IAtsUser> getLeads() {
return getRelatedUsers(AtsRelationTypes.TeamLead_Lead);
}
public Collection<IAtsUser> getSubscribed() {
return getRelatedUsers(AtsRelationTypes.SubscribedUser_User);
}
Collection<IAtsUser> getRelatedUsers(IRelationTypeSide relation) {
Set<IAtsUser> results = new HashSet<IAtsUser>();
try {
for (ArtifactReadable userArt : artifact.getRelated(relation)) {
IAtsUser lead = AtsServerService.get().getUserService().getUserById(userArt.getGuid());
results.add(lead);
}
} catch (OseeCoreException ex) {
OseeLog.log(Activator.class, Level.SEVERE, ex);
}
return results;
}
@Override
public Object getStoreObject() {
return artifact;
}
}
|