diff --git a/spec/src/main/asciidoc/annotations.adoc b/spec/src/main/asciidoc/annotations.adoc index b8d299aa9..687e5e37a 100644 --- a/spec/src/main/asciidoc/annotations.adoc +++ b/spec/src/main/asciidoc/annotations.adoc @@ -14,7 +14,7 @@ === Models Annotation -As mentioned previously, the Mapping API has annotations that make the Java developer's life easier; these annotations have two categories: +As previously mentioned, the Mapping API has annotations that make the Java developer's life easier; these annotations have two categories: * Annotation Models * Qualifier annotation @@ -52,7 +52,7 @@ public class Person { } ---- -An entity that is a field be will incorporated as a sub-entity. For example, in a Document, the entity field will be converted to a subdocument. +An entity that is a field will be incorporated as a sub-entity. For example, in a Document, the entity field will be converted to a sub-document. [source,java] @@ -96,7 +96,7 @@ public class Address { ---- ===== @Column -This annotation defines which fields that belong an Entity will be persisted. There is a single attribute that specifies that name in Database. It is default value that is the field name as declared in the class. This annotation is mandatory for non-Key-Value database types. In Key-Value types, only the Key needs to be identified with `@Key` - all other fields are stored as a single blob. +This annotation defines which fields that belong to an Entity will be persisted. There is a single attribute that specifies that name in Database. It is default value that is the field name as declared in the class. This annotation is mandatory for non-Key-Value database types. In Key-Value types, only the Key needs to be identified with `@Key` - all other fields are stored as a single blob. [source,java] ---- @@ -111,16 +111,16 @@ public class Person { @Column private List phones; - //ignored + // ignored private String address; } ---- ===== @MappedSuperclass -The class with the MapperSuperclass annotation will have all attributes considered as an extension of his subclass with Entity annotation. In this case, all attributes are going to be stored, even the attributes inside the Super Class. +The class with the `@MapperSuperclass` annotation will have all attributes considered as an extension of this subclass with an `@Entity` annotation. In this case, all attributes are going to be stored, even the attributes inside the super class. -This means, that This annotation causes fields annotated with `@Column` in a parent class to be persisted together with the child class' fields. +This means, that this annotation causes fields annotated with `@Column` in a parent class to be persisted together with the child class' fields. [source,java] @@ -148,7 +148,7 @@ On the example above, when saving a Dog instance, Animal class' fields are saved ===== @Id -Defines which attribute is the entity's id, or the Key in Key-Value databases. In such case, the Value is the remaining information. It has a single attribute (like `@Column`) to define the native name. Unlike `@Column`, the default value is `_id`. +This annotation defines which attribute is the entity's ID, or the Key in Key-Value databases. In such a case, the Value is the remaining information. It has a single attribute (like `@Column`) to define the native name. Unlike `@Column`, the default value is `_id`. [source,java] ---- @@ -169,7 +169,7 @@ public class User implements Serializable { ===== @Embeddable -Defines a class whose instances are stored as an intrinsic part of an owning entity and share the identity of that object. The behaviour is similar to `@MappedSuperclass`, but this is used on composition instead of inheritance. +This annotation defines a class whose instances are stored as an intrinsic part of an owning entity and share the identity of that object. The behaviour is similar to `@MappedSuperclass`, but this is used on composition instead of inheritance. [source,java] ---- @@ -195,11 +195,11 @@ public class Author { ---- -In this example, there is a single Instance in the database with columns `title`, `author` and `age`. +In this example, there is a single instance in the database with columns `title`, `author` and `age`. ===== @Convert -This annotation allows value convertions when mapping the value that came from the Communication API. This is useful for cases such as to cipher a field (String to String conversion), or to convert to a custom type. The Converter annotation has a single, mandatory parameter: a Class that inherits from AttributeConverter that will be used to perform the convertion. The example below shows how to create a converter to a custom Money class. +This annotation allows value conversions when mapping the value that came from the Communication API. This is useful for cases such as to cipher a field (String to String conversion), or to convert to a custom type. The Converter annotation has a single, mandatory parameter: a class that inherits from `AttributeConverter` that will be used to perform the conversion. The example below shows how to create a converter to a custom `Money` class. [source,java] ---- @@ -214,40 +214,40 @@ public class Employee { @Column("money") @Convert(MoneyConverter.class) - private MonetaryAmmount salary; + private MonetaryAmount salary; } -public class MoneyConverter implements AttributeConverter { +public class MoneyConverter implements AttributeConverter { @Override - public String convertToDatabaseColumn(MonetaryAmmount appValue) { + public String convertToDatabaseColumn(MonetaryAmount appValue) { return appValue.toString(); } @Override - public MonetaryAmmount convertToEntityAttribute(String dbValue) { - return MonetaryAmmount.parse(dbValue); + public MonetaryAmount convertToEntityAttribute(String dbValue) { + return MonetaryAmount.parse(dbValue); } } -public class MonetaryAmmount { +public class MonetaryAmount { private final String currency; private final BigDecimal value; public String toString() { - //specific implementation + // specific implementation } - public static MonetaryAmmount parse(String string) { - //specific implementation + public static MonetaryAmount parse(String string) { + // specific implementation } } ---- ===== Collections -The Mapping layer supports `java.util.Collection` (and subclasses, as defined below) mapping to simple elements such as `String` and `Integer` (that will be sent to the communication API as-is), and mapping to `Entity` or `Embedded` entities. +The Mapping layer supports `java.util.Collection` (and subclasses as defined below) mapping to simple elements such as `String` and `Integer` (that will be sent to the communication API as-is), and mapping to `Entity` or `Embedded` entities. The following collections are supported: @@ -316,7 +316,7 @@ The above classes are mapped to: This annotation allows programmers to specialize `@Inject` annotations to choose which specific resource should be injected. -For example, when working with multiple DocumentRepositories, the following is ambiguous: +For example, when working with multiple `DocumentRepositories`, the following statement are ambiguous: [source,java] ---- @@ -337,11 +337,11 @@ Applying the annotation to the example above, the result is: [source,java] ---- @Inject -@Database(value = DatabaseType.DOCUMENT, provider = “databaseA”) +@Database(value = DatabaseType.DOCUMENT, provider = "databaseA") private DocumentRepository repositoryA; @Inject -@Database(value = DatabaseType.DOCUMENT, provider = “databaseB”) +@Database(value = DatabaseType.DOCUMENT, provider = "databaseB") private DocumentRepository repositoryB; ---- diff --git a/spec/src/main/asciidoc/mapping.adoc b/spec/src/main/asciidoc/mapping.adoc index 8164f70af..0105ffd2f 100644 --- a/spec/src/main/asciidoc/mapping.adoc +++ b/spec/src/main/asciidoc/mapping.adoc @@ -12,11 +12,11 @@ // // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 -== Mapping API Introduction +== Introduction to the Mapping API -The mapping level, to put it differently, has the same goals as either the JPA or ORM. In NoSQL world, the *OxM* then converts the entity object to a communication model. +The mapping level, to put it differently, has the same goals as either the JPA or ORM. In the NoSQL world, the *OxM* then converts the entity object to a communication model. -This level is in charge to do integration among technologies such as Bean Validation. The Mapping API has annotations that make the Java developer’s life easier. As a communication project, it must be extensible and configurable to keep the diversity of NoSQL database. +This level is in charge to perform integration among technologies such as Bean Validation. The Mapping API has annotations that make the Java developer’s life easier. As a communication project, it must be extensible and configurable to keep the diversity of NoSQL database. To go straight and cover the four NoSQL types, this API has four domains: @@ -39,14 +39,14 @@ The mapping API has five parts: TIP: Each module works separately as a Communication API. -IMPORTANT: Like communication API, there is a support for database diversity. This project has extensions for each database types on the database mapping level. +IMPORTANT: Similar to the communication API, there is a support for database diversity. This project has extensions for each database types on the database mapping level. include::annotations.adoc[] === Template classes -The template offers convenient operations to create, update, delete, query, and provides a mapping between your domain objects and communication API. The templates classes have the goal to persist an Entity Model through a communication API. It has three components: +The template offers convenient operations to create, update, delete, query, and provides a mapping among your domain objects and communication API. The templates classes have a goal to persist an Entity Model through a communication API. It has three components: * *Converter*: That converts the Entity to a communication level API. * *EntityManager*: The EntityManager for communication. diff --git a/spec/src/main/asciidoc/template_column.adoc b/spec/src/main/asciidoc/template_column.adoc index 8c782a5aa..a51eef5cc 100644 --- a/spec/src/main/asciidoc/template_column.adoc +++ b/spec/src/main/asciidoc/template_column.adoc @@ -14,11 +14,11 @@ ==== ColumnTemplate -This template has the duty to be a bridge between the entity model and the communication to a column family. +This template has the responsibility to serve as a bridge between the entity model and the communication to a column family NoSQL database type. The `ColumnTemplate` is the column template for the synchronous tasks. It has three components: -* *ColumnEntityConverter*: That converts an entity to communication API, e.g., The Person to ColumnFamilyEntity. +* *ColumnEntityConverter*: Converts an entity to communication API, e.g., the `Person` to `ColumnFamilyEntity`. * *ColumnCollectionManager*: The communication column family entity manager. @@ -26,7 +26,7 @@ The `ColumnTemplate` is the column template for the synchronous tasks. It has th [source,java] ---- -ColumnTemplate template = //instance; +ColumnTemplate template = // instance; Person person = new Person(); person.setAddress("Olympus"); @@ -44,7 +44,7 @@ template.update(person); template.update(people); ---- -For information removal and retrieval, there are *ColumnQuery* and *ColumnDeleteQuery* respectively; also, the callback method can be used. +For information removal and retrieval, there are `ColumnQuery` and `ColumnDeleteQuery` classes, respectively. Also, the callback method may be used. [source,java] ---- @@ -60,7 +60,7 @@ template.delete(deleteQuery); ---- -Both *ColumnQuery* and *ColumnDeleteQuery* won't convert the Object to native fields. However, there is *ColumnQueryMapperBuilder* that creates both query types, reading the Class then switching to the native fields through annotations. +Both `ColumnQuery` and `ColumnDeleteQuery` won't convert the object to native fields. However, `ColumnQueryMapperBuilder` creates both query types, reads the class, then switches to the native fields through annotations. [source,java] ---- @@ -85,15 +85,15 @@ private ColumnQueryMapperBuilder mapperBuilder; public void mapper() { ColumnQuery query = mapperBuilder.selectFrom(Person.class).where("id").gte(10).build(); - //translating: select().from("Person").where("native_id").gte(10L).build(); + // translating: select().from("Person").where("native_id").gte(10L).build(); ColumnDeleteQuery deleteQuery = mapperBuilder.deleteFrom(Person.class) .where("id").eq("20").build(); - //translating: delete().from("Person").where("native_id").gte(10L).build(); + // translating: delete().from("Person").where("native_id").gte(10L).build(); } ---- -To use a column template, just follow the CDI style and put an `@Inject` on the field. +To use a column template, just follow the CDI style and precede the field with the `@Inject` annotation. [source,java] ---- @@ -101,20 +101,20 @@ To use a column template, just follow the CDI style and put an `@Inject` on the private ColumnTemplate template; ---- -The next step is to produce a **ColumnFamilyManager**: +The next step is to produce a `ColumnFamilyManager`: [source,java] ---- @Produces public ColumnFamilyManager getManager() { - ColumnFamilyManager manager = //instance; + ColumnFamilyManager manager = // instance; return manager; } ---- -To work with more than one Column Template, there are two approaches: +To work with more than one column template, there are two approaches: -1) Using qualifiers: +1) Use qualifiers: [source,java] ---- @@ -126,31 +126,31 @@ private ColumnTemplate templateA; @Database(value = DatabaseType.COLUMN, provider = "databaseB") private ColumnTemplate templateB; -//producers methods +// producers methods @Produces @Database(value = DatabaseType.COLUMN, provider = "databaseA") public ColumnFamilyManager getManagerA() { - ColumnFamilyManager manager =//instance; + ColumnFamilyManager manager =// instance; return manager; } @Produces @Database(value = DatabaseType.COLUMN, provider = "databaseB") public ColumnFamilyManager getManagerB() { - ColumnFamilyManager manager = //instance; + ColumnFamilyManager manager = // instance; return manager; } ---- -2) Using the **ColumnTemplateProducer** class: +2) Use the `ColumnTemplateProducer` class: ```java @Inject private ColumnTemplateProducer producer; public void sample() { - ColumnFamilyManager managerA = //instance; - ColumnFamilyManager managerB = //instance; + ColumnFamilyManager managerA = // instance; + ColumnFamilyManager managerB = // instance; ColumnTemplate templateA = producer.get(managerA); ColumnTemplate templateB = producer.get(managerB); } diff --git a/spec/src/main/asciidoc/template_document.adoc b/spec/src/main/asciidoc/template_document.adoc index 0eec66a52..45e69c660 100644 --- a/spec/src/main/asciidoc/template_document.adoc +++ b/spec/src/main/asciidoc/template_document.adoc @@ -14,7 +14,7 @@ ==== DocumentTemplate -This template has the duty to be a bridge between the entity model and communication API to document collection. It has two classes; `DocumentTemplate` and `DocumentTemplateAsync` - one for the synchronous and the other for the asynchronous work. +This template has the responsibility to serve as a bridge between the entity model and communication API to a document collection. It has two classes; `DocumentTemplate` and `DocumentTemplateAsync` - one for the synchronous and the other for the asynchronous tasks. The `DocumentTemplate` is the document template for the synchronous tasks. It has three components: @@ -27,7 +27,7 @@ The `DocumentTemplate` is the document template for the synchronous tasks. It ha [source,java] ---- -DocumentTemplate template = //instance; +DocumentTemplate template = // instance; Person person = new Person(); person.setAddress("Olympus"); @@ -45,7 +45,7 @@ template.update(person); template.update(people); ---- -To both remove and retrieve information from document collection, there are *DocumentQuery* and *DocumentDeleteQuery*. +To remove and retrieve information from document collection, there are `DocumentQuery` and `DocumentDeleteQuery` classes. [source,java] ---- @@ -60,7 +60,7 @@ DocumentDeleteQuery deleteQuery = delete().from("Person").where("address") template.delete(deleteQuery); ---- -Both *DocumentQuery* and *DocumentDeleteQuery* query won't convert the Object to native fields. However, there is *DocumentQueryMapperBuilder* that creates both queries types reading the Class then switching to the native fields through annotations. +Both `DocumentQuery` and `DocumentDeleteQuery` query won't convert the Object to native fields. However, `DocumentQueryMapperBuilder` creates both query types, reads the class, then switches to the native fields through annotations. [source,java] ---- @@ -86,15 +86,15 @@ private DocumentQueryMapperBuilder mapperBuilder; public void mapper() { DocumentQuery query = mapperBuilder.selectFrom(Person.class).where("id") .gte(10).build(); - //translating: select().from("Person").where("native_id").gte(10L).build(); + // translating: select().from("Person").where("native_id").gte(10L).build(); DocumentDeleteQuery deleteQuery = mapperBuilder.deleteFrom(Person.class) .where("id").eq("20").build(); - //translating: delete().from("Person").where("native_id").gte(10L).build(); + // translating: delete().from("Person").where("native_id").gte(10L).build(); } ---- -To use a document template, just follow the CDI style and put an `@Inject` on the field. +To use a document template, just follow the CDI style and place an `@Inject` annotation on the field. [source,java] ---- @@ -102,20 +102,20 @@ To use a document template, just follow the CDI style and put an `@Inject` on th private DocumentTemplate template; ---- -The next step is to produce a **DocumentCollectionManager:** +The next step is to produce a `DocumentCollectionManager`: [source,java] ---- @Produces public DocumentCollectionManager getManager() { - DocumentCollectionManager manager = //instance; + DocumentCollectionManager manager = // instance; return manager; } ---- -To work with more than one Document Template, there are two approaches: +To work with more than one document template, there are two approaches: -1) Using qualifiers: +1) Use qualifiers: [source,java] ---- @@ -127,11 +127,11 @@ private DocumentTemplate templateA; @Database(value = DatabaseType.DOCUMENT, provider = "databaseB") private DocumentTemplate templateB; -//producers methods +// producers methods @Produces @Database(value = DatabaseType.DOCUMENT, provider = "databaseA") public DocumentCollectionManager getManagerA() { - DocumentCollectionManager manager = //instance; + DocumentCollectionManager manager = // instance; return manager; } @@ -143,7 +143,7 @@ public DocumentCollectionManager getManagerB() { } ---- -2) Using the *DocumentTemplateProducer* class: +2) Use the `DocumentTemplateProducer` class: [source,java] ---- @@ -151,8 +151,8 @@ public DocumentCollectionManager getManagerB() { private DocumentTemplateProducer producer; public void sample() { - DocumentCollectionManager managerA = //instance; - DocumentCollectionManager managerB = //instance; + DocumentCollectionManager managerA = // instance; + DocumentCollectionManager managerB = // instance; DocumentTemplate templateA = producer.get(managerA); DocumentTemplate templateB = producer.get(managerB); } @@ -162,13 +162,13 @@ public void sample() { The `DocumentTemplateAsync` is the document template for the asynchronous tasks. It has two components: -* *DocumentEntityConverter:* That converts an entity to communication API, e.g., The Person to DocumentEntity. +* *DocumentEntityConverter:* Converts an entity to communication API, e.g., the `Person` to `DocumentEntity`. * *DocumentCollectionManagerAsync:* The asynchronous document collection entity manager. [source,java] ---- -DocumentTemplateAsync templateAsync = //instance; +DocumentTemplateAsync templateAsync = // instance; Person person = new Person(); person.setAddress("Olympus"); @@ -189,7 +189,7 @@ templateAsync.update(person, callback); templateAsync.update(people); ---- -For information removal and retrieval, there are *DocumentQuery* and *DocumentDeleteQuery* respectively; also, the callback method can be used. +For information removal and retrieval, there are `DocumentQuery` and `DocumentDeleteQuery`, respectively. Also, the callback method may be used. [source,java] ---- Consumer> callBackPeople = p -> {}; @@ -199,7 +199,7 @@ templateAsync.delete(deleteQuery); templateAsync.delete(deleteQuery, voidCallBack); ---- -To use a document template, just follow the CDI style and put an `@Inject` on the field. +To use a document template, just follow the CDI style and precede the field with the `@Inject` annotation. [source,java] ---- @@ -207,20 +207,20 @@ To use a document template, just follow the CDI style and put an `@Inject` on th private DocumentTemplateAsync template; ---- -The next step is to produce a **DocumentCollectionManagerAsync:** +The next step is to produce a `DocumentCollectionManagerAsync`: [source,java] ---- @Produces public DocumentCollectionManagerAsync getManager() { - DocumentCollectionManagerAsync managerAsync = //instance; + DocumentCollectionManagerAsync managerAsync = // instance; return manager; } ---- -To work with more than one Document Template, there are two approaches: +To work with more than one document template, there are two approaches: -1) Using qualifiers: +1) Use qualifiers: [source,java] ---- @@ -232,23 +232,23 @@ private DocumentTemplateAsync templateA; @Database(value = DatabaseType.DOCUMENT, provider = "databaseB") private DocumentTemplateAsync templateB; -//producers methods +// producers methods @Produces @Database(value = DatabaseType.DOCUMENT, provider = "databaseA") public DocumentCollectionManagerAsync getManagerA() { - DocumentCollectionManager manager = //instance + DocumentCollectionManager manager = // instance return manager; } @Produces @Database(value = DatabaseType.DOCUMENT, provider = "databaseB") public DocumentCollectionManagerAsync getManagerB() { - DocumentCollectionManager manager = //instance + DocumentCollectionManager manager = // instance return manager; } ---- -2) Using the *DocumentTemplateAsyncProducer*: +2) Use the `DocumentTemplateAsyncProducer`: [source,java] ---- @@ -256,8 +256,8 @@ public DocumentCollectionManagerAsync getManagerB() { private DocumentTemplateAsyncProducer producer; public void sample() { - DocumentCollectionManagerAsync managerA = //instance; - DocumentCollectionManagerAsync managerB = //instance; + DocumentCollectionManagerAsync managerA = // instance; + DocumentCollectionManagerAsync managerB = // instance; DocumentTemplateAsync templateA = producer.get(managerA); DocumentTemplateAsync templateB = producer.get(managerB); } diff --git a/spec/src/main/asciidoc/template_graph.adoc b/spec/src/main/asciidoc/template_graph.adoc index 440b92c98..e91c88cf7 100644 --- a/spec/src/main/asciidoc/template_graph.adoc +++ b/spec/src/main/asciidoc/template_graph.adoc @@ -14,9 +14,9 @@ ==== Graph template +This template has the responsibility to serve as the persistence of an entity in a Graph database using http://tinkerpop.apache.org/[Apache Tinkerpop]. The `GraphTemplate` is the column template for synchronous tasks. It has three components: -The `GraphTemplate` is responsible for the persistence of an entity in a Graph database using http://tinkerpop.apache.org/[Apache Tinkerpop]. It is composed basically of three components. * *GraphConverter*: That converts an entity to communication API, e.g., The Person to Vertex. * *Graph*: A Graph is a container object for a collection of Vertex, Edge, VertexProperty, and Property objects. @@ -24,7 +24,7 @@ The `GraphTemplate` is responsible for the persistence of an entity in a Graph d [source,java] ---- -GraphTemplate template = //instance; +GraphTemplate template = // instance; Person person = new Person(); person.setAddress("Olympus"); @@ -46,23 +46,21 @@ template.update(people); [source,java] ---- -Person poliana = //instance; -Book shack = //instance; +Person poliana = // instance; +Book shack = // instance; EdgeEntity edge = graphTemplate.edge(poliana, "reads", shack); reads.add("where", "Brazil"); Person out = edge.getOutgoing(); Book in = edge.getIncoming(); ---- -===== Querying with traversal +===== Querying with Traversal -Traversals in Gremlin are spawned from a TraversalSource. The GraphTraversalSource is the typical "graph-oriented" DSL used throughout the documentation and will most likely be the most used DSL in a TinkerPop application. +Traversals in Gremlin are spawned from a `TraversalSource`. The `GraphTraversalSource` is the typical "graph-oriented" DSL used throughout the documentation and will most likely be the most used DSL in a TinkerPop application. To run a query in Graph with Gremlin, there are traversal interfaces. These interfaces are lazy; in other words, they just run after any finalizing method. -E.g.: - -In the scenario, there is a marketing campaign, and the target is: +For example, In this scenario, there is a marketing campaign, and the target is: * An engineer * The salary is higher than $3,000 @@ -90,7 +88,7 @@ List developers = graph.getTraversalVertex() ---- -To use a graph template, just follow the CDI style and put an `@Inject` on the field. +To use a graph template, just follow the CDI style and precede the field with the `@Inject` annotation. [source,java] ---- @@ -98,20 +96,20 @@ To use a graph template, just follow the CDI style and put an `@Inject` on the f private GraphTemplate template; ---- -The next step: make a *Graph* instance eligible to CDI, applying the producers method: +The next step: make a `Graph` instance eligible to CDI, applying the producers method: [source,java] ---- @Produces public Graph getManager() { - Graph graph = //instance; + Graph graph = // instance; return graph; } ---- -To work with more than one Graph Template, there are two approaches: +To work with more than one graph template, there are two approaches: -1) Using qualifiers: +1) Use qualifiers: [source,java] ---- @@ -123,23 +121,23 @@ private GraphTemplate templateA; @Database(value = DatabaseType.GRAPH, provider = "databaseB") private GraphTemplate templateB; -//producers methods +// producers methods @Produces @Database(value = DatabaseType.GRAPH, provider = "databaseA") public Graph getManagerA() { - Graph manager = //instance; + Graph manager = // instance; return graph; } @Produces @Database(value = DatabaseType.GRAPH, provider = "databaseB") public Graph getManagerB() { - Graph graph = //instance; + Graph graph = // instance; return graph; } ---- -2) Using the *GraphTemplateProducer* class: +2) Use the `GraphTemplateProducer` class: [source,java] ---- @@ -147,8 +145,8 @@ public Graph getManagerB() { private GraphTemplateProducer producer; public void sample() { - Graph graphA = //instance; - Graph graphB = //instance; + Graph graphA = // instance; + Graph graphB = // instance; GraphTemplate templateA = producer.get(graphA); GraphTemplate templateB = producer.get(graphB); } diff --git a/spec/src/main/asciidoc/template_key_value.adoc b/spec/src/main/asciidoc/template_key_value.adoc index 8ed5624d4..b0e128793 100644 --- a/spec/src/main/asciidoc/template_key_value.adoc +++ b/spec/src/main/asciidoc/template_key_value.adoc @@ -12,9 +12,11 @@ // // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 -==== Key-Value template +==== Key-Value Template -The `KeyValueTemplate` is the template for synchronous tasks. It has three components: The `KeyValueTemplate` is responsible for the persistence of an entity in a key-value database. It is composed basically of three components. +This template has the responsibility to serve as the persistence of an entity in a key-value database. + +The `KeyValueTemplate` is the template for synchronous tasks. It has three components: * *KeyValueEntityConverter*: That converts an entity to communication API, e.g., The Person to KeyValueEntity. * *BucketManager*: The key-value entity manager. @@ -22,7 +24,7 @@ The `KeyValueTemplate` is the template for synchronous tasks. It has three compo [source,java] ---- -KeyValueTemplate template = //instance; +KeyValueTemplate template = // instance; User user = new User(); user.setNickname("ada"); user.setAge(10); @@ -36,9 +38,9 @@ Optional ada = template.get("ada", Person.class); Iterable usersFound = template.get(Collections.singletonList("ada"), Person.class); ---- -WARNING: To key-value templates, both Entity and @Id, are required. The @Id identifies the key, and the whole entity will be the value. The API won't cover how this value persists this entity at NoSQL database. +WARNING: In key-value templates, both the `@Entity` and `@Id` annotations are required. The `@Id` identifies the key, and the whole entity will be the value. The API won't cover how the value persists this entity. -To use a key-value template, just follow the CDI style and put an `@Inject` on the field. +To use a key-value template, just follow the CDI style and precede the field with the `@Inject` annotation. [source,java] ---- @@ -46,18 +48,19 @@ To use a key-value template, just follow the CDI style and put an `@Inject` on t private KeyValueTemplate template; ---- -The next step is to produce a *BucketManager*: +The next step is to produce a `BucketManager`: [source,java] ---- @Produces public BucketManager getManager() { - BucketManager manager = //instance; + BucketManager manager = // instance; return manager; } ---- -To work with more than one key-value Template, there are two approaches: -1) Using qualifiers: +To work with more than one key-value template, there are two approaches: + +1) Use qualifiers: [source,java] ---- @@ -69,25 +72,25 @@ private KeyValueTemplate templateA; @Database(value = DatabaseType.KEY_VALUE, provider = "databaseB") private KeyValueTemplate templateB; -//producers methods +// producers methods @Produces @Database(value = DatabaseType.KEY_VALUE, provider = "databaseA") public BucketManager getManagerA() { - DocumentCollectionManager manager = //instance; + DocumentCollectionManager manager = // instance; return manager; } @Produces @Database(value = DatabaseType.KEY_VALUE, provider = "databaseB") public DocumentCollectionManager getManagerB() { - BucketManager manager = //instance; + BucketManager manager = // instance; return manager; } ---- -2) Using the *KeyValueTemplateProducer* class: +2) Use the `KeyValueTemplateProducer` class: [source,java] ---- @@ -95,8 +98,8 @@ public DocumentCollectionManager getManagerB() { private KeyValueTemplateProducer producer; public void sample() { - BucketManager managerA = //instance; - BucketManager managerB = //instance; + BucketManager managerA = // instance; + BucketManager managerB = // instance; KeyValueTemplate templateA = producer.get(managerA); KeyValueTemplate templateB = producer.get(managerB); }