Project

General

Profile

« Previous | Next » 

Revision c226920a

Added by Fabian Reimeier almost 6 years ago

Documentation and refactoring

View differences:

src/main/java/eu/etaxonomy/cdm/i18n/Messages.java
14 14
import com.vaadin.server.VaadinSession;
15 15

  
16 16
/**
17
 * Internationalization class.
17 18
 * @author freimeier
18 19
 *
19 20
 */
src/main/java/eu/etaxonomy/cdm/vaadin/component/distributionStatus/AreaAndTaxonSettingsConfigWindow.java
59 59
/**
60 60
 *
61 61
 * @author pplitzner
62
 * A Configuration window for choosing distribution areas and taxa to work with.
62 63
 *
63 64
 */
64 65
public class AreaAndTaxonSettingsConfigWindow
65 66
            extends SettingsDialogWindowBase<AreaAndTaxonSettingsPresenter>
66 67
            implements ValueChangeListener, ClickListener, ExpandListener{
67 68

  
69
	/**
70
	 * 
71
	 */
68 72
    private static final long serialVersionUID = 1439411115014088780L;
69 73
    private ComboBox classificationBox;
70 74
    private TextField taxonFilter;
......
85 89
        super();
86 90
        this.distributionTableView = distributionTableView;
87 91
    }
88

  
92
    
93
    /**
94
     * 
95
     * {@inheritDoc}
96
     */
89 97
    @Override
90 98
    protected void init() {
91 99
        //init classification
......
137 145
        updateButtons();
138 146
    }
139 147

  
148
    /**
149
     * 
150
     * {@inheritDoc}
151
     */
140 152
    @Override
141 153
    protected AbstractLayout buildMainLayout() {
142 154

  
......
230 242
        return leftAndRightContainer;
231 243
    }
232 244

  
245
    /**
246
     * 
247
     * {@inheritDoc}
248
     */
233 249
    @Override
234 250
    public void valueChange(ValueChangeEvent event) {
235 251
        Property<?> property = event.getProperty();
......
271 287
        updateButtons();
272 288
    }
273 289

  
290
    /**
291
     * 
292
     * {@inheritDoc}
293
     */
274 294
    @Override
275 295
    protected boolean isValid() {
276 296
        return classificationBox.getValue()!=null && distAreaBox.getValue()!=null;
277 297
    }
278 298

  
299
    /**
300
     * 
301
     * {@inheritDoc}
302
     */
279 303
    @Override
280 304
    public void buttonClick(ClickEvent event) {
281 305
        Object source = event.getSource();
......
305 329
        }
306 330
    }
307 331

  
332
    /**
333
     * 
334
     * {@inheritDoc}
335
     */
308 336
    @Override
309 337
    public void nodeExpand(ExpandEvent event) {
310 338
        UuidAndTitleCache<TaxonNode> parent = (UuidAndTitleCache<TaxonNode>) event.getItemId();
311 339
        ((TaxonNodeContainer) taxonTree.getContainerDataSource()).addChildItems(parent);
312 340
    }
313 341

  
342
    /**
343
     * Starts a {@link TreeUpdater} thread to populate the {@link #taxonTree} with taxa of the classification specified by the given {@code rootNode}.
344
     * @param rootNode The root node of the classification whose taxa should be shown in the {@link #taxonTree}.
345
     */
314 346
    private void showClassificationTaxa(TaxonNode rootNode) {
315 347
        final Collection<UuidAndTitleCache<TaxonNode>> children = CdmSpringContextHelper.getTaxonNodeService().listChildNodesAsUuidAndTitleCache(rootNode);
316 348
        // Enable polling and set frequency to 0.5 seconds
......
318 350
        taxonTree.setEnabled(false);
319 351
        taxonTree.removeAllItems();
320 352
        Notification.show(Messages.getLocalizedString(Messages.AreaAndTaxonSettingsConfigWindow_LOADING_TAXA));
321

  
322 353
        new TreeUpdater(children).start();
323 354
    }
324 355

  
356
    /**
357
     * Returns the {@link UuidAndTitleCache} object of the classification specified by the given {@link RowId} of the {@link CdmSQLContainer} used in the {@link #classificationBox}.
358
     * @param classificationSelection
359
     * @return {@link UuidAndTitleCache} object of the given classification specified by {@code classificationSelection}
360
     */
325 361
    private UuidAndTitleCache<TaxonNode> getUuidAndTitleCacheFromRowId(Object classificationSelection) {
326 362
        String uuidString = (String) classificationBox.getContainerProperty(classificationSelection, "uuid").getValue(); //$NON-NLS-1$
327 363
        Property<Integer> rootNodeContainerProperty = null;
......
350 386
        return new AreaAndTaxonSettingsPresenter();
351 387
    }
352 388

  
389
    /**
390
     * Thread to populate {@link AreaAndTaxonSettingsConfigWindow#taxonTree}.
391
     *
392
     */
353 393
    private class TreeUpdater extends Thread{
354

  
394
    
395
    	/**
396
    	 * The taxa to show.
397
    	 */
355 398
    	private Collection<UuidAndTitleCache<TaxonNode>> children;
356 399

  
357

  
400
    	/**
401
    	 * Creates a thread to show the given collection of taxa in {@link AreaAndTaxonSettingsConfigWindow#taxonTree}.
402
    	 * @param children {@link UuidAndTitleCache} of the taxa to show.
403
    	 */
358 404
		public TreeUpdater(Collection<UuidAndTitleCache<TaxonNode>> children) {
359 405
			this.children = children;
360 406
		}
361 407

  
408
		/**
409
		 * 
410
		 * {@inheritDoc}
411
		 */
362 412
		@Override
363 413
    	public void run() {
364 414
			UI.getCurrent().access(new Runnable() {
415
				/**
416
				 * 
417
				 * {@inheritDoc}
418
				 */
365 419
				@Override
366 420
				public void run() {
367 421
					taxonTree.setContainerDataSource(new TaxonNodeContainer(children));
src/main/java/eu/etaxonomy/cdm/vaadin/component/distributionStatus/DetailWindow.java
22 22
import eu.etaxonomy.cdm.model.description.TextData;
23 23
import eu.etaxonomy.cdm.model.taxon.Taxon;
24 24

  
25

  
25
/**
26
 * A window to display details of a taxon.
27
 *
28
 */
26 29
@Scope("prototype")
27 30
public class DetailWindow extends CustomComponent{
28 31

  
......
30 33
	private final Collection<DescriptionElementBase> listDescriptions;
31 34
	private final Taxon taxon;
32 35

  
36
	/**
37
	 * Displays a window showing the given details of the given taxon.
38
	 * @param taxon The taxon the details belong to.
39
	 * @param listDescriptions The details to show.
40
	 */
33 41
	public DetailWindow(Taxon taxon, Collection<DescriptionElementBase> listDescriptions) {
34 42
		this.taxon = taxon;
35 43
		this.listDescriptions = listDescriptions;
36 44

  
37 45
	}
38 46

  
47
	/**
48
	 * Creates the detail window.
49
	 * @return Window to be displayed.
50
	 */
39 51
	public Window createWindow(){
40 52
		Window window = new Window();
41 53
		window.setHeightUndefined();
......
47 59
			window.setContent(new Label(Messages.getLocalizedString(Messages.DetailWindow_NO_DESCRIPTIVE_DATA_FOUND)));
48 60
		}
49 61
		else{
50
			window.setContent(constructDescriptionTree(taxon));
62
			window.setContent(constructDescriptionTree());
51 63
		}
52 64
		return window;
53 65
	}
54 66

  
55
	private Tree constructDescriptionTree(Taxon taxon){
67
	/**
68
	 * Creates a tree view of the details contained in {@link #listDescriptions}.
69
	 * @return Tree of details contained in {@link #listDescriptions}.
70
	 */
71
	private Tree constructDescriptionTree(){
56 72
		Tree tree = new Tree();
57 73
		tree.setSizeUndefined();
58 74
		String parent = "Descriptive Data"; //$NON-NLS-1$
......
61 77
		return tree;
62 78
	}
63 79

  
80
	/**
81
	 * Populates a given {@link Tree} with the details contained in {@code listDescriptions} and sets its root to {@code parent}. 
82
	 * @param tree The tree to populate.
83
	 * @param listDescriptions The details to show.
84
	 * @param parent The root of the tree.
85
	 */
64 86
	private void initDescriptionTree(Tree tree, Collection<DescriptionElementBase>listDescriptions, Object parent) {
65 87
		//TODO: sorting List
66 88
		for (DescriptionElementBase deb : listDescriptions){
src/main/java/eu/etaxonomy/cdm/vaadin/component/distributionStatus/DistributionStatusSettingsConfigWindow.java
28 28
import eu.etaxonomy.cdm.vaadin.view.distributionStatus.settings.DistributionStatusSettingsPresenter;
29 29

  
30 30
/**
31
 *A configuration window to set the available distribution status and toggle the usage of
32
 *abbreviated labels.
31 33
 * @author alex
32 34
 * @since 22.04.2015
33 35
 *
......
54 56
    	this.distributionTableView = distributionTableView;
55 57
    }
56 58

  
59
    /**
60
     * 
61
     * {@inheritDoc}
62
     */
57 63
    @Override
58 64
    protected void init() {
59 65
        boxToggleAbbreviatedLabels.addValueChangeListener(this);
......
66 72
        updateButtons();
67 73
    }
68 74

  
75
    /**
76
     * 
77
     * {@inheritDoc}
78
     */
69 79
    @Override
70 80
    protected AbstractLayout buildMainLayout() {
71 81

  
......
102 112
        return mainLayout;
103 113
    }
104 114

  
115
    /**
116
     * 
117
     * {@inheritDoc}
118
     */
105 119
    @Override
106 120
    protected boolean isValid() {
107 121
    	return true;
108 122
    }
109

  
123
    
124
    /**
125
     * 
126
     * {@inheritDoc}
127
     */
110 128
	@Override
111 129
	public void valueChange(ValueChangeEvent event) {
112 130
		Property<?> property = event.getProperty();
......
115 133
		}
116 134
	}
117 135

  
136
	/**
137
	 * 
138
	 * {@inheritDoc}
139
	 */
118 140
	@Override
119 141
	public void buttonClick(ClickEvent event) {
120 142
		Object source = event.getSource();
src/main/java/eu/etaxonomy/cdm/vaadin/component/distributionStatus/DistributionToolbar.java
24 24
import eu.etaxonomy.vaadin.ui.navigation.NavigationEvent;
25 25
import eu.etaxonomy.vaadin.ui.navigation.NavigationManager;
26 26

  
27
/**
28
 * A toolbar for the distribution app. Displayed at the top of the screen.
29
 */
27 30
@SpringComponent("distributionToolbar")
28 31
@ViewScope
29 32
public class DistributionToolbar extends HorizontalLayout implements Serializable{
......
72 75
//	private final Authentication authentication;
73 76
//	private ExcelExporter exporter = new ExcelExporter();
74 77

  
78
	/**
79
	 * Constructs the toolbar.
80
	 */
75 81
	@PostConstruct
76 82
    public void init() {
77 83
		setMargin(true);
......
109 115
		updateAuthenticationButtons();
110 116
    }
111 117

  
118
	/**
119
	 * Called when authentication was successful. Updates the user menu buttons.
120
	 * @param event
121
	 */
112 122
	@EventBusListenerMethod
113 123
    public void onAuthenticationSuccessEvent(org.vaadin.spring.events.Event<AuthenticationSuccessEvent> event){
114 124
        boolean isInitialized = userButton != null;
......
120 130
        }
121 131
    }
122 132

  
123
    /**
124
     * @param event
125
     */
133
	/**
134
	 * Updates the user menu buttons on login and logout.
135
	 */
126 136
    protected void updateAuthenticationButtons() {
127 137
        if(userHelper.userIsAutheticated() && !userHelper.userIsAnnonymous()){
128 138
            userButton.setCaption(userHelper.userName());
......
154 164
        uiEventBus.publish(this, new NavigationEvent("login", navigationManager.getCurrentViewName())); //$NON-NLS-1$
155 165
    }
156 166

  
157

  
167
    /**
168
     * Logs the user out and closes the session.
169
     */
158 170
    private void performLogout() {
159 171
        userHelper.logout();
160 172
        updateAuthenticationButtons();
161 173
        navigationManager.reloadCurrentView();
162 174
    }
163 175

  
176
    /**
177
     * The settings button.
178
     * @return
179
     */
164 180
    public Button getSettingsButton(){
165 181
        return settingsButton;
166 182
    }
167 183

  
184
    /**
185
     * Button to open the {@link DistributionStatusSettingsConfigWindow}.
186
     * @return Button to display the {@link DistributionStatusSettingsConfigWindow}.
187
     */
168 188
    public Button getDistributionSettingsButton() {
169 189
		return distributionSettingsButton;
170 190
	}
171 191

  
192
    /**
193
     * Unused.
194
     * @return
195
     */
172 196
	public Button getEditButton() {
173 197
		return editButton;
174 198
	}
175 199

  
200
	/**
201
	 * Unused.
202
	 * @return
203
	 */
176 204
	public Button getSaveButton() {
177 205
		return saveButton;
178 206
	}
179 207

  
208
	/**
209
	 * Button to open the {@link DetailWindow}.
210
	 * @return  Button to open the {@link DetailWindow}.
211
	 */
180 212
	public Button getDetailButton() {
181 213
		return detailButton;
182 214
	}
183 215

  
184
   public Button getHelpButton() {
185
        return helpButton;
186
    }
216
	/**
217
	 * Button to open the {@link HelpWindow}.
218
	 * @return Button to open the {@link HelpWindow}.
219
	 */
220
	public Button getHelpButton() {
221
		return helpButton;
222
	}
187 223
}
src/main/java/eu/etaxonomy/cdm/vaadin/component/distributionStatus/HelpWindow.java
25 25
import eu.etaxonomy.cdm.vaadin.view.distributionStatus.IDistributionTableView;
26 26

  
27 27
/**
28
 * A help window to display useful information on the usage of the distribution editor.
28 29
 * @author freimeier
29 30
 * @since 9 Mar 2018
30 31
 *
......
34 35
    private AbstractOrderedLayout mainLayout;
35 36
    private IDistributionTableView view;
36 37

  
38
    /**
39
     * Creates a new help window.
40
     * @param view The view the help window is related to.
41
     */
37 42
    public HelpWindow(IDistributionTableView view) {
38 43
        this.view = view;
39 44
        buildMainLayout();
40 45
    }
41 46

  
47
    /**
48
     * Builds the layout of the help window and populates it with content.
49
     * @return Layout of the help window.
50
     */
42 51
    private AbstractLayout buildMainLayout() {
43 52
        mainLayout = new VerticalLayout();
44 53
        mainLayout.setSizeFull();
......
59 68
        return mainLayout;
60 69
    }
61 70

  
71
    /**
72
     * Creates the help window to display.
73
     * @param caption The caption of the window.
74
     * @return Help window to be displayed.
75
     */
62 76
    public Window createWindow(String caption) {
63 77
        window = new Window();
64 78
        window.setModal(true);
src/main/java/eu/etaxonomy/cdm/vaadin/component/distributionStatus/SettingsDialogWindowBase.java
10 10
import eu.etaxonomy.cdm.i18n.Messages;
11 11
import eu.etaxonomy.cdm.vaadin.view.distributionStatus.settings.SettingsPresenterBase;
12 12

  
13

  
14
/**
15
 * A base class for setting dialog windows.
16
 * 
17
 * @author fabreim
18
 * @since May 17, 2018
19
 *
20
 * @param <P> The SettingsPresenterBase the SettingsDialog is used for.
21
 */
13 22
@SuppressWarnings("serial")
14 23
public abstract class SettingsDialogWindowBase<P extends SettingsPresenterBase> extends CustomComponent {
15 24

  
......
25 34
        init();
26 35
	}
27 36

  
37
	/**
38
	 * Returns the presenter the settings window belongs to.
39
	 * @return The presenter the settings window belongs to. 
40
	 */
28 41
    protected abstract P getPresenter();
29 42

  
43
    /**
44
     * Builds the layout of the settings window.
45
     * @return Layout of the settings window.
46
     */
30 47
    protected abstract AbstractLayout buildMainLayout();
31 48

  
49
    /**
50
     * Initializes the settings window and populates it with content.
51
     */
32 52
	protected abstract void init();
33 53

  
34 54
	protected HorizontalLayout createOkCancelButtons() {
......
49 69
		return buttonToolBar;
50 70
	}
51 71

  
72
	/**
73
	 * Creates the settings window and sets its caption.
74
	 * @param caption The caption of the window.
75
	 * @return The settings window to be displayed.
76
	 */
52 77
	public Window createWindow(String caption) {
53 78
	    window = new Window();
54 79
	    window.setModal(true);
src/main/java/eu/etaxonomy/cdm/vaadin/container/NamedAreaContainer.java
12 12
import eu.etaxonomy.cdm.model.common.TermVocabulary;
13 13
import eu.etaxonomy.cdm.model.location.NamedArea;
14 14

  
15
/**
16
 * A container containing the {@link NamedArea}s of a specified {@link TermVocabulary}.
17
 * @author fabreim
18
 * @since May 17, 2018
19
 */
15 20
public class NamedAreaContainer extends BeanItemContainer<NamedArea> {
16 21

  
17 22
    private static final long serialVersionUID = 9150424479597481361L;
18 23

  
24
    /**
25
     * Creates a NamedAreaContainer containing all {@link NamedArea}s of the given {@code vocabulary} 
26
     * in alphabetically ascending order.
27
     * @param vocabulary The vocabulary containing the {@link NamedArea}s to populate the container with.
28
     * @throws IllegalArgumentException
29
     */
19 30
	public NamedAreaContainer(TermVocabulary<NamedArea> vocabulary)
20 31
	        throws IllegalArgumentException {
21 32
	    super(NamedArea.class);
......
34 45
	    }
35 46
	}
36 47

  
48
	/**
49
	 * Comparator to sort the {@link NamedArea}s contained in {@link NamedAreaContainer}s.
50
	 *
51
	 */
37 52
	private class AlphabeticallyAscendingNamedAreaComparator implements Comparator<NamedArea>{
38 53

  
54
		/**
55
		 * 
56
		 * {@inheritDoc}
57
		 */
39 58
        @Override
40 59
        public int compare(NamedArea o1, NamedArea o2) {
41 60
            return o2.compareTo(o1);
src/main/java/eu/etaxonomy/cdm/vaadin/container/PresenceAbsenceTermContainer.java
27 27

  
28 28
	private static Collection<PresenceAbsenceTerm> defaultDistributionStatus;
29 29

  
30
	/**
31
	 * A comparator to sort {@link PresenceAbsenceTerm}s contained in {@link PresenceAbsenceTermContainer}s.
32
	 *
33
	 */
30 34
    static class PresenceAbsenceTermComparator implements Comparator<PresenceAbsenceTerm> {
31 35
        @Override
32 36
        public int compare(PresenceAbsenceTerm pa1, PresenceAbsenceTerm pa2) {
......
35 39

  
36 40
    }
37 41

  
42
    /**
43
     * Creates and initializes a new {@link PresenceAbsenceTermContainer}.
44
     * @throws IllegalArgumentException
45
     */
38 46
	private PresenceAbsenceTermContainer()
39 47
			throws IllegalArgumentException {
40 48
		super(PresenceAbsenceTerm.class);
41 49
		initDataModel();
42 50
	}
43 51

  
52
	/**
53
	 * Initializes the data model of the container and adds all allowed {@link PresenceAbsenceTerm}s to the bean.
54
	 */
44 55
    private void initDataModel() {
45 56
        Collection<PresenceAbsenceTerm> distributionStatus = getDistributionStatusList(TERMS_INIT_STRATEGY);
46 57
        defaultDistributionStatus = distributionStatus;
47 58
		addAll(distributionStatus);
48 59
    }
49 60

  
61
    /**
62
     * Gets an existing instance of the {@link PresenceAbsenceTermContainer} or creates a new one.
63
     * @return Instance of {@link PresenceAbsenceTermContainer}.
64
     */
50 65
	public static PresenceAbsenceTermContainer getInstance(){
51 66
	    if(instance == null){
52 67
	        instance = new PresenceAbsenceTermContainer();
......
64 79
	    return instance;
65 80
	}
66 81

  
82
	/**
83
	 * Returns a list of all allowed {@link PresenceAbsenceTerm}s.
84
	 * @param propertyPath The property path to use for calling {@link CdmSpringContextHelper} functions to load {@link PresenceAbsenceTerm}s.
85
	 * @return List of all allowed {@link PresenceAbsenceTerm}s.
86
	 */
67 87
    public static List<PresenceAbsenceTerm> getDistributionStatusList(List<String> propertyPath){
68 88
        CdmPreference statusPref = CdmSpringContextHelper.getPreferenceService().findVaadin(PreferencePredicate.AvailableDistributionStatus);
69 89
        List<PresenceAbsenceTerm> paList;
src/main/java/eu/etaxonomy/cdm/vaadin/ui/DistributionStatusUI.java
41 41
    @Autowired
42 42
    NavigationManagerBean navigator;
43 43

  
44
    /**
45
     * Sets the access AcessDeniedView for the UI.
46
     */
44 47
    protected void configureAccessDeniedView() {
45 48
        viewProvider.setAccessDeniedViewClass(RedirectToLoginView.class);
46 49
    }
47 50

  
48 51
    /**
49
     * @return
52
     * Returns the state of the UI.
53
     * @return State of the UI.
50 54
     */
51 55
    private String pageFragmentAsState() {
52 56
        Page page = Page.getCurrent();
......
68 72
    @Autowired
69 73
    UIEventBus uiEventBus;
70 74

  
75
    /**
76
     * Creates a new DistributionStatusUI.
77
     */
71 78
    public DistributionStatusUI() {
72 79

  
73 80
    }
74 81

  
82
    /**
83
     * 
84
     * {@inheritDoc}
85
     */
75 86
	@Override
76 87
	protected void init(VaadinRequest request) {
77 88

  
src/main/java/eu/etaxonomy/cdm/vaadin/util/DistributionEditorUtil.java
10 10

  
11 11
import eu.etaxonomy.cdm.model.common.TermVocabulary;
12 12
import eu.etaxonomy.cdm.model.location.NamedArea;
13
import eu.etaxonomy.cdm.model.taxon.Classification;
14
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
13 15
import eu.etaxonomy.cdm.vaadin.view.distributionStatus.IDistributionTableView;
14 16

  
17
/**
18
 * A utility class for the distribution status editor.
19
 *
20
 */
15 21
public class DistributionEditorUtil {
16 22

  
17 23
	public static final String VIEW_TABLE = "table";
......
30 36

  
31 37
    public static final String SEPARATOR = ";;";
32 38

  
39
    /**
40
     * Updates the vaadin session attributes related to the chosen 
41
     * {@link TaxonNode}s, {@link NamedArea}s and {@link Classification}
42
     * and refreshes the given {@code distributionStatusTableView}.
43
     * @param distributionTableView The view to refresh after updating the session variables.
44
     * @param taxonNodes The taxa to be shown in the {@code distributionTableView}.
45
     * @param areaVoc The {@link TermVocabulary} of {@link NamedArea}s to be used.
46
     * @param selectedAreas The {@link NamedArea}s to be availbale in the {@code distributionTableView}.
47
     * @param classificationUuid The {@link UUID} of the {@link Classification} the {@code taxonNodes} belong to.
48
     */
33 49
    public static void updateDistributionView(IDistributionTableView distributionTableView, List<UUID> taxonNodes, TermVocabulary<NamedArea> areaVoc,
34 50
            List<NamedArea> selectedAreas, UUID classificationUuid) {
35 51
	    VaadinSession.getCurrent().setAttribute(SATTR_TAXON_NODES_UUID, taxonNodes);
......
39 55
	    distributionTableView.update();
40 56
	}
41 57

  
58
    /**
59
     * Clears the session attributes related to the chosen 
60
     * {@link TaxonNode}s, {@link TermVocabulary} of {@link NamedArea}s,
61
     * {@link NamedArea}s and {@link Classification}.
62
     */
42 63
    public static void clearSessionAttributes(){
43 64
    	VaadinSession.getCurrent().setAttribute(SATTR_TAXON_NODES_UUID, null);
44 65
    	VaadinSession.getCurrent().setAttribute(SATTR_SELECTED_AREA_VOCABULARY_UUID, null);
......
46 67
    	VaadinSession.getCurrent().setAttribute(SATTR_CLASSIFICATION, null);
47 68
    }
48 69

  
70
    /**
71
     * Returns {@code true} if abbreviated labels should be used.
72
     * @return {@code true} if abbreviated labels should be used.
73
     */
49 74
    public static boolean isAbbreviatedLabels(){
50 75
    	Object isAbbreviated = VaadinSession.getCurrent().getAttribute(DistributionEditorUtil.SATTR_ABBREVIATED_LABELS);
51 76
		return (isAbbreviated==null || (boolean) isAbbreviated);
52 77
    }
53 78

  
79
    /**
80
     * Shows an {@link SQLException} to the user.
81
     * @param e The exception to show.
82
     */
54 83
	public static void showSqlError(SQLException e) {
55 84
		Notification.show("Error while accessing data base.","Cause: "+e.getMessage(), Type.ERROR_MESSAGE);
56 85
		e.printStackTrace();
src/main/java/eu/etaxonomy/cdm/vaadin/util/DistributionStatusQuery.java
19 19
import java.util.UUID;
20 20

  
21 21
import org.springframework.transaction.TransactionStatus;
22
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
22 23
import org.vaadin.addons.lazyquerycontainer.Query;
23 24
import org.vaadin.addons.lazyquerycontainer.QueryDefinition;
24 25

  
......
37 38
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
38 39

  
39 40
/**
41
 * A {@link Query} for populating a {@link LazyQueryContainer} with distribution status data.
42
 * Currently unused.
43
 * 
40 44
 * @author freimeier
41 45
 * @since 16.11.2017
42
 *
43 46
 */
44

  
45 47
public class DistributionStatusQuery implements Query{
46 48
    public static final String DTYPE_COLUMN = "DTYPE";
47 49
    public static final String ID_COLUMN = "id";
......
55 57
    private List<UUID> nodeUuids;
56 58
    private List<NamedArea> namedAreas;
57 59

  
60
    /**
61
     * Creates a new DistributionStatusQuery which will return distribution status information
62
     * found in the specified {@link CdmRepository} for the {@link TaxonNode}s given by {@code nodeUuids} and the specified {@link NamedArea}s.
63
     * @param repo The repo to search for information.
64
     * @param nodeUuids The {@link UUID}s of {@link TaxonNode}s to search information for.
65
     * @param namedAreas The list of {@link NamedArea}s the distribution information should be related to.
66
     * @param definition The query definition to be used.
67
     */
58 68
    public DistributionStatusQuery(CdmRepository repo, List<UUID> nodeUuids, List<NamedArea> namedAreas, QueryDefinition definition) {
59 69
        this.repo = repo;
60 70
        this.nodeUuids = nodeUuids;
......
62 72
        this.definition = definition;
63 73
    }
64 74

  
65
    /* (non-Javadoc)
66
     * @see org.vaadin.addons.lazyquerycontainer.Query#constructItem()
75
    /**
76
     * 
77
     * {@inheritDoc}
67 78
     */
68 79
    @Override
69 80
    public Item constructItem() {
70 81
        return null;
71 82
    }
72

  
73
    /* (non-Javadoc)
74
     * @see org.vaadin.addons.lazyquerycontainer.Query#deleteAllItems()
75
     */
83
    
84
   /**
85
    * 
86
    * {@inheritDoc}
87
    */
76 88
    @Override
77 89
    public boolean deleteAllItems() {
78 90
        return false;
79 91
    }
80 92

  
81
    /* (non-Javadoc)
82
     * @see org.vaadin.addons.lazyquerycontainer.Query#loadItems(int, int)
83
     */
93
	/**
94
	 * 
95
	 * {@inheritDoc}
96
	 */
84 97
    @Override
85 98
    public List<Item> loadItems(int startIndex, int count) {
86 99
        List<Item> items = new ArrayList<>();
......
106 119
        return items;
107 120
    }
108 121

  
109
    /* (non-Javadoc)
110
     * @see org.vaadin.addons.lazyquerycontainer.Query#saveItems(java.util.List, java.util.List, java.util.List)
122
    /**
123
     * 
124
     * {@inheritDoc}
111 125
     */
112 126
    @Override
113 127
    public void saveItems(List<Item> addedItems, List<Item> modifiedItems, List<Item> removedItems) {
......
123 137
        }
124 138
    }
125 139

  
126
    /* (non-Javadoc)
127
     * @see org.vaadin.addons.lazyquerycontainer.Query#size()
140
    /**
141
     * 
142
     * {@inheritDoc}
128 143
     */
129 144
    @Override
130 145
    public int size() {
131 146
        return this.nodeUuids.size();
132 147
    }
133 148

  
149
    /**
150
     * Returns a map which maps {@link NamedArea}s to the related distribution status for the given {@code taxon}.
151
     * @param taxon The taxon the map should contain information for.
152
     * @return Map of {@link NamedArea}s and the related distribution status for the given {@code taxon}.
153
     */
134 154
    private Map<NamedArea, PresenceAbsenceTerm> getAreaToDistributionStatusMap(Taxon taxon) {
135 155
        Map<NamedArea, PresenceAbsenceTerm> distributionStatusMap = new HashMap<>();
136 156

  
......
144 164
        return distributionStatusMap;
145 165
    }
146 166

  
167
    /**
168
     * Updates the given taxon with the distribution information contained in {@code areaToDistributionStatusUuidMap}.
169
     * @param taxon The taxon to be updated.
170
     * @param areaToDistributionStatusUuidMap The information to update the taxon with.
171
     */
147 172
    private void updateDistributionStatus(Taxon taxon,  Map<NamedArea, UUID> areaToDistributionStatusUuidMap) {
148 173
        CdmRepository repo = this.repo;
149 174
        TransactionStatus tx = repo.startTransaction();
......
195 220
        repo.commitTransaction(tx);
196 221
    }
197 222

  
223
    /**
224
     * Returns the distribution information of the given {@code taxon}.
225
     * @param taxon The taxon to get the distribution information of.
226
     * @return The distribution information of the given {@code taxon}.
227
     */
198 228
    private List<Distribution> getDistributions(Taxon taxon) {
199 229
        Set<Feature> setFeature = new HashSet<>(Arrays.asList(Feature.DISTRIBUTION()));
200 230
        List<Distribution> listTaxonDescription = CdmSpringContextHelper.getDescriptionService()
src/main/java/eu/etaxonomy/cdm/vaadin/util/DistributionStatusQueryDefinition.java
18 18
import eu.etaxonomy.cdm.model.location.NamedArea;
19 19

  
20 20
/**
21
 * The {@link LazyQueryDefinition} to be used by {@link DistributionStatusQuery}.
21 22
 * @author freimeier
22 23
 * @since 22.11.2017
23 24
 *
......
29 30
    private List<NamedArea> namedAreas;
30 31

  
31 32
    /**
32
     * @param repo
33
     * @param nodeUuids
34
     * @param namedAreas
35
     * @param compositeItems
36
     * @param batchSize
37
     * @param idPropertyId
33
     * Creates a new {@link LazyQueryDefinition} to be used by {@link DistributionStatusQuery}.
34
     * @param namedAreas The {@link NamedArea}s to get distribution information for.
35
     * @param compositeItems True if native items should be wrapped to CompositeItems.
36
     * @param batchSize Value for batch size.
38 37
     */
39 38
    public DistributionStatusQueryDefinition(List<NamedArea> namedAreas,
40 39
            boolean compositeItems, int batchSize) {
src/main/java/eu/etaxonomy/cdm/vaadin/util/DistributionStatusQueryFactory.java
17 17

  
18 18
import eu.etaxonomy.cdm.api.application.CdmRepository;
19 19
import eu.etaxonomy.cdm.model.location.NamedArea;
20
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
20 21

  
21 22
/**
23
 * The {@link QueryFactory} to generate {@link DistributionStatusQuery}.
22 24
 * @author freimeier
23 25
 * @since 16.11.2017
24
 *
25 26
 */
26 27
public class DistributionStatusQueryFactory implements QueryFactory{
27 28
    CdmRepository repo;
28 29
    List<UUID> nodeUuids;
29 30
    List<NamedArea> namedAreas;
30 31

  
32
    /**
33
     * Creates a new DistributionStatusQueryFactory which generates {@link DistributionStatusQuery}
34
     * which return distribution status information found in the specified {@link CdmRepository}
35
     * for the {@link TaxonNode}s given by {@code nodeUuids} and the specified {@link NamedArea}s.
36
     * @param repo The repo to search for information.
37
     * @param nodeUuids The {@link UUID}s of {@link TaxonNode}s to search information for.
38
     * @param namedAreas The list of {@link NamedArea}s the distribution information should be related to.
39
     */
31 40
    public DistributionStatusQueryFactory(CdmRepository repo, List<UUID> nodeUuids, List<NamedArea> namedAreas) {
32 41
        this.repo = repo;
33 42
        this.nodeUuids = nodeUuids;
34 43
        this.namedAreas = namedAreas;
35 44
    }
36 45

  
37
    /* (non-Javadoc)
38
     * @see org.vaadin.addons.lazyquerycontainer.QueryFactory#constructQuery(org.vaadin.addons.lazyquerycontainer.QueryDefinition)
46
    /**
47
     * 
48
     * {@inheritDoc}
39 49
     */
40 50
    @Override
41 51
    public Query constructQuery(QueryDefinition definition) {
src/main/java/eu/etaxonomy/cdm/vaadin/view/distributionStatus/DistributionTablePresenter.java
62 62
import eu.etaxonomy.vaadin.mvp.AbstractPresenter;
63 63

  
64 64
/**
65
 * @author freimeier
66
 * @since 18.10.2017
67
 *
65
 * The presenter of the distribution status editor. 
66
 * 
68 67
 */
69 68
@SpringComponent
70 69
@ViewScope
......
87 86
        // no point subscribing
88 87
    }
89 88

  
89
    /**
90
     * Changes the distribution status of the given {@link Taxon} for the given {@link NamedArea} to the sepcified {@link PresenceAbsenceTerm}.  
91
     * @param area The area to update the distribution status for.
92
     * @param distributionStatus The distribution status to update the taxon with.
93
     * @param taxon The taxon to be updated.
94
     * @return 
95
     * {@code 0} if the update was successful. 
96
     * {@code 1} if the distributionStatus was null and the {@link DescriptionElementBase} was deleted successfully.
97
     * {@code -1} if an error occurred.
98
     */
90 99
    public int updateDistributionField(NamedArea area, PresenceAbsenceTerm distributionStatus, Taxon taxon) {
91 100
	    TransactionStatus tx = repo.startTransaction();
92 101
	    taxon = (Taxon)repo.getTaxonService().find(taxon.getUuid());
......
137 146
	    return -1;
138 147
	}
139 148

  
149
    /**
150
     * Returns a {@link CdmSQLContainer} containing the distribution status information
151
     * for the chosen {@link TaxonNode}s and {@link NamedArea}s.
152
     * @return  {@link CdmSQLContainer} containing the distribution status information
153
     *  for the chosen {@link TaxonNode}s and {@link NamedArea}s.
154
     * @throws SQLException
155
     */
140 156
    public CdmSQLContainer getSQLContainer() throws SQLException{
141 157
         List<Integer> nodeIds = new ArrayList<>();
142 158
         for (TaxonNode taxonNode : getAllNodes()) {
......
149 165
         return null;
150 166
    }
151 167

  
168
    /**
169
     * Returns a {@link PresenceAbsenceTermContainer} containing all allowed and chosen {@link PresenceAbsenceTerm}s. 
170
     * @return {@link PresenceAbsenceTermContainer} containing all allowed and chosen {@link PresenceAbsenceTerm}s.
171
     */
152 172
    public PresenceAbsenceTermContainer getPresenceAbsenceTermContainer() {
153 173
        return PresenceAbsenceTermContainer.getInstance();
154 174
    }
155 175

  
176
    /**
177
     * Returns a list of {@link DescriptionElementBase}s for the specified {@link Taxon} and {@link Feature} set.
178
     * @param taxon The {@link Taxon} to get the descriptions for.
179
     * @param setFeature The features to get the descriptions for.
180
     * @return List of {@link DescriptionElementBase}s for the specified {@link Taxon} and {@link Feature} set.
181
     */
156 182
    public List<DescriptionElementBase> listDescriptionElementsForTaxon(Taxon taxon, Set<Feature> setFeature){
157 183
        List<DescriptionElementBase> listDescriptionElementsForTaxon = CdmSpringContextHelper.getDescriptionService().listDescriptionElementsForTaxon(taxon, setFeature, null, null, null, DESCRIPTION_INIT_STRATEGY);
158 184
        sort(listDescriptionElementsForTaxon);
159 185
        return listDescriptionElementsForTaxon;
160 186
    }
161 187

  
188
    /**
189
     * Returns the list of {@link NamedArea}s for which the distribution status can't be updated.
190
     * @return List of {@link NamedArea}s for which the distribution status can't be updated.
191
     */
162 192
    public List<NamedArea> getReadOnlyAreas(){
163 193
        List<NamedArea> readonly = new ArrayList<>();
164 194
        // TODO: HACK FOR RL 2017: Remove as soon as possible by receiving read only areas from cdm preferences
......
166 196
        return readonly;
167 197
    }
168 198

  
199
    /**
200
     * Returns the {@link NamedArea} referred to by the given {@code areaString}.
201
     * @param areaString An string referring to a {@link NamedArea}.
202
     * @return The {@link NamedArea} referred to by the given {@code areaString}.
203
     */
169 204
    public NamedArea getAreaFromString(String areaString){
170 205
        List<NamedArea> namedAreas = getChosenAreas();
171 206
        NamedArea area = null;
......
193 228
        return area;
194 229
    }
195 230

  
231
    /**
232
     * Returns the {@link Distribution} of the given {@link Taxon}. 
233
     * @param taxon Taxon to get the {@link Distribution} of.
234
     * @return {@link Distribution} of the given {@link Taxon}.
235
     */
196 236
    private List<Distribution> getDistributions(Taxon taxon) {
197 237
        Set<Feature> setFeature = new HashSet<>(Arrays.asList(Feature.DISTRIBUTION()));
198 238
        List<Distribution> listTaxonDescription = CdmSpringContextHelper.getDescriptionService()
......
201 241

  
202 242
    }
203 243

  
244
    /**
245
     * Returns the list of chosen {@link NamedArea}s defined in the 
246
     * related vaadin session attribute {@link DistributionEditorUtil#SATTR_SELECTED_AREAS}.
247
     * If this vaadin session attribute is not set, all allowed {@link NamedArea}s of the 
248
     * chosen {@link TermVocabulary} defined by the vaadin session attribute
249
     * {@link DistributionEditorUtil#SATTR_SELECTED_AREA_VOCABULARY_UUID} are returned.
250
     * @return List of chosen {@link NamedArea}s defined in the 
251
     * related vaadin session attribute {@link DistributionEditorUtil#SATTR_SELECTED_AREAS}.
252
     * If this vaadin session attribute is not set, all allowed {@link NamedArea}s of the 
253
     * chosen {@link TermVocabulary} defined by the vaadin session attribute
254
     * {@link DistributionEditorUtil#SATTR_SELECTED_AREA_VOCABULARY_UUID}.
255
     */
204 256
	private List<NamedArea> getChosenAreas(){
205 257
	    List<NamedArea> namedAreas = (List<NamedArea>)VaadinSession.getCurrent().getAttribute(DistributionEditorUtil.SATTR_SELECTED_AREAS);
206 258
	    if(namedAreas!=null && namedAreas.isEmpty()){
......
209 261
	    return namedAreas;
210 262
	}
211 263

  
264
	/**
265
	 * Returns all {@link NamedArea}s of the {@link TermVocabulary} defined 
266
	 * by the vaadin session attribute {@link DistributionEditorUtil#SATTR_SELECTED_AREA_VOCABULARY_UUID}
267
	 * ordered by labels.
268
	 * @return all {@link NamedArea}s of the {@link TermVocabulary} defined 
269
	 * by the vaadin session attribute {@link DistributionEditorUtil#SATTR_SELECTED_AREA_VOCABULARY_UUID}
270
	 * ordered by labels..
271
	 */
212 272
	private List<NamedArea> getChosenAreasFromVoc(){
213 273
	    VaadinSession session = VaadinSession.getCurrent();
214 274
	    UUID vocUUID = (UUID) session.getAttribute(DistributionEditorUtil.SATTR_SELECTED_AREA_VOCABULARY_UUID);
......
224 284

  
225 285
	}
226 286

  
227
   private List<TaxonNode> getChosenTaxonNodes() {
228
        VaadinSession session = VaadinSession.getCurrent();
287
	/**
288
	 * Returns all {@link TaxonNode}s defined by the 
289
	 * vaadin session attribute {@link DistributionEditorUtil#SATTR_TAXON_NODES_UUID}.
290
	 * If this session attribute is not set, all {@link TaxonNode}s of the chosen
291
	 * classification defined by the vaadin session attribute 
292
	 * {@link DistributionEditorUtil#SATTR_CLASSIFICATION} are returned.
293
	 * @return All {@link TaxonNode}s defined by the 
294
	 * vaadin session attribute {@link DistributionEditorUtil#SATTR_TAXON_NODES_UUID}.
295
	 * If this session attribute is not set, all {@link TaxonNode}s of the chosen
296
	 * classification defined by the vaadin session attribute 
297
	 * {@link DistributionEditorUtil#SATTR_CLASSIFICATION}.
298
	 */
299
	private List<TaxonNode> getChosenTaxonNodes() {
300
		VaadinSession session = VaadinSession.getCurrent();
229 301
        List<UUID> taxonNodeUUIDs = (List<UUID>) session.getAttribute(DistributionEditorUtil.SATTR_TAXON_NODES_UUID);
230 302
        UUID classificationUuid = (UUID)session.getAttribute(DistributionEditorUtil.SATTR_CLASSIFICATION);
231 303
        if((taxonNodeUUIDs==null || taxonNodeUUIDs.isEmpty()) && classificationUuid!=null){
......
241 313
        return Collections.emptyList();
242 314
    }
243 315

  
316
	/**
317
	 * Returns the list of chosen {@link TaxonNode}s returned by {@link #getChosenTaxonNodes()}
318
	 * and adds their children to it.
319
	 * @return List of chosen {@link TaxonNode}s returned by {@link #getChosenTaxonNodes()}
320
	 * and their children.
321
	 */
244 322
	private List<TaxonNode> getAllNodes(){
245 323
		List<TaxonNode> allNodes = new ArrayList<>();
246 324

  
......
256 334

  
257 335
	protected static final List<String> DESCRIPTION_INIT_STRATEGY = Arrays.asList(new String []{
258 336
            "$", //$NON-NLS-1$
259
            "elements.*", //$NON-NLS-1$
260
            "elements.sources.citation.authorship.$", //$NON-NLS-1$
261
            "elements.sources.nameUsedInSource.originalNameString", //$NON-NLS-1$
262
            "elements.area.level", //$NON-NLS-1$
263
            "elements.modifyingText", //$NON-NLS-1$
264
            "elements.states.*", //$NON-NLS-1$
265
            "elements.media", //$NON-NLS-1$
266
            "elements.multilanguageText", //$NON-NLS-1$
267
            "multilanguageText", //$NON-NLS-1$
268
            "stateData.$", //$NON-NLS-1$
269
            "annotations", //$NON-NLS-1$
270
            "markers", //$NON-NLS-1$
271
            "sources.citation.authorship", //$NON-NLS-1$
272
            "sources.nameUsedInSource", //$NON-NLS-1$
273
            "multilanguageText", //$NON-NLS-1$
274
            "media", //$NON-NLS-1$
275
            "name.$", //$NON-NLS-1$
276
            "name.rank", //$NON-NLS-1$
277
            "name.status.type", //$NON-NLS-1$
278
            "taxon2.name", //$NON-NLS-1$
279
    });
337
"elements.*", //$NON-NLS-1$
338
"elements.sources.citation.authorship.$", //$NON-NLS-1$
339
"elements.sources.nameUsedInSource.originalNameString", //$NON-NLS-1$
340
"elements.area.level", //$NON-NLS-1$
341
"elements.modifyingText", //$NON-NLS-1$
342
"elements.states.*", //$NON-NLS-1$
343
"elements.media", //$NON-NLS-1$
344
"elements.multilanguageText", //$NON-NLS-1$
345
"multilanguageText", //$NON-NLS-1$
346
"stateData.$", //$NON-NLS-1$
347
"annotations", //$NON-NLS-1$
348
"markers", //$NON-NLS-1$
349
"sources.citation.authorship", //$NON-NLS-1$
350
"sources.nameUsedInSource", //$NON-NLS-1$
351
"multilanguageText", //$NON-NLS-1$
352
"media", //$NON-NLS-1$
353
"name.$", //$NON-NLS-1$
354
"name.rank", //$NON-NLS-1$
355
"name.status.type", //$NON-NLS-1$
356
"taxon2.name", //$NON-NLS-1$
357
});
280 358

  
281
	/**Helper Methods*/
282
	private void sort(List<DescriptionElementBase> list){
283
		Collections.sort(list, new Comparator<DescriptionElementBase>() {
359
/**Helper Methods*/
360
private void sort(List<DescriptionElementBase> list){
361
	Collections.sort(list, new Comparator<DescriptionElementBase>() {
284 362

  
285
			@Override
286
			public int compare(DescriptionElementBase o1, DescriptionElementBase o2) {
287
				String feature1 = o1.getFeature().getTitleCache();
288
				String feature2 = o2.getFeature().getTitleCache();
289
				if(feature1 !=null && feature2 !=null){
290
					return feature1.compareTo(feature2);
291
				}else{
292
					return 0;
363
		@Override
364
		public int compare(DescriptionElementBase o1, DescriptionElementBase o2) {
365
			String feature1 = o1.getFeature().getTitleCache();
366
			String feature2 = o2.getFeature().getTitleCache();
367
			if(feature1 !=null && feature2 !=null){
368
				return feature1.compareTo(feature2);
369
			}else{
370
				return 0;
293 371

  
294
				}
295 372
			}
296
		});
297
	}
373
		}
374
	});
375
}
298 376

  
299
	/**
300
	 *
301
	 * {@inheritDoc}
302
	 */
303
	@Override
304
	protected void onPresenterReady() {
305
	    /*
306
         * The area and taxon settings window should only be displayed after login
307
         * and only when no classification and areas are chosen yet.
308
         */
309
	    VaadinSession vaadinSession = VaadinSession.getCurrent();
310
	    if(userHelper.userIsAutheticated()
311
	            && !userHelper.userIsAnnonymous()
312
	            && (vaadinSession.getAttribute(DistributionEditorUtil.SATTR_CLASSIFICATION) == null
313
	            || vaadinSession.getAttribute(DistributionEditorUtil.SATTR_SELECTED_AREA_VOCABULARY_UUID) == null
314
	            || vaadinSession.getAttribute(DistributionEditorUtil.SATTR_SELECTED_AREAS) == null)) {
315
            getView().openAreaAndTaxonSettings();
316
        }
377
/**
378
 *
379
 * {@inheritDoc}
380
 */
381
@Override
382
protected void onPresenterReady() {
383
    /*
384
 * The area and taxon settings window should only be displayed after login
385
 * and only when no classification and areas are chosen yet.
386
 */
387
    VaadinSession vaadinSession = VaadinSession.getCurrent();
388
    if(userHelper.userIsAutheticated()
389
            && !userHelper.userIsAnnonymous()
390
            && (vaadinSession.getAttribute(DistributionEditorUtil.SATTR_CLASSIFICATION) == null
391
            || vaadinSession.getAttribute(DistributionEditorUtil.SATTR_SELECTED_AREA_VOCABULARY_UUID) == null
392
            || vaadinSession.getAttribute(DistributionEditorUtil.SATTR_SELECTED_AREAS) == null)) {
393
        getView().openAreaAndTaxonSettings();
317 394
    }
395
}
318 396

  
319
	/**Unused Methods*/
320
	// TODO: Currently unused. Remove?
321
    private List<String> getAbbreviatedNamedAreas() {
322
        List<NamedArea> terms = getChosenAreasFromVoc();
323
        List<String> list = new ArrayList<>();
324
        for(DefinedTermBase<?> dtb: terms){
325
            for(Representation r : dtb.getRepresentations()){
326
                list.add(r.getAbbreviatedLabel());
327
            }
397
/**Unused Methods*/
398
// TODO: Currently unused. Remove?
399
private List<String> getAbbreviatedNamedAreas() {
400
    List<NamedArea> terms = getChosenAreasFromVoc();
401
    List<String> list = new ArrayList<>();
402
    for(DefinedTermBase<?> dtb: terms){
403
        for(Representation r : dtb.getRepresentations()){
404
            list.add(r.getAbbreviatedLabel());
328 405
        }
329
        return list;
330 406
    }
407
    return list;
408
}
331 409

  
332
    // TODO: Currently unused. Remove?
333
    private HashMap<DescriptionElementBase, Distribution> getDistribution(DefinedTermBase dt, Taxon taxon) {
334
        Set<Feature> setFeature = new HashSet<>(Arrays.asList(Feature.DISTRIBUTION()));
335
        List<DescriptionElementBase> listTaxonDescription = CdmSpringContextHelper.getDescriptionService().listDescriptionElementsForTaxon(taxon, setFeature, null, null, null, DESCRIPTION_INIT_STRATEGY);
336
        HashMap<DescriptionElementBase, Distribution> map = null;
337
        for(DescriptionElementBase deb : listTaxonDescription){
338
            if(deb instanceof Distribution){
339
                Distribution db = (Distribution)deb;
340
                String titleCache = dt.getTitleCache();
341
                if(db.getArea().getTitleCache().equalsIgnoreCase(titleCache)){
342
                    map = new HashMap<DescriptionElementBase, Distribution>();
343
                    map.put(deb, db);
344
                }
410
// TODO: Currently unused. Remove?
411
private HashMap<DescriptionElementBase, Distribution> getDistribution(DefinedTermBase dt, Taxon taxon) {
412
    Set<Feature> setFeature = new HashSet<>(Arrays.asList(Feature.DISTRIBUTION()));
413
    List<DescriptionElementBase> listTaxonDescription = CdmSpringContextHelper.getDescriptionService().listDescriptionElementsForTaxon(taxon, setFeature, null, null, null, DESCRIPTION_INIT_STRATEGY);
414
    HashMap<DescriptionElementBase, Distribution> map = null;
415
    for(DescriptionElementBase deb : listTaxonDescription){
416
        if(deb instanceof Distribution){
417
            Distribution db = (Distribution)deb;
418
            String titleCache = dt.getTitleCache();
419
            if(db.getArea().getTitleCache().equalsIgnoreCase(titleCache)){
420
                map = new HashMap<DescriptionElementBase, Distribution>();
421
                map.put(deb, db);
345 422
            }
346 423
        }
347
        return map;
348 424
    }
425
    return map;
426
}
349 427

  
350
    public LazyQueryContainer getAreaDistributionStatusContainer() {
351
        List<UUID> nodeUuids = getAllNodes().stream().map(n -> n.getUuid()).collect(Collectors.toCollection(ArrayList::new));
352
        List<NamedArea> namedAreas = getChosenAreas();
353
        if(namedAreas!=null){
354
            QueryFactory factory = new DistributionStatusQueryFactory(this.repo, nodeUuids, namedAreas);
355
            QueryDefinition defintion = new DistributionStatusQueryDefinition(namedAreas, true, 50);
356
            return new LazyQueryContainer(defintion, factory);
357
        }
358
        return null;
428
public LazyQueryContainer getAreaDistributionStatusContainer() {
429
    List<UUID> nodeUuids = getAllNodes().stream().map(n -> n.getUuid()).collect(Collectors.toCollection(ArrayList::new));
430
    List<NamedArea> namedAreas = getChosenAreas();
431
    if(namedAreas!=null){
432
        QueryFactory factory = new DistributionStatusQueryFactory(this.repo, nodeUuids, namedAreas);
433
        QueryDefinition defintion = new DistributionStatusQueryDefinition(namedAreas, true, 50);
434
        return new LazyQueryContainer(defintion, factory);
359 435
    }
436
    return null;
437
}
360 438
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/distributionStatus/DistributionTableViewBean.java
60 60
import eu.etaxonomy.cdm.vaadin.view.AbstractPageView;
61 61

  
62 62
/**
63
 * The main view of the distribution status editor.
64
 * 
63 65
 * @author freimeier
64 66
 * @since 18.10.2017
65 67
 *
......
86 88
	private DistributionStatusSettingsConfigWindow distributionStatusConfigWindow;
87 89
	private HelpWindow helpWindow;
88 90

  
91
	/**
92
	 * Creates a new distribution status editor view.
93
	 */
89 94
	public DistributionTableViewBean() {
90 95
		super();
91 96
	}
92 97

  
98
	/**
99
	 * Initializes the layout of the view,
100
	 * adds the {@link DistributionToolbar} and
101
	 * creates the distribution status table and adds click listener for editing to it.
102
	 * @return Layout of the view.
103
	 */
93 104
	private AbsoluteLayout initLayout() {
94 105
		AbsoluteLayout mainLayout = new AbsoluteLayout();
95 106
		mainLayout.setImmediate(false);
......
319 330
//        footerCell.setText(String.format(Messages.DistributionTableViewBean_TOTAL_TAXA, gridcontainer.size()));
320 331
	}
321 332

  
333
	/**
334
	 * Adds click listener to the buttons defined in the {@link DistributionToolbar}.
335
	 */
322 336
	private void createEditClickListener(){
323 337
		//details
324 338
	    Button detailButton = toolbar.getDetailButton();
src/main/java/eu/etaxonomy/cdm/vaadin/view/distributionStatus/IDistributionTableView.java
13 13
import eu.etaxonomy.vaadin.mvp.ApplicationView;
14 14

  
15 15
/**
16
 * 
17
 * Interface for the distribution status editor view.
18
 * 
16 19
 * @author freimeier
17 20
 * @since 18.10.2017
18 21
 *
src/main/java/eu/etaxonomy/cdm/vaadin/view/distributionStatus/NoCommitFieldGroup.java
11 11
import com.vaadin.data.fieldgroup.FieldGroup;
12 12

  
13 13
/**
14
 * Field group that might be used for vaadin grid
15
 * instantiation of the distribution status editor.
16
 * 
14 17
 * @author freimeier
15 18
 * @since 18.10.2017
16 19
 *
......
19 22

  
20 23
    private static final long serialVersionUID = -1666206997756640330L;
21 24

  
25
    /**
26
     * 
27
     * {@inheritDoc}
28
     */
22 29
    @Override
23 30
	public boolean isReadOnly() {
24 31
		return false;
25 32
	}
26 33

  
34
    /**
35
     * 
36
     * {@inheritDoc}
37
     */
27 38
	@Override
28 39
	public void commit() {}
29 40
}

Also available in: Unified diff