<commit_before>package org.opensingular.server.p.commons.admin.healthsystem.docs.wicket;

import org.apache.commons.lang3.StringUtils;
import org.apache.wicket.extensions.markup.html.repeater.data.sort.ISortState;
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
import org.apache.wicket.extensions.markup.html.repeater.data.table.ISortableDataProvider;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.repeater.RepeatingView;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.util.ListModel;
import org.apache.wicket.request.Request;
import org.apache.wicket.request.cycle.RequestCycle;
import org.apache.wicket.request.flow.RedirectToUrlException;
import org.opensingular.form.STypeComposite;
import org.opensingular.lib.wicket.util.datatable.BSDataTable;
import org.opensingular.lib.wicket.util.datatable.BSDataTableBuilder;
import org.opensingular.server.commons.form.SingularServerSpringTypeLoader;
import org.opensingular.server.p.commons.admin.healthsystem.HealthSystemPage;
import org.opensingular.server.p.commons.admin.healthsystem.docs.DocumentationMetadataBuilder;
import org.opensingular.server.p.commons.admin.healthsystem.docs.TabulatedMetadata;

import javax.inject.Inject;
import java.util.Iterator;
import java.util.List;

import static org.opensingular.lib.wicket.util.util.WicketUtils.*;

public class DocumentatioTablePage extends WebPage {

    private IModel<List<TabulatedMetadata>> tablesModel;

    private boolean showNumbers;
    private boolean showObservacoes;

    @Inject
    private SingularServerSpringTypeLoader typeLoader;
    public DocumentatioTablePage() {
        RequestCycle.get().setResponsePage(HealthSystemPage.class);
    }


    public DocumentatioTablePage(Class<? extends STypeComposite> stype, boolean showNumbers, boolean showObservacoes) {
        this.showNumbers = showNumbers;
        this.showObservacoes = showObservacoes;
        tablesModel = new ListModel<>(new DocumentationMetadataBuilder(typeLoader.loadTypeOrException(stype)).getTabulatedFormat());
    }

    @Override
    protected void onConfigure() {
        RepeatingView repeatingView = new RepeatingView("tables", tablesModel);
        for (TabulatedMetadata metas : tablesModel.getObject()) {
            IModel<Integer> counterModel = new Model<>(0);
            WebMarkupContainer components = new WebMarkupContainer(repeatingView.newChildId());
            components.add(new Label("title", $m.ofValue(metas.getTableName())));
            components.add(setupDataTable("table", metas, counterModel));
            repeatingView.add(components);
        }
        queue(repeatingView);
    }

    protected BSDataTable<DocumentationRow, String> setupDataTable(String table, TabulatedMetadata metas, IModel<Integer> counterModel) {
        BSDataTableBuilder<DocumentationRow, String, IColumn<DocumentationRow, String>> builder = new BSDataTableBuilder<>(createDataProvider(metas));
        if (showNumbers) {
            builder.appendPropertyColumn($m.ofValue("Número"), r -> {
                if (r instanceof DocumentationRowBlockSeparator) {
                    return ((DocumentationRowBlockSeparator) r).getBlockName();
                }
                Integer i = counterModel.getObject();
                i = i + 1;
                counterModel.setObject(i);
                return i;
            });
        }
        builder.appendPropertyColumn($m.ofValue("Nome do campo"), r -> format(isBlock(r) ? null : ((DocumentationRowFieldMetadata) r).getFieldName()))
                .appendPropertyColumn($m.ofValue("Tipo"), r -> format(isBlock(r) ? null : ((DocumentationRowFieldMetadata) r).getDocTypeAbbreviation()))
                .appendPropertyColumn($m.ofValue("Obrigatório"), r -> format(isBlock(r) ? null : ((DocumentationRowFieldMetadata) r).getRequired()))
                .appendPropertyColumn($m.ofValue("Habilitado"), r -> format(isBlock(r) ? null : ((DocumentationRowFieldMetadata) r).getEnabled()))
                .appendPropertyColumn($m.ofValue("Tamanho"), r -> format(isBlock(r) ? null : ((DocumentationRowFieldMetadata) r).getFieldSize()))
                .appendPropertyColumn($m.ofValue("Regras"), r -> format(isBlock(r) ? null : ((DocumentationRowFieldMetadata) r).getBusinessRules()))<commit_msg>correção de chamada do super<commit_after>package org.opensingular.server.p.commons.admin.healthsystem.docs.wicket;

import org.apache.commons.lang3.StringUtils;
import org.apache.wicket.extensions.markup.html.repeater.data.sort.ISortState;
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
import org.apache.wicket.extensions.markup.html.repeater.data.table.ISortableDataProvider;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.repeater.RepeatingView;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.util.ListModel;
import org.apache.wicket.request.Request;
import org.apache.wicket.request.cycle.RequestCycle;
import org.apache.wicket.request.flow.RedirectToUrlException;
import org.opensingular.form.STypeComposite;
import org.opensingular.lib.wicket.util.datatable.BSDataTable;
import org.opensingular.lib.wicket.util.datatable.BSDataTableBuilder;
import org.opensingular.server.commons.form.SingularServerSpringTypeLoader;
import org.opensingular.server.p.commons.admin.healthsystem.HealthSystemPage;
import org.opensingular.server.p.commons.admin.healthsystem.docs.DocumentationMetadataBuilder;
import org.opensingular.server.p.commons.admin.healthsystem.docs.TabulatedMetadata;

import javax.inject.Inject;
import java.util.Iterator;
import java.util.List;

import static org.opensingular.lib.wicket.util.util.WicketUtils.*;

public class DocumentatioTablePage extends WebPage {

    private IModel<List<TabulatedMetadata>> tablesModel;

    private boolean showNumbers;
    private boolean showObservacoes;

    @Inject
    private SingularServerSpringTypeLoader typeLoader;
    public DocumentatioTablePage() {
        RequestCycle.get().setResponsePage(HealthSystemPage.class);
    }


    public DocumentatioTablePage(Class<? extends STypeComposite> stype, boolean showNumbers, boolean showObservacoes) {
        this.showNumbers = showNumbers;
        this.showObservacoes = showObservacoes;
        tablesModel = new ListModel<>(new DocumentationMetadataBuilder(typeLoader.loadTypeOrException(stype)).getTabulatedFormat());
    }

    @Override
    protected void onInitialize() {
        super.onInitialize();
        RepeatingView repeatingView = new RepeatingView("tables", tablesModel);
        for (TabulatedMetadata metas : tablesModel.getObject()) {
            IModel<Integer> counterModel = new Model<>(0);
            WebMarkupContainer components = new WebMarkupContainer(repeatingView.newChildId());
            components.add(new Label("title", $m.ofValue(metas.getTableName())));
            components.add(setupDataTable("table", metas, counterModel));
            repeatingView.add(components);
        }
        queue(repeatingView);
    }

    protected BSDataTable<DocumentationRow, String> setupDataTable(String table, TabulatedMetadata metas, IModel<Integer> counterModel) {
        BSDataTableBuilder<DocumentationRow, String, IColumn<DocumentationRow, String>> builder = new BSDataTableBuilder<>(createDataProvider(metas));
        if (showNumbers) {
            builder.appendPropertyColumn($m.ofValue("Número"), r -> {
                if (r instanceof DocumentationRowBlockSeparator) {
                    return ((DocumentationRowBlockSeparator) r).getBlockName();
                }
                Integer i = counterModel.getObject();
                i = i + 1;
                counterModel.setObject(i);
                return i;
            });
        }
        builder.appendPropertyColumn($m.ofValue("Nome do campo"), r -> format(isBlock(r) ? null : ((DocumentationRowFieldMetadata) r).getFieldName()))
                .appendPropertyColumn($m.ofValue("Tipo"), r -> format(isBlock(r) ? null : ((DocumentationRowFieldMetadata) r).getDocTypeAbbreviation()))
                .appendPropertyColumn($m.ofValue("Obrigatório"), r -> format(isBlock(r) ? null : ((DocumentationRowFieldMetadata) r).getRequired()))
                .appendPropertyColumn($m.ofValue("Habilitado"), r -> format(isBlock(r) ? null : ((DocumentationRowFieldMetadata) r).getEnabled()))
                .appendPropertyColumn($m.ofValue("Tamanho"), r -> format(isBlock(r) ? null : ((DocumentationRowFieldMetadata) r).getFieldSize()))
                .appendPropertyColumn($m.ofValue("Regras"), r -> format(isBlock(r) ? null : ((DocumentationRowFieldMetadata) r).getBusinessRules()))
{'fraction_non_alphanumeric': 0.11415220293724966, 'fraction_numerical': 0.0006675567423230974, 'mean_word_length': 4.151289398280802, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '2377389', 'n_tokens_mistral': 2581, 'n_tokens_neox': 2549, 'n_words': 392}