mirror of https://github.com/apache/cloudstack.git
propagate sort order through retrieval sequence (#9624)
This commit is contained in:
parent
dda9ef2dc8
commit
0fae0c021f
|
|
@ -32,7 +32,6 @@ import org.springframework.stereotype.Component;
|
|||
import com.cloud.storage.DiskOfferingVO;
|
||||
import com.cloud.storage.Storage;
|
||||
import com.cloud.utils.db.Attribute;
|
||||
import com.cloud.utils.db.Filter;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
|
|
@ -60,16 +59,6 @@ public class DiskOfferingDaoImpl extends GenericDaoBase<DiskOfferingVO, Long> im
|
|||
_computeOnlyAttr = _allAttributes.get("computeOnly");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DiskOfferingVO> searchIncludingRemoved(SearchCriteria<DiskOfferingVO> sc, final Filter filter, final Boolean lock, final boolean cache) {
|
||||
return super.searchIncludingRemoved(sc, filter, lock, cache);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <K> List<K> customSearchIncludingRemoved(SearchCriteria<K> sc, final Filter filter) {
|
||||
return super.customSearchIncludingRemoved(sc, filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<DiskOfferingVO> executeList(final String sql, final Object... params) {
|
||||
StringBuilder builder = new StringBuilder(sql);
|
||||
|
|
|
|||
|
|
@ -3639,7 +3639,7 @@ public class QueryManagerImpl extends MutualExclusiveIdsManagerBase implements Q
|
|||
public ListResponse<ServiceOfferingResponse> searchForServiceOfferings(ListServiceOfferingsCmd cmd) {
|
||||
Pair<List<ServiceOfferingJoinVO>, Integer> result = searchForServiceOfferingsInternal(cmd);
|
||||
result.first();
|
||||
ListResponse<ServiceOfferingResponse> response = new ListResponse<ServiceOfferingResponse>();
|
||||
ListResponse<ServiceOfferingResponse> response = new ListResponse<>();
|
||||
List<ServiceOfferingResponse> offeringResponses = ViewResponseHelper.createServiceOfferingResponse(result.first().toArray(new ServiceOfferingJoinVO[result.first().size()]));
|
||||
response.setResponses(offeringResponses, result.second());
|
||||
return response;
|
||||
|
|
|
|||
|
|
@ -39,11 +39,13 @@ import com.cloud.offering.DiskOffering;
|
|||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.server.ResourceTag;
|
||||
import com.cloud.user.AccountManager;
|
||||
import com.cloud.utils.db.Attribute;
|
||||
import com.cloud.utils.db.Filter;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
|
||||
import static org.apache.cloudstack.query.QueryService.SortKeyAscending;
|
||||
|
||||
@Component
|
||||
public class DiskOfferingJoinDaoImpl extends GenericDaoBase<DiskOfferingJoinVO, Long> implements DiskOfferingJoinDao {
|
||||
public static final Logger s_logger = Logger.getLogger(DiskOfferingJoinDaoImpl.class);
|
||||
|
|
@ -59,7 +61,6 @@ public class DiskOfferingJoinDaoImpl extends GenericDaoBase<DiskOfferingJoinVO,
|
|||
|
||||
private final SearchBuilder<DiskOfferingJoinVO> dofIdSearch;
|
||||
private SearchBuilder<DiskOfferingJoinVO> diskOfferingSearch;
|
||||
private final Attribute _typeAttr;
|
||||
|
||||
protected DiskOfferingJoinDaoImpl() {
|
||||
|
||||
|
|
@ -71,9 +72,6 @@ public class DiskOfferingJoinDaoImpl extends GenericDaoBase<DiskOfferingJoinVO,
|
|||
diskOfferingSearch.and("idIN", diskOfferingSearch.entity().getId(), SearchCriteria.Op.IN);
|
||||
diskOfferingSearch.done();
|
||||
|
||||
|
||||
_typeAttr = _allAttributes.get("type");
|
||||
|
||||
_count = "select count(distinct id) from disk_offering_view WHERE ";
|
||||
}
|
||||
|
||||
|
|
@ -168,6 +166,8 @@ public class DiskOfferingJoinDaoImpl extends GenericDaoBase<DiskOfferingJoinVO,
|
|||
|
||||
@Override
|
||||
public List<DiskOfferingJoinVO> searchByIds(Long... offeringIds) {
|
||||
Filter searchFilter = new Filter(DiskOfferingJoinVO.class, "sortKey", SortKeyAscending.value());
|
||||
searchFilter.addOrderBy(DiskOfferingJoinVO.class, "id", true);
|
||||
// set detail batch query size
|
||||
int DETAILS_BATCH_SIZE = 2000;
|
||||
String batchCfg = configDao.getValue("detail.batch.query.size");
|
||||
|
|
@ -186,7 +186,7 @@ public class DiskOfferingJoinDaoImpl extends GenericDaoBase<DiskOfferingJoinVO,
|
|||
}
|
||||
SearchCriteria<DiskOfferingJoinVO> sc = diskOfferingSearch.create();
|
||||
sc.setParameters("idIN", ids);
|
||||
List<DiskOfferingJoinVO> accounts = searchIncludingRemoved(sc, null, null, false);
|
||||
List<DiskOfferingJoinVO> accounts = searchIncludingRemoved(sc, searchFilter, null, false);
|
||||
if (accounts != null) {
|
||||
uvList.addAll(accounts);
|
||||
}
|
||||
|
|
@ -202,7 +202,7 @@ public class DiskOfferingJoinDaoImpl extends GenericDaoBase<DiskOfferingJoinVO,
|
|||
}
|
||||
SearchCriteria<DiskOfferingJoinVO> sc = diskOfferingSearch.create();
|
||||
sc.setParameters("idIN", ids);
|
||||
List<DiskOfferingJoinVO> accounts = searchIncludingRemoved(sc, null, null, false);
|
||||
List<DiskOfferingJoinVO> accounts = searchIncludingRemoved(sc, searchFilter, null, false);
|
||||
if (accounts != null) {
|
||||
uvList.addAll(accounts);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,5 +34,6 @@ public interface ServiceOfferingJoinDao extends GenericDao<ServiceOfferingJoinVO
|
|||
ServiceOfferingJoinVO newServiceOfferingView(ServiceOffering offering);
|
||||
|
||||
Map<Long, List<String>> listDomainsOfServiceOfferingsUsedByDomainPath(String domainPath);
|
||||
|
||||
List<ServiceOfferingJoinVO> searchByIds(Long... id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,13 +25,8 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.cloud.dc.VsphereStoragePolicyVO;
|
||||
import com.cloud.dc.dao.VsphereStoragePolicyDao;
|
||||
import com.cloud.user.AccountManager;
|
||||
import com.cloud.utils.db.TransactionLegacy;
|
||||
import org.apache.cloudstack.annotation.AnnotationService;
|
||||
import org.apache.cloudstack.annotation.dao.AnnotationDao;
|
||||
import com.cloud.storage.DiskOfferingVO;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
|
|
@ -41,14 +36,22 @@ import org.springframework.stereotype.Component;
|
|||
|
||||
import com.cloud.api.ApiDBUtils;
|
||||
import com.cloud.api.query.vo.ServiceOfferingJoinVO;
|
||||
import com.cloud.dc.VsphereStoragePolicyVO;
|
||||
import com.cloud.dc.dao.VsphereStoragePolicyDao;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.server.ResourceTag.ResourceObjectType;
|
||||
import com.cloud.storage.DiskOfferingVO;
|
||||
import com.cloud.user.AccountManager;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.Filter;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.TransactionLegacy;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static org.apache.cloudstack.query.QueryService.SortKeyAscending;
|
||||
|
||||
@Component
|
||||
public class ServiceOfferingJoinDaoImpl extends GenericDaoBase<ServiceOfferingJoinVO, Long> implements ServiceOfferingJoinDao {
|
||||
public static final Logger s_logger = Logger.getLogger(ServiceOfferingJoinDaoImpl.class);
|
||||
|
|
@ -230,6 +233,9 @@ public class ServiceOfferingJoinDaoImpl extends GenericDaoBase<ServiceOfferingJo
|
|||
|
||||
@Override
|
||||
public List<ServiceOfferingJoinVO> searchByIds(Long... offeringIds) {
|
||||
Filter searchFilter = new Filter(ServiceOfferingJoinVO.class, "sortKey", SortKeyAscending.value());
|
||||
searchFilter.addOrderBy(ServiceOfferingJoinVO.class, "id", true);
|
||||
|
||||
// set detail batch query size
|
||||
int DETAILS_BATCH_SIZE = 2000;
|
||||
String batchCfg = configDao.getValue("detail.batch.query.size");
|
||||
|
|
@ -248,9 +254,9 @@ public class ServiceOfferingJoinDaoImpl extends GenericDaoBase<ServiceOfferingJo
|
|||
}
|
||||
SearchCriteria<ServiceOfferingJoinVO> sc = srvOfferingSearch.create();
|
||||
sc.setParameters("idIN", ids);
|
||||
List<ServiceOfferingJoinVO> accounts = searchIncludingRemoved(sc, null, null, false);
|
||||
if (accounts != null) {
|
||||
uvList.addAll(accounts);
|
||||
List<ServiceOfferingJoinVO> offerings = searchIncludingRemoved(sc, searchFilter, null, false);
|
||||
if (offerings != null) {
|
||||
uvList.addAll(offerings);
|
||||
}
|
||||
curr_index += DETAILS_BATCH_SIZE;
|
||||
}
|
||||
|
|
@ -264,9 +270,9 @@ public class ServiceOfferingJoinDaoImpl extends GenericDaoBase<ServiceOfferingJo
|
|||
}
|
||||
SearchCriteria<ServiceOfferingJoinVO> sc = srvOfferingSearch.create();
|
||||
sc.setParameters("idIN", ids);
|
||||
List<ServiceOfferingJoinVO> accounts = searchIncludingRemoved(sc, null, null, false);
|
||||
if (accounts != null) {
|
||||
uvList.addAll(accounts);
|
||||
List<ServiceOfferingJoinVO> offerings = searchIncludingRemoved(sc, searchFilter, null, false);
|
||||
if (offerings != null) {
|
||||
uvList.addAll(offerings);
|
||||
}
|
||||
}
|
||||
return uvList;
|
||||
|
|
|
|||
|
|
@ -534,6 +534,12 @@ export default {
|
|||
actions: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
currentPage: {
|
||||
type: Number
|
||||
},
|
||||
pageSize: {
|
||||
type: Number
|
||||
}
|
||||
},
|
||||
inject: ['parentFetchData', 'parentToggleLoading'],
|
||||
|
|
@ -754,8 +760,9 @@ export default {
|
|||
},
|
||||
updateOrder (data) {
|
||||
const promises = []
|
||||
const previousSortKeys = this.pageSize && this.currentPage ? this.pageSize * (this.currentPage - 1) : 0
|
||||
data.forEach((item, index) => {
|
||||
promises.push(this.handleUpdateOrder(item.id, index + 1))
|
||||
promises.push(this.handleUpdateOrder(item.id, previousSortKeys + index + 1))
|
||||
})
|
||||
Promise.all(promises).catch((reason) => {
|
||||
console.log(reason)
|
||||
|
|
|
|||
|
|
@ -412,6 +412,8 @@
|
|||
:columns="columns"
|
||||
:items="items"
|
||||
:actions="actions"
|
||||
:currentPage="page"
|
||||
:pageSize="pageSize"
|
||||
:columnKeys="columnKeys"
|
||||
:selectedColumns="selectedColumns"
|
||||
ref="listview"
|
||||
|
|
|
|||
Loading…
Reference in New Issue