2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.navigation
.navigator
;
12 import java
.util
.ArrayList
;
13 import java
.util
.Arrays
;
14 import java
.util
.List
;
16 import org
.eclipse
.core
.runtime
.IAdaptable
;
17 import org
.eclipse
.core
.runtime
.PlatformObject
;
18 import org
.eclipse
.ui
.IElementFactory
;
19 import org
.eclipse
.ui
.IMemento
;
20 import org
.eclipse
.ui
.IPersistableElement
;
22 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
23 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
24 import eu
.etaxonomy
.cdm
.api
.service
.IClassificationService
;
25 import eu
.etaxonomy
.cdm
.model
.common
.ITreeNode
;
26 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
27 import eu
.etaxonomy
.cdm
.persistence
.hibernate
.CdmDataChangeMap
;
28 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
37 public class Root
extends PlatformObject
implements IAdaptable
, IPersistableElement
, IElementFactory
, IConversationEnabled
{
39 private final ConversationHolder conversation
;
42 * <p>Constructor for Root.</p>
44 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
46 public Root (ConversationHolder conversation
){
47 this.conversation
= conversation
;
51 * <p>getParentBeans</p>
53 * @return a {@link java.util.List} object.
55 public List
<ITreeNode
> getParentBeans() {
56 List
<String
> propertyPaths
= Arrays
.asList(new String
[]{
58 "rootNode.childNodes"}); //$NON-NLS-1$
60 List
<Classification
> classifications
= CdmStore
.getService(IClassificationService
.class).list(null, null, null, null, propertyPaths
);
61 List
<ITreeNode
> rootNodes
= new ArrayList
<>();
63 if(classifications
.size() == 0){
64 //FIXME E4 migrate or delete; when does this happen and SHOULD this happen?
65 // Classification classification = Classification.NewInstance(Messages.Root_MY_CLASSIFICATION);
66 // AbstractPostOperation operation = new CreateClassification(Messages.Root_CREATE_CLASSIFICATION, NavigationUtil.getUndoContext(), classification, NavigationUtil.getNavigator(false), NavigationUtil.getNavigator(false), NavigationUtil.getNavigator(false));
67 // NavigationUtil.executeOperation(operation);
69 // classifications = CdmStore.getService(IClassificationService.class).list(null, null, null, null, propertyPaths);
71 for (Classification classification
: classifications
){
72 rootNodes
.add(classification
.getRootNode());
78 * @see org.eclipse.ui.IPersistableElement#getFactoryId()
83 * @return a {@link java.lang.String} object.
86 public String
getFactoryId() {
91 * @see org.eclipse.ui.IPersistable#saveState(org.eclipse.ui.IMemento)
95 public void saveState(IMemento memento
) {
99 * @see org.eclipse.ui.IElementFactory#createElement(org.eclipse.ui.IMemento)
103 public IAdaptable
createElement(IMemento memento
) {
108 * @see eu.etaxonomy.cdm.persistence.hibernate.ICdmPostDataChangeObserver#update(eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap)
111 public void update(CdmDataChangeMap changeEvents
) {}
114 * @see eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder()
117 public ConversationHolder
getConversationHolder() {