Project

General

Profile

Revision d8cc12a4

IDd8cc12a42115da9867c725578856d120825a010d
Parent a1765b1a
Child 2b4395ed

Added by Katja Luther almost 4 years ago

ref #6283: minor changes to fix exceptions in polytomous key editing

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/hibernate/HHH_9751_Util.java
12 12
import java.util.Collection;
13 13

  
14 14
import org.apache.log4j.Logger;
15
import org.hibernate.Hibernate;
16 15
import org.hibernate.LazyInitializationException;
17 16

  
18 17

  
......
35 34
     */
36 35
    static public int removeAllNull(Collection collection) {
37 36

  
38
        int cnt = 0;
37
        int cnt = collection.size();
39 38
        try {
40
           if (Hibernate.isInitialized(collection)){
41
               if (collection.contains(null)){
42
                    while(collection.contains(null)){
43
                        cnt++;
44
                        collection.remove(null);
45
                    }
39

  
40
           if (collection.contains(null)){
41
             while(collection.contains(null)){
42
                    cnt++;
43
                    collection.remove(null);
46 44
                }
47
           }
45
            }
46

  
48 47
        } catch (LazyInitializationException e) {
49 48
            logger.info("Cannot clean up uninitialized children without a session, skipping.");
50 49
        }
51
        return cnt;
50
        return cnt - collection.size() ;
52 51
    }
53 52

  
54 53
}
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/description/PolytomousKeyNode.java
559 559
	private int getMaxNodeNumber(int maxNumber, PolytomousKeyNode parent) {
560 560
		if (parent.getNodeNumber() != null) {
561 561
			maxNumber = (maxNumber < parent.getNodeNumber()) ? parent.getNodeNumber() : maxNumber;
562
			parent.removeNullValueFromChildren();
562 563
			for (PolytomousKeyNode child : parent.getChildren()) {
563 564
			    if (parent == child){
564 565
					throw new RuntimeException("Parent and child are the same for the given key node. This will lead to an infinite loop when updating the max node number.");
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/PolytomousKeyNodeServiceImpl.java
49 49
        PolytomousKeyNode node = dao.findByUuid(nodeUUID);
50 50
        node = HibernateProxyHelper.deproxy(node);
51 51
        if(node == null) {
52
            result.addException(new Exception("The polytomouskey node was already deleted."));;
52
           // result.addException(new Exception("The polytomouskey node was already deleted."));;
53
            return result;
53 54
        }
54 55
        List<PolytomousKeyNode> children = new ArrayList<PolytomousKeyNode>();
56

  
55 57
        node.removeNullValueFromChildren();
56 58
        for (PolytomousKeyNode child: node.getChildren()){
57 59
            children.add(child);

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)