Page Menu
Home
HEPForge
Search
Configure Global Search
Log In
Files
F8308670
EasySearch2.java
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Subscribers
None
EasySearch2.java
View Options
package
cedar.hepdata.webapp.pages
;
import
cedar.hepdata.model.*
;
import
cedar.hepdata.xml.*
;
import
cedar.hepdata.db.*
;
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.awt.image.BufferedImage
;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.List
;
import
java.math.BigInteger
;
import
org.apache.tapestry5.ComponentResources
;
import
org.apache.tapestry5.Link
;
import
org.apache.tapestry5.MarkupWriter
;
import
org.apache.tapestry5.StreamResponse
;
//import org.apache.tapestry5.annotations.Inject;
//import org.apache.tapestry5.annotations.Parameter;
import
org.apache.tapestry5.ioc.services.TypeCoercer
;
import
org.apache.tapestry5.dom.Element
;
import
org.apache.tapestry5.services.Response
;
public
class
EasySearch2
{
@Inject
private
RequestGlobals
_reqGlobals
;
@Inject
private
org
.
hibernate
.
Session
_session
;
public
String
getQueryParam
(
String
param
){
return
_reqGlobals
.
getRequest
().
getParameter
(
param
);
}
private
static
String
_finalstate
;
public
String
getInitialState
(){
String
_initialstate
=
_reqGlobals
.
getRequest
().
getParameter
(
"initial"
);
int
j
=
_initialstate
.
lastIndexOf
(
"("
);
if
(
j
>
0
){
_initialstate
=
_initialstate
.
substring
(
0
,
j
-
1
);}
return
_initialstate
;
}
public
String
getCount2
()
{
int
j
=
_finalstates
.
indexOf
(
_dsreaction
);
// System.out.println("size" + _countsfs.size() + " j is " + j + " _finalstate is " + _dsreaction);
BigInteger
_count2
=
_countsfs
.
get
(
j
);
return
_count2
.
toString
();
// return "xxx";
}
//DsReaction
private
static
String
_dsreaction
;
public
String
getDsReaction
()
{
return
_dsreaction
;
}
public
void
setDsReaction
(
String
dsreaction
)
{
_dsreaction
=
dsreaction
;
}
private
List
<
String
>
_dsreactions
=
new
ArrayList
();
private
List
<
String
>
_finalstates
=
new
ArrayList
();
private
List
<
BigInteger
>
_countsre
=
new
ArrayList
();
private
List
<
BigInteger
>
_countsfs
=
new
ArrayList
();
public
List
<
String
>
getDsReactions
(){
String
initialstate
=
getInitialState
();
Query
q
=
null
;
StringBuffer
b
=
new
StringBuffer
();
b
.
append
(
"select DsReactions from DsReactions where DsReactions like '"
);
b
.
append
(
initialstate
);
b
.
append
(
"%' group by DsReactions order by DsReactions"
);
q
=
_session
.
createSQLQuery
(
b
.
toString
());
_dsreactions
=
q
.
list
();
Query
qc
=
null
;
StringBuffer
bc
=
new
StringBuffer
();
bc
.
append
(
"select count(*) from DsReactions where DsReactions like '"
);
bc
.
append
(
initialstate
);
bc
.
append
(
"%' group by DsReactions order by DsReactions"
);
qc
=
_session
.
createSQLQuery
(
bc
.
toString
());
_countsre
=
qc
.
list
();
Iterator
it
=
_dsreactions
.
iterator
();
Iterator
itc
=
_countsre
.
iterator
();
_countsfs
.
clear
();
_finalstates
.
clear
();
while
(
it
.
hasNext
()){
String
_dsreac
=
(
String
)
it
.
next
();
BigInteger
_countre
=
(
BigInteger
)
itc
.
next
();
int
i
=
_dsreac
.
indexOf
(
"-->"
);
if
(
i
>
0
)
{
String
_finalstate
=
_dsreac
.
substring
(
i
+
4
);
System
.
out
.
println
(
_finalstate
);
if
(
!
_finalstates
.
contains
(
_finalstate
)
)
{
_finalstates
.
add
(
_finalstate
);
_countsfs
.
add
(
_countre
);
}
else
{
int
j
=
_finalstates
.
indexOf
(
_finalstate
);
BigInteger
temp
=
_countsfs
.
get
(
j
);
_countsfs
.
set
(
j
,
temp
.
add
(
_countre
));
}
}
}
return
_finalstates
;
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 21, 12:50 PM (1 d, 21 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4022828
Default Alt Text
EasySearch2.java (3 KB)
Attached To
rHEPDATASVN hepdatasvn
Event Timeline
Log In to Comment