@Override
  public List<VMTemplateVO> publicIsoSearch(
      Boolean bootable, boolean listRemoved, Map<String, String> tags) {

    SearchBuilder<VMTemplateVO> sb = null;
    if (tags == null || tags.isEmpty()) {
      sb = PublicIsoSearch;
    } else {
      sb = createSearchBuilder();
      sb.and("public", sb.entity().isPublicTemplate(), SearchCriteria.Op.EQ);
      sb.and("format", sb.entity().getFormat(), SearchCriteria.Op.EQ);
      sb.and("type", sb.entity().getTemplateType(), SearchCriteria.Op.EQ);
      sb.and("bootable", sb.entity().isBootable(), SearchCriteria.Op.EQ);
      sb.and("removed", sb.entity().getRemoved(), SearchCriteria.Op.EQ);

      SearchBuilder<ResourceTagVO> tagSearch = _tagsDao.createSearchBuilder();
      for (int count = 0; count < tags.size(); count++) {
        tagSearch
            .or()
            .op("key" + String.valueOf(count), tagSearch.entity().getKey(), SearchCriteria.Op.EQ);
        tagSearch.and(
            "value" + String.valueOf(count), tagSearch.entity().getValue(), SearchCriteria.Op.EQ);
        tagSearch.cp();
      }
      tagSearch.and("resourceType", tagSearch.entity().getResourceType(), SearchCriteria.Op.EQ);
      sb.groupBy(sb.entity().getId());
      sb.join(
          "tagSearch",
          tagSearch,
          sb.entity().getId(),
          tagSearch.entity().getResourceId(),
          JoinBuilder.JoinType.INNER);
    }

    SearchCriteria<VMTemplateVO> sc = sb.create();

    sc.setParameters("public", 1);
    sc.setParameters("format", "ISO");
    sc.setParameters("type", TemplateType.PERHOST.toString());
    if (bootable != null) {
      sc.setParameters("bootable", bootable);
    }

    if (!listRemoved) {
      sc.setParameters("removed", (Object) null);
    }

    if (tags != null && !tags.isEmpty()) {
      int count = 0;
      sc.setJoinParameters("tagSearch", "resourceType", TaggedResourceType.ISO.toString());
      for (String key : tags.keySet()) {
        sc.setJoinParameters("tagSearch", "key" + String.valueOf(count), key);
        sc.setJoinParameters("tagSearch", "value" + String.valueOf(count), tags.get(key));
        count++;
      }
    }

    return listBy(sc);
  }
 @Override
 @DB
 public List<VMTemplateVO> listAllInZone(long dataCenterId) {
   SearchCriteria<VMTemplateVO> sc = TmpltsInZoneSearch.create();
   sc.setParameters("avoidtype", TemplateType.PERHOST.toString());
   sc.setJoinParameters("tmpltzone", "zoneId", dataCenterId);
   return listBy(sc);
 }
  @Override
  public List<VMTemplateVO> publicIsoSearch(Boolean bootable, boolean listRemoved) {
    SearchCriteria<VMTemplateVO> sc = PublicIsoSearch.create();
    sc.setParameters("public", 1);
    sc.setParameters("format", "ISO");
    sc.setParameters("type", TemplateType.PERHOST.toString());
    if (bootable != null) {
      sc.setParameters("bootable", bootable);
    }

    if (!listRemoved) {
      sc.setParameters("removed", (Object) null);
    }

    return listBy(sc);
  }