@Override public int getVpcCountByOfferingId(long offId) { SearchCriteria<Integer> sc = CountByOfferingId.create(); sc.setParameters("offeringId", offId); List<Integer> results = customSearch(sc, null); return results.get(0); }
@Override public Vpc getActiveVpcById(long vpcId) { SearchCriteria<VpcVO> sc = AllFieldsSearch.create(); sc.setParameters("id", vpcId); sc.setParameters("state", Vpc.State.Enabled); return findOneBy(sc); }
@Override public List<? extends Vpc> listByAccountId(long accountId) { SearchCriteria<VpcVO> sc = AllFieldsSearch.create(); sc.setParameters("accountId", accountId); return listBy(sc, null); }
@Override @DB public VpcVO persist(VpcVO vpc, Map<String, List<String>> serviceProviderMap) { TransactionLegacy txn = TransactionLegacy.currentTxn(); txn.start(); VpcVO newVpc = super.persist(vpc); persistVpcServiceProviders(vpc.getId(), serviceProviderMap); txn.commit(); return newVpc; }
@Override @DB public boolean remove(Long id) { TransactionLegacy txn = TransactionLegacy.currentTxn(); txn.start(); VpcVO entry = findById(id); if (entry != null) { _tagsDao.removeByIdAndType(id, ResourceObjectType.Vpc); } boolean result = super.remove(id); txn.commit(); return result; }
protected VpcDaoImpl() { super(); CountByOfferingId = createSearchBuilder(Integer.class); CountByOfferingId.select(null, Func.COUNT, CountByOfferingId.entity().getId()); CountByOfferingId.and("offeringId", CountByOfferingId.entity().getVpcOfferingId(), Op.EQ); CountByOfferingId.and("removed", CountByOfferingId.entity().getRemoved(), Op.NULL); CountByOfferingId.done(); AllFieldsSearch = createSearchBuilder(); AllFieldsSearch.and("id", AllFieldsSearch.entity().getId(), Op.EQ); AllFieldsSearch.and("state", AllFieldsSearch.entity().getState(), Op.EQ); AllFieldsSearch.and("accountId", AllFieldsSearch.entity().getAccountId(), Op.EQ); AllFieldsSearch.done(); CountByAccountId = createSearchBuilder(Long.class); CountByAccountId.select(null, Func.COUNT, CountByAccountId.entity().getId()); CountByAccountId.and("accountId", CountByAccountId.entity().getAccountId(), Op.EQ); CountByAccountId.and("removed", CountByAccountId.entity().getRemoved(), Op.NULL); CountByAccountId.done(); }
@Override public long countByAccountId(long accountId) { SearchCriteria<Long> sc = CountByAccountId.create(); sc.setParameters("accountId", accountId); List<Long> results = customSearch(sc, null); return results.get(0); }
@Override public List<VpcVO> listInactiveVpcs() { SearchCriteria<VpcVO> sc = AllFieldsSearch.create(); sc.setParameters("state", Vpc.State.Inactive); return listBy(sc, null); }