From: Mark G. <mg...@us...> - 2005-09-27 19:25:23
|
Update of /cvsroot/gmod/apollo/src/java/apollo/external In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28959/src/java/apollo/external Modified Files: ApolloControlServlet.java Log Message: http servlet listener now checks chromosome & range to make sure that its the same chromosome loaded and the range is in range - also bounds with min & max of current cur set range. Index: ApolloControlServlet.java =================================================================== RCS file: /cvsroot/gmod/apollo/src/java/apollo/external/ApolloControlServlet.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ApolloControlServlet.java 20 Sep 2005 23:15:14 -0000 1.2 --- ApolloControlServlet.java 27 Sep 2005 19:25:15 -0000 1.3 *************** *** 6,13 **** --- 6,16 ---- import javax.servlet.http.HttpServletResponse; + import apollo.datamodel.CurationSet; + import apollo.dataadapter.Region; import apollo.config.Config; import apollo.gui.Controller; import apollo.gui.event.BaseFocusEvent; import apollo.gui.synteny.CurationManager; + import apollo.gui.synteny.GuiCurationState; /** take in http request for a location and load it - *************** *** 35,46 **** private void loadFromRequestMap(Map requestMap) { try { ! String chromosome = getChromosome(requestMap); ! int start = getStart(requestMap); ! int end = getEnd(requestMap); ! debugPrint("got request for chrom "+chromosome+" "+start+"-"+end); ! selectRegionInApollo(chromosome,start,end); } catch (ParameterException e) { ! System.out.println("Loading http request failed. "+e.getMessage()); // popup... } --- 38,49 ---- private void loadFromRequestMap(Map requestMap) { try { ! Region region = getHttpRegion(requestMap); ! debugPrint("got request for "+region); ! // puts region in bounds, throws ex if entirely out of bounds ! checkRegion(region); ! selectRegionInApollo(region); } catch (ParameterException e) { ! System.out.println("Selecting http request failed. "+e.getMessage()); // popup... } *************** *** 58,61 **** --- 61,91 ---- } + private void checkChromosome(String httpChrom) throws ParameterException { + String chr = getCurSet().getChromosome(); + if (!httpChrom.equals(chr)) { + throw new ParameterException("Requested chromosome "+httpChrom+" is not "+ + "currently active("+chr+")"); + } + } + + private void checkRegion(Region region) throws ParameterException { + checkChromosome(region.getChromosome()); // throws ex if wrong chrom + int curStart = getCurSet().getStart(); + int curEnd = getCurSet().getEnd(); + if (region.getEnd() < curStart || region.getStart() > curEnd) + throw new ParameterException("Region "+region+" outside of current region"); + if (region.getStart() < curStart) + region.setStart(curStart); + if (region.getEnd() > curEnd) + region.setEnd(curEnd); + } + + private Region getHttpRegion(Map requestMap) throws ParameterException { + String chrom = getChromosome(requestMap); + int start = getStart(requestMap); + int end = getEnd(requestMap); + return new Region(chrom,start,end); + } + private int getStart(Map requestMap) throws ParameterException { return getNumber(requestMap,"start"); *************** *** 92,104 **** } ! private void selectRegionInApollo(String chrom, int start, int end) { // ??? - check out zoom to selected & BaseFocusEvent... // also query apollo for its current range - see if in range // and query chrom ! BaseFocusEvent bfe = new BaseFocusEvent(this,start,end); //Controller.getMasterController().handleBaseFocusEvent(bfe); ! CurationManager.getActiveCurationState().getController().handleBaseFocusEvent(bfe); } private class ParameterException extends Exception { --- 122,143 ---- } ! private void selectRegionInApollo(Region region) { // ??? - check out zoom to selected & BaseFocusEvent... // also query apollo for its current range - see if in range // and query chrom ! BaseFocusEvent bfe = new BaseFocusEvent(this,region); //Controller.getMasterController().handleBaseFocusEvent(bfe); ! getCurState().getController().handleBaseFocusEvent(bfe); ! } ! ! private GuiCurationState getCurState() { ! return CurationManager.getActiveCurationState(); } + private CurationSet getCurSet() { + return getCurState().getCurationSet(); + } + + private class ParameterException extends Exception { |