private Map<String,JSONObject> findUploadIds(CouchQueryResults results) throws Exception { Map<String,JSONObject> rowsByUploadId = new HashMap<String,JSONObject>(); for(JSONObject row : results.getRows()) { String state = null; String uploadId = null; JSONArray key = row.optJSONArray("key"); if( null != key ){ if( key.length() > 0 ){ state = key.getString(0); } if( key.length() > 1 ){ uploadId = key.getString(1); } }; if( UploadConstants.UPLOAD_WORK_UPLOADED_FILE.equals(state) ) { rowsByUploadId.put(uploadId, row); } } return rowsByUploadId; }
@Override public SearchResults getAllDateIntervals() throws Exception { SearchResults results = new SearchResults(); CouchQuery query = new CouchQuery(); query.setViewName("date-index"); query.setIncludeDocs(false); query.setReduce(false); CouchQueryResults queryResults = atlasDesignDocument.performQuery(query); results.documentWithIntervals = new ArrayList<DocumentWithInterval>(queryResults.getRows().size()); for(JSONObject row : queryResults.getRows()){ String docId = row.optString("id"); JSONObject jsonInterval = row.optJSONObject("value"); if( null != docId && null != jsonInterval ){ TimeInterval interval = TimeInterval.fromJson(jsonInterval); DocumentWithInterval docWithInt = new DocumentWithInterval(docId, interval); results.documentWithIntervals.add(docWithInt); } } return results; }
count = results.getRows().size(); } catch(Exception e){ logger.error("Unable to obtain list of media for approvals",e);
@Override public SearchResults getAllDateIntervals() throws Exception { SearchResults results = new SearchResults(); CouchQuery query = new CouchQuery(); query.setViewName("date-index"); query.setIncludeDocs(false); query.setReduce(false); CouchQueryResults queryResults = atlasDesignDocument.performQuery(query); results.documentWithIntervals = new ArrayList<DocumentWithInterval>(queryResults.getRows().size()); for(JSONObject row : queryResults.getRows()){ String docId = row.optString("id"); JSONObject jsonInterval = row.optJSONObject("value"); if( null != docId && null != jsonInterval ){ TimeInterval interval = TimeInterval.fromJson(jsonInterval); DocumentWithInterval docWithInt = new DocumentWithInterval(docId, interval); results.documentWithIntervals.add(docWithInt); } } return results; }
query.setGrouping(true); CouchQueryResults result = atlasDesign.performQuery(query); for(JSONObject row : result.getRows()){ Integer clusterId = null;
query.setKeys(keys); CouchQueryResults result = atlasDesign.performQuery(query); for(JSONObject row : result.getRows()){ String docId = row.getString("id"); Integer elemClusterId = null;
List<JSONObject> rows = results.getRows();
query.setReduce(false); CouchQueryResults result = atlasDesign.performQuery(query); for(JSONObject row : result.getRows()){ String docId = row.getString("id"); Integer clusterId = null;
List<JSONObject> rows = results.getRows(); if( rows.size() < 1 ) { documentsFromSchemaName.put(schemaName, null);
@Override public SearchResults getDateIntervalsIntersectingWith(TimeInterval range, NowReference now) throws Exception { SearchResults results = new SearchResults(); CouchQuery query = new CouchQuery(); query.setViewName("date-index"); query.setIncludeDocs(false); query.setReduce(false); CouchQueryResults queryResults = atlasDesignDocument.performQuery(query); results.documentWithIntervals = new ArrayList<DocumentWithInterval>(queryResults.getRows().size()); for(JSONObject row : queryResults.getRows()){ String docId = row.optString("id"); JSONObject jsonInterval = row.optJSONObject("value"); results.intervalCount++; if( null != docId && null != jsonInterval ){ TimeInterval interval = TimeInterval.fromJson(jsonInterval); if( interval.intersectsWith(range, now) ){ DocumentWithInterval docWithInt = new DocumentWithInterval(docId, interval); results.documentWithIntervals.add(docWithInt); results.intervalMatched++; } } } return results; } }
CouchQueryResults queryResults = atlasDesignDocument.performQuery(query); results.documentWithIntervals = new ArrayList<DocumentWithInterval>(queryResults.getRows().size()); for(JSONObject row : queryResults.getRows()){ String docId = row.optString("id"); JSONObject jsonInterval = row.optJSONObject("value");
static public DocumentRetrieval create(CouchDb couchDb, String layerName) throws Exception { CouchDesignDocument dd = couchDb.getDesignDocument("atlas"); CouchQuery query = new CouchQuery(); query.setViewName("geom-layer"); query.setStartKey(layerName); query.setEndKey(layerName); query.setIncludeDocs(false); CouchQueryResults results = dd.performQuery(query); Set<String> ids = new HashSet<String>(); for(JSONObject row : results.getRows()){ String docId = row.optString("id"); if( null != docId ) { ids.add(docId); } } return new DocumentRetrievalLayer(couchDb, ids.iterator()); }
@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"); if( null != doc ){ return doc; } } throw new Exception("Unable to find user with e-mail address: "+emailAddress); } catch (Exception e) { throw new Exception("Error while searching user with e-mail address: "+emailAddress,e); } }
for(JSONObject row : results.getRows()) { String id = row.optString("id"); if( false == docIdsToSkip.contains(id) ) {
static public DocumentRetrieval create(CouchDb couchDb, String schemaName) throws Exception { CouchDesignDocument dd = couchDb.getDesignDocument("atlas"); CouchQuery query = new CouchQuery(); query.setViewName("nunaliit-schema"); query.setStartKey(schemaName); query.setEndKey(schemaName); query.setIncludeDocs(false); CouchQueryResults results = dd.performQuery(query); Set<String> ids = new HashSet<String>(); for(JSONObject row : results.getRows()){ String docId = row.optString("id"); if( null != docId ) { ids.add(docId); } } return new DocumentRetrievalSchema(couchDb, ids.iterator()); }
query.setViewName("skeleton-docs"); CouchQueryResults results = designDoc.performQuery(query); List<JSONObject> rows = results.getRows(); for(JSONObject row : rows){ String docId = row.getString("id");
query.setViewName("layer-definitions"); CouchQueryResults queryResults = atlasDesign.performQuery(query); for(JSONObject row : queryResults.getRows()){ String layerId = row.getString("key"); if( "public".equals(layerId) ) { query.setGrouping(true); CouchQueryResults queryResults = atlasDesign.performQuery(query); for(JSONObject row : queryResults.getRows()){ String layerId = row.getString("key"); if( false == "public".equals(layerId) ) {