// wdev-18049
  public Boolean countContractsWithTheSameServiceForTheSaneCCGCode(
      ContractConfigRefVo contractId, ServiceRefVo serviceRef, String cCGCode) {
    if (cCGCode == null || cCGCode == "") return null;

    StringBuilder hqlBuilder =
        new StringBuilder(
            "select c1_1.id, count (c1_1.id) from ContractConfig as c1_1 left join c1_1.serviceLocations as c2_1 left join c2_1.service as s1_1 left join c1_1.cCGsForContract as c3_1 where  ( ");
    ArrayList<String> paramNames = new ArrayList<String>();
    ArrayList<Object> paramValues = new ArrayList<Object>();

    String and = "";
    if (contractId != null && contractId.getID_ContractConfigIsNotNull()) {
      hqlBuilder.append("c1_1.id <> :cID ");
      and = "and ";
      paramNames.add("cID");
      paramValues.add(contractId.getID_ContractConfig());
    }
    if (serviceRef != null && serviceRef.getID_ServiceIsNotNull()) {
      hqlBuilder.append(and);
      hqlBuilder.append("s1_1.id = :service ");
      and = "and ";
      paramNames.add("service");
      paramValues.add(serviceRef.getID_Service());
    }
    if (cCGCode != null) {
      hqlBuilder.append(and);
      hqlBuilder.append(" c3_1.cCGCode like :ccgCode and c3_1.isActive = 1");
      and = "and ";
      paramNames.add("ccgCode");
      paramValues.add("%" + cCGCode + "%");
    }

    hqlBuilder.append(") group by c1_1.id");

    List<?> dos = getDomainFactory().find(hqlBuilder.toString(), paramNames, paramValues);
    if (dos != null && dos.size() > 0) {
      Object[] value = (Object[]) dos.get(0);
      Integer nrcontracts = (Integer) value[0];
      if (nrcontracts > 0) return true;
      else return false;
    }

    return null;
  }
  // WDEV-20181
  public ContractServiceLocationsConfigVo getContractServiceLocConfByContractService(
      ContractConfigRefVo contractRef, ServiceRefVo serviceRef) {
    if (contractRef == null || serviceRef == null) {
      return null;
    }

    String sql =
        "select serviceLoc from ContractConfig as contractConf left join contractConf.serviceLocations as serviceLoc where contractConf.id = :ContractID and serviceLoc.service.id = :ServiceID";

    List<?> listServiceLoc =
        getDomainFactory()
            .find(
                sql,
                new String[] {"ContractID", "ServiceID"},
                new Object[] {contractRef.getID_ContractConfig(), serviceRef.getID_Service()});

    if (listServiceLoc != null && listServiceLoc.size() > 0)
      return ContractServiceLocationsConfigVoAssembler.create(
          (ContractServiceLocationsConfig) listServiceLoc.get(0));

    return null;
  }