Example #1
0
 @Override
 public T findById(String id) {
   String s = service.realTimeGet(getIndex(), getType(), id);
   if (s != null) {
     return mapping.get(s, t);
   } else {
     return null;
   }
 }
Example #2
0
 @Override
 public OperationStatus write(WriteOperation builder, List<? extends T> t) {
   // TODO: need to gather operation results and return
   OperationStatus status = new OperationStatus();
   if (t.size() == 1) {
     service.index(
         getIndex(),
         getType(),
         mapping.get(t.get(0)),
         AnnotationHelper.getDocumentId(t.get(0), getIdField()));
   } else if (t.size() > 1) {
     List<String> list = new ArrayList<String>();
     for (T o : t) {
       list.add(mapping.get(o));
       // TODO: what do we do with null ids? bail with exception? Report the error with
       // OperationStatus?
     }
     service.bulkIndex(getIndex(), getType(), list.toArray(new String[list.size()]), getIdField());
   }
   status.setSucceeded(true);
   return status;
 }
Example #3
0
 @Override
 public OperationStatus write(T... t) {
   // TODO: Need to gather results from index operation
   OperationStatus status = new OperationStatus();
   if (t.length == 1) {
     service.index(
         getIndex(),
         getType(),
         mapping.get(t[0]),
         AnnotationHelper.getDocumentId(t[0], getIdField()));
   } else if (t.length > 1) {
     List<String> list = new ArrayList<String>();
     for (T o : t) {
       list.add(mapping.get(o));
       // TODO: what do we do with null ids? bail with exception? Report the error with
       // OperationStatus?
     }
     service.bulkIndex(getIndex(), getType(), list.toArray(new String[list.size()]), getIdField());
   }
   status.setSucceeded(true);
   return status;
 }
Example #4
0
 @Override
 public <T> T find(Query query, Class<T> clazz) {
   String s = service.getSingle(query, getIndex(), getType());
   return mapping.get(s, clazz);
 }
Example #5
0
 @Override
 public T find(Query query) {
   String s = service.getSingle(query, getIndex(), getType());
   return mapping.get(s, t);
 }
Example #6
0
 @Override
 public <T> T findById(String id, Class<T> clazz) {
   String s = service.realTimeGet(getIndex(), getType(), id);
   return mapping.get(s, clazz);
 }