[Nmrshiftdb-devel] CVS: nmrshiftdb/src/java/org/openscience/nmrshiftdb/portlets ResultPortlet.java,1
Brought to you by:
steinbeck
|
From: Stefan K. <sk...@us...> - 2002-05-30 15:08:05
|
Update of /cvsroot/nmrshiftdb/nmrshiftdb/src/java/org/openscience/nmrshiftdb/portlets
In directory usw-pr-cvs1:/tmp/cvs-serv18766/nmrshiftdb/portlets
Modified Files:
ResultPortlet.java SubmitPortlet.java
Log Message:
added MoleculeHyperlink, SpectrumHyperlink, removed fingerprint1-16
Index: ResultPortlet.java
===================================================================
RCS file: /cvsroot/nmrshiftdb/nmrshiftdb/src/java/org/openscience/nmrshiftdb/portlets/ResultPortlet.java,v
retrieving revision 1.70
retrieving revision 1.71
diff -C2 -r1.70 -r1.71
*** ResultPortlet.java 30 May 2002 15:02:22 -0000 1.70
--- ResultPortlet.java 30 May 2002 15:08:00 -0000 1.71
***************
*** 38,42 ****
//The number of molecules displayed per result page (must be an even figure!)
private final int MOLECULES_PER_PAGE = 10;
! private final int PAGES_PER_BROWSE_LINE=15;
--- 38,42 ----
//The number of molecules displayed per result page (must be an even figure!)
private final int MOLECULES_PER_PAGE = 10;
! private final int PAGES_PER_BROWSE_LINE = 15;
***************
*** 116,121 ****
if (session.getAttribute("viewingAction") != null)
{
! spectra=mol.selectSpectra((String)session.getAttribute("fingerprint"));
! }else{
spectra = mol.selectSpectra();
}
--- 116,123 ----
if (session.getAttribute("viewingAction") != null)
{
! spectra = mol.selectSpectra((String) session.getAttribute("fingerprint"));
! }
! else
! {
spectra = mol.selectSpectra();
}
***************
*** 289,293 ****
stmt2.close();
TurbineDB.releaseConnection(dbconn);
! session.setAttribute("fingerprint",fingerprint);
}
catch (Exception ex)
--- 291,295 ----
stmt2.close();
TurbineDB.releaseConnection(dbconn);
! session.setAttribute("fingerprint", fingerprint);
}
catch (Exception ex)
***************
*** 562,629 ****
if (req.getParameter("structuresearch").equals("subsearch"))
{
- /*BigInteger fingerprint1 = SearchUtilities.getBigIntegerValue(Fingerprinter.getFingerprint(mol), 1023);
- BigInteger fingerprint2 = SearchUtilities.getBigIntegerValue(Fingerprinter.getFingerprint(mol), 959);
- BigInteger fingerprint3 = SearchUtilities.getBigIntegerValue(Fingerprinter.getFingerprint(mol), 895);
- BigInteger fingerprint4 = SearchUtilities.getBigIntegerValue(Fingerprinter.getFingerprint(mol), 831);
- BigInteger fingerprint5 = SearchUtilities.getBigIntegerValue(Fingerprinter.getFingerprint(mol), 767);
- BigInteger fingerprint6 = SearchUtilities.getBigIntegerValue(Fingerprinter.getFingerprint(mol), 703);
- BigInteger fingerprint7 = SearchUtilities.getBigIntegerValue(Fingerprinter.getFingerprint(mol), 639);
- BigInteger fingerprint8 = SearchUtilities.getBigIntegerValue(Fingerprinter.getFingerprint(mol), 575);
- BigInteger fingerprint9 = SearchUtilities.getBigIntegerValue(Fingerprinter.getFingerprint(mol), 511);
- BigInteger fingerprint10 = SearchUtilities.getBigIntegerValue(Fingerprinter.getFingerprint(mol), 447);
- BigInteger fingerprint11 = SearchUtilities.getBigIntegerValue(Fingerprinter.getFingerprint(mol), 383);
- BigInteger fingerprint12 = SearchUtilities.getBigIntegerValue(Fingerprinter.getFingerprint(mol), 319);
- BigInteger fingerprint13 = SearchUtilities.getBigIntegerValue(Fingerprinter.getFingerprint(mol), 255);
- BigInteger fingerprint14 = SearchUtilities.getBigIntegerValue(Fingerprinter.getFingerprint(mol), 191);
- BigInteger fingerprint15 = SearchUtilities.getBigIntegerValue(Fingerprinter.getFingerprint(mol), 127);
- BigInteger fingerprint16 = SearchUtilities.getBigIntegerValue(Fingerprinter.getFingerprint(mol), 63);
-
- query = "SELECT DISTINCT MOLECULE.MOLECULE_ID, MOLECULE.STRUCTURE_FILE FROM MOLECULE,SPECTRUM WHERE (FINGERPRINT_1 & ";
- query = query + fingerprint1.longValue() + " = " + fingerprint1.longValue();
- query = query + ") AND (" + "FINGERPRINT_2 & " + fingerprint2.longValue() + " = " + fingerprint2.longValue();
- query = query + ") AND (" + "FINGERPRINT_3 & " + fingerprint3.longValue() + " = " + fingerprint3.longValue();
- query = query + ") AND (" + "FINGERPRINT_4 & " + fingerprint4.longValue() + " = " + fingerprint4.longValue();
- query = query + ") AND (" + "FINGERPRINT_5 & " + fingerprint5.longValue() + " = " + fingerprint5.longValue();
- query = query + ") AND (" + "FINGERPRINT_6 & " + fingerprint6.longValue() + " = " + fingerprint6.longValue();
- query = query + ") AND (" + "FINGERPRINT_7 & " + fingerprint7.longValue() + " = " + fingerprint7.longValue();
- query = query + ") AND (" + "FINGERPRINT_8 & " + fingerprint8.longValue() + " = " + fingerprint8.longValue();
- query = query + ") AND (" + "FINGERPRINT_9 & " + fingerprint9.longValue() + " = " + fingerprint9.longValue();
- query = query + ") AND (" + "FINGERPRINT_10 & " + fingerprint10.longValue() + " = " + fingerprint10.longValue();
- query = query + ") AND (" + "FINGERPRINT_11 & " + fingerprint11.longValue() + " = " + fingerprint11.longValue();
- query = query + ") AND (" + "FINGERPRINT_12 & " + fingerprint12.longValue() + " = " + fingerprint12.longValue();
- query = query + ") AND (" + "FINGERPRINT_13 & " + fingerprint13.longValue() + " = " + fingerprint13.longValue();
- query = query + ") AND (" + "FINGERPRINT_14 & " + fingerprint14.longValue() + " = " + fingerprint14.longValue();
- query = query + ") AND (" + "FINGERPRINT_15 & " + fingerprint15.longValue() + " = " + fingerprint15.longValue();
- query = query + ") AND (" + "FINGERPRINT_16 & " + fingerprint16.longValue() + " = " + fingerprint16.longValue();
- query = query + ") AND SPECTRUM.REVIEW_FLAG = 'true' AND SPECTRUM.MOLECULE_ID = MOLECULE.MOLECULE_ID;";
-
- */
DBConnection dbconn = TurbineDB.getConnection();
java.sql.Statement stmt = dbconn.createStatement();
ResultSet rs;
- ResultSet rs2;
-
- /*z1 = System.currentTimeMillis();
- rs = stmt.executeQuery(query);
- z2 = System.currentTimeMillis();
- z2 = z2 - z1;
- System.err.println("BitSet Zeit : " + z2);*/
-
String fp = (SearchUtilities.getBitString(Fingerprinter.getFingerprint(mol)));
! query = "SELECT DISTINCT MOLECULE.MOLECULE_ID, MOLECULE.STRUCTURE_FILE FROM MOLECULE, SPECTRUM WHERE SPECTRUM.REVIEW_FLAG = 'true' AND fingerprint_compare(MOLECULE.NMRSHIFTDB_NUMBER, " + "\"" + fp + "\"" + ")" + " = \"" + "Y" + "\" AND SPECTRUM.MOLECULE_ID = MOLECULE.MOLECULE_ID;";
! Statement stmt2 = dbconn.createStatement();
z1 = System.currentTimeMillis();
! rs2 = stmt2.executeQuery(query);
z2 = System.currentTimeMillis();
z2 = z2 - z1;
System.err.println("UDF Zeit : " + z2);
//System.err.println("searchBysubstructure query : " + query);
! while (rs2.next())
{
! results.add(rs2.getString(2));
}
stmt.close();
- stmt2.close();
z2 = System.currentTimeMillis();
z2 = z2 - z1;
--- 564,584 ----
if (req.getParameter("structuresearch").equals("subsearch"))
{
DBConnection dbconn = TurbineDB.getConnection();
java.sql.Statement stmt = dbconn.createStatement();
ResultSet rs;
String fp = (SearchUtilities.getBitString(Fingerprinter.getFingerprint(mol)));
! query = "SELECT DISTINCT MOLECULE.MOLECULE_ID, MOLECULE.STRUCTURE_FILE FROM MOLECULE, SPECTRUM WHERE SPECTRUM.REVIEW_FLAG = 'true' AND fingerprint_compare(MOLECULE.FINGERPRINT, " + "\"" + fp + "\"" + ")" + " = \"" + "Y" + "\" AND SPECTRUM.MOLECULE_ID = MOLECULE.MOLECULE_ID;";
z1 = System.currentTimeMillis();
! rs = stmt.executeQuery(query);
z2 = System.currentTimeMillis();
z2 = z2 - z1;
System.err.println("UDF Zeit : " + z2);
//System.err.println("searchBysubstructure query : " + query);
! while (rs.next())
{
! results.add(rs.getString(2));
}
stmt.close();
z2 = System.currentTimeMillis();
z2 = z2 - z1;
***************
*** 680,701 ****
}
//Put together the line for browsing the pages
! String browsingLineStartWith=req.getParameter("browsingLineStartWith");
! if(browsingLineStartWith==null)
! browsingLineStartWith="0";
! int browsingLineStartWithInt=new Integer(browsingLineStartWith).intValue();
! int browsingLineEndWithInt=browsingLineStartWithInt+PAGES_PER_BROWSE_LINE;
! if(browsingLineEndWithInt>numberOfPages)
! browsingLineEndWithInt=(int)numberOfPages;
! if(browsingLineStartWithInt>0)
! browsingLine.append("<a href=\"portal?nmrshiftdbaction=showNewPage&startMolecule=" + startMolecule + "&browsingLineStartWith="+(browsingLineStartWithInt-PAGES_PER_BROWSE_LINE) +"\"><<</a> ");
for (int i = browsingLineStartWithInt; i < browsingLineEndWithInt; i++)
{
! if(i==(startMolecule/MOLECULES_PER_PAGE))
! browsingLine.append("<a style=\"color:red\"><b>"+(i + 1) + "<b></a> ");
else
! browsingLine.append("<a href=\"portal?nmrshiftdbaction=showNewPage&startMolecule=" + i * MOLECULES_PER_PAGE + "&browsingLineStartWith="+browsingLineStartWithInt+"\">" + (i + 1) + "</a> ");
}
- if(browsingLineEndWithInt<numberOfPages)
- browsingLine.append("<a href=\"portal?nmrshiftdbaction=showNewPage&startMolecule=" + startMolecule + "&browsingLineStartWith="+(browsingLineStartWithInt+PAGES_PER_BROWSE_LINE) +"\">>></a> ");
context.put("browsingline", browsingLine);
DecimalFormat format = new DecimalFormat("#,##0.00");
--- 635,672 ----
}
//Put together the line for browsing the pages
! String browsingLineStartWith = req.getParameter("browsingLineStartWith");
! if (browsingLineStartWith == null)
! {
! browsingLineStartWith = "0";
! }
! int browsingLineStartWithInt = new Integer(browsingLineStartWith).intValue();
! int browsingLineEndWithInt = browsingLineStartWithInt + PAGES_PER_BROWSE_LINE;
! if (browsingLineEndWithInt > numberOfPages)
! {
! browsingLineEndWithInt = (int) numberOfPages;
! }
! if (browsingLineStartWithInt > 0)
! {
! browsingLine.append("<a href=\"portal?nmrshiftdbaction=showNewPage&startMolecule=" + startMolecule + "&browsingLineStartWith=" + (browsingLineStartWithInt - PAGES_PER_BROWSE_LINE) + "\"><<</a> ");
! }
for (int i = browsingLineStartWithInt; i < browsingLineEndWithInt; i++)
{
! if (i == (startMolecule / MOLECULES_PER_PAGE))
! {
! browsingLine.append("<a style=\"color:red\"><b>" + (i + 1) + "<b></a> ");
! }
else
! {
! browsingLine.append("<a href=\"portal?nmrshiftdbaction=showNewPage&startMolecule=" + i * MOLECULES_PER_PAGE + "&browsingLineStartWith=" + browsingLineStartWithInt + "\">" + (i + 1) + "</a> ");
! }
! }
! if (browsingLineEndWithInt < numberOfPages)
! {
! browsingLine.append("<a href=\"portal?nmrshiftdbaction=showNewPage&startMolecule=" + startMolecule + "&browsingLineStartWith=" + (browsingLineStartWithInt + 15) + "\">>></a> ");
! }
! if (browsingLineEndWithInt < numberOfPages)
! {
! browsingLine.append("<a href=\"portal?nmrshiftdbaction=showNewPage&startMolecule=" + startMolecule + "&browsingLineStartWith=" + (browsingLineStartWithInt + PAGES_PER_BROWSE_LINE) + "\">>></a> ");
}
context.put("browsingline", browsingLine);
DecimalFormat format = new DecimalFormat("#,##0.00");
Index: SubmitPortlet.java
===================================================================
RCS file: /cvsroot/nmrshiftdb/nmrshiftdb/src/java/org/openscience/nmrshiftdb/portlets/SubmitPortlet.java,v
retrieving revision 1.88
retrieving revision 1.89
diff -C2 -r1.88 -r1.89
*** SubmitPortlet.java 30 May 2002 15:02:22 -0000 1.88
--- SubmitPortlet.java 30 May 2002 15:08:01 -0000 1.89
***************
*** 129,133 ****
}
session.setAttribute("subData", subData);
! action="";
}
//User wants to add a spectrum to a molecule
--- 129,133 ----
}
session.setAttribute("subData", subData);
! action = "";
}
//User wants to add a spectrum to a molecule
***************
*** 143,164 ****
dbmol = (DBMolecule) v.get(0);
subData.setMolecule(dbmol.getStructureFile());
! Molecule molWithOutH=(Molecule) XMLTools.getFromXMLString(new String(dbmol.getSerializedMolecule()));
! //We need to make a molecule with the Hs
! Molecule mol=new Molecule();
! Atom[] atoms=molWithOutH.getAtoms();
! for(int i=0;i<atoms.length;i++){
mol.addAtom(molWithOutH.getAtomAt(i));
}
! for(int i=0;i<atoms.length;i++){
! if(atoms[i].getHydrogenCount()!=0){
! for(int k=0;k<atoms[i].getHydrogenCount();k++){
! Atom h=new Atom("H");
mol.addAtom(h);
! mol.addBond(new Bond(molWithOutH.getAtomAt(i),h,1));
}
}
}
! Bond[] bonds=molWithOutH.getBonds();
! for(int i=0;i<bonds.length;i++){
mol.addBond(molWithOutH.getBondAt(i));
}
--- 143,169 ----
dbmol = (DBMolecule) v.get(0);
subData.setMolecule(dbmol.getStructureFile());
! Molecule molWithOutH = (Molecule) XMLTools.getFromXMLString(new String(dbmol.getSerializedMolecule()));
! //We need to make a molecule with the Hs
! Molecule mol = new Molecule();
! Atom[] atoms = molWithOutH.getAtoms();
! for (int i = 0; i < atoms.length; i++)
! {
mol.addAtom(molWithOutH.getAtomAt(i));
}
! for (int i = 0; i < atoms.length; i++)
! {
! if (atoms[i].getHydrogenCount() != 0)
! {
! for (int k = 0; k < atoms[i].getHydrogenCount(); k++)
! {
! Atom h = new Atom("H");
mol.addAtom(h);
! mol.addBond(new Bond(molWithOutH.getAtomAt(i), h, 1));
}
}
}
! Bond[] bonds = molWithOutH.getBonds();
! for (int i = 0; i < bonds.length; i++)
! {
mol.addBond(molWithOutH.getBondAt(i));
}
***************
*** 304,311 ****
//Very convenient for debugging - after typing it a second time I decided to keep it
/*
! for(int i=0;i<subData.getSignalstable().size();i++){
! System.err.println(((ValueTriple)subData.getSignalstable().get(i)).toString());
! }
! */
subData.setLevel(4);
returnValue = submitPage(messages, subData, runData, session);
--- 309,316 ----
//Very convenient for debugging - after typing it a second time I decided to keep it
/*
! * for(int i=0;i<subData.getSignalstable().size();i++){
! * System.err.println(((ValueTriple)subData.getSignalstable().get(i)).toString());
! * }
! */
subData.setLevel(4);
returnValue = submitPage(messages, subData, runData, session);
***************
*** 587,607 ****
//This dates are used whenever the creation date is needed
! Date now=new Date();
! String time=new String(System.currentTimeMillis()+"");
! String nmrshiftdbnr=javax.servlet.http.HttpUtils.getRequestURL(req)+"_"+((NmrshiftdbUser) runData.getUser()).getUserName()+"_"+now.toString()+"."+time.substring(time.length()-4)+"ms";
! Vector chemNames=null;
! DBAtom[] dbatoms=null;
! DBBond[] dbbonds=null;
! DBAtomCount[] dbatomcount=null;
Vector bondAtoms = null;
if (session.getAttribute("existingMolecule") == null)
{
//If the molecule is new, we save it
! dbmol= subData.saveMolecule(mol, molWithH, subData.getMolecule(), now,subData.getCasNumber(),nmrshiftdbnr, userKey, subData.getChemName());
! chemNames=subData.chemNames;
! dbatoms=subData.dbatoms;
! dbbonds=subData.dbbonds;
! dbatomcount=subData.dbatomcount;
! bondAtoms=subData.bondAtoms;
}
else
--- 592,612 ----
//This dates are used whenever the creation date is needed
! Date now = new Date();
! String time = new String(System.currentTimeMillis() + "");
! String nmrshiftdbnr = javax.servlet.http.HttpUtils.getRequestURL(req) + "_" + ((NmrshiftdbUser) runData.getUser()).getUserName() + "_" + now.toString() + "." + time.substring(time.length() - 4) + "ms";
! Vector chemNames = null;
! DBAtom[] dbatoms = null;
! DBBond[] dbbonds = null;
! DBAtomCount[] dbatomcount = null;
Vector bondAtoms = null;
if (session.getAttribute("existingMolecule") == null)
{
//If the molecule is new, we save it
! dbmol = subData.saveMolecule(mol, molWithH, subData.getMolecule(), now, subData.getCasNumber(), nmrshiftdbnr, userKey, subData.getChemName());
! chemNames = subData.chemNames;
! dbatoms = subData.dbatoms;
! dbbonds = subData.dbbonds;
! dbatomcount = subData.dbatomcount;
! bondAtoms = subData.bondAtoms;
}
else
***************
*** 618,622 ****
dbatoms[i] = (DBAtom) v.get(i);
}
! subData.dbatoms=dbatoms;
//And also the bonds
crit = new Criteria();
--- 623,627 ----
dbatoms[i] = (DBAtom) v.get(i);
}
! subData.dbatoms = dbatoms;
//And also the bonds
crit = new Criteria();
***************
*** 628,632 ****
dbbonds[i] = (DBBond) v.get(i);
}
! subData.dbbonds=dbbonds;
//And the bondAtoms
Criteria critSignals = new Criteria();
--- 633,637 ----
dbbonds[i] = (DBBond) v.get(i);
}
! subData.dbbonds = dbbonds;
//And the bondAtoms
Criteria critSignals = new Criteria();
***************
*** 668,672 ****
if (session.getAttribute("onesubmit") != null)
{
! NmrshiftdbUser user=(NmrshiftdbUser)session.getAttribute("onesubmit");
runData.setUser(user);
user.setHasLoggedIn(new Boolean(true));
--- 673,677 ----
if (session.getAttribute("onesubmit") != null)
{
! NmrshiftdbUser user = (NmrshiftdbUser) session.getAttribute("onesubmit");
runData.setUser(user);
user.setHasLoggedIn(new Boolean(true));
***************
*** 683,687 ****
NmrshiftdbUser reviewer = (NmrshiftdbUser) reviewers.get(new Double("" + (Math.random() * reviewers.size())).intValue());
//Save the review assignment
! DBUserDBSpectrum reviewAssignment=new DBUserDBSpectrum();
reviewAssignment.setDBSpectrum(spectrum);
reviewAssignment.setNmrshiftdbUser(reviewer);
--- 688,692 ----
NmrshiftdbUser reviewer = (NmrshiftdbUser) reviewers.get(new Double("" + (Math.random() * reviewers.size())).intValue());
//Save the review assignment
! DBUserDBSpectrum reviewAssignment = new DBUserDBSpectrum();
reviewAssignment.setDBSpectrum(spectrum);
reviewAssignment.setNmrshiftdbUser(reviewer);
***************
*** 765,775 ****
//The atoms in the current molecule of the element of the choosen spectrum type
! Vector elementsOfChoosenType=new Vector();
! if(subData.getChoosenSpectrumType()!=null){
! context.put("choosenspectrumtype",subData.getChoosenSpectrumType());
! if (subData.getMolecule() != "") {
! Molecule mol=null;
! try {
! if(session.getAttribute("existingMolecule")==null){
MDLReader mdlreader = new MDLReader(new StringReader(subData.getMolecule()));
mol = (Molecule) mdlreader.read(new Molecule());
--- 770,784 ----
//The atoms in the current molecule of the element of the choosen spectrum type
! Vector elementsOfChoosenType = new Vector();
! if (subData.getChoosenSpectrumType() != null)
! {
! context.put("choosenspectrumtype", subData.getChoosenSpectrumType());
! if (subData.getMolecule() != "")
! {
! Molecule mol = null;
! try
! {
! if (session.getAttribute("existingMolecule") == null)
! {
MDLReader mdlreader = new MDLReader(new StringReader(subData.getMolecule()));
mol = (Molecule) mdlreader.read(new Molecule());
***************
*** 778,787 ****
else
{
- mol = (Molecule) XMLTools.getFromXMLString(((DBMolecule)session.getAttribute("existingMolecule")).getSerializedMolecule());//AtomUtils.assignHs(mol, (DBMolecule)session.getAttribute("existingMolecule"));
}
}
catch (Exception ex)
{
! Log.error("Error in SubmitPortlet.submitPage2: "+ex.getMessage());
return ("An error occured. Please report that bug!");
}
--- 787,795 ----
else
{
}
}
catch (Exception ex)
{
! Log.error("Error in SubmitPortlet.submitPage2: " + ex.getMessage());
return ("An error occured. Please report that bug!");
}
***************
*** 884,889 ****
context.put("assignments", runData.getRequest().getParameter("spectrum"));
}
! context.put("jsarraylength", ""+(subData.getSignalstable().size()+1));
! if (session.getAttribute("existingMolecule") == null) {
context.put("existingmolecule", "false");
}
--- 892,898 ----
context.put("assignments", runData.getRequest().getParameter("spectrum"));
}
! context.put("jsarraylength", "" + (subData.getSignalstable().size() + 1));
! if (session.getAttribute("existingMolecule") == null)
! {
context.put("existingmolecule", "false");
}
|