예제 #1
0
파일: ViewQuery.java 프로젝트: rrva/Ektorp
 /**
  * @param Will be JSON-encoded.
  * @return the view query for chained calls
  */
 public ViewQuery endKey(Object o) {
   reset();
   try {
     endKey = mapper.writeValueAsString(o);
   } catch (Exception e) {
     throw Exceptions.propagate(e);
   }
   return this;
 }
예제 #2
0
파일: ViewQuery.java 프로젝트: rrva/Ektorp
 public String toJson(ObjectMapper mapper) {
   ObjectNode rootNode = mapper.createObjectNode();
   ArrayNode keysNode = rootNode.putArray("keys");
   for (Object key : keys) {
     keysNode.addPOJO(key);
   }
   try {
     return mapper.writeValueAsString(rootNode);
   } catch (Exception e) {
     throw Exceptions.propagate(e);
   }
 }
예제 #3
0
 private DesignDocument.View loadViewFromFile(
     Map<String, DesignDocument.View> views, View input, Class<?> repositoryClass) {
   try {
     InputStream in = repositoryClass.getResourceAsStream(input.file());
     if (in == null) {
       throw new FileNotFoundException("Could not load view file with path: " + input.file());
     }
     String json = IOUtils.toString(in, "UTF-8");
     return mapper().readValue(json.replaceAll("\n", ""), DesignDocument.View.class);
   } catch (Exception e) {
     throw Exceptions.propagate(e);
   }
 }