|
20 | 20 |
|
21 | 21 | import javax.ejb.Local; |
22 | 22 |
|
| 23 | +import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO; |
23 | 24 | import org.apache.log4j.Logger; |
24 | 25 | import org.springframework.stereotype.Component; |
25 | 26 |
|
26 | 27 | import com.cloud.storage.VMTemplateZoneVO; |
27 | 28 | import com.cloud.utils.db.GenericDaoBase; |
28 | 29 | import com.cloud.utils.db.SearchBuilder; |
29 | 30 | import com.cloud.utils.db.SearchCriteria; |
| 31 | +import com.cloud.utils.db.Transaction; |
30 | 32 |
|
31 | 33 | @Component |
32 | 34 | @Local(value={VMTemplateZoneDao.class}) |
33 | 35 | public class VMTemplateZoneDaoImpl extends GenericDaoBase<VMTemplateZoneVO, Long> implements VMTemplateZoneDao { |
34 | 36 | public static final Logger s_logger = Logger.getLogger(VMTemplateZoneDaoImpl.class.getName()); |
35 | | - |
| 37 | + |
36 | 38 | protected final SearchBuilder<VMTemplateZoneVO> ZoneSearch; |
37 | 39 | protected final SearchBuilder<VMTemplateZoneVO> TemplateSearch; |
38 | 40 | protected final SearchBuilder<VMTemplateZoneVO> ZoneTemplateSearch; |
39 | | - |
40 | | - |
| 41 | + |
| 42 | + |
41 | 43 | public VMTemplateZoneDaoImpl () { |
42 | 44 | ZoneSearch = createSearchBuilder(); |
43 | 45 | ZoneSearch.and("zone_id", ZoneSearch.entity().getZoneId(), SearchCriteria.Op.EQ); |
44 | 46 | ZoneSearch.done(); |
45 | | - |
| 47 | + |
46 | 48 | TemplateSearch = createSearchBuilder(); |
47 | 49 | TemplateSearch.and("template_id", TemplateSearch.entity().getTemplateId(), SearchCriteria.Op.EQ); |
48 | 50 | TemplateSearch.done(); |
49 | | - |
| 51 | + |
50 | 52 | ZoneTemplateSearch = createSearchBuilder(); |
51 | 53 | ZoneTemplateSearch.and("zone_id", ZoneTemplateSearch.entity().getZoneId(), SearchCriteria.Op.EQ); |
52 | 54 | ZoneTemplateSearch.and("template_id", ZoneTemplateSearch.entity().getTemplateId(), SearchCriteria.Op.EQ); |
53 | 55 | ZoneTemplateSearch.done(); |
54 | 56 | } |
55 | | - |
| 57 | + |
56 | 58 |
|
57 | 59 | @Override |
58 | 60 | public List<VMTemplateZoneVO> listByZoneId(long id) { |
@@ -84,6 +86,19 @@ public List<VMTemplateZoneVO> listByZoneTemplate(Long zoneId, long templateId) { |
84 | 86 | } |
85 | 87 | sc.setParameters("template_id", templateId); |
86 | 88 | return listBy(sc); |
87 | | - } |
| 89 | + } |
| 90 | + |
| 91 | + |
| 92 | + @Override |
| 93 | + public void deletePrimaryRecordsForTemplate(long templateId) { |
| 94 | + SearchCriteria<VMTemplateZoneVO> sc = TemplateSearch.create(); |
| 95 | + sc.setParameters("template_id", templateId); |
| 96 | + Transaction txn = Transaction.currentTxn(); |
| 97 | + txn.start(); |
| 98 | + remove(sc); |
| 99 | + txn.commit(); |
| 100 | + |
| 101 | + } |
| 102 | + |
88 | 103 |
|
89 | 104 | } |
0 commit comments