Revision 6e249736
Added by Patrick Plitzner almost 7 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/FeatureTreeBuilderViewPart.java | ||
---|---|---|
9 | 9 |
*/ |
10 | 10 |
package eu.etaxonomy.taxeditor.editor.workingSet; |
11 | 11 |
|
12 |
import java.math.BigInteger; |
|
13 |
import java.util.ArrayList; |
|
14 |
import java.util.HashMap; |
|
15 |
import java.util.List; |
|
16 |
import java.util.Map; |
|
17 | 12 |
import java.util.UUID; |
18 | 13 |
|
19 | 14 |
import javax.annotation.PostConstruct; |
20 | 15 |
import javax.annotation.PreDestroy; |
21 | 16 |
|
22 |
import org.bgbm.prometheus.xml.NEWQUALITATIVEPROPERTY; |
|
23 |
import org.bgbm.prometheus.xml.ONTOLOGYDETAILS; |
|
24 |
import org.bgbm.prometheus.xml.STRUCTURETERM; |
|
25 |
import org.bgbm.prometheus.xml.Structure; |
|
26 |
import org.bgbm.prometheus.xml.TYPETERM; |
|
27 | 17 |
import org.eclipse.e4.ui.di.Focus; |
28 | 18 |
import org.eclipse.jface.viewers.TreeViewer; |
29 | 19 |
import org.eclipse.swt.SWT; |
30 | 20 |
import org.eclipse.swt.layout.FillLayout; |
31 | 21 |
import org.eclipse.swt.widgets.Composite; |
32 |
import org.eclipse.swt.widgets.Tree; |
|
33 | 22 |
|
34 | 23 |
import eu.etaxonomy.cdm.api.service.IVocabularyService; |
35 | 24 |
import eu.etaxonomy.cdm.model.common.TermVocabulary; |
... | ... | |
42 | 31 |
*/ |
43 | 32 |
public class FeatureTreeBuilderViewPart { |
44 | 33 |
|
45 |
private Tree treeStructures; |
|
46 |
private Tree treeProperties; |
|
47 |
private Tree treeCharacters; |
|
48 | 34 |
private TreeViewer treeViewerCharacters; |
49 | 35 |
private TreeViewer treeViewerProperties; |
50 | 36 |
private TreeViewer treeViewerStructures; |
51 | 37 |
|
52 | 38 |
public FeatureTreeBuilderViewPart() { |
53 |
ontology = PrometheusOntology.createOntology(); |
|
54 |
createIndex(ontology); |
|
55 | 39 |
} |
56 | 40 |
|
57 | 41 |
/** |
... | ... | |
63 | 47 |
|
64 | 48 |
treeViewerStructures = new TreeViewer(parent, SWT.BORDER); |
65 | 49 |
treeViewerStructures.setColumnProperties(new String[] {}); |
66 |
treeStructures = treeViewerStructures.getTree(); |
|
67 | 50 |
|
68 | 51 |
treeViewerProperties = new TreeViewer(parent, SWT.BORDER); |
69 |
treeProperties = treeViewerProperties.getTree(); |
|
70 | 52 |
|
71 | 53 |
treeViewerCharacters = new TreeViewer(parent, SWT.BORDER); |
72 |
treeCharacters = treeViewerCharacters.getTree(); |
|
73 | 54 |
|
74 | 55 |
init(); |
75 | 56 |
} |
76 | 57 |
|
77 | 58 |
private void init(){ |
78 |
TermVocabulary vocabulary = CdmStore.getService(IVocabularyService.class).load(UUID.fromString("b94244a5-5040-4c00-be34-12137c4b192f"));
|
|
79 |
treeViewerStructures.setContentProvider(new StructureContentProvider(vocabulary));
|
|
59 |
TermVocabulary structureVoc = CdmStore.getService(IVocabularyService.class).load(UUID.fromString("51f3a28e-6c1a-40bf-b504-012a12d69112"));
|
|
60 |
treeViewerStructures.setContentProvider(new StructureContentProvider()); |
|
80 | 61 |
treeViewerStructures.setLabelProvider(new StructureLabelProvider()); |
81 |
treeViewerStructures.setInput(""); |
|
62 |
treeViewerStructures.setInput(structureVoc); |
|
63 |
|
|
64 |
TermVocabulary propertiesVoc = CdmStore.getService(IVocabularyService.class).load(UUID.fromString("c5ff574b-40a5-4046-b2a0-59bfbe6b6616")); |
|
65 |
treeViewerProperties.setContentProvider(new StructureContentProvider()); |
|
66 |
treeViewerProperties.setLabelProvider(new StructureLabelProvider()); |
|
67 |
treeViewerProperties.setInput(propertiesVoc); |
|
82 | 68 |
} |
83 | 69 |
|
84 | 70 |
@PreDestroy |
... | ... | |
87 | 73 |
|
88 | 74 |
@Focus |
89 | 75 |
public void setFocus() { |
90 |
// TODO Set the focus to control |
|
91 | 76 |
} |
92 | 77 |
|
93 | 78 |
public TreeViewer getTreeViewerCharacters() { |
... | ... | |
100 | 85 |
return treeViewerStructures; |
101 | 86 |
} |
102 | 87 |
|
103 |
|
|
104 |
private final Map<String, List<String>> taxonToCharacterListMap = new HashMap<>(); |
|
105 |
|
|
106 |
private final Map<BigInteger, STRUCTURETERM> structureTermMap = new HashMap<>(); |
|
107 |
private final Map<BigInteger, TYPETERM> typeTermMap = new HashMap<>(); |
|
108 |
private final Map<BigInteger, NEWQUALITATIVEPROPERTY> qualPropertyTermMap = new HashMap<>(); |
|
109 |
private final Map<BigInteger, List<BigInteger>> structureTermToQualPropertyMap = new HashMap<>(); |
|
110 |
private ONTOLOGYDETAILS ontology; |
|
111 |
|
|
112 |
|
|
113 |
private void createIndex(ONTOLOGYDETAILS ontology){ |
|
114 |
//structures |
|
115 |
List<STRUCTURETERM> terms = ontology.getONTOLOGYDETAILSBody().getTERMS().getSTRUCTURETERMS().getSTRUCTURETERM(); |
|
116 |
terms.forEach((STRUCTURETERM structureTerm) -> structureTermMap.put(structureTerm.getGLOBALID(), structureTerm)); |
|
117 |
//type terms |
|
118 |
List<TYPETERM> typeTerms = ontology.getONTOLOGYDETAILSBody().getTERMS().getTYPEOFSTRUCTURETERMS().getTYPETERM(); |
|
119 |
typeTerms.forEach((TYPETERM typeterm) -> typeTermMap.put(typeterm.getGLOBALID(), typeterm)); |
|
120 |
//properties |
|
121 |
List<NEWQUALITATIVEPROPERTY> qualProperties = ontology.getONTOLOGYDETAILSBody().getNewQualitativeProperties().getNEWQUALITATIVEPROPERTY(); |
|
122 |
qualProperties.forEach((NEWQUALITATIVEPROPERTY newqualitativeproperty) -> |
|
123 |
{ |
|
124 |
BigInteger id = newqualitativeproperty.getIDSEQ(); |
|
125 |
qualPropertyTermMap.put(id, newqualitativeproperty); |
|
126 |
|
|
127 |
List<Structure> structures = newqualitativeproperty.getStructuresLinkedToProperty().getStructure(); |
|
128 |
structures.forEach((Structure structure) -> |
|
129 |
{ |
|
130 |
List<BigInteger> properties = structureTermToQualPropertyMap.get(structure.getRefID()); |
|
131 |
if(properties==null){ |
|
132 |
properties = new ArrayList<>(); |
|
133 |
} |
|
134 |
properties.add(id); |
|
135 |
structureTermToQualPropertyMap.put(structure.getRefID(), properties); |
|
136 |
}); |
|
137 |
}); |
|
138 |
} |
|
139 |
|
|
140 |
/** |
|
141 |
* @return the ontology |
|
142 |
*/ |
|
143 |
public ONTOLOGYDETAILS getOntology() { |
|
144 |
return ontology; |
|
145 |
} |
|
146 |
|
|
147 |
public Map<BigInteger, STRUCTURETERM> getStructureTermMap() { |
|
148 |
return structureTermMap; |
|
149 |
} |
|
150 | 88 |
} |
Also available in: Unified diff
Show properties in property tree