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
.Arrays
;
13 import java
.util
.List
;
15 import org
.eclipse
.core
.runtime
.IAdaptable
;
16 import org
.eclipse
.core
.runtime
.PlatformObject
;
17 import org
.eclipse
.ui
.IElementFactory
;
18 import org
.eclipse
.ui
.IMemento
;
19 import org
.eclipse
.ui
.IPersistableElement
;
21 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
22 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
23 import eu
.etaxonomy
.cdm
.api
.service
.IClassificationService
;
24 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
25 import eu
.etaxonomy
.cdm
.persistence
.hibernate
.CdmDataChangeMap
;
26 import eu
.etaxonomy
.taxeditor
.navigation
.NavigationUtil
;
27 import eu
.etaxonomy
.taxeditor
.navigation
.operation
.CreateClassification
;
28 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostOperation
;
29 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
38 public class Root
extends PlatformObject
implements IAdaptable
, IPersistableElement
, IElementFactory
, IConversationEnabled
{
40 private final ConversationHolder conversation
;
43 * <p>Constructor for Root.</p>
45 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
47 public Root (ConversationHolder conversation
){
48 this.conversation
= conversation
;
52 * <p>getParentBeans</p>
54 * @return a {@link java.util.List} object.
56 public List
<Classification
> getParentBeans() {
57 List
<String
> propertyPaths
= Arrays
.asList(new String
[]{
59 "rootNode.childNodes"});
61 List
<Classification
> classifications
= CdmStore
.getService(IClassificationService
.class).list(null, null, null, null, propertyPaths
);
63 if(classifications
.size() == 0){
64 Classification classification
= Classification
.NewInstance("My Classification");
65 AbstractPostOperation operation
= new CreateClassification("Creating initial classification", NavigationUtil
.getUndoContext(), classification
, NavigationUtil
.getNavigator(false), NavigationUtil
.getNavigator(false), NavigationUtil
.getNavigator(false));
66 NavigationUtil
.executeOperation(operation
);
68 classifications
= CdmStore
.getService(IClassificationService
.class).list(null, null, null, null, propertyPaths
);
71 return classifications
;
75 * @see org.eclipse.ui.IPersistableElement#getFactoryId()
80 * @return a {@link java.lang.String} object.
83 public String
getFactoryId() {
88 * @see org.eclipse.ui.IPersistable#saveState(org.eclipse.ui.IMemento)
92 public void saveState(IMemento memento
) {
96 * @see org.eclipse.ui.IElementFactory#createElement(org.eclipse.ui.IMemento)
100 public IAdaptable
createElement(IMemento memento
) {
105 * @see eu.etaxonomy.cdm.persistence.hibernate.ICdmPostDataChangeObserver#update(eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap)
108 public void update(CdmDataChangeMap changeEvents
) {}
111 * @see eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder()
114 public ConversationHolder
getConversationHolder() {