mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-16 07:10:48 +00:00
bug4104: Added minor fixes and JavaDocs for TagFilter logic
This commit is contained in:
1 parent
b4886bd4cd
commit
6a353810ea
13 files changed
+71
-21
No files matched your search
+1
@@ -2148,4 +2148,5 @@ public interface StringMessages extends com.sap.sse.gwt.client.StringMessages,
|
||||
String confirm();
|
||||
String cancel();
|
||||
String close();
|
||||
String username();
|
||||
}
|
||||
+1
@@ -2140,6 +2140,7 @@ tagCreateFilterNotLoggedIn=You are not logged in so filters will not be saved!
|
||||
tagCreateFilterHint=Create a filter set to filter the list of tags.
|
||||
tagButtonNotSavable=Could not save tag-button on the server!
|
||||
tagNotEditable=You may not edit this tag!
|
||||
username=User name
|
||||
confirm=Confirm
|
||||
cancel=Cancel
|
||||
close=Close
|
||||
+1
@@ -2135,6 +2135,7 @@ tagCreateFilterNotLoggedIn=Bitte einloggen um Filter speichern zu können!
|
||||
tagCreateFilterHint=Lege einen Filter an, um die sichtbaren Tags zu reduzieren.
|
||||
tagButtonNotSavable=Tag-Button konnten nicht auf dem Server gespeichert werden!
|
||||
tagNotEditable=Du darfst diesen Tag nicht bearbeiten!
|
||||
username=Benutzername
|
||||
confirm=Fortfahren
|
||||
cancel=Abbrechen
|
||||
close=Schließen
|
||||
+3
@@ -23,6 +23,9 @@ import com.sap.sse.common.filter.Filter;
|
||||
import com.sap.sse.common.filter.FilterSet;
|
||||
import com.sap.sse.gwt.client.dialog.DataEntryDialog;
|
||||
|
||||
/**
|
||||
* Used to create or edit a {@link FilterSet} for {@link TagDTO}s
|
||||
*/
|
||||
public abstract class AbstractTagsFilterSetDialog extends DataEntryDialog<FilterSet<TagDTO, FilterWithUI<TagDTO>>> {
|
||||
private final FilterSet<TagDTO, FilterWithUI<TagDTO>> tagsFilterSet;
|
||||
private final StringMessages stringMessages;
|
||||
|
||||
+3
@@ -6,6 +6,9 @@ import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
import com.sap.sailing.gwt.ui.shared.TagDTO;
|
||||
import com.sap.sse.common.filter.FilterSet;
|
||||
|
||||
/**
|
||||
* Used to create a {@link FilterSet} for {@link TagDTO}s
|
||||
*/
|
||||
public class CreateTagsFilterSetDialog extends AbstractTagsFilterSetDialog {
|
||||
|
||||
public CreateTagsFilterSetDialog(List<String> existingFilterSetNames, List<String> availableTagFilterNames,
|
||||
|
||||
+3
@@ -6,6 +6,9 @@ import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
import com.sap.sailing.gwt.ui.shared.TagDTO;
|
||||
import com.sap.sse.common.filter.FilterSet;
|
||||
|
||||
/**
|
||||
* Used to edit a {@link FilterSet} for {@link TagDTO}s
|
||||
*/
|
||||
public class EditTagsFilterSetDialog extends AbstractTagsFilterSetDialog {
|
||||
|
||||
public EditTagsFilterSetDialog(FilterSet<TagDTO, FilterWithUI<TagDTO>> tagsFilterSet, List<String> availableTagFilterNames,
|
||||
|
||||
+5
@@ -7,6 +7,11 @@ import com.sap.sailing.gwt.ui.shared.TagDTO;
|
||||
import com.sap.sse.common.filter.Filter;
|
||||
import com.sap.sse.common.filter.FilterSet;
|
||||
|
||||
/**
|
||||
* Contains a {@link List} of {@link FilterSet filterSet}.
|
||||
* {@link activeFilterSet} holds current active {@link FilterSet filterSet} due to always only one {@link FilterSet filterSet} being applied
|
||||
*
|
||||
*/
|
||||
public class TagFilterSets {
|
||||
private List<FilterSet<TagDTO, FilterWithUI<TagDTO>>> filterSets;
|
||||
|
||||
|
||||
+16
-3
@@ -19,8 +19,7 @@ import com.sap.sse.gwt.client.dialog.DataEntryDialog;
|
||||
import com.sap.sse.security.ui.client.UserService;
|
||||
|
||||
/**
|
||||
* A dialog to create, edit and delete filter sets for tags
|
||||
*
|
||||
* A dialog to create, edit and delete {@link TagFilterSets}
|
||||
*/
|
||||
public class TagFilterSetsDialog extends DataEntryDialog<TagFilterSets> {
|
||||
private final TagFilterSets tagFilterSets;
|
||||
@@ -142,6 +141,12 @@ public class TagFilterSetsDialog extends DataEntryDialog<TagFilterSets> {
|
||||
return activeFilterSetRadioButton;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Button, which if clicked creates and opens a {@link EditTagsFilterSetDialog},
|
||||
* with which a user can edit a {@link FilterSet}
|
||||
* @param filterSetToEdit The {@link FilterSet} to edit
|
||||
* @return This Button, which now can be placed into the UI
|
||||
*/
|
||||
private Button createEditFilterSetButton(final FilterSet<TagDTO, FilterWithUI<TagDTO>> filterSetToEdit) {
|
||||
final Button editFilterSetBtn = new Button(stringMessages.edit());
|
||||
final String filterSetToEditName = filterSetToEdit.getName();
|
||||
@@ -196,6 +201,11 @@ public class TagFilterSetsDialog extends DataEntryDialog<TagFilterSets> {
|
||||
return editFilterSetBtn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Button, which if clicked deletes a {@link FilterSet} can be deleted
|
||||
* @param filterSet The regarding {@link FilterSet} which will get deleted if clicked
|
||||
* @return The Button
|
||||
*/
|
||||
private Button createDeleteFilterSetButton(FilterSet<TagDTO, FilterWithUI<TagDTO>> filterSet) {
|
||||
final Button deleteFilterSetBtn = new Button(stringMessages.delete());
|
||||
deleteFilterSetBtn.addStyleName("inlineButton");
|
||||
@@ -225,7 +235,10 @@ public class TagFilterSetsDialog extends DataEntryDialog<TagFilterSets> {
|
||||
});
|
||||
return deleteFilterSetBtn;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the maintained {@link TagFilterSets}
|
||||
*/
|
||||
@Override
|
||||
protected TagFilterSets getResult() {
|
||||
TagFilterSets result = new TagFilterSets();
|
||||
|
||||
+23
-3
@@ -11,6 +11,10 @@ import com.sap.sailing.gwt.ui.shared.TagDTO;
|
||||
import com.sap.sse.common.filter.FilterSet;
|
||||
import com.sap.sse.common.filter.ValueFilter;
|
||||
|
||||
/**
|
||||
* Serializes and deserializes {@link TagFilterSets}.
|
||||
*/
|
||||
|
||||
public class TagFilterSetsJsonDeSerializer implements GwtJsonDeSerializer<TagFilterSets> {
|
||||
public static final String FIELD_ACTIVE_FILTERSET = "activeFilterSet";
|
||||
public static final String FIELD_FILTERSETS = "filterSets";
|
||||
@@ -18,16 +22,24 @@ public class TagFilterSetsJsonDeSerializer implements GwtJsonDeSerializer<TagFil
|
||||
public static final String FIELD_FILTERSET_ISEDITABLE = "isEditable";
|
||||
public static final String FIELD_FILTERS = "filters";
|
||||
|
||||
|
||||
/**
|
||||
* Serializes {@link TagFilterSets tagFilterSets} to {@link JSONObject json}.
|
||||
*
|
||||
* @param tagFilterSets
|
||||
* {@link TagFilterSets} to be serialized
|
||||
* @return {@link JSONObject json object}
|
||||
*/
|
||||
@Override
|
||||
public JSONObject serialize(TagFilterSets filterSets) {
|
||||
public JSONObject serialize(TagFilterSets tagFilterSets) {
|
||||
JSONObject result = new JSONObject();
|
||||
result.put(FIELD_ACTIVE_FILTERSET,
|
||||
filterSets.getActiveFilterSet() != null ? new JSONString(filterSets.getActiveFilterSet().getName())
|
||||
tagFilterSets.getActiveFilterSet() != null ? new JSONString(tagFilterSets.getActiveFilterSet().getName())
|
||||
: JSONNull.getInstance());
|
||||
JSONArray filterSetArray = new JSONArray();
|
||||
result.put(FIELD_FILTERSETS, filterSetArray);
|
||||
int i = 0;
|
||||
for (FilterSet<TagDTO, FilterWithUI<TagDTO>> filterSet : filterSets.getFilterSets()) {
|
||||
for (FilterSet<TagDTO, FilterWithUI<TagDTO>> filterSet : tagFilterSets.getFilterSets()) {
|
||||
// only editable filter sets are stored
|
||||
if (filterSet.isEditable()) {
|
||||
JSONObject filterSetObject = new JSONObject();
|
||||
@@ -50,6 +62,14 @@ public class TagFilterSetsJsonDeSerializer implements GwtJsonDeSerializer<TagFil
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deserializes {@link JSONObject json} to {@link TagFilterSets tagFilterSets}.
|
||||
*
|
||||
* @param rootObject
|
||||
* JSONObject to be deserialized
|
||||
* @return {@link TagFilterSets tagFilterSets}
|
||||
*/
|
||||
@Override
|
||||
public TagFilterSets deserialize(JSONObject rootObject) {
|
||||
TagFilterSets result = null;
|
||||
|
||||
+6
-1
@@ -3,9 +3,14 @@ package com.sap.sailing.gwt.ui.client.shared.filter;
|
||||
import com.sap.sailing.gwt.ui.shared.TagDTO;
|
||||
|
||||
/**
|
||||
* A factory for FilterWithUI<Tag> instances
|
||||
* A factory for FilterWithUI<TagDTO> instances
|
||||
*/
|
||||
public class TagFilterWithUIFactory {
|
||||
/**
|
||||
* Creates and returns a requested {@link FilterWithUI}
|
||||
* @param filterName The name of the requested filter
|
||||
* @return A new Instance of the requested {@link FilterWithUI}
|
||||
*/
|
||||
public static FilterWithUI<TagDTO> createFilter(String filterName) {
|
||||
if (TagUsernameFilter.FILTER_NAME.equals(filterName)) {
|
||||
return new TagUsernameFilter();
|
||||
|
||||
+4
-4
@@ -10,9 +10,9 @@ import com.sap.sse.common.filter.AbstractTextFilter;
|
||||
public class TagTagFilter extends AbstractTextFilter<TagDTO> implements FilterWithUI<TagDTO> {
|
||||
public static final String FILTER_NAME = "TagTagFilter";
|
||||
|
||||
public TagTagFilter() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if {@link TagDTO} matches filter criteria
|
||||
*/
|
||||
@Override
|
||||
public boolean matches(TagDTO tag) {
|
||||
boolean result = false;
|
||||
@@ -75,7 +75,7 @@ public class TagTagFilter extends AbstractTextFilter<TagDTO> implements FilterWi
|
||||
|
||||
@Override
|
||||
public String getLocalizedDescription(StringMessages stringMessages) {
|
||||
return "Top " + this.getValue() + " " + stringMessages.tag();
|
||||
return stringMessages.tag();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-9
@@ -6,9 +6,6 @@ import com.sap.sse.common.filter.AbstractTextFilter;
|
||||
|
||||
/**
|
||||
* A filter filtering tags by the name of their author
|
||||
*
|
||||
* @author Julian Rendl (D067890)
|
||||
*
|
||||
*/
|
||||
public class TagUsernameFilter extends AbstractTextFilter<TagDTO> implements FilterWithUI<TagDTO> {
|
||||
public static final String FILTER_NAME = "TagUsernameFilter";
|
||||
@@ -65,16 +62,12 @@ public class TagUsernameFilter extends AbstractTextFilter<TagDTO> implements Fil
|
||||
|
||||
@Override
|
||||
public String getLocalizedName(StringMessages stringMessages) {
|
||||
// return stringMessages.username();
|
||||
// TODO: Proper way to handle multiple instances of string messages?
|
||||
return com.sap.sse.security.ui.client.i18n.StringMessages.INSTANCE.username();
|
||||
return stringMessages.username();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocalizedDescription(StringMessages stringMessages) {
|
||||
// return stringMessages.username();
|
||||
// TODO: Proper way to handle multiple instances of string messages?
|
||||
return com.sap.sse.security.ui.client.i18n.StringMessages.INSTANCE.username();
|
||||
return stringMessages.username();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-1
@@ -8,7 +8,9 @@ import com.sap.sse.common.filter.NumberFilter;
|
||||
import com.sap.sse.common.filter.TextFilter;
|
||||
import com.sap.sse.common.filter.TextOperator;
|
||||
import com.sap.sse.common.filter.ValueFilter;
|
||||
|
||||
/**
|
||||
* JSON serializer and deserializer for {@link FilterWithUI}
|
||||
*/
|
||||
public class TagValueFilterJsonDeSerializerUtil {
|
||||
public static final String FIELD_FILTER_NAME = "name";
|
||||
public static final String FIELD_FILTER_OPERATOR = "operator";
|
||||
|
||||
Reference in new issue
Block a user