List of usage examples for java.sql SQLException fillInStackTrace
public synchronized Throwable fillInStackTrace()
From source file:uk.nhs.cfh.dsp.snomed.dao.impl.SnomedConceptDatabaseDAO.java
/** * Initialise statements.//from w w w . ja v a 2 s .c om */ public synchronized void initialiseStatements() { // create prepared statements try { getConceptWithIDStatement = connection .prepareStatement("" + "SELECT DISTINCT FULLYSPECIFIEDNAME, ISPRIMITIVE, CONCEPTSTATUS," + "CTV3ID, SNOMEDID, SOURCE FROM SNOMED.CONCEPT " + "WHERE CONCEPTID = ? "); // descriptions getDescriptionsForConceptIDStatement = connection.prepareStatement( "" + "SELECT DISTINCT DESCRIPTIONID, DESCRIPTIONSTATUS, TERM, INITIALCAPITALSTATUS, " + "DESCRIPTIONTYPE, LANGUAGECODE, SOURCE FROM SNOMED.TERM " + "WHERE CONCEPTID = ? "); // relationships getRelationshipsForConceptIDStatement = connection .prepareStatement("" + "SELECT DISTINCT RELATIONSHIPID, CONCEPTID1, RELATIONSHIPTYPE, " + "CONCEPTID2, CHARACTERISTICTYPE, REFINABILITY, RELATIONSHIPGROUP, SOURCE " + "FROM SNOMED.REL WHERE CONCEPTID1 = ?"); getChildRelationshipsForConceptIDStatement = connection .prepareStatement("" + "SELECT DISTINCT CONCEPTID1 " + "FROM SNOMED.REL WHERE RELATIONSHIPTYPE = '116680003' AND CONCEPTID2 = ?"); // get concepts like statement getConceptsLikeStatement = connection.prepareStatement( "" + "SELECT DISTINCT CONCEPTID FROM SNOMED.CONCEPT " + "WHERE FULLYSPECIFIEDNAME LIKE ? "); // get ancestors statement getAncestorsStatement = connection.prepareStatement( "" + "SELECT SUPERTYPEID FROM SNOMED.TRANSITIVECLOSURE " + "WHERE SUBTYPEID = ?"); // get descendants getDescendantsStatement = connection.prepareStatement( "" + "SELECT SUBTYPEID FROM SNOMED.TRANSITIVECLOSURE " + "WHERE SUPERTYPEID = ?"); // get replacements getReplacementConceptStatement = connection .prepareStatement("" + "SELECT CONCEPTID2 FROM SNOMED.REL WHERE CONCEPTID1 = ? AND " + "RELATIONHSIPTYPE IN ('168666000', '370124000')"); // get preferred term getPreferredTermStatement = connection.prepareStatement( "" + "SELECT TERM FROM SNOMED.TERM WHERE DESCRIPTIONTYPE = 1 AND CONCEPTID = ?"); } catch (SQLException e) { logger.warn("SQL error encountered while initialising statements.\n" + "Nested exception is : " + e.fillInStackTrace()); } }
From source file:uk.nhs.cfh.dsp.snomed.dao.impl.SnomedConceptDatabaseDAO.java
public synchronized TerminologyConcept getTerminologyConcept(String conceptID) throws ConceptNotFoundException { String conceptLabel = ""; boolean isPrimitive = true; String source = ""; int conceptStatus = 0; String ctv3ID = ""; String snomedID = ""; // set value in prepared statement try {//from w ww . j a v a2 s . co m // strip all non digit numbers from concept id conceptID = conceptID.replaceAll("[^\\d]", ""); getConceptWithIDStatement.setString(1, conceptID); ResultSet rs = getConceptWithIDStatement.executeQuery(); while (rs.next()) { conceptLabel = rs.getString(1); int isPrim = rs.getInt(2); conceptStatus = rs.getInt(3); ctv3ID = rs.getString(4); snomedID = rs.getString(5); if (isPrim == 0) { isPrimitive = false; } source = rs.getString(6); } // close result set rs.close(); } catch (SQLException e) { logger.warn("SQL Error encountered while checking for concept with id : " + conceptID + "\nNested exception is : " + e.fillInStackTrace()); } catch (Exception e) { logger.warn("A variable most likely returned a null value unexpectedly." + "\nNested exception is : " + e.fillInStackTrace()); } // create terminology concept if ("".equalsIgnoreCase(conceptLabel)) { throw new ConceptNotFoundException(conceptID); } else { SnomedConcept concept = new SnomedConceptImpl(conceptID, conceptLabel); // add primitve status concept.setPrimitive(isPrimitive); concept.setSource(source); // use utility function of ComponentStatus to get value concept.setStatus(ComponentStatus.valueOf(conceptStatus)); concept.setCtv3ID(ctv3ID); concept.setSnomedID(snomedID); // set concept type concept.setType(getConceptType(conceptID)); try { // set descriptions setDescriptions(concept); // set relationships setRelationships(concept); } catch (SQLException e) { logger.warn("SQL Exception while querying database. Nested exception is : " + e.fillInStackTrace()); } catch (Exception e) { logger.warn("A variable most likely returned a null value unexpectedly." + "\nNested exception is : " + e.fillInStackTrace()); } return concept; } }
From source file:uk.nhs.cfh.dsp.snomed.dao.impl.SnomedConceptDatabaseDAO.java
public synchronized TerminologyConcept getCurrentConceptForConcept(String conceptId) throws ConceptNotFoundException { if (conceptId != null) { // replace value in getReplacementConceptStatement try {//from ww w. j a v a2 s . c om getReplacementConceptStatement.setString(1, conceptId); ResultSet rs = getReplacementConceptStatement.executeQuery(); Set<String> replacements = new HashSet<String>(); while (rs.next()) { replacements.add(rs.getString(1)); } // close result set rs.close(); List<String> concepts = new ArrayList<String>(replacements); if (replacements.size() > 1) { logger.warn("More than one matching replacement concept found. Returning the first " + "concept found. The following is a list of all matching replacements : " + replacements); return getTerminologyConcept(concepts.get(0)); } else if (replacements.size() == 0) { logger.warn("No replacement concept found for concept with ID : " + conceptId); return null; } else { return getTerminologyConcept(concepts.get(0)); } } catch (SQLException e) { logger.warn(e.fillInStackTrace()); return null; } } else { throw new IllegalArgumentException("Concept ID passed can not be null."); } }
From source file:uk.nhs.cfh.dsp.snomed.dao.impl.SnomedConceptDatabaseDAO.java
/** * Gets the concept type.//ww w. j a va 2s . c om * * @param conceptId the concept id * @return the concept type */ protected synchronized ConceptType getConceptType(String conceptId) { ConceptType type = ConceptType.UNKNOWN; // we create a sorted concept type list, because we need to check in a specific order List<ConceptType> types = new ArrayList<ConceptType>(); types.add(ConceptType.DISEASE); types.add(ConceptType.FINDING); types.add(ConceptType.FINDING_WEC); types.add(ConceptType.OBSERVABLE_ENTITY); types.add(ConceptType.BODY_STRUCTURE); types.add(ConceptType.PHARMACEUTICAL_OR_BIOLOGICAL_PRODUCT); types.add(ConceptType.EVENT); types.add(ConceptType.SURGICAL_PROCEDURE); types.add(ConceptType.PROCEDURE); types.add(ConceptType.PROCEDURE_WEC); types.add(ConceptType.SPECIMEN); types.add(ConceptType.DRUG_DEVICE_COMBO_PRODUCT); types.add(ConceptType.SITUATION_WEC); try { PreparedStatement ps = connection.prepareStatement("SELECT COUNT(SUBTYPEID) FROM " + "SNOMED.TRANSITIVECLOSURE WHERE SUBTYPEID = ? AND SUPERTYPEID= ?"); ps.setString(1, conceptId); // change supertype and check result int result = 0; for (ConceptType ct : types) { ps.setString(2, ct.getID()); // execute statement and check result ResultSet rs = ps.executeQuery(); while (rs.next()) { result = rs.getInt(1); } // close result set rs.close(); if (result == 1) { // close ps ps.close(); return ct; } } } catch (SQLException e) { logger.warn("Error querying transitive closure table. Nested exception is : " + e.fillInStackTrace()); } return type; }
From source file:uk.nhs.cfh.dsp.snomed.dao.impl.SnomedConceptDatabaseDAO.java
/** * Sets the data source./* w w w . j a v a2s. c om*/ * * @param dataSource the new data source */ public synchronized void setDataSource(DataSource dataSource) { if (dataSource != null) { try { this.connection = dataSource.getConnection(); initialiseStatements(); } catch (SQLException e) { logger.warn("Error obtaining connection from data source. " + "Nested exception is : " + e.fillInStackTrace()); } } }
From source file:uk.nhs.cfh.dsp.snomed.expression.comparator.impl.AbstractExpressionComparator.java
/** * Instantiates a new abstract expression comparator. * * @param dataSource the data source//from w w w .j a va 2 s . co m * @param terminologyConceptDAO the terminology concept dao */ protected AbstractExpressionComparator(DataSource dataSource, TerminologyConceptDAO terminologyConceptDAO) { try { this.connection = dataSource.getConnection(); initialiseStatements(); } catch (SQLException e) { logger.warn("Error obtaining connection from data source. " + "Nested exception is : " + e.fillInStackTrace()); } this.terminologyConceptDAO = terminologyConceptDAO; }
From source file:uk.nhs.cfh.dsp.snomed.expression.comparator.impl.AbstractExpressionComparator.java
/** * Initialise statements./*from w w w. ja v a2 s .c o m*/ */ protected void initialiseStatements() { try { checkAncestorsStatement = connection .prepareStatement("" + "SELECT COUNT(SUPERTYPEID) FROM SNOMED.TRANSITIVECLOSURE WHERE " + "SUPERTYPEID = ? AND SUBTYPEID = ?"); checkDescendantsStatement = connection .prepareStatement("" + "SELECT COUNT(SUBTYPEID) FROM SNOMED.TRANSITIVECLOSURE WHERE " + "SUBTYPEID = ? AND SUPERTYPEID = ?"); checkStatusStatement = connection .prepareStatement("" + "SELECT CONCEPTSTATUS FROM SNOMED.CONCEPT WHERE CONCEPTID = ?"); } catch (SQLException e) { logger.warn(e.fillInStackTrace()); } }
From source file:uk.nhs.cfh.dsp.snomed.expression.comparator.impl.AbstractExpressionComparator.java
/** * Sets the data source./* w ww . j av a 2 s .co m*/ * * @param dataSource the new data source */ public synchronized void setDataSource(DataSource dataSource) { try { this.connection = dataSource.getConnection(); initialiseStatements(); } catch (SQLException e) { logger.warn("Error obtaining connection from data source. " + "Nested exception is : " + e.fillInStackTrace()); } }
From source file:uk.nhs.cfh.dsp.snomed.expression.comparator.impl.AbstractExpressionComparator.java
/** * Checks if is active concept.// w w w . jav a 2 s . co m * * @param conceptId the concept id * @return true, if is active concept */ private boolean isActiveConcept(String conceptId) { boolean isActive = false; // set value in checkStatusStatement try { int status = 0; checkStatusStatement.setString(1, conceptId); ResultSet rs = checkStatusStatement.executeQuery(); while (rs.next()) { status = rs.getInt(1); } if (status == 0 || status == 6 || status == 11) { isActive = true; } } catch (SQLException e) { logger.warn(e.fillInStackTrace()); } return isActive; }
From source file:uk.nhs.cfh.dsp.snomed.hierarchyprovider.impl.AbstractHierarchyProvider.java
/** * Instantiates a new hierarchy provider impl. * * @param dataSource the data source/*from ww w .ja v a 2 s .c o m*/ */ public AbstractHierarchyProvider(DataSource dataSource) { try { this.connection = dataSource.getConnection(); initialiseStatements(); } catch (SQLException e) { logger.warn("Error obtaining connection from data source. " + "Nested exception is : " + e.fillInStackTrace()); } }