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
|
/*******************************************************************************
* 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.ui.data.model.editor.input;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.eclipse.osee.framework.core.data.IAttributeType;
import org.eclipse.osee.framework.core.enums.CoreBranches;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.type.ArtifactType;
import org.eclipse.osee.framework.core.model.type.AttributeType;
import org.eclipse.osee.framework.core.model.type.RelationType;
import org.eclipse.osee.framework.jdk.core.type.HashCollection;
import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTypeManager;
import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
import org.eclipse.osee.framework.skynet.core.attribute.AttributeTypeManager;
import org.eclipse.osee.framework.skynet.core.relation.RelationTypeManager;
import org.eclipse.osee.framework.ui.data.model.editor.model.ArtifactDataType;
import org.eclipse.osee.framework.ui.data.model.editor.model.AttributeDataType;
import org.eclipse.osee.framework.ui.data.model.editor.model.RelationDataType;
import org.eclipse.osee.framework.ui.skynet.ArtifactImageManager;
/**
* @author Roberto E. Escobar
*/
public class OseeDataTypeDatastore {
public static List<AttributeDataType> getAttributeTypes() throws OseeCoreException {
List<AttributeDataType> attributeDataTypes = new ArrayList<AttributeDataType>();
for (AttributeType attributeType : AttributeTypeManager.getAllTypes()) {
String baseClass = AttributeTypeManager.getAttributeBaseClass(attributeType).getCanonicalName();
String providerClass = AttributeTypeManager.getAttributeProviderClass(attributeType).getCanonicalName();
AttributeDataType attributeDataType =
new AttributeDataType(String.valueOf(attributeType.getId()), attributeType.getName(), baseClass,
attributeType.getDefaultValue(), attributeType.getFileTypeExtension(),
attributeType.getMaxOccurrences(), attributeType.getMinOccurrences(), providerClass,
attributeType.getTaggerId(), attributeType.getDescription(), attributeType.getOseeEnumTypeId());
attributeDataTypes.add(attributeDataType);
}
return attributeDataTypes;
}
public static List<RelationDataType> getRelationDataTypes() throws OseeCoreException {
List<RelationDataType> relationDataTypes = new ArrayList<RelationDataType>();
for (RelationType relationType : RelationTypeManager.getAllTypes()) {
RelationDataType relationDataType =
new RelationDataType(String.valueOf(relationType.getId()), relationType.getName(), "", "",
relationType.isOrdered(), "", relationType.getSideAName(), relationType.getSideBName());
relationDataTypes.add(relationDataType);
}
return relationDataTypes;
}
public static List<ArtifactDataType> getArtifactDataTypes() throws OseeCoreException {
List<ArtifactDataType> artifactDataTypes = new ArrayList<ArtifactDataType>();
for (ArtifactType artifactType : ArtifactTypeManager.getAllTypes()) {
ArtifactDataType artifactDataType =
new ArtifactDataType(String.valueOf(artifactType.getId()), artifactType.getName(),
ArtifactImageManager.getImage(artifactType));
artifactDataTypes.add(artifactDataType);
}
return artifactDataTypes;
}
public static HashCollection<String, String> getArtifactToAttributeEntries() throws OseeCoreException {
HashCollection<String, String> toReturn = new HashCollection<String, String>();
for (ArtifactType artifactType : ArtifactTypeManager.getAllTypes()) {
Collection<IAttributeType> attributeTypes =
artifactType.getAttributeTypes(BranchManager.getBranch(CoreBranches.SYSTEM_ROOT));
for (IAttributeType attrType : attributeTypes) {
int typeId = AttributeTypeManager.getType(attrType).getId();
toReturn.put(String.valueOf(artifactType.getId()), String.valueOf(typeId));
}
}
return toReturn;
}
public static HashCollection<String, String> getArtifactInheritance() throws OseeCoreException {
HashCollection<String, String> toReturn = new HashCollection<String, String>();
for (ArtifactType artifactType : ArtifactTypeManager.getAllTypes()) {
if (artifactType.hasSuperArtifactTypes()) {
for (ArtifactType superType : artifactType.getSuperArtifactTypes()) {
toReturn.put(String.valueOf(superType.getId()), String.valueOf(artifactType.getId()));
}
}
}
return toReturn;
}
}
|