Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
iperdomo committed Oct 24, 2013
2 parents 05cd9fd + 7dffb22 commit 4970a3e
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 5 deletions.
8 changes: 6 additions & 2 deletions Dashboard/app/js/lib/views/reports/report-views.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ FLOW.chartView = FLOW.View.extend({
this.chartType = FLOW.chartTypeControl.content[0];
},

hideChart: function () {
return this.get('noChoiceBool') || this.get('noDataBool');
}.property('noChoiceBool', 'noDataBool'),

getChartData: function () {
// createBarChart();
this.set('noChoiceBool', false);
if (FLOW.selectedControl.get('selectedQuestion') !== null) {
FLOW.surveyQuestionSummaryControl.doSurveyQuestionSummaryQuery(FLOW.selectedControl.selectedQuestion.get('keyId'));
Expand All @@ -41,10 +44,11 @@ FLOW.chartView = FLOW.View.extend({
maxPer, i, tot, totPerc;

deleteChart();

if (FLOW.surveyQuestionSummaryControl.content.get('isLoaded') === true) {
FLOW.chartDataControl.set('total', FLOW.surveyQuestionSummaryControl.content.get('length'));
if (FLOW.chartDataControl.get('total') == 0) {
this.set('noDataBool',true);
this.set('noDataBool', true);
return;
} else {
this.set('noDataBool', false);
Expand Down
4 changes: 2 additions & 2 deletions Dashboard/app/js/templates/application/footer.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<div>
<nav id="footerNav" class="floats-in">
<ul>
<li><a href="http://www.akvo.org/blog/?cat=30" title="Go to News and Software Updates" target="_blank" > {{t _news_and_software_updates}}</a></li>
<li><a href="https://github.com/akvo/akvo-flow/releases" title="Go to News and Software Updates" target="_blank" > {{t _news_and_software_updates}}</a></li>
<li><a href="http://flowhelp.akvo.org" title="Support" target="_blank" > {{t _support}}</a></li>
<li><a href="http://flow.readthedocs.org/en/latest/index.html" title="Documentation and User Guides" target="_blank" >{{t _documentation_and_user_guides}}</a></li>
<li><a href="http://akvo.org/help/akvo-policies-and-terms/akvo-terms-of-use/ " title="Terms of Service" target="_blank" >{{t _terms_of_service}}</a></li>
<li><a href="http://akvo.org/help/akvo-policies-and-terms-2/akvo-terms-of-use/" title="Terms of Service" target="_blank" >{{t _terms_of_service}}</a></li>
<li><a href="http://www.akvo.org" title="akvo.org" target="_blank" class="akvoDotOrg">akvo.org</a></li>
<li><a href="/admin/logout.html">{{t _log_out}}</a></li>
</ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@
<p class="errorMsg">There is no data available for this question. Please select another one.</p>
{{/if}}
<h3 class="chartTitle">{{FLOW.selectedControl.selectedQuestion.text}}</h3>
{{#unless view.hideChart}}
<div id="piechart">
<p>Choose a Question from above selectors.</p>
</div>
{{/unless}}
{{/view}}

<script type="text/javascript">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
import com.gallatinsystems.survey.domain.QuestionGroup;
import com.gallatinsystems.survey.domain.QuestionOption;
import com.gallatinsystems.survey.domain.Survey;
import com.gallatinsystems.surveyal.dao.SurveyedLocaleDao;
import com.gallatinsystems.surveyal.domain.SurveyedLocale;
import com.google.appengine.api.backends.BackendServiceFactory;
import com.google.appengine.api.memcache.MemcacheService;
import com.google.appengine.api.memcache.stdimpl.GCacheFactory;
Expand Down Expand Up @@ -139,6 +141,9 @@ protected RestResponse handleRequest(RestRequest req) throws Exception {
} else if (DataProcessorRequest.DELETE_DUPLICATE_QAS
.equalsIgnoreCase(dpReq.getAction())) {
deleteDuplicatedQAS(dpReq.getOffset());
} else if (DataProcessorRequest.CHANGE_LOCALE_TYPE_ACTION
.equalsIgnoreCase(dpReq.getAction())) {
changeLocaleType(dpReq.getSurveyId());
}
return new RestResponse();
}
Expand Down Expand Up @@ -233,6 +238,46 @@ private void fixDuplicateOtherText() {
} while (cursor != null);
}

/**
* changes the surveyedLocales attached to a survey to a different type
* 1 = Point
* 2 = Household
* 3 = Public Institutions
*/
private void changeLocaleType(Long surveyId) {
SurveyInstanceDAO siDao = new SurveyInstanceDAO();
SurveyedLocaleDao slDao = new SurveyedLocaleDao();
SurveyDAO sDao = new SurveyDAO();
String cursor = null;
// get the desired type from the survey definition
Survey s = sDao.getByKey(surveyId);
if (s != null && s.getPointType() != null && s.getPointType().length() > 0){
String localeType = s.getPointType();

do {
List<SurveyInstance> siList = siDao.listSurveyInstanceBySurvey(surveyId, QAS_PAGE_SIZE, cursor);
List<SurveyedLocale> slList = new ArrayList<SurveyedLocale>();
if (siList != null && siList.size() > 0) {
for (SurveyInstance si : siList) {
if (si.getSurveyedLocaleId() != null) {
SurveyedLocale sl = slDao.getByKey(si.getSurveyedLocaleId());
if (sl != null && !sl.getLocaleType().equals(localeType)) {
sl.setLocaleType(localeType);
slList.add(sl);
}
}
}
slDao.save(slList);
if (siList.size() == QAS_PAGE_SIZE) {
cursor = SurveyInstanceDAO.getCursor(siList);
} else {
cursor = null;
}
}
} while (cursor != null);
}
}

private void fixNullSubmitter() {
SurveyInstanceDAO instDao = new SurveyInstanceDAO();
List<SurveyInstance> instances = instDao.listInstanceBySubmitter(null);
Expand Down
29 changes: 29 additions & 0 deletions GAE/src/org/waterforpeople/mapping/app/web/TestHarnessServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -1711,6 +1711,35 @@ else if ("saveSurveyGroupRefactor".equals(action)) {
} else if ("startProjectFlagUpdate".equals(action)) {
DataProcessorRestServlet.sendProjectUpdateTask(
req.getParameter("country"), null);
} else if ("changeLocaleType".equals(action)) {
String surveyId = req
.getParameter(DataProcessorRequest.SURVEY_ID_PARAM);
if (surveyId == null) {
try {
resp.getWriter()
.println("surveyId parameter missing");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return;
}

TaskOptions options = TaskOptions.Builder.withUrl(
"/app_worker/dataprocessor").param(
DataProcessorRequest.ACTION_PARAM,
DataProcessorRequest.CHANGE_LOCALE_TYPE_ACTION);

if (req.getParameter("bypassBackend") == null
|| !req.getParameter("bypassBackend").equals("true")) {
// change the host so the queue invokes the backend
options = options.header("Host",BackendServiceFactory.getBackendService()
.getBackendAddress("dataprocessor"));
}
options.param(DataProcessorRequest.SURVEY_ID_PARAM, surveyId);
com.google.appengine.api.taskqueue.Queue queue = com.google.appengine.api.taskqueue.QueueFactory
.getDefaultQueue();
queue.add(options);
} else if (DataProcessorRequest.REBUILD_QUESTION_SUMMARY_ACTION
.equals(action)) {
TaskOptions options = TaskOptions.Builder.withUrl(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class DataProcessorRequest extends RestRequest {
public static final String DELTA_PARAM = "delta";
public static final String API_KEY_PARAM = "apiKey";
public static final String OFFSET_PARAM = "offset";
public static final String CHANGE_LOCALE_TYPE_ACTION = "changeLocaleType";

private String country;
private String source;
Expand Down Expand Up @@ -178,5 +179,4 @@ public Long getOffset() {
public void setOffset(Long offset) {
this.offset = offset;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,7 @@ public List<SurveyInstance> listSurveyInstanceBySurvey(Long surveyId,
PersistenceManager pm = PersistenceFilter.getManager();
Query q = pm.newQuery(SurveyInstance.class);
q.setFilter("surveyId == surveyIdParam");
q.setOrdering("createdDateTime asc");
q.declareParameters("Long surveyIdParam");
prepareCursor(cursorString, count, q);
List<SurveyInstance> siList = (List<SurveyInstance>) q
Expand Down
4 changes: 4 additions & 0 deletions GAE/war/WEB-INF/datastore-indexes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,10 @@
<datastore-index kind="SurveyInstance" ancestor="false" >
<property name="surveyId" direction="asc"/>
<property name="collectionDate" direction="desc"/>
</datastore-index>
<datastore-index kind="SurveyInstance" ancestor="false" source="manual">
<property name="surveyId" direction="asc"/>
<property name="createdDateTime" direction="asc"/>
</datastore-index>
<datastore-index kind="SurveyInstance" ancestor="false"
source="auto">
Expand Down

0 comments on commit 4970a3e

Please sign in to comment.