@Override
  protected void syncSearch() {
    if (getEntity() == null) {
      return;
    }

    super.syncSearch();

    IdQueryParameters parameters = new IdQueryParameters((getEntity()).getId());
    parameters.setRefresh(getIsQueryFirstTime());

    Frontend.getInstance()
        .runQuery(
            VdcQueryType.GetAllDisksByStorageDomainId,
            parameters,
            new AsyncQuery(
                this,
                new INewAsyncCallback() {
                  @Override
                  public void onSuccess(Object model, Object ReturnValue) {
                    StorageDiskListModel storageDiskListModel = (StorageDiskListModel) model;
                    storageDiskListModel.setItems(
                        (ArrayList) ((VdcQueryReturnValue) ReturnValue).getReturnValue());
                  }
                }));
  }
Esempio n. 2
0
  @Override
  protected void syncSearch() {
    if (getEntity() == null) {
      return;
    }

    super.syncSearch();

    IdQueryParameters tempVar = new IdQueryParameters(getEntity().getId());
    tempVar.setRefresh(getIsQueryFirstTime());
    Frontend.getInstance()
        .runQuery(
            VdcQueryType.GetVmsByStorageDomain,
            tempVar,
            new AsyncQuery<>(
                new AsyncCallback<VdcQueryReturnValue>() {
                  @Override
                  public void onSuccess(VdcQueryReturnValue returnValue) {
                    ArrayList<VM> vms = returnValue.getReturnValue();
                    Collections.sort(vms, new LexoNumericNameableComparator<>());
                    setItems(vms);
                    setIsEmpty(vms.size() == 0);
                  }
                }));
  }
  @Test
  public void testExecuteQueryCommand() {
    IdQueryParameters params = getQueryParameters();
    when(params.getId()).thenReturn(vmId);

    GetAllVmSnapshotsByVmIdQuery<IdQueryParameters> query = getQuery();
    query.executeQueryCommand();

    @SuppressWarnings("unchecked")
    List<Snapshot> snapshots = query.getQueryReturnValue().getReturnValue();

    // Assert the correct disks are returned
    assertTrue("snapshot should be in the return value", snapshots.contains(snapshot));
    assertEquals("there should be exactly one snapshot returned", 1, snapshots.size());
  }
  @Override
  protected void syncSearch() {
    if (getEntity() == null) {
      return;
    }

    super.syncSearch();

    AsyncQuery _asyncQuery = new AsyncQuery();
    _asyncQuery.setModel(this);
    _asyncQuery.asyncCallback =
        new INewAsyncCallback() {
          @Override
          public void onSuccess(Object model, Object ReturnValue) {
            StorageVmListModel vmModel = (StorageVmListModel) model;
            vmModel.setItems((ArrayList<VM>) ((VdcQueryReturnValue) ReturnValue).getReturnValue());
            vmModel.setIsEmpty(((List) vmModel.getItems()).size() == 0);
          }
        };

    IdQueryParameters tempVar = new IdQueryParameters(getEntity().getId());
    tempVar.setRefresh(getIsQueryFirstTime());
    Frontend.getInstance().runQuery(VdcQueryType.GetVmsByStorageDomain, tempVar, _asyncQuery);
  }