+
+ /**
+ * Add the table to a query string.
+ *
+ * @param queryString the query string
+ * @param tableClass the class name of the table
+ * @return the updated query string
+ */
+ private <T extends PfConcept> String setQueryTable(final String queryString, final Class<T> tableClass) {
+ return queryString.replace(TABLE_TOKEN, tableClass.getSimpleName());
+ }
+
+ /**
+ * Check that a query returned one and only one entry and return that entry.
+ *
+ * @param someClass the class being searched for
+ * @param searchFilter the search filter
+ * @param resultList the result list returned by the query
+ * @return the single unique result
+ */
+ private <T extends PfConcept> T getSingleResult(final Class<T> someClass, final String searchFilter,
+ List<T> resultList) {
+ if (resultList == null || resultList.isEmpty()) {
+ return null;
+ }
+ if (resultList.size() > 1) {
+ throw new IllegalArgumentException("More than one result was returned query on " + someClass
+ + " with filter " + searchFilter + ": " + resultList);
+ }
+ return resultList.get(0);
+ }
+
+ /**
+ * check the result get from database and return the object.
+ *
+ * @param <T> the type of the object to get, a subclass of {@link PfConcept}
+ * @param someClass the class of the object to get, a subclass of {@link PfConcept}
+ * @param objToCheck the object that was retrieved from the database
+ * @return the checked object or null
+ */
+ private <T extends PfConcept> T checkAndReturn(final Class<T> someClass, final T objToCheck) {
+ if (objToCheck != null) {
+ try {
+ return PfUtils.makeCopy(objToCheck);
+ } catch (final Exception e) {
+ LOGGER.warn(CLONE_ERR_MSG, someClass.getName(), e);
+ }
+ }
+ return null;
+ }