All Downloads are FREE. Search and download functionalities are using the official Maven repository.

templates.util.CheckResultImpl.ftl Maven / Gradle / Ivy

Go to download

Maven plugin to generate Java classes from StoredProcedure and Functions in Database

There is a newer version: 1.8.20
Show newest version
<#if header>
/*
 * Copyright (C) 2019 Yadickson Soto
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see .
 */

package ${javaPackage}.util;

import java.sql.SQLException;
import java.util.Map;
<#if logger>

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.Marker;


import org.springframework.stereotype.Component;

/**
 * Check result from store procedure or function.
 *
 * @author @GENERATOR.NAME@
 * @version @GENERATOR.VERSION@
 */
@Component
public final class CheckResultImpl implements CheckResult {
<#if logger>

    /**
     * Logger.
     */
    private static final Logger LOGGER
            = LoggerFactory.getLogger(CheckResultImpl.class);


    /**
     * Success constant value.
     */
    private static final String SUCCESS_CODE = "${successCode}";

    /**
     * {@inheritDoc}
     */
    @Override
    public void check(final Map map) throws SQLException {

        if (map == null) {
            return;
        }

        Number code = (Number) map.get("${outParameterCode}");

        if (code == null) {
            return;
        }

        if (!SUCCESS_CODE.equals(code.toString())) {
            String description = (String) map.get("${outParameterMessage}");
<#if logger>
            LOGGER.error(Marker.ANY_MARKER, "${outParameterCode}: {}", code);
            LOGGER.error(Marker.ANY_MARKER, "${outParameterMessage}: {}", description);

            throw new SQLException(description, code.toString());
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy