Project

General

Profile

Revision 32f1b240

ID32f1b2404ba7a2a786b05c5c2fbb3af683c76fe5
Parent 68c83855
Child f5f02f66

Added by Patrick Plitzner about 7 years ago

  • added service method to retrieve a map of SingleReads and their "hosting" Sequences

View differences:

cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/molecular/ISequenceService.java
9 9
*/
10 10
package eu.etaxonomy.cdm.api.service.molecular;
11 11

  
12
import java.util.Collection;
13
import java.util.Map;
14

  
12 15
import eu.etaxonomy.cdm.api.service.IAnnotatableService;
13 16
import eu.etaxonomy.cdm.model.molecular.Sequence;
14 17
import eu.etaxonomy.cdm.model.molecular.SingleRead;
......
29 32
     */
30 33
    public boolean moveSingleRead(Sequence from, Sequence to, SingleRead singleRead);
31 34

  
35
    /**
36
     * Creates and returns a map with {@link SingleRead}s as keys.
37
     * The value for each key is a list of those {@link Sequence}s that link to this SingleRead.
38
     * @return a map of SingleReads as keys and the Sequences linking to them
39
     */
40
    public Map<SingleRead, Collection<Sequence>> getSingleReadSequencesMap();
41

  
32 42
}
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/molecular/SequenceServiceImpl.java
9 9
*/
10 10
package eu.etaxonomy.cdm.api.service.molecular;
11 11

  
12
import java.util.ArrayList;
13
import java.util.Collection;
14
import java.util.HashMap;
15
import java.util.Map;
16

  
12 17
import org.apache.log4j.Logger;
13 18
import org.springframework.beans.factory.annotation.Autowired;
14 19
import org.springframework.stereotype.Service;
......
50 55
        saveOrUpdate(to);
51 56
        return true;
52 57
    }
58

  
59
    /* (non-Javadoc)
60
     * @see eu.etaxonomy.cdm.api.service.molecular.ISequenceService#getSingleReadSequenceMap()
61
     */
62
    @Override
63
    public Map<SingleRead, Collection<Sequence>> getSingleReadSequencesMap() {
64
        Map<SingleRead, Collection<Sequence>> singleReadToSequences = new HashMap<SingleRead, Collection<Sequence>>();
65
        for(Sequence sequence:list(Sequence.class, null, null, null, null)){
66
            for(SingleRead singleRead:sequence.getSingleReads()){
67
                Collection<Sequence> sequences = singleReadToSequences.get(singleRead);
68
                if(sequences==null){
69
                    sequences = new ArrayList<Sequence>();
70
                }
71
                sequences.add(sequence);
72
                singleReadToSequences.put(singleRead, sequences);
73
            }
74
        }
75
        return singleReadToSequences;
76
    }
53 77
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)