3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
11 package eu
.etaxonomy
.taxeditor
.navigation
.navigator
;
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
.taxon
.Classification
;
26 import eu
.etaxonomy
.cdm
.persistence
.hibernate
.CdmDataChangeMap
;
27 import eu
.etaxonomy
.taxeditor
.navigation
.NavigationUtil
;
28 import eu
.etaxonomy
.taxeditor
.navigation
.operation
.CreateClassification
;
29 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostOperation
;
30 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
39 public class Root
extends PlatformObject
implements IAdaptable
, IPersistableElement
, IElementFactory
, IConversationEnabled
{
41 private final ConversationHolder conversation
;
44 * <p>Constructor for Root.</p>
46 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
48 public Root (ConversationHolder conversation
){
49 this.conversation
= conversation
;
53 * <p>getParentBeans</p>
55 * @return a {@link java.util.List} object.
57 public List
<Classification
> getParentBeans() {
58 List
<String
> propertyPaths
= Arrays
.asList(new String
[]{"name"});
60 List
<Classification
> classifications
= CdmStore
.getService(IClassificationService
.class).list(null, null, null, null, propertyPaths
);
62 if(classifications
.size() == 0){
63 Classification classification
= Classification
.NewInstance("My Classification");
64 AbstractPostOperation operation
= new CreateClassification("Creating initial classification", NavigationUtil
.getUndoContext(), classification
, NavigationUtil
.getNavigator(false), NavigationUtil
.getNavigator(false), NavigationUtil
.getNavigator(false));
65 NavigationUtil
.executeOperation(operation
);
67 classifications
= CdmStore
.getService(IClassificationService
.class).list(null, null, null, null, propertyPaths
);
70 return classifications
;
74 * @see org.eclipse.ui.IPersistableElement#getFactoryId()
79 * @return a {@link java.lang.String} object.
82 public String
getFactoryId() {
87 * @see org.eclipse.ui.IPersistable#saveState(org.eclipse.ui.IMemento)
91 public void saveState(IMemento memento
) {
95 * @see org.eclipse.ui.IElementFactory#createElement(org.eclipse.ui.IMemento)
99 public IAdaptable
createElement(IMemento memento
) {
104 * @see eu.etaxonomy.cdm.persistence.hibernate.ICdmPostDataChangeObserver#update(eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap)
107 public void update(CdmDataChangeMap changeEvents
) {}
110 * @see eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder()
113 public ConversationHolder
getConversationHolder() {