Project

General

Profile

Revision 9db81ba4

ID9db81ba4f79b61c3dc81b89740e048951fd746cf
Parent 5e80260d
Child 743a9157

Added by Andreas Müller about 1 year ago

ref #6794 remove setRoot from FeatureTree

View differences:

cdmlib-io/src/test/java/eu/etaxonomy/cdm/io/owl/out/OwlExportTest.java
68 68
     */
69 69
    public FeatureTree createFeatureTree() {
70 70
        FeatureTree tree = FeatureTree.NewInstance();
71
        tree.setRoot(FeatureNode.NewInstance());
72 71

  
73 72
        FeatureNode nodeA = FeatureNode.NewInstance(Feature.NewInstance("A", "A", "A"));
74 73
        FeatureNode nodeA1 = FeatureNode.NewInstance(Feature.NewInstance("A1", "A1", "A1"));
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/description/FeatureTree.java
171 171
	public FeatureNode getRoot() {
172 172
		return root;
173 173
	}
174
	/**
175
	 * @see	#getRoot()
176
	 */
177
	public void setRoot(FeatureNode root) {
178
		this.root = root;
179
	}
174

  
175
    /**
176
     * @deprecated this method is only for internal use when deleting a {@link FeatureTree}
177
     * from a database. It should never be called for other reasons.
178
     */
179
    @Deprecated
180
    public void removeRootNode() {
181
        this.root = null;
182
    }
180 183

  
181 184
	/**
182 185
	 * Returns the (ordered) list of {@link FeatureNode feature nodes} which are immediate
cdmlib-model/src/test/java/eu/etaxonomy/cdm/model/description/FeatureTreeTest.java
3 3

  
4 4

  
5 5
import static org.junit.Assert.assertEquals;
6
import static org.junit.Assert.assertNotNull;
7 6
import static org.junit.Assert.assertNotSame;
8 7

  
9 8
import java.util.List;
......
37 36
	@Before
38 37
	public void setUp() throws Exception {
39 38
		testTree = FeatureTree.NewInstance();
40
		node1 = FeatureNode.NewInstance();
41
		node1.setFeature(Feature.ANATOMY());
42
		node2 = FeatureNode.NewInstance();
43
		node2.setFeature(Feature.BIOLOGY_ECOLOGY());
44
		node3 = FeatureNode.NewInstance();
45
		node3.setFeature(Feature.DESCRIPTION());
46
		node4 = FeatureNode.NewInstance();
47
		node4.setFeature(Feature.DISCUSSION());
48
		
49
		testTree.setRoot(node1);
39

  
40
		node1 = FeatureNode.NewInstance(Feature.ANATOMY());
41
		node2 = FeatureNode.NewInstance(Feature.BIOLOGY_ECOLOGY());
42
		node3 = FeatureNode.NewInstance(Feature.DESCRIPTION());
43
		node4 = FeatureNode.NewInstance(Feature.DISCUSSION());
44

  
45
		testTree.getRoot().addChild(node1);
50 46
		node1.addChild(node2);
51 47
		node2.addChild(node3);
52 48
		node3.addChild(node4);
53
		
54
		
55
		
56
	}
57
	@Test
58
	public void testSetRoot(){
59
		testTree.setRoot(node2);
60
		assertNotNull(testTree.getRoot());
61
		assertEquals(testTree.getRoot(), node2);
49

  
50

  
51

  
62 52
	}
53
//	@Test
54
//	public void testSetRoot(){
55
//		testTree.setRoot(node2);
56
//		assertNotNull(testTree.getRoot());
57
//		assertEquals(testTree.getRoot(), node2);
58
//	}
63 59
	@Test
64 60
	public void testAddChild(){
65 61
		FeatureNode node21 = FeatureNode.NewInstance();
......
83 79
		assertEquals (clone.getRoot().getFeature(), testTree.getRoot().getFeature());
84 80
		assertNotSame(clone.getRoot(), testTree.getRoot());
85 81
		List<FeatureNode> children = clone.getRootChildren();
86
		
87
		assertEquals(children.get(0).getFeature(), node2.getFeature());
82

  
83

  
84
		assertEquals(children.get(0).getTerm(), node1.getTerm());
85
	    assertNotSame(children.get(0), node1);
86
	    children = children.get(0).getChildNodes();
87

  
88
		assertEquals(children.get(0).getTerm(), node2.getTerm());
88 89
		assertNotSame(children.get(0), node2);
89 90
		assertEquals(children.get(1).getFeature(), node21.getFeature());
90 91
		assertNotSame(children.get(1), node21);
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/FeatureTreeServiceImpl.java
124 124
        DeleteResult result = new DeleteResult();
125 125
        FeatureTree tree = dao.load(featureTreeUuid);
126 126

  
127
        FeatureNode rootNode = HibernateProxyHelper.deproxy(tree.getRoot(), FeatureNode.class);
127
        FeatureNode rootNode = HibernateProxyHelper.deproxy(tree.getRoot());
128 128
        FeatureNodeDeletionConfigurator config = new FeatureNodeDeletionConfigurator();
129 129
        config.setChildHandling(ChildHandling.DELETE);
130 130
        result =featureNodeService.deleteFeatureNode(rootNode.getUuid(), config);
131
        tree.setRoot(null);
131
        tree.removeRootNode();
132 132
        if (result.isOk()){
133 133
          dao.delete(tree);
134 134
          result.addDeletedObject(tree);
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/NaturalLanguageGeneratorTest.java
55 55
		description = TaxonDescription.NewInstance(taxon);
56 56

  
57 57
		featureTree= FeatureTree.NewInstance();
58
		FeatureNode root = FeatureNode.NewInstance();
59
		featureTree.setRoot(root);
58
		FeatureNode root = featureTree.getRoot();
60 59
		String[][][] tableStrings = { { {"a","b"} } , { { "a1" , "a2"  } , { "b1" } } };
61 60
		buildBranches(root,tableStrings,0,2,0);
62 61
		for (Iterator<Feature> f = featureSet.iterator() ; f.hasNext() ;){

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)