You can subscribe to this list here.
| 2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(157) |
Nov
(121) |
Dec
(19) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(34) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <rga...@us...> - 2002-10-18 15:05:48
|
Update of /cvsroot/csms/csms-core/src/test In directory usw-pr-cvs1:/tmp/cvs-serv10867/test Added Files: placeholder Log Message: Initial test code for scoring application --- NEW FILE: placeholder --- CVS happy |
|
From: <rga...@us...> - 2002-10-18 14:57:31
|
Update of /cvsroot/csms/csms-core/src/documentation/xdocs
In directory usw-pr-cvs1:/tmp/cvs-serv10690/documentation/xdocs
Modified Files:
book.xml index.xml
Log Message:
Initial CSMS developers web site import
Index: book.xml
===================================================================
RCS file: /cvsroot/csms/csms-core/src/documentation/xdocs/book.xml,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** book.xml 17 Oct 2002 16:53:48 -0000 1.1.1.1
--- book.xml 18 Oct 2002 14:57:28 -0000 1.2
***************
*** 8,12 ****
<menu label="Community">
! <menu-item label="Download" href="http://sourceforge.net/project/showfiles.php?group_id=36516"/>
</menu>
--- 8,12 ----
<menu label="Community">
! <menu-item label="Project Management" href="http://sourceforge.net/projects/csms"/>
</menu>
Index: index.xml
===================================================================
RCS file: /cvsroot/csms/csms-core/src/documentation/xdocs/index.xml,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** index.xml 17 Oct 2002 16:53:48 -0000 1.1.1.1
--- index.xml 18 Oct 2002 14:57:28 -0000 1.2
***************
*** 4,8 ****
<document>
<header>
! <title>Krysalis-Project</title>
<authors>
<person id="rdg" name="Ross D. Gardler" email="ro...@sa..."/>
--- 4,8 ----
<document>
<header>
! <title>Community Sports Management System</title>
<authors>
<person id="rdg" name="Ross D. Gardler" email="ro...@sa..."/>
***************
*** 12,43 ****
<body>
<section title="Introduction">
! <p><strong>Krysalis-Project</strong> is project designed to
! enable new projects to be started quickly and easily. The idea
! is that you copy this project to your own directory and
! customise it to reflect your own project. The project includes
! the recomended minimum configuration for a project using the
! CoPDoC (Community Project Document Code) paradigm. As such it
! uses the following cents:</p>
! <ul>
! <li>Unit tests</li>
! <li>Web site (documentation)</li>
! <li>Source code xref</li>
! <li>Javadocs</li>
! <li>Checkstyle (only checks no tabs exist, license header file is
! present, javadocs statements are present)</li>
! </ul>
! <p>In order to start your own project from this template simply
! edit the following files:</p>
! <ul>
! <li>module.xml</li>
! <li>properties.xml</li>
! <li>README.txt</li>
! <li>status.xml</li>
! <li>/src/documentation/index.xml</li>
! <li>/src/documentation/book.xml</li>
! </ul>
! <p>Your source code goes in <code>/src/java</code>. Test harnesses go in
! /src/test. To build your project simply run <code>cent</code> from the
! project root directory</p>
</section>
</body>
--- 12,25 ----
<body>
<section title="Introduction">
! <p>The <strong>Community Sports Management System</strong>
! sports league management system allowing the creation of leagues and
! the management of teams and players within those leagues together with
! all the stats generated in games. The core system is sport agnostic
! and is extended to support individual sports with the add on of sport
! modules. We aim to support as many sports as possible, both real and
! fantasy. The software also provides mechanisms for supporting online
! communities based around each sport, league and team.</p>
!
!
</section>
</body>
|
|
From: <rga...@us...> - 2002-10-18 14:56:48
|
Update of /cvsroot/csms/csms-core/src/java/org/fanfoot/scoring In directory usw-pr-cvs1:/tmp/cvs-serv10082/java/org/fanfoot/scoring Added Files: Event.java EventParser.java EventParserConfiguration.java EventParserConfigurationException.java EventParserListener.java EventPattern.java Events.java Scores.java ScoringConfiguration.java ScoringConfigurationException.java Log Message: Initial auto scoring application import --- NEW FILE: Event.java --- /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is Community Sports Management System. * * The Initial Developer of the Original Code is * We know What you Want.net * * Portions created by the Initial Developer are Copyright (C) 2002 * the Initial Developer. All Rights Reserved. * * Contributor(s): * * Ross Gardler <ross [at] saafe.org> * Mike Lever <mikel [at] fanfoot.com> * Stuart Gardler <stuart [at] wkwyw.net> * * ***** END LICENSE BLOCK ***** */ /* * Event.java * * Created on 20 September 2002, 21:59 */ package org.fanfoot.scoring; import java.util.Enumeration; import java.util.Hashtable; import javax.xml.parsers.ParserConfigurationException; import org.saafe.utils.XMLUtils; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Text; import java.util.logging.Logger; import java.util.logging.Level; /** * An event in a live game that may have an impact on the fantasy game * @author rgardler */ public class Event { /** Holds value of property src which indicates where this event record came from. */ private String src = ""; /** Holds value of property type. */ private String type = ""; /** The parts describing this event */ Hashtable parts = new Hashtable(); /** Holds value of property UID. */ private String UID = ""; final Logger logger = Logger.getLogger("org.fanfoot.scoring"); /** Creates a new instance of Event of the type indicated * @param strType the type of this event * @param strGroupUID a unique identifier for the group of events that *this event belongs to. From this a unique event identifier will be *created. */ public Event(String strType) { this.setType(strType); } /** Getter for property src. * @return Value of property src. * */ public String getSrc() { return this.src; } /** Setter for property src. * @param src New value of property src. * */ public void setSrc(String src) { this.src = src; } /** Getter for property type. * @return Value of property type. * */ public String getType() { return this.type; } /** Setter for property type. * @param type New value of property type. * */ public void setType(String type) { this.type = type; } /** * Get the part of the event named. * @param strPart name of the part required * @return value of the part requested */ public String getPart(String strPart) { return (String) parts.get(strPart); } /** * Add the named part and value to the collection of parts. * @param strName name of the part, nulls are converted to an empty string * @param strValue value of the part */ public void putPart(String strName, String strValue) { if (strValue == null) strValue = ""; parts.put(strName, strValue); } /** * Get all the parts for this event. * @retrun Hashtable containing all the parts, indexed by part name */ public Hashtable getParts() { return this.parts; } /** * Get all part names for this event. * @return the part names present in this event */ public Enumeration getPartNames() { return parts.keys(); } /** Return an XML DOM representation of this event * @return Document XML DOM representation of this event */ public Document toXMLDoc() throws ParserConfigurationException { logger.entering("org.fanfoot.scoring.Event", "toXMLDoc()"); Document doc = XMLUtils.createXMLDoc(); appendXMLTo(doc); logger.finest("Root element of document is named " + doc.getDocumentElement().getNodeName()); logger.exiting("org.fanfoot.scoring.Event", "toXMLDoc()"); return doc; } /** Append this event as a DOM node to the supplied XMl Docmuent. * @param doc the document to append to */ public void appendXMLTo(Document doc) { Element root = doc.createElement("event"); if (doc.getDocumentElement() == null) { doc.appendChild(root); } else { doc.getDocumentElement().appendChild(root); } Element elem = doc.createElement("uid"); Text text = doc.createTextNode(this.getUID()); elem.appendChild(text); root.appendChild(elem); elem=doc.createElement("type"); text = doc.createTextNode(this.getType()); elem.appendChild(text); root.appendChild(elem); elem=doc.createElement("src"); text = doc.createTextNode(this.getSrc()); elem.appendChild(text); root.appendChild(elem); Enumeration enuPartNames = this.getPartNames(); String strPartName; String strPartValue; while (enuPartNames.hasMoreElements()) { strPartName = (String)enuPartNames.nextElement(); strPartValue = this.getPart(strPartName); elem = doc.createElement(strPartName); if (strPartValue != "") { text = doc.createTextNode(strPartValue); elem.appendChild(text); } root.appendChild(elem); } } /** Getter for property UID. * @return Value of property UID. * */ public String getUID() { return this.UID; } /** Setter for property UID. * @param UID New value of property UID. * */ public void setUID(String UID) { this.UID = UID; } } --- NEW FILE: EventParser.java --- /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is Community Sports Management System. * * The Initial Developer of the Original Code is * We know What you Want.net * * Portions created by the Initial Developer are Copyright (C) 2002 * the Initial Developer. All Rights Reserved. * * Contributor(s): * * Ross Gardler <ross [at] saafe.org> * Mike Lever <mikel [at] fanfoot.com> * Stuart Gardler <stuart [at] wkwyw.net> * * ***** END LICENSE BLOCK ***** */ /* * EventParser.java * * Created on 21 September 2002, 11:51 */ package org.fanfoot.scoring; import java.io.File; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.EventObject; import java.util.Vector; import java.util.logging.Level; import java.util.logging.Logger; import java.util.regex.Matcher; import org.saafe.utils.XMLUtils; import org.w3c.dom.Document; /** * Parsers a file looking for events that may be important in a fantasy game. * Creates a set of Event objects from a given commentary/statistics file. * @author rgardler */ public class EventParser { /** Holds value of property conf. */ private EventParserConfiguration conf; final Logger logger = Logger.getLogger("org.fanfoot.scoring"); private Vector listeners = new Vector(); // list of Listeners private Document docCommentary = null; // the original commentary document /** Creates a new instance of EventParser */ public EventParser() { super(); } /** Creates a new instance of EventParser * @param strURL the url of the configuration file for this parser * @throws EventParserConfigurationException */ public EventParser(String strURL) throws EventParserConfigurationException { super(); conf = new EventParserConfiguration(strURL); } /** * Parse the supplied resource * @param strURL the URL of the resource to parse * @param strType the type of resource this is (this corresponds * to the sourceType element of the matcher element in the config file * @return Events found in the resource */ public Events parse(String strURL, String strType) throws MalformedURLException, IOException, EventParserConfigurationException { URL url = new URL(strURL); return parse(url, strType); } /** * Parse the supplied file * @param file the file to parse * @param strType the type of resource this is (this corresponds * to the sourceType element of the matcher element in the config file * @return Events found in the resource */ public Events parse(File file, String strType) throws IOException, EventParserConfigurationException { return parse(file.toURL(), strType); } /** * Parse the supplied resource * @param url the URL of the resource to parse * @param strType the type of resource this is (this corresponds * to the sourceType element of the matcher element in the config file * @return Events found in the resource */ public Events parse(URL url, String strType) throws MalformedURLException, IOException, EventParserConfigurationException { docCommentary = XMLUtils.loadTidiedHTML(url); this.notifyRetrievedCommentary(); StringBuffer sbData = new StringBuffer(); XMLUtils.appendAllText(docCommentary.getDocumentElement(), sbData); String strData = sbData.toString(); logger.finest("Live Data: " + strData); ArrayList patterns = conf.getPatternsForType(strType); Events evtsResult = new Events(); String strEventsUID = parseEventsUID(strData, strType); evtsResult.setUID(strEventsUID); logger.info("UID for these events is: " + strEventsUID); Events evtsCurrent; EventPattern p; logger.info("Start processing " + patterns.size() + " event patterns."); for (int i = 0; i < patterns.size(); i++) { p = (EventPattern) patterns.get(i); evtsCurrent = processEvents(p, strData); if (evtsCurrent != null) { evtsResult.addAll(evtsCurrent, this.conf); } } return evtsResult; } /** * Extract all events matched by the supplied pattern in * the supplied textual data. * @param p Pattern matching the event * @param strData the data to look for events in * @return Events matched by the pattern */ private Events processEvents(EventPattern p, String strData) { logger.entering("org.fanfoot.scoring.EventParser", "processEvents(eventPattern, strData)"); Events evts = new Events(); Matcher m = p.getRegexPattern().matcher(strData); String strPartValue; String strPartName; logger.finest("Looking for matches of type " + p.getType() + " (RE=" + p.getRegexPattern().pattern() + ")"); while (m.find()) { logger.fine("Matched event in: " + m.group()); Event evt = new Event(p.getType()); // Extract the event parts and store them in the event object logger.finest("There are " + m.groupCount() + " groups in the match"); for (int i = 1; i <= m.groupCount(); i++) { strPartValue = m.group(i).trim(); strPartName = p.getPartName(i); evt.putPart(strPartName, strPartValue); logger.finest("Set " + strPartName + " to " + strPartValue + " (part #" + i + ")"); } logger.fine("Added event of type " + p.getType()); evts.add(evt); } logger.exiting("org.fanfoot.scoring.EventParser", "processEvents(eventPattern, strData)"); return evts; } /** Create a Unique Identifier for a set of Events held in the * supplied game data string. This is done by matching the * Regular Expression * in the UID child element of the events root element in the parser * configuration file. * @param strData the game data * @para, strType the type of data supplied * @returns String UID for this set of events * @throws EventParserConfigurationException */ public String parseEventsUID(String strData, String strType) throws EventParserConfigurationException { StringBuffer sb = new StringBuffer(); Matcher m; logger.entering("org.fanfoot.scoring.EventParser", "parseEventUID(strData, strType"); // get the UID element EventPattern uidPattern = this.conf.getEventsUIDPattern(strType); m = uidPattern.getRegexPattern().matcher(strData); logger.finest("UID pattern is " + uidPattern.getRegexPattern().pattern()); // get the UID parts while (m.find()) { // Extract the UID parts and build the UID for (int i = 1; i <= m.groupCount(); i++) { sb.append('_'); sb.append(m.group(i).trim()); } } logger.exiting("org.fanfoot.scoring.EventParser", "parseEventUID(strData, strType"); // concatenate the parts return sb.toString(); } /** Getter for property conf. * @return Value of property conf. * */ public EventParserConfiguration getConfiguration() { return this.conf; } /** Setter for property conf. * @param conf New value of property conf. * */ public void setConfiguration(EventParserConfiguration conf) { this.conf = conf; } /** Load the configuration file indicated. * @param strConf URL from which to load configuration file * */ public void loadConfiguration(String strConf) throws EventParserConfigurationException { EventParserConfiguration conf = new EventParserConfiguration(strConf); setConfiguration(conf); } public synchronized void addListener(EventParserListener epl) { Vector v = (Vector) listeners.clone(); v.addElement(epl); listeners = v; } public synchronized void removeListener(EventParserListener epl) { Vector v = (Vector) listeners.clone(); v.removeElement(epl); listeners = v; } protected void notifyRetrievedCommentary() { logger.entering("org.fanfoot.scoring.EventParser", "notifyRetrievedCommentary()"); Vector l; EventObject e = new EventObject(this); l = listeners; // Atomic assignment EventParserListener epl = null; for (int i = 0; i < l.size(); i++) { epl = (EventParserListener) l.elementAt(i); epl.retrievedCommentary(e); } logger.entering("org.fanfoot.scoring.EventParser", "notifyRetrievedCommentary()"); } /** * Return the source code of the currently loaded commentary. * @return string containing the source code for the current commentary */ public String getCommentarySource() { String strCommentary; try { strCommentary = XMLUtils.xmlToString(docCommentary); } catch (javax.xml.transform.TransformerConfigurationException tce) { logger.log(Level.WARNING, "Unable to convert commentary document to string", tce); strCommentary = "ERROR: Unable to convert commentary document to a string du to a Transformer Configuration problem"; } catch (javax.xml.transform.TransformerException te) { logger.log(Level.WARNING, "Unable to convert commentary document to string", te); strCommentary = "ERROR: Unable to convert commentary document to a string du to a Transformer problem"; } return strCommentary; } } --- NEW FILE: EventParserConfiguration.java --- /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is Community Sports Management System. * * The Initial Developer of the Original Code is * We know What you Want.net * * Portions created by the Initial Developer are Copyright (C) 2002 * the Initial Developer. All Rights Reserved. * * Contributor(s): * * Ross Gardler <ross [at] saafe.org> * Mike Lever <mikel [at] fanfoot.com> * Stuart Gardler <stuart [at] wkwyw.net> * * ***** END LICENSE BLOCK ***** */ /* * EventParserConfiguration.java * * Created on 21 September 2002, 11:27 */ package org.fanfoot.scoring; import java.io.IOException; import java.util.ArrayList; import java.util.logging.Level; import java.util.logging.Logger; import javax.xml.parsers.ParserConfigurationException; import org.apache.commons.jxpath.JXPathContext; import org.apache.xpath.XPathAPI; import org.saafe.utils.XMLUtils; import org.w3c.dom.DOMException; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; /** * Reads an XML configuration file and builds a set of * Regular Expressions that are used to extract information from * a commentary/statistics resource. * * @author rgardler */ public class EventParserConfiguration { Document confDocument; final Logger logger = Logger.getLogger("org.fanfoot.scoring"); /** * Creates a new instance of EventParserConfiguration * using the indicated configuration file * @param strURL the URL of the configuration file to use */ public EventParserConfiguration(String strURL) throws EventParserConfigurationException { super(); try { loadConfigFile(strURL); } catch (Exception e) { logger.log(Level.WARNING, "Problem loading parser config file " + strURL, e); throw new EventParserConfigurationException( "Problem loading parser config file " + strURL + " " + e); } } /** * Read the comfiguration file indicated. * @param strURL the URL of the cofiguration file */ private void loadConfigFile(String strURL) throws ParserConfigurationException, DOMException, SAXException, IOException { confDocument = XMLUtils.parseXML(strURL); } /** * Get all patterns in the config file for a source of the indicated type. * @param String strSourceType Name indicating the value of the * sourceType element of the requiered Patterns * @returns an arraylist of the patterns. Patterns are represented as * java.util.regex.Patterns */ public ArrayList getPatternsForType(String strSourceType) { NodeList ndl = confDocument.getElementsByTagName("pattern"); // iterate over all the tags keeping only those that have a child // sourceType element with the value strSourceType ArrayList patterns = new ArrayList(); Node node; for (int i = 0; i < ndl.getLength(); i++) { node = ndl.item(i); JXPathContext context = JXPathContext.newContext(node); if (context.getValue("/sourceType").equals(strSourceType)) { if (node.getParentNode().getNodeName().equals("event")) { patterns.add(new EventPattern(node)); } } } return patterns; } /** Get an Iterator of part names that are used to identify duplicate * events of the given type. If no duplicateDetection element exists then * an empty iterator will be returned. * @param strType the type we are considering */ public java.util.Iterator getDuplicateDetectionParts(String strType) { JXPathContext context = JXPathContext.newContext(confDocument); java.util.Iterator it = context.iterate("/events/event[@type='" + strType + "']/duplicateDetection/part/@name"); return it; } /** * Get the pattern for extracting the UID of the Events group * this configuration file is for. * @param strSourceType the source type we want to use * @return the event pattern for the UID * @throws EventParserConfigurationException * @refactor Precompile the XPath statements to improve speed */ public EventPattern getEventsUIDPattern(String strSourceType) throws EventParserConfigurationException { String strXPathStatement = "/events/UID/pattern"; EventPattern pattern = null; Node node = null; logger.finest("Node name of conf document element " + confDocument.getDocumentElement().getNodeName()); try { node = XPathAPI.selectSingleNode(confDocument.getDocumentElement(), strXPathStatement); } catch (Exception e) { throw new EventParserConfigurationException( "Problem finding events UID pattern", e); } if (node != null) { pattern = new EventPattern(node); logger.finest("Node name returned by XPath statement (" + strXPathStatement + ") is " + node.getNodeName()); } else { logger.finest("No node returned by XPath statement (" + strXPathStatement + ")"); } return pattern; } } --- NEW FILE: EventParserConfigurationException.java --- /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is Community Sports Management System. * * The Initial Developer of the Original Code is * We know What you Want.net * * Portions created by the Initial Developer are Copyright (C) 2002 * the Initial Developer. All Rights Reserved. * * Contributor(s): * * Ross Gardler <ross [at] saafe.org> * Mike Lever <mikel [at] fanfoot.com> * Stuart Gardler <stuart [at] wkwyw.net> * * ***** END LICENSE BLOCK ***** */ /* * EventParserConfigurationError.java * * Created on 21 September 2002, 11:41 */ package org.fanfoot.scoring; /** * * @author rgardler */ public class EventParserConfigurationException extends java.lang.Exception { Exception root = null; /** * Creates a new instance of <code>EventParserConfigurationError</code> without detail message. */ public EventParserConfigurationException() { } /** * Constructs an instance of <code>EventParserConfigurationError</code> with the specified detail message. * @param msg the detail message. */ public EventParserConfigurationException(String msg) { super(msg); } /** * Constructs an instance of <code>EventParserConfigurationError</code> * with the specified detail message * and the root exception supplied * @param msg the detail message. */ public EventParserConfigurationException(String msg, Exception e) { super(msg); root = e; } } --- NEW FILE: EventParserListener.java --- /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is Community Sports Management System. * * The Initial Developer of the Original Code is * We know What you Want.net * * Portions created by the Initial Developer are Copyright (C) 2002 * the Initial Developer. All Rights Reserved. * * Contributor(s): * * Ross Gardler <ross [at] saafe.org> * Mike Lever <mikel [at] fanfoot.com> * Stuart Gardler <stuart [at] wkwyw.net> * * ***** END LICENSE BLOCK ***** */ /* * EventParserListener.java * * Created on 06 October 2002, 10:00 */ package org.fanfoot.scoring; import java.util.EventListener; import java.util.EventObject; /** * A listener to events generated by EventParser. * @see org.fanfoot.scoring.EventParser * @author rgardler */ public abstract interface EventParserListener extends EventListener { /** * Loaded Commentay file. */ public abstract void retrievedCommentary(EventObject e); } --- NEW FILE: EventPattern.java --- /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is Community Sports Management System. * * The Initial Developer of the Original Code is * We know What you Want.net * * Portions created by the Initial Developer are Copyright (C) 2002 * the Initial Developer. All Rights Reserved. * * Contributor(s): * * Ross Gardler <ross [at] saafe.org> * Mike Lever <mikel [at] fanfoot.com> * Stuart Gardler <stuart [at] wkwyw.net> * * ***** END LICENSE BLOCK ***** */ /* * Pattern.java * * Created on 21 September 2002, 16:57 */ package org.fanfoot.scoring; import java.util.ArrayList; import java.util.regex.Pattern; import java.util.logging.Logger; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; /** * A pattern with which to identify events that may affect fantasy scores * in a textual commentary or set of statistics. * @author rgardler */ public class EventPattern { private Logger logger = Logger.getLogger("org.fanfoot.scoring"); /** Holds value of property regexPattern which * is a regular expression pattern used for matching an event.*/ private Pattern regexPattern; /** Holds value of property capturingGroup which contains the * name of each capturing group in the Pattern */ private ArrayList capturingGroup = new ArrayList(); /** Holds value of property type. */ private String type; /** Creates a new instance of Pattern * @param node a DOM node taken from a configuration file describing an event pattern */ public EventPattern(Node node) { super(); StringBuffer sb = new StringBuffer(); String strGroupName; String strRE; NamedNodeMap atts; int idxGroup = 1; Node curNode = node.getFirstChild(); Node childNode; while (curNode != null) { if (curNode.getNodeName().equals("part")) { childNode = curNode.getFirstChild(); if (childNode.getNodeType() == node.TEXT_NODE) { strRE = childNode.getNodeValue(); sb.append('('); sb.append(strRE); sb.append(')'); atts = curNode.getAttributes(); strGroupName = atts.getNamedItem("name").getNodeValue(); this.setCapturingGroup(idxGroup, strGroupName); idxGroup = idxGroup + 1; logger.fine("Added capturing group " + strGroupName + " with RE " + strRE); } else { strRE = childNode.getFirstChild().getNodeValue(); sb.append('('); sb.append(strRE); sb.append(')'); atts = curNode.getAttributes(); strGroupName = atts.getNamedItem("name").getNodeValue(); this.setCapturingGroup(idxGroup, strGroupName); idxGroup = idxGroup + 1; logger.fine("Added capturing group " + strGroupName + " with RE " + strRE); } } else if (curNode.getNodeName().equals("unwantedPart")) { strRE = curNode.getFirstChild().getNodeValue(); sb.append(strRE); logger.fine("Added non-capturing group with RE " + strRE); } curNode = curNode.getNextSibling(); } regexPattern = Pattern.compile(sb.toString()); Node eventNode = node.getParentNode(); atts = eventNode.getAttributes(); String strType = atts.getNamedItem("type").getFirstChild() .getNodeValue(); this.setType(strType); } /** Getter for property regexPattern. * @return Value of property regexPattern. * */ public Pattern getRegexPattern() { return this.regexPattern; } /** Setter for property regexPattern. * @param regexPattern New value of property regexPattern. * */ public void setRegexPattern(Pattern regexPattern) { this.regexPattern = regexPattern; } /** Indexed getter for property capturingGroup. * @param index Index of the property. * @return Value of the property at <CODE>index</CODE>. * */ public String getCapturingGroup(int index) { return (String) this.capturingGroup.get(index - 1); } /** Get the part name for the indicate capturing group * @param index Index of the property. * @return Value of the property at <CODE>index</CODE>. * */ public String getPartName(int index) { return getCapturingGroup(index); } /** Indexed setter for property capturingGroup. * @param index Index of the property. * @param capturingGroupName New value of the property at <CODE>index</CODE>. * */ public void setCapturingGroup(int index, String capturingGroupName) { //this.capturingGroup.ensureCapacity(index); this.capturingGroup.add(index - 1, capturingGroupName); } /** Getter for property type. * @return Value of property type. * */ public String getType() { return this.type; } /** Setter for property type. * @param type New value of property type. * */ public void setType(String type) { this.type = type; } } --- NEW FILE: Events.java --- /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is Community Sports Management System. * * The Initial Developer of the Original Code is * We know What you Want.net * * Portions created by the Initial Developer are Copyright (C) 2002 * the Initial Developer. All Rights Reserved. * * Contributor(s): * * Ross Gardler <ross [at] saafe.org> * Mike Lever <mikel [at] fanfoot.com> * Stuart Gardler <stuart [at] wkwyw.net> * * ***** END LICENSE BLOCK ***** */ /* * Events.java * * Created on 20 September 2002, 22:02 */ package org.fanfoot.scoring; import java.util.ArrayList; import java.util.Enumeration; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Vector; import java.util.logging.Logger; import javax.xml.parsers.ParserConfigurationException; import org.saafe.utils.XMLUtils; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Text; /** * A collection of Events that have happened in a real game that may * affect the fantasy game. * @author rgardler * @seeAlso org.fanfoot.scoring.Event */ public class Events { /** Holds value of property events. */ private LinkedList events = new LinkedList(); /** A list of all event types found in this collection */ private Vector types = new Vector(); /** Holds value of property uid. */ private String uid = ""; /** Holds value of property srcData. */ private String srcData = ""; final Logger logger = Logger.getLogger("org.fanfoot.scoring"); /** Creates a new instance of Events */ public Events() { super(); } /** Creates a new instance of Events * @param strUID a unique identifier for this set of events, must be application unique */ public Events(String strUID) { super(); this.setUID(strUID); } /** * Get the collection of events * @return the collection of events * */ public List getEvents() { return this.events; } /** * Get the event at the given index * @return the collection of events * */ public Event getEvent(int idx) { return (Event) this.events.get(idx); } /** Add the supplied event to the Events list. * @param evt The event to add */ public void add(Event evt) { if (!this.types.contains(evt.getType())) { this.types.add(evt.getType()); } this.events.add(evt); } /** * Get the number of events in this collection. * @return int number of events in collection */ public int size() { return this.events.size(); } /** * Add all the supplied events to this Events collection. * @param evts the events to add * @param conf the vonfiguration for these events */ public void addAll(Events evts) { Iterator iter = evts.getEvents().iterator(); while (iter.hasNext()) this.add((Event) iter.next()); } /** * Add all the supplied events to this Events collection. * FIXME: implement duplicate checking * If a duplicate event (as indicated by the events configuration file) * is located then the second event is marked as a duplicate and * both events are marked as requireing validation. * * @param evts the events to add * @param conf the vonfiguration for these events */ public void addAll(Events evts, EventParserConfiguration conf) { Iterator iter = evts.getEvents().iterator(); Event evt; while (iter.hasNext()) { evt = (Event) iter.next(); if (!contains(evt, conf)) { this.add(evt); } } } /** Checks to see if this events collection contains the supplied * event by checking against the duplicateDetection config in the * configuration file. * @param evt the event to check for * @param conf the event parser configuration * @return true if the events collection contains an identical event allready */ public boolean contains(Event evt, EventParserConfiguration conf) { boolean contains = false; // indicates if an element that is equal does NOT exist boolean partsAreEqual = true; // indicates if the parts tested so far are equal Iterator events = this.getEventsByType(evt.getType()).iterator(); Event existingEvt; Iterator parts; String strPart; while (events.hasNext() & !contains) { parts = conf.getDuplicateDetectionParts(evt.getType()); if (parts.hasNext()) { partsAreEqual = true; } else { partsAreEqual = false; } existingEvt = (Event) events.next(); logger.finest("Checking to see if event type " + existingEvt + " type (" + existingEvt.getType() + ") equals " + evt + " type (" + evt.getType() + ")"); while (parts.hasNext()) { strPart = (String) parts.next(); logger.finest("Checking to see if values for part " + strPart + " are equal (" + evt.getPart(strPart) + " = " + existingEvt.getPart(strPart) + ")"); partsAreEqual = (evt.getPart(strPart).equals(existingEvt.getPart( strPart))) & partsAreEqual; logger.finest("All parts to date are equal = " + partsAreEqual); } contains = partsAreEqual; } return contains; } /** Get the names of all event types present * @return Enumeration of all event types */ public Enumeration getTypes() { return this.types.elements(); } /** Get all events in the collection of the indicated type. * @param strType the type of event requried * @return an ArrayList of all events of the supplied type */ public ArrayList getEventsByType(String strType) { ArrayList result = new ArrayList(); Event evt; // current event being processes Iterator li = events.iterator(); while (li.hasNext()) { evt = (Event) li.next(); if (evt.getType().equals(strType)) { result.add(evt); } } return result; } /** Getter for property UID. * @return Value of property UID. * */ public String getUID() { return this.uid; } /** Setter for property UID. * @param UID New value of property UID. * */ public void setUID(String UID) { this.uid = UID; } /** Getter for property srcData. * @return Value of property srcData. * */ public String getSrcData() { return this.srcData; } /** Setter for property srcData. * @param srcData New value of property srcData. * */ public void setSrcData(String srcData) { this.srcData = srcData; } /** Return an XML DOM representation of this event * @return Document XML DOM representation of this event */ public Document toXMLDoc() throws ParserConfigurationException { Document doc = XMLUtils.createXMLDoc("events"); Element root = doc.getDocumentElement(); Element elem = doc.createElement("uid"); Text text = doc.createTextNode(this.getUID()); elem.appendChild(text); root.appendChild(elem); elem = doc.createElement("srcData"); text = doc.createTextNode(this.getSrcData()); elem.appendChild(text); root.appendChild(elem); Enumeration evtTypes = this.getTypes(); // all types of events String strType; // type of events currently being processed ArrayList typeEvts; // all events of a certain type Event evt; // event currently being processed while (evtTypes.hasMoreElements()) { strType = (String) evtTypes.nextElement(); typeEvts = this.getEventsByType(strType); for (int i = 0; i < typeEvts.size(); i++) { evt = (Event) typeEvts.get(i); evt.appendXMLTo(doc); } } return doc; } } --- NEW FILE: Scores.java --- /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is Community Sports Management System. * * The Initial Developer of the Original Code is * We know What you Want.net * * Portions created by the Initial Developer are Copyright (C) 2002 * the Initial Developer. All Rights Reserved. * * Contributor(s): * * Ross Gardler <ross [at] saafe.org> * Mike Lever <mikel [at] fanfoot.com> * Stuart Gardler <stuart [at] wkwyw.net> * * ***** END LICENSE BLOCK ***** */ /* * calculator.java * * Created on 24 September 2002, 13:21 */ package org.fanfoot.scoring; import java.util.logging.Level; import java.util.logging.Logger; import org.saafe.utils.XMLUtils; import org.w3c.dom.Document; /** * Calculates the score for each <code>Event</code> in a given events * collection. * @author rgardler */ public class Scores { static final Logger logger = Logger.getLogger("org.fanfoot.scoring"); /** Holds value of property events. */ private Events events; /** Holds value of property conf. */ private ScoringConfiguration conf; /** The document holding the scores. */ private Document scoresDocument; /** Creates a new instance of calculator * @parm evts the events to calculate the score from * @throws ScoringConfigurationException if unable to calculate scores */ public Scores(Events evts, ScoringConfiguration sc) throws ScoringConfigurationException { this.setEvents(evts); this.setConfiguration(sc); this.calculate(); } /** Getter for property events. * @return Value of property events. * */ public Events getEvents() { return this.events; } /** Setter for property events. * @param events New value of property events. * */ public void setEvents(Events events) { this.events = events; } /** Getter for property conf. * @return Value of property conf. * */ public ScoringConfiguration getConfiguration() { return this.conf; } /** Setter for property conf. * @param conf New value of property conf. * */ public void setConfiguration(ScoringConfiguration conf) { this.conf = conf; } /** Calculate the scores. * @return DOM document representing the scores * @throws ScoringConfigurationException if unalb to calculate scores */ public Document calculate() throws ScoringConfigurationException { logger.entering("org.fanfoot.scoring.scores", "calculate()"); Document doc = null; try { logger.finest("Events document root element is named " + getEvents().toXMLDoc().getDocumentElement().getNodeName()); doc = XMLUtils.transform(getEvents().toXMLDoc(), getConfiguration().getXSL()); } catch (Exception e) { logger.log(Level.WARNING, "Unable to calculate scores", e); throw new ScoringConfigurationException( "Unable to calculate scores", e); } setScoresDocument(doc); logger.finest("Scores document root element is named " + getScoresDocument().getDocumentElement().getNodeName()); logger.exiting("org.fanfoot.scoring.scores", "calculate()"); return doc; } /** Getter for property scoresDocument. * @return Value of property scoresDocument. * */ public Document getScoresDocument() { return this.scoresDocument; } /** Setter for property scoresDocument. * @param scoresDocument New value of property scoresDocument. * */ public void setScoresDocument(Document scoresDocument) { this.scoresDocument = scoresDocument; } } --- NEW FILE: ScoringConfiguration.java --- /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is Community Sports Management System. * * The Initial Developer of the Original Code is * We know What you Want.net * * Portions created by the Initial Developer are Copyright (C) 2002 * the Initial Developer. All Rights Reserved. * * Contributor(s): * * Ross Gardler <ross [at] saafe.org> * Mike Lever <mikel [at] fanfoot.com> * Stuart Gardler <stuart [at] wkwyw.net> * * ***** END LICENSE BLOCK ***** */ /* * ScoreConfiguration.java * * Created on 24 September 2002, 13:26 */ package org.fanfoot.scoring; import java.util.logging.Logger; import java.util.logging.Level; /** * A score configuration manages how scores are calculated from * events. This class is simply a wrapper for an XSL document * that is used to transfore the XML representation of a set * of <code>Events</code> into another XML document representing * the scores generated from those events. * @author rgardler */ public class ScoringConfiguration { /** Holds value of property xSLURL. */ private String xSLURL; static final Logger logger = Logger.getLogger("org.fanfoot.scoring"); /** Creates a new instance of ScoreConfiguration * @param strURL the url of the XSL stylesheet to generate scores from <code>Events</code> */ public ScoringConfiguration(String strURL) { this.xSLURL = strURL; } /** Getter for property xSLURL. * @return Value of property xSLURL. * */ public String getXSLURL() { return this.xSLURL; } /** Setter for property xSLURL. * @param xSLURL New value of property xSLURL. * */ public void setXSLURL(String xSLURL) { this.xSLURL = xSLURL; } /** * Get XSL Document that is used to transform <code>Events</code> * DOM documents into a score DOM document. * @return scores as a dom Document * @throws ScoringConfigurtionException if unable to load the XSL file * @refactor many times the XSL will not have changed so there is no need * to relod the document. Cache it here. */ public org.w3c.dom.Document getXSL() throws ScoringConfigurationException { org.w3c.dom.Document doc; try { doc = org.saafe.utils.XMLUtils.parseXML(xSLURL); } catch (javax.xml.parsers.ParserConfigurationException pce) { logger.log(Level.WARNING, "Unable to parse scoring XSL", pce); throw new ScoringConfigurationException("Unable to parse scoring XSL", pce); } catch ( org.xml.sax.SAXException se) { logger.log(Level.WARNING, "Unable to parse scoring XSL", se); throw new ScoringConfigurationException("Unable to parse scoring XSL", se); } catch (java.io.IOException ioe) { logger.log(Level.WARNING, "Unable to parse scoring XSL", ioe); throw new ScoringConfigurationException("Unable to parse scoring XSL", ioe); } return doc; } } --- NEW FILE: ScoringConfigurationException.java --- /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is Community Sports Management System. * * The Initial Developer of the Original Code is * We know What you Want.net * * Portions created by the Initial Developer are Copyright (C) 2002 * the Initial Developer. All Rights Reserved. * * Contributor(s): * * Ross Gardler <ross [at] saafe.org> * Mike Lever <mikel [at] fanfoot.com> * Stuart Gardler <stuart [at] wkwyw.net> * * ***** END LICENSE BLOCK ***** */ /* * ScoringConfigurationException.java * * Created on 24 September 2002, 13:37 */ package org.fanfoot.scoring; /** * * @author rgardler */ public class ScoringConfigurationException extends java.lang.Exception { Exception root = null; /** * Creates a new instance of <code>ScoringConfigurationException</code> without detail message. */ public ScoringConfigurationException() { } /** * Constructs an instance of <code>ScoringConfigurationException</code> with the specified detail message. * @param msg the detail message. */ public ScoringConfigurationException(String msg) { super(msg); } /** * Constructs an instance of <code>ScoringConfigurationError</code> * with the specified detail message * and the root exception supplied * @param msg the detail message. */ public ScoringConfigurationException(String msg, Exception e) { super(msg); root = e; } } |
|
From: <rga...@us...> - 2002-10-18 14:56:48
|
Update of /cvsroot/csms/csms-core/src/java/org/fanfoot/gui
In directory usw-pr-cvs1:/tmp/cvs-serv10082/java/org/fanfoot/gui
Added Files:
ControlCentre.form ControlCentre.java
Log Message:
Initial auto scoring application import
--- NEW FILE: ControlCentre.form ---
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.0" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
<NonVisualComponents>
<Menu class="javax.swing.JMenuBar" name="mnubarMain">
<SubComponents>
<Menu class="javax.swing.JMenu" name="mnuFile">
<Properties>
<Property name="mnemonic" type="int" value="70"/>
<Property name="text" type="java.lang.String" value="File"/>
</Properties>
<SubComponents>
<MenuItem class="javax.swing.JMenuItem" name="mnuItemParseFile">
<Properties>
<Property name="mnemonic" type="int" value="70"/>
<Property name="text" type="java.lang.String" value="Parse File"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="mnuItemParseFileActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="mnuitemParseURL">
<Properties>
<Property name="text" type="java.lang.String" value="Parse URL"/>
<Property name="toolTipText" type="java.lang.String" value="Load an URL and parse scores from it"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="mnuitemParseURLActionPerformed"/>
</Events>
</MenuItem>
</SubComponents>
</Menu>
<Menu class="javax.swing.JMenu" name="mnuConfig">
<Properties>
<Property name="mnemonic" type="int" value="67"/>
<Property name="text" type="java.lang.String" value="Configuration"/>
<Property name="toolTipText" type="java.lang.String" value="Configure the score calculator"/>
</Properties>
<SubComponents>
<MenuItem class="javax.swing.JMenuItem" name="setPaths">
<Properties>
<Property name="mnemonic" type="int" value="80"/>
<Property name="text" type="java.lang.String" value="Paths"/>
<Property name="toolTipText" type="java.lang.String" value="Set the paths to configuration files"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="setPathsActionPerformed"/>
</Events>
</MenuItem>
</SubComponents>
</Menu>
<Menu class="javax.swing.JMenu" name="mnuDebug">
<Properties>
<Property name="mnemonic" type="int" value="68"/>
<Property name="text" type="java.lang.String" value="Debug"/>
</Properties>
<SubComponents>
<MenuItem class="javax.swing.JMenuItem" name="parseBBCTExt1">
<Properties>
<Property name="mnemonic" type="int" value="49"/>
<Property name="text" type="java.lang.String" value="Parse BBC Test 1"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="parseBBCTExt1ActionPerformed"/>
</Events>
</MenuItem>
</SubComponents>
</Menu>
</SubComponents>
</Menu>
</NonVisualComponents>
<Properties>
<Property name="title" type="java.lang.String" value="FanFoot Control Centre"/>
<Property name="maximizedBounds" type="java.awt.Rectangle" editor="org.netbeans.beaninfo.editors.RectangleEditor">
<Rectangle value="[0, 0, 800, 800]"/>
</Property>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="menuBar" type="java.lang.String" value="mnubarMain"/>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
</SyntheticProperties>
<Events>
<EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="exitForm"/>
</Events>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<SubComponents>
<Container class="javax.swing.JTabbedPane" name="tabpneEvents">
<Properties>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[800, 800]"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="North"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout"/>
</Container>
</SubComponents>
</Form>
--- NEW FILE: ControlCentre.java ---
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Community Sports Management System.
*
* The Initial Developer of the Original Code is
* We know What you Want.net
*
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Ross Gardler <ross [at] saafe.org>
* Mike Lever <mikel [at] fanfoot.com>
* Stuart Gardler <stuart [at] wkwyw.net>
*
* ***** END LICENSE BLOCK ***** */
/*
* controlCentre.java
*
* Created on 22 September 2002, 11:10
*/
package org.fanfoot.gui;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.EventObject;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import javax.xml.parsers.ParserConfigurationException;
import org.fanfoot.scoring.Event;
import org.fanfoot.scoring.EventParser;
import org.fanfoot.scoring.EventParserConfigurationException;
import org.fanfoot.scoring.EventParserListener;
import org.fanfoot.scoring.Events;
import org.fanfoot.scoring.Scores;
import org.fanfoot.scoring.ScoringConfiguration;
import org.fanfoot.scoring.ScoringConfigurationException;
import org.saafe.ui.gui.dialog.getURL;
import org.saafe.ui.gui.prefs.PreferencesEditor;
import org.saafe.utils.XMLUtils;
import org.w3c.dom.Document;
/**
*
* @author rgardler
*/
public class ControlCentre extends JFrame implements EventParserListener {
//Create a file chooser
final JFileChooser fc = new JFileChooser();
//FIXME: all these default config strings should be load into the prefs object
final String strDefaultEventConfigFile = "http://www.fanfoot.com/test/footballEvents.xml";
final String strDefaultScoringConfigFile = "http://www.fanfoot.com/test/BBCScoringConfig.xsl";
final String strDefaultScores2HTMLXSLFile = "http://www.fanfoot.com/test/Scores2HTML.xsl";
final String[] strDefaultURLs = {
"",
"http://news.bbc.co.uk/sport/hi/english/static/football/statistics/teams/a/arsenal/live_hi.stm",
"http://news.bbc.co.uk/sport/hi/english/static/football/statistics/teams/a/aston_villa/live_hi.stm",
"http://news.bbc.co.uk/sport/hi/english/static/football/statistics/teams/b/birmingham_city/live_hi.stm",
"http://news.bbc.co.uk/sport/hi/english/static/football/statistics/teams/b/blackburn_rovers/live_hi.stm",
"http://news.bbc.co.uk/sport/hi/english/static/football/statistics/teams/b/bolton_wanderers/live_hi.stm",
"http://news.bbc.co.uk/sport/hi/english/static/football/statistics/teams/c/charlton_athletic/live_hi.stm",
"http://news.bbc.co.uk/sport/hi/english/static/football/statistics/teams/c/chelsea/live_hi.stm",
"http://news.bbc.co.uk/sport/hi/english/static/football/statistics/teams/e/everton/live_hi.stm",
"http://news.bbc.co.uk/sport/hi/english/static/football/statistics/teams/f/fulham/live_hi.stm",
"http://news.bbc.co.uk/sport/hi/english/static/football/statistics/teams/l/leeds_united/live_hi.stm",
"http://news.bbc.co.uk/sport/hi/english/static/football/statistics/teams/l/liverpool/live_hi.stm",
"http://news.bbc.co.uk/sport/hi/english/static/football/statistics/teams/m/man_city/live_hi.stm",
"http://news.bbc.co.uk/sport/hi/english/static/football/statistics/teams/m/man_utd/live_hi.stm",
"http://news.bbc.co.uk/sport/hi/english/static/football/statistics/teams/m/middlesbrough/live_hi.stm",
"http://news.bbc.co.uk/sport/hi/english/static/football/statistics/teams/n/newcastle_united/live_hi.stm",
"http://news.bbc.co.uk/sport/hi/english/static/football/statistics/teams/s/southampton/live_hi.stm",
"http://news.bbc.co.uk/sport/hi/english/static/football/statistics/teams/s/sunderland/live_hi.stm",
"http://news.bbc.co.uk/sport/hi/english/static/football/statistics/teams/t/tottenham_hotspur/live_hi.stm",
"http://news.bbc.co.uk/sport/hi/english/static/football/statistics/teams/w/west_bromwich_albion/live_hi.stm",
"http://news.bbc.co.uk/sport/hi/english/static/football/statistics/teams/w/west_ham_utd/live_hi.stm"
};
final Logger logger = Logger.getLogger("org.fanfoot.gui");
protected String strBBCType = "BBC Text Commentary";
private Preferences prefs;;
private EventParser eventParser;
ScoringConfiguration scoringConfig;
Scores scores;
/** Creates new form controlCentre using the default configuration file.
* @throws FileNotFoundException if the default configuration file cannot be found
* @throws IOException if there is a problem reading the properties file
*/
public ControlCentre() throws FileNotFoundException, IOException {
initEventParser();
initComponents();
prefs = Preferences.userNodeForPackage(ControlCentre.class);
if (prefs.get("debug", "true").toLowerCase().equals("true")) {
mnuDebug.setVisible(true);
} else {
mnuDebug.setVisible(false);
}
scoringConfig = new ScoringConfiguration(prefs.get("ScoringConfigurationFile", strDefaultScoringConfigFile));
}
/** Initialise the EventParser object.
*/
private void initEventParser() {
eventParser = new EventParser();
eventParser.addListener(this);
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
private void initComponents() {//GEN-BEGIN:initComponents
tabpneEvents = new javax.swing.JTabbedPane();
mnubarMain = new javax.swing.JMenuBar();
mnuFile = new javax.swing.JMenu();
mnuItemParseFile = new javax.swing.JMenuItem();
mnuitemParseURL = new javax.swing.JMenuItem();
mnuConfig = new javax.swing.JMenu();
setPaths = new javax.swing.JMenuItem();
mnuDebug = new javax.swing.JMenu();
parseBBCTExt1 = new javax.swing.JMenuItem();
setTitle("FanFoot Control Centre");
setMaximizedBounds(new java.awt.Rectangle(0, 0, 800, 800));
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
exitForm(evt);
}
});
tabpneEvents.setMaximumSize(new java.awt.Dimension(800, 800));
getContentPane().add(tabpneEvents, java.awt.BorderLayout.NORTH);
mnuFile.setMnemonic('F');
mnuFile.setText("File");
mnuItemParseFile.setMnemonic('F');
mnuItemParseFile.setText("Parse File");
mnuItemParseFile.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
mnuItemParseFileActionPerformed(evt);
}
});
mnuFile.add(mnuItemParseFile);
mnuitemParseURL.setText("Parse URL");
mnuitemParseURL.setToolTipText("Load an URL and parse scores from it");
mnuitemParseURL.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
mnuitemParseURLActionPerformed(evt);
}
});
mnuFile.add(mnuitemParseURL);
mnubarMain.add(mnuFile);
mnuConfig.setMnemonic('C');
mnuConfig.setText("Configuration");
mnuConfig.setToolTipText("Configure the score calculator");
setPaths.setMnemonic('P');
setPaths.setText("Paths");
setPaths.setToolTipText("Set the paths to configuration files");
setPaths.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
setPathsActionPerformed(evt);
}
});
mnuConfig.add(setPaths);
mnubarMain.add(mnuConfig);
mnuDebug.setMnemonic('D');
mnuDebug.setText("Debug");
parseBBCTExt1.setMnemonic('1');
parseBBCTExt1.setText("Parse BBC Test 1");
parseBBCTExt1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
parseBBCTExt1ActionPerformed(evt);
}
});
mnuDebug.add(parseBBCTExt1);
mnubarMain.add(mnuDebug);
setJMenuBar(mnubarMain);
pack();
}//GEN-END:initComponents
private void mnuitemParseURLActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mnuitemParseURLActionPerformed
getURL dialog = new getURL(this, true, strDefaultURLs);
URL url = dialog.getURL();
generateScores(url);
}//GEN-LAST:event_mnuitemParseURLActionPerformed
private void setPathsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_setPathsActionPerformed
try {
PreferencesEditor dlgPrefsEditor = new PreferencesEditor(this, true, prefs);
dlgPrefsEditor.show();
} catch (BackingStoreException bse) {
// FIXME: Inform user of this problem
logger.log(Level.SEVERE, "Unable to create Preferences Editor", bse);
}
}//GEN-LAST:event_setPathsActionPerformed
private void parseBBCTExt1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_parseBBCTExt1ActionPerformed
URL url = null;
try {
url = new URL("http://www.fanfoot.com/test/testCommentary_BBC_1.html");
} catch (Exception e) {
}
generateScores(url);
}//GEN-LAST:event_parseBBCTExt1ActionPerformed
private void mnuItemParseFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mnuItemParseFileActionPerformed
//FIXME detect the type from the file, or have user specify it
String strType = strBBCType;
Events evts; // the events parsed from the file
int returnVal = fc.showOpenDialog(this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = fc.getSelectedFile();
logger.finest("Parsing: " + file.getName() + " of type " + strType +".\n");
try {
eventParser.loadConfiguration(prefs.get("EventConfigurationFile", strDefaultEventConfigFile));
} catch (EventParserConfigurationException epc) {
logger.severe("Cannot load parser config file");
// FIXME Tell the user of this error
}
try {
generateScores(file.toURL());
} catch (java.net.MalformedURLException mue) {
logger.warning("File path does not translate to a valid URL");
// FIXME: Warn the user of this error
}
} else {
logger.finest("Parse command cancelled by user.\n");
}
}//GEN-LAST:event_mnuItemParseFileActionPerformed
/**
* Gerenate the scores from the supplied url using the current configuration.
* Scores are displayed in the GUI.
* @param url the url to load
*/
private void generateScores(URL url) {
Events evts; // the events parsed from the file
// FIXME: currently we download the URL twice, once to display in the Browser and once in the EventParser
org.saafe.utils.BrowserControl.displayURL(url);
try {
eventParser.loadConfiguration(strDefaultEventConfigFile);
logger.info("Loaded Event Config file: " + strDefaultEventConfigFile);
} catch (EventParserConfigurationException epc) {
logger.severe("Cannot load parser config file");
// FIXME Tell the user of this error
}
try {
//FIXME the type of file should be user selectable
evts = eventParser.parse(url, strBBCType);
logger.info("Parsed events from file at: " + url.toString());
populateEventTables(evts);
} catch (IOException io) {
logger.log(Level.SEVERE, "Cannot configure event parser", io);
// FIXME Tell the user of this error
} catch (EventParserConfigurationException epce) {
logger.log(Level.SEVERE, "Cannot configure event parser", epce);
// FIXME Tell the user of this error
}
}
/** Exit the Application */
private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm
System.exit(0);
}//GEN-LAST:event_exitForm
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
try {
new ControlCentre().show();
} catch (Exception e) {
System.out.println("Unable to load configuration file.");
e.printStackTrace();
}
}
/** Creates an events table for each of the event types
* and adds it to the tabbed pane displaying events.
*@param evts the events to display
*/
private void populateEventTables(Events evts) {
Enumeration evtTypes = evts.getTypes(); // all types of events
String strType; // type of events currently being processed
ArrayList typeEvts; // all events of a certain type
Event evt; // event currently being processed
Enumeration enuPartNames; // part names of current event
Vector columnNames; // table column names
Vector row; // current table row
Vector evtRows; // table rows for a specific event
String strPartName; // name of the part being processed
DefaultTableModel data; // data model for the events table
JTable jtable; // the table of events
JScrollPane scrPane;// the scroll pane for the table
logger.entering("org.fanfoot.gui", "populateEventTables(evts)");
tabpneEvents.removeAll();
javax.swing.JEditorPane htmlEditorPane = new javax.swing.JEditorPane();
htmlEditorPane.setContentType("text/html");
tabpneEvents.add("Summary", htmlEditorPane);
try {
org.saafe.ui.gui.xml.XMLTreePanel xmlTree = new org.saafe.ui.gui.xml.XMLTreePanel();
xmlTree.setDocument(evts.toXMLDoc());
scrPane = new JScrollPane();
scrPane.setViewportView(xmlTree);
tabpneEvents.add("Events", scrPane);
} catch (ParserConfigurationException pce) {
// FIXME Tell the user of this error
logger.log(Level.SEVERE, "XML Parser configuration error", pce);
}
try {
scores = new Scores(evts, scoringConfig);
} catch (ScoringConfigurationException sce) {
logger.log(Level.WARNING, "Unable to calculate scores", sce);
}
org.saafe.ui.gui.xml.XMLTreePanel xmlTree = new org.saafe.ui.gui.xml.XMLTreePanel();
xmlTree.setDocument(scores.getScoresDocument());
scrPane = new JScrollPane();
scrPane.setViewportView(xmlTree);
tabpneEvents.add("Scores", scrPane);
Document docScores2HTML = null;
try {
docScores2HTML = XMLUtils.parseXML(prefs.get("Scores2HTMLStylsheet", strDefaultScores2HTMLXSLFile));
} catch (Exception e) {
logger.log(Level.WARNING, "Unable to load XSL to convert scores doc to HTML.", e);
htmlEditorPane.setText("<h2>Error Parsing Scores</h2><p>" + e + "</p>");
}
try {
Document htmlScores = XMLUtils.transform(scores.getScoresDocument(), docScores2HTML);
String strHTML = XMLUtils.xmlToString(htmlScores);
logger.finest("HTML representation of scores is " + strHTML);
htmlEditorPane.setText(strHTML);
} catch (Exception e) {
logger.log(Level.WARNING, "Unable to convert scores document to HTML.", e);
htmlEditorPane.setText("<h2>Error Parsing Scores</h2><p>" + e + "</p>");
}
logger.finest("Event Types = " + evtTypes.toString());
while (evtTypes.hasMoreElements()) {
strType = (String)evtTypes.nextElement();
typeEvts = evts.getEventsByType(strType);
columnNames = new Vector();
evtRows = new Vector();
logger.finest("Processing events of type " + strType);
for (int i = 0; i < typeEvts.size(); i ++) {
evt = (Event)typeEvts.get(i);
row = new Vector();
enuPartNames = evt.getPartNames();
while (enuPartNames.hasMoreElements()) {
strPartName = (String)enuPartNames.nextElement();
if (! columnNames.contains(strPartName)) {
columnNames.add(strPartName);
logger.finest("Added column name " + strPartName);
}
row.add(evt.getPart(strPartName));
logger.finest("Added column data " + evt.getPart(strPartName));
}
evtRows.add(row);
}
data = new DefaultTableModel(evtRows, columnNames);
jtable = new JTable(data);
scrPane = new JScrollPane();
scrPane.setViewportView(jtable);
tabpneEvents.addTab(strType, null, scrPane, "Display events of type " + strType);
}
this.pack();
logger.exiting("org.fanfoot.gui", "populateEventTables(evts)");
}
/** Loaded Commentay file.
*
*/
public void retrievedCommentary(EventObject e) {
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JMenu mnuDebug;
private javax.swing.JMenuBar mnubarMain;
private javax.swing.JMenuItem parseBBCTExt1;
private javax.swing.JMenuItem setPaths;
private javax.swing.JTabbedPane tabpneEvents;
private javax.swing.JMenuItem mnuItemParseFile;
private javax.swing.JMenuItem mnuitemParseURL;
private javax.swing.JMenu mnuConfig;
private javax.swing.JMenu mnuFile;
// End of variables declaration//GEN-END:variables
}
|
|
From: <rga...@us...> - 2002-10-18 14:52:33
|
Update of /cvsroot/csms/csms-core
In directory usw-pr-cvs1:/tmp/cvs-serv8585
Modified Files:
properties.xml
Log Message:
Switching to using our own skin (based on the avalon site skin)
Index: properties.xml
===================================================================
RCS file: /cvsroot/csms/csms-core/properties.xml,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** properties.xml 17 Oct 2002 16:53:47 -0000 1.1.1.1
--- properties.xml 18 Oct 2002 14:52:30 -0000 1.2
***************
*** 42,46 ****
<skin
! name="avalon-site">
<navlinks>
<link1
--- 42,46 ----
<skin
! name="csms-site">
<navlinks>
<link1
***************
*** 52,56 ****
<link3
href="http://csms.sourceforge.net">Community
! SPorts Management System</link3>
</navlinks>
--- 52,56 ----
<link3
href="http://csms.sourceforge.net">Community
! Sports Management System</link3>
</navlinks>
|
|
From: <rga...@us...> - 2002-10-18 14:40:36
|
Update of /cvsroot/csms/csms-core
In directory usw-pr-cvs1:/tmp/cvs-serv3613
Modified Files:
module.xml
Log Message:
Adding dependant libraries
Index: module.xml
===================================================================
RCS file: /cvsroot/csms/csms-core/module.xml,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** module.xml 17 Oct 2002 16:53:47 -0000 1.1.1.1
--- module.xml 18 Oct 2002 14:40:32 -0000 1.2
***************
*** 6,10 ****
<url href="http://csms.sourceforge.net"/>
! <site hostname="krysalis.sourceforge.net"
remotedir="/home/groups/c/cs/csms/htdocs"/>
--- 6,10 ----
<url href="http://csms.sourceforge.net"/>
! <site hostname="csms.sourceforge.net"
remotedir="/home/groups/c/cs/csms/htdocs"/>
***************
*** 68,71 ****
--- 68,78 ----
<ant target="gump" vm="1.4"/>
+
+ <depend project="saafe-commons" version="supplied" export="true"/>
+ <depend project="jtidy" version="supplied" export="true"/>
+ <depend project="commons-jxpath" version="supplied" export="true"/>
+
+ <depend project="junit" version="supplied" export="false"/>
+ <depend project="xmlunit" version="supplied" export="false"/>
<!-- Work dirs to be included in classpath -->
|