Example usage for java.sql SQLException fillInStackTrace

List of usage examples for java.sql SQLException fillInStackTrace

Introduction

In this page you can find the example usage for java.sql SQLException fillInStackTrace.

Prototype

public synchronized Throwable fillInStackTrace() 

Source Link

Document

Fills in the execution stack trace.

Usage

From source file:uk.nhs.cfh.dsp.snomed.hierarchyprovider.impl.AbstractHierarchyProvider.java

/**
 * Initialise statements./*www. jav a 2  s  . c  om*/
 */
protected void initialiseStatements() {

    try {
        getParentsStatement = connection.prepareStatement("" + "SELECT DISTINCT " + targetColumnName + " "
                + "FROM " + schemaName + "." + relationshipTableName + " WHERE " + attributeName + " = '"
                + attributeValue + "' AND " + sourceColumnName + " = ?");

        getChildrenStatement = connection.prepareStatement("" + "SELECT DISTINCT " + sourceColumnName + " "
                + "FROM " + schemaName + "." + relationshipTableName + " WHERE " + attributeName + " = '"
                + attributeValue + "' AND " + targetColumnName + " = ?");

    } catch (SQLException e) {
        logger.warn("Nested exception is : " + e.fillInStackTrace().getMessage());
    }
}

From source file:uk.nhs.cfh.dsp.snomed.hierarchyprovider.impl.AbstractHierarchyProvider.java

public Set<String> getParents(String conceptId) {

    Set<String> parentIds = new HashSet<String>();
    if (conceptId != null && !"".equalsIgnoreCase(conceptId)) {
        // get concept id and set parameter
        try {/*from ww w  .j a v  a2  s .  c o  m*/
            getParentsStatement.setString(1, conceptId);
            ResultSet rs = getParentsStatement.executeQuery();
            while (rs.next()) {
                String parentID = rs.getString(1);
                parentIds.add(parentID);
            }

        } catch (SQLException e) {
            logger.warn("Nested exception is : " + e.fillInStackTrace());
        }

        return parentIds;
    } else {
        throw new IllegalArgumentException(NULL_ARG_MSG + conceptId);
    }
}

From source file:uk.nhs.cfh.dsp.snomed.hierarchyprovider.impl.AbstractHierarchyProvider.java

public Set<String> getChildren(String conceptId) {

    Set<String> childrenIds = new HashSet<String>();
    if (conceptId != null && !"".equalsIgnoreCase(conceptId)) {
        // get concept id and set parameter
        try {/*from ww w.j  a  v  a 2s .  c om*/
            getChildrenStatement.setString(1, conceptId);
            ResultSet rs = getChildrenStatement.executeQuery();
            while (rs.next()) {
                String childID = rs.getString(1);
                childrenIds.add(childID);
            }

        } catch (SQLException e) {
            logger.warn("Nested exception is : " + e.fillInStackTrace());
        }

        return childrenIds;
    } else {
        throw new IllegalArgumentException(NULL_ARG_MSG + conceptId);
    }
}

From source file:uk.nhs.cfh.dsp.snomed.hierarchyprovider.impl.AbstractHierarchyProvider.java

/**
 * Sets the data source./*from  www  .  ja  v  a  2 s .  co m*/
 *
 * @param dataSource the new data source
 */
public synchronized void setDataSource(DataSource dataSource) {

    try {
        this.dataSource = dataSource;
        this.connection = dataSource.getConnection();
    } catch (SQLException e) {
        logger.warn("Error obtaining connection from data source. " + "Nested exception is : "
                + e.fillInStackTrace());
    }
}

From source file:uk.nhs.cfh.dsp.snomed.hierarchyprovider.impl.NormalFormHierarchyProviderImpl.java

/**
 * Initialise statements./*from   ww  w .  j av  a  2  s  .  c  om*/
 */
@Override
public void initialiseStatements() {

    try {
        super.initialiseStatements();

        getPrimitiveParentsStatement = getConnection().prepareStatement("" + "SELECT DISTINCT "
                + getRelationshipTableName() + "." + getTargetColumnName() + " FROM " + getSchemaName() + "."
                + getRelationshipTableName() + " INNER JOIN " + getSchemaName() + "." + conceptTableName
                + " ON " + getRelationshipTableName() + "." + getAttributeName() + " = '" + getAttributeValue()
                + "' AND " + conceptTableName + "." + conceptIsPrimitiveColumnName + " =1 AND "
                + getRelationshipTableName() + "." + getSourceColumnName() + " = ?" + " AND " + conceptTableName
                + "." + conceptIdColumnName + " = " + getRelationshipTableName() + "." + getTargetColumnName());

        getDefinedParentsStatement = getConnection().prepareStatement("" + "SELECT DISTINCT "
                + getRelationshipTableName() + "." + getTargetColumnName() + " FROM " + getSchemaName() + "."
                + getRelationshipTableName() + " INNER JOIN " + getSchemaName() + "." + conceptTableName
                + " ON " + getRelationshipTableName() + "." + getAttributeName() + " = '" + getAttributeValue()
                + "' AND " + conceptTableName + "." + conceptIsPrimitiveColumnName + " =0 AND "
                + getRelationshipTableName() + "." + getSourceColumnName() + " = ?" + " AND " + conceptTableName
                + "." + conceptIdColumnName + " = " + getRelationshipTableName() + "." + getTargetColumnName());

        getDefinedAncestorsStatement = getConnection().prepareStatement("" + "SELECT T."
                + getSuperTypeColumnName() + " FROM " + getSchemaName() + "." + getTcTableName()
                + " AS T INNER JOIN " + getSchemaName() + "." + conceptTableName + " ON " + conceptTableName
                + "." + conceptIsPrimitiveColumnName + " =0 AND T." + getSubTypeColumnName() + " = ? " + " AND "
                + conceptTableName + "." + conceptIdColumnName + " = T." + getSuperTypeColumnName());

        getPrimitiveAncestorsStatement = getConnection().prepareStatement("" + "SELECT T."
                + getSuperTypeColumnName() + " FROM " + getSchemaName() + "." + getTcTableName()
                + " AS T INNER JOIN " + getSchemaName() + "." + conceptTableName + " ON " + conceptTableName
                + "." + conceptIsPrimitiveColumnName + " =1 AND T." + getSubTypeColumnName() + " = ? " + " AND "
                + conceptTableName + "." + conceptIdColumnName + " = T." + getSuperTypeColumnName());

        checkPrimitiveStatusStatement = getConnection()
                .prepareStatement("" + "SELECT " + conceptIsPrimitiveColumnName + " FROM " + getSchemaName()
                        + "." + conceptTableName + " WHERE " + conceptIdColumnName + " = ?");

    } catch (SQLException e) {
        logger.warn(e.fillInStackTrace());
    }
}

From source file:uk.nhs.cfh.dsp.snomed.hierarchyprovider.impl.NormalFormHierarchyProviderImpl.java

public Set<String> getPrimitiveParents(String conceptId) {

    Set<String> primitiveParents = new HashSet<String>();
    if (conceptId != null) {

        // set and execute getPrimitiveParentsStatement
        try {//from   ww  w  .  j  av a  2s  .c  o m
            getPrimitiveParentsStatement.setString(1, conceptId);
            ResultSet rs = getPrimitiveParentsStatement.executeQuery();
            while (rs.next()) {
                String primitiveParent = rs.getString(1);
                primitiveParents.add(primitiveParent);
            }

            // close result set
            rs.close();
            if (logger.isDebugEnabled()) {
                logger.debug("primitiveParents = " + primitiveParents);
            }

        } catch (SQLException e) {
            logger.warn(e.fillInStackTrace());
        }
    } else {
        throw new IllegalArgumentException("Argument passed can not be null : " + conceptId);
    }

    return primitiveParents;
}

From source file:uk.nhs.cfh.dsp.snomed.hierarchyprovider.impl.NormalFormHierarchyProviderImpl.java

public Set<String> getPrimitiveAncestors(String conceptId) {

    Set<String> primitiveAncestors = new HashSet<String>();
    if (conceptId != null) {
        // set conceptid in getPrimitiveAncestorsStatement  and execute it
        try {/*from  w w w . j  av a2  s  .  c  o  m*/
            getPrimitiveAncestorsStatement.setString(1, conceptId);
            ResultSet rs = getPrimitiveAncestorsStatement.executeQuery();
            while (rs.next()) {
                String primitiveAncestor = rs.getString(1);
                primitiveAncestors.add(primitiveAncestor);
            }

            // close result set
            rs.close();

            /*
            The TC table currently seems to allow a concept to add self as supertype of self...
            this needs to be handled... so remove concept itself from proximalPrimitives
            */

            primitiveAncestors.remove(conceptId);
            if (logger.isDebugEnabled()) {
                logger.debug("primitiveAncestors = " + primitiveAncestors);
            }
        } catch (SQLException e) {
            logger.warn(e.fillInStackTrace());
        }
    } else {
        throw new IllegalArgumentException("ConceptId passed can not be null");
    }

    return primitiveAncestors;
}

From source file:uk.nhs.cfh.dsp.snomed.hierarchyprovider.impl.NormalFormHierarchyProviderImpl.java

public Set<String> getFullyDefinedAncestors(String conceptId) {

    Set<String> definedAncestors = new HashSet<String>();
    if (conceptId != null) {
        // set conceptid in getDefinedAncestorsStatement  and execute it
        try {//from  w w  w.ja  v a 2  s .c o m
            getDefinedAncestorsStatement.setString(1, conceptId);
            ResultSet rs = getDefinedAncestorsStatement.executeQuery();
            while (rs.next()) {
                String definedAncestor = rs.getString(1);
                definedAncestors.add(definedAncestor);
            }

            // close result set
            rs.close();
            if (logger.isDebugEnabled()) {
                logger.debug("definedAncestors = " + definedAncestors);
            }
        } catch (SQLException e) {
            logger.warn(e.fillInStackTrace());
        }
    } else {
        throw new IllegalArgumentException("ConceptId passed can not be null");
    }

    return definedAncestors;
}

From source file:uk.nhs.cfh.dsp.snomed.hierarchyprovider.impl.NormalFormHierarchyProviderImpl.java

public Set<String> getFullyDefinedParents(String conceptId) {

    Set<String> definedParents = new HashSet<String>();
    if (conceptId != null) {
        // set and execute getDefinedParentsStatement
        try {/*from w w w .  j  a v a2  s . c  o m*/
            getDefinedParentsStatement.setString(1, conceptId);
            ResultSet rs = getDefinedParentsStatement.executeQuery();
            while (rs.next()) {
                String definedParent = rs.getString(1);
                definedParents.add(definedParent);
            }

            // close result set
            rs.close();

            if (logger.isDebugEnabled()) {
                logger.debug("definedParents = " + definedParents);
            }

        } catch (SQLException e) {
            logger.warn(e.fillInStackTrace());
        }

    } else {
        throw new IllegalArgumentException("Argument passed can not be null");
    }

    return definedParents;
}

From source file:uk.nhs.cfh.dsp.snomed.hierarchyprovider.impl.NormalFormHierarchyProviderImpl.java

public Set<String> getProximalPrimitiveParents(String conceptId) {

    if (conceptId != null) {
        // check if concept with id is primitive
        try {/*w  w w.  ja v a  2  s .  com*/
            int status = 0;
            checkPrimitiveStatusStatement.setString(1, conceptId);
            ResultSet rs = checkPrimitiveStatusStatement.executeQuery();
            while (rs.next()) {
                status = rs.getInt(1);
            }

            // close resultset
            rs.close();

            if (status == 1) {
                // we know concept is primitive, so we just have to return itself
                return Collections.singleton(conceptId);
            } else {
                Set<String> proximalPrimitives = new HashSet<String>();
                /*
                we get all primitive ancestors. We then loop through the ancestors and remove the ancestors
                that are parents of another entry already present.
                */

                Set<String> primitiveAncestors = getPrimitiveAncestors(conceptId);

                // add all primitiveAncestors  to proximalPrimitives and then keep removing primitive parents
                proximalPrimitives.addAll(primitiveAncestors);
                for (String ancestor : primitiveAncestors) {
                    // get primtive ancestors of ancestor and remove from proximal primitives
                    Set<String> localAncestors = getPrimitiveAncestors(ancestor);
                    proximalPrimitives.removeAll(localAncestors);
                }

                return proximalPrimitives;
            }
        } catch (SQLException e) {
            logger.warn(e.fillInStackTrace());
            return Collections.emptySet();
        }
    } else {
        throw new IllegalArgumentException(
                "Concept with ID passed does not exist. Concept ID is : " + conceptId);
    }
}