<commit_before>/*
 * Copyright (C) 2016 Singular Studios (a.k.a Atom Tecnologia) - www.opensingular.com
 *
 * 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.opensingular.server.p.commons.admin.healthsystem.stypes;

import org.opensingular.form.SIComposite;
import org.opensingular.form.SInfoType;
import org.opensingular.form.STypeComposite;
import org.opensingular.form.STypeList;
import org.opensingular.form.TypeBuilder;
import org.opensingular.form.type.core.STypeString;
import org.opensingular.form.view.SViewListByTable;
import org.opensingular.server.p.commons.admin.healthsystem.validation.webchecker.IProtocolChecker;
import org.opensingular.server.p.commons.admin.healthsystem.validation.webchecker.ProtocolCheckerFactory;

import java.util.Arrays;

@SInfoType(spackage = SSystemHealthPackage.class, newable = true, name = SWebHealth.TYPE_NAME)
public class SWebHealth extends STypeComposite<SIComposite> {
	public static final String TYPE_NAME = "webhealth";
	public static final String TYPE_FULL_NAME = SSystemHealthPackage.PACKAGE_NAME+"."+TYPE_NAME;

	@Override
	protected void onLoadType(TypeBuilder tb) {

        STypeList<STypeComposite<SIComposite>, SIComposite> urlsList = this.addFieldListOfComposite("urls", "urlsList");
        urlsList.setView(()->new SViewListByTable());

        this
        	.asAtr()
        		.label("Url (Protocolos suportados: " +
                        Arrays.asList(ProtocolCheckerFactory.values()).toString().replace("[", "").replace("]", "")
                        + ")");

        STypeComposite<SIComposite> tabela = urlsList.getElementsType();

        STypeString urlField = tabela.addFieldString("url");
		urlField
	        .asAtr()
	        	.maxLength(100)
	        .asAtrBootstrap()
	        	.colPreference(3);

		urlField.addInstanceValidator(validatable->{
			try {
				IProtocolChecker protocolChecker = ProtocolCheckerFactory.getProtocolChecker(validatable.getInstance().getValue());
				protocolChecker.protocolCheck(validatable);
			} catch (Exception e) {
				validatable.error(e.getMessage());
			}
		});
	}
}<commit_msg>correção do log da exceção<commit_after>/*
 * Copyright (C) 2016 Singular Studios (a.k.a Atom Tecnologia) - www.opensingular.com
 *
 * 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.opensingular.server.p.commons.admin.healthsystem.stypes;

import org.opensingular.form.SIComposite;
import org.opensingular.form.SInfoType;
import org.opensingular.form.STypeComposite;
import org.opensingular.form.STypeList;
import org.opensingular.form.TypeBuilder;
import org.opensingular.form.type.core.STypeString;
import org.opensingular.form.view.SViewListByTable;
import org.opensingular.server.p.commons.admin.healthsystem.validation.webchecker.IProtocolChecker;
import org.opensingular.server.p.commons.admin.healthsystem.validation.webchecker.ProtocolCheckerFactory;

import java.util.Arrays;

@SInfoType(spackage = SSystemHealthPackage.class, newable = true, name = SWebHealth.TYPE_NAME)
public class SWebHealth extends STypeComposite<SIComposite> {
	public static final String TYPE_NAME = "webhealth";
	public static final String TYPE_FULL_NAME = SSystemHealthPackage.PACKAGE_NAME+"."+TYPE_NAME;

	@Override
	protected void onLoadType(TypeBuilder tb) {

        STypeList<STypeComposite<SIComposite>, SIComposite> urlsList = this.addFieldListOfComposite("urls", "urlsList");
        urlsList.setView(()->new SViewListByTable());

        this
        	.asAtr()
        		.label("Url (Protocolos suportados: " +
                        Arrays.asList(ProtocolCheckerFactory.values()).toString().replace("[", "").replace("]", "")
                        + ")");

        STypeComposite<SIComposite> tabela = urlsList.getElementsType();

        STypeString urlField = tabela.addFieldString("url");
		urlField
	        .asAtr()
	        	.maxLength(100)
	        .asAtrBootstrap()
	        	.colPreference(3);

		urlField.addInstanceValidator(validatable->{
			try {
				IProtocolChecker protocolChecker = ProtocolCheckerFactory.getProtocolChecker(validatable.getInstance().getValue());
				protocolChecker.protocolCheck(validatable);
			} catch (Exception e) {
                getLogger().error(e.getMessage(), e);
				validatable.error(e.getMessage());
			}
		});
	}
}
{'fraction_non_alphanumeric': 0.10663641520136131, 'fraction_numerical': 0.0045377197958026095, 'mean_word_length': 4.071907957813998, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '6726585', 'n_tokens_mistral': 1603, 'n_tokens_neox': 1563, 'n_words': 352}