Java Code Examples for com.datastax.driver.core.BoundStatement#setList()

The following examples show how to use com.datastax.driver.core.BoundStatement#setList() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ManufactureKittingDaoImpl.java    From arcusplatform with Apache License 2.0 5 votes vote down vote up
@Override
public void createKit(Kit kit) {
	BoundStatement bound = new BoundStatement(createKit);		
	bound.setString(KitColumns.hubid.name(), kit.getHubId());
	bound.setString(KitColumns.type.name(), kit.getType());
	bound.setList(KitColumns.devices.name(), convertToString(kit.getDevices()));
	session.execute(bound);
}
 
Example 2
Source File: CassandraAlarmIncidentDAO.java    From arcusplatform with Apache License 2.0 5 votes vote down vote up
@Override
public void upsert(AlarmIncident incident) {
   PreparedStatement pStmt = incident.isCleared() ? upsertWithTtl : upsert;
   BoundStatement bound = new BoundStatement(pStmt);
   bound.setUUID(Column.placeid.name(), incident.getPlaceId());
   bound.setUUID(Column.incidentid.name(), incident.getId());
   bound.setString(Column.alertstate.name(), incident.getAlertState().name());
   if(incident.getPlatformAlertState() == null) {
      bound.setString(Column.platformstate.name(), incident.getAlertState().name());
   }
   else {
      bound.setString(Column.platformstate.name(), incident.getPlatformAlertState().name());
   }
   if(incident.getHubAlertState() == null) {
      bound.setToNull(Column.hubstate.name());
   }
   else {
      bound.setString(Column.hubstate.name(), incident.getHubAlertState().name());
   }
   bound.setSet(Column.activealerts.name(), incident.getActiveAlerts());
   bound.setSet(Column.additionalalerts.name(), incident.getAdditionalAlerts().stream().map(AlertType::name).collect(Collectors.toSet()));
   bound.setString(Column.alert.name(), incident.getAlert().name());
   bound.setString(Column.cancelledby.name(), incident.getCancelledBy() == null ? null : incident.getCancelledBy().getRepresentation());
   bound.setTimestamp(Column.prealertendtime.name(), incident.getPrealertEndTime());
   bound.setTimestamp(Column.endtime.name(), incident.getEndTime());
   bound.setString(Column.monitoringstate.name(), incident.getMonitoringState().name());
   bound.setList(Column.tracker.name(), incident.getTracker().stream().map((te) -> JSON.toJson(te.toMap())).collect(Collectors.toList()));
   bound.setBool(Column.mockincident.name(), incident.isMockIncident());
   bound.setBool(Column.monitored.name(), incident.isMonitored());
   bound.setBool(Column.confirmed.name(),  incident.isConfirmed());
   session.execute(bound);
}
 
Example 3
Source File: CassandraPOJOOutputOperator.java    From attic-apex-malhar with Apache License 2.0 4 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
protected Statement setStatementParameters(PreparedStatement updateCommand, Object tuple) throws DriverException
{
  final BoundStatement boundStmnt = new BoundStatement(updateCommand);
  final int size = columnDataTypes.size();
  for (int i = 0; i < size; i++) {
    final DataType type = columnDataTypes.get(i);
    switch (type.getName()) {
      case UUID:
        final UUID id = ((Getter<Object, UUID>)getters.get(i)).get(tuple);
        boundStmnt.setUUID(i, id);
        break;
      case ASCII:
      case VARCHAR:
      case TEXT:
        final String ascii = ((Getter<Object, String>)getters.get(i)).get(tuple);
        boundStmnt.setString(i, ascii);
        break;
      case BOOLEAN:
        final boolean bool = ((GetterBoolean<Object>)getters.get(i)).get(tuple);
        boundStmnt.setBool(i, bool);
        break;
      case INT:
        final int intValue = ((GetterInt<Object>)getters.get(i)).get(tuple);
        boundStmnt.setInt(i, intValue);
        break;
      case BIGINT:
      case COUNTER:
        final long longValue = ((GetterLong<Object>)getters.get(i)).get(tuple);
        boundStmnt.setLong(i, longValue);
        break;
      case FLOAT:
        final float floatValue = ((GetterFloat<Object>)getters.get(i)).get(tuple);
        boundStmnt.setFloat(i, floatValue);
        break;
      case DOUBLE:
        final double doubleValue = ((GetterDouble<Object>)getters.get(i)).get(tuple);
        boundStmnt.setDouble(i, doubleValue);
        break;
      case DECIMAL:
        final BigDecimal decimal = ((Getter<Object, BigDecimal>)getters.get(i)).get(tuple);
        boundStmnt.setDecimal(i, decimal);
        break;
      case SET:
        Set<?> set = ((Getter<Object, Set<?>>)getters.get(i)).get(tuple);
        boundStmnt.setSet(i, set);
        break;
      case MAP:
        final Map<?,?> map = ((Getter<Object, Map<?,?>>)getters.get(i)).get(tuple);
        boundStmnt.setMap(i, map);
        break;
      case LIST:
        final List<?> list = ((Getter<Object, List<?>>)getters.get(i)).get(tuple);
        boundStmnt.setList(i, list);
        break;
      case TIMESTAMP:
        final Date date = ((Getter<Object, Date>)getters.get(i)).get(tuple);
        boundStmnt.setDate(i, LocalDate.fromMillisSinceEpoch(date.getTime()));
        break;
      default:
        throw new RuntimeException("unsupported data type " + type.getName());
    }
  }
  return boundStmnt;
}