Skip to content
Snippets Groups Projects
Commit a9ace9d7 authored by Rustam Lotsmanenko (EPAM)'s avatar Rustam Lotsmanenko (EPAM)
Browse files

Batch API

parent f4d29ea0
No related branches found
No related tags found
1 merge request!10Batch API
......@@ -45,7 +45,7 @@ The following software have components provided under the terms of this license:
- Guava InternalFutureFailureAccess and InternalFutures (from https://repo1.maven.org/maven2/com/google/guava/failureaccess)
- Guava ListenableFuture only (from https://repo1.maven.org/maven2/com/google/guava/listenablefuture)
- Guava: Google Core Libraries for Java (from http://code.google.com/p/guava-libraries, https://github.com/google/guava, https://repo1.maven.org/maven2/com/google/guava/guava)
- Hibernate Validator (from http://hibernate.org/validator, https://repo1.maven.org/maven2/org/hibernate/hibernate-validator, https://repo1.maven.org/maven2/org/hibernate/validator/hibernate-validator)
- Hibernate Validator (from https://hibernate.org/validator, https://repo1.maven.org/maven2/org/hibernate/hibernate-validator, https://repo1.maven.org/maven2/org/hibernate/validator/hibernate-validator)
- J2ObjC Annotations (from https://github.com/google/j2objc/)
- JBoss Logging 3 (from http://www.jboss.org)
- JJWT :: API (from https://repo1.maven.org/maven2/io/jsonwebtoken/jjwt-api)
......@@ -144,7 +144,7 @@ CC0-1.0
The following software have components provided under the terms of this license:
- Guava: Google Core Libraries for Java (from http://code.google.com/p/guava-libraries, https://github.com/google/guava, https://repo1.maven.org/maven2/com/google/guava/guava)
- Hibernate Validator (from http://hibernate.org/validator, https://repo1.maven.org/maven2/org/hibernate/hibernate-validator, https://repo1.maven.org/maven2/org/hibernate/validator/hibernate-validator)
- Hibernate Validator (from https://hibernate.org/validator, https://repo1.maven.org/maven2/org/hibernate/hibernate-validator, https://repo1.maven.org/maven2/org/hibernate/validator/hibernate-validator)
- Netty/Common (from https://repo1.maven.org/maven2/io/netty/netty-common)
- reactive-streams (from http://www.reactive-streams.org/)
......
......@@ -21,7 +21,7 @@
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>os-osm-core</artifactId>
<version>0.27.0-rc3</version>
<version>0.27.0-rc4</version>
<scope>provided</scope>
</dependency>
<dependency>
......
......@@ -31,6 +31,7 @@ import com.google.cloud.datastore.KeyFactory;
import com.google.cloud.datastore.ProjectionEntity;
import com.google.cloud.datastore.Query;
import com.google.cloud.datastore.QueryResults;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
......@@ -87,6 +88,18 @@ public class DsQueryRunner implements QueryRunner, TransactionProvider {
}
}
@Override
public <E> void create(Destination destination, E... input) throws TranslatorException {
List<SetQuery<E>> queries = Arrays.stream(input).map(i -> new SetQuery<>(i, destination)).toList();
DatastoreReaderWriter datastore = getDatastore(destination);
DsTranslator dsTranslator = translator.getObject();
FullEntity<?>[] entities = new FullEntity[queries.size()];
for (int i = 0; i < entities.length; i++) {
entities[i] = dsTranslator.externalizeEntity(queries.get(i));
}
datastore.add(entities);
}
private <OET> OET upsert(SetQuery<OET> query, boolean returnUpdated) {
final DatastoreReaderWriter datastore = getDatastore(query);
final DsTranslator dsTranslator = translator.getObject();
......@@ -99,6 +112,18 @@ public class DsQueryRunner implements QueryRunner, TransactionProvider {
}
}
@Override
public <E> void upsert(Destination destination, E... input) throws TranslatorException {
List<SetQuery<E>> queries = Arrays.stream(input).map(i -> new SetQuery<>(i, destination)).toList();
DatastoreReaderWriter datastore = getDatastore(destination);
DsTranslator dsTranslator = translator.getObject();
FullEntity<?>[] entities = new FullEntity[queries.size()];
for (int i = 0; i < entities.length; i++) {
entities[i] = dsTranslator.externalizeEntity(queries.get(i));
}
datastore.put(entities);
}
@Override
public <E> void create(SetQuery<E> query) throws TranslatorException {
create(query, false);
......
......@@ -29,7 +29,7 @@
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>os-osm-test-core</artifactId>
<version>0.27.0-rc3</version>
<version>0.27.0-rc4</version>
</dependency>
</dependencies>
......
......@@ -42,7 +42,7 @@ class DsSchemaQueryIT extends SchemaTestBed {
@Test
void simpleSchemaUpsertTest() {
context.upsertAndGet(gages.get(0), destination);
context.upsertAndGet(destination, gages.get(0));
GetQuery<Schema> q = new GetQuery<>(Schema.class, destination,
eq("kind", gages.get(0).getKind()));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment