1616// under the License.
1717package com .cloud .vm .dao ;
1818
19+ import com .cloud .utils .Pair ;
20+ import com .cloud .utils .db .Filter ;
1921import com .cloud .utils .db .GenericDaoBase ;
2022import com .cloud .utils .db .SearchBuilder ;
2123import com .cloud .utils .db .SearchCriteria ;
2224import com .cloud .vm .ImportVMTaskVO ;
25+ import org .apache .cloudstack .vm .ImportVmTask ;
2326import org .apache .commons .lang3 .StringUtils ;
2427import org .springframework .stereotype .Component ;
2528
@@ -41,12 +44,14 @@ void init() {
4144 AllFieldsSearch .and ("accountId" , AllFieldsSearch .entity ().getAccountId (), SearchCriteria .Op .EQ );
4245 AllFieldsSearch .and ("vcenter" , AllFieldsSearch .entity ().getVcenter (), SearchCriteria .Op .EQ );
4346 AllFieldsSearch .and ("convertHostId" , AllFieldsSearch .entity ().getConvertHostId (), SearchCriteria .Op .EQ );
47+ AllFieldsSearch .and ("state" , AllFieldsSearch .entity ().getState (), SearchCriteria .Op .EQ );
4448 AllFieldsSearch .done ();
4549 }
4650
4751
4852 @ Override
49- public List <ImportVMTaskVO > listImportVMTasks (Long zoneId , Long accountId , String vcenter , Long convertHostId , boolean showCompleted ) {
53+ public Pair <List <ImportVMTaskVO >, Integer > listImportVMTasks (Long zoneId , Long accountId , String vcenter , Long convertHostId ,
54+ ImportVmTask .TaskState state , Long startIndex , Long pageSizeVal ) {
5055 SearchCriteria <ImportVMTaskVO > sc = AllFieldsSearch .create ();
5156 if (zoneId != null ) {
5257 sc .setParameters ("zoneId" , zoneId );
@@ -60,6 +65,10 @@ public List<ImportVMTaskVO> listImportVMTasks(Long zoneId, Long accountId, Strin
6065 if (convertHostId != null ) {
6166 sc .setParameters ("convertHostId" , convertHostId );
6267 }
63- return showCompleted ? listIncludingRemovedBy (sc ) : listBy (sc );
68+ if (state != null ) {
69+ sc .setParameters ("state" , state );
70+ }
71+ Filter filter = new Filter (ImportVMTaskVO .class , "created" , false , startIndex , pageSizeVal );
72+ return searchAndCount (sc , filter );
6473 }
6574}
0 commit comments