<commit_before>/*
 * Copyright 2012 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.broadleafcommerce.admin.client.view.dialog;

import org.broadleafcommerce.admin.client.dto.AdminExporterDTO;
import org.broadleafcommerce.openadmin.client.BLCMain;
import org.broadleafcommerce.openadmin.client.dto.BasicFieldMetadata;
import org.broadleafcommerce.openadmin.client.dto.Property;
import org.broadleafcommerce.openadmin.client.view.dynamic.form.FormBuilder;

import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.FormMethod;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.IButton;
import com.smartgwt.client.widgets.Window;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.FormItem;
import com.smartgwt.client.widgets.form.fields.HiddenItem;
import com.smartgwt.client.widgets.layout.HLayout;

import java.util.ArrayList;
import java.util.List;

/**
 * Dialog to show the extra criteria (if available) for an export. If no criteria is
 * available for the exporter, the form is immediately submitted to the server
 * 
 * @author <NAME>
 */
public class ExportCriteriaDialog extends Window {

    protected IButton submitButton;
    protected DynamicForm form;
    protected List<FormItem> formItems;
    protected FormItem exporterNameField;
    protected boolean shouldShowForm;

    public ExportCriteriaDialog(AdminExporterDTO exporter) {
        super();
        
        //only show the form if there is extra criteria
        setShouldShowForm(exporter.getAdditionalCriteriaProperties() != null && exporter.getAdditionalCriteriaProperties().size() > 0);
        
        form = new DynamicForm();
        form.setCellPadding(8);
        form.setWidth100();
        form.setCanSubmit(true);
        form.setMethod(FormMethod.POST);
        form.setAction(BLCMain.webAppContext + "/export");
        
        //add the hidden input for the exporter
        exporterNameField = new HiddenItem("exporter");
        exporterNameField.setValue(exporter.getName());

        HLayout formLayout = new HLayout();
        formLayout.addMember(form);
        addItem(formLayout);

        this.setTitle("Custom Criteria");
        this.setIsModal(true);
        this.setShowModalMask(true);
        this.setShowMinimizeButton(false);
        this.setCanDragResize(true);
        this.setOverflow(Overflow.AUTO);
        this.setVisible(false);

        formLayout.setLayoutMargin(20);
        formLayout.setAlign(Alignment.CENTER);
        formLayout.setWidth100();
        
        if (getShouldShowForm()) {
            this.setWidth(550);
            this.setHeight(400);
            
            ArrayList<FormItem> formItems = new ArrayList<FormItem>();
            for (Property property : exporter.getAdditionalCriteriaProperties()) {
                Boolean presentationLargeEntry = ((BasicFieldMetadata) property.getMetadata()).isLargeEntry();
                boolean largeEntry = (presentationLargeEntry) == null ? false : presentationLargeEntry;<commit_msg>Fixed an issue where the export criteria POST was returning a 404<commit_after>/*
 * Copyright 2012 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.broadleafcommerce.admin.client.view.dialog;

import org.broadleafcommerce.admin.client.dto.AdminExporterDTO;
import org.broadleafcommerce.openadmin.client.BLCMain;
import org.broadleafcommerce.openadmin.client.dto.BasicFieldMetadata;
import org.broadleafcommerce.openadmin.client.dto.Property;
import org.broadleafcommerce.openadmin.client.view.dynamic.form.FormBuilder;

import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.FormMethod;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.IButton;
import com.smartgwt.client.widgets.Window;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.FormItem;
import com.smartgwt.client.widgets.form.fields.HiddenItem;
import com.smartgwt.client.widgets.layout.HLayout;

import java.util.ArrayList;
import java.util.List;

/**
 * Dialog to show the extra criteria (if available) for an export. If no criteria is
 * available for the exporter, the form is immediately submitted to the server
 * 
 * @author <NAME>
 */
public class ExportCriteriaDialog extends Window {

    protected IButton submitButton;
    protected DynamicForm form;
    protected List<FormItem> formItems;
    protected FormItem exporterNameField;
    protected boolean shouldShowForm;

    public ExportCriteriaDialog(AdminExporterDTO exporter) {
        super();
        
        //only show the form if there is extra criteria
        setShouldShowForm(exporter.getAdditionalCriteriaProperties() != null && exporter.getAdditionalCriteriaProperties().size() > 0);
        
        form = new DynamicForm();
        form.setCellPadding(8);
        form.setWidth100();
        form.setCanSubmit(true);
        form.setMethod(FormMethod.POST);
        form.setAction(BLCMain.webAppContext + "/admin/export");
        
        //add the hidden input for the exporter
        exporterNameField = new HiddenItem("exporter");
        exporterNameField.setValue(exporter.getName());

        HLayout formLayout = new HLayout();
        formLayout.addMember(form);
        addItem(formLayout);

        this.setTitle("Custom Criteria");
        this.setIsModal(true);
        this.setShowModalMask(true);
        this.setShowMinimizeButton(false);
        this.setCanDragResize(true);
        this.setOverflow(Overflow.AUTO);
        this.setVisible(false);

        formLayout.setLayoutMargin(20);
        formLayout.setAlign(Alignment.CENTER);
        formLayout.setWidth100();
        
        if (getShouldShowForm()) {
            this.setWidth(550);
            this.setHeight(400);
            
            ArrayList<FormItem> formItems = new ArrayList<FormItem>();
            for (Property property : exporter.getAdditionalCriteriaProperties()) {
                Boolean presentationLargeEntry = ((BasicFieldMetadata) property.getMetadata()).isLargeEntry();
                boolean largeEntry = (presentationLargeEntry) == null ? false : presentationLargeEntry;
{'fraction_non_alphanumeric': 0.0927091528979806, 'fraction_numerical': 0.006687647521636507, 'mean_word_length': 3.5698022768124624, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, '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': '4270018', 'n_tokens_mistral': 2090, 'n_tokens_neox': 2014, 'n_words': 512}