Project

General

Profile

« Previous | Next » 

Revision 417a8287

Added by Katja Luther over 6 years ago

move initialize to constructor and small changes in cdmlightexport

View differences:

cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/cdmLight/CdmLightClassificationExport.java
16 16
import java.util.List;
17 17
import java.util.Map;
18 18
import java.util.Set;
19
import java.util.UUID;
20 19

  
21 20
import org.apache.commons.lang3.StringUtils;
22 21
import org.springframework.stereotype.Component;
......
147 146

  
148 147
                TaxonNode node = partitioner.next();
149 148
                while (node != null){
150
                  handleTaxonNode(state, node.getUuid());
149
                  handleTaxonNode(state, node);
151 150
                  node = partitioner.next();
152 151
                }
153 152

  
......
167 166
     * @param state
168 167
     * @param classificationUuid
169 168
     */
170
    private void handleTaxonNode(CdmLightExportState state, UUID taxonNodeUuid) {
169
    private void handleTaxonNode(CdmLightExportState state, TaxonNode taxonNode) {
171 170
        try {
172
            TaxonNode taxonNode = getTaxonNodeService().find(taxonNodeUuid);
171
//            TaxonNode taxonNode = getTaxonNodeService().find(taxonNodeUuid);
173 172

  
174 173
            if (taxonNode == null){
175
                String message = String.format("TaxonNode for given taxon node UUID not found. No data imported for %s", taxonNodeUuid.toString());
174
                String message = "TaxonNode for given taxon node UUID not found. ";
176 175
                //TODO
177 176
                state.getResult().addWarning(message);
178 177
            }else{
......
180 179
                if (root.hasTaxon()){
181 180
                    handleTaxon(state, root);
182 181
                }else{
183
                    for (TaxonNode child : root.getChildNodes()){
184
                        handleTaxon(state, child);
185
                        //TODO progress monitor
186
                    }
182
//                    for (TaxonNode child : root.getChildNodes()){
183
//                        handleTaxon(state, child);
184
//                        //TODO progress monitor
185
//                    }
187 186
                }
188 187
            }
189 188
        } catch (Exception e) {
190 189
            state.getResult().addException(e, "An unexpected error occurred when handling classification " +
191
                    taxonNodeUuid + ": " + e.getMessage() + e.getStackTrace());
190
                    taxonNode.getUuid() + ": " + e.getMessage() + e.getStackTrace());
192 191
        }
193 192
    }
194 193

  
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/cdmLight/CdmLightExportResultProcessor.java
97 97
    public void createFinalResult(CdmLightExportState state) {
98 98

  
99 99
        if (!result.isEmpty() ){
100
            state.setAuthorStore(new HashMap<>());
101
            state.setHomotypicalGroupStore(new HashMap<>());
102
            state.setReferenceStore(new HashMap<>());
103
            state.setSpecimenStore(new HashMap<>());
100 104
            //Replace quotes by double quotes
101 105
            for (CdmLightExportTable table: result.keySet()){
102 106
                //schreibe jede Tabelle in einen Stream...
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/cdmLight/CdmLightExportState.java
38 38

  
39 39
    private Map<Integer, HomotypicalGroup> homotypicalGroupStore = new HashMap<>();
40 40
    private Map<Integer, TeamOrPersonBase<?>> authorStore = new HashMap<>();
41

  
41 42
    private Map<Integer, SpecimenOrObservationBase> specimenStore = new HashMap<>();
42 43
    private Map<Integer, Reference> referenceStore = new HashMap<>();
43 44

  
......
106 107
    }
107 108

  
108 109
    /**
109
     * @return the homotypicalGroupStore
110
     * @return the specimenStore
110 111
     */
111
    public Map<Integer, TeamOrPersonBase<?>> getAuthorStore() {
112
        return authorStore;
112
    public Map<Integer, SpecimenOrObservationBase> getSpecimenStore() {
113
        return specimenStore;
114
    }
115

  
116

  
117

  
118
    /**
119
     * @param specimenStore the specimenStore to set
120
     */
121
    public void setSpecimenStore(Map<Integer, SpecimenOrObservationBase> specimenStore) {
122
        this.specimenStore = specimenStore;
123
    }
124

  
125

  
126

  
127

  
128

  
129
    /**
130
     * @param homotypicalGroupStore the homotypicalGroupStore to set
131
     */
132
    public void setHomotypicalGroupStore(Map<Integer, HomotypicalGroup> homotypicalGroupStore) {
133
        this.homotypicalGroupStore = homotypicalGroupStore;
134
    }
135

  
136
    /**
137
     * @param authorStore the authorStore to set
138
     */
139
    public void setAuthorStore(Map<Integer, TeamOrPersonBase<?>> authorStore) {
140
        this.authorStore = authorStore;
113 141
    }
114 142

  
115 143
    /**
......
119 147
        this.authorStore.put(author.getId(), author);
120 148
    }
121 149

  
150
    /**
151
     * @return the homotypicalGroupStore
152
     */
153
    public Map<Integer, TeamOrPersonBase<?>> getAuthorStore() {
154
        return authorStore;
155
    }
156

  
157

  
122 158
    public TeamOrPersonBase<?> getAuthorFromStore(Integer id){
123 159
        return authorStore.get(id);
124 160
    }
......
141 177
        this.referenceStore.put(ref.getId(), ref);
142 178

  
143 179
    }
144

  
180
    /**
181
     * @param referenceStore the referenceStore to set
182
     */
183
    public void setReferenceStore(Map<Integer, Reference> referenceStore) {
184
        this.referenceStore = referenceStore;
185
    }
186
    /**
187
     * @return the referenceStore
188
     */
189
    public Map<Integer, Reference> getReferenceStore() {
190
        return referenceStore;
191
    }
145 192

  
146 193
}
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/common/TaxonNodeOutStreamPartitioner.java
97 97
		this.state = state;
98 98
		this.parentMonitor = parentMonitor;
99 99
		this.parentTicks = parentTicks;
100

  
100
		initialize();
101 101

  
102 102
	}
103 103

  
......
126 126

  
127 127
	public TaxonNode next(){
128 128
	    int currentIndexAtStart = currentIndex;
129
	    initialize();
129

  
130 130
	    if(fifo.isEmpty()){
131

  
131 132
	        List<TaxonNode> list = getNextPartition();
132 133
	        fifo.addAll(list);
133 134
	    }

Also available in: Unified diff