org.qi4j.spi.entitystore.helpers

## Class JSONMapEntityStoreMixin

- java.lang.Object
- - org.qi4j.spi.entitystore.helpers.JSONMapEntityStoreMixin

- All Implemented Interfaces:
    EntityStore, EntityStoreSPI, JSONMapEntityStoreActivation, StateStore

      public class JSONMapEntityStoreMixin
      extends Object
      implements EntityStore, EntityStoreSPI, StateStore, JSONMapEntityStoreActivation

  Implementation of EntityStore that works with an implementation of MapEntityStore.

  Implement `MapEntityStore` and add as mixin to the service using this mixin.

  See `MemoryMapEntityStoreMixin` for reference.

  EntityStores based on this mixin gets support for the Migration and Cache extensions.

  MapEntityStore implementations will get their values as JSON.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `JSONMapEntityStoreMixin.CacheState`

    - ### Nested classes/interfaces inherited from interface org.qi4j.spi.entitystore.helpers.JSONMapEntityStoreActivation

      `JSONMapEntityStoreActivation.Activator`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected String` | `uuid`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `JSONMapEntityStoreMixin()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `StateCommitter` | `applyChanges(EntityStoreUnitOfWork unitOfWork, Iterable<EntityState> state)`
    `EntityState` | `entityStateOf(EntityStoreUnitOfWork unitOfWork, ModuleSpi module, EntityReference identity)`
    `Input<EntityState,EntityStoreException>` | `entityStates(ModuleSpi module)`
    `JSONObject` | `jsonStateOf(String id)`
    `EntityState` | `newEntityState(EntityStoreUnitOfWork unitOfWork, ModuleSpi module, EntityReference identity, EntityDescriptor entityDescriptor)`
    `EntityStoreUnitOfWork` | `newUnitOfWork(Usecase usecaseMetaInfo, ModuleSpi module, long currentTime)`
    `protected String` | `newUnitOfWorkId()`
    `protected JSONEntityState` | `readEntityState(ModuleSpi module, Reader entityState)`
    `void` | `setUpJSONMapES()`
    `void` | `tearDownJSONMapES()`
    `protected void` | `writeEntityState(JSONEntityState state, Writer writer, String identity, long lastModified)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### uuid

          protected String uuid

  - ### Constructor Detail

    - #### JSONMapEntityStoreMixin

          public JSONMapEntityStoreMixin()

  - ### Method Detail

    - #### setUpJSONMapES

          public void setUpJSONMapES()
                              throws Exception

      Specified by:
        `setUpJSONMapES` in interface `JSONMapEntityStoreActivation`
      Throws:
        `Exception`

    - #### tearDownJSONMapES

          public void tearDownJSONMapES()
                                 throws Exception

      Specified by:
        `tearDownJSONMapES` in interface `JSONMapEntityStoreActivation`
      Throws:
        `Exception`

    - #### newUnitOfWork

          public EntityStoreUnitOfWork newUnitOfWork(Usecase usecaseMetaInfo,
                                            ModuleSpi module,
                                            long currentTime)

      Specified by:
        `newUnitOfWork` in interface `EntityStore`

    - #### newEntityState

          public EntityState newEntityState(EntityStoreUnitOfWork unitOfWork,
                                   ModuleSpi module,
                                   EntityReference identity,
                                   EntityDescriptor entityDescriptor)

      Specified by:
        `newEntityState` in interface `EntityStoreSPI`

    - #### entityStateOf

          public EntityState entityStateOf(EntityStoreUnitOfWork unitOfWork,
                                  ModuleSpi module,
                                  EntityReference identity)

      Specified by:
        `entityStateOf` in interface `EntityStoreSPI`

    - #### applyChanges

          public StateCommitter applyChanges(EntityStoreUnitOfWork unitOfWork,
                                    Iterable<EntityState> state)
                                      throws EntityStoreException

      Specified by:
        `applyChanges` in interface `EntityStoreSPI`
      Throws:
        `EntityStoreException`

    - #### entityStates

          public Input<EntityState,EntityStoreException> entityStates(ModuleSpi module)

      Specified by:
        `entityStates` in interface `EntityStore`

    - #### newUnitOfWorkId

          protected String newUnitOfWorkId()

    - #### writeEntityState

          protected void writeEntityState(JSONEntityState state,
                              Writer writer,
                              String identity,
                              long lastModified)
                                   throws EntityStoreException

      Throws:
        `EntityStoreException`

    - #### readEntityState

          protected JSONEntityState readEntityState(ModuleSpi module,
                                        Reader entityState)
                                             throws EntityStoreException

      Throws:
        `EntityStoreException`

    - #### jsonStateOf

          public JSONObject jsonStateOf(String id)
                                 throws IOException

      Specified by:
        `jsonStateOf` in interface `StateStore`
      Throws:
        `IOException`