[Nmrshiftdb-devel] CVS: nmrshiftdb/src/java/org/openscience/nmrshiftdb/portlets SubmitPortlet.java,1
Brought to you by:
steinbeck
|
From: Stefan K. <sk...@us...> - 2002-03-06 16:41:23
|
Update of /cvsroot/nmrshiftdb/nmrshiftdb/src/java/org/openscience/nmrshiftdb/portlets
In directory usw-pr-cvs1:/tmp/cvs-serv11083/java/org/openscience/nmrshiftdb/portlets
Modified Files:
SubmitPortlet.java
Log Message:
modified om files
Index: SubmitPortlet.java
===================================================================
RCS file: /cvsroot/nmrshiftdb/nmrshiftdb/src/java/org/openscience/nmrshiftdb/portlets/SubmitPortlet.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** SubmitPortlet.java 5 Mar 2002 09:29:04 -0000 1.7
--- SubmitPortlet.java 6 Mar 2002 16:41:16 -0000 1.8
***************
*** 31,35 ****
* @created 18. Februar 2002
*/
! public class SubmitPortlet extends AbstractPortlet {
/**
* Gets the content attribute of the ResultPortlet object
--- 31,36 ----
* @created 18. Februar 2002
*/
! public class SubmitPortlet extends AbstractPortlet
! {
/**
* Gets the content attribute of the ResultPortlet object
***************
*** 37,42 ****
* @param runData Created by turbine
* @return The content to be displayed as the portlet
*/
! public ConcreteElement getContent(RunData runData) {
HttpServletRequest req = runData.getRequest();
String action = req.getParameter("nmrshiftdbaction");
--- 38,45 ----
* @param runData Created by turbine
* @return The content to be displayed as the portlet
+ * @since
*/
! public ConcreteElement getContent(RunData runData)
! {
HttpServletRequest req = runData.getRequest();
String action = req.getParameter("nmrshiftdbaction");
***************
*** 47,56 ****
String returnValue = "";
//Create new SubmittingData object in case there is none in the session, i. e. no submission currently going on
! if (subData == null) {
subData = new SubmittingData();
session.setAttribute("subData", subData);
}
//User submittet new values for the spectrum
! if (action != null && action.equals("submitSpectrumForAssignment")) {
String spectrum = req.getParameter("spectrum") + '\n';
char[] charSpectrum = spectrum.toCharArray();
--- 50,61 ----
String returnValue = "";
//Create new SubmittingData object in case there is none in the session, i. e. no submission currently going on
! if (subData == null)
! {
subData = new SubmittingData();
session.setAttribute("subData", subData);
}
//User submittet new values for the spectrum
! if (action != null && action.equals("submitSpectrumForAssignment"))
! {
String spectrum = req.getParameter("spectrum") + '\n';
char[] charSpectrum = spectrum.toCharArray();
***************
*** 60,80 ****
boolean addingShift = true;
//The string is parsed
! for (int i = 0; i < charSpectrum.length; i++) {
! if (charSpectrum[i] == ';') {
intensity = "";
addingShift = false;
! } else {
! if (charSpectrum[i] == '\n') {
IntTriple figures = new IntTriple();
! if (shift.trim() != "") {
! try {
figures.value1 = (new Integer(shift.trim())).intValue();
! if (intensity.trim() == "") {
figures.value2 = 0;
! } else {
figures.value2 = (new Integer(intensity.trim())).intValue();
}
numberSpectrum.add(figures);
! } catch (NumberFormatException ex) {
messages += "Your input included wrong characters!<br>";
}
--- 65,97 ----
boolean addingShift = true;
//The string is parsed
! for (int i = 0; i < charSpectrum.length; i++)
! {
! if (charSpectrum[i] == ';')
! {
intensity = "";
addingShift = false;
! }
! else
! {
! if (charSpectrum[i] == '\n')
! {
IntTriple figures = new IntTriple();
! if (shift.trim() != "")
! {
! try
! {
figures.value1 = (new Integer(shift.trim())).intValue();
! if (intensity.trim() == "")
! {
figures.value2 = 0;
! }
! else
! {
figures.value2 = (new Integer(intensity.trim())).intValue();
}
numberSpectrum.add(figures);
! }
! catch (NumberFormatException ex)
! {
messages += "Your input included wrong characters!<br>";
}
***************
*** 82,89 ****
addingShift = true;
}
! } else {
! if (addingShift) {
shift = shift + charSpectrum[i];
! } else {
intensity = intensity + charSpectrum[i];
}
--- 99,111 ----
addingShift = true;
}
! }
! else
! {
! if (addingShift)
! {
shift = shift + charSpectrum[i];
! }
! else
! {
intensity = intensity + charSpectrum[i];
}
***************
*** 92,96 ****
}
//Values added to the signals table
! for (int i = 0; i < numberSpectrum.size(); i++) {
subData.addToSignalstable(numberSpectrum.get(i));
}
--- 114,119 ----
}
//Values added to the signals table
! for (int i = 0; i < numberSpectrum.size(); i++)
! {
subData.addToSignalstable(numberSpectrum.get(i));
}
***************
*** 98,106 ****
}
//User submitted new assignments
! if (action != null && action.equals("submitAssignments")) {
! for (int i = 0; i < subData.getSignalstable().size(); i++) {
! if (req.getParameter("atomSelect" + i).equals("none")) {
((IntTriple) subData.getSignalstable().get(i)).value3 = -1;
! } else {
((IntTriple) subData.getSignalstable().get(i)).value3 = new Integer(req.getParameter("atomSelect" + i).trim()).intValue();
}
--- 121,134 ----
}
//User submitted new assignments
! if (action != null && action.equals("submitAssignments"))
! {
! for (int i = 0; i < subData.getSignalstable().size(); i++)
! {
! if (req.getParameter("atomSelect" + i).equals("none"))
! {
((IntTriple) subData.getSignalstable().get(i)).value3 = -1;
! }
! else
! {
((IntTriple) subData.getSignalstable().get(i)).value3 = new Integer(req.getParameter("atomSelect" + i).trim()).intValue();
}
***************
*** 109,138 ****
}
//User submitted a molecule in marvin
! if (action != null && action.equals("submitMolecule")) {
subData.setMolecule(req.getParameter("MolTxt"));
returnValue = submitPage(messages, subData);
}
//User submitted the whole input
! if (action != null && action.equals("submitForConfirm")) {
subData.setSolvent(req.getParameter("solvent"));
subData.setChemName(req.getParameter("chemName"));
String fieldStrengthStr = req.getParameter("fieldStrength");
String temperatureStr = req.getParameter("temperature");
! try {
int fieldStrength = Integer.parseInt(fieldStrengthStr);
subData.setFieldStrength(fieldStrength);
! } catch (NumberFormatException ex) {
messages += "Your field strength is not a decimal figure!";
}
! try {
long temp = Long.parseLong(temperatureStr);
subData.setTemperature(temp);
! } catch (NumberFormatException ex) {
messages += "Your temperature is not a decimal figure!";
}
! if (messages == "") {
//Show confirm screen
returnValue = "Here the data should be reapeated!<form action=\"/jetspeed/portal/\" method=\"post\"><input type=\"hidden\" name=\"nmrshiftdbaction\" value=\"submitSpectrumForDB\"><input type=\"submit\" value=\"Write to Database\"></form>";
! } else {
//Display message and show input screen again
returnValue = submitPage(messages, subData);
--- 137,177 ----
}
//User submitted a molecule in marvin
! if (action != null && action.equals("submitMolecule"))
! {
subData.setMolecule(req.getParameter("MolTxt"));
returnValue = submitPage(messages, subData);
}
//User submitted the whole input
! if (action != null && action.equals("submitForConfirm"))
! {
subData.setSolvent(req.getParameter("solvent"));
subData.setChemName(req.getParameter("chemName"));
String fieldStrengthStr = req.getParameter("fieldStrength");
String temperatureStr = req.getParameter("temperature");
! try
! {
int fieldStrength = Integer.parseInt(fieldStrengthStr);
subData.setFieldStrength(fieldStrength);
! }
! catch (NumberFormatException ex)
! {
messages += "Your field strength is not a decimal figure!";
}
! try
! {
long temp = Long.parseLong(temperatureStr);
subData.setTemperature(temp);
! }
! catch (NumberFormatException ex)
! {
messages += "Your temperature is not a decimal figure!";
}
! if (messages == "")
! {
//Show confirm screen
returnValue = "Here the data should be reapeated!<form action=\"/jetspeed/portal/\" method=\"post\"><input type=\"hidden\" name=\"nmrshiftdbaction\" value=\"submitSpectrumForDB\"><input type=\"submit\" value=\"Write to Database\"></form>";
! }
! else
! {
//Display message and show input screen again
returnValue = submitPage(messages, subData);
***************
*** 140,150 ****
}
//User submittet confirm screen
! if (action != null && action.equals("submitSpectrumForDB")) {
//Log.debug(subData.getMolecule());
MDLReader mdlreader = new MDLReader(new StringReader(subData.getMolecule()));
Molecule mol = new Molecule();
! try {
mol = (Molecule) mdlreader.read(new Molecule());
! } catch (Throwable ex) {
Log.debug("Fehler1: " + ex.getMessage());
StringWriter strWr = new StringWriter();
--- 179,193 ----
}
//User submittet confirm screen
! if (action != null && action.equals("submitSpectrumForDB"))
! {
//Log.debug(subData.getMolecule());
MDLReader mdlreader = new MDLReader(new StringReader(subData.getMolecule()));
Molecule mol = new Molecule();
! try
! {
mol = (Molecule) mdlreader.read(new Molecule());
! }
! catch (Throwable ex)
! {
Log.debug("Fehler1: " + ex.getMessage());
StringWriter strWr = new StringWriter();
***************
*** 154,160 ****
}
//Add molecule to DB
! try {
//Torque.init("/usr/local/jakarta-tomcat-3.3a/webapps/jetspeed/WEB-INF/conf/Torque.properties");
! org.apache.turbine.util.db.pool.DBConnection dbconn=org.apache.turbine.services.db.TurbineDB.getConnection();
System.err.println(dbconn);
Criteria crit = new Criteria();
--- 197,204 ----
}
//Add molecule to DB
! try
! {
//Torque.init("/usr/local/jakarta-tomcat-3.3a/webapps/jetspeed/WEB-INF/conf/Torque.properties");
! org.apache.turbine.util.db.pool.DBConnection dbconn = org.apache.turbine.services.db.TurbineDB.getConnection();
System.err.println(dbconn);
Criteria crit = new Criteria();
***************
*** 181,185 ****
Atom[] atoms = mol.getAtoms();
NumberKey[] nkAtom = new NumberKey[atoms.length];
! for (int i = 0; i < atoms.length; i++) {
crit = new Criteria();
crit.add(DBAtomPeer.SYMBOL, atoms[i].getSymbol());
--- 225,230 ----
Atom[] atoms = mol.getAtoms();
NumberKey[] nkAtom = new NumberKey[atoms.length];
! for (int i = 0; i < atoms.length; i++)
! {
crit = new Criteria();
crit.add(DBAtomPeer.SYMBOL, atoms[i].getSymbol());
***************
*** 191,195 ****
Bond[] bonds = mol.getBonds();
NumberKey[] nkBond = new NumberKey[bonds.length];
! for (int i = 0; i < bonds.length; i++) {
crit = new Criteria();
crit.add(DBBondPeer.DEGREE, bonds[i].getOrder());
--- 236,241 ----
Bond[] bonds = mol.getBonds();
NumberKey[] nkBond = new NumberKey[bonds.length];
! for (int i = 0; i < bonds.length; i++)
! {
crit = new Criteria();
crit.add(DBBondPeer.DEGREE, bonds[i].getOrder());
***************
*** 199,203 ****
//Add bonds-atoms relationship to DB
Atom[] neighbourAtoms = bonds[i].getAtoms();
! for (int k = 0; k < neighbourAtoms.length; k++) {
crit = new Criteria();
crit.add(DBBondDBAtomPeer.BOND_ID, nkBond[i].getValue());
--- 245,250 ----
//Add bonds-atoms relationship to DB
Atom[] neighbourAtoms = bonds[i].getAtoms();
! for (int k = 0; k < neighbourAtoms.length; k++)
! {
crit = new Criteria();
crit.add(DBBondDBAtomPeer.BOND_ID, nkBond[i].getValue());
***************
*** 208,212 ****
//add signals to DB
NumberKey[] nkSignal = new NumberKey[subData.getSignalstable().size()];
! for (int i = 0; i < subData.getSignalstable().size(); i++) {
crit = new Criteria();
crit.add(DBSignalPeer.DIMENSIONALITY, 1);
--- 255,260 ----
//add signals to DB
NumberKey[] nkSignal = new NumberKey[subData.getSignalstable().size()];
! for (int i = 0; i < subData.getSignalstable().size(); i++)
! {
crit = new Criteria();
crit.add(DBSignalPeer.DIMENSIONALITY, 1);
***************
*** 221,225 ****
NumberKey nk = (NumberKey) DBSignalDBAtomPeer.doInsert(crit);
}
! } catch (Exception ex) {
Log.debug("Fehler2: " + ex.getMessage());
StringWriter strWr = new StringWriter();
--- 269,275 ----
NumberKey nk = (NumberKey) DBSignalDBAtomPeer.doInsert(crit);
}
! }
! catch (Exception ex)
! {
Log.debug("Fehler2: " + ex.getMessage());
StringWriter strWr = new StringWriter();
***************
*** 231,235 ****
returnValue = "Your spectrum has been submitted and will be reviewed shortly! Thanks for your contribution! For a new submit <a heref=\"http://localhost:8080/jetspeed/portal/pane0/Submit\">click here</a>";
}
! if (action == null) {
returnValue = submitPage(messages, subData);
}
--- 281,286 ----
returnValue = "Your spectrum has been submitted and will be reviewed shortly! Thanks for your contribution! For a new submit <a heref=\"http://localhost:8080/jetspeed/portal/pane0/Submit\">click here</a>";
}
! if (action == null)
! {
returnValue = submitPage(messages, subData);
}
***************
*** 243,253 ****
* @param o The object to be serialized
* @return The serialized object
*/
! private String serializeObject(Object o) {
StringWriter strWriter = new StringWriter();
! try {
ObjOut out = new ObjOut(false, strWriter);
out.writeObject(o);
! } catch (IOException ex) {
System.out.println(ex.getMessage());
}
--- 294,309 ----
* @param o The object to be serialized
* @return The serialized object
+ * @since
*/
! private String serializeObject(Object o)
! {
StringWriter strWriter = new StringWriter();
! try
! {
ObjOut out = new ObjOut(false, strWriter);
out.writeObject(o);
! }
! catch (IOException ex)
! {
System.out.println(ex.getMessage());
}
***************
*** 262,273 ****
* @param subData submittingData object from session
* @return The content to be displayed as the portlet
*/
! private String submitPage(String messages, SubmittingData subData) {
String returnValue = "";
int tableSize;
//the number of rows the table for the assignments will have (10 is minimum)
! if (subData.getSignalstable().size() < 10) {
tableSize = 10;
! } else {
tableSize = subData.getSignalstable().size() + 2;
}
--- 318,334 ----
* @param subData submittingData object from session
* @return The content to be displayed as the portlet
+ * @since
*/
! private String submitPage(String messages, SubmittingData subData)
! {
String returnValue = "";
int tableSize;
//the number of rows the table for the assignments will have (10 is minimum)
! if (subData.getSignalstable().size() < 10)
! {
tableSize = 10;
! }
! else
! {
tableSize = subData.getSignalstable().size() + 2;
}
***************
*** 304,315 ****
//The mol is put into the MView applet via a file (Problem: If two people write at the same time, the files are messed up)
File outputFile = new File("/usr/local/jakarta-tomcat-3.3a/webapps/jetspeed/nmrshiftdb/temp.mol");
! try {
FileWriter out = new FileWriter(outputFile);
out.write(subData.getMolecule());
out.close();
! } catch (Exception e) {
System.out.println(e.getMessage());
}
! if (!subData.getMolecule().equals("")) {
returnValue += "mview_param(\"mol\",\"temp.mol\");\n";
}
--- 365,380 ----
//The mol is put into the MView applet via a file (Problem: If two people write at the same time, the files are messed up)
File outputFile = new File("/usr/local/jakarta-tomcat-3.3a/webapps/jetspeed/nmrshiftdb/temp.mol");
! try
! {
FileWriter out = new FileWriter(outputFile);
out.write(subData.getMolecule());
out.close();
! }
! catch (Exception e)
! {
System.out.println(e.getMessage());
}
! if (!subData.getMolecule().equals(""))
! {
returnValue += "mview_param(\"mol\",\"temp.mol\");\n";
}
***************
*** 325,339 ****
returnValue += tableSize + "\" valign=\"bottom\">Enter one shift per line, the intensity<br>(optional) seperated by ;<br>like<br>56;4<br>64;6<br><form action=\"/jetspeed/portal/\" name=\"spectrumForm\" method=\"post\"><input type=\"hidden\" name=\"nmrshiftdbaction\" value=\"submitSpectrumForAssignment\"><textarea name=\"spectrum\" cols=\"10\" rows=\"10\"></textarea><br><input type=\"submit\" value=\"Submit the Spectrum\"></form></td></tr>";
returnValue += "<form action=\"/jetspeed/portal/\" method=\"post\"><input type=\"hidden\" name=\"nmrshiftdbaction\" value=\"submitAssignments\">";
! for (int i = 0; i < subData.getSignalstable().size(); i++) {
returnValue += "<tr><td><select name=\"atomSelect" + i + "\" size=\"1\" onChange=\"unselectandselect(this.value)\">";
! if (((IntTriple) subData.getSignalstable().get(i)).value3 == -1) {
returnValue += "<OPTION SELECTED>none</option>";
! } else {
returnValue += "<OPTION>none</option>";
}
! for (int k = 0; k < subData.getSignalstable().size(); k++) {
! if (k == ((IntTriple) subData.getSignalstable().get(i)).value3) {
returnValue += "<option selected>" + (k) + "</option>";
! } else {
returnValue += "<option>" + (k) + "</option>";
}
--- 390,412 ----
returnValue += tableSize + "\" valign=\"bottom\">Enter one shift per line, the intensity<br>(optional) seperated by ;<br>like<br>56;4<br>64;6<br><form action=\"/jetspeed/portal/\" name=\"spectrumForm\" method=\"post\"><input type=\"hidden\" name=\"nmrshiftdbaction\" value=\"submitSpectrumForAssignment\"><textarea name=\"spectrum\" cols=\"10\" rows=\"10\"></textarea><br><input type=\"submit\" value=\"Submit the Spectrum\"></form></td></tr>";
returnValue += "<form action=\"/jetspeed/portal/\" method=\"post\"><input type=\"hidden\" name=\"nmrshiftdbaction\" value=\"submitAssignments\">";
! for (int i = 0; i < subData.getSignalstable().size(); i++)
! {
returnValue += "<tr><td><select name=\"atomSelect" + i + "\" size=\"1\" onChange=\"unselectandselect(this.value)\">";
! if (((IntTriple) subData.getSignalstable().get(i)).value3 == -1)
! {
returnValue += "<OPTION SELECTED>none</option>";
! }
! else
! {
returnValue += "<OPTION>none</option>";
}
! for (int k = 0; k < subData.getSignalstable().size(); k++)
! {
! if (k == ((IntTriple) subData.getSignalstable().get(i)).value3)
! {
returnValue += "<option selected>" + (k) + "</option>";
! }
! else
! {
returnValue += "<option>" + (k) + "</option>";
}
|