Project

General

Profile

« Previous | Next » 

Revision 49a35b7d

Added by Patrick Plitzner over 7 years ago

ref #5458 Refactoring

  • removed single implemented interfaces
  • merged methods
  • removed unnecessary try&catch blocks

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/presenter/dbstatus/DistributionTablePresenter.java
35 35
import eu.etaxonomy.cdm.model.taxon.Taxon;
36 36
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
37 37
import eu.etaxonomy.cdm.vaadin.container.CdmSQLContainer;
38
import eu.etaxonomy.cdm.vaadin.model.LazyLoadedContainer;
39 38
import eu.etaxonomy.cdm.vaadin.util.CdmQueryFactory;
40 39
import eu.etaxonomy.cdm.vaadin.util.CdmSpringContextHelper;
41 40
import eu.etaxonomy.cdm.vaadin.view.dbstatus.DistributionTableView;
42
import eu.etaxonomy.cdm.vaadin.view.dbstatus.IDistributionTableComponent;
43 41

  
44 42

  
45
public class DistributionTablePresenter implements IDistributionTableComponent.DistributionTableComponentListener{
46

  
43
public class DistributionTablePresenter {
47 44

  
48 45
	private final IClassificationService classificationService;
49 46
	private final IVocabularyService vocabularyService;
......
53 50
	private final DistributionTableView view;
54 51
	private final ITaxonService taxonService;
55 52

  
56
	public DistributionTablePresenter(DistributionTableView dtv) throws SQLException{
53
	public DistributionTablePresenter(DistributionTableView dtv){
57 54
	    this.view = dtv;
58 55
	    view.addListener(this);
59 56
	    taxonService = CdmSpringContextHelper.getTaxonService();
......
64 61
		termService = CdmSpringContextHelper.getTermService();
65 62
	}
66 63

  
67

  
68
	@Override
69 64
    public int updateDistributionField(String distributionAreaString, Object comboValue, Taxon taxon) {
70 65
	    Set<DefinedTermBase> chosenTerms = getChosenTerms();
71 66
	    NamedArea namedArea = null;
......
115 110
	    return -1;
116 111
	}
117 112

  
118
	@Override
119 113
	public Set<DefinedTermBase> getChosenTerms() {
120 114
		VaadinSession session = VaadinSession.getCurrent();
121 115
		UUID termUUID = (UUID) session.getAttribute("selectedTerm");
......
124 118
		return term.getTerms();
125 119
	}
126 120

  
127

  
128
	@Override
129 121
	public List<String> getAbbreviatedTermList() {
130 122
		SortedSet<DefinedTermBase> terms = getTermSet();
131 123
		List<String> list = new ArrayList<String>();
......
134 126
		        list.add(r.getAbbreviatedLabel());
135 127
		    }
136 128
		}
137
//		Collections.sort(list);
138 129
		return list;
139 130
	}
140 131

  
141
    @Override
142
    public List<String> getTermList() {
143
        SortedSet<DefinedTermBase> terms = getTermSet();
144
        List<String> list = new ArrayList<String>();
145
        for(DefinedTermBase dtb: terms){
146
           list.add(dtb.getTitleCache());
147
        }
148
//      Collections.sort(list);
149
        return list;
150
    }
151

  
152 132
    public List<String> getNamedAreas(){
153 133
    	String selectedAreas = (String) VaadinSession.getCurrent().getAttribute("selectedAreas");
154 134
    	if(CdmUtils.isBlank(selectedAreas)){
155
    	    return getTermList();
135
    	    SortedSet<DefinedTermBase> terms = getTermSet();
136
            List<String> list = new ArrayList<String>();
137
            for(DefinedTermBase dtb: terms){
138
               list.add(dtb.getTitleCache());
139
            }
140
    	    return list;
156 141
    	}
157 142
    	return Arrays.asList(selectedAreas.split(","));
158 143
    }
159 144

  
160

  
161 145
	private SortedSet<DefinedTermBase> getTermSet(){
162 146
	    VaadinSession session = VaadinSession.getCurrent();
163 147
	    UUID termUUID = (UUID) session.getAttribute("selectedTerm");
......
166 150
	    return term.getTermsOrderedByLabels(Language.DEFAULT());
167 151
	}
168 152

  
169
	@Override
170 153
	public HashMap<DescriptionElementBase, Distribution> getDistribution(DefinedTermBase dt, Taxon taxon) {
171 154
		Set<Feature> setFeature = new HashSet<Feature>(Arrays.asList(Feature.DISTRIBUTION()));
172 155
		List<DescriptionElementBase> listTaxonDescription = descriptionService.listDescriptionElementsForTaxon(taxon, setFeature, null, null, null, DESCRIPTION_INIT_STRATEGY);
......
183 166
		}
184 167
		return map;
185 168
	}
186
	@Override
169

  
187 170
	public List<DescriptionElementBase> listDescriptionElementsForTaxon(Taxon taxon, Set<Feature> setFeature){
188 171
		List<DescriptionElementBase> listDescriptionElementsForTaxon = descriptionService.listDescriptionElementsForTaxon(taxon, setFeature, null, null, null, DESCRIPTION_INIT_STRATEGY);
189 172
		sort(listDescriptionElementsForTaxon);
190 173
		return listDescriptionElementsForTaxon;
191 174
	}
192 175

  
193
	@Override
194 176
	public List<Distribution> getDistributions(Taxon taxon) {
195 177
		Set<Feature> setFeature = new HashSet<Feature>(Arrays.asList(Feature.DISTRIBUTION()));
196 178
		List<Distribution> listTaxonDescription = descriptionService.listDescriptionElementsForTaxon(taxon, setFeature, null, null, null, DESCRIPTION_INIT_STRATEGY);
......
198 180

  
199 181
	}
200 182

  
201
	@Override
202 183
	public List<TaxonNode> getAllNodes(){
203 184
		TaxonNode taxonNode = getChosenTaxonNode();
204 185
		List<TaxonNode> nodes = new ArrayList<TaxonNode>();
......
210 191
	}
211 192

  
212 193

  
213
	@Override
214 194
	public TaxonNode getChosenTaxonNode() {
215 195
		VaadinSession session = VaadinSession.getCurrent();
216 196
		UUID taxonNodeUUID = (UUID) session.getAttribute("taxonNodeUUID");
......
218 198
		return classificationNode;
219 199
	}
220 200

  
221
	@Override
222 201
	public int getSizeOfTaxonNode(){
223 202
		TaxonNode taxonNode = getChosenTaxonNode();
224 203
		return taxonNodeService.loadChildNodesOfTaxonNode(taxonNode, null, true, null).size();
225 204
	}
226 205

  
227 206

  
228
	@Override
229 207
	public CdmSQLContainer getSQLContainer() throws SQLException{
230 208
		List<Integer> nodeIds = new ArrayList<Integer>();
231 209
		for (TaxonNode taxonNode : getAllNodes()) {
......
260 238
            "taxon2.name"
261 239
    });
262 240

  
263

  
264
	@Override
265 241
	public IClassificationService getClassificationService() {
266 242
		return classificationService;
267 243
	}
268 244

  
269

  
270
	@Override
271 245
	public IVocabularyService getVocabularyService() {
272 246
		return vocabularyService;
273 247
	}
274 248

  
275

  
276
	@Override
277 249
	public IDescriptionService getDescriptionService() {
278 250
		return descriptionService;
279 251
	}
280 252

  
281

  
282
	@Override
283 253
	public ITaxonNodeService getTaxonNodeService() {
284 254
		return taxonNodeService;
285 255
	}
286 256

  
287

  
288
	@Override
289 257
	public ITermService getTermService() {
290 258
		return termService;
291 259
	}
292

  
293
	@Override
294
	public LazyLoadedContainer getTableContainer() {
295
		return null;
296
	}
297

  
298

  
299

  
300
	@Override
301 260
	public ITaxonService getTaxonService() {
302 261
		return taxonService;
303 262
	}
304 263

  
305

  
306 264
	/**Helper Methods*/
307 265

  
308 266
	private void sort(List<DescriptionElementBase> list){
......
320 278
				}
321 279
			}
322 280
		});
323

  
324 281
	}
325 282
}

Also available in: Unified diff