All Downloads are FREE. Search and download functionalities are using the official Maven repository.

info.archinnov.achilles.generated.manager.EntitySensor_Manager Maven / Gradle / Ivy

package info.archinnov.achilles.generated.manager;

import com.datastax.driver.core.BoundStatement;
import com.datastax.driver.core.PreparedStatement;
import com.datastax.driver.core.RegularStatement;
import info.archinnov.achilles.generated.dsl.EntitySensor_Delete;
import info.archinnov.achilles.generated.dsl.EntitySensor_Select;
import info.archinnov.achilles.generated.dsl.EntitySensor_Update;
import info.archinnov.achilles.generated.meta.entity.EntitySensor_AchillesMeta;
import info.archinnov.achilles.internals.entities.EntitySensor;
import info.archinnov.achilles.internals.query.crud.DeleteByPartitionWithOptions;
import info.archinnov.achilles.internals.query.crud.DeleteWithOptions;
import info.archinnov.achilles.internals.query.crud.FindWithOptions;
import info.archinnov.achilles.internals.query.crud.InsertWithOptions;
import info.archinnov.achilles.internals.query.raw.NativeQuery;
import info.archinnov.achilles.internals.query.typed.TypedQuery;
import info.archinnov.achilles.internals.runtime.AbstractManager;
import info.archinnov.achilles.internals.runtime.RuntimeEngine;
import info.archinnov.achilles.validation.Validator;
import java.lang.Class;
import java.lang.Long;
import java.lang.Object;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

public final class EntitySensor_Manager extends AbstractManager {
  public final EntitySensor_AchillesMeta meta;

  public EntitySensor_Manager(final Class entityClass, final EntitySensor_AchillesMeta meta, final RuntimeEngine rte) {
    super(entityClass, meta, rte);
    this.meta = meta;
  }

  /**
   * Provide CRUD operations: 
*
    *
  • FIND BY ID
  • *
  • INSERT
  • *
  • INSERT STATIC
  • *
  • INSERT IF NOT EXISTS
  • *
  • DELETE BY ID
  • *
  • DELETE BY ID IF NOT EXISTS
  • *
  • DELETE BY PARTITION
  • *
*/ public final EntitySensor_CRUD crud() { return new EntitySensor_CRUD(); } /** * Provide DSL methods:
*
    *
  • SELECT
  • *
  • ITERATION ON SELECT
  • *
  • UPDATE
  • *
  • DELETE
  • *
*/ public final EntitySensor_DSL dsl() { return new EntitySensor_DSL(); } /** * Provide QUERY methods:
*
    *
  • Typed Queries (for SELECT only)
  • *
  • Native Queries (for any kind of statement)
  • *
*/ public final EntitySensor_QUERY query() { return new EntitySensor_QUERY(); } public final class EntitySensor_CRUD { /** * Find an entity by its complete primary key@param sensorId partition key 'sensorId'@param date clustering column 'date'@return FindWithOptions */ public FindWithOptions findById(final Long sensorId, final Long date) { List keys = new ArrayList<>(); List encodedKeys = new ArrayList<>(); Validator.validateNotNull(sensorId, "Partition key '%s' should not be null", "sensorId"); keys.add(sensorId); encodedKeys.add(EntitySensor_AchillesMeta.sensorId.encodeFromJava(sensorId)); Validator.validateNotNull(date, "Partition key '%s' should not be null", "date"); keys.add(date); encodedKeys.add(EntitySensor_AchillesMeta.date.encodeFromJava(date)); final Object[] primaryKeyValues = keys.toArray(); final Object[] encodedPrimaryKeyValues = encodedKeys.toArray(); return new FindWithOptions(entityClass, meta, rte, primaryKeyValues, encodedPrimaryKeyValues); } /** * Delete an entity instance by extracting its primary keyRemark: Achilles will throw an exception if any column being part of the primary key is NULL@param an instance of EntitySensor to be delete@return DeleteWithOptions */ public DeleteWithOptions delete(final EntitySensor instance) { return deleteInternal(instance); } /** * Delete an entity using its complete primary key@param sensorId partition key 'sensorId'@param date clustering column 'date'@return DeleteWithOptions */ public DeleteWithOptions deleteById(final Long sensorId, final Long date) { List keys = new ArrayList<>(); List encodedKeys = new ArrayList<>(); Validator.validateNotNull(sensorId, "Partition key '%s' should not be null", "sensorId"); keys.add(sensorId); encodedKeys.add(EntitySensor_AchillesMeta.sensorId.encodeFromJava(sensorId)); Validator.validateNotNull(date, "Partition key '%s' should not be null", "date"); keys.add(date); encodedKeys.add(EntitySensor_AchillesMeta.date.encodeFromJava(date)); final Object[] partitionKeysValues = keys.toArray(); final Object[] encodedPartitionKeyValues = encodedKeys.toArray(); return new DeleteWithOptions(entityClass, meta, rte, partitionKeysValues, encodedPartitionKeyValues, Optional.empty()); } /** * Insert this entity * * @param instance an instance of EntitySensor * @return InsertWithOptions */ public final InsertWithOptions insert(final EntitySensor instance) { return insertInternal(instance, false); } /** * Delete a whole partition using the partition key@param sensorId partition key 'sensorId'@return DeleteByPartitionWithOptions */ public DeleteByPartitionWithOptions deleteByPartitionKeys(final Long sensorId) { List keys = new ArrayList<>(); List encodedKeys = new ArrayList<>(); Validator.validateNotNull(sensorId, "Partition key '%s' should not be null", "sensorId"); keys.add(sensorId); encodedKeys.add(EntitySensor_AchillesMeta.sensorId.encodeFromJava(sensorId)); final Object[] partitionKeys = keys.toArray(); final Object[] encodedPartitionKeys = encodedKeys.toArray(); return new DeleteByPartitionWithOptions(meta, rte, partitionKeys, encodedPartitionKeys); } } public final class EntitySensor_DSL { /** * Generate a SELECT statement@return EntitySensor_Select */ public final EntitySensor_Select select() { return new EntitySensor_Select(rte, meta); } /** * Generate a DELETE statement@return EntitySensor_Delete */ public final EntitySensor_Delete delete() { return new EntitySensor_Delete(rte, meta); } /** * Generate an UPDATE statement@return EntitySensor_Update */ public final EntitySensor_Update update() { return new EntitySensor_Update(rte, meta); } } public final class EntitySensor_QUERY { /** * Execute the bound statement and map the result back into an instance of EntitySensor
* Remark: the bound statement should be a SELECT statement@param boundStatement a bound statement@return TypedQuery */ public final TypedQuery typedQueryForSelect(BoundStatement boundStatement) { return typedQueryForSelectInternal(boundStatement); } /** * Execute the prepared statement and map the result back into an instance of EntitySensor
* Remark: the prepared statement should be a SELECT statement@param preparedStatement a prepared statement@return TypedQuery */ public final TypedQuery typedQueryForSelect(PreparedStatement preparedStatement, Object... encodedBoundValues) { return typedQueryForSelectInternal(preparedStatement, encodedBoundValues); } /** * Execute the regular statement and map the result back into an instance of EntitySensor
* Remark: the regular statement should be a SELECT statement@param regularStatement a regular statement@return TypedQuery */ public final TypedQuery typedQueryForSelect(RegularStatement regularStatement, Object... encodedBoundValues) { return typedQueryForSelectInternal(regularStatement, encodedBoundValues); } /** * Execute the native bound statement@param boundStatement a bound statement@return NativeQuery */ public final NativeQuery nativeQuery(BoundStatement boundStatement) { return nativeQueryInternal(boundStatement); } /** * Execute the native prepared statement@param preparedStatement a prepared statement@return NativeQuery */ public final NativeQuery nativeQuery(PreparedStatement preparedStatement, Object... encodedBoundValues) { return nativeQueryInternal(preparedStatement, encodedBoundValues); } /** * Execute the native regular statement@param regularStatement a regular statement@return NativeQuery */ public final NativeQuery nativeQuery(RegularStatement regularStatement, Object... encodedBoundValues) { return nativeQueryInternal(regularStatement, encodedBoundValues); } } }