[HepData-svn] r1815 - in trunk/hepdata-webapp/src/main: java/cedar/hepdata/formats java/cedar/hepdata/webapp/pages resources/cedar/hepdata/webapp/pages

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Wed Aug 13 15:14:14 BST 2014


Author: watt
Date: Wed Aug 13 15:14:14 2014
New Revision: 1815

Log:
DoiData extends ViewBase

Modified:
   trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/InputFormatter.java
   trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/DoiData.java
   trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/View.java
   trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/View.tml

Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/InputFormatter.java
==============================================================================
--- trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/InputFormatter.java	Wed Aug  6 16:13:15 2014	(r1814)
+++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/InputFormatter.java	Wed Aug 13 15:14:14 2014	(r1815)
@@ -51,7 +51,7 @@
             String dstr = InputFormatter.format(d);
             if (dstr != null) s.append(dstr);
         }
-	s.append("\n*E\n");
+	if(p!=null) { s.append("\n*E\n"); }
         return s.toString();
     }
 

Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/DoiData.java
==============================================================================
--- trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/DoiData.java	Wed Aug  6 16:13:15 2014	(r1814)
+++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/DoiData.java	Wed Aug 13 15:14:14 2014	(r1815)
@@ -20,530 +20,6 @@
 import java.io.File;
 
 
-public class DoiData extends ViewBase {
+public class DoiData extends View {
 
-    // @Inject
-    // private Request _req;
-    // public Request getRequest() { return _req; }
-
-    // @Inject
-    // private org.hibernate.Session _session;
-
-    @InjectPage
-    private SavePlot saveplot;
-
-    // Decode URL context into the params map
-    public StreamResponse onActivate(EventContext context) {
-        // Do the basic parsing via the base class
-        parseBaseViewContext(context);
-
-        // Handle pattern parsing separately
-        Pattern patt = Pattern.compile("\\A" + "(short|long|full|plain.txt|yoda|aida|pyroot.py|root|mpl|bdms|hepml|scavis.py|input|marcxml)" + "\\Z",
-                                       Pattern.CASE_INSENSITIVE);
-        Pattern patt2 = Pattern.compile("\\A" + "(irn\\d+)" + "\\Z",Pattern.CASE_INSENSITIVE);
-        String stype = "i";
-        for (int i = 0; i < context.getCount(); i++) {
-            String ps = context.get(String.class, i);
-            Matcher m = patt.matcher(ps);
-            if (m.matches()) {
-                setQueryParam("format", m.group(1).toLowerCase());
-            } else {
-                setQueryParam("format", "full");
-            }
-            m = patt2.matcher(ps);
-            if (m.matches()) {
-                stype = "s";
-            } 
-        }
-
-        // Now handle the special formats (after parsing *all* context elements)
-        String fmt = getQueryParam("format");
-        if (fmt != null) {
-            if (fmt.equals("scavis.py")) return asJhepwork();
-            if (fmt.equals("hepml")) return asHepML();
-            if (fmt.equals("marcxml")) return asMarcXML();
-            if (fmt.equals("bdms")) return asBDMS();
-            if (fmt.equals("input")) return asINPUT(context);
-            if (fmt.equals("plain.txt")) return asPlain();
-            if (fmt.equals("aida")) return asAIDA(stype);
-            if (fmt.equals("pyroot.py")) return asPyROOT();
-            if (fmt.equals("yoda")) return asYODA(stype);
-            if (fmt.equals("root")) return asROOT();
-            if (fmt.equals("mpl")) return asMatplotlib();
-            //if (fmt.equals("gnuplot")) return asPlain();
-        }
-
-        // Normal rendering
-        return null;
-    }
-
-
-    public Object formatContext(String fmt) {
-        Vector<String> ctx = new Vector<String>(getBaseContext());
-        ctx.add(fmt);
-        return ctx;
-    }
-    public Object getShortContext() {
-        return formatContext("short");
-    }
-    public Object getFullContext() {
-        return getBaseContext();
-    }
-
-
-    ///////////////////////////////////////////////
-    //
-    public Object getJhepworkContext() {
-        return formatContext("scavis.py");
-    }
-    public StreamResponse asJhepwork() {
-        Set<Dataset> ds = getDatasets();
-        String asJhepwork = JhepworkFormatter.format(ds, getQueryX(), getQueryY());
-        if (asJhepwork == null) {
-            asJhepwork = "No valid paper and dataset specified";
-        }
-        return new TextStreamResponse("text/plain", asJhepwork);
-    }
-
-    public Object getHepMLContext() {
-        return formatContext("hepml");
-    }
-    public StreamResponse asHepML() {
-        Paper p = getPaper();
-        String asHepML = HepMLFormatter.format(p);
-        if (asHepML == null) {
-            asHepML = "No valid paper specified";
-        }
-        return new TextStreamResponse("text/plain", asHepML);
-    }
-
-    public Object getMarcXMLContext() {
-        return formatContext("marcxml");
-    }
-    public StreamResponse asMarcXML() {
-        Paper p = getPaper();
-        String asMarcXML = MarcXMLFormatter.format(p);
-        if (asMarcXML == null) {
-            asMarcXML = "No valid paper specified";
-        }
-        return new TextStreamResponse("text/xml", asMarcXML);
-    }
-
-    public Object getBdmsContext() {
-        return formatContext("bdms");
-    }
-    public StreamResponse asBDMS() {
-        Paper p = getPaper();
-        String asBDMS = BdmsFormatter.format(p);
-        if (asBDMS == null) {
-            asBDMS = "No valid paper specified";
-        }
-        return new TextStreamResponse("text/plain", asBDMS);
-    }
-
-    public Object getInputContext() {
-        return formatContext("input");
-    }
-    public StreamResponse asINPUT(EventContext context) {
-        Paper p = null;
-        if(context.getCount()==2) { p = getPaper(); }
-        Set<Dataset> ds = getDatasets();
-        String asINPUT = InputFormatter.format(ds, p);
-        if (asINPUT == null) {
-            asINPUT = "No valid paper and dataset specified";
-        }
-        return new TextStreamResponse("text/plain", asINPUT);
-    }
-
-
-    public Object getPlainContext() {
-        return formatContext("plain.txt");
-    }
-    public StreamResponse asPlain() {
-        Set<Dataset> ds = getDatasets();
-        String asPlain = PlainFormatter.format(ds, getQueryX(), getQueryY());
-        if (asPlain == null) {
-            asPlain = "No valid paper and dataset specified";
-        }
-        return new TextStreamResponse("text/plain", asPlain);
-    }
-
-
-    public Object getYodaContext() {
-        return formatContext("yoda");
-    }
-    public StreamResponse asYODA(String stype) {
-        Set<Dataset> ds = getDatasets();
-        String asYODA = YodaFormatter.format(ds,stype);
-        if (asYODA == null) {
-            asYODA = "No valid paper and dataset specified";
-        }
-        return new TextStreamResponse("text/plain", asYODA);
-    }
-
-
-    public Object getAidaContext() {
-        return formatContext("aida");
-    }
-    public StreamResponse asAIDA(String stype) {
-        Set<Dataset> ds = getDatasets();
-        String asAIDA = AidaFormatter.format(ds,stype);
-        if (asAIDA == null) {
-            asAIDA = "No valid paper and dataset specified";
-        }
-        return new TextStreamResponse("text/xml", asAIDA);
-    }
-
-
-    public Object getRootContext() {
-        return formatContext("root");
-    }
-    public StreamResponse asROOT() {
-        /// @todo This should really be called "asCINT"
-        Set<Dataset> ds = getDatasets();
-        String asRoot = RootFormatter.format(ds);
-        if (asRoot == null) {
-            asRoot = "No valid paper and dataset specified";
-        }
-        return new TextStreamResponse("text/plain", asRoot);
-    }
-
-
-    public Object getMatplotlibContext() {
-        return formatContext("mpl");
-    }
-    public StreamResponse asMatplotlib() {
-        /// @todo This should really be called "asCINT"
-        Set<Dataset> ds = getDatasets();
-        String asMpl = MatplotlibFormatter.format(ds);
-        if (asMpl == null) {
-            asMpl = "No valid paper and dataset specified";
-        }
-        return new TextStreamResponse("text/plain", asMpl);
-    }
-
-
-    public Object getPyRootContext() {
-        return formatContext("pyroot.py");
-    }
-    public StreamResponse asPyROOT() {
-        Set<Dataset> ds = getDatasets();
-        String asPyRoot = PyRootFormatter.format(ds);
-        if (asPyRoot == null) {
-            asPyRoot = "No valid paper and dataset specified";
-        }
-        return new TextStreamResponse("text/plain", asPyRoot);
-    }
-
-
-    //////////////////////////////////////////
-
-
-    public String getFormat() {
-        String fmt = getQueryParam("format");
-        if (fmt == null) fmt = "full";
-        return fmt;
-    }
-
-    public boolean getShortFormat() {
-        return getFormat().equals("short");
-    }
-
-    public boolean getLongFormat() {
-        return getFormat().equals("full");
-    }
-
-    public boolean getShowList() {
-        return getShortFormat();
-    }
-
-
-    public boolean getShowSys() {
-        return getLongFormat();
-    }
-
-    public boolean getHaveSys() {
-        String filename = "/home/whalley/systematics/files/" + getPaper().getSpiresId() + ".sys";
-        File testfile = new File(filename);
-        return testfile.exists();
-    }
-
-
-    public boolean getShowExtra() {
-        return getLongFormat();
-    }
-
-    public boolean getHaveExtraIRN() {
-        String filename = "/home/hepdata/resource/" + getPaper().getSpiresId() + "/index.html";
-        File testfile = new File(filename);
-        return testfile.exists();
-    }
-    
-    public boolean getHaveExtraIRNDesc() {
-        File testfile = new File("/home/hepdata/resource/" + getPaper().getSpiresId() + "/description");
-        return testfile.exists();
-    }
-    public boolean getHaveExtraIRNDesc1() {
-        File testfile = new File("/home/hepdata/resource/" + getPaper().getSpiresId() + "/description1");
-        return testfile.exists();
-    }
-    public boolean getHaveExtraIRNDesc2() {
-        File testfile = new File("/home/hepdata/resource/" + getPaper().getSpiresId() + "/description2");
-        return testfile.exists();
-    }
-    public boolean getHaveExtraIRNDesc3() {
-        File testfile = new File("/home/hepdata/resource/" + getPaper().getSpiresId() + "/description3");
-        return testfile.exists();
-    }
-    public boolean getHaveExtraIRNDesc4() {
-        File testfile = new File("/home/hepdata/resource/" + getPaper().getSpiresId() + "/description4");
-        return testfile.exists();
-    }
-    
-    public boolean getHaveExtraRED() {
-        String filename = "/home/hepdata/resource/" + getPaper().getRedId() + "/index.shtml";
-        File testfile = new File(filename);
-        return testfile.exists();
-    }
-    public boolean getHaveExtraREDDesc() {
-        File testfile = new File("/home/hepdata/resource/" + getPaper().getRedId() + "/description");
-        return testfile.exists();
-    }
-    public boolean getHaveExtraREDDesc1() {
-        File testfile = new File("/home/hepdata/resource/" + getPaper().getRedId() + "/description1");
-        return testfile.exists();
-    }
-    public boolean getHaveExtraREDDesc2() {
-        File testfile = new File("/home/hepdata/resource/" + getPaper().getRedId() + "/description2");
-        return testfile.exists();
-    }
-    public boolean getHaveExtraREDDesc3() {
-        File testfile = new File("/home/hepdata/resource/" + getPaper().getRedId() + "/description3");
-        return testfile.exists();
-    }
-    public boolean getHaveExtraREDDesc4() {
-        File testfile = new File("/home/hepdata/resource/" + getPaper().getRedId() + "/description4");
-        return testfile.exists();
-    }
-
-    public String getShowExtraIRNDesc() {
-        String filename = "/home/hepdata/resource/" + getPaper().getSpiresId() + "/description";
-        File testfile = new File(filename);
-        String line = "";
-        if(testfile.exists()){
-            try {
-               BufferedReader in = new BufferedReader(new FileReader(filename));
-               line = in.readLine();
-               } catch (IOException e){}
-        }
-        return line;
-    }
-    public String getShowExtraIRNDesc1() {
-        String filename = "/home/hepdata/resource/" + getPaper().getSpiresId() + "/description1";
-        File testfile = new File(filename);
-        String line = "";
-        if(testfile.exists()){
-            try {
-               BufferedReader in = new BufferedReader(new FileReader(filename));
-               line = in.readLine();
-               } catch (IOException e){}
-        }
-        return line;
-    }
-    public String getShowExtraIRNLink1() {
-        String filename = "/home/hepdata/resource/" + getPaper().getSpiresId() + "/link1";
-        File testfile = new File(filename);
-        String line = "";
-        if(testfile.exists()){
-            try {
-               BufferedReader in = new BufferedReader(new FileReader(filename));
-               line = in.readLine();
-               } catch (IOException e){}
-        }
-        return line;
-    }
-    public String getShowExtraIRNDesc2() {
-        String filename = "/home/hepdata/resource/" + getPaper().getSpiresId() + "/description2";
-        File testfile = new File(filename);
-        String line = "";
-        if(testfile.exists()){
-            try {
-               BufferedReader in = new BufferedReader(new FileReader(filename));
-               line = in.readLine();
-               } catch (IOException e){}
-        }
-        return line;
-    }
-    public String getShowExtraIRNLink2() {
-        String filename = "/home/hepdata/resource/" + getPaper().getSpiresId() + "/link2";
-        File testfile = new File(filename);
-        String line = "";
-        if(testfile.exists()){
-            try {
-               BufferedReader in = new BufferedReader(new FileReader(filename));
-               line = in.readLine();
-               } catch (IOException e){}
-        }
-        return line;
-    }
-     public String getShowExtraIRNDesc3() {
-        String filename = "/home/hepdata/resource/" + getPaper().getSpiresId() + "/description3";
-        File testfile = new File(filename);
-        String line = "";
-        if(testfile.exists()){
-            try {
-               BufferedReader in = new BufferedReader(new FileReader(filename));
-               line = in.readLine();
-               } catch (IOException e){}
-        }
-        return line;
-    }
-    public String getShowExtraIRNLink3() {
-        String filename = "/home/hepdata/resource/" + getPaper().getSpiresId() + "/link3";
-        File testfile = new File(filename);
-        String line = "";
-        if(testfile.exists()){
-            try {
-               BufferedReader in = new BufferedReader(new FileReader(filename));
-               line = in.readLine();
-               } catch (IOException e){}
-        }
-        return line;
-    }
-     public String getShowExtraIRNDesc4() {
-        String filename = "/home/hepdata/resource/" + getPaper().getSpiresId() + "/description4";
-        File testfile = new File(filename);
-        String line = "";
-        if(testfile.exists()){
-            try {
-               BufferedReader in = new BufferedReader(new FileReader(filename));
-               line = in.readLine();
-               } catch (IOException e){}
-        }
-        return line;
-    }
-    public String getShowExtraIRNLink4() {
-        String filename = "/home/hepdata/resource/" + getPaper().getSpiresId() + "/link4";
-        File testfile = new File(filename);
-        String line = "";
-        if(testfile.exists()){
-            try {
-               BufferedReader in = new BufferedReader(new FileReader(filename));
-               line = in.readLine();
-               } catch (IOException e){}
-        }
-        return line;
-    }
-   public String getShowExtraREDDesc() {
-        String filename = "/home/hepdata/resource/" + getPaper().getRedId() + "/description";
-        File testfile = new File(filename);
-        String line = "";
-        if(testfile.exists()){
-            try {
-               BufferedReader in = new BufferedReader(new FileReader(filename));
-               line = in.readLine();
-               } catch (IOException e){}
-        }
-        return line;
-    }
-    public String getShowExtraREDDesc1() {
-        String filename = "/home/hepdata/resource/" + getPaper().getRedId() + "/description1";
-        File testfile = new File(filename);
-        String line = "";
-        if(testfile.exists()){
-            try {
-               BufferedReader in = new BufferedReader(new FileReader(filename));
-               line = in.readLine();
-               } catch (IOException e){}
-        }
-        return line;
-    }
-    public String getShowExtraREDLink1() {
-        String filename = "/home/hepdata/resource/" + getPaper().getRedId() + "/link1";
-        File testfile = new File(filename);
-        String line = "";
-        if(testfile.exists()){
-            try {
-               BufferedReader in = new BufferedReader(new FileReader(filename));
-               line = in.readLine();
-               } catch (IOException e){}
-        }
-        return line;
-    }
-    public String getShowExtraREDDesc2() {
-        String filename = "/home/hepdata/resource/" + getPaper().getRedId() + "/description2";
-        File testfile = new File(filename);
-        String line = "";
-        if(testfile.exists()){
-            try {
-               BufferedReader in = new BufferedReader(new FileReader(filename));
-               line = in.readLine();
-               } catch (IOException e){}
-        }
-        return line;
-    }
-    public String getShowExtraREDLink2() {
-        String filename = "/home/hepdata/resource/" + getPaper().getRedId() + "/link2";
-        File testfile = new File(filename);
-        String line = "";
-        if(testfile.exists()){
-            try {
-               BufferedReader in = new BufferedReader(new FileReader(filename));
-               line = in.readLine();
-               } catch (IOException e){}
-        }
-        return line;
-    }
-    public String getShowExtraREDDesc3() {
-        String filename = "/home/hepdata/resource/" + getPaper().getRedId() + "/description3";
-        File testfile = new File(filename);
-        String line = "";
-        if(testfile.exists()){
-            try {
-               BufferedReader in = new BufferedReader(new FileReader(filename));
-               line = in.readLine();
-               } catch (IOException e){}
-        }
-        return line;
-    }
-    public String getShowExtraREDLink3() {
-        String filename = "/home/hepdata/resource/" + getPaper().getRedId() + "/link3";
-        File testfile = new File(filename);
-        String line = "";
-        if(testfile.exists()){
-            try {
-               BufferedReader in = new BufferedReader(new FileReader(filename));
-               line = in.readLine();
-               } catch (IOException e){}
-        }
-        return line;
-    }
-    public String getShowExtraREDDesc4() {
-        String filename = "/home/hepdata/resource/" + getPaper().getRedId() + "/description4";
-        File testfile = new File(filename);
-        String line = "";
-        if(testfile.exists()){
-            try {
-               BufferedReader in = new BufferedReader(new FileReader(filename));
-               line = in.readLine();
-               } catch (IOException e){}
-        }
-        return line;
-    }
-    public String getShowExtraREDLink4() {
-        String filename = "/home/hepdata/resource/" + getPaper().getRedId() + "/link4";
-        File testfile = new File(filename);
-        String line = "";
-        if(testfile.exists()){
-            try {
-               BufferedReader in = new BufferedReader(new FileReader(filename));
-               line = in.readLine();
-               } catch (IOException e){}
-        }
-        return line;
-    }
-    
-    public boolean getHaveCurrentPlot(){
-        return saveplot.getHaveSaved();
-    } 
 }

Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/View.java
==============================================================================
--- trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/View.java	Wed Aug  6 16:13:15 2014	(r1814)
+++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/View.java	Wed Aug 13 15:14:14 2014	(r1815)
@@ -35,10 +35,10 @@
     // Decode URL context into the params map
     public StreamResponse onActivate(EventContext context) {
         // Do the basic parsing via the base class
-        for (int ii=0; ii<context.getCount(); ii++){
-           System.out.println("Context: "+context.get(String.class,ii)); 
-           System.out.println("ContextSize: "+context.getCount()); 
-        }  
+        //for (int ii=0; ii<context.getCount(); ii++){
+        //   System.out.println("Context: "+context.get(String.class,ii)); 
+        //   System.out.println("ContextSize: "+context.getCount()); 
+        //}  
         parseBaseViewContext(context);
 
         // Handle pattern parsing separately

Modified: trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/View.tml
==============================================================================
--- trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/View.tml	Wed Aug  6 16:13:15 2014	(r1814)
+++ trunk/hepdata-webapp/src/main/resources/cedar/hepdata/webapp/pages/View.tml	Wed Aug 13 15:14:14 2014	(r1815)
@@ -172,7 +172,7 @@
           <br/>
         </t:if>
         <t:if test="paper.cdsId">
-	      Record in:
+	  Record in:
           <a href=" http://cds.cern.ch/record/${paper.cdsId}"><b>CERN Document Server</b></a>
 	  <br/>
         </t:if>


More information about the HepData-svn mailing list