Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.commcare.formplayer.beans.menus.BaseResponseBean;
import org.commcare.formplayer.beans.menus.EntityDetailListResponse;
import org.commcare.formplayer.beans.menus.EntityDetailResponse;
import org.commcare.formplayer.beans.menus.LocationRelevantResponseBean;
import org.commcare.formplayer.services.FormplayerStorageFactory;
import org.commcare.formplayer.services.MenuSessionFactory;
import org.commcare.formplayer.services.ResponseMetaDataTracker;
Expand Down Expand Up @@ -93,7 +92,7 @@ public EntityDetailListResponse getDetails(@RequestBody SessionNavigationBean se
if (detail == null) {
throw new RuntimeException("Could not get inline details");
}
return setLocationNeeds(detail, menuSession);
return detail;
}

String[] selections = sessionNavigationBean.getSelections();
Expand Down Expand Up @@ -130,7 +129,7 @@ public EntityDetailListResponse getDetails(@RequestBody SessionNavigationBean se
if (detail == null) {
throw new RuntimeException("Tried to get details while not on a case list.");
}
return setLocationNeeds(new EntityDetailListResponse(detail), menuSession);
return new EntityDetailListResponse(detail);
}
EntityScreen entityScreen = (EntityScreen)currentScreen;
TreeReference reference = entityScreen.resolveTreeReference(detailSelection);
Expand All @@ -140,14 +139,11 @@ public EntityDetailListResponse getDetails(@RequestBody SessionNavigationBean se
}

restoreFactory.cacheSessionSelections(selections);
return setLocationNeeds(
new EntityDetailListResponse(entityScreen,
menuSession.getEvalContextWithHereFuncHandler(),
reference,
storageFactory.getPropertyManager().isFuzzySearchEnabled(),
sessionNavigationBean.getIsShortDetail()),
menuSession
);
return new EntityDetailListResponse(entityScreen,
menuSession.getSessionWrapper().getEvaluationContext(),
reference,
storageFactory.getPropertyManager().isFuzzySearchEnabled(),
sessionNavigationBean.getIsShortDetail());
}

/**
Expand Down Expand Up @@ -193,7 +189,7 @@ public BaseResponseBean navigateSessionWithAuth(@RequestBody SessionNavigationBe
return formSubmissionResponse;
} else {
notificationLogger.logNotification(response.getNotification(), request);
return setLocationNeeds(response, menuSession);
return response;
}
}

Expand All @@ -217,13 +213,6 @@ private SubmitResponseBean handleAutoFormSubmission(HttpServletRequest request,
return null;
}

private static <T extends LocationRelevantResponseBean> T setLocationNeeds(T responseBean,
MenuSession menuSession) {
responseBean.setShouldRequestLocation(menuSession.locationRequestNeeded());
responseBean.setShouldWatchLocation(menuSession.hereFunctionEvaluated());
return responseBean;
}

@RequestMapping(value = Constants.URL_GET_ENDPOINT, method = RequestMethod.POST)
@UserLock
@UserRestore
Expand All @@ -246,7 +235,7 @@ public BaseResponseBean navigateToEndpoint(@RequestBody SessionNavigationBean se
return formSubmissionResponse;
} else {
notificationLogger.logNotification(response.getNotification(), request);
return setLocationNeeds(response, menuSession);
return response;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.commcare.formplayer.beans;

import org.commcare.formplayer.beans.menus.LocationRelevantResponseBean;
import org.commcare.formplayer.exceptions.ApplicationConfigException;
import org.commcare.formplayer.util.Constants;
import org.commcare.formplayer.util.FormplayerSentry;
Expand All @@ -25,7 +24,7 @@
/**
* Created by willpride on 1/20/16.
*/
public class EvaluateXPathResponseBean extends LocationRelevantResponseBean {
public class EvaluateXPathResponseBean {
private String output;
private String status;
private String contentType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package org.commcare.formplayer.beans.debugger;

import org.commcare.formplayer.beans.menus.LocationRelevantResponseBean;

import java.util.HashSet;
import java.util.List;

/**
* Response for the debugger tab
*/
public class MenuDebuggerContentResponseBean extends LocationRelevantResponseBean {
public class MenuDebuggerContentResponseBean {
private String appId;
private AutoCompletableItem[] autoCompletableItems;
private XPathQueryItem[] recentXPathQueries;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* end should redirect to the app home NOTE: clearSession causes all other displayables to be
* disregarded
*/
public class BaseResponseBean extends LocationRelevantResponseBean {
public class BaseResponseBean {
protected NotificationMessage notification;
protected String title;
protected boolean clearSession;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/**
* Created by willpride on 1/4/17.
*/
public class EntityDetailListResponse extends LocationRelevantResponseBean {
public class EntityDetailListResponse {

private EntityDetailResponse[] entityDetailList;
private boolean isPersistentDetail;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ public MenuSession buildSession(SerializableMenuSession serializableMenuSession,
@Trace
public MenuSession getMenuSessionFromBean(SessionNavigationBean sessionNavigationBean) throws Exception {
MenuSession menuSession = performInstall(sessionNavigationBean);
menuSession.setCurrentBrowserLocation(sessionNavigationBean.getGeoLocation());
menuSession.setWindowWidth(sessionNavigationBean.getWindowWidth());
return menuSession;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.commcare.formplayer.session.MenuSession;
import org.commcare.formplayer.util.Constants;
import org.commcare.formplayer.util.FormplayerDatadog;
import org.commcare.formplayer.util.FormplayerHereFunctionHandler;
import org.commcare.formplayer.util.SimpleTimer;
import org.commcare.formplayer.web.client.WebClient;
import org.commcare.modern.session.SessionWrapper;
Expand Down Expand Up @@ -189,7 +188,6 @@ public BaseResponseBean getNextMenu(@Nullable Screen nextScreen, MenuSession men
return getNextMenu(null, menuSession, queryData, entityScreenContext);
}
}
addHereFuncHandler((EntityScreen)nextScreen, menuSession);
menuResponseBean = new EntityListResponse((EntityScreen)nextScreen);
datadog.addRequestScopedTag(Constants.MODULE_TAG, "case_list");
Sentry.setTag(Constants.MODULE_TAG, "case_list");
Expand Down Expand Up @@ -226,12 +224,6 @@ private void setPeristenMenuToBean(BaseResponseBean menuResponseBean, ArrayList<
}
}

private void addHereFuncHandler(EntityScreen nextScreen, MenuSession menuSession) {
EvaluationContext ec = nextScreen.getEvalContext();
ec.addFunctionHandler(
new FormplayerHereFunctionHandler(menuSession, menuSession.getCurrentBrowserLocation()));
}

@Trace
public BaseResponseBean advanceSessionWithSelections(MenuSession menuSession,
String[] selections, QueryData queryData) throws Exception {
Expand Down Expand Up @@ -650,11 +642,11 @@ private static EntityDetailListResponse getDetail(MenuSession menuSession, boole

EvaluationContext ec;
if (inline) {
ec = menuSession.getEvalContextWithHereFuncHandler();
ec = menuSession.getSessionWrapper().getEvaluationContext();
return new EntityDetailListResponse(persistentDetail.getFlattenedDetails(), ec, reference,
isFuzzySearchEnabled);
} else {
ec = new EvaluationContext(menuSession.getEvalContextWithHereFuncHandler(), reference);
ec = new EvaluationContext(menuSession.getSessionWrapper().getEvaluationContext(), reference);
EntityDetailResponse detailResponse = new EntityDetailResponse(persistentDetail, ec);
detailResponse.setHasInlineTile(entityDatum.getInlineDetail() != null);
return new EntityDetailListResponse(detailResponse);
Expand Down Expand Up @@ -723,9 +715,9 @@ private NewFormResponse startFormEntry(MenuSession menuSession) throws Exception

private String getAssertionFailure(MenuSession menuSession) {
Text text = menuSession.getSessionWrapper().getCurrentEntry().getAssertions().getAssertionFailure(
menuSession.getEvalContextWithHereFuncHandler());
menuSession.getSessionWrapper().getEvaluationContext());
if (text != null) {
return text.evaluate(menuSession.getEvalContextWithHereFuncHandler());
return text.evaluate(menuSession.getSessionWrapper().getEvaluationContext());
}
return null;
}
Expand Down
35 changes: 1 addition & 34 deletions src/main/java/org/commcare/formplayer/session/MenuSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.commcare.formplayer.services.FormplayerStorageFactory;
import org.commcare.formplayer.services.InstallService;
import org.commcare.formplayer.services.RestoreFactory;
import org.commcare.formplayer.util.FormplayerHereFunctionHandler;
import org.commcare.formplayer.util.SessionUtils;
import org.commcare.formplayer.util.StringUtils;
import org.commcare.formplayer.util.serializer.SessionSerializer;
Expand Down Expand Up @@ -68,7 +67,7 @@
*
* A lot of this is copied from the CLI. We need to merge that. Big TODO
*/
public class MenuSession implements HereFunctionHandlerListener {
public class MenuSession {
private final SerializableMenuSession session;
private final boolean isPersistentMenuEnabled;
private final boolean isAutoAdvanceMenu;
Expand Down Expand Up @@ -460,38 +459,6 @@ public void setSmartLinkRedirect(String url) {
smartLinkRedirect = url;
}

public void setCurrentBrowserLocation(String location) {
this.currentBrowserLocation = location;
}

public String getCurrentBrowserLocation() {
return this.currentBrowserLocation;
}

@Override
public void onEvalLocationChanged() {
}

@Override
public void onHereFunctionEvaluated() {
this.hereFunctionEvaluated = true;
}

public boolean locationRequestNeeded() {
return this.hereFunctionEvaluated && this.currentBrowserLocation == null;
}

public boolean hereFunctionEvaluated() {
return this.hereFunctionEvaluated;
}

@Trace
public EvaluationContext getEvalContextWithHereFuncHandler() {
EvaluationContext ec = sessionWrapper.getEvaluationContext();
ec.addFunctionHandler(new FormplayerHereFunctionHandler(this, currentBrowserLocation));
return ec;
}

public SerializableMenuSession serialize() {
session.setCommcareSession(SessionSerializer.serialize(sessionWrapper));
return session;
Expand Down

This file was deleted.

Loading