protected void enqueueUpdate(Object nestedItem, K key, DbSession session) {
if (hasIndex()) {
session.enqueue(new EmbeddedIndexAction<K>(
- this.getIndexType(), IndexAction.Method.UPSERT, nestedItem, key));
+ this.getIndexType(), IndexAction.Method.UPSERT, key, nestedItem));
}
}
public void enqueueDelete(Object nestedItem, K key, DbSession session) {
if (hasIndex()) {
session.enqueue(new EmbeddedIndexAction<K>(
- this.getIndexType(), IndexAction.Method.DELETE, nestedItem, key));
+ this.getIndexType(), IndexAction.Method.DELETE, key, nestedItem));
}
}
public void enqueueInsert(Object nestedItem, K key, DbSession session) {
if (hasIndex()) {
session.enqueue(new EmbeddedIndexAction<K>(
- this.getIndexType(), IndexAction.Method.UPSERT, nestedItem, key));
+ this.getIndexType(), IndexAction.Method.UPSERT, key, nestedItem));
}
}
}
@Override
- public void upsert(Object obj, KEY key) throws Exception {
+ public void upsert(KEY key, Object object, Object... objects) throws Exception {
long t0 = System.currentTimeMillis();
- List<UpdateRequest> requests = this.normalizer.normalizeNested(obj, key);
+ List<UpdateRequest> requests = this.normalizer.normalizeNested(object, key);
long t1 = System.currentTimeMillis();
this.updateDocument(requests, key);
long t2 = System.currentTimeMillis();
LOG.debug("UPSERT [object] time:{}ms ({}ms normalize, {}ms elastic)",
- t2-t0, t1-t0, t2-t1);
+ t2 - t0, t1 - t0, t2 - t1);
}
@Override
- public void upsertByDto(DTO item) {
+ public void upsertByDto(DTO item, DTO... items) {
try {
long t0 = System.currentTimeMillis();
List<UpdateRequest> request = normalizer.normalize(item);
this.updateDocument(request, item.getKey());
long t2 = System.currentTimeMillis();
LOG.debug("UPSERT [dto] time:{}ms ({}ms normalize, {}ms elastic)",
- t2-t0, t1-t0, t2-t1);
+ t2 - t0, t1 - t0, t2 - t1);
} catch (Exception e) {
LOG.error("Could not update document for index {}: {}",
this.getIndexName(), e.getMessage(), e);
}
@Override
- public void upsertByKey(KEY key) {
+ public void upsertByKey(KEY key, KEY... keys) {
try {
this.updateDocument(normalizer.normalize(key), key);
} catch (Exception e) {
}
@Override
- public void delete(Object obj, KEY key) throws Exception {
+ public void delete(KEY key, Object object, Object... objects) throws Exception {
LOG.debug("DELETE NESTED _id:{} in index {}", key, this.getIndexName());
- this.updateDocument(this.normalizer.deleteNested(obj, key), key);
+ this.updateDocument(this.normalizer.deleteNested(object, key), key);
}
@Override
- public void deleteByKey(KEY key) {
+ public void deleteByKey(KEY key, KEY... keys) {
try {
this.deleteDocument(key);
} catch (Exception e) {
}
@Override
- public void deleteByDto(DTO item) {
+ public void deleteByDto(DTO item, DTO... items) {
try {
this.deleteDocument(item.getKey());
} catch (Exception e) {
void refresh();
- void upsert(Object obj, KEY key) throws Exception;
+ void upsert(KEY key, Object object, Object... objects) throws Exception;
- void upsertByKey(KEY key);
+ void upsertByKey(KEY key, KEY... keys);
- void upsertByDto(DTO dto);
+ void upsertByDto(DTO dto, DTO... dtos);
- void delete(Object obj, KEY key) throws Exception;
+ void delete(KEY key, Object object, Object... objects) throws Exception;
- void deleteByKey(KEY key);
+ void deleteByKey(KEY key, KEY... keys);
- void deleteByDto(DTO dto);
+ void deleteByDto(DTO dto, DTO... dtos);
Date getLastSynchronization();
public class DtoIndexAction<E extends Dto> extends IndexAction {
private final E item;
+ private final E[] items;
- public DtoIndexAction(String indexType, Method method, E item) {
+ public DtoIndexAction(String indexType, Method method, E item, E... items) {
super(indexType, method);
this.item = item;
+ this.items = items;
}
@Override
public void doExecute() {
try {
if (this.getMethod().equals(Method.DELETE)) {
- index.deleteByDto(this.item);
+ index.deleteByDto(this.item, this.items);
} else if (this.getMethod().equals(Method.UPSERT)) {
- index.upsertByDto(this.item);
+ index.upsertByDto(this.item, this.items);
}
} catch (Exception e) {
throw new IllegalStateException(this.getClass().getSimpleName() +
public class EmbeddedIndexAction<K extends Serializable> extends IndexAction {
- private final Object item;
private final K key;
+ private final Object item;
+ private final Object[] items;
- public EmbeddedIndexAction(String indexType, Method method, Object item, K key) {
+ public EmbeddedIndexAction(String indexType, Method method, K key, Object item, Object... items) {
super(indexType, method);
this.indexType = indexType;
this.method = method;
this.key = key;
this.item = item;
+ this.items = items;
}
@Override
try {
if (this.getMethod().equals(Method.DELETE)) {
- index.delete(this.item, this.key);
+ index.delete(this.key, this.item, this.items);
} else if (this.getMethod().equals(Method.UPSERT)) {
- index.upsert(this.item, this.key);
+ index.upsert(this.key, this.item, this.items);
}
} catch (Exception e) {
throw new IllegalStateException(this.getClass().getSimpleName() +
public class KeyIndexAction<K extends Serializable> extends IndexAction {
private final K key;
+ private final K[] keys;
- public KeyIndexAction(String indexType, Method method, K key) {
+ public KeyIndexAction(String indexType, Method method, K key, K... keys) {
super(indexType, method);
this.key = key;
+ this.keys = keys;
}
@Override
public void doExecute() {
try {
if (this.getMethod().equals(Method.DELETE)) {
- index.deleteByKey(this.key);
+ index.deleteByKey(this.key, this.keys);
} else if (this.getMethod().equals(Method.UPSERT)) {
- index.upsertByKey(this.key);
+ index.upsertByKey(this.key, this.keys);
}
} catch (Exception e) {
throw new IllegalStateException(this.getClass().getSimpleName() +