<commit_before>/*
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 *
 * @author dward
 *
 */
package org.curriki.gwt.client.search.selectors;

import org.curriki.gwt.client.Main;
import org.curriki.gwt.client.Constants;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.HorizontalPanel;

public class SpecialFilterSelector extends DropdownSingleSelector
{
    public SpecialFilterSelector() {
        super();
        setFieldName("__special");

        addOption(Main.getTranslation("search.selector.filters.none"), "");
        if (!Main.getSingleton().getUser().getFullName().equals(Constants.USER_XWIKI_GUEST)) {
            addOption(Main.getTranslation("search.selector.filters.mine"), "mine");
        }
        addOption(Main.getTranslation("search.selector.filters.collections"), "collections");
    }

    public Widget getLabel()
    {
        HorizontalPanel p = new HorizontalPanel();
        p.add(new Label(Main.getTranslation("search.selector.filters")));
        //p.add(getTooltip("filters"));
        return p;
    }

    public String getFilter()
    {
        String filter = "";
        String value = getValue(getSelectedIndex());
        if (value.length() > 0){
            if (value.equals("collections")){
                filter = "XWiki.CompositeAssetClass.type:collection";
            }
            if (value.equals("mine")){
                filter = "creator:"+Main.getSingleton().getUser().getFullName(); // This is the full USERNAME, not realname
            }
        }

        return filter;
    }<commit_msg>- CURRIKI-1032  - Add filter to only show reviewed items<commit_after>/*
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 *
 * @author dward
 *
 */
package org.curriki.gwt.client.search.selectors;

import org.curriki.gwt.client.Main;
import org.curriki.gwt.client.Constants;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.HorizontalPanel;

public class SpecialFilterSelector extends DropdownSingleSelector
{
    public SpecialFilterSelector() {
        super();
        setFieldName("__special");

        addOption(Main.getTranslation("search.selector.filters.none"), "");
        if (!Main.getSingleton().getUser().getFullName().equals(Constants.USER_XWIKI_GUEST)) {
            addOption(Main.getTranslation("search.selector.filters.mine"), "mine");
        }
        addOption(Main.getTranslation("search.selector.filters.collections"), "collections");
        addOption(Main.getTranslation("search.selector.filters.reviewed"), "reviewed");
    }

    public Widget getLabel()
    {
        HorizontalPanel p = new HorizontalPanel();
        p.add(new Label(Main.getTranslation("search.selector.filters")));
        //p.add(getTooltip("filters"));
        return p;
    }

    public String getFilter()
    {
        String filter = "";
        String value = getValue(getSelectedIndex());
        if (value.length() > 0){
            if (value.equals("collections")){
                filter = "XWiki.CompositeAssetClass.type:collection";
            }
            if (value.equals("reviewed")){
                filter = "CRS.CurrikiReviewStatusClass.status:(1 OR 2 OR 3 OR P)";
            }
            if (value.equals("mine")){
                filter = "creator:"+Main.getSingleton().getUser().getFullName(); // This is the full USERNAME, not realname
            }
        }

        return filter;
    }
{'fraction_non_alphanumeric': 0.1092275091504527, 'fraction_numerical': 0.006742438836447698, 'mean_word_length': 3.0594214229867083, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2773735', 'n_tokens_mistral': 1434, 'n_tokens_neox': 1392, 'n_words': 432}