Page Menu
Home
HEPForge
Search
Configure Global Search
Log In
Files
F9501871
View.java
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
18 KB
Subscribers
None
View.java
View Options
package
cedar.hepdata.webapp.pages
;
import
cedar.hepdata.model.*
;
import
cedar.hepdata.util.*
;
import
cedar.hepdata.xml.*
;
import
cedar.hepdata.db.*
;
import
cedar.hepdata.formats.*
;
import
org.apache.tapestry5.EventContext
;
import
org.apache.tapestry5.StreamResponse
;
import
org.apache.tapestry5.util.TextStreamResponse
;
import
org.apache.tapestry5.annotations.*
;
import
org.apache.tapestry5.ioc.annotations.*
;
import
org.apache.tapestry5.services.*
;
import
org.hibernate.*
;
import
org.hibernate.criterion.*
;
import
java.util.*
;
import
java.io.*
;
import
java.util.regex.*
;
import
java.io.File
;
public
class
View
extends
ViewBase
{
// @Inject
// private Request _req;
// public Request getRequest() { return _req; }
// @Inject
// private org.hibernate.Session _session;
// 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
();
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
(
"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
()
{
Paper
p
=
getPaper
();
String
asINPUT
=
InputFormatter
.
format
(
p
);
if
(
asINPUT
==
null
)
{
asINPUT
=
"No valid paper 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
()
{
Set
<
Dataset
>
ds
=
getDatasets
();
String
asYODA
=
YodaFormatter
.
format
(
ds
);
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
;
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Feb 23, 3:13 PM (1 h, 1 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4486876
Default Alt Text
View.java (18 KB)
Attached To
rHEPDATASVN hepdatasvn
Event Timeline
Log In to Comment