Coverage Summary for Class: RecursiveResourcePersister (com.acciente.oacc.sql.internal.persister)

Class Class, % Method, % Line, %
RecursiveResourcePersister 100% (1/ 1) 100% (2/ 2) 78.6% (11/ 14)


1 /* 2  * Copyright 2009-2018, Acciente LLC 3  * 4  * Acciente LLC licenses this file to you under the 5  * Apache License, Version 2.0 (the "License"); you 6  * may not use this file except in compliance with the 7  * License. You may obtain a copy of the License at 8  * 9  * http://www.apache.org/licenses/LICENSE-2.0 10  * 11  * Unless required by applicable law or agreed to in 12  * writing, software distributed under the License is 13  * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES 14  * OR CONDITIONS OF ANY KIND, either express or implied. 15  * See the License for the specific language governing 16  * permissions and limitations under the License. 17  */ 18 package com.acciente.oacc.sql.internal.persister; 19  20 import com.acciente.oacc.sql.SQLProfile; 21 import com.acciente.oacc.sql.internal.persister.id.DomainId; 22 import com.acciente.oacc.sql.internal.persister.id.Id; 23  24 import java.io.Serializable; 25 import java.sql.SQLException; 26  27 public class RecursiveResourcePersister extends CommonResourcePersister implements Serializable { 28  private static final long serialVersionUID = 1L; 29  30  public RecursiveResourcePersister(SQLProfile sqlProfile, 31  SQLStrings sqlStrings) { 32  super(sqlProfile, sqlStrings); 33  } 34  35  @Override 36  public boolean isDomainEmpty(SQLConnection connection, Id<DomainId> resourceDomainId) { 37  SQLStatement statement = null; 38  39  try { 40  SQLResult resultSet; 41  42  statement = connection.prepareStatement(sqlStrings.SQL_findInResource_COUNTResourceID_BY_DomainID); 43  statement.setResourceDomainId(1, resourceDomainId); 44  resultSet = statement.executeQuery(); 45  46  if (!resultSet.next()) { 47  throw new IllegalArgumentException("Could not read resource count for domain: " + resourceDomainId); 48  } 49  50  final int count = resultSet.getInteger("COUNTResourceID"); 51  52  resultSet.close(); 53  54  return count == 0; 55  } 56  catch (SQLException e) { 57  throw new RuntimeException(e); 58  } 59  finally { 60  closeStatement(statement); 61  } 62  } 63 }