问:
error: incompatible types: <null> cannot be converted to int if (!_cursor.isNull(null)) using android room
I'm using room for my android database. here i have a many to many relationship between Customer and ServiceProvider class i used this tutorial to do it but after compiling i received this error:

/home/omid/IntelliJIDEAProjects/Accounting/app/build/generated/ap_generated_sources/debug/out/com/omidmsl/accounting/db/CustomerDAO_Impl.java:69: error: incompatible types:  cannot be converted to int
            if (!_cursor.isNull(null)) {

and it is mentioning to this code CustomerDAO_Impl.java (compiler created this):

```<code>package com.omidmsl.accounting.db;

import android.database.Cursor;
import androidx.collection.ArrayMap;
import androidx.room.RoomDatabase;
import androidx.room.RoomSQLiteQuery;
import androidx.room.util.CursorUtil;
import androidx.room.util.DBUtil;
import androidx.room.util.StringUtil;
import com.omidmsl.accounting.models.Business;
import com.omidmsl.accounting.models.Customer;
import com.omidmsl.accounting.models.serviceprovider.CustomerOfServiceProvider;
import java.lang.Override;
import java.lang.String;
import java.lang.StringBuilder;
import java.lang.SuppressWarnings;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;

@SuppressWarnings({"unchecked", "deprecation"})
public final class CustomerDAO_Impl implements CustomerDAO {
  private final RoomDatabase __db;

  public CustomerDAO_Impl(RoomDatabase __db) {
    this.__db = __db;
  }

  @Override
  public List<Customer> getCustomers() {
    final String _sql = "SELECT * FROM Customer";
    final RoomSQLiteQuery _statement = RoomSQLiteQuery.acquire(_sql, 0);
    __db.assertNotSuspendingTransaction();
    final Cursor _cursor = DBUtil.query(__db, _statement, false, null);
    try {
      final int _cursorIndexOfCustomerName = CursorUtil.getColumnIndexOrThrow(_cursor, "customerName");
      final int _cursorIndexOfPhoneNumber = CursorUtil.getColumnIndexOrThrow(_cursor, "phoneNumber");
      final List<Customer> _result = new ArrayList<Customer>(_cursor.getCount());
      while(_cursor.moveToNext()) {
        final Customer _item;
        _item = new Customer();
        final String _tmpCustomerName;
        _tmpCustomerName = _cursor.getString(_cursorIndexOfCustomerName);
        _item.setCustomerName(_tmpCustomerName);
        final String _tmpPhoneNumber;
        _tmpPhoneNumber = _cursor.getString(_cursorIndexOfPhoneNumber);
        _item.setPhoneNumber(_tmpPhoneNumber);
        _result.add(_item);
      }
      return _result;
    } finally {
      _cursor.close();
      _statement.release();
    }
  }

  @Override
  public List<CustomerOfServiceProvider> getCustomersOfServiceProvider() {
    final String _sql = "SELECT * FROM Customer";
    final RoomSQLiteQuery _statement = RoomSQLiteQuery.acquire(_sql, 0);
    __db.assertNotSuspendingTransaction();
    __db.beginTransaction();
    try {
      final Cursor _cursor = DBUtil.query(__db, _statement, true, null);
      try {
        final int _cursorIndexOfPhoneNumber = CursorUtil.getColumnIndexOrThrow(_cursor, "phoneNumber");
        final ArrayMap<String, ArrayList<Customer>> _collectionCustomers = new ArrayMap<String, ArrayList<Customer>>();
        while (_cursor.moveToNext()) {
          if (!_cursor.isNull(null)) {
            final String _tmpKey = _cursor.getString(null);
            ArrayList<Customer> _tmpCustomersCollection = _collectionCustomers.get(_tmpKey);
            if (_tmpCustomersCollection == null) {
              _tmpCustomersCollection = new ArrayList<Customer>();
              _collectionCustomers.put(_tmpKey, _tmpCustomersCollection);
            }
          }
        }
        _cursor.moveToPosition(-1);
        __fetchRelationshipCustomerAscomOmidmslAccountingModelsCustomer(_collectionCustomers);
        final List<CustomerOfServiceProvider> _result = new ArrayList<CustomerOfServiceProvider>(_cursor.getCount());
        while(_cursor.moveToNext()) {
          final CustomerOfServiceProvider _item;
          final Business _tmpServiceProvider;
          if (! (_cursor.isNull(_cursorIndexOfPhoneNumber))) {
            _tmpServiceProvider = new Business();
            final String _tmpPhoneNumber;
            _tmpPhoneNumber = _cursor.getString(_cursorIndexOfPhoneNumber);
            _tmpServiceProvider.setPhoneNumber(_tmpPhoneNumber);
          }  else  {
            _tmpServiceProvider = null;
          }
          ArrayList<Customer> _tmpCustomersCollection_1 = null;
          if (!_cursor.isNull(null)) {
            final String _tmpKey_1 = _cursor.getString(null);
            _tmpCustomersCollection_1 = _collectionCustomers.get(_tmpKey_1);
          }
          if (_tmpCustomersCollection_1 == null) {
            _tmpCustomersCollection_1 = new ArrayList<Customer>();
          }
          _item = new CustomerOfServiceProvider();
          _item.setServiceProvider(_tmpServiceProvider);
          _item.setCustomers(_tmpCustomersCollection_1);
          _result.add(_item);
        }
        __db.setTransactionSuccessful();
        return _result;
      } finally {
        _cursor.close();
        _statement.release();
      }
    } finally {
      __db.endTransaction();
    }
  }

  @Override
  public List<Customer> getCustomer(final String cName) {
    final String _sql = "SELECT * FROM Customer WHERE customerName = ?";
    final RoomSQLiteQuery _statement = RoomSQLiteQuery.acquire(_sql, 1);
    int _argIndex = 1;
    if (cName == null) {
      _statement.bindNull(_argIndex);
    } else {
      _statement.bindString(_argIndex, cName);
    }
    __db.assertNotSuspendingTransaction();
    final Cursor _cursor = DBUtil.query(__db, _statement, false, null);
    try {
      final int _cursorIndexOfCustomerName = CursorUtil.getColumnIndexOrThrow(_cursor, "customerName");
      final int _cursorIndexOfPhoneNumber = CursorUtil.getColumnIndexOrThrow(_cursor, "phoneNumber");
      final List<Customer> _result = new ArrayList<Customer>(_cursor.getCount());
      while(_cursor.moveToNext()) {
        final Customer _item;
        _item = new Customer();
        final String _tmpCustomerName;
        _tmpCustomerName = _cursor.getString(_cursorIndexOfCustomerName);
        _item.setCustomerName(_tmpCustomerName);
        final String _tmpPhoneNumber;
        _tmpPhoneNumber = _cursor.getString(_cursorIndexOfPhoneNumber);
        _item.setPhoneNumber(_tmpPhoneNumber);
        _result.add(_item);
      }
      return _result;
    } finally {
      _cursor.close();
      _statement.release();
    }
  }

  private void __fetchRelationshipCustomerAscomOmidmslAccountingModelsCustomer(final ArrayMap<String, ArrayList<Customer>> _map) {
    final Set<String> __mapKeySet = _map.keySet();
    if (__mapKeySet.isEmpty()) {
      return;
    }
    // check if the size is too big, if so divide;
    if(_map.size() > RoomDatabase.MAX_BIND_PARAMETER_CNT) {
      ArrayMap<String, ArrayList<Customer>> _tmpInnerMap = new ArrayMap<String, ArrayList<Customer>>(androidx.room.RoomDatabase.MAX_BIND_PARAMETER_CNT);
      int _tmpIndex = 0;
      int _mapIndex = 0;
      final int _limit = _map.size();
      while(_mapIndex < _limit) {
        _tmpInnerMap.put(_map.keyAt(_mapIndex), _map.valueAt(_mapIndex));
        _mapIndex++;
        _tmpIndex++;
        if(_tmpIndex == RoomDatabase.MAX_BIND_PARAMETER_CNT) {
          __fetchRelationshipCustomerAscomOmidmslAccountingModelsCustomer(_tmpInnerMap);
          _tmpInnerMap = new ArrayMap<String, ArrayList<Customer>>(RoomDatabase.MAX_BIND_PARAMETER_CNT);
          _tmpIndex = 0;
        }
      }
      if(_tmpIndex > 0) {
        __fetchRelationshipCustomerAscomOmidmslAccountingModelsCustomer(_tmpInnerMap);
      }
      return;
    }
    StringBuilder _stringBuilder = StringUtil.newStringBuilder();
    _stringBuilder.append("SELECT `Customer`.`customerName` AS `customerName`,`Customer`.`phoneNumber` AS `phoneNumber`,_junction.`businessName` FROM `Service` AS _junction INNER JOIN `Customer` ON (_junction.`customerName` = `Customer`.`customerName`) WHERE _junction.`businessName` IN (");
    final int _inputSize = __mapKeySet.size();
    StringUtil.appendPlaceholders(_stringBuilder, _inputSize);
    _stringBuilder.append(")");
    final String _sql = _stringBuilder.toString();
    final int _argCount = 0 + _inputSize;
    final RoomSQLiteQuery _stmt = RoomSQLiteQuery.acquire(_sql, _argCount);
    int _argIndex = 1;
    for (String _item : __mapKeySet) {
      if (_item == null) {
        _stmt.bindNull(_argIndex);
      } else {
        _stmt.bindString(_argIndex, _item);
      }
      _argIndex ++;
    }
    final Cursor _cursor = DBUtil.query(__db, _stmt, false, null);
    try {
      final int _itemKeyIndex = 2; // _junction.businessName;
      if (_itemKeyIndex == -1) {
        return;
      }
      final int _cursorIndexOfCustomerName = CursorUtil.getColumnIndex(_cursor, "customerName");
      final int _cursorIndexOfPhoneNumber = CursorUtil.getColumnIndex(_cursor, "phoneNumber");
      while(_cursor.moveToNext()) {
        if (!_cursor.isNull(_itemKeyIndex)) {
          final String _tmpKey = _cursor.getString(_itemKeyIndex);
          ArrayList<Customer> _tmpRelation = _map.get(_tmpKey);
          if (_tmpRelation != null) {
            final Customer _item_1;
            _item_1 = new Customer();
            if (_cursorIndexOfCustomerName != -1) {
              final String _tmpCustomerName;
              _tmpCustomerName = _cursor.getString(_cursorIndexOfCustomerName);
              _item_1.setCustomerName(_tmpCustomerName);
            }
            if (_cursorIndexOfPhoneNumber != -1) {
              final String _tmpPhoneNumber;
              _tmpPhoneNumber = _cursor.getString(_cursorIndexOfPhoneNumber);
              _item_1.setPhoneNumber(_tmpPhoneNumber);
            }
            _tmpRelation.add(_item_1);
          }
        }
      }
    } finally {
      _cursor.close();
    }
  }
}

</code>```

and here is the rest of my codes:

Customer.java:

```<code>package com.omidmsl.accounting.models;

import androidx.annotation.NonNull;
import androidx.room.Entity;
import androidx.room.PrimaryKey;

@Entity(tableName = "Customer")
public class Customer {

    public static final String KEY_NAME = "customer_name";
    public static final String KEY_PHONE_NUMBER = "phone_number";

    @NonNull
    @PrimaryKey
    private String customerName;
    private String phoneNumber;

    public String getCustomerName() {
        return customerName;
    }

    public void setCustomerName(String customerName) {
        this.customerName = customerName;
    }

    public String getPhoneNumber() {
        return phoneNumber;
    }

    public void setPhoneNumber(String phoneNumber) {
        this.phoneNumber = phoneNumber;
    }
}
</code>```

CustomerDAO.java:

```<code>package com.omidmsl.accounting.db;

import androidx.room.Dao;
import androidx.room.Query;
import androidx.room.Transaction;
import com.omidmsl.accounting.models.Customer;
import com.omidmsl.accounting.models.serviceprovider.CustomerOfServiceProvider;

import java.util.List;

@Dao
public interface CustomerDAO {

    @Query("SELECT * FROM Customer")
    public List<Customer> getCustomers();

    @Transaction
    @Query("SELECT * FROM Customer")
    public List<CustomerOfServiceProvider> getCustomersOfServiceProvider();

    @Query("SELECT * FROM Customer WHERE customerName = :cName")
    public List<Customer> getCustomer(String cName);
}

</code>```

Business.java:

```<code>package com.omidmsl.accounting.models;

import androidx.annotation.NonNull;
import androidx.room.Entity;
import androidx.room.*;

@Entity(tableName = "Business")
public class Business {

    public static final String KEY_TYPE = "type";
    public static final String KEY_NAME = "business_name";
    public static final String KEY_PHONE_NUMBER = "phone_number";

    private int type;
    @PrimaryKey
    @NonNull
    private String businessName;
    private String phoneNumber;
    @Ignore
    private long costs;
    @Ignore
    private long buys;

    public Business(int type) {
        this.type = type;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public Business() {
        businessName = "";
    }

    public String getBusinessName() {
        return businessName;
    }

    public void setBusinessName(String businessName) {
        this.businessName = businessName;
    }

    public String getPhoneNumber() {
        return phoneNumber;
    }

    public void setPhoneNumber(String phoneNumber) {
        this.phoneNumber = phoneNumber;
    }

    public long getCosts() {
        return costs;
    }

    public void setCosts(long costs) {
        this.costs = costs;
    }

    public long getBuys() {
        return buys;
    }

    public void setBuys(long buys) {
        this.buys = buys;
    }
}

</code>```

ServiceProviderDAO.java:

```<code>package com.omidmsl.accounting.db;

import androidx.room.Dao;
import androidx.room.Query;
import androidx.room.Transaction;
import com.omidmsl.accounting.models.serviceprovider.ServiceProviderOfCustomer;

import java.util.List;

@Dao
public interface ServiceProviderDAO {
    @Transaction
    @Query("SELECT * FROM Business")
    public List<ServiceProviderOfCustomer> getServiceProvidersOfCustomer();
}
</code>```

CustomersOfServiceProvider.java:

```<code>package com.omidmsl.accounting.models.serviceprovider;

import androidx.room.*;
import com.omidmsl.accounting.models.Business;
import com.omidmsl.accounting.models.Customer;

import java.util.List;

public class CustomerOfServiceProvider {
    @Embedded
    private Business serviceProvider;
    @Relation(
            parentColumn = "businessName",
            entityColumn = "customerName",
            associateBy = @Junction(Service.class)
    )
    private List<Customer> customers;

    public Business getServiceProvider() {
        return serviceProvider;
    }

    public void setServiceProvider(Business serviceProvider) {
        this.serviceProvider = serviceProvider;
    }

    public List<Customer> getCustomers() {
        return customers;
    }

    public void setCustomers(List<Customer> customers) {
        this.customers = customers;
    }
}
</code>```

please help me

答:
thank you @ianhanniballake. problem solved!.

in CustomerDAO file i found this problem:

```<code>@Transaction
    @Query("SELECT * FROM Customer")
    public List<CustomerOfServiceProvider> getCustomersOfServiceProvider();
</code>```

type of this list must be ServiceProvidersOfCustomer:

```<code>@Transaction
    @Query("SELECT * FROM Customer")
    public List<ServiceProviderOfCustomer> getServiceProvidersOfCustomer();
</code>```

Body:
I'm using room for my android database. here i have a many to many relationship between Customer and ServiceProvider class i used this tutorial to do it but after compiling i received this error:

/home/omid/IntelliJIDEAProjects/Accounting/app/build/generated/ap_generated_sources/debug/out/com/omidmsl/accounting/db/CustomerDAO_Impl.java:69: error: incompatible types:  cannot be converted to int
            if (!_cursor.isNull(null)) {

and it is mentioning to this code CustomerDAO_Impl.java (compiler created this):

package com.omidmsl.accounting.db;

import android.database.Cursor;
import androidx.collection.ArrayMap;
import androidx.room.RoomDatabase;
import androidx.room.RoomSQLiteQuery;
import androidx.room.util.CursorUtil;
import androidx.room.util.DBUtil;
import androidx.room.util.StringUtil;
import com.omidmsl.accounting.models.Business;
import com.omidmsl.accounting.models.Customer;
import com.omidmsl.accounting.models.serviceprovider.CustomerOfServiceProvider;
import java.lang.Override;
import java.lang.String;
import java.lang.StringBuilder;
import java.lang.SuppressWarnings;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;

@SuppressWarnings({"unchecked", "deprecation"})
public final class CustomerDAO_Impl implements CustomerDAO {
  private final RoomDatabase __db;

  public CustomerDAO_Impl(RoomDatabase __db) {
    this.__db = __db;
  }

  @Override
  public List<Customer> getCustomers() {
    final String _sql = "SELECT * FROM Customer";
    final RoomSQLiteQuery _statement = RoomSQLiteQuery.acquire(_sql, 0);
    __db.assertNotSuspendingTransaction();
    final Cursor _cursor = DBUtil.query(__db, _statement, false, null);
    try {
      final int _cursorIndexOfCustomerName = CursorUtil.getColumnIndexOrThrow(_cursor, "customerName");
      final int _cursorIndexOfPhoneNumber = CursorUtil.getColumnIndexOrThrow(_cursor, "phoneNumber");
      final List<Customer> _result = new ArrayList<Customer>(_cursor.getCount());
      while(_cursor.moveToNext()) {
        final Customer _item;
        _item = new Customer();
        final String _tmpCustomerName;
        _tmpCustomerName = _cursor.getString(_cursorIndexOfCustomerName);
        _item.setCustomerName(_tmpCustomerName);
        final String _tmpPhoneNumber;
        _tmpPhoneNumber = _cursor.getString(_cursorIndexOfPhoneNumber);
        _item.setPhoneNumber(_tmpPhoneNumber);
        _result.add(_item);
      }
      return _result;
    } finally {
      _cursor.close();
      _statement.release();
    }
  }

  @Override
  public List<CustomerOfServiceProvider> getCustomersOfServiceProvider() {
    final String _sql = "SELECT * FROM Customer";
    final RoomSQLiteQuery _statement = RoomSQLiteQuery.acquire(_sql, 0);
    __db.assertNotSuspendingTransaction();
    __db.beginTransaction();
    try {
      final Cursor _cursor = DBUtil.query(__db, _statement, true, null);
      try {
        final int _cursorIndexOfPhoneNumber = CursorUtil.getColumnIndexOrThrow(_cursor, "phoneNumber");
        final ArrayMap<String, ArrayList<Customer>> _collectionCustomers = new ArrayMap<String, ArrayList<Customer>>();
        while (_cursor.moveToNext()) {
          if (!_cursor.isNull(null)) {
            final String _tmpKey = _cursor.getString(null);
            ArrayList<Customer> _tmpCustomersCollection = _collectionCustomers.get(_tmpKey);
            if (_tmpCustomersCollection == null) {
              _tmpCustomersCollection = new ArrayList<Customer>();
              _collectionCustomers.put(_tmpKey, _tmpCustomersCollection);
            }
          }
        }
        _cursor.moveToPosition(-1);
        __fetchRelationshipCustomerAscomOmidmslAccountingModelsCustomer(_collectionCustomers);
        final List<CustomerOfServiceProvider> _result = new ArrayList<CustomerOfServiceProvider>(_cursor.getCount());
        while(_cursor.moveToNext()) {
          final CustomerOfServiceProvider _item;
          final Business _tmpServiceProvider;
          if (! (_cursor.isNull(_cursorIndexOfPhoneNumber))) {
            _tmpServiceProvider = new Business();
            final String _tmpPhoneNumber;
            _tmpPhoneNumber = _cursor.getString(_cursorIndexOfPhoneNumber);
            _tmpServiceProvider.setPhoneNumber(_tmpPhoneNumber);
          }  else  {
            _tmpServiceProvider = null;
          }
          ArrayList<Customer> _tmpCustomersCollection_1 = null;
          if (!_cursor.isNull(null)) {
            final String _tmpKey_1 = _cursor.getString(null);
            _tmpCustomersCollection_1 = _collectionCustomers.get(_tmpKey_1);
          }
          if (_tmpCustomersCollection_1 == null) {
            _tmpCustomersCollection_1 = new ArrayList<Customer>();
          }
          _item = new CustomerOfServiceProvider();
          _item.setServiceProvider(_tmpServiceProvider);
          _item.setCustomers(_tmpCustomersCollection_1);
          _result.add(_item);
        }
        __db.setTransactionSuccessful();
        return _result;
      } finally {
        _cursor.close();
        _statement.release();
      }
    } finally {
      __db.endTransaction();
    }
  }

  @Override
  public List<Customer> getCustomer(final String cName) {
    final String _sql = "SELECT * FROM Customer WHERE customerName = ?";
    final RoomSQLiteQuery _statement = RoomSQLiteQuery.acquire(_sql, 1);
    int _argIndex = 1;
    if (cName == null) {
      _statement.bindNull(_argIndex);
    } else {
      _statement.bindString(_argIndex, cName);
    }
    __db.assertNotSuspendingTransaction();
    final Cursor _cursor = DBUtil.query(__db, _statement, false, null);
    try {
      final int _cursorIndexOfCustomerName = CursorUtil.getColumnIndexOrThrow(_cursor, "customerName");
      final int _cursorIndexOfPhoneNumber = CursorUtil.getColumnIndexOrThrow(_cursor, "phoneNumber");
      final List<Customer> _result = new ArrayList<Customer>(_cursor.getCount());
      while(_cursor.moveToNext()) {
        final Customer _item;
        _item = new Customer();
        final String _tmpCustomerName;
        _tmpCustomerName = _cursor.getString(_cursorIndexOfCustomerName);
        _item.setCustomerName(_tmpCustomerName);
        final String _tmpPhoneNumber;
        _tmpPhoneNumber = _cursor.getString(_cursorIndexOfPhoneNumber);
        _item.setPhoneNumber(_tmpPhoneNumber);
        _result.add(_item);
      }
      return _result;
    } finally {
      _cursor.close();
      _statement.release();
    }
  }

  private void __fetchRelationshipCustomerAscomOmidmslAccountingModelsCustomer(final ArrayMap<String, ArrayList<Customer>> _map) {
    final Set<String> __mapKeySet = _map.keySet();
    if (__mapKeySet.isEmpty()) {
      return;
    }
    // check if the size is too big, if so divide;
    if(_map.size() > RoomDatabase.MAX_BIND_PARAMETER_CNT) {
      ArrayMap<String, ArrayList<Customer>> _tmpInnerMap = new ArrayMap<String, ArrayList<Customer>>(androidx.room.RoomDatabase.MAX_BIND_PARAMETER_CNT);
      int _tmpIndex = 0;
      int _mapIndex = 0;
      final int _limit = _map.size();
      while(_mapIndex < _limit) {
        _tmpInnerMap.put(_map.keyAt(_mapIndex), _map.valueAt(_mapIndex));
        _mapIndex++;
        _tmpIndex++;
        if(_tmpIndex == RoomDatabase.MAX_BIND_PARAMETER_CNT) {
          __fetchRelationshipCustomerAscomOmidmslAccountingModelsCustomer(_tmpInnerMap);
          _tmpInnerMap = new ArrayMap<String, ArrayList<Customer>>(RoomDatabase.MAX_BIND_PARAMETER_CNT);
          _tmpIndex = 0;
        }
      }
      if(_tmpIndex > 0) {
        __fetchRelationshipCustomerAscomOmidmslAccountingModelsCustomer(_tmpInnerMap);
      }
      return;
    }
    StringBuilder _stringBuilder = StringUtil.newStringBuilder();
    _stringBuilder.append("SELECT `Customer`.`customerName` AS `customerName`,`Customer`.`phoneNumber` AS `phoneNumber`,_junction.`businessName` FROM `Service` AS _junction INNER JOIN `Customer` ON (_junction.`customerName` = `Customer`.`customerName`) WHERE _junction.`businessName` IN (");
    final int _inputSize = __mapKeySet.size();
    StringUtil.appendPlaceholders(_stringBuilder, _inputSize);
    _stringBuilder.append(")");
    final String _sql = _stringBuilder.toString();
    final int _argCount = 0 + _inputSize;
    final RoomSQLiteQuery _stmt = RoomSQLiteQuery.acquire(_sql, _argCount);
    int _argIndex = 1;
    for (String _item : __mapKeySet) {
      if (_item == null) {
        _stmt.bindNull(_argIndex);
      } else {
        _stmt.bindString(_argIndex, _item);
      }
      _argIndex ++;
    }
    final Cursor _cursor = DBUtil.query(__db, _stmt, false, null);
    try {
      final int _itemKeyIndex = 2; // _junction.businessName;
      if (_itemKeyIndex == -1) {
        return;
      }
      final int _cursorIndexOfCustomerName = CursorUtil.getColumnIndex(_cursor, "customerName");
      final int _cursorIndexOfPhoneNumber = CursorUtil.getColumnIndex(_cursor, "phoneNumber");
      while(_cursor.moveToNext()) {
        if (!_cursor.isNull(_itemKeyIndex)) {
          final String _tmpKey = _cursor.getString(_itemKeyIndex);
          ArrayList<Customer> _tmpRelation = _map.get(_tmpKey);
          if (_tmpRelation != null) {
            final Customer _item_1;
            _item_1 = new Customer();
            if (_cursorIndexOfCustomerName != -1) {
              final String _tmpCustomerName;
              _tmpCustomerName = _cursor.getString(_cursorIndexOfCustomerName);
              _item_1.setCustomerName(_tmpCustomerName);
            }
            if (_cursorIndexOfPhoneNumber != -1) {
              final String _tmpPhoneNumber;
              _tmpPhoneNumber = _cursor.getString(_cursorIndexOfPhoneNumber);
              _item_1.setPhoneNumber(_tmpPhoneNumber);
            }
            _tmpRelation.add(_item_1);
          }
        }
      }
    } finally {
      _cursor.close();
    }
  }
}

and here is the rest of my codes:

Customer.java:

package com.omidmsl.accounting.models;

import androidx.annotation.NonNull;
import androidx.room.Entity;
import androidx.room.PrimaryKey;

@Entity(tableName = "Customer")
public class Customer {

    public static final String KEY_NAME = "customer_name";
    public static final String KEY_PHONE_NUMBER = "phone_number";

    @NonNull
    @PrimaryKey
    private String customerName;
    private String phoneNumber;

    public String getCustomerName() {
        return customerName;
    }

    public void setCustomerName(String customerName) {
        this.customerName = customerName;
    }

    public String getPhoneNumber() {
        return phoneNumber;
    }

    public void setPhoneNumber(String phoneNumber) {
        this.phoneNumber = phoneNumber;
    }
}

CustomerDAO.java:

package com.omidmsl.accounting.db;

import androidx.room.Dao;
import androidx.room.Query;
import androidx.room.Transaction;
import com.omidmsl.accounting.models.Customer;
import com.omidmsl.accounting.models.serviceprovider.CustomerOfServiceProvider;

import java.util.List;

@Dao
public interface CustomerDAO {

    @Query("SELECT * FROM Customer")
    public List<Customer> getCustomers();

    @Transaction
    @Query("SELECT * FROM Customer")
    public List<CustomerOfServiceProvider> getCustomersOfServiceProvider();

    @Query("SELECT * FROM Customer WHERE customerName = :cName")
    public List<Customer> getCustomer(String cName);
}

Business.java:

package com.omidmsl.accounting.models;

import androidx.annotation.NonNull;
import androidx.room.Entity;
import androidx.room.*;

@Entity(tableName = "Business")
public class Business {

    public static final String KEY_TYPE = "type";
    public static final String KEY_NAME = "business_name";
    public static final String KEY_PHONE_NUMBER = "phone_number";

    private int type;
    @PrimaryKey
    @NonNull
    private String businessName;
    private String phoneNumber;
    @Ignore
    private long costs;
    @Ignore
    private long buys;

    public Business(int type) {
        this.type = type;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public Business() {
        businessName = "";
    }

    public String getBusinessName() {
        return businessName;
    }

    public void setBusinessName(String businessName) {
        this.businessName = businessName;
    }

    public String getPhoneNumber() {
        return phoneNumber;
    }

    public void setPhoneNumber(String phoneNumber) {
        this.phoneNumber = phoneNumber;
    }

    public long getCosts() {
        return costs;
    }

    public void setCosts(long costs) {
        this.costs = costs;
    }

    public long getBuys() {
        return buys;
    }

    public void setBuys(long buys) {
        this.buys = buys;
    }
}

ServiceProviderDAO.java:

package com.omidmsl.accounting.db;

import androidx.room.Dao;
import androidx.room.Query;
import androidx.room.Transaction;
import com.omidmsl.accounting.models.serviceprovider.ServiceProviderOfCustomer;

import java.util.List;

@Dao
public interface ServiceProviderDAO {
    @Transaction
    @Query("SELECT * FROM Business")
    public List<ServiceProviderOfCustomer> getServiceProvidersOfCustomer();
}

CustomersOfServiceProvider.java:

package com.omidmsl.accounting.models.serviceprovider;

import androidx.room.*;
import com.omidmsl.accounting.models.Business;
import com.omidmsl.accounting.models.Customer;

import java.util.List;

public class CustomerOfServiceProvider {
    @Embedded
    private Business serviceProvider;
    @Relation(
            parentColumn = "businessName",
            entityColumn = "customerName",
            associateBy = @Junction(Service.class)
    )
    private List<Customer> customers;

    public Business getServiceProvider() {
        return serviceProvider;
    }

    public void setServiceProvider(Business serviceProvider) {
        this.serviceProvider = serviceProvider;
    }

    public List<Customer> getCustomers() {
        return customers;
    }

    public void setCustomers(List<Customer> customers) {
        this.customers = customers;
    }
}

please help me

Body:
thank you @ianhanniballake. problem solved!.

in CustomerDAO file i found this problem:

@Transaction
    @Query("SELECT * FROM Customer")
    public List<CustomerOfServiceProvider> getCustomersOfServiceProvider();

type of this list must be ServiceProvidersOfCustomer:

@Transaction
    @Query("SELECT * FROM Customer")
    public List<ServiceProviderOfCustomer> getServiceProvidersOfCustomer();


来源: stackexchange

问:
use grep or awk to split a column into multiple columns with the headers in the original file headers
I have the following output

```<code>SRR51XXXX
5
6
7
SRR51XXYY
8
9
1
2
</code>```

and so on..

SO each header file begins with SRR51 and then with unique 4 digit numbers.I want to turn this single column output into separate columns
such as

```<code>SRR513XXXX            SRR513XXXY
5                        8
6                        9
7                        1
</code>```

Fig to show the data

答:
```<code>awk '/^SRR/{r=1;c++}{a[r++,c]=$1}END{while(r>i++){while(c>j++){printf "%s\t", a[i,j]}printf "\n";j=0}}' /path/to/my/file.txt
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I have the following output

SRR51XXXX
5
6
7
SRR51XXYY
8
9
1
2

and so on..

SO each header file begins with SRR51 and then with unique 4 digit numbers.I want to turn this single column output into separate columns
such as

SRR513XXXX            SRR513XXXY
5                        8
6                        9
7                        1

Fig to show the data


问:
Vue.js random color appended to user list everytime page is (re)loaded
I have some jQuery code I want to convert to Vue.js. Basically, everytime I (re)load the page, a random color is given to each user of a list and its different everytime.

Here is the jQuery code:

```<code>//RANDOM USER COLOR
    $(".usersElements").each(function(index) {
    var idUser = $(this).attr("id");
        if ($.inArray(idUser, usersColors) == -1) {
            var letters = '0123456789ABCDEF';
            var color = '#';
            for (var i = 0; i < 6; i++) {
            color += letters[Math.floor(Math.random() * 16)];
        }
        usersColors.push(idUser);
        colors.push(color);
        $(this).find(".colorsByUser").css("background-color", color);
        } else {
            var index = usersColors.indexOf(idUser);
            $(this).find(".colorsByUser").css("background-color", colors[index]);
        }
    });
</code>```

I forgot to mention and this might be important. The list of users is dynamic and called with PHP.
Here is the HTML:

```<code>                <div class="col-md-12">
                   <div id="users" name="users">
                   <!--- section to display the list of users starts -->
                        <?php   if(!empty($user))
                        {
                            foreach($user as $value)
                            {
                            ?>
                                <div class="row oddEven usersElements userid" id=<?php echo $value->id;?> style="margin-top: -1vw;">
                                    <div v-on:click="displayAgregators(<?php echo $value->id;?>)" class="col-md-10">
                                        <span id="items<?php echo $value->id;?>"><?php echo ucfirst($value->username);?></span>
                                    </div>
                                    <div class="col-md-2">
                                        <div class="colorsByUser"></div>
                                    </div>
                                </div>
                            <?php }
                        }?>
                    </div>
                </div>
</code>```

I have searched for different solutions, but nothing directly related to the problem.
Hope you guys can help!

答:
You can use Vue custom directive</p>

```<code><div v-colors>

</div>
</code>```

```<code> directives: {
    colors: {
      inserted(el) {
//the current dom element

        el.style.backgroundColor = `#${(
          (Math.random() * 0xffffff) <<
          0
        ).toString(16)}`;
      //  console.log(((Math.random() * 0xffffff) << 0).toString(16));
      }
    }
  }
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I have some jQuery code I want to convert to Vue.js. Basically, everytime I (re)load the page, a random color is given to each user of a list and its different everytime.

Here is the jQuery code:

//RANDOM USER COLOR
    $(".usersElements").each(function(index) {
    var idUser = $(this).attr("id");
        if ($.inArray(idUser, usersColors) == -1) {
            var letters = '0123456789ABCDEF';
            var color = '#';
            for (var i = 0; i < 6; i++) {
            color += letters[Math.floor(Math.random() * 16)];
        }
        usersColors.push(idUser);
        colors.push(color);
        $(this).find(".colorsByUser").css("background-color", color);
        } else {
            var index = usersColors.indexOf(idUser);
            $(this).find(".colorsByUser").css("background-color", colors[index]);
        }
    });

I forgot to mention and this might be important. The list of users is dynamic and called with PHP.
Here is the HTML:

                        <?php   if(!empty($user))
                        {
                            foreach($user as $value)
                            {
                            ?>
                                <div class="row oddEven usersElements userid" id=<?php echo $value->id;?> style="margin-top: -1vw;">
                                    <div v-on:click="displayAgregators(<?php echo $value->id;?>)" class="col-md-10">
                                        <span id="items<?php echo $value->id;?>"><?php echo ucfirst($value->username);?>

                            <?php }
                        }?>

I have searched for different solutions, but nothing directly related to the problem.
Hope you guys can help!

Body:
You can use Vue custom directive

<div v-colors>

</div>

 directives: {
    colors: {
      inserted(el) {
//the current dom element

        el.style.backgroundColor = `#${(
          (Math.random() * 0xffffff) <<
          0
        ).toString(16)}`;
      //  console.log(((Math.random() * 0xffffff) << 0).toString(16));
      }
    }
  }


问:
argv listing directory files
this very simple code is driving me nuts.

```<code>import sys,string,socket

maquina = sys.argv[1]
texto = string.join(sys.argv[2:], " ")
print '['+maquina+']'
print '['+texto+']'

mysock = socket.socket( socket.AF_INET, socket.SOCK_DGRAM )
if  maquina == '*':
    for ip in range(18,254):
        mysock.sendto( texto, ('192.168.0.'+str(ip),8090) )
else:
    mysock.sendto( texto, (maquina,8090))
mysock.close()
</code>```

When I type

```<code>python send.py 192.168.0.135 several strings
</code>```

the output is:

```<code>[192.168.0.135]
[several strings]
</code>```

But if I type

```<code>python send.py * several strings
</code>```

I got:

```<code>[ajax]
[ajustaprofile.py build dia2django.py djangoajax django-cube django-evolution django_excel_templates-0.1 Doc google_appengine httpd.conf imagens jre1.5.0_08 lib list_mailbackup.py luma models.py netsend.py pip-log.txt reverse.py share testparamet.py tnsnames.ora util virttool-0.1 xlrd-0.7.1 xlutils-1.4.1 xlwt-0.7.2 several lines]
</code>```

This is the file list that I have on current directory!
Python translates somehow '*' to the files of current directory.

I tried to do the homework using this link but I got no clue.

http://docs.python.org/library/sys.html
http://www.faqs.org/docs/diveintopython/kgp_commandline.html

How can I use "*" on argv ?

答: Try using '*' instead of *. Your shell feeds results of * to the program via cmdline args, just like ls *.

Title: argv listing directory files

Body:
this very simple code is driving me nuts.

import sys,string,socket

maquina = sys.argv[1]
texto = string.join(sys.argv[2:], " ")
print '['+maquina+']'
print '['+texto+']'

mysock = socket.socket( socket.AF_INET, socket.SOCK_DGRAM )
if  maquina == '*':
    for ip in range(18,254):
        mysock.sendto( texto, ('192.168.0.'+str(ip),8090) )
else:
    mysock.sendto( texto, (maquina,8090))
mysock.close()

When I type

python send.py 192.168.0.135 several strings

the output is:

[192.168.0.135]
[several strings]

But if I type

python send.py * several strings

I got:

[ajax]
[ajustaprofile.py build dia2django.py djangoajax django-cube django-evolution django_excel_templates-0.1 Doc google_appengine httpd.conf imagens jre1.5.0_08 lib list_mailbackup.py luma models.py netsend.py pip-log.txt reverse.py share testparamet.py tnsnames.ora util virttool-0.1 xlrd-0.7.1 xlutils-1.4.1 xlwt-0.7.2 several lines]

This is the file list that I have on current directory!
Python translates somehow '*' to the files of current directory.

I tried to do the homework using this link but I got no clue.

http://docs.python.org/library/sys.html
http://www.faqs.org/docs/diveintopython/kgp_commandline.html

How can I use "*" on argv ?


问:
Uploading AWS serverless application lambda - separately ? ( without ApiGateway settings)
With a normal Lambda function (in C#) I could publish the Function Handler alone to AWS.

But now I want to :

Create a serverless application (webapi .Net Core in C#)

upload it , and only then - attach it to an existing ApiGateway

For the demos I've seen, I must update the "Events" section in the serverless.template file which is in the solution. ( I might be wrong here).

But

What if I already have a complex ApiGateway which I've built before :

—And I only want to upload the serverless application?

I'm asking because I see that I must declare the ApiGateway also in here :

Question:

Is it possible to only upload the serverless application project ) (without any apigateway info) , and only then - attach it to an existing webapi (via aws console) , without also configuring the serverless.template file?

答: Sure. The events portion of the function is optional, so you can leave it out entirely. You can also deploy it without using the serverless transform, by using the AWS::Lambda::Function resource type, which may make more sense if you aren't using any of the transforms from SAM.


问:
How to accept space separated integers and store them in a vector in C++?
I tried to accept N spaced integers, store them in a vector and print them. This is my code:

```<code>#include <string>
#include <vector>

using namespace std;
int main() {
  string rawInput;
  vector<string> numbers;
  while( getline( cin, rawInput, ' ' ) )
  {
    numbers.push_back(rawInput);
  }
  for (int j = 0; j < sizeof(numbers)/sizeof(numbers[0]); ++j) {
    cout << numbers[j] << " ";
  }
}
</code>```

It doesn't work. I get no output after running this code.
Please give an example with floating point numbers and integers. Please tell me how to print them as well. Thank you.

答:
For space separated integers, don't use getline.  The newline counts as space when constructing integers.

Try something like this:

```<code>std::vector<int> database;
int number;
while (cin >> number)
{
    database.push_back(number);
}
</code>```

You may want ask yourself if there really is a need to read a line of integers (or if any kind of record is delineated by a newline).

Edit 1: Reading space separated integers by text line

If you must read by line, one method is to use std::istringstream:

```<code>std::vector<int> database;
std::string text_line;
while (getline(cin, text_line))
{
    int number;
    std::istringstream line_stream(text_line);
    while (line_stream >> number)
    {
        database.push_back(number);
    }
}
</code>```

IMHO, reading by line adds an unnecessary level of complexity.

Body:
I tried to accept N spaced integers, store them in a vector and print them. This is my code:

#include <string>
#include <vector>

using namespace std;
int main() {
  string rawInput;
  vector<string> numbers;
  while( getline( cin, rawInput, ' ' ) )
  {
    numbers.push_back(rawInput);
  }
  for (int j = 0; j < sizeof(numbers)/sizeof(numbers[0]); ++j) {
    cout << numbers[j] << " ";
  }
}

It doesn't work. I get no output after running this code.
Please give an example with floating point numbers and integers. Please tell me how to print them as well. Thank you.

Body:
For space separated integers, don't use getline.  The newline counts as space when constructing integers.

Try something like this:

std::vector<int> database;
int number;
while (cin >> number)
{
    database.push_back(number);
}

You may want ask yourself if there really is a need to read a line of integers (or if any kind of record is delineated by a newline).

Edit 1: Reading space separated integers by text line

If you must read by line, one method is to use std::istringstream:

std::vector<int> database;
std::string text_line;
while (getline(cin, text_line))
{
    int number;
    std::istringstream line_stream(text_line);
    while (line_stream >> number)
    {
        database.push_back(number);
    }
}

IMHO, reading by line adds an unnecessary level of complexity.


问:
Perform basic arithmetic operations on AudioKit FM oscillator parameters: Interpolation & time Transition
Does AudioKit provide a method to calculate interpolated values of discrete array members?
Does AudioKit provide a method to smooth transition operation between parameters of an oscillator like baseFrequency, AKOperation.periodicTrigger or hold?

Below the code I use for FM generation:

```<code>let oscillator = AKOperation.fmOscillator(baseFrequency: Synth.frequency,
                                                      carrierMultiplier: 2,
                                                      modulatingMultiplier: 0.8,
                                                      modulationIndex: 1,
                                                      amplitude: Synth.amplitude.triggeredWithEnvelope(
                                                        trigger: AKOperation.periodicTrigger(period: Synth.cyclic),
                                                        attack: 0.01,
                                                        hold: Synth.hold,
                                                        release: 0.01))
</code>```

For input parameter interpolated values of Frequency Cycle and Duty shall be calculated by interpolation based on the table (array) below:

```<code>P1      Freq.   Cycle   Duty %

-10     200     100     100

-3.04   405     100     100

-0.51   300     500     100

-0.50   200     800     5

0.09        400     600     10

0.10        400     600     50

1.16        550     552     52

2.67        763     483     55

4.24        985     412     58

6.00        1234    322     62

8.00        1517    241     66

10.00   1800    150     70
</code>```

The transition of values (for Freq., Cycle ans Duty) shall be smoothen based on input parameter P1. Is this what AKComputedParameter e.g. smoothDelay is made for?

How do I tell AudioKit to apply AKComputedParameter?

Do you have a sample code (code snippet) for achievement of interpolation/transition operation with application to oscillator based on the code above? Either based on AK or vDSP methods.

I’m not quiet sure on how to apply https://audiokit.io/docs/Protocols/AKComputedParameter.html

答:
I think this question was downvoted somewhat because it seems like you're asking for too much of an actual implementation with that table of values.  I'm going to ignore that and say that however you decide to change the parameters of the oscillator in your app logic, you can make the transitions smooth by portamento'ing the values.

So, in your case for frequency you would replace Synth.frequency with a parameter you set that you would then portamento like AKOperation.parameters[0].portamento(halfTime: 0.5)

See an example for using parameters here: https://audiokit.io/playgrounds/Synthesis/Plucked%20String%20Operation/

Body:
Does AudioKit provide a method to calculate interpolated values of discrete array members?
Does AudioKit provide a method to smooth transition operation between parameters of an oscillator like baseFrequency, AKOperation.periodicTrigger or hold?

Below the code I use for FM generation:

let oscillator = AKOperation.fmOscillator(baseFrequency: Synth.frequency,
                                                      carrierMultiplier: 2,
                                                      modulatingMultiplier: 0.8,
                                                      modulationIndex: 1,
                                                      amplitude: Synth.amplitude.triggeredWithEnvelope(
                                                        trigger: AKOperation.periodicTrigger(period: Synth.cyclic),
                                                        attack: 0.01,
                                                        hold: Synth.hold,
                                                        release: 0.01))

For input parameter interpolated values of Frequency Cycle and Duty shall be calculated by interpolation based on the table (array) below:

P1      Freq.   Cycle   Duty %

-10     200     100     100

-3.04   405     100     100

-0.51   300     500     100

-0.50   200     800     5

0.09        400     600     10

0.10        400     600     50

1.16        550     552     52

2.67        763     483     55

4.24        985     412     58

6.00        1234    322     62

8.00        1517    241     66

10.00   1800    150     70

The transition of values (for Freq., Cycle ans Duty) shall be smoothen based on input parameter P1. Is this what AKComputedParameter e.g. smoothDelay is made for?

How do I tell AudioKit to apply AKComputedParameter?

Do you have a sample code (code snippet) for achievement of interpolation/transition operation with application to oscillator based on the code above? Either based on AK or vDSP methods.

I’m not quiet sure on how to apply https://audiokit.io/docs/Protocols/AKComputedParameter.html


问:
Why do I get "NoSuchWindowError" error with "getWindowHandle" when it should return the current window handle?
In selenium 2 getWindowHandle says:

Schedules a command to retrieve they current window handle.

But when I try to do something with the handle returned from this it throws me the "NoSuchWindowError". How is this even possible? If is the current window it should not be closed. If is closed then the current window is another one. Right?

Using:

Webdriver for javascript/node.js;

ChromeDriver;

Update 2:

Seems like a bug. The window that closes is the facebook login.

Here is how to reproduce:

Go to some page that requests facebook login;

A facebook login popup window appears;

You login;

The facebook window closes;

Now if you try to get the current handle, then you get this error.

As asked:

I want to get the window title or similar, doesn't really matter, I just need the handle id.

Here is the full error stack, which is not that useful:

```<code>[8.572][SEVERE]: Unable to receive message from renderer
FF

(::) failed steps (::)

NoSuchWindowError: no such window: target window already closed
  at Object.Future.wait (c:\app\node_modules\fibers\future.js:398:15)
  at [object Object]._.extend.update (c:\app\tests\shared\Browser.js:183:62)
  at [object Object].<anonymous> (c:\app\tests\shared\Browser.js:138:18)
  at c:\app\node_modules\fibers\future.js:416:21

    - - - - -
from unknown error: web view not found
  (Session info: chrome=40.0.2214.111)
  (Driver info: chromedriver=2.9.248315,platform=Windows NT 6.1 SP1 x86)
    at new bot.Error (c:\app\node_modules\selenium-webdriver\lib\atoms\error.js:113:18)
    at Object.bot.response.checkResponse (c:\app\node_modules\selenium-webdriver\lib\atoms\response.js:106:9)
    at c:\app\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:362:20
    at c:\app\node_modules\selenium-webdriver\lib\goog\base.js:1582:15
    at [object Object].webdriver.promise.ControlFlow.runInNewFrame_ (c:\app\node_modules\selenium-webdriver\lib\webdriver\promise.js:1654:20)
    at notify (c:\app\node_modules\selenium-webdriver\lib\webdriver\promise.js:465:12)
    at notifyAll (c:\app\node_modules\selenium-webdriver\lib\webdriver\promise.js:442:7)
    at resolve (c:\app\node_modules\selenium-webdriver\lib\webdriver\promise.js:420:7)
    at [object Object].fulfill (c:\app\node_modules\selenium-webdriver\lib\webdriver\promise.js:535:5)
    at c:\app\node_modules\selenium-webdriver\lib\webdriver\promise.js:1520:10
    at c:\app\node_modules\selenium-webdriver\lib\goog\base.js:1582:15
    at [object Object].webdriver.promise.ControlFlow.runInNewFrame_ (c:\app\node_modules\selenium-webdriver\lib\webdriver\promise.js:1654:20)
    at notify (c:\app\node_modules\selenium-webdriver\lib\webdriver\promise.js:465:12)
    at notifyAll (c:\app\node_modules\selenium-webdriver\lib\webdriver\promise.js:442:7)
    at resolve (c:\app\node_modules\selenium-webdriver\lib\webdriver\promise.js:420:7)
    at fulfill (c:\app\node_modules\selenium-webdriver\lib\webdriver\promise.js:535:5)
    at c:\app\node_modules\selenium-webdriver\lib\goog\base.js:1582:15
    at [object Object].webdriver.promise.ControlFlow.runInNewFrame_ (c:\app\node_modules\selenium-webdriver\lib\webdriver\promise.js:1654:20)
    at notify (c:\app\node_modules\selenium-webdriver\lib\webdriver\promise.js:465:12)
    at notifyAll (c:\app\node_modules\selenium-webdriver\lib\webdriver\promise.js:442:7)
    at resolve (c:\app\node_modules\selenium-webdriver\lib\webdriver\promise.js:420:7)
    at [object Object].fulfill (c:\app\node_modules\selenium-webdriver\lib\webdriver\promise.js:535:5)
    at c:\app\node_modules\selenium-webdriver\lib\webdriver\promise.js:721:49
    at c:\app\node_modules\selenium-webdriver\lib\webdriver\http\http.js:96:5
    at IncomingMessage.<anonymous> (c:\app\node_modules\selenium-webdriver\http\index.js:131:7)
    at IncomingMessage.emit (events.js:117:20)
    at _stream_readable.js:943:16
    at process._tickDomainCallback (node.js:463:13)
==== async task ====
WebDriver.getWindowHandle()
    at [object Object].webdriver.WebDriver.schedule (c:\app\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:345:15)
    at [object Object].webdriver.WebDriver.getWindowHandle (c:\app\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:672:15)
    at [object Object].<anonymous> (c:\app\tests\shared\Browser.js:23:12)
    at [object Object].fn [as f_getWindowHandle] (c:\app\node_modules\fibers\future.js:89:26)
    at [object Object]._.extend.update (c:\app\tests\shared\Browser.js:183:42)
    at [object Object].<anonymous> (c:\app\tests\shared\Browser.js:138:18)
    at c:\app\node_modules\fibers\future.js:416:21
</code>```

答:
try

```<code>var webdriver = require('selenium-webdriver');
var driver = new webdriver.Builder().forBrowser('chrome').build();
</code>```

then you will see chrome is opened, DON'T CLOSE IT. then try

```<code>driver.get('http://www.google.com')
</code>```

Body:
In selenium 2 getWindowHandle says:

Schedules a command to retrieve they current window handle.

But when I try to do something with the handle returned from this it throws me the "NoSuchWindowError". How is this even possible? If is the current window it should not be closed. If is closed then the current window is another one. Right?

Using:

Webdriver for javascript/node.js;

ChromeDriver;

Update 2:

Seems like a bug. The window that closes is the facebook login.

Here is how to reproduce:

Go to some page that requests facebook login;

A facebook login popup window appears;

You login;

The facebook window closes;

Now if you try to get the current handle, then you get this error.

As asked:

I want to get the window title or similar, doesn't really matter, I just need the handle id.

Here is the full error stack, which is not that useful:

[8.572][SEVERE]: Unable to receive message from renderer
FF

(::) failed steps (::)

NoSuchWindowError: no such window: target window already closed
  at Object.Future.wait (c:\app\node_modules\fibers\future.js:398:15)
  at [object Object]._.extend.update (c:\app\tests\shared\Browser.js:183:62)
  at [object Object].<anonymous> (c:\app\tests\shared\Browser.js:138:18)
  at c:\app\node_modules\fibers\future.js:416:21

    - - - - -
from unknown error: web view not found
  (Session info: chrome=40.0.2214.111)
  (Driver info: chromedriver=2.9.248315,platform=Windows NT 6.1 SP1 x86)
    at new bot.Error (c:\app\node_modules\selenium-webdriver\lib\atoms\error.js:113:18)
    at Object.bot.response.checkResponse (c:\app\node_modules\selenium-webdriver\lib\atoms\response.js:106:9)
    at c:\app\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:362:20
    at c:\app\node_modules\selenium-webdriver\lib\goog\base.js:1582:15
    at [object Object].webdriver.promise.ControlFlow.runInNewFrame_ (c:\app\node_modules\selenium-webdriver\lib\webdriver\promise.js:1654:20)
    at notify (c:\app\node_modules\selenium-webdriver\lib\webdriver\promise.js:465:12)
    at notifyAll (c:\app\node_modules\selenium-webdriver\lib\webdriver\promise.js:442:7)
    at resolve (c:\app\node_modules\selenium-webdriver\lib\webdriver\promise.js:420:7)
    at [object Object].fulfill (c:\app\node_modules\selenium-webdriver\lib\webdriver\promise.js:535:5)
    at c:\app\node_modules\selenium-webdriver\lib\webdriver\promise.js:1520:10
    at c:\app\node_modules\selenium-webdriver\lib\goog\base.js:1582:15
    at [object Object].webdriver.promise.ControlFlow.runInNewFrame_ (c:\app\node_modules\selenium-webdriver\lib\webdriver\promise.js:1654:20)
    at notify (c:\app\node_modules\selenium-webdriver\lib\webdriver\promise.js:465:12)
    at notifyAll (c:\app\node_modules\selenium-webdriver\lib\webdriver\promise.js:442:7)
    at resolve (c:\app\node_modules\selenium-webdriver\lib\webdriver\promise.js:420:7)
    at fulfill (c:\app\node_modules\selenium-webdriver\lib\webdriver\promise.js:535:5)
    at c:\app\node_modules\selenium-webdriver\lib\goog\base.js:1582:15
    at [object Object].webdriver.promise.ControlFlow.runInNewFrame_ (c:\app\node_modules\selenium-webdriver\lib\webdriver\promise.js:1654:20)
    at notify (c:\app\node_modules\selenium-webdriver\lib\webdriver\promise.js:465:12)
    at notifyAll (c:\app\node_modules\selenium-webdriver\lib\webdriver\promise.js:442:7)
    at resolve (c:\app\node_modules\selenium-webdriver\lib\webdriver\promise.js:420:7)
    at [object Object].fulfill (c:\app\node_modules\selenium-webdriver\lib\webdriver\promise.js:535:5)
    at c:\app\node_modules\selenium-webdriver\lib\webdriver\promise.js:721:49
    at c:\app\node_modules\selenium-webdriver\lib\webdriver\http\http.js:96:5
    at IncomingMessage.<anonymous> (c:\app\node_modules\selenium-webdriver\http\index.js:131:7)
    at IncomingMessage.emit (events.js:117:20)
    at _stream_readable.js:943:16
    at process._tickDomainCallback (node.js:463:13)
==== async task ====
WebDriver.getWindowHandle()
    at [object Object].webdriver.WebDriver.schedule (c:\app\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:345:15)
    at [object Object].webdriver.WebDriver.getWindowHandle (c:\app\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:672:15)
    at [object Object].<anonymous> (c:\app\tests\shared\Browser.js:23:12)
    at [object Object].fn [as f_getWindowHandle] (c:\app\node_modules\fibers\future.js:89:26)
    at [object Object]._.extend.update (c:\app\tests\shared\Browser.js:183:42)
    at [object Object].<anonymous> (c:\app\tests\shared\Browser.js:138:18)
    at c:\app\node_modules\fibers\future.js:416:21

Body:
try

var webdriver = require('selenium-webdriver');
var driver = new webdriver.Builder().forBrowser('chrome').build();

then you will see chrome is opened, DON'T CLOSE IT. then try

driver.get('http://www.google.com')


问:
Renaming labels of a factor in R
I have census data of Male and Female populations organizaed by age group:

```<code>library(tidyverse)

url <- "https://www2.census.gov/programs-surveys/popest/datasets/2010-2018/counties/asrh/cc-est2018-alldata-54.csv"

if (!file.exists("./datafiles/cc-est2018-alldata-54.csv"))
  download.file(url, destfile = "./datafiles/cc-est2018-alldata-54.csv", mode = "wb")

popSample <- read.csv("./datafiles/cc-est2018-alldata-54.csv") %>%
  filter(AGEGRP != 0 & YEAR == 1) %>%
  select("STNAME", "CTYNAME", "AGEGRP", "TOT_POP", "TOT_MALE", "TOT_FEMALE")

popSample$AGEGRP <- as.factor(popSample$AGEGRP)
</code>```

I then plot the Male and Female population relationships, faceted by age group (1-18, which is currently treated as a int

```<code>g <- ggplot(popSample, aes(x=TOT_MALE, y=TOT_FEMALE)) +
  geom_point(alpha = 0.5, colour="darkblue") +
  scale_x_log10() +
  scale_y_log10() +
  facet_wrap(~AGEGRP) +
  stat_smooth(method = "lm", col = "darkred", size=.75) +
  labs(title = "F vs. M Population across all Age Groups", x = "Total Male (log10)", y = "Total Female (log10)") +
  theme_light()

g
</code>```

Which results in this plot: https://share.getcloudapp.com/v1ur6O4e

The problem: I am trying to convert the column AGEGRP from ‘int’ to ‘factor’, and change the factors labels from “1”, “2”, “3”, … “18” to "AgeGroup1", "AgeGroup2", "AgeGroup3", … "AgeGroup18"

When I try this code, my AGEGRP column's observation values are all replaced with NAs:popSample$AGEGRP <- factor(popSample$AGEGRP, levels = c("0 to 4", "5 to 9", "10 to 14", "15 to 19", "20 to 24", "25 to 29", "30 to 34", "35 to 39", "40 to 44", "45 to 49", "50 to 54", "55 to 59", "60 to 64", "65 to 69", "70 to 74", "75 to 79", "80 to 84", "85+"))

https://share.getcloudapp.com/qGuo1O4y

Thank you for your help,

答:
To change all the factor labels with one function, you can use forcats::fct_relabel (forcats ships as part of the tidyverse, which you've already got loaded). The changed factor labels will carry over to the plot facets and the order stays the same.

First few entries:

# before relabelling
popSample$AGEGRP[1:4]
#> [1] 1 2 3 4
#> Levels: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

# after relabelling
forcats::fct_relabel(popSample$AGEGRP, ~paste0("AgeGroup", .))[1:4]
#> [1] AgeGroup1 AgeGroup2 AgeGroup3 AgeGroup4
#> 18 Levels: AgeGroup1 AgeGroup2 AgeGroup3 AgeGroup4 AgeGroup5 ... AgeGroup18
```

<p>Or with base R, reassign the levels:</p>

<pre class="lang-r prettyprint-override"><code>levels(popSample$AGEGRP) <- paste0("AgeGroup", levels(popSample$AGEGRP))
popSample$AGEGRP[1:4]
#> [1] AgeGroup1 AgeGroup2 AgeGroup3 AgeGroup4
#> 18 Levels: AgeGroup1 AgeGroup2 AgeGroup3 AgeGroup4 AgeGroup5 ... AgeGroup18
</code>```

Title: Renaming labels of a factor in R

Body:
I have census data of Male and Female populations organizaed by age group:

library(tidyverse)

url <- "https://www2.census.gov/programs-surveys/popest/datasets/2010-2018/counties/asrh/cc-est2018-alldata-54.csv"

if (!file.exists("./datafiles/cc-est2018-alldata-54.csv"))
  download.file(url, destfile = "./datafiles/cc-est2018-alldata-54.csv", mode = "wb")

popSample <- read.csv("./datafiles/cc-est2018-alldata-54.csv") %>%
  filter(AGEGRP != 0 & YEAR == 1) %>%
  select("STNAME", "CTYNAME", "AGEGRP", "TOT_POP", "TOT_MALE", "TOT_FEMALE")

popSample$AGEGRP <- as.factor(popSample$AGEGRP)

I then plot the Male and Female population relationships, faceted by age group (1-18, which is currently treated as a int

g <- ggplot(popSample, aes(x=TOT_MALE, y=TOT_FEMALE)) +
  geom_point(alpha = 0.5, colour="darkblue") +
  scale_x_log10() +
  scale_y_log10() +
  facet_wrap(~AGEGRP) +
  stat_smooth(method = "lm", col = "darkred", size=.75) +
  labs(title = "F vs. M Population across all Age Groups", x = "Total Male (log10)", y = "Total Female (log10)") +
  theme_light()

g

Which results in this plot: https://share.getcloudapp.com/v1ur6O4e

The problem: I am trying to convert the column AGEGRP from ‘int’ to ‘factor’, and change the factors labels from “1”, “2”, “3”, … “18” to "AgeGroup1", "AgeGroup2", "AgeGroup3", … "AgeGroup18"

When I try this code, my AGEGRP column's observation values are all replaced with NAs:popSample$AGEGRP <- factor(popSample$AGEGRP, levels = c("0 to 4", "5 to 9", "10 to 14", "15 to 19", "20 to 24", "25 to 29", "30 to 34", "35 to 39", "40 to 44", "45 to 49", "50 to 54", "55 to 59", "60 to 64", "65 to 69", "70 to 74", "75 to 79", "80 to 84", "85+"))

https://share.getcloudapp.com/qGuo1O4y

Thank you for your help,

Body:
To change all the factor labels with one function, you can use forcats::fct_relabel (forcats ships as part of the tidyverse, which you've already got loaded). The changed factor labels will carry over to the plot facets and the order stays the same.

First few entries:

# before relabelling
popSample$AGEGRP[1:4]
#> [1] 1 2 3 4
#> Levels: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

# after relabelling
forcats::fct_relabel(popSample$AGEGRP, ~paste0("AgeGroup", .))[1:4]
#> [1] AgeGroup1 AgeGroup2 AgeGroup3 AgeGroup4
#> 18 Levels: AgeGroup1 AgeGroup2 AgeGroup3 AgeGroup4 AgeGroup5 ... AgeGroup18

Or with base R, reassign the levels:

levels(popSample$AGEGRP) <- paste0("AgeGroup", levels(popSample$AGEGRP))
popSample$AGEGRP[1:4]
#> [1] AgeGroup1 AgeGroup2 AgeGroup3 AgeGroup4
#> 18 Levels: AgeGroup1 AgeGroup2 AgeGroup3 AgeGroup4 AgeGroup5 ... AgeGroup18


问:
How to generate a random number and export it to an automated email?
I'm using jqueryform.com form builder to create a registration form. I'd like the registration form to assign each registrant user with an account number (randomly generated 6-digit number) and then I'd like the program to place the account number in an automated email that is already programmed to send out when the form is submitted.

The form files are .js and .php files. I believe the automated email program pulls variables out of .php script such as the variables {AutoID} or {Date}, for example:

Automated Email Program GUI

I've drafted up this random number generator:

```<code>  <p>
    <?php
    $randomNumber = rand(100000,999999);
    print_r($randomNumber);
    print_r("\n");
    ?>
  </p>
</code>```

Where would I put this and how can I reference its product in the automated email program GUI?

答:
Instead of the automated email program you can use PHP to send emails like below

```<code><?php

$randomNumber = rand(100000,999999);
$to_email = 'email@company.com';
$subject = 'Your account info';
$message = 'Your account number is '.$randomNumber;
$headers = 'From: noreply@domain.com';
mail($to_email,$subject,$message,$headers);

?>
</code>```

But if you must use the program then you need to add a hidden input to your form and pass the random number as a value like this

```<code><input type="hidden" name="randomValue" value="<?php echo $randomNumber;?>">
</code>```

then retrieve the value from the form as {randomValue}

Body:
I'm using jqueryform.com form builder to create a registration form. I'd like the registration form to assign each registrant user with an account number (randomly generated 6-digit number) and then I'd like the program to place the account number in an automated email that is already programmed to send out when the form is submitted.

The form files are .js and .php files. I believe the automated email program pulls variables out of .php script such as the variables {AutoID} or {Date}, for example:

Automated Email Program GUI

I've drafted up this random number generator:

    <?php
    $randomNumber = rand(100000,999999);
    print_r($randomNumber);
    print_r("\n");
    ?>

Where would I put this and how can I reference its product in the automated email program GUI?

Body:
Instead of the automated email program you can use PHP to send emails like below

<?php

$randomNumber = rand(100000,999999);
$to_email = 'email@company.com';
$subject = 'Your account info';
$message = 'Your account number is '.$randomNumber;
$headers = 'From: noreply@domain.com';
mail($to_email,$subject,$message,$headers);

?>

But if you must use the program then you need to add a hidden input to your form and pass the random number as a value like this

<input type="hidden" name="randomValue" value="<?php echo $randomNumber;?>">

then retrieve the value from the form as {randomValue}


问:
Invalid scope when getting access token to EWS on Office365
I am trying to request an access token for EWS with a regular @outlook.com Office 365 account. Using EWS with Basic Auth is working without problems.

I am requesting the scope

https://outlook.office365.com/EWS.AccessAsUser.All

from https://login.microsoftonline.com/common.

With an account from our organization this token is granted and access is possible. But with the @outlook.com account it givers me the error

The provided resource value for the input parameter 'scope' is not valid

Where is the difference between an organization Office 365 Account and @outlook.com account. And why are the valid scopes different?

答:
The scope is "https://outlook.office.com/EWS.AccessAsUser.All".

Try this code: https://learn.microsoft.com/en-us/exchange/client-developer/exchange-web-services/how-to-authenticate-an-ews-application-by-using-oauth


问:
How to change the color of correct answer using JavaScript when check answer button clicked

Lorem ipsum dolor sit amet, consectetur adipiscing elit
 (A)Lorem ipsum dolor

  (B)Lorem ipsum dolor
 (C) Lorem ipsum dolor
 (D) Lorem ipsum dolor

<button class="ans-button">check answer</button>

Lorem ipsum dolor sit amet, consectetur adipiscing elit

  (A)Lorem ipsum dolor
 (B)Lorem ipsum dolor
 (C) Lorem ipsum dolor
 (D) Lorem ipsum dolor

<button class="ans-button">check answer</button>

Lorem ipsum dolor sit amet, consectetur adipiscing elit
 (A)Lorem ipsum dolor
 (B)Lorem ipsum dolor
 (C) Lorem ipsum dolor

  (D) Lorem ipsum dolor

<button class="ans-button">check answer</button>```

how to change the color of the correct option when 'check answer' button of the question clicked?

答:
Remove the hard coded correct class on each span element and define the class in css, then on button click find the corresponding span(answer) element and add the class to the element:

[...document.getElementsByClassName('ans-button')].forEach(button => button.addEventListener('click', highlightAnswer));

function highlightAnswer() {
    const answer = event.target.previousElementSibling.querySelector('span');
    answer.classList.add('correct');
}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.correct {
  background-color: green;
}</code>```

Lorem ipsum dolor sit amet, consectetur adipiscing elit
 (A)Lorem ipsum dolor

  (B)Lorem ipsum dolor
 (C) Lorem ipsum dolor
 (D) Lorem ipsum dolor

<button class="ans-button">check answer</button>

Lorem ipsum dolor sit amet, consectetur adipiscing elit

  (A)Lorem ipsum dolor
 (B)Lorem ipsum dolor
 (C) Lorem ipsum dolor
 (D) Lorem ipsum dolor

<button class="ans-button">check answer</button>

Lorem ipsum dolor sit amet, consectetur adipiscing elit
 (A)Lorem ipsum dolor
 (B)Lorem ipsum dolor
 (C) Lorem ipsum dolor
(D) Lorem ipsum dolor

<button class="ans-button">check answer</button>```

Body:
Lorem ipsum dolor sit amet, consectetur adipiscing elit
 (A)Lorem ipsum dolor

  (B)Lorem ipsum dolor
 (C) Lorem ipsum dolor
 (D) Lorem ipsum dolor

<button class="ans-button">check answer</button>

Lorem ipsum dolor sit amet, consectetur adipiscing elit

  (A)Lorem ipsum dolor
 (B)Lorem ipsum dolor
 (C) Lorem ipsum dolor
 (D) Lorem ipsum dolor

<button class="ans-button">check answer</button>

Lorem ipsum dolor sit amet, consectetur adipiscing elit
 (A)Lorem ipsum dolor
 (B)Lorem ipsum dolor
 (C) Lorem ipsum dolor

  (D) Lorem ipsum dolor

<button class="ans-button">check answer</button>

how to change the color of the correct option when 'check answer' button of the question clicked?

Body:
Remove the hard coded correct class on each span element and define the class in css, then on button click find the corresponding span(answer) element and add the class to the element:

[...document.getElementsByClassName('ans-button')].forEach(button => button.addEventListener('click', highlightAnswer));

function highlightAnswer() {
    const answer = event.target.previousElementSibling.querySelector('span');
    answer.classList.add('correct');
}

.correct {
  background-color: green;
}

<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit<br> (A)Lorem ipsum dolor<br>
  <span>(B)Lorem ipsum dolor</span><br> (C) Lorem ipsum dolor<br> (D) Lorem ipsum dolor
</p>
<button class="ans-button">check answer</button>

<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit<br>
  <span>(A)Lorem ipsum dolor</span><br> (B)Lorem ipsum dolor<br> (C) Lorem ipsum dolor<br> (D) Lorem ipsum dolor
</p>
<button class="ans-button">check answer</button>

<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit<br> (A)Lorem ipsum dolor<br> (B)Lorem ipsum dolor<br> (C) Lorem ipsum dolor<br><span>(D) Lorem ipsum dolor</span>
</p>
<button class="ans-button">check answer</button>


问:
Kinesis Streams and Flink
I have a question regarding sharding data in a Kinesis stream. I would like to use a random partition key when sending user data to my kinesis stream so that the data in the shards is evenly distributed. For the sake of making this question simpler, I would then like to aggregate the user data by keying off of a userId in my Flink application. </p>

<p>My question is this: if the shards are randomly partitioned so that data for one userId is spread across multiple Kinesis shards, can Flink handle reading off of multiple shards and then redistributing the data so that all of the data for a single userId is streamed to the same aggregator task? Or, do I need to shard the kinesis stream by user id before it is consumed by Flink? </p>

答:
... can Flink handle reading off of multiple shards and then redistributing the data so that all of the data for a single userId is streamed to the same aggregator task?

The effect of a keyBy(e -> e.userId), if you use Flink's DataStream API, is to redistribute all of the events so that all events for any particular userId will be streamed to the same downstream aggregator task.

Would each host read in data from a subset of the shards in the stream and would Flink then use the keyBy operator to pass messages of the same key to the host that will perform the actual aggregation?

Yes, that's right.

If, for example, you have 8 physical hosts, each providing 8 slots for running the job, then there will be 64 instances of the aggregator task, each of which will be responsible for a disjoint subset of the key space.

Assuming there are more than 64 shards available to read from, then each in each of the 64 tasks, the source will read from one or more shards, and then distribute the events it reads according to their userIds. Assuming the userIds are evenly spread across the shards, then each source instance will find that a few of the events it reads are for userIds it is been assigned to handle, and the local aggregator should be used. The rest of the events will each need to be sent out to one of the other 63 aggregators, depending on which worker is responsible for each userId.

Title: Kinesis Streams and Flink

Body:
I have a question regarding sharding data in a Kinesis stream. I would like to use a random partition key when sending user data to my kinesis stream so that the data in the shards is evenly distributed. For the sake of making this question simpler, I would then like to aggregate the user data by keying off of a userId in my Flink application.

My question is this: if the shards are randomly partitioned so that data for one userId is spread across multiple Kinesis shards, can Flink handle reading off of multiple shards and then redistributing the data so that all of the data for a single userId is streamed to the same aggregator task? Or, do I need to shard the kinesis stream by user id before it is consumed by Flink?