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

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Thu Mar 27 15:20:24 GMT 2014


Author: whalley
Date: Thu Mar 27 15:20:24 2014
New Revision: 1774

Log:
yoda formatter to reflect irn/ins in the url

Modified:
   trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/AidaFormatter.java
   trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/YodaFormatter.java
   trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/View.java

Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/AidaFormatter.java
==============================================================================
--- trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/AidaFormatter.java	Wed Mar 26 16:25:30 2014	(r1773)
+++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/AidaFormatter.java	Thu Mar 27 15:20:24 2014	(r1774)
@@ -57,7 +57,8 @@
             t_pname.setAttribute("expts", expts);
             t_pname.setAttribute("year", year);
             if(stype.equals("i")) { t_pname.setAttribute("spiresId", "I"+d.getPaper().getInspireId()); } 
-            else { t_pname.setAttribute("spiresId", "S"+d.getPaper().getSpiresId()); }
+            else if (stype.equals("s")) { t_pname.setAttribute("spiresId", "S"+d.getPaper().getSpiresId()); }
+            else { t_pname.setAttribute("spiresId", "0000000"); }
             String pname = t_pname.toString();
             String path = "/REF/" + pname;
 

Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/YodaFormatter.java
==============================================================================
--- trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/YodaFormatter.java	Wed Mar 26 16:25:30 2014	(r1773)
+++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/YodaFormatter.java	Thu Mar 27 15:20:24 2014	(r1774)
@@ -19,23 +19,23 @@
         return s.toString();
     }
 
-    public static String format(Paper p) {
+    public static String format(Paper p,String stype) {
         if (p == null) return null;
-        return format(p.getDatasets());
+        return format(p.getDatasets(),stype);
     }
 
 
-    public static String format(Collection<Dataset> ds) {
+    public static String format(Collection<Dataset> ds,String stype) {
         StringBuffer s = new StringBuffer();
         for (Dataset d : ds) {
-            String dstr = YodaFormatter.format(d);
+            String dstr = YodaFormatter.format(d,stype);
             if (dstr != null) s.append(dstr);
         }
         return s.toString();
     }
 
 
-    public static String format(Dataset d) {
+    public static String format(Dataset d,String stype) {
         String asYODA = null;
         try {
             if (d != null) {
@@ -54,10 +54,9 @@
                 StringTemplate t_pname = new StringTemplate("$expts$$year$_$inspireId$");
                 t_pname.setAttribute("expts", expts);
                 t_pname.setAttribute("year", year);
-                String lead = "";
-                if(pp.getInspireId()!=null)    { t_pname.setAttribute("inspireId", "I"+pp.getInspireId()); lead="I"; }
-                else if(pp.getSpiresId()!=null) { t_pname.setAttribute("inspireId", "I"+pp.getSpiresId()); lead="S"; }
-                else { t_pname.setAttribute("inspireId", "0000000"); lead = "X"; }
+                if(stype.equals("i")) { t_pname.setAttribute("inspireId", "I"+d.getPaper().getInspireId()); } 
+                else if (stype.equals("s")) { t_pname.setAttribute("inspireId", "S"+d.getPaper().getSpiresId()); }
+                else { t_pname.setAttribute("inspireId", "0000000"); }
                 String pname = t_pname.toString();
                 
                 for (XAxis x : d.getXAxes()) {

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 Mar 26 16:25:30 2014	(r1773)
+++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/View.java	Thu Mar 27 15:20:24 2014	(r1774)
@@ -67,7 +67,7 @@
             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();
+            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();
@@ -170,9 +170,9 @@
     public Object getYodaContext() {
         return formatContext("yoda");
     }
-    public StreamResponse asYODA() {
+    public StreamResponse asYODA(String stype) {
         Set<Dataset> ds = getDatasets();
-        String asYODA = YodaFormatter.format(ds);
+        String asYODA = YodaFormatter.format(ds,stype);
         if (asYODA == null) {
             asYODA = "No valid paper and dataset specified";
         }


More information about the HepData-svn mailing list