Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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.getEvalContextWithHereFuncHandler(),
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 @@ -229,7 +228,7 @@ private void setPeristenMenuToBean(BaseResponseBean menuResponseBean, ArrayList<
private void addHereFuncHandler(EntityScreen nextScreen, MenuSession menuSession) {
EvaluationContext ec = nextScreen.getEvalContext();
ec.addFunctionHandler(
new FormplayerHereFunctionHandler(menuSession, menuSession.getCurrentBrowserLocation()));
new ScreenUtils.HereDummyFunc(-23.56, -46.66));
}

@Trace
Expand Down
30 changes: 2 additions & 28 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,35 +459,10 @@ 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));
ec.addFunctionHandler(new ScreenUtils.HereDummyFunc(-23.56, -46.66));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this method be still called ? If not think we should we hard crash here instead with a IllegalStateException so that we know this code is indeed not being used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are fine with getting an error when somebody does end up using the here() function, then yes. This could just be removed and all getEvalContextWithHereFuncHandler could be replaced with getSessionWrapper().getEvaluationContext().

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do think if we are not going to support here, it should result into a very explicit error on Web Apps UI when someone does use it instead of giving an impression that everything is fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chatted with Woody and he thinks it would be better to throw the exception.

return ec;
}

Expand Down

This file was deleted.

Loading