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

com.ibm.fhir.schema.control.GetResourceChangeLogEmpty Maven / Gradle / Ivy

There is a newer version: 4.11.1
Show newest version
/*
 * (C) Copyright IBM Corp. 2021
 *
 * SPDX-License-Identifier: Apache-2.0
 */

package com.ibm.fhir.schema.control;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import com.ibm.fhir.database.utils.api.IDatabaseSupplier;
import com.ibm.fhir.database.utils.api.IDatabaseTranslator;

/**
 * Checks the RESOURCE_CHANGE_LOG table to see if it has been populated with
 * any data
 */
public class GetResourceChangeLogEmpty implements IDatabaseSupplier {
    private final String schemaName;

    public GetResourceChangeLogEmpty(String schemaName) {
        this.schemaName = schemaName;
    }

    @Override
    public Boolean run(IDatabaseTranslator translator, Connection c) {
        Boolean result = true;

        final String SQL = "SELECT 1 "
                + "  FROM " + schemaName + ".RESOURCE_CHANGE_LOG "
                + translator.limit("1");

        try (Statement s = c.createStatement()) {
            ResultSet rs = s.executeQuery(SQL);
            if (rs.next()) {
                result = false;
            }
        } catch (SQLException x) {
            throw translator.translate(x);
        }

        return result;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy