/*
 * Created on Dec 14, 2004
 */
package uk.org.ponder.rsf.viewstate;

import uk.org.ponder.beanutil.BeanGetter;
import uk.org.ponder.beanutil.PathUtil;
import uk.org.ponder.beanutil.entity.EntityID;
import uk.org.ponder.stringutil.URLUtil;

/**
 * View parameters, which as well as defining the core viewID, are centred 
 * upon a particular entity, defined by Java class and entity ID.
 * @author Antranig Basman (antranig@caret.cam.ac.uk)
 * 
 */
public class EntityCentredViewParameters extends ViewParameters {
  public static final String MODE_NEW = "new";
  public static final String MODE_EDIT = "edit";
  
  public String getParseSpec() {
   return ViewParameters.BASE_PARSE_SPEC + ", mode";
  }

  public void clearParams() {
  }

  public EntityCentredViewParameters(String viewid, EntityID entity, String mode) {
    this.viewID = viewid;
    this.entity = entity;
    this.mode = mode;
  }
  public EntityCentredViewParameters(String viewid, EntityID entity) {
    this(viewid, entity, null);
  }
  
  public EntityCentredViewParameters() {}
  
  public EntityID entity;
  public String mode;
  
  public void parsePathInfo(String pathinfo) {
    String[] pathcomps = URLUtil.splitPathInfo(pathinfo);
    // remove leading / which is specced to be there
    viewID = pathcomps[1];
    entity.ID = pathcomps[2];
  }

  public String toPathInfo() {
    return "/" + viewID + "/" + entity.ID;
  }
  
  public String getELPath() {
    return PathUtil.buildPath(entity.entityname, entity.ID);
  }
  
  /** Fetch the references entity from the supplied beangetter */
  public Object fetch(BeanGetter beangetter) {
    return beangetter.getBean(getELPath());
  }

}
@@ -205,50 +205,8 @@
 ID;%0D
-%0Aimport uk.org.ponder.stringutil.URLUtil;%0D
 %0A%0D%0A/
@@ -671,52 +671,28 @@
  %22, 
-mode%22;%0D%0A  %7D%0D%0A%0D%0A  public void clearParams() %7B
+@1:entity.ID, mode%22;
 %0D%0A  
@@ -863,16 +863,20 @@
 ;%0D%0A  %7D%0D%0A
+  %0D%0A
   public
@@ -1086,320 +1086,8 @@
   %0D%0A
-  public void parsePathInfo(String pathinfo) %7B%0D%0A    String%5B%5D pathcomps = URLUtil.splitPathInfo(pathinfo);%0D%0A    // remove leading / which is specced to be there%0D%0A    viewID = pathcomps%5B1%5D;%0D%0A    entity.ID = pathcomps%5B2%5D;%0D%0A  %7D%0D%0A%0D%0A  public String toPathInfo() %7B%0D%0A    return %22/%22 + viewID + %22/%22 + entity.ID;%0D%0A  %7D%0D%0A  %0D%0A
   pu
@@ -1209,17 +1209,17 @@
 eference
-s
+d
  entity 

Fix to bring ECVP up to new trunk URL idiom