Examples of CouchQueryResults


Examples of ca.carleton.gcrc.couch.client.CouchQueryResults

    CouchQuery query = new CouchQuery();
    query.setViewName(viewName);
    query.setStartKey(serverName);
    query.setEndKey(serverName);
   
    CouchQueryResults results;
    try {
      results = configDesign.performQuery(query);
    } catch (Exception e) {
      throw new Exception("Error accessing view: "+viewName,e);
    }
   
    // Analyze configuration
    if( results.getRows().size() < 1 ) {
      throw new Exception("Configuration with id "+serverName+" not found.");
    }
    CouchConfig config = null;
    try {
      JSONObject row = results.getRows().get(0);
      JSONObject doc = row.getJSONObject("value");

      config = parseJSON(doc);

    } catch(Exception e) {
View Full Code Here

Examples of ca.carleton.gcrc.couch.client.CouchQueryResults

    CouchQuery query = new CouchQuery();
    query.setViewName(viewName);
    query.setStartKey(serverName);
    query.setEndKey(serverName);
   
    CouchQueryResults results;
    try {
      results = configDesign.performQuery(query);
    } catch (Exception e) {
      throw new Exception("Error accessing view: "+viewName,e);
    }
   
    // Analyze configuration
    if( results.getRows().size() < 1 ) {
      throw new Exception("Configuration with id "+serverName+" not found.");
    }
    CouchConfig config = null;
    try {
      JSONObject row = results.getRows().get(0);
      JSONObject doc = row.getJSONObject("value");

      config = parseJSON(doc);

    } catch(Exception e) {
View Full Code Here

Examples of ca.carleton.gcrc.couch.client.CouchQueryResults

    {
      logger.debug("Obtain list of all schemas");
      CouchDesignDocument designDoc = couchDb.getDesignDocument("atlas");
      CouchQuery query = new CouchQuery();
      query.setViewName("schemas");
      CouchQueryResults results = designDoc.performQuery(query);
      List<JSONObject> rows = results.getRows();
      for(JSONObject row : rows){
        String docId = row.getString("id");
        docIds.add(docId);
      }
    }
   
    // Add all modules
    {
      logger.debug("Obtain list of all modules");
      CouchDesignDocument designDoc = couchDb.getDesignDocument("atlas");
      CouchQuery query = new CouchQuery();
      query.setViewName("modules");
      CouchQueryResults results = designDoc.performQuery(query);
      List<JSONObject> rows = results.getRows();
      for(JSONObject row : rows){
        String docId = row.getString("id");
        docIds.add(docId);
      }
    }
View Full Code Here

Examples of ca.carleton.gcrc.couch.client.CouchQueryResults

      query.setViewName("validated-emails");
      query.setStartKey(emailAddress);
      query.setEndKey(emailAddress);
      query.setIncludeDocs(true);

      CouchQueryResults results = nunaliitUserDesignDocument.performQuery(query);
      List<JSONObject> rows = results.getRows();
      for(JSONObject row : rows){
        JSONObject doc = row.optJSONObject("doc");
        if( null != doc ){
          return doc;
        }
View Full Code Here

Examples of ca.carleton.gcrc.couch.client.CouchQueryResults

    query.setStartKey(agreementRole);
    query.setEndKey(agreementRole);
   
    logger.debug("Looking for users with role: "+agreementRole);
   
    CouchQueryResults results = userDbDesignDocument.performQuery(query);

    if( results.getRows().size() > 0 ) {
      // Find all acceptable agreements
      Set<String> agreementContents =
        AgreementUtils.getContentsFromAgreementDocument(agreementDoc);
     
      for(JSONObject row : results.getRows()){
        String docId = row.optString("id","<no id>");
        try {
          verifyUser(docId, agreementContents);
        } catch(Exception e) {
          logger.error("Unable to process user: "+docId, e);
View Full Code Here

Examples of ca.carleton.gcrc.couch.client.CouchQueryResults

 
  private void activity() {
    CouchQuery query = new CouchQuery();
    query.setViewName("server_work");
   
    CouchQueryResults results;
    try {
      results = dd.performQuery(query);
    } catch (Exception e) {
      logger.error("Error accessing server",e);
      waitMillis(60 * 1000); // wait a minute
      return;
    }
   
    // Check for work
    String docId = null;
    JSONArray state = null;
    for(JSONObject row : results.getRows()) {
      String id = row.optString("id");
      if( false == docIdsToSkip.contains(id) ) {
        // Found some work
        docId = id;
        state = row.optJSONArray("key");
View Full Code Here

Examples of ca.carleton.gcrc.couch.client.CouchQueryResults

    // Deal with document database
    {
      CouchQuery query = new CouchQuery();
      query.setViewName("server_work");
     
      CouchQueryResults results;
      results = documentDbDesign.performQuery(query);
      rowsByUploadId = findUploadIds(results);
         
      for(JSONObject row : results.getRows()) {
        String id = row.optString("id");
       
        String state = null;
        String attachmentName = null;
        JSONArray key = row.optJSONArray("key");
        if( null != key ){
          if( key.length() > 0 ){
            state = key.getString(0);
          }
          if( key.length() > 1 ){
            attachmentName = key.getString(1);
          }
        };
       
        // Discount documents in error state
        synchronized(this) {
          if( docIdsToSkip.contains(id) ) {
            continue;
          }
        }
       
        if( UploadConstants.UPLOAD_STATUS_WAITING_FOR_UPLOAD.equals(state) ) {
          // In the case of "waiting_for_upload", the attachment name
          // refers to the uploadId
          JSONObject uploadIdRow = rowsByUploadId.get(attachmentName);
          if( null == uploadIdRow ) {
            // Missing information to continue
            continue;
          } else {
            String uploadRequestDocId = uploadIdRow.getString("id");
           
            WorkDocumentDb work = new WorkDocumentDb(documentDbDesign, state, id);
            work.setUploadId(attachmentName);
            work.setUploadRequestDocId(uploadRequestDocId);
            return work;
          }
         
        } else if( UploadConstants.UPLOAD_WORK_UPLOADED_FILE.equals(state) ) {
          // Ignore
          continue;
         
        } else {
          // Everything else
          WorkDocumentDb work = new WorkDocumentDb(documentDbDesign, state, id);
          work.setAttachmentName(attachmentName);
          return work;
        }
      }
    }
   
    // At this point, no work found in the document database. Look in the
    // submission database, if present
    if( null != submissionDbDesign ){
      CouchQuery query = new CouchQuery();
      query.setViewName("upload-work");
     
      CouchQueryResults results = submissionDbDesign.performQuery(query);
     
      for(JSONObject row : results.getRows()) {
        String id = row.optString("id");
       
        String state = null;
        String uploadId = null;
        JSONArray key = row.optJSONArray("key");
View Full Code Here

Examples of ca.carleton.gcrc.couch.client.CouchQueryResults

    query.setViewName("roles");
    query.setIncludeDocs(true);
    query.setReduce(false);
    query.setKeys(roles);
   
    CouchQueryResults results = dd.performQuery(query);
    List<JSONObject> rows = results.getRows();
   
    // Accumulate users
    Map<String,JSONObject> idToUser = new HashMap<String,JSONObject>();
    for(JSONObject row : rows){
      JSONObject doc = row.optJSONObject("doc");
View Full Code Here

Examples of ca.carleton.gcrc.couch.client.CouchQueryResults

 
  private void activity() {
    CouchQuery query = new CouchQuery();
    query.setViewName("server_work");
   
    CouchQueryResults results;
    try {
      results = dd.performQuery(query);
    } catch (Exception e) {
      logger.error("Error accessing server",e);
      waitMillis(60 * 1000); // wait a minute
      return;
    }
   
    // Check for work
    String docId = null;
    JSONArray state = null;
    for(JSONObject row : results.getRows()) {
      String id = row.optString("id");
      if( false == docIdsToSkip.contains(id) ) {
        // Found some work
        docId = id;
        state = row.optJSONArray("key");
View Full Code Here

Examples of ca.carleton.gcrc.couch.client.CouchQueryResults

      int count = 0;
      try {
        CouchQuery query = new CouchQuery();
        query.setViewName("approval");
       
        CouchQueryResults results = serverDesignDoc.performQuery(query);
        count = results.getRows().size();
      } catch(Exception e){
        logger.error("Unable to obtain list of media for approvals",e);
      }
     
      if( count < 1 ){
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.