Package ca.carleton.gcrc.couch.client

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


   
    configDesign.getDatabase().createDocument(doc);
  }

  public CouchConfig retrieveConfigurationObject() throws Exception {
    CouchQuery query = new CouchQuery();
    query.setViewName(viewName);
    query.setStartKey(serverName);
    query.setEndKey(serverName);
   
    CouchQueryResults results;
    try {
      results = configDesign.performQuery(query);
    } catch (Exception e) {
View Full Code Here


   
    configDesign.getDatabase().createDocument(doc);
  }

  public CouchConfig retrieveConfigurationObject() throws Exception {
    CouchQuery query = new CouchQuery();
    query.setViewName(viewName);
    query.setStartKey(serverName);
    query.setEndKey(serverName);
   
    CouchQueryResults results;
    try {
      results = configDesign.performQuery(query);
    } catch (Exception e) {
View Full Code Here

   
    // Add all schemas
    {
      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

  }

  @Override
  public JSONObject getUserFromEmailAddress(String emailAddress) throws Exception {
    try {
      CouchQuery query = new CouchQuery();
      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");
View Full Code Here

      return;
    }
   
    // Check users that have agreed to the previous agreement and revoke
    // privilege
    CouchQuery query = new CouchQuery();
    query.setViewName("roles");
    query.setStartKey(agreementRole);
    query.setEndKey(agreementRole);
   
    logger.debug("Looking for users with role: "+agreementRole);
   
    CouchQueryResults results = userDbDesignDocument.performQuery(query);
View Full Code Here

    logger.info("Upload worker thread exiting");
  }
 
  private void activity() {
    CouchQuery query = new CouchQuery();
    query.setViewName("server_work");
   
    CouchQueryResults results;
    try {
      results = dd.performQuery(query);
    } catch (Exception e) {
View Full Code Here

  private Work getWork() throws Exception {
    Map<String,JSONObject> rowsByUploadId = null;

    // 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");
View Full Code Here

    return getUsersWithRoles(roles);
  }
 
  @Override
  public Collection<UserDocument> getUsersWithRoles(List<String> roles) throws Exception {
    CouchQuery query = new CouchQuery();
    query.setViewName("roles");
    query.setIncludeDocs(true);
    query.setReduce(false);
    query.setKeys(roles);
   
    CouchQueryResults results = dd.performQuery(query);
    List<JSONObject> rows = results.getRows();
   
    // Accumulate users
View Full Code Here

    logger.info("Upload worker thread exiting");
  }
 
  private void activity() {
    CouchQuery query = new CouchQuery();
    query.setViewName("server_work");
   
    CouchQueryResults results;
    try {
      results = dd.performQuery(query);
    } catch (Exception e) {
View Full Code Here

      if( stopped ) return;
     
      // Check if any media is waiting for approval
      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);
View Full Code Here

TOP

Related Classes of ca.carleton.gcrc.couch.client.CouchQuery

Copyright © 2018 www.massapicom. 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.