[HepData-svn] r1408 - trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Thu Oct 14 13:57:36 BST 2010


Author: whalley
Date: Thu Oct 14 13:57:36 2010
New Revision: 1408

Log:
adding jhepwork formatter

Modified:
   trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/View.java
   trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/ViewTest.java

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	Thu Oct  7 09:58:06 2010	(r1407)
+++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/View.java	Thu Oct 14 13:57:36 2010	(r1408)
@@ -36,7 +36,7 @@
         parseBaseViewContext(context);
 
         // Handle pattern parsing separately
-        Pattern patt = Pattern.compile("\\A" + "(short|long|full|plain|yoda|aida|pyroot|root|mpl|bdms|hepml)" + "\\Z",
+        Pattern patt = Pattern.compile("\\A" + "(short|long|full|plain|yoda|aida|pyroot|root|mpl|bdms|hepml|jhepwork)" + "\\Z",
                                        Pattern.CASE_INSENSITIVE);
         for (int i = 0; i < context.getCount(); i++) {
             String ps = context.get(String.class, i);
@@ -51,6 +51,7 @@
         // Now handle the special formats (after parsing *all* context elements)
         String fmt = getQueryParam("format");
         if (fmt != null) {
+            if (fmt.equals("jhepwork")) return asJhepwork();
             if (fmt.equals("hepml")) return asHepML();
             if (fmt.equals("bdms")) return asBDMS();
             if (fmt.equals("plain")) return asPlain();
@@ -82,6 +83,18 @@
 
     ///////////////////////////////////////////////
     //
+    public Object getJhepworkContext() {
+        return formatContext("jhepwork");
+    }
+    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");
     }

Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/ViewTest.java
==============================================================================
--- trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/ViewTest.java	Thu Oct  7 09:58:06 2010	(r1407)
+++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/ViewTest.java	Thu Oct 14 13:57:36 2010	(r1408)
@@ -36,7 +36,7 @@
         parseBaseViewContext(context);
 
         // Handle pattern parsing separately
-        Pattern patt = Pattern.compile("\\A" + "(short|long|full|plain|yoda|aida|pyroot|root|mpl|bdms)" + "\\Z",
+        Pattern patt = Pattern.compile("\\A" + "(short|long|full|plain|yoda|aida|pyroot|root|mpl|bdms|hepml|jhepwork)" + "\\Z",
                                        Pattern.CASE_INSENSITIVE);
         for (int i = 0; i < context.getCount(); i++) {
             String ps = context.get(String.class, i);
@@ -47,10 +47,11 @@
                 setQueryParam("format", "full");
             }
         }
-
         // Now handle the special formats (after parsing *all* context elements)
         String fmt = getQueryParam("format");
         if (fmt != null) {
+            if (fmt.equals("jhepwork")) return asJhepwork();
+            if (fmt.equals("hepml")) return asHepML();
             if (fmt.equals("bdms")) return asBDMS();
             if (fmt.equals("plain")) return asPlain();
             if (fmt.equals("aida")) return asAIDA();
@@ -80,6 +81,30 @@
 
 
     ///////////////////////////////////////////////
+    public Object getJhepworkContext() {
+        return formatContext("jhepwork");
+    }
+    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 getBdmsContext() {
         return formatContext("bdms");


More information about the HepData-svn mailing list