From kawas at dev.open-bio.org Fri Jun 1 09:01:16 2007 From: kawas at dev.open-bio.org (Eddie Kawas) Date: Fri, 1 Jun 2007 09:01:16 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706011301.l51D1GZ5007989@dev.open-bio.org> kawas Fri Jun 1 09:01:15 EDT 2007 Update of /home/repository/moby/moby-live/Perl/MOBY In directory dev.open-bio.org:/tmp/cvs-serv7954 Modified Files: Central.pm Log Message: fixed the embedded cdata bug found by irri what happened was that in the message child of a registration element, we try to let the user know why the rdf was bad. Unfortunately, it was wrapped in a CDATA element. Now it isnt. moby-live/Perl/MOBY Central.pm,1.282,1.283 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.282 retrieving revision 1.283 diff -u -r1.282 -r1.283 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2007/02/20 01:02:01 1.282 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2007/06/01 13:01:15 1.283 @@ -1447,8 +1447,9 @@ "Registration successful but RDF is not correctly formatted:\n\n $RDF", $SVC->lsid, "" ); } + # wrap RDF in CDATA - moved it here, so that we can return the 'bad' rdf above return &_success( "Registration successful", $SVC->lsid, - $RDF ); + "" ); } sub _getServiceInstanceRDF { @@ -1467,7 +1468,9 @@ my $response = $browser->get($url); if ($response) { my $rdfXML = $response->content; - return "" unless ( $rdfXML =~ /title>Service Instance Not FoundService Instance Not Found kawas Thu Jun 7 10:26:46 EDT 2007 Update of /home/repository/moby/moby-live/Docs/MOBY-S_API In directory dev.open-bio.org:/tmp/cvs-serv23214/MOBY-S_API Modified Files: XMLPayloads.html Log Message: retrieveService end element was missing a '/' moby-live/Docs/MOBY-S_API XMLPayloads.html,1.18,1.19 =================================================================== RCS file: /home/repository/moby/moby-live/Docs/MOBY-S_API/XMLPayloads.html,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- /home/repository/moby/moby-live/Docs/MOBY-S_API/XMLPayloads.html 2007/02/05 14:30:46 1.18 +++ /home/repository/moby/moby-live/Docs/MOBY-S_API/XMLPayloads.html 2007/06/07 14:26:46 1.19 @@ -382,7 +382,7 @@
         <retrieveService>
             <Service authURI="authority.URI.here" serviceName="MyService"/>          
-        <retrieveService>
+        </retrieveService>
 

Output XML

From kawas at dev.open-bio.org Thu Jun 7 11:30:01 2007 From: kawas at dev.open-bio.org (Eddie Kawas) Date: Thu, 7 Jun 2007 11:30:01 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706071530.l57FU1SM023629@dev.open-bio.org> kawas Thu Jun 7 11:30:01 EDT 2007 Update of /home/repository/moby/moby-live/Docs/MOBY-S_API In directory dev.open-bio.org:/tmp/cvs-serv23593/MOBY-S_API Modified Files: XMLPayloads.html Log Message: xml from retrieveService was missing a '>' at the cdata element level moby-live/Docs/MOBY-S_API XMLPayloads.html,1.19,1.20 =================================================================== RCS file: /home/repository/moby/moby-live/Docs/MOBY-S_API/XMLPayloads.html,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- /home/repository/moby/moby-live/Docs/MOBY-S_API/XMLPayloads.html 2007/06/07 14:26:46 1.19 +++ /home/repository/moby/moby-live/Docs/MOBY-S_API/XMLPayloads.html 2007/06/07 15:30:01 1.20 @@ -392,7 +392,7 @@
          <Service authURI="authority.URI.here" serviceName="MyService" 
 	 lsid='urn:lsid:authority.uri:serviceinstance:id'>
-              <![CDATA[WSDL document here]]
+              <![CDATA[WSDL document here]]>
          </Service>
 
From gordonp at dev.open-bio.org Thu Jun 7 19:55:42 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 7 Jun 2007 19:55:42 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706072355.l57Ntg5u025474@dev.open-bio.org> gordonp Thu Jun 7 19:55:42 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client In directory dev.open-bio.org:/tmp/cvs-serv25439/src/main/org/biomoby/client Modified Files: CentralCachedCallsImpl.java Log Message: First stage commit of update: now concurrent requests for the sameCentral call are blocked, excepted for the first one moby-live/Java/src/main/org/biomoby/client CentralCachedCallsImpl.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralCachedCallsImpl.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralCachedCallsImpl.java 2006/07/07 04:12:39 1.1 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralCachedCallsImpl.java 2007/06/07 23:55:42 1.2 @@ -1,13 +1,15 @@ /** * Implements the functionality of caching by reusing identical calls to * MOBY central (e.g. asking multiple times what services take a DNA - * sequence in the gi namespace). + * sequence in the gi namespace). This is an in-memory cache in CentralImpl, + * but a filesystem cache backs it up here, so calls can be cached between + * JVM instances. */ package org.biomoby.client; import org.biomoby.shared.MobyException; -import java.util.Properties; +import java.util.*; public class CentralCachedCallsImpl extends CentralImpl{ @@ -15,6 +17,8 @@ protected static final long THE_EPOCH = 0; // don't care when the call is made, it shouldn't affect the onto mapping of calls to IDs protected static final Properties PROPERTIES = null; // don't have any properties for the call + protected Map inProgressCalls; // used to synchronize concurrent, redundant calls to Central + /************************************************************************* * Default constructor. It connects to a default Moby registry * (as defined in {@link #DEFAULT_ENDPOINT}) using a default namespace @@ -23,6 +27,7 @@ public CentralCachedCallsImpl() throws MobyException { super (DEFAULT_ENDPOINT, DEFAULT_NAMESPACE); + inProgressCalls = new HashMap(); } /************************************************************************* @@ -34,6 +39,7 @@ public CentralCachedCallsImpl (String endpoint) throws MobyException { super (endpoint, DEFAULT_NAMESPACE); + inProgressCalls = new HashMap(); } /************************************************************************* @@ -47,20 +53,59 @@ public CentralCachedCallsImpl (String endpoint, String namespace) throws MobyException { super (endpoint, namespace); + inProgressCalls = new HashMap(); } + /** + * The implementation of this method is smart enough that if the same call + * is made more than once, even concurrently(!), we only go to the server once, + * and use a cached value for all other invocations. + */ protected Object doCall (String method, Object[] parameters) throws MobyException { - String callKey = createId(method, parameters); - if(getCacheMode() && existsInCache(callKey)){ - return getContents(callKey); - } + Object result = null; - Object result = super.doCall(method, parameters); - + String callKey = createId(method, parameters); if(getCacheMode()){ - setContents(callKey, result); + + // It's in the cache? + if(existsInCache(callKey)){ + return getContents(callKey); + } + + // The same request is already in progress, in another thread? + Object inProgressCall = null; + synchronized(inProgressCalls){ + String threadName = inProgressCalls.get(callKey); + if(threadName == null){ + // No one's currently doing this request...claim it for this thread + threadName = Thread.currentThread().getName(); + inProgressCalls.put(callKey, threadName); + } + inProgressCall = threadName; + } + + // The first thread making a call will block subsequent ones with the same callKey + synchronized(inProgressCall){ + // Should be true for subsequent calls + if(existsInCache(callKey)){ + return getContents(callKey); + } + // Should get here only if I'm the first caller for the callKey, + // or subsequent call when previous doCall() for this callKey throws an exception + // i.e. setContents() isn't called after doCall() + try{ + result = super.doCall(method, parameters); + setContents(callKey, result); + } finally{ + // Remove the blocker, regardless of whether an Exception was thrown or not. + inProgressCalls.remove(callKey); + } + } + } + else{ + result = super.doCall(method, parameters); } return result; From gordonp at dev.open-bio.org Fri Jun 8 10:03:01 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 8 Jun 2007 10:03:01 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706081403.l58E31vM028646@dev.open-bio.org> gordonp Fri Jun 8 10:03:01 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/test In directory dev.open-bio.org:/tmp/cvs-serv28612/src/main/ca/ucalgary/seahawk/util/test Log Message: Directory /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/test added to the repository moby-live/Java/src/main/ca/ucalgary/seahawk/util/test - New directory rcsdiff: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/test/RCS/-,v: No such file or directory rcsdiff: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/test/RCS/New,v: No such file or directory rcsdiff: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/test/RCS/directory,v: No such file or directory From gordonp at dev.open-bio.org Fri Jun 8 10:04:27 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 8 Jun 2007 10:04:27 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706081404.l58E4Rsh028710@dev.open-bio.org> gordonp Fri Jun 8 10:04:27 EDT 2007 Update of /home/repository/moby/moby-live/Java In directory dev.open-bio.org:/tmp/cvs-serv28675 Modified Files: build.xml Log Message: Commit of Seahawk 1.0 updates and associated core updates moby-live/Java build.xml,1.63,1.64 =================================================================== RCS file: /home/repository/moby/moby-live/Java/build.xml,v retrieving revision 1.63 retrieving revision 1.64 diff -u -r1.63 -r1.64 --- /home/repository/moby/moby-live/Java/build.xml 2007/02/08 17:00:21 1.63 +++ /home/repository/moby/moby-live/Java/build.xml 2007/06/08 14:04:27 1.64 @@ -552,7 +552,16 @@ - + + + + + + + + + + From gordonp at dev.open-bio.org Fri Jun 8 10:04:27 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 8 Jun 2007 10:04:27 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706081404.l58E4RT1028730@dev.open-bio.org> gordonp Fri Jun 8 10:04:27 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/Clients In directory dev.open-bio.org:/tmp/cvs-serv28675/src/Clients Modified Files: HelloMOBY2.java Log Message: Commit of Seahawk 1.0 updates and associated core updates moby-live/Java/src/Clients HelloMOBY2.java,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/Clients/HelloMOBY2.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/Clients/HelloMOBY2.java 2006/04/06 13:42:44 1.3 +++ /home/repository/moby/moby-live/Java/src/Clients/HelloMOBY2.java 2007/06/08 14:04:27 1.4 @@ -32,7 +32,9 @@ // Ignoring start of request here, nothing for us to do // requestID is a unique ID for this invocation - public void start(MobyRequest request, int requestID){ + public void start(MobyRequestEvent mre){ + System.out.println("Data being sent is: "); + System.out.println(mre.getContent().toString()); } // Called by MobyRequest when the response is available From gordonp at dev.open-bio.org Fri Jun 8 10:04:27 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 8 Jun 2007 10:04:27 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706081404.l58E4RrM028790@dev.open-bio.org> gordonp Fri Jun 8 10:04:27 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv28675/src/main/ca/ucalgary/seahawk/gui Modified Files: FileAndTextTransferHandler.java MobyContentClipboard.java MobyContentGUI.java MobyContentHelpPane.java MobyContentPane.java MobyDataObjectWidget.java MobyObjectTransferHandler.java MobySaveDialog.java MobyServicesGUI.java MobyShimmer.java Added Files: MobyContentProducer.java SeahawkOptionsGUI.java Log Message: Commit of Seahawk 1.0 updates and associated core updates moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyContentProducer.java,NONE,1.1 SeahawkOptionsGUI.java,NONE,1.1 FileAndTextTransferHandler.java,1.5,1.6 MobyContentClipboard.java,1.3,1.4 MobyContentGUI.java,1.8,1.9 MobyContentHelpPane.java,1.2,1.3 MobyContentPane.java,1.7,1.8 MobyDataObjectWidget.java,1.1,1.2 MobyObjectTransferHandler.java,1.1,1.2 MobySaveDialog.java,1.2,1.3 MobyServicesGUI.java,1.10,1.11 MobyShimmer.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/FileAndTextTransferHandler.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/FileAndTextTransferHandler.java 2007/04/26 15:15:45 1.5 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/FileAndTextTransferHandler.java 2007/06/08 14:04:27 1.6 @@ -33,7 +33,6 @@ } public boolean importData(JComponent c, Transferable t) { - System.err.println("importData called for file and text transfer handler"); if (!canImport(c, t.getTransferDataFlavors())) { System.err.println("Cannot drop data into Seahawk: " + t); return false; =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentClipboard.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentClipboard.java 2007/04/03 02:34:08 1.3 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentClipboard.java 2007/06/08 14:04:27 1.4 @@ -1,13 +1,10 @@ package ca.ucalgary.seahawk.gui; +import ca.ucalgary.seahawk.util.DataRecorder; + import org.biomoby.client.MobyRequestEventHandler; -import org.biomoby.shared.data.MobyContentInstance; -import org.biomoby.shared.data.MobyDataInstance; -import org.biomoby.shared.data.MobyDataJob; -import org.biomoby.shared.data.MobyDataObject; -import org.biomoby.shared.data.MobyDataObjectSet; -import org.biomoby.shared.data.MobyDataUtils; +import org.biomoby.shared.data.*; import javax.swing.ImageIcon; import javax.swing.JLabel; @@ -51,8 +48,8 @@ private MobyDataInstance itemToDelete; private static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(MobyContentClipboard.class); public MobyContentClipboard(MobyContentGUI cGUI, MobyServicesGUI sGUI, JTabbedPane parentComponent, - JLabel statusBar){ - super(cGUI, sGUI, parentComponent, statusBar); + DataRecorder recorder, JLabel statusBar){ + super(cGUI, sGUI, parentComponent, recorder, statusBar); ClassLoader cl = getClass().getClassLoader(); if(cl == null){ =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java 2007/04/26 15:23:59 1.8 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java 2007/06/08 14:04:27 1.9 @@ -19,8 +19,9 @@ import org.biomoby.client.MobyRequest; import org.biomoby.client.MobyRequestEvent; import org.biomoby.client.MobyRequestEventHandler; +import org.biomoby.shared.*; import org.biomoby.shared.data.*; -import ca.ucalgary.seahawk.util.DescriptiveFileFilter; +import ca.ucalgary.seahawk.util.*; /** * Main interface component: textually displays the data in a MOBY content XML document. @@ -38,6 +39,7 @@ public final static String SAVE_BUTTON_NAME = "MCGsaveButton"; public final static String PRINT_BUTTON_NAME = "MCGprintButton"; public final static String HELP_BUTTON_NAME = "MCGhelpButton"; + public final static String SETTINGS_BUTTON_NAME = "MCGsettingsButton"; public final static String OPEN_OPTION_NAME = "MCGopenPopup"; public final static String FILE_OPEN_OPTION_NAME = "MCGopenPopupFileOption"; public final static String WEB_OPEN_OPTION_NAME = "MCGopenPopupWebOption"; @@ -69,11 +71,13 @@ private JButton saveButton; private JButton printButton; private JButton helpButton; + private JButton settingsButton; private Transformer moby2HTMLConverter; // XSLT engine private MobyServicesGUI servicesGUI; private DocumentBuilder docBuilder = null; private MobyContentClipboard clipboard; private MobyContentHelpPane helpPane; + private DataRecorder dataRecorder; // used for workflow export, etc. private boolean setup; private Map request2tab; private int activeTabIndex = -1; @@ -163,6 +167,15 @@ gridbag.setConstraints(helpButton, c); statusPanel.add(helpButton); + settingsButton = new JButton(new ImageIcon(cl.getResource("ca/ucalgary/seahawk/resources/images/settings.gif"))); + settingsButton.setToolTipText("Show program options"); + settingsButton.setPreferredSize(buttonSize); + settingsButton.setEnabled(true); + settingsButton.addActionListener(this); + settingsButton.setName(SETTINGS_BUTTON_NAME); + gridbag.setConstraints(settingsButton, c); + statusPanel.add(settingsButton); + status = new JLabel(DEFAULT_STATUS_MSG, SwingConstants.LEFT); JPanel labelPanel = new JPanel(); labelPanel.setLayout(new BorderLayout()); @@ -182,9 +195,16 @@ tabbedPane.setToolTipText("Hit to display a new tab"); tabbedPane.addKeyListener(this); + try{ + dataRecorder = new DataRecorder(servicesGUI.getMobyCentralImpl()); + } catch(Exception e){ + e.printStackTrace(); + } + clipboard = new MobyContentClipboard(this, servicesGUI, - tabbedPane, + tabbedPane, + dataRecorder, status); getContentPane().add(tabbedPane, java.awt.BorderLayout.CENTER); @@ -293,19 +313,20 @@ * Called by MOBYRequest when the service request is being sent. We * can create the GUI and wait message here. */ - public void start(MobyRequest request, int requestID){ + public void start(MobyRequestEvent requestEvent){ if(!setup){ setup(); } MobyContentPane tab = createTab("New Request"); - request2tab.put(new Integer(requestID), tab); - tab.start(request, requestID); + request2tab.put(new Integer(requestEvent.getID()), tab); + tab.start(requestEvent); } protected MobyContentPane createTab(String title){ MobyContentPane tab = new MobyContentPane(this, servicesGUI, - tabbedPane, + tabbedPane, + dataRecorder, status); setVisible(true); tab.setPreferredSize(getContentSize()); @@ -469,9 +490,10 @@ public int showHelpTab(){ if(helpPane == null){ helpPane = new MobyContentHelpPane(this, - servicesGUI, - tabbedPane, - status); + servicesGUI, + tabbedPane, + dataRecorder, + status); } // Not a tab in the display yet @@ -877,44 +899,28 @@ java.util.Locale.setDefault(java.util.Locale.ENGLISH); // Unless overridden on the command line, use xerces - if(System.getProperty("javax.xml.parsers.DocumentBuilderFactory") == null){ - System.setProperty("javax.xml.parsers.DocumentBuilderFactory", - "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl"); - } + //if(System.getProperty("javax.xml.parsers.DocumentBuilderFactory") == null){ + // System.setProperty("javax.xml.parsers.DocumentBuilderFactory", + // "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl"); + //} // Unless overridden on the command line, use xalan - if(System.getProperty("javax.xml.transform.TransformerFactory") == null){ - System.setProperty("javax.xml.transform.TransformerFactory", - "org.apache.xalan.processor.TransformerFactoryImpl"); - } + //if(System.getProperty("javax.xml.transform.TransformerFactory") == null){ + // System.setProperty("javax.xml.transform.TransformerFactory", + // "org.apache.xalan.processor.TransformerFactoryImpl"); + //} // Setting this explicitly prevents repeated calls to the META-INF file encoding the same - if(System.getProperty("org.apache.xerces.xni.parser.XMLParserConfiguration") == null){ - System.setProperty("org.apache.xerces.xni.parser.XMLParserConfiguration", - "org.apache.xerces.parsers.StandardParserConfiguration"); - } + //if(System.getProperty("org.apache.xerces.xni.parser.XMLParserConfiguration") == null){ + // System.setProperty("org.apache.xerces.xni.parser.XMLParserConfiguration", + // "org.apache.xerces.parsers.StandardParserConfiguration"); + //} -// if(System.getProperty("org.apache.commons.logging.Log") == null){ -// System.setProperty("org.apache.commons.logging.Log", -// "org.apache.commons.logging.impl.SimpleLog"); -// } - -// if(System.getProperty("org.apache.commons.logging.simplelog.defaultlog") == null){ -// System.setProperty("org.apache.commons.logging.simplelog.defaultlog", -// "error"); -// } + // First, restore any user preferences (uses default settings file location) + SeahawkOptions.restoreSettings(); - // The following command will cache all data type definitions for this session - new Thread(){ - public void run(){org.biomoby.shared.MobyDataType.getDataType("Object");} - }.start(); - new Thread(){ - public void run(){org.biomoby.shared.MobyServiceType.getServiceType("Analysis");} - }.start(); - // And the service definitions - //new Thread(){ - // public void run(){org.biomoby.shared.MobyService.getService("","");} - // }.start(); + // Asynchronously load up ontology data so it's ready when the user needs it. + cacheOntologies(); MobyContentGUI gui = ca.ucalgary.seahawk.util.MobyUtils.getMobyContentGUI(new JLabel()); gui.setDefaultCloseOperation(defaultCloseOperation); @@ -942,6 +948,43 @@ } } + protected static void cacheOntologies(){ + final org.biomoby.registry.meta.Registry preferredRegistry = SeahawkOptions.getRegistry(); + + // Redirect the registry endpoints to local cache files if available + // preferredRegistry and/or dataDefURL may be null, if not cached, but that's okay to pass around + + // The following command will cache all data type definitions for this session + new Thread(){ + public void run(){ + URL dataDefURL = RegistryCache.getDataTypeOntologyURL(preferredRegistry); + if(dataDefURL != null){ + // Use the cached file rather than actually going to the registry + MobyDataType.loadDataTypes(dataDefURL, preferredRegistry); + } + else{ + MobyDataType.getDataType("Object", preferredRegistry); + } + } + }.start(); + new Thread(){ + public void run(){ + URL serviceTypeDefURL = RegistryCache.getServiceTypeOntologyURL(preferredRegistry); + if(serviceTypeDefURL != null){ + // Use the cached file rather than actually going to the registry + MobyServiceType.loadServiceTypes(serviceTypeDefURL, preferredRegistry); + } + else{ + MobyServiceType.getServiceType("Analysis", preferredRegistry); + } + } + }.start(); + // And the service definitions + //new Thread(){ + // public void run(){org.biomoby.shared.MobyService.getService("","");} + // }.start(); + } + /** * Method to be called when an applet is being decommissioned. */ =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentHelpPane.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentHelpPane.java 2007/02/08 16:59:57 1.2 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentHelpPane.java 2007/06/08 14:04:27 1.3 @@ -1,6 +1,8 @@ package ca.ucalgary.seahawk.gui; +import ca.ucalgary.seahawk.util.DataRecorder; + import org.biomoby.client.MobyRequestEventHandler; import org.biomoby.shared.data.MobyContentInstance; import org.biomoby.shared.data.MobyDataInstance; @@ -39,8 +41,8 @@ private static URL helpHTMLURL; private static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(MobyContentHelpPane.class); public MobyContentHelpPane(MobyContentGUI cGUI, MobyServicesGUI sGUI, JTabbedPane parentComponent, - JLabel statusBar){ - super(cGUI, sGUI, parentComponent, statusBar); + DataRecorder recorder, JLabel statusBar){ + super(cGUI, sGUI, parentComponent, recorder, statusBar); // So JFCUnit tests can find it setName(HELP_TAB_NAME); =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java 2007/04/18 16:04:06 1.7 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java 2007/06/08 14:04:27 1.8 @@ -1,8 +1,7 @@ package ca.ucalgary.seahawk.gui; -// For external links -import ca.ucalgary.seahawk.util.BrowserLauncher; +import ca.ucalgary.seahawk.util.*; import org.biomoby.client.MobyRequest; import org.biomoby.client.MobyRequestEvent; @@ -19,14 +18,10 @@ import org.apache.xpath.*; import org.apache.xpath.objects.*; -import ca.ucalgary.seahawk.util.*; - import javax.swing.*; import javax.swing.event.*; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Point; +import java.awt.*; import java.awt.print.*; import java.awt.event.*; import java.io.*; @@ -67,17 +62,19 @@ private int lastClickY = 1; private boolean hasFailed = false; private boolean isContentsXML = false; + private DataRecorder dataRecorder; // Text selection members private int dot; private int mark; private String selectedTextData; private static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(MobyContentPane.class); - public MobyContentPane(MobyContentGUI cGUI, MobyServicesGUI sGUI, JTabbedPane parentComponent, JLabel statusBar){ + public MobyContentPane(MobyContentGUI cGUI, MobyServicesGUI sGUI, JTabbedPane parentComponent, DataRecorder recorder, JLabel statusBar){ tabbedPane = parentComponent; status = statusBar; contentGUI = cGUI; servicesGUI = sGUI; + dataRecorder = recorder; // The next line is what provides the drag 'n' drop capability addKeyListener(this); @@ -89,7 +86,6 @@ editorPane = new PrintableJEditorPane(); editorPane.addKeyListener(this); editorPane.setTransferHandler(getTransferHandler()); - //editorPane.setPreferredSize(parentComponent.getPreferredSize()); editorPane.setEditable(false); editorPane.addMouseListener(this); editorPane.addHyperlinkListener(this); @@ -254,11 +250,12 @@ else if(htmlContents.indexOf(" ") != -1){ htmlContents = htmlContents.replaceAll(">([^<]+ [^<]+)<", ">
$1
<"); } - //else{ + else{ // Break up any really long DNA/AA stretches - htmlContents = htmlContents.replaceAll("([a-zA-Z]{60,})", "
$1
"); - htmlContents = htmlContents.replaceAll("([a-zA-Z]{60})", "$1\n"); - //} + System.err.println("Trying to break up long streches"); + htmlContents = htmlContents.replaceAll("([a-zA-Z]{60})", "\n
$1"); + htmlContents = htmlContents.replaceAll("([a-zA-Z]{60})([a-zA-Z]{1,})", "$1\n
$2
\n"); + } // Otherwise assume it's formatted resultBuffer.append(htmlContents); } @@ -286,9 +283,7 @@ // Assume it's plain text, or whatever the JEditorPane can glean from the content-type // such as a remote HTML or RTF doc, because result buffer will be empty in condition below else{ - editorPane.setContentType("text/plain"); isContentsXML = false; - editorPane.setFont(java.awt.Font.getFont("Monospaced")); } if(resultBuffer.length() == 0){ @@ -313,7 +308,12 @@ logger.error("Failure in loading MOBYfied binary data:\n" + e); } // Shouldn't get here unless either not binary, or the binary data load failed - editorPane.setPage(url); + System.err.println("Is plain text"); + editorPane.setContentType("text/html"); + resultBuffer = new StringBuffer("
"+
+						getInputStreamContents(url.openStream()).replaceAll("&", "&").replaceAll("<","<")+
+						"
"); + editorPane.setText(resultBuffer.toString()); } else{ editorPane.setText(resultBuffer.toString()); @@ -322,6 +322,8 @@ } // Regardless of the doc, scroll to a reference called "start:" if available. // By default the pane will annoyingly scroll to the bottom when new data is loaded. + try{Thread.sleep(1000);} // Give it time to paint before scrolling + catch(Exception te){} editorPane.scrollToReference("start"); } catch (java.io.IOException ioe) { @@ -385,11 +387,19 @@ * Called by MOBYRequest when the service request is being sent. We * can create the GUI and wait message here. */ - public void start(MobyRequest request, int requestID){ + public void start(MobyRequestEvent requestEvent){ hasFailed = false; tabbedPane.setSelectedComponent(this); - tabbedPane.setTitleAt(tabbedPane.indexOfComponent(this), ""+requestID+"-"+request.getService().getName()); + tabbedPane.setTitleAt(tabbedPane.indexOfComponent(this), + ""+requestEvent.getID()+"-"+requestEvent.getService().getName()); setWaitScreen(); + // Store the request being sent (w/ 2ndary params and all), + // for reference (e.g. when exporting a workflow) + try{ + dataRecorder.saveInputData(requestEvent); + } catch(Exception e){ + e.printStackTrace(); + } } public void stop(MobyRequest request, int requestID){ @@ -474,6 +484,20 @@ return hasFailed; } + public String toScufl() throws Exception{ + URL[] historyToExport = (URL[]) history.toArray(new URL[history.size()]); + if(historyIndex != historyToExport.length-1){ + // Shorten the array if we aren't cuurently on the last doc (i.e. + // we don't want to export documents forward in the history) + URL[] truncatedHistory = new URL[historyIndex]; + System.arraycopy(historyToExport, 0, truncatedHistory, 0, historyIndex); + historyToExport = truncatedHistory; + } + ByteArrayOutputStream output = new ByteArrayOutputStream(); + dataRecorder.exportWorkflow(historyToExport, output, DataRecorder.TAVERNA15); + return output.toString(); + } + // Save the MOBY data to a file, then tell NewBrowser to load that local file URL protected void loadDataInBrowser(MobyRequestEvent mre){ @@ -509,21 +533,12 @@ } try { - // Create temp file. - File temp = File.createTempFile(serviceToFilePrefix(mobyRequest.getService()), ".xml"); - - // Delete temp file when program exits. - temp.deleteOnExit(); - - // Write to temp file - FileWriter out = new FileWriter(temp); - out.write(mre.getContentsXML()); - out.close(); - gotoURL(temp.toURL(), true); - } catch (IOException ioe) { + URL outputURL = dataRecorder.saveOutputData(mre); + gotoURL(outputURL, true); + } catch (Exception e) { failed("Could not write a local file"); - editorPane.setText("ERROR: Could not write temporary file for MOBY results: " + ioe); - ioe.printStackTrace(); + editorPane.setText("ERROR: Could not write temporary file for MOBY results: " + e); + e.printStackTrace(); return; } succeeded(responseType); @@ -821,12 +836,12 @@ } if(mobyString != null){ - mobyData = new MobyDataString("", mobyString); + mobyData = new MobyDataString("", mobyString, SeahawkOptions.getRegistry()); } else{ - mobyData = new MobyDataObject(""); + mobyData = new MobyDataObject("", SeahawkOptions.getRegistry()); } - mobyData.addNamespace(MobyNamespace.getNamespace(namespace)); + mobyData.addNamespace(MobyNamespace.getNamespace(namespace, SeahawkOptions.getRegistry())); if(mobyID != null){ mobyData.setId(mobyID); @@ -952,8 +967,8 @@ * This method tries to figure out what kinds of MOBY Data could be * created from the string given. e.g. Keywords, DNASequence, etc. */ - protected MobyDataInstance[] loadMobyDataFromString(String data, boolean reverseSelected){ - return MobyUtils.convertStringToObjects(data, reverseSelected); + protected MobyDataInstance[] loadMobyDataFromString(String data){ + return MobyUtils.convertStringToObjects(data); } public boolean isMobyURL(URL u){ @@ -964,8 +979,8 @@ // MouseListener interface implementation public void mouseClicked(MouseEvent e){ // Allow middle button paste - if(e.getButton() == MouseEvent.BUTTON3 || - e.getButton() == MouseEvent.BUTTON2 && e.isAltDown()){ + if(e.getButton() == MouseEvent.BUTTON2 || + e.getButton() == MouseEvent.BUTTON3 && e.isAltDown()){ paste(); } } @@ -999,7 +1014,7 @@ if(selectedTextData == null){ return; } - MobyDataInstance[] mobyData = loadMobyDataFromString(selectedTextData, mark > dot); + MobyDataInstance[] mobyData = loadMobyDataFromString(selectedTextData); if(mobyData == null || mobyData.length == 0){ logger.warn("No MobyData could be made from the selected text"); return; @@ -1066,111 +1081,6 @@ status.setText("Click your selection to use as MOBY data!"); } - private MobyService getService(int index) throws Exception{ - String filename = ((URL) history.elementAt(index)).getPath(); - if(filename.lastIndexOf('/') != -1){ - filename = filename.substring(filename.lastIndexOf('/')+1); - } - return filePrefixToService(filename); - } - - private String getScuflProcessor(int index) throws Exception{ - MobyService service = getService(index); - - if(service == null){ //data was loaded from file, not from a service - return ""; - } - - StringBuffer secondaryParams = new StringBuffer(); - // example input human - - return " \n"+ - " "+service.getDescription()+"\n" + - " \n"+ - " "+servicesGUI.getMobyCentralImpl().getRegistryEndpoint()+"\n"+ - " "+service.getName()+"\n"+ - " "+service.getAuthority()+"\n"+ - secondaryParams.toString() + - " \n"+ - " \n"; - - } - - public String toScufl() throws Exception{ - - StringBuffer scufl = new StringBuffer(); - scufl.append("\n" + - "\n" + - " \n"); - - // The first service to be called - int i = 0; - MobyService firstService = getService(i); - while(firstService == null){ - firstService = getService(++i); - } - MobyPrimaryData[] inputData = firstService.getPrimaryInputs(); - if(inputData != null && inputData.length != 0){ - // Seahawk only deals with single input services for now - scufl.append(" \n"+ - " Generates "+inputData[0].getDataType().getDescription()+"\n"+ - " \n"+ - " "+servicesGUI.getMobyCentralImpl().getRegistryEndpoint()+"\n"+ - " "+inputData[0].getDataType().getName()+"\n"+ - " \n"+ - " \n"+ - " \n"); - - MobyNamespace[] inputNS = inputData[0].getNamespaces(); - String nsNames = "Object"; - if(inputNS != null && inputNS.length != 0){ - String firstNS = inputNS[0].getName().replaceAll("urn:lsid:biomoby.org:namespacetype:(.*?):.*", "$1"); - nsNames = firstNS; - for(int j = 1; j < inputNS.length; j++){ - nsNames = nsNames + "_or_" + inputNS[j].getName().replaceAll("[^A-Za-z0-9_]", "_"); - } - nsNames = nsNames.replaceAll("[^A-Za-z0-9_]", "_"); - nsNames = nsNames + "_"; - // Predefine the namespace for the user since it's available - scufl.append("" - + firstNS + "\n"); - } - else{ - scufl.append("\n"); - } - scufl.append("\n" + - " text/plain\n"+ - "\n"); - - scufl.append(getScuflProcessor(i)); - - scufl.append("\n" + - "\n" + - ""); - } - else{ - // service has no input if we're here... - scufl.append(getScuflProcessor(i)); - } - - // for each history element, there was a service execution that generated the data - for(; i < historyIndex; i++){ - scufl.append(getScuflProcessor(i+1)); - scufl.append("\n"); - } - scufl.append("\n"); - scufl.append("" + - "text/xml"+ - "\n"); - scufl.append("\n"); - - return scufl.toString(); - } - /** * Implemented to provide paste functionality (control-v or the paste button on a Sun keyboard), * since the editor panes are not editable and therefore by default do not respond to =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyDataObjectWidget.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyDataObjectWidget.java 2007/04/26 15:19:58 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyDataObjectWidget.java 2007/06/08 14:04:27 1.2 @@ -16,7 +16,7 @@ * the user to drop data onto it via a MobyObjectTransferHandler * (hence the implementation of MobyObjectReceiver). */ -public class MobyDataObjectWidget extends JLabel implements MobyObjectReceiver{ +public class MobyDataObjectWidget extends JLabel implements MobyObjectReceiver, MobyContentProducer{ public static final int PARAM_TOOLTIP_WIDTH = 50; public static final Color INSTANTIATED_FG_COLOUR = Color.DARK_GRAY; public static final Color UNINSTANTIATED_FG_COLOUR = Color.RED; @@ -58,7 +58,17 @@ setTransferHandler(MobyObjectTransferHandler.getHandler(client)); } + // Enables copying of MOBY data to the clipboard + addMouseListener(new DragMouseAdapter()); + } + // Shamelessly copied from the Java DnD tutorial's LabalDND.java + private class DragMouseAdapter extends MouseAdapter { + public void mousePressed(MouseEvent e) { + JComponent c = (JComponent)e.getSource(); + TransferHandler handler = c.getTransferHandler(); + handler.exportAsDrag(c, e, TransferHandler.COPY); + } } private Icon getInstantiatedIcon(){ @@ -221,4 +231,11 @@ acceptableData.put(name, targetData); return acceptableData; } + + /** + * Used to send data out to the clipboard. + */ + public MobyContentInstance exportMobyContent(){ + return null; + } } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyObjectTransferHandler.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyObjectTransferHandler.java 2007/04/26 15:19:58 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyObjectTransferHandler.java 2007/06/08 14:04:27 1.2 @@ -1,6 +1,7 @@ package ca.ucalgary.seahawk.gui; import ca.ucalgary.seahawk.util.HTMLUtils; +import ca.ucalgary.seahawk.util.MobyUtils; import ca.ucalgary.seahawk.services.MobyClient; import org.biomoby.shared.MobyPrefixResolver; import org.biomoby.shared.*; @@ -28,7 +29,7 @@ * be convertible into a desired Moby Object data type in order to be dropped. Components using this * class as their TransferHandler should implement MobyObjectReceiver for this to do something meaningful. */ -public class MobyObjectTransferHandler extends FileAndTextTransferHandler { +public class MobyObjectTransferHandler extends FileAndTextTransferHandler implements ClipboardOwner{ private MobyClient client; private static Map handlers; @@ -309,5 +310,34 @@ keeper.put(key, entry.getValue()); } } -} + /** + * Drag and copy functiunality. + */ + public void exportToClipboard(JComponent comp, + Clipboard clip, + int action) throws IllegalStateException{ + Transferable createdData = null; + try{ + if(!(comp instanceof MobyContentProducer)){ + throw new IllegalStateException("Component calling exportToClipboard " + + "was not a MobyObjectProducer as expected, export aborted"); + } + createdData = MobyUtils.createTransferable(((MobyContentProducer) comp).exportMobyContent()); + clip.setContents(createdData, this); + } catch(IllegalStateException e){ + // To be consistent with the normal transfer handler, call exportDone + // even if we failed + exportDone(comp, createdData, TransferHandler.NONE); + throw e; + } + exportDone(comp, createdData, action); + } + + /** + * To satisfy the ClipboardOwner interface. + */ + public void lostOwnership(Clipboard clipboard, Transferable contents){ + + } +} =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobySaveDialog.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobySaveDialog.java 2007/02/08 16:59:57 1.2 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobySaveDialog.java 2007/06/08 14:04:27 1.3 @@ -113,6 +113,7 @@ ostream.flush(); ostream.close(); } catch (Exception ex) { + ex.printStackTrace(); JOptionPane.showMessageDialog(null, "Cannot save the Seahawk tab history as a Taverna workflow: "+ex, "Error saving", JOptionPane.ERROR_MESSAGE); } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyServicesGUI.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyServicesGUI.java 2007/04/26 15:26:24 1.10 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyServicesGUI.java 2007/06/08 14:04:27 1.11 @@ -2,20 +2,23 @@ import ca.ucalgary.seahawk.services.MobyClient; import ca.ucalgary.seahawk.util.HTMLUtils; -import javax.swing.*; -import org.w3c.dom.*; +import ca.ucalgary.seahawk.util.SeahawkOptions; + import org.biomoby.shared.*; import org.biomoby.shared.data.*; import org.biomoby.client.MobyRequest; import org.biomoby.client.MobyRequestEventHandler; -import java.lang.ref.WeakReference; +import org.w3c.dom.*; + import java.awt.event.*; import java.awt.*; import java.io.*; +import java.lang.ref.WeakReference; import java.text.Collator; import java.net.URL; import java.util.*; +import javax.swing.*; import javax.swing.event.PopupMenuListener; import javax.swing.event.PopupMenuEvent; @@ -249,8 +252,8 @@ // Need to choose among multiple parameters if(paramMatch.size() > 1){ targetParamName = (String) JOptionPane.showInputDialog(null, - "Choose the service parameter the chosen " + - "object represents", + "Choose the service parameter\n"+ + "the chosen object represents", "Service Parameter Choice", JOptionPane.QUESTION_MESSAGE, null, @@ -783,7 +786,8 @@ MobyDataType outputType = null; if(output != null && output.length != 0 && output[0] instanceof MobyPrimaryData){ - outputType = MobyDataType.getDataType(((MobyPrimaryData) output[0]).getDataType().getName()); + outputType = MobyDataType.getDataType(((MobyPrimaryData) output[0]).getDataType().getName(), + SeahawkOptions.getRegistry()); } if(outputType == null){ logger.warn("No output data type (ontology) was associated with service " + @@ -1176,7 +1180,7 @@ } // Make sure we have a fully documented data type object - mobyDataType = MobyDataType.getDataType(targetData.getDataType().getName()); + mobyDataType = MobyDataType.getDataType(targetData.getDataType().getName(), SeahawkOptions.getRegistry()); String desc = null; String datatype = null; if(mobyDataType == null){ =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyShimmer.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyShimmer.java 2007/02/08 16:59:57 1.2 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyShimmer.java 2007/06/08 14:04:27 1.3 @@ -115,7 +115,7 @@ } } - public void start(MobyRequest request, int requestID){ + public void start(MobyRequestEvent requestEvent){ } public void processEvent(MobyRequestEvent mre){ From gordonp at dev.open-bio.org Fri Jun 8 10:04:27 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 8 Jun 2007 10:04:27 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706081404.l58E4Rrh028892@dev.open-bio.org> gordonp Fri Jun 8 10:04:27 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util In directory dev.open-bio.org:/tmp/cvs-serv28675/src/main/ca/ucalgary/seahawk/util Modified Files: HTMLUtils.java MobyUtils.java Added Files: DataRecorder.java MobyDataTransferable.java RegistryCache.java SeahawkOptions.java Log Message: Commit of Seahawk 1.0 updates and associated core updates moby-live/Java/src/main/ca/ucalgary/seahawk/util DataRecorder.java,NONE,1.1 MobyDataTransferable.java,NONE,1.1 RegistryCache.java,NONE,1.1 SeahawkOptions.java,NONE,1.1 HTMLUtils.java,1.2,1.3 MobyUtils.java,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/HTMLUtils.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/HTMLUtils.java 2007/04/26 15:15:45 1.2 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/HTMLUtils.java 2007/06/08 14:04:27 1.3 @@ -180,21 +180,25 @@ org.w3c.dom.Element data = db.parse(new ByteArrayInputStream(xmltext.getBytes())).getDocumentElement(); if(data.getLocalName().equals(MobyTags.MOBY)){ - content = MobyDataUtils.fromXMLDocument(data); + content = MobyDataUtils.fromXMLDocument(data, SeahawkOptions.getRegistry()); } else if(data.getLocalName().equals(MobyTags.MOBYCONTENT)){ - content = new MobyContentInstance(data); + content = new MobyContentInstance(data, SeahawkOptions.getRegistry()); } else if(data.getLocalName().equals(MobyTags.MOBYDATA)){ content = new MobyContentInstance(); - content.parseDataGroup(data); + content.parseDataGroup(data, SeahawkOptions.getRegistry()); } else{ // Any other data can be processed by the base object class - content = new MobyContentInstance(MobyDataObject.createInstanceFromDOM(data), "Drag 'n' Drop data"); + content = new MobyContentInstance(MobyDataObject.createInstanceFromDOM(data, SeahawkOptions.getRegistry()), + "Drag 'n' Drop data"); } } catch(Exception e){ e.printStackTrace(); + System.err.println("This issue may be related to your choice of registry ("+ + (SeahawkOptions.getRegistry() == null ? "MOBY default" : SeahawkOptions.getRegistry().getSynonym()) + +")"); } return content; } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/MobyUtils.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/MobyUtils.java 2007/04/18 15:55:18 1.6 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/MobyUtils.java 2007/06/08 14:04:27 1.7 @@ -4,10 +4,12 @@ import ca.ucalgary.seahawk.gui.MobyServicesGUI; import ca.ucalgary.seahawk.services.MobyClient; +import org.biomoby.registry.meta.Registry; import org.biomoby.shared.data.*; import org.biomoby.shared.MobyDataType; import org.biomoby.shared.MobyNamespace; +import java.awt.datatransfer.Transferable; import java.io.ByteArrayOutputStream; import java.io.InputStream; import java.net.URL; @@ -24,6 +26,10 @@ private static MobyContentGUI mobyContentGUI = null; private static MobyServicesGUI mobyServicesGUI = null; + + public static Transferable createTransferable(MobyContentInstance contents){ + return null; + } /** * The purpose of this method is to create a MOBY document to encapsulate @@ -47,20 +53,22 @@ // Find MOBY Objects in it MobyDataObject[] foundObjects = client.getMobyObjects(bytes.toByteArray(), - MobyDataType.getDataType(MobyDataBytes.BASE64_DATATYPE)); + MobyDataType.getDataType(MobyDataBytes.BASE64_DATATYPE, + SeahawkOptions.getRegistry())); // Did we unambiguously find one binary object? if(foundObjects != null && foundObjects.length == 1){ MobyContentInstance mci = new MobyContentInstance(); String[] dataName = url.getPath().split("/"); MobyDataJob job = new MobyDataJob(); job.put(dataName[dataName.length-1], foundObjects[0]); + System.err.println("Namespace of found object was " + foundObjects[0].getPrimaryNamespace().getName()); mci.put(dataName[dataName.length-1], job); // name the data by the last part of the URL path return mci; } return null; } - public static MobyDataInstance[] convertStringToObjects(String data, boolean reverseSelected){ + public static MobyDataInstance[] convertStringToObjects(String data){ if(data == null){ return new MobyDataInstance[0]; } @@ -74,23 +82,13 @@ } // Can always use the data as a string - MobyDataString strObject = new MobyDataString(objectName, data); + MobyDataString strObject = new MobyDataString(objectName, data, SeahawkOptions.getRegistry()); strObject.setPrimaryNamespace(new MobyNamespace("seahawk")); objects.add(strObject); // See if it's sequence MobyDataComposite mdc = createMobySequence(data, "user-selection"); if(mdc != null){ - // reverse complement DNA if necessary - if(reverseSelected && - (mdc.getDataType() == MobyDataType.getDataType("DNASequence") || - mdc.getDataType() == MobyDataType.getDataType("RNASequence"))){ - - MobyDataComposite nucObject = (MobyDataComposite) mdc; - MobyDataString seq = (MobyDataString) nucObject.get("SequenceString"); - seq.setValue(Sequence.reverseComplement(seq.toString())); - } - mdc.setName(objectName); objects.add(mdc); } @@ -99,8 +97,9 @@ if(data.trim().matches("^[A-Za-z0-9_-]{3,35}$")){ objects.add(new MobyDataComposite("Global_Keyword", "dummy_name", - "seahawk", - data.trim())); + "unknown", + data.trim(), + SeahawkOptions.getRegistry())); } } @@ -163,19 +162,22 @@ sequence = new MobyDataComposite("DNASequence", "dummy_name", "seahawk", - id); + id, + SeahawkOptions.getRegistry()); } else if(Sequence.isRNA(sequenceData)){ sequence = new MobyDataComposite("RNASequence", "dummy_name", "seahawk", - id); + id, + SeahawkOptions.getRegistry()); } else if(Sequence.isProtein(sequenceData)){ sequence = new MobyDataComposite("AminoAcidSequence", "dummy_name", "seahawk", - id); + id, + SeahawkOptions.getRegistry()); } // Not a recognized type of sequence else{ @@ -183,8 +185,8 @@ } sequenceData = sequenceData.replaceAll("[ \t\r\n0-9]", ""); // strip whitespace and possible milestone digits - sequence.put("SequenceString", new MobyDataString(sequenceData)); - sequence.put("Length", new MobyDataInt(sequenceData.length())); + sequence.put("SequenceString", new MobyDataString(sequenceData, SeahawkOptions.getRegistry())); + sequence.put("Length", new MobyDataInt(sequenceData.length(), SeahawkOptions.getRegistry())); return sequence; } From gordonp at dev.open-bio.org Fri Jun 8 10:04:27 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 8 Jun 2007 10:04:27 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706081404.l58E4RdT028818@dev.open-bio.org> gordonp Fri Jun 8 10:04:27 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources In directory dev.open-bio.org:/tmp/cvs-serv28675/src/main/ca/ucalgary/seahawk/resources Modified Files: MobyContentGUIHelp.html mobyBuilderRules.xml startup.html Log Message: Commit of Seahawk 1.0 updates and associated core updates moby-live/Java/src/main/ca/ucalgary/seahawk/resources MobyContentGUIHelp.html,1.1,1.2 mobyBuilderRules.xml,1.4,1.5 startup.html,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/MobyContentGUIHelp.html,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/MobyContentGUIHelp.html 2006/10/25 02:33:22 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/MobyContentGUIHelp.html 2007/06/08 14:04:27 1.2 @@ -49,6 +49,12 @@

How do I create data?

+

Drag and Drop / Cut and Paste

+

+ The easiest way to create data is to simply drag a file, text selection, or Web link + onto the Seahawk interface. Seahawk will try to display the data you drop. +

+

Loading documents

Click the folder/Web icon on the bottom toolbar will give you the option of @@ -64,14 +70,13 @@ With the mouse, you can highlight arbitrary sections of text in the Seahawk display. Clicking within selected text will raise a popup menu showing MOBY service options. Seahawk will try to determine the type of data highlighted are - potentially show services for the selection as a: + potentially show services for the selection as a, among other things:

  • String
  • Search Keyword
  • Database Identifier
  • Protein Sequence
  • -
  • DNA/RNA Sequence (note that highlighting sequence right-to-left - will create the reverse complement)
  • +
  • DNA/RNA Sequence

=================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/mobyBuilderRules.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/mobyBuilderRules.xml 2007/04/26 15:30:01 1.4 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/mobyBuilderRules.xml 2007/06/08 14:04:27 1.5 @@ -4,15 +4,26 @@ http://www.bioxml.info/dtd/tigrxml.dtd http://www.bioxml.info/dtd/Bioseq.dtd - + - (\N+(?:\x20|\r|\t|\n)?)+ + (\N*\s*(\N{10,}(?:\x20|\r|\t|\n)?)+\N*) - unknown + '' + + $1 + string-length('$1') + + + + + (\P*\s*(\P{10,}(?:\x20|\r|\t|\n)?)+\P*) + + + '' - $2 - string-length('$2') + $1 + string-length('$1') =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/startup.html,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/startup.html 2007/04/26 15:31:00 1.3 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/startup.html 2007/06/08 14:04:27 1.4 @@ -14,6 +14,8 @@ For example data, and more help on using Seahawk to automatically discover and run Web-based analysis services, please click the help icon at the bottom of this window. - +

+Please help us improve Seahawk by completing a user survey! +

From gordonp at dev.open-bio.org Fri Jun 8 10:04:28 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 8 Jun 2007 10:04:28 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706081404.l58E4Si0029000@dev.open-bio.org> gordonp Fri Jun 8 10:04:27 EDT 2007 Update of /home/repository/moby/moby-live/Java/xmls In directory dev.open-bio.org:/tmp/cvs-serv28675/xmls Modified Files: seahawkBuild.xml Log Message: Commit of Seahawk 1.0 updates and associated core updates moby-live/Java/xmls seahawkBuild.xml,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Java/xmls/seahawkBuild.xml,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Java/xmls/seahawkBuild.xml 2006/12/15 04:39:52 1.7 +++ /home/repository/moby/moby-live/Java/xmls/seahawkBuild.xml 2007/06/08 14:04:27 1.8 @@ -25,6 +25,10 @@ + + + + @@ -87,7 +91,7 @@ - + @@ -129,10 +133,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+
+
+ + + + + +
+ + - + + From gordonp at dev.open-bio.org Fri Jun 8 10:04:27 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 8 Jun 2007 10:04:27 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706081404.l58E4R6A028906@dev.open-bio.org> gordonp Fri Jun 8 10:04:27 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/test In directory dev.open-bio.org:/tmp/cvs-serv28675/src/main/ca/ucalgary/seahawk/util/test Added Files: DataRecorderTestCase.java Log Message: Commit of Seahawk 1.0 updates and associated core updates moby-live/Java/src/main/ca/ucalgary/seahawk/util/test DataRecorderTestCase.java,NONE,1.1 From gordonp at dev.open-bio.org Fri Jun 8 10:04:27 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 8 Jun 2007 10:04:27 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706081404.l58E4Rf5028832@dev.open-bio.org> gordonp Fri Jun 8 10:04:27 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/images In directory dev.open-bio.org:/tmp/cvs-serv28675/src/main/ca/ucalgary/seahawk/resources/images Added Files: settings.gif Log Message: Commit of Seahawk 1.0 updates and associated core updates moby-live/Java/src/main/ca/ucalgary/seahawk/resources/images settings.gif,NONE,1.1 From gordonp at dev.open-bio.org Fri Jun 8 10:04:27 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 8 Jun 2007 10:04:27 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706081404.l58E4Rf5028926@dev.open-bio.org> gordonp Fri Jun 8 10:04:27 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/resources In directory dev.open-bio.org:/tmp/cvs-serv28675/src/main/ca/ucalgary/services/resources Modified Files: acdRules.xml Log Message: Commit of Seahawk 1.0 updates and associated core updates moby-live/Java/src/main/ca/ucalgary/services/resources acdRules.xml,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/resources/acdRules.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/resources/acdRules.xml 2007/03/12 14:33:38 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/resources/acdRules.xml 2007/06/08 14:04:27 1.2 @@ -35,7 +35,7 @@ - >\s*(\S+)\s*([^\n]+)((?:\n\N+)+) + >\x20*(\S+)\x20+([^\n]+)((?:\n\N+)+) $1 @@ -46,7 +46,7 @@ - >\s*(\S*)\s*((?:\n\N+)+) + >\x20*(\S*)\x20*((?:\n\N+)+) $1 @@ -58,7 +58,7 @@ - >\s*(\S+)\s+([^\n]+)((?:\n\P+)+) + >\x20*(\S+)\x20+([^\n]+)((?:\n\P+)+) $1 @@ -69,7 +69,7 @@ - >\s*(\S*)\s*((?:\n\P+)+) + >\x20*(\S*)\x20*((?:\n\P+)+) $1 @@ -78,11 +78,58 @@ string-length('$2') - + + + + + + + \A.PNG\r\n\x1A\n.*\z - + + $0 + + + + + \AABIF.*\z + $0 From gordonp at dev.open-bio.org Fri Jun 8 10:04:27 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 8 Jun 2007 10:04:27 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706081404.l58E4R0Y028982@dev.open-bio.org> gordonp Fri Jun 8 10:04:27 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared In directory dev.open-bio.org:/tmp/cvs-serv28675/src/main/org/biomoby/shared Modified Files: MobyDataType.java MobyNamespace.java MobyService.java MobyServiceType.java Log Message: Commit of Seahawk 1.0 updates and associated core updates moby-live/Java/src/main/org/biomoby/shared MobyDataType.java,1.14,1.15 MobyNamespace.java,1.6,1.7 MobyService.java,1.18,1.19 MobyServiceType.java,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataType.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataType.java 2006/07/07 04:12:40 1.14 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataType.java 2007/06/08 14:04:27 1.15 @@ -7,8 +7,11 @@ package org.biomoby.shared; -import java.util.Comparator; -import java.util.Vector; +import java.net.URL; +import java.util.*; + +import org.biomoby.client.CentralImpl; +import org.biomoby.registry.meta.*; import org.biomoby.shared.extended.DataTypeParser; /** @@ -49,9 +52,11 @@ protected String id = null; protected String comment = null; protected String lsid = null; + protected Registry registry = null; // with which registry was the data type registered? - private static MobyDataType[] uninitializedDatatypes = new MobyDataType[0]; - private static MobyDataType[] datatypes = uninitializedDatatypes; + private static Map datatypesMapBySynonym = new HashMap(); + private static Map datatypesMapByURL = new HashMap(); + private static Registry defaultRegistry = null; /************************************************************************** * Default constructor. @@ -74,24 +79,111 @@ setName (name); } + public void setRegistry(Registry r){ + registry = r; + } + + public Registry getRegistry(){ + return registry; + } + + protected static String convertRegistryToDataTypeResourceURL(Registry reg) throws MobyException{ + CentralImpl central = new CentralImpl(reg.getEndpoint()); + MobyResourceRef[] resources = central.getResourceRefs(); + for(MobyResourceRef resource: resources){ + if(Central.DATA_TYPES_RESOURCE_NAME.equals(resource.getResourceName())){ + return resource.getResourceLocation().toString(); + } + } + System.err.println("Error! Could not find the data type resource from the registry " + reg.getSynonym()); + return null; + } + + public synchronized static Registry getDefaultRegistry(){ + if(defaultRegistry == null){ + try{ + defaultRegistry = (new RegistriesList()).get(Registries.DEFAULT_REGISTRY_SYNONYM); + } catch(Exception e){ + e.printStackTrace(); + } + if(defaultRegistry == null){ + System.err.println("Error! Could not find a default registry! No data types will be available."); + System.err.println("Sought " + Registries.DEFAULT_REGISTRY_SYNONYM + " but available options are:"); + for(String synonym: (new RegistriesList()).list()){ + System.err.println(synonym); + } + } + } + return defaultRegistry; + } + + /** + * Particularly useful for loading data types from cached file, or + * refreshing an in-memory cache. + */ + public static void loadDataTypes(URL dataDefURL, Registry reg){ + MobyDataType[] datatypes; + try{ + DataTypeParser p = new DataTypeParser(dataDefURL); + + datatypes = p.getMobyDataTypesFromRDF(); + for(MobyDataType dataType: datatypes){ + dataType.setRegistry(reg); + } + } + catch(Exception e){ + System.err.println("Cannot parse MOBY Object Ontology: " + e); + e.printStackTrace(); + return; + } + datatypesMapBySynonym.put(reg.getSynonym(), datatypes); + datatypesMapByURL.put(dataDefURL.toString(), datatypes); + } + public static MobyDataType getDataType(String className){ + return getDataType(className, null); + } + + /** + * Retrieves a datatype object from the registry's ontology. + */ + public static MobyDataType getDataType(String className, Registry reg){ if(className == null){ return null; } - + + if(reg == null){ + reg = getDefaultRegistry(); + } + if(reg == null){ + return null; + } + + MobyDataType[] datatypes = datatypesMapBySynonym.get(reg.getSynonym()); + // This method has not been called yet in the JVM, populate the datatypes - synchronized(datatypes){ - if(datatypes == uninitializedDatatypes){ + synchronized(datatypesMapByURL){ + if(datatypes == null){ + String dataDefURL = null; try{ - DataTypeParser p = new DataTypeParser("http://biomoby.org/RESOURCES/MOBY-S/Objects"); - //DataTypeParser p = new DataTypeParser(RdfParser.OBJECT_URI); - datatypes = p.getMobyDataTypesFromRDF(); + dataDefURL = convertRegistryToDataTypeResourceURL(reg); + datatypes = datatypesMapByURL.get(dataDefURL); + + if(datatypes == null){ + DataTypeParser p = new DataTypeParser(dataDefURL); + datatypes = p.getMobyDataTypesFromRDF(); + for(MobyDataType dataType: datatypes){ + dataType.setRegistry(reg); + } + } } catch(Exception e){ System.err.println("Cannot parse MOBY Object Ontology: " + e); e.printStackTrace(); return null; } + datatypesMapBySynonym.put(reg.getSynonym(), datatypes); + datatypesMapByURL.put(dataDefURL, datatypes); } } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyNamespace.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyNamespace.java 2006/09/22 22:55:38 1.6 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyNamespace.java 2007/06/08 14:04:27 1.7 @@ -7,9 +7,13 @@ package org.biomoby.shared; -import java.util.Comparator; +import org.biomoby.client.CentralImpl; +import org.biomoby.registry.meta.Registry; import org.biomoby.shared.extended.NamespaceParser; +import java.util.*; +import java.net.URL; + /** * A container representing a namespace used in the Moby registry. *

@@ -30,9 +34,10 @@ protected String description = ""; protected String lsid = null; protected String id = null; + protected Registry registry; //provenance of the namspace definition - protected static MobyNamespace[] uninitializedNamespaces = new MobyNamespace[0]; - protected static MobyNamespace[] namespaces = uninitializedNamespaces; + private static Map namespacesMapBySynonym = new HashMap(); + private static Map namespacesMapByURL = new HashMap(); /************************************************************************** * Default constructor. Other characteristics are empty - which is usually @@ -42,23 +47,91 @@ this.name = name; } + protected static String convertRegistryToNamespaceResourceURL(Registry reg) throws MobyException{ + CentralImpl central = new CentralImpl(reg.getEndpoint()); + MobyResourceRef[] resources = central.getResourceRefs(); + for(MobyResourceRef resource: resources){ + if(Central.NAMESPACES_RESOURCE_NAME.equals(resource.getResourceName())){ + return resource.getResourceLocation().toString(); + } + } + System.err.println("Error! Could not find the namespace resource from the registry " + reg.getSynonym()); + return null; + } + + public Registry getRegistry(){ + return registry; + } + + public void setRegistry(Registry reg){ + reg = registry; + } + + /** + * Particularly useful for loading namespace definitions from cached file, or + * refreshing an in-memory cache. + */ + public static void loadNamespaces(URL namespaceDefURL, Registry reg){ + MobyNamespace[] namespaces; + try{ + NamespaceParser p = new NamespaceParser(namespaceDefURL); + namespaces = p.getMobyNamespacesFromRDF(); + + for(MobyNamespace namespace: namespaces){ + namespace.setRegistry(reg); + } + } + catch(Exception e){ + System.err.println("Cannot parse MOBY Namespace Ontology: " + e); + e.printStackTrace(); + return; + } + namespacesMapBySynonym.put(reg.getSynonym(), namespaces); + namespacesMapByURL.put(namespaceDefURL.toString(), namespaces); + } + public static MobyNamespace getNamespace(String ns){ + return getNamespace(ns, null); + } + + public static MobyNamespace getNamespace(String ns, Registry reg){ if(ns == null){ return null; } + if(reg == null){ + reg = MobyDataType.getDefaultRegistry(); + } + if(reg == null){ + return null; + } + + MobyNamespace[] namespaces = namespacesMapBySynonym.get(reg.getSynonym()); + // This method has not been called yet in the JVM, populate the datatypes - synchronized (namespaces){ - if(namespaces == uninitializedNamespaces){ + synchronized(namespacesMapByURL){ + if(namespaces == null){ + String namespaceDefURL = null; try{ - NamespaceParser p = new NamespaceParser("http://biomoby.org/RESOURCES/MOBY-S/Namespaces"); - namespaces = p.getMobyNamespacesFromRDF(); + namespaces = namespacesMapByURL.get(namespaceDefURL); + + if(namespaces == null){ + namespaceDefURL = convertRegistryToNamespaceResourceURL(reg); + NamespaceParser p = new NamespaceParser(namespaceDefURL); + namespaces = p.getMobyNamespacesFromRDF(); + + for(MobyNamespace namespace: namespaces){ + namespace.setRegistry(reg); + } + } } catch(Exception e){ System.err.println("Cannot parse MOBY Namespace Ontology: " + e); e.printStackTrace(); return null; } + namespacesMapBySynonym.put(reg.getSynonym(), namespaces); + namespacesMapByURL.put(namespaceDefURL, namespaces); } } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyService.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyService.java 2007/05/31 13:42:51 1.18 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyService.java 2007/06/08 14:04:27 1.19 @@ -7,9 +7,9 @@ package org.biomoby.shared; -import java.util.Comparator; -import java.util.Enumeration; -import java.util.Vector; +import java.util.*; +import java.net.URL; +import java.util.regex.Pattern; import org.biomoby.shared.extended.ServiceInstanceParser; /** @@ -76,6 +76,7 @@ // We need both, because you can't synchrinize on a null array protected static MobyService[] uninitializedServices = new MobyService[0]; protected static MobyService[] services = uninitializedServices; + protected static Map serviceMap = new HashMap(); // the elements of these Vectors are of type MobyData protected Vector primaryInputs = new Vector(); @@ -507,36 +508,68 @@ this.serviceType = (serviceType == null ? new MobyServiceType() : serviceType); } + public static MobyService getService(String lsid){ + String[] lsidParts = lsid.split(":"); + String[] sNameParts = lsidParts[4].split(","); + return getService(sNameParts[1], sNameParts[0]); + } + public static MobyService getService(String name, String authority){ if(name == null || authority == null){ return null; } - // This method has not been called yet in the JVM, populate the datatypes - synchronized (services){ - if(services == uninitializedServices){ - try{ - ServiceInstanceParser p = new ServiceInstanceParser("http://biomoby.org/RESOURCES/MOBY-S/ServiceInstances"); - services = p.getMobyServicesFromRDF(); + // Perform a linear search for the corresponding namespace and authority + String lsid = "urn:lsid:biomoby.org:serviceinstance:"+authority+","+name; + if(!serviceMap.containsKey(lsid)){ + try{ + URL lsidResolver = new URL("http://mobycentral.icapture.ubc.ca/authority/lsid/ResolveLSID?lsid="+lsid); + Object o = getContent(lsidResolver); + if(!(o instanceof String)){ + System.err.println("Response for "+lsid + " was not a String, but a " + o.getClass()); + } + String metadata = (String) o; + + String redirectPattern = "latest>"; + int redirectStringIndex = metadata.indexOf(redirectPattern+lsid); + String lsidFull = null; + if(redirectStringIndex != -1){ + int lsidFullIndex = redirectStringIndex+redirectPattern.length(); + lsidFull = metadata.substring(lsidFullIndex, lsidFullIndex+lsid.length()+21); + //System.err.println("Retrieving full LSID " + lsidFull); + lsidResolver = new URL("http://mobycentral.icapture.ubc.ca/authority/lsid/ResolveLSID?lsid="+lsidFull); + metadata = getContent(lsidResolver); } - catch(Exception e){ - System.err.println("Cannot parse MOBY Service Instance Database: " + e); - e.printStackTrace(); - return null; + metadata = Pattern.compile(".*(<\\?xml\\s.*RDF>).*", Pattern.DOTALL).matcher(metadata).replaceFirst("$1") + .replaceAll(">",">") + .replaceAll("<","<") + .replaceAll(""", "\"") + .replaceAll("&", "&"); + //System.err.println(metadata); + + ServiceInstanceParser p = new ServiceInstanceParser(); + services = p.getMobyServicesFromRDF(metadata); + if(services.length > 0){ + serviceMap.put(lsid, services[0]); + if(lsidFull != null){ + serviceMap.put(lsidFull, services[0]); + } } + } catch(Exception e){ + e.printStackTrace(); } } - // Perform a linear search for the corresponding namespace and authority - for(int i = 0; i < services.length; i++){ - if(name.equals(services[i].getName()) && - authority.equals(services[i].getAuthority())){ - return services[i]; - } - } + return serviceMap.get(lsid); + } - // Wasn't found if we got to here - return null; + private static String getContent(URL u) throws Exception{ + StringBuffer contents = new StringBuffer(); + java.io.LineNumberReader reader = new java.io.LineNumberReader(new java.io.InputStreamReader(u.openStream())); + for(String line = reader.readLine(); line != null; line = reader.readLine()){ + contents.append(line+"\n"); + } + return contents.toString(); } public boolean isAsynchronous(){ =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyServiceType.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyServiceType.java 2006/09/22 22:56:44 1.7 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyServiceType.java 2007/06/08 14:04:27 1.8 @@ -7,10 +7,13 @@ package org.biomoby.shared; -import java.util.Comparator; -import java.util.Vector; +import org.biomoby.client.CentralImpl; +import org.biomoby.registry.meta.Registry; import org.biomoby.shared.extended.ServiceTypeParser; +import java.util.*; +import java.net.URL; + /** * A container representing a service type used in the Moby registry. *

@@ -33,9 +36,10 @@ protected String[] parentNames = new String[] { }; protected String id = null; protected String lsid = null; + protected Registry registry; // provenance of the service type definition - protected static MobyServiceType[] unintializedServicetypes = new MobyServiceType[0]; - protected static MobyServiceType[] servicetypes = unintializedServicetypes; + private static Map servicetypesMapBySynonym = new HashMap(); + private static Map servicetypesMapByURL = new HashMap(); public int compareTo (Object obj) { return name.compareToIgnoreCase ( ((MobyServiceType)obj).getName() ); @@ -59,23 +63,91 @@ setName (typeName); } + protected static String convertRegistryToServiceTypeResourceURL(Registry reg) throws MobyException{ + CentralImpl central = new CentralImpl(reg.getEndpoint()); + MobyResourceRef[] resources = central.getResourceRefs(); + for(MobyResourceRef resource: resources){ + if(Central.SERVICE_TYPES_RESOURCE_NAME.equals(resource.getResourceName())){ + return resource.getResourceLocation().toString(); + } + } + System.err.println("Error! Could not find the service type resource from the registry " + reg.getSynonym()); + return null; + } + + public Registry getRegistry(){ + return registry; + } + + public void setRegistry(Registry reg){ + reg = registry; + } + + /** + * Particularly useful for loading namespace definitions from cached file, or + * refreshing an in-memory cache. + */ + public static void loadServiceTypes(URL serviceDefURL, Registry reg){ + MobyServiceType[] servicetypes; + try{ + ServiceTypeParser p = new ServiceTypeParser(serviceDefURL); + servicetypes = p.getMobyServiceTypesFromRDF(); + + for(MobyServiceType servicetype: servicetypes){ + servicetype.setRegistry(reg); + } + } + catch(Exception e){ + System.err.println("Cannot parse MOBY Service Type Ontology: " + e); + e.printStackTrace(); + return; + } + servicetypesMapBySynonym.put(reg.getSynonym(), servicetypes); + servicetypesMapByURL.put(serviceDefURL.toString(), servicetypes); + } + public static MobyServiceType getServiceType(String className){ + return getServiceType(className, null); + } + + public static MobyServiceType getServiceType(String className, Registry reg){ if(className == null){ return null; } - synchronized(servicetypes){ - if(servicetypes == unintializedServicetypes){ + if(reg == null){ + reg = MobyDataType.getDefaultRegistry(); + } + if(reg == null){ + return null; + } + + MobyServiceType[] servicetypes = servicetypesMapBySynonym.get(reg.getSynonym()); + + // This method has not been called yet in the JVM, populate the datatypes + synchronized(servicetypesMapByURL){ + if(servicetypes == null){ + String serviceDefURL = null; try{ - // Using test server for now, as it deals with the RDF properly - ServiceTypeParser p = new ServiceTypeParser("http://biomoby.org/RESOURCES/MOBY-S/Services"); - servicetypes = p.getMobyServiceTypesFromRDF(); + servicetypes = servicetypesMapByURL.get(serviceDefURL); + + if(servicetypes == null){ + serviceDefURL = convertRegistryToServiceTypeResourceURL(reg); + ServiceTypeParser p = new ServiceTypeParser(serviceDefURL); + servicetypes = p.getMobyServiceTypesFromRDF(); + + for(MobyServiceType servicetype: servicetypes){ + servicetype.setRegistry(reg); + } + } } catch(Exception e){ System.err.println("Cannot parse MOBY Service Type Ontology: " + e); e.printStackTrace(); return null; } + servicetypesMapBySynonym.put(reg.getSynonym(), servicetypes); + servicetypesMapByURL.put(serviceDefURL, servicetypes); } } From gordonp at dev.open-bio.org Fri Jun 8 10:04:27 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 8 Jun 2007 10:04:27 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706081404.l58E4Rc4028952@dev.open-bio.org> gordonp Fri Jun 8 10:04:27 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client In directory dev.open-bio.org:/tmp/cvs-serv28675/src/main/org/biomoby/client Modified Files: MobyRequest.java MobyRequestEvent.java MobyRequestEventHandler.java Log Message: Commit of Seahawk 1.0 updates and associated core updates moby-live/Java/src/main/org/biomoby/client MobyRequest.java,1.25,1.26 MobyRequestEvent.java,1.4,1.5 MobyRequestEventHandler.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java 2007/04/26 15:08:03 1.25 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java 2007/06/08 14:04:27 1.26 @@ -273,17 +273,17 @@ * @throws SOAPException i.e. there was a problem with the underlying transaction/transport layer */ public MobyContentInstance invokeService() throws Exception, MobyException, SOAPException, NoSuccessException{ - return invokeService((StringBuffer) null); + return invokeService(inputData, (StringBuffer) null); } // Used internally for asynchronous thread calls that all need the XML data // and can't rely on the answer from thread-insensitive getResponseXML() - private MobyContentInstance invokeService(StringBuffer contentsXML) + private MobyContentInstance invokeService(MobyContentInstance inData, StringBuffer contentsXML) throws Exception, MobyException, SOAPException, NoSuccessException{ - return invokeService(contentsXML, null, 0); + return invokeService(inData, contentsXML, null, 0); } - private MobyContentInstance invokeService(StringBuffer contentsXML, MobyRequestEventHandler handler, int requestId) + private MobyContentInstance invokeService(MobyContentInstance inData, StringBuffer contentsXML, MobyRequestEventHandler handler, int requestId) throws Exception, MobyException, SOAPException, NoSuccessException{ if(mobyService == null){ @@ -293,10 +293,10 @@ Element mobyDOM = null; if(mobyService.isAsynchronous()){ // Async is "simpler", because it had to merge DOMs together into a single MobyContentInstance anyway - return performAsyncSOAPRequest(mobyService, inputData, handler, requestId); + return performAsyncSOAPRequest(mobyService, inData, handler, requestId); } else{ - String mobyXML = convertMOBYDataToMOBYRequest(inputData); + String mobyXML = convertMOBYDataToMOBYRequest(inData); Call call = getServiceFromWSDL(); mobyDOM = performSOAPRequest(call, mobyXML, contentsXML); // The following parses the DOM and extracts all the appropriate jMOBY objects to represent the XML in Java @@ -342,7 +342,7 @@ } // Inform the handler that some data has been added to the response (for incremental display?) - MobyRequestEvent mre = new MobyRequestEvent(finalContents, this, null, requestId); + MobyRequestEvent mre = new MobyRequestEvent(finalContents, this, mservice, null, requestId); StringWriter xmlWriter = new StringWriter(); MobyDataUtils.toXMLDocument(xmlWriter, finalContents); @@ -377,7 +377,7 @@ public synchronized int invokeService(MobyRequestEventHandler handler){ int id = autoID++; - Thread t = new InvocationThread(this, handler, id); // see internal class definition below + Thread t = new InvocationThread(this, inputData, handler, id); // see internal class definition below t.start(); return id; @@ -386,12 +386,14 @@ // This is the class that asynchronously calls the service and does a callback to // the handler specified in the invocation. class InvocationThread extends Thread { + MobyContentInstance data; MobyService mservice; MobyRequest mobyRequest; MobyRequestEventHandler handler; int requestId; - InvocationThread(MobyRequest mr, MobyRequestEventHandler h, int id){ + InvocationThread(MobyRequest mr, MobyContentInstance inData, MobyRequestEventHandler h, int id){ + data = inData; mobyRequest = mr; mservice = mobyRequest.getService(); handler = h; @@ -402,21 +404,24 @@ } public void run() { - MobyContentInstance content = null; + MobyRequestEvent requestEvent = new MobyRequestEvent(data, mobyRequest, mservice, null, requestId); + // Tell the handler we're starting the request, with the given data + handler.start(requestEvent); + MobyRequestEvent responseEvent = null; - handler.start(mobyRequest, requestId); + MobyContentInstance content = null; StringBuffer contentsXML = new StringBuffer(); //to be filled in by the RPC call below try{ - content = mobyRequest.invokeService(contentsXML, handler, requestId); //RPC call... + content = mobyRequest.invokeService(data, contentsXML, handler, requestId); //RPC call... } catch(Exception e){ - responseEvent = new MobyRequestEvent(content, mobyRequest, e, requestId); + responseEvent = new MobyRequestEvent(content, mobyRequest, mservice, e, requestId); } catch(Error err){ - responseEvent = new MobyRequestEvent(content, mobyRequest, err, requestId); + responseEvent = new MobyRequestEvent(content, mobyRequest, mservice, err, requestId); } if(responseEvent == null){ - responseEvent = new MobyRequestEvent(content, mobyRequest, null, requestId); + responseEvent = new MobyRequestEvent(content, mobyRequest, mservice, null, requestId); } // We've got the raw XML laying around, so why not provide it unmolested to the callback? responseEvent.setContentsXML(contentsXML.toString()); =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequestEvent.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequestEvent.java 2006/07/07 04:12:39 1.4 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequestEvent.java 2007/06/08 14:04:27 1.5 @@ -2,6 +2,7 @@ import java.io.ByteArrayOutputStream; import java.io.ByteArrayInputStream; +import org.biomoby.shared.MobyService; import org.biomoby.shared.data.MobyContentInstance; import org.biomoby.shared.data.MobyDataUtils; @@ -18,17 +19,26 @@ protected MobyContentInstance contents; protected MobyRequest originatingMobyRequest; protected String dataPayloadXML; + protected MobyService service; protected Throwable exception; private static int nextEventID = 0; - public MobyRequestEvent(MobyContentInstance mci, MobyRequest requestSource, Throwable e, int id){ + public MobyRequestEvent(MobyContentInstance mci, MobyRequest requestSource, MobyService serv, Throwable e, int id){ consumed = false; done = false; contents = mci; originatingMobyRequest = requestSource; exception = e; eventID = id; + service = serv; + } + + /** + * @return the name of the remote service generating the event + */ + public MobyService getService(){ + return service; } /** =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequestEventHandler.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequestEventHandler.java 2006/03/28 21:11:22 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequestEventHandler.java 2007/06/08 14:04:27 1.3 @@ -12,10 +12,10 @@ public interface MobyRequestEventHandler{ /** - * If a client, denotes that a service request has been sent. + * If a client, denotes that a service request has been sent (and the contents is exactly what is being sent to the service). * If a server, denotes that you should be ready to start receiving events (an init of sorts) */ - public void start(MobyRequest request, int requestID); + public void start(MobyRequestEvent request); public void processEvent(MobyRequestEvent mre); From gordonp at dev.open-bio.org Fri Jun 8 10:04:27 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 8 Jun 2007 10:04:27 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706081404.l58E4RGW028866@dev.open-bio.org> gordonp Fri Jun 8 10:04:27 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services In directory dev.open-bio.org:/tmp/cvs-serv28675/src/main/ca/ucalgary/seahawk/services Modified Files: MobyClient.java MobyComplexBuilder.java TextClient.java Log Message: Commit of Seahawk 1.0 updates and associated core updates moby-live/Java/src/main/ca/ucalgary/seahawk/services MobyClient.java,1.12,1.13 MobyComplexBuilder.java,1.6,1.7 TextClient.java,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java 2007/04/26 15:22:27 1.12 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java 2007/06/08 14:04:27 1.13 @@ -1,8 +1,10 @@ package ca.ucalgary.seahawk.services; import ca.ucalgary.seahawk.util.NamespaceContextImpl; +import ca.ucalgary.seahawk.util.SeahawkOptions; import org.biomoby.client.*; +import org.biomoby.registry.meta.Registry; import org.biomoby.shared.*; import org.biomoby.shared.data.*; @@ -15,12 +17,7 @@ import org.apache.xml.utils.PrefixResolver; import org.apache.xml.utils.PrefixResolverDefault; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -import javax.xml.parsers.*; +import org.w3c.dom.*; import java.io.*; import java.net.URL; @@ -28,6 +25,7 @@ import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; +import javax.xml.parsers.*; /** * The engine that finds MOBY data in unstructured text or DOM of other XML languages according @@ -76,7 +74,17 @@ private int serviceLevel = MobyService.UNCHECKED; public MobyClient() throws MobyException{ - c = new CentralCachedCallsImpl(); + Registry reg = SeahawkOptions.getRegistry(); + if(reg == null){ + reg = MobyDataType.getDefaultRegistry(); + } + + if(reg != null && reg.getEndpoint() != null){ + c = new CentralCachedCallsImpl(reg.getEndpoint()); + } + else{ + c = new CentralCachedCallsImpl(); + } xpathMap = new HashMap(); urlRegexMap = new HashMap(); regexMap = new HashMap(); @@ -657,7 +665,7 @@ */ public MobyDataObject[] getMobyObjects(byte[] rawData, MobyDataType targetDataType){ // Only do the magic check if the target data type inherits from MOBY's base64 class (i.e. might encode binary data) - if(!targetDataType.inheritsFrom(MobyDataType.getDataType(MobyDataBytes.BASE64_DATATYPE))){ + if(!targetDataType.inheritsFrom(MobyDataType.getDataType(MobyDataBytes.BASE64_DATATYPE, targetDataType.getRegistry()))){ //System.err.println("Data type does not inerit from Base64, continuing with string-based search..."); return getMobyObjects(new String(rawData), targetDataType); } @@ -959,7 +967,8 @@ //} mService[j].setStatus(MobyService.ALIVE, isServiceAlive(mService[j])); - mService[j].setServiceType(MobyServiceType.getServiceType(mService[j].getServiceType().getName())); + mService[j].setServiceType(MobyServiceType.getServiceType(mService[j].getServiceType().getName(), + SeahawkOptions.getRegistry())); if(serviceLevel != MobyService.UNCHECKED){ int serviceStatus = mService[j].getStatus(); //System.err.println("Service " + mService[j].getName() + " has status " + serviceStatus); =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyComplexBuilder.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyComplexBuilder.java 2007/04/18 15:58:08 1.6 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyComplexBuilder.java 2007/06/08 14:04:27 1.7 @@ -1,5 +1,7 @@ package ca.ucalgary.seahawk.services; +import ca.ucalgary.seahawk.util.SeahawkOptions; + import org.biomoby.shared.*; import org.biomoby.shared.data.MobyDataObject; import org.biomoby.shared.data.MobyDataComposite; @@ -46,7 +48,7 @@ } public MobyComplexBuilder(String dataType, Map members, Map nameSpaces, String articleName) throws Exception{ - mobyDataType = MobyDataType.getDataType(dataType); + mobyDataType = MobyDataType.getDataType(dataType, SeahawkOptions.getRegistry()); // Not an existing Ontology data type if(mobyDataType == null){ mobyDataType = new MobyDataType(dataType); @@ -96,7 +98,7 @@ String ns = (String) iter.next(); // Give the namespace a meaningful description from the MOBY registry - mobyNS[i] = MobyNamespace.getNamespace(ns); + mobyNS[i] = MobyNamespace.getNamespace(ns, SeahawkOptions.getRegistry()); if(mobyNS[i] == null){ System.err.println("Namespace '"+ns+"' is not registered in MOBY Central"); // Not a registered namespace in MOBY Central's ontology @@ -114,7 +116,7 @@ MobyDataObject mobyObj = null; if(mobyDataType.getName().equals("Object")){ - mobyObj = new MobyDataObject(""); + mobyObj = new MobyDataObject("", SeahawkOptions.getRegistry()); } // else ifs for other primitives in the future maybe? else{ @@ -152,7 +154,7 @@ } else{ // ... the subsequent ones are saved as cross-references - mobyObj.addCrossReference(new MobyDataObject(mobyNS[i].getName(), result)); + mobyObj.addCrossReference(new MobyDataObject(mobyNS[i].getName(), result, SeahawkOptions.getRegistry())); } } } @@ -182,6 +184,7 @@ } } } + System.err.println("Namespace of object being returned is " + mobyObj.getPrimaryNamespace().getName()); return mobyObj; } @@ -190,6 +193,7 @@ throws MobyException{ byte[] resultBytes = result.getBytes(); boolean nonBasic = result.length() != 2 || result.indexOf("$") != 0; + boolean isBinary = encodingMode != null && encodingMode.equals(MobyClient.ENCODING_ATTR_BASE64_VAL); MobyPrefixResolver.MobyNodeList nodeList = new MobyPrefixResolver.MobyNodeList(); @@ -205,7 +209,7 @@ // "$250 per metre". Not sure of a good way around this yet (i.e. when varValue had $k in it where k > j)... for(int j = 0; j <= matcher.groupCount(); j++){ // A replaceAll() for binary data - if(data != null){ + if(data != null && isBinary){ int srcPos = 0; for(int varIndex = result.indexOf("$"+j, srcPos); varIndex != -1; @@ -251,7 +255,7 @@ } } - if(encodingMode != null && encodingMode.equals(MobyClient.ENCODING_ATTR_BASE64_VAL)){ + if(isBinary){ //(new Exception("Base 64 encoding")).printStackTrace(); result = org.apache.axis.encoding.Base64.encode(data == null ? result.getBytes() : resultBytes); } @@ -281,7 +285,7 @@ MobyDataObject mobyObj = null; if(mobyDataType.getName().equals("Object")){ - mobyObj = new MobyDataObject(""); + mobyObj = new MobyDataObject("", SeahawkOptions.getRegistry()); } // else ifs for other primitives in the future maybe? else{ @@ -306,7 +310,7 @@ } else{ // ... the subsequent ones are saved as cross-references - mobyObj.addCrossReference(new MobyDataObject(mobyNS[i].getName(), value)); + mobyObj.addCrossReference(new MobyDataObject(mobyNS[i].getName(), value, SeahawkOptions.getRegistry())); } } } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/TextClient.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/TextClient.java 2007/04/18 16:07:41 1.3 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/TextClient.java 2007/06/08 14:04:27 1.4 @@ -1,5 +1,7 @@ package ca.ucalgary.seahawk.services; +import ca.ucalgary.seahawk.util.SeahawkOptions; + import org.biomoby.shared.*; import org.biomoby.shared.data.MobyDataInstance; @@ -92,7 +94,7 @@ } // See if the type exists in the ontology - MobyDataType type = MobyDataType.getDataType(templateNameParts[0]); + MobyDataType type = MobyDataType.getDataType(templateNameParts[0], SeahawkOptions.getRegistry()); if(type == null){ System.err.println("Ignoring template whose name attribute (" + templateName + ") uses a non-existent datatype (" + templateNameParts[0] + ")"); From gordonp at dev.open-bio.org Fri Jun 8 16:30:22 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 8 Jun 2007 16:30:22 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706082030.l58KUMbr029949@dev.open-bio.org> gordonp Fri Jun 8 16:30:21 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util In directory dev.open-bio.org:/tmp/cvs-serv29870/src/main/ca/ucalgary/seahawk/util Modified Files: SeahawkOptions.java Log Message: Code revamp to deal with new disk cache moby-live/Java/src/main/ca/ucalgary/seahawk/util SeahawkOptions.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/SeahawkOptions.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/SeahawkOptions.java 2007/06/08 14:04:27 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/SeahawkOptions.java 2007/06/08 20:30:21 1.2 @@ -265,7 +265,7 @@ * @return the file system location where preferences are stored (whether the file currently exists or not) */ public static File getDefaultsFile(){ - return new File(System.getProperty("java.io.tmpdir"), System.getProperty("user.name")+"."+PROPS_FILE_NAME); + return new File(System.getProperty("user.dir"), PROPS_FILE_NAME); } /** @@ -320,12 +320,12 @@ throw new IOException("The temporary data path given (" + dir.toString() + ") is not writeable as required"); } - // Uncomment if we ever need to do a directory listing - //if(!dir.canRead()){ - // throw new IOException("The temporary data path given (" + dir.toString() + - // ") is not readable as required"); - //} + if(!dir.canRead()){ + throw new IOException("The temporary data path given (" + dir.toString() + + ") is not readable as required"); + } tmpDir = dir; + RegistryCache.setTempDir(dir); } /** From gordonp at dev.open-bio.org Fri Jun 8 16:30:22 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 8 Jun 2007 16:30:22 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706082030.l58KUMQ8029985@dev.open-bio.org> gordonp Fri Jun 8 16:30:22 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/meta In directory dev.open-bio.org:/tmp/cvs-serv29870/src/main/org/biomoby/registry/meta Modified Files: Registry.java Log Message: Code revamp to deal with new disk cache moby-live/Java/src/main/org/biomoby/registry/meta Registry.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/meta/Registry.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/meta/Registry.java 2007/05/31 13:42:51 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/meta/Registry.java 2007/06/08 20:30:22 1.3 @@ -8,6 +8,10 @@ package org.biomoby.registry.meta; +import org.biomoby.client.CentralImpl; +import org.biomoby.shared.MobyResourceRef; +import org.biomoby.shared.MobyException; + /** * A container for meta data about a BioMoby registry.

* @@ -172,4 +176,23 @@ isPublic = value; } + /** + * Learn the RDF location for resources of the registry. + * + * @param resourceName one of the org.biomoby.shared.Central RESOURCE constants + * + * @return the URL of the resource, or null if the resource does not exist + */ + public static java.net.URL findResourceURL(Registry reg, String resourceName) throws MobyException{ + CentralImpl central = new CentralImpl(reg.getEndpoint()); + MobyResourceRef[] resources = central.getResourceRefs(); + for(MobyResourceRef resource: resources){ + if(resourceName.equals(resource.getResourceName())){ + return resource.getResourceLocation(); + } + } + System.err.println("Error! Could not find the data type resource from the registry " + reg.getSynonym()); + return null; + } + } From gordonp at dev.open-bio.org Fri Jun 8 16:30:21 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 8 Jun 2007 16:30:21 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706082030.l58KULP4029931@dev.open-bio.org> gordonp Fri Jun 8 16:30:21 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services In directory dev.open-bio.org:/tmp/cvs-serv29870/src/main/ca/ucalgary/seahawk/services Modified Files: MobyClient.java Log Message: Code revamp to deal with new disk cache moby-live/Java/src/main/ca/ucalgary/seahawk/services MobyClient.java,1.13,1.14 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java 2007/06/08 14:04:27 1.13 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java 2007/06/08 20:30:21 1.14 @@ -4,7 +4,7 @@ import ca.ucalgary.seahawk.util.SeahawkOptions; import org.biomoby.client.*; -import org.biomoby.registry.meta.Registry; +import org.biomoby.registry.meta.*; import org.biomoby.shared.*; import org.biomoby.shared.data.*; @@ -76,7 +76,7 @@ public MobyClient() throws MobyException{ Registry reg = SeahawkOptions.getRegistry(); if(reg == null){ - reg = MobyDataType.getDefaultRegistry(); + reg = RegistryCache.getDefaultRegistry(); } if(reg != null && reg.getEndpoint() != null){ From gordonp at dev.open-bio.org Fri Jun 8 16:30:22 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 8 Jun 2007 16:30:22 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706082030.l58KUMFw030021@dev.open-bio.org> gordonp Fri Jun 8 16:30:22 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared In directory dev.open-bio.org:/tmp/cvs-serv29870/src/main/org/biomoby/shared Modified Files: MobyDataType.java MobyNamespace.java MobyServiceType.java Log Message: Code revamp to deal with new disk cache moby-live/Java/src/main/org/biomoby/shared MobyDataType.java,1.15,1.16 MobyNamespace.java,1.7,1.8 MobyServiceType.java,1.8,1.9 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataType.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataType.java 2007/06/08 14:04:27 1.15 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataType.java 2007/06/08 20:30:22 1.16 @@ -11,7 +11,8 @@ import java.util.*; import org.biomoby.client.CentralImpl; -import org.biomoby.registry.meta.*; +import org.biomoby.registry.meta.Registry; +import org.biomoby.registry.meta.RegistryCache; import org.biomoby.shared.extended.DataTypeParser; /** @@ -55,8 +56,7 @@ protected Registry registry = null; // with which registry was the data type registered? private static Map datatypesMapBySynonym = new HashMap(); - private static Map datatypesMapByURL = new HashMap(); - private static Registry defaultRegistry = null; + private static Map datatypesMapByURL = new HashMap(); /************************************************************************** * Default constructor. @@ -87,57 +87,24 @@ return registry; } - protected static String convertRegistryToDataTypeResourceURL(Registry reg) throws MobyException{ - CentralImpl central = new CentralImpl(reg.getEndpoint()); - MobyResourceRef[] resources = central.getResourceRefs(); - for(MobyResourceRef resource: resources){ - if(Central.DATA_TYPES_RESOURCE_NAME.equals(resource.getResourceName())){ - return resource.getResourceLocation().toString(); - } - } - System.err.println("Error! Could not find the data type resource from the registry " + reg.getSynonym()); - return null; - } - - public synchronized static Registry getDefaultRegistry(){ - if(defaultRegistry == null){ - try{ - defaultRegistry = (new RegistriesList()).get(Registries.DEFAULT_REGISTRY_SYNONYM); - } catch(Exception e){ - e.printStackTrace(); - } - if(defaultRegistry == null){ - System.err.println("Error! Could not find a default registry! No data types will be available."); - System.err.println("Sought " + Registries.DEFAULT_REGISTRY_SYNONYM + " but available options are:"); - for(String synonym: (new RegistriesList()).list()){ - System.err.println(synonym); - } - } - } - return defaultRegistry; - } - /** * Particularly useful for loading data types from cached file, or * refreshing an in-memory cache. */ - public static void loadDataTypes(URL dataDefURL, Registry reg){ - MobyDataType[] datatypes; - try{ - DataTypeParser p = new DataTypeParser(dataDefURL); - - datatypes = p.getMobyDataTypesFromRDF(); - for(MobyDataType dataType: datatypes){ - dataType.setRegistry(reg); - } + public static void loadDataTypes(URL dataDefURL, Registry reg) throws Exception{ + if(reg == null){ + reg = RegistryCache.getDefaultRegistry(); } - catch(Exception e){ - System.err.println("Cannot parse MOBY Object Ontology: " + e); - e.printStackTrace(); - return; + + MobyDataType[] datatypes; + DataTypeParser p = new DataTypeParser(dataDefURL); + + datatypes = p.getMobyDataTypesFromRDF(); + for(MobyDataType dataType: datatypes){ + dataType.setRegistry(reg); } datatypesMapBySynonym.put(reg.getSynonym(), datatypes); - datatypesMapByURL.put(dataDefURL.toString(), datatypes); + datatypesMapByURL.put(dataDefURL, datatypes); } public static MobyDataType getDataType(String className){ @@ -153,7 +120,7 @@ } if(reg == null){ - reg = getDefaultRegistry(); + reg = RegistryCache.getDefaultRegistry(); } if(reg == null){ return null; @@ -164,26 +131,20 @@ // This method has not been called yet in the JVM, populate the datatypes synchronized(datatypesMapByURL){ if(datatypes == null){ - String dataDefURL = null; try{ - dataDefURL = convertRegistryToDataTypeResourceURL(reg); - datatypes = datatypesMapByURL.get(dataDefURL); - + URL dataDefURL = Registry.findResourceURL(reg, Central.DATA_TYPES_RESOURCE_NAME); + datatypes = datatypesMapByURL.get(dataDefURL); if(datatypes == null){ - DataTypeParser p = new DataTypeParser(dataDefURL); - datatypes = p.getMobyDataTypesFromRDF(); - for(MobyDataType dataType: datatypes){ - dataType.setRegistry(reg); - } + loadDataTypes(dataDefURL, reg); + datatypes = datatypesMapByURL.get(dataDefURL); } + } catch(Exception e){ - System.err.println("Cannot parse MOBY Object Ontology: " + e); + System.err.println("Cannot parse MOBY Service Type Ontology: " + e); e.printStackTrace(); return null; } - datatypesMapBySynonym.put(reg.getSynonym(), datatypes); - datatypesMapByURL.put(dataDefURL, datatypes); } } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyNamespace.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyNamespace.java 2007/06/08 14:04:27 1.7 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyNamespace.java 2007/06/08 20:30:22 1.8 @@ -9,6 +9,7 @@ import org.biomoby.client.CentralImpl; import org.biomoby.registry.meta.Registry; +import org.biomoby.registry.meta.RegistryCache; import org.biomoby.shared.extended.NamespaceParser; import java.util.*; @@ -100,7 +101,7 @@ } if(reg == null){ - reg = MobyDataType.getDefaultRegistry(); + reg = RegistryCache.getDefaultRegistry(); } if(reg == null){ return null; =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyServiceType.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyServiceType.java 2007/06/08 14:04:27 1.8 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyServiceType.java 2007/06/08 20:30:22 1.9 @@ -9,6 +9,7 @@ import org.biomoby.client.CentralImpl; import org.biomoby.registry.meta.Registry; +import org.biomoby.registry.meta.RegistryCache; import org.biomoby.shared.extended.ServiceTypeParser; import java.util.*; @@ -39,7 +40,7 @@ protected Registry registry; // provenance of the service type definition private static Map servicetypesMapBySynonym = new HashMap(); - private static Map servicetypesMapByURL = new HashMap(); + private static Map servicetypesMapByURL = new HashMap(); public int compareTo (Object obj) { return name.compareToIgnoreCase ( ((MobyServiceType)obj).getName() ); @@ -63,19 +64,7 @@ setName (typeName); } - protected static String convertRegistryToServiceTypeResourceURL(Registry reg) throws MobyException{ - CentralImpl central = new CentralImpl(reg.getEndpoint()); - MobyResourceRef[] resources = central.getResourceRefs(); - for(MobyResourceRef resource: resources){ - if(Central.SERVICE_TYPES_RESOURCE_NAME.equals(resource.getResourceName())){ - return resource.getResourceLocation().toString(); - } - } - System.err.println("Error! Could not find the service type resource from the registry " + reg.getSynonym()); - return null; - } - - public Registry getRegistry(){ + public Registry getRegistry(){ return registry; } @@ -87,23 +76,20 @@ * Particularly useful for loading namespace definitions from cached file, or * refreshing an in-memory cache. */ - public static void loadServiceTypes(URL serviceDefURL, Registry reg){ - MobyServiceType[] servicetypes; - try{ - ServiceTypeParser p = new ServiceTypeParser(serviceDefURL); - servicetypes = p.getMobyServiceTypesFromRDF(); - - for(MobyServiceType servicetype: servicetypes){ - servicetype.setRegistry(reg); - } + public static void loadServiceTypes(URL serviceDefURL, Registry reg) throws Exception{ + if(reg == null){ + reg = RegistryCache.getDefaultRegistry(); } - catch(Exception e){ - System.err.println("Cannot parse MOBY Service Type Ontology: " + e); - e.printStackTrace(); - return; + + MobyServiceType[] servicetypes; + ServiceTypeParser p = new ServiceTypeParser(serviceDefURL); + servicetypes = p.getMobyServiceTypesFromRDF(); + + for(MobyServiceType servicetype: servicetypes){ + servicetype.setRegistry(reg); } servicetypesMapBySynonym.put(reg.getSynonym(), servicetypes); - servicetypesMapByURL.put(serviceDefURL.toString(), servicetypes); + servicetypesMapByURL.put(serviceDefURL, servicetypes); } public static MobyServiceType getServiceType(String className){ @@ -116,7 +102,7 @@ } if(reg == null){ - reg = MobyDataType.getDefaultRegistry(); + reg = RegistryCache.getDefaultRegistry(); } if(reg == null){ return null; @@ -127,18 +113,12 @@ // This method has not been called yet in the JVM, populate the datatypes synchronized(servicetypesMapByURL){ if(servicetypes == null){ - String serviceDefURL = null; try{ - servicetypes = servicetypesMapByURL.get(serviceDefURL); - + URL serviceDefURL = Registry.findResourceURL(reg, Central.SERVICE_TYPES_RESOURCE_NAME); + servicetypes = servicetypesMapByURL.get(serviceDefURL); if(servicetypes == null){ - serviceDefURL = convertRegistryToServiceTypeResourceURL(reg); - ServiceTypeParser p = new ServiceTypeParser(serviceDefURL); - servicetypes = p.getMobyServiceTypesFromRDF(); - - for(MobyServiceType servicetype: servicetypes){ - servicetype.setRegistry(reg); - } + loadServiceTypes(serviceDefURL, reg); + servicetypes = servicetypesMapByURL.get(serviceDefURL); } } catch(Exception e){ @@ -146,8 +126,6 @@ e.printStackTrace(); return null; } - servicetypesMapBySynonym.put(reg.getSynonym(), servicetypes); - servicetypesMapByURL.put(serviceDefURL, servicetypes); } } From gordonp at dev.open-bio.org Fri Jun 8 16:30:21 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 8 Jun 2007 16:30:21 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706082030.l58KULRt029913@dev.open-bio.org> gordonp Fri Jun 8 16:30:21 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv29870/src/main/ca/ucalgary/seahawk/gui Modified Files: MobyContentGUI.java MobyContentPane.java SeahawkOptionsGUI.java Log Message: Code revamp to deal with new disk cache moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyContentGUI.java,1.9,1.10 MobyContentPane.java,1.8,1.9 SeahawkOptionsGUI.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java 2007/06/08 14:04:27 1.9 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java 2007/06/08 20:30:21 1.10 @@ -19,8 +19,10 @@ import org.biomoby.client.MobyRequest; import org.biomoby.client.MobyRequestEvent; import org.biomoby.client.MobyRequestEventHandler; +import org.biomoby.registry.meta.*; import org.biomoby.shared.*; import org.biomoby.shared.data.*; + import ca.ucalgary.seahawk.util.*; /** @@ -949,7 +951,7 @@ } protected static void cacheOntologies(){ - final org.biomoby.registry.meta.Registry preferredRegistry = SeahawkOptions.getRegistry(); + final Registry preferredRegistry = SeahawkOptions.getRegistry(); // Redirect the registry endpoints to local cache files if available // preferredRegistry and/or dataDefURL may be null, if not cached, but that's okay to pass around @@ -957,25 +959,46 @@ // The following command will cache all data type definitions for this session new Thread(){ public void run(){ - URL dataDefURL = RegistryCache.getDataTypeOntologyURL(preferredRegistry); - if(dataDefURL != null){ - // Use the cached file rather than actually going to the registry - MobyDataType.loadDataTypes(dataDefURL, preferredRegistry); - } - else{ - MobyDataType.getDataType("Object", preferredRegistry); + File dataDefFile = RegistryCache.getOntologyFile(preferredRegistry, + Central.DATA_TYPES_RESOURCE_NAME); + try{ + URL dataDefURL = dataDefFile.toURI().toURL(); + if(dataDefFile.exists()){ + // Use the cached file rather than actually going to the registry + MobyDataType.loadDataTypes(dataDefURL, preferredRegistry); + } + else{ + // Create it from the remote source, then load it + RegistryCache.cacheRegistryOntology(preferredRegistry, + Central.DATA_TYPES_RESOURCE_NAME); + MobyDataType.loadDataTypes(dataDefURL, preferredRegistry); + } + }catch(Exception e){ + e.printStackTrace(); } } - }.start(); + }.start(); + new Thread(){ public void run(){ - URL serviceTypeDefURL = RegistryCache.getServiceTypeOntologyURL(preferredRegistry); - if(serviceTypeDefURL != null){ - // Use the cached file rather than actually going to the registry - MobyServiceType.loadServiceTypes(serviceTypeDefURL, preferredRegistry); - } - else{ - MobyServiceType.getServiceType("Analysis", preferredRegistry); + File serviceTypeDefFile = RegistryCache.getOntologyFile(preferredRegistry, + Central.SERVICE_TYPES_RESOURCE_NAME); + try{ + URL serviceTypeDefURL = serviceTypeDefFile.toURI().toURL(); + if(serviceTypeDefFile.exists()){ + // Use the cached file rather than actually going to the registry + MobyServiceType.loadServiceTypes(serviceTypeDefURL, + preferredRegistry); + } + else{ + // Create it from the remote source, then load it + RegistryCache.cacheRegistryOntology(preferredRegistry, + Central.SERVICE_TYPES_RESOURCE_NAME); + MobyServiceType.loadServiceTypes(serviceTypeDefURL, + preferredRegistry); + } + } catch(Exception e){ + e.printStackTrace(); } } }.start(); =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java 2007/06/08 14:04:27 1.8 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java 2007/06/08 20:30:21 1.9 @@ -310,9 +310,17 @@ // Shouldn't get here unless either not binary, or the binary data load failed System.err.println("Is plain text"); editorPane.setContentType("text/html"); - resultBuffer = new StringBuffer("

"+
-						getInputStreamContents(url.openStream()).replaceAll("&", "&").replaceAll("<","<")+
-						"
"); + String body = getInputStreamContents(url.openStream()); + // Is it already HTML? + if(body.toLowerCase().indexOf("
"+
+						    body.replaceAll("&", "&").replaceAll("<","<")+
+						    "
"); + } editorPane.setText(resultBuffer.toString()); } else{ =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/SeahawkOptionsGUI.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/SeahawkOptionsGUI.java 2007/06/08 14:04:27 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/SeahawkOptionsGUI.java 2007/06/08 20:30:21 1.2 @@ -1,4 +1,5 @@ package ca.ucalgary.seahawk.gui; public class SeahawkOptionsGUI{ + } From gordonp at dev.open-bio.org Fri Jun 8 16:30:22 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 8 Jun 2007 16:30:22 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706082030.l58KUMPM029967@dev.open-bio.org> gordonp Fri Jun 8 16:30:22 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client In directory dev.open-bio.org:/tmp/cvs-serv29870/src/main/org/biomoby/client Modified Files: CentralCachedCallsImpl.java Log Message: Code revamp to deal with new disk cache moby-live/Java/src/main/org/biomoby/client CentralCachedCallsImpl.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralCachedCallsImpl.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralCachedCallsImpl.java 2007/06/07 23:55:42 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralCachedCallsImpl.java 2007/06/08 20:30:22 1.3 @@ -8,11 +8,15 @@ package org.biomoby.client; +import org.biomoby.registry.meta.RegistryCache; + import org.biomoby.shared.MobyException; + +import java.io.*; import java.util.*; public class CentralCachedCallsImpl extends CentralImpl{ - + protected static String CHAR_ENCODING = "UTF-8"; protected static final String SYNTAX_TYPE = "xml"; protected static final long THE_EPOCH = 0; // don't care when the call is made, it shouldn't affect the onto mapping of calls to IDs protected static final Properties PROPERTIES = null; // don't have any properties for the call @@ -111,6 +115,71 @@ return result; } + // check existence of a cached object + public boolean existsInCache (String id) { + if(!getCacheMode()){ + return false; + } + if(super.existsInCache(id)){ + return true; + } + + File cachedDataFile = RegistryCache.getCentralCallFile(getRegistryEndpoint(), id); + // See if it's in the disk cache, if so, load it to memory + if(cachedDataFile != null){ + try{ + Object cachedValue = loadDataFromFile(cachedDataFile); + // Save the disk data to memory + super.setContents(id, cachedValue); + } catch(Exception e){ + e.printStackTrace(); + System.err.println("Could not load data from cache file " + cachedDataFile); + return false; + } + return true; + } + else{ + return false; + } + } + + protected Object loadDataFromFile(File cacheFile) throws Exception{ + char[] contentsBuffer = new char[(int) cacheFile.length()]; // assumes filesize < 2GB + FileReader cacheFileReader = new FileReader(cacheFile); + cacheFileReader.read(contentsBuffer); + return new String(contentsBuffer); + } + + protected void storeDataToFile(File cacheFile, Object data) throws Exception{ + if(data instanceof CharSequence){ + FileWriter cacheFileWriter = new FileWriter(cacheFile); + cacheFileWriter.write(((CharSequence) data).toString()); + cacheFileWriter.close(); + } + else if(data instanceof Serializable){ + throw new Exception("Serialization in cache not yet implemented"); + } + else{ + throw new Exception("Asked to serialize data that is neither a CharSequence, " + + "nor serializable. Found " + data.getClass().getName()); + } + } + + // cache an object + public void setContents (String id, java.lang.Object data) { + if(!getCacheMode()){ + return; + } + + super.setContents(id, data); + File cachedDataFile = RegistryCache.calcCentralCallFile(getRegistryEndpoint(), id); + try{ + storeDataToFile(cachedDataFile, data); + } catch(Exception e){ + System.err.println("Could not store data to cache file " + cachedDataFile); + } + } + protected String createId(String method, Object[] parameters){ // Set the semantics to the call parameters's string representation concatenated // If we were to be pedantic, we should covert the xml into a canonical format From gordonp at dev.open-bio.org Fri Jun 8 16:31:15 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 8 Jun 2007 16:31:15 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706082031.l58KVFF2030091@dev.open-bio.org> gordonp Fri Jun 8 16:31:15 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/meta In directory dev.open-bio.org:/tmp/cvs-serv30060/src/main/org/biomoby/registry/meta Added Files: RegistryCache.java Log Message: Moved from Seahawk, updated moby-live/Java/src/main/org/biomoby/registry/meta RegistryCache.java,NONE,1.1 From gordonp at dev.open-bio.org Fri Jun 8 16:32:04 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 8 Jun 2007 16:32:04 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706082032.l58KW43R030152@dev.open-bio.org> gordonp Fri Jun 8 16:32:04 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util In directory dev.open-bio.org:/tmp/cvs-serv30120/src/main/ca/ucalgary/seahawk/util Removed Files: RegistryCache.java Log Message: Moved to org/biomoby/registry/meta/RegistryCache.java moby-live/Java/src/main/ca/ucalgary/seahawk/util RegistryCache.java,1.1,NONE rcsdiff: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/RCS/RegistryCache.java,v: No such file or directory From gordonp at dev.open-bio.org Fri Jun 8 20:26:25 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 8 Jun 2007 20:26:25 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706090026.l590QPqW030470@dev.open-bio.org> gordonp Fri Jun 8 20:26:24 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/meta In directory dev.open-bio.org:/tmp/cvs-serv30435/src/main/org/biomoby/registry/meta Modified Files: RegistriesList.java Log Message: Changed illegal characters in INAB registry description to Unicode a-acute moby-live/Java/src/main/org/biomoby/registry/meta RegistriesList.java,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/meta/RegistriesList.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/meta/RegistriesList.java 2007/05/21 00:56:15 1.3 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/meta/RegistriesList.java 2007/06/09 00:26:24 1.4 @@ -60,7 +60,7 @@ "INAB, Spain", "", true, - "The MOBY registry at the Instituto Nacional de Bioinform??tica, Spain."), + "The MOBY registry at the Instituto Nacional de Bioinform\u00E1tica, Spain."), new Registry ("testing", From gordonp at dev.open-bio.org Sat Jun 9 14:12:53 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Sat, 9 Jun 2007 14:12:53 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706091812.l59ICrcT004820@dev.open-bio.org> gordonp Sat Jun 9 14:12:52 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data In directory dev.open-bio.org:/tmp/cvs-serv4785/src/main/org/biomoby/shared/data Modified Files: MobyDataComposite.java Log Message: Made error message for anonymous member more verbose moby-live/Java/src/main/org/biomoby/shared/data MobyDataComposite.java,1.15,1.16 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataComposite.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataComposite.java 2007/06/07 23:58:15 1.15 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataComposite.java 2007/06/09 18:12:52 1.16 @@ -59,7 +59,7 @@ if(fieldName == null || fieldName.length() == 0){ throw new MobyException("The subelement with index " + i + " does not have an article " + - "name, which is required"); + "name, which is required (tag "+element.getNodeName()+")"); } MobyDataObject childObject = (MobyDataObject) createInstanceFromDOM(child); if(childObject == null){ From gordonp at dev.open-bio.org Sat Jun 9 14:13:38 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Sat, 9 Jun 2007 14:13:38 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706091813.l59IDc7t004863@dev.open-bio.org> gordonp Sat Jun 9 14:13:38 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data In directory dev.open-bio.org:/tmp/cvs-serv4828/src/main/org/biomoby/shared/data Modified Files: MobyDataXref.java Log Message: Fixed DOM parsing so evidence abbrevation, rather than full code, is expected in XML attributes moby-live/Java/src/main/org/biomoby/shared/data MobyDataXref.java,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataXref.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataXref.java 2006/12/13 17:53:57 1.6 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataXref.java 2007/06/09 18:13:38 1.7 @@ -71,7 +71,7 @@ MobyPrefixResolver.getAttr(e, "serviceName"), MobyPrefixResolver.getAttr(e, "authURI")); - setEvidenceCode(MobyPrefixResolver.getAttr(e, "evidenceCode")); + setEvidenceCodeByAbbrev(MobyPrefixResolver.getAttr(e, "evidenceCode")); setXrefType(MobyPrefixResolver.getAttr(e, "xrefType")); String d = e.getTextContent(); @@ -102,6 +102,10 @@ serviceDescription = desc; } + public void setEvidenceCodeByAbbrev(String abbrev) throws IllegalArgumentException{ + setEvidenceCode(evidenceAbbrevToCode(abbrev)); + } + public void setEvidenceCode(String code) throws IllegalArgumentException{ if(code == null || code.length() == 0){ throw new IllegalArgumentException("Evidence code for an Xref cannot be blank"); @@ -115,8 +119,59 @@ } else{ throw new IllegalArgumentException("Evidence code to be set (" + - code + " was not a valid GO code"); + code + ") was not a valid GO code"); + } + } + + /** + * Given one of the static final evidence codes from this class, returns the 2 or 3 letter + * GO evidence abbreviations. See http://www.geneontology.org/doc/GO.evidence.html + */ + public static String evidenceAbbrevToCode(String abbrev) throws IllegalArgumentException{ + if(abbrev == null || abbrev.length() == 0){ + throw new IllegalArgumentException("Evidence code abbreviation for an Xref cannot be blank"); + } + if(abbrev.equals("IC")){ + return IC; + } + if(abbrev.equals("IDA")){ + return IDA; + } + if(abbrev.equals("IEA")){ + return IEA; + } + if(abbrev.equals("IEP")){ + return IEP; + } + if(abbrev.equals("IGI")){ + return IGI; + } + if(abbrev.equals("IMP")){ + return IMP; + } + if(abbrev.equals("IPI")){ + return IPI; + } + if(abbrev.equals("ISS")){ + return ISS; + } + if(abbrev.equals("NAS")){ + return NAS; + } + if(abbrev.equals("ND")){ + return ND; + } + if(abbrev.equals("RCA")){ + return RCA; + } + if(abbrev.equals("TAS")){ + return TAS; + } + if(abbrev.equals("NR")){ + return NR; } + throw new IllegalArgumentException("Evidence abbreviation to expand (" + + abbrev + " was not a valid GO code abbreviation"); } /** From gordonp at dev.open-bio.org Sat Jun 9 14:14:33 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Sat, 9 Jun 2007 14:14:33 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706091814.l59IEXko004918@dev.open-bio.org> gordonp Sat Jun 9 14:14:33 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data In directory dev.open-bio.org:/tmp/cvs-serv4871/src/main/org/biomoby/shared/data Modified Files: MobyDataBoolean.java MobyDataDateTime.java MobyDataFloat.java MobyDataInt.java Log Message: Added trim() calls to make primitives' parsing more robust moby-live/Java/src/main/org/biomoby/shared/data MobyDataBoolean.java,1.4,1.5 MobyDataDateTime.java,1.9,1.10 MobyDataFloat.java,1.7,1.8 MobyDataInt.java,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataBoolean.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataBoolean.java 2007/06/07 23:58:15 1.4 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataBoolean.java 2007/06/09 18:14:33 1.5 @@ -62,11 +62,11 @@ * "Yes" and "1" are not acceptable. */ public MobyDataBoolean(String articleName, String booleanString){ - this(articleName, Boolean.valueOf(booleanString), null); + this(articleName, Boolean.valueOf(booleanString.trim()), null); } public MobyDataBoolean(String articleName, String booleanString, Registry registry){ - this(articleName, Boolean.valueOf(booleanString), registry); + this(articleName, Boolean.valueOf(booleanString.trim()), registry); } public MobyDataBoolean(Boolean b){ =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataDateTime.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataDateTime.java 2007/06/07 23:58:15 1.9 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataDateTime.java 2007/06/09 18:14:33 1.10 @@ -55,7 +55,7 @@ public MobyDataDateTime(String articleName, String stringISO8601, Registry registry) throws IllegalArgumentException{ super(articleName); setDataType(MobyDataType.getDataType(MobyTags.MOBYDATETIME, registry)); - value = parseISO8601(stringISO8601); + value = parseISO8601(stringISO8601.trim()); } public MobyDataDateTime(String stringISO8601){ =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataFloat.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataFloat.java 2007/06/07 23:58:15 1.7 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataFloat.java 2007/06/09 18:14:33 1.8 @@ -102,7 +102,7 @@ public MobyDataFloat(String articleName, String stringNumber, Registry registry) throws NumberFormatException{ super(articleName); setDataType(MobyDataType.getDataType(MobyTags.MOBYFLOAT, registry)); - value = new BigDecimal(stringNumber); + value = new BigDecimal(stringNumber.trim()); } public MobyDataFloat(String stringNumber){ =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataInt.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataInt.java 2007/06/07 23:58:15 1.6 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataInt.java 2007/06/09 18:14:33 1.7 @@ -97,7 +97,7 @@ public MobyDataInt(String articleName, String stringNumber, Registry registry) throws NumberFormatException{ super(articleName); setDataType(MobyDataType.getDataType(MobyTags.MOBYINTEGER, registry)); - value = new BigInteger(stringNumber); + value = new BigInteger(stringNumber.trim()); } /** From gordonp at dev.open-bio.org Sat Jun 9 14:17:12 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Sat, 9 Jun 2007 14:17:12 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706091817.l59IHCdh004982@dev.open-bio.org> gordonp Sat Jun 9 14:17:12 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared In directory dev.open-bio.org:/tmp/cvs-serv4947/src/main/org/biomoby/shared Modified Files: MobyDataType.java Log Message: Shortcircuit on empty parent searches, for efficiency moby-live/Java/src/main/org/biomoby/shared MobyDataType.java,1.16,1.17 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataType.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataType.java 2007/06/08 20:30:22 1.16 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataType.java 2007/06/09 18:17:12 1.17 @@ -159,6 +159,7 @@ } // Wasn't found if we got to here + //(new Exception("Couldn't find data type for '"+className+"'")).printStackTrace(); return null; } @@ -275,7 +276,8 @@ } public MobyDataType getParent(){ - return getDataType(getParentName()); + String parentName = getParentName(); + return parentName == null || parentName.length() == 0 ? null : getDataType(parentName); } /** From gordonp at dev.open-bio.org Sat Jun 9 14:21:43 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Sat, 9 Jun 2007 14:21:43 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706091821.l59ILhQh005046@dev.open-bio.org> gordonp Sat Jun 9 14:21:43 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/meta In directory dev.open-bio.org:/tmp/cvs-serv5011/src/main/org/biomoby/registry/meta Modified Files: RegistryCache.java Log Message: Fixed javadoc, added cache deletion mechanisms, removed debug message moby-live/Java/src/main/org/biomoby/registry/meta RegistryCache.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/meta/RegistryCache.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/meta/RegistryCache.java 2007/06/08 20:31:15 1.1 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/meta/RegistryCache.java 2007/06/09 18:21:43 1.2 @@ -22,7 +22,7 @@ /** * Returns where a resource should be cached locally, whether it current exists or not. * - * @param one of the resources listed in org.biomoby.shared.Central + * @param resourceName one of the resources listed in org.biomoby.shared.Central */ public static File getOntologyFile(Registry reg, String resourceName){ File fileLocation = null; @@ -87,7 +87,6 @@ cacheFileWriter.write(line+"\n"); } cacheFileWriter.close(); - System.err.println("Wrote " + cacheFile); } public synchronized static Registry getDefaultRegistry(){ @@ -112,7 +111,7 @@ String regName = reg == null ? Registries.DEFAULT_REGISTRY_SYNONYM : reg.getSynonym(); String userName = System.getProperty("user.name") == null ? "" : "." + System.getProperty("user.name"); return new File(tempDir, - REG_CACHE_FILE_PREFIX+"DataType"+userName+"."+regName); + REG_CACHE_FILE_PREFIX+userName+"."+regName+".DataTypes.rdf"); } public static File getServiceTypeOntologyFile(Registry reg){ @@ -129,7 +128,7 @@ String regName = reg == null ? Registries.DEFAULT_REGISTRY_SYNONYM : reg.getSynonym(); String userName = System.getProperty("user.name") == null ? "" : "." + System.getProperty("user.name"); return new File(tempDir, - REG_CACHE_FILE_PREFIX+"ServiceType"+userName+"."+regName); + REG_CACHE_FILE_PREFIX+userName+"."+regName+".ServiceTypes.rdf"); } public static File getNamespaceOntologyFile(Registry reg){ @@ -146,7 +145,7 @@ String regName = reg == null ? Registries.DEFAULT_REGISTRY_SYNONYM : reg.getSynonym(); String userName = System.getProperty("user.name") == null ? "" : "." + System.getProperty("user.name"); return new File(tempDir, - REG_CACHE_FILE_PREFIX+"Namespace"+userName+"."+regName); + REG_CACHE_FILE_PREFIX+userName+"."+regName+".Namespaces.rdf"); } public static File getServiceOntologyFile(Registry reg){ @@ -163,7 +162,7 @@ String regName = reg == null ? Registries.DEFAULT_REGISTRY_SYNONYM : reg.getSynonym(); String userName = System.getProperty("user.name") == null ? "" : "." + System.getProperty("user.name"); return new File(tempDir, - REG_CACHE_FILE_PREFIX+"Service"+userName+"."+regName); + REG_CACHE_FILE_PREFIX+userName+"."+regName+".Services.rdf"); } /** @@ -204,4 +203,34 @@ public static void setTempDir(File dir){ tempDir = dir; } + + /** + * @param allowedAgeMillis files older than this are deleted, or if negative, all are deleted, or if zero, deleted at the end of the session + */ + public static void deleteExpiredCacheFiles(long allowedAgeMillis){ + String userName = System.getProperty("user.name") == null ? "" : "." + System.getProperty("user.name"); + String relativeRegFilePrefix = REG_CACHE_FILE_PREFIX+userName; + String relativeCallFilePrefix = CALL_CACHE_FILE_PREFIX+userName; + + long currentTime = System.currentTimeMillis(); + + for(File tempFile: tempDir.listFiles()){ + // See if it belongs to us, based on the name + if(tempFile.getName().startsWith(relativeRegFilePrefix) || + tempFile.getName().startsWith(relativeCallFilePrefix)){ + // 0 means "for this session only" + if(allowedAgeMillis == 0){ + tempFile.deleteOnExit(); + } + else if(allowedAgeMillis < 0 || + currentTime-tempFile.lastModified() > allowedAgeMillis){ + tempFile.delete(); + } + } + } + } + + public static void deleteAllCacheFiles(){ + deleteExpiredCacheFiles(-1); // negative time == delete all + } } From gordonp at dev.open-bio.org Sat Jun 9 17:58:26 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Sat, 9 Jun 2007 17:58:26 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706092158.l59LwQ8h005262@dev.open-bio.org> gordonp Sat Jun 9 17:58:26 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared In directory dev.open-bio.org:/tmp/cvs-serv5219/src/main/org/biomoby/shared Modified Files: MobyDataType.java MobyNamespace.java MobyServiceType.java Log Message: Changed to synchronize multi-thread access better (i.e. don't load an ontology more than once) moby-live/Java/src/main/org/biomoby/shared MobyDataType.java,1.17,1.18 MobyNamespace.java,1.8,1.9 MobyServiceType.java,1.9,1.10 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataType.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataType.java 2007/06/09 18:17:12 1.17 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataType.java 2007/06/09 21:58:26 1.18 @@ -92,19 +92,21 @@ * refreshing an in-memory cache. */ public static void loadDataTypes(URL dataDefURL, Registry reg) throws Exception{ - if(reg == null){ - reg = RegistryCache.getDefaultRegistry(); - } - - MobyDataType[] datatypes; - DataTypeParser p = new DataTypeParser(dataDefURL); - - datatypes = p.getMobyDataTypesFromRDF(); - for(MobyDataType dataType: datatypes){ - dataType.setRegistry(reg); + synchronized(datatypesMapBySynonym){ + if(reg == null){ + reg = RegistryCache.getDefaultRegistry(); + } + + MobyDataType[] datatypes; + DataTypeParser p = new DataTypeParser(dataDefURL); + + datatypes = p.getMobyDataTypesFromRDF(); + for(MobyDataType dataType: datatypes){ + dataType.setRegistry(reg); + } + datatypesMapBySynonym.put(reg.getSynonym(), datatypes); + datatypesMapByURL.put(dataDefURL, datatypes); } - datatypesMapBySynonym.put(reg.getSynonym(), datatypes); - datatypesMapByURL.put(dataDefURL, datatypes); } public static MobyDataType getDataType(String className){ @@ -125,8 +127,11 @@ if(reg == null){ return null; } - - MobyDataType[] datatypes = datatypesMapBySynonym.get(reg.getSynonym()); + MobyDataType[] datatypes = null; + // sync makes sure we don't fetch it if it's currently being loaded by loadDataTypes + synchronized(datatypesMapBySynonym){ + datatypes = datatypesMapBySynonym.get(reg.getSynonym()); + } // This method has not been called yet in the JVM, populate the datatypes synchronized(datatypesMapByURL){ @@ -135,7 +140,9 @@ URL dataDefURL = Registry.findResourceURL(reg, Central.DATA_TYPES_RESOURCE_NAME); datatypes = datatypesMapByURL.get(dataDefURL); if(datatypes == null){ + System.err.println("Fetching data type ontology from " + dataDefURL); loadDataTypes(dataDefURL, reg); + System.err.println(" ... done"); datatypes = datatypesMapByURL.get(dataDefURL); } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyNamespace.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyNamespace.java 2007/06/08 20:30:22 1.8 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyNamespace.java 2007/06/09 21:58:26 1.9 @@ -72,23 +72,23 @@ * Particularly useful for loading namespace definitions from cached file, or * refreshing an in-memory cache. */ - public static void loadNamespaces(URL namespaceDefURL, Registry reg){ - MobyNamespace[] namespaces; - try{ + public static void loadNamespaces(URL namespaceDefURL, Registry reg) throws Exception{ + synchronized(namespacesMapBySynonym){ + if(reg == null){ + reg = RegistryCache.getDefaultRegistry(); + } + + MobyNamespace[] namespaces; NamespaceParser p = new NamespaceParser(namespaceDefURL); namespaces = p.getMobyNamespacesFromRDF(); - + for(MobyNamespace namespace: namespaces){ namespace.setRegistry(reg); } + + namespacesMapBySynonym.put(reg.getSynonym(), namespaces); + namespacesMapByURL.put(namespaceDefURL.toString(), namespaces); } - catch(Exception e){ - System.err.println("Cannot parse MOBY Namespace Ontology: " + e); - e.printStackTrace(); - return; - } - namespacesMapBySynonym.put(reg.getSynonym(), namespaces); - namespacesMapByURL.put(namespaceDefURL.toString(), namespaces); } public static MobyNamespace getNamespace(String ns){ @@ -107,32 +107,30 @@ return null; } - MobyNamespace[] namespaces = namespacesMapBySynonym.get(reg.getSynonym()); + MobyNamespace[] namespaces = null; + // sync makes sure we don't fetch it if it's currently being loaded by loadNamespaces + synchronized(namespacesMapBySynonym){ + namespaces = namespacesMapBySynonym.get(reg.getSynonym()); + } - // This method has not been called yet in the JVM, populate the datatypes + // This method has not been called yet in the JVM, populate the namespaces synchronized(namespacesMapByURL){ if(namespaces == null){ - String namespaceDefURL = null; try{ - namespaces = namespacesMapByURL.get(namespaceDefURL); - + URL namespaceDefURL = Registry.findResourceURL(reg, Central.NAMESPACES_RESOURCE_NAME); + namespaces = namespacesMapByURL.get(namespaceDefURL); if(namespaces == null){ - namespaceDefURL = convertRegistryToNamespaceResourceURL(reg); - NamespaceParser p = new NamespaceParser(namespaceDefURL); - namespaces = p.getMobyNamespacesFromRDF(); - - for(MobyNamespace namespace: namespaces){ - namespace.setRegistry(reg); - } + System.err.println("Fetching namespace ontology from "+namespaceDefURL); + loadNamespaces(namespaceDefURL, reg); + namespaces = namespacesMapByURL.get(namespaceDefURL); } + } catch(Exception e){ System.err.println("Cannot parse MOBY Namespace Ontology: " + e); e.printStackTrace(); return null; } - namespacesMapBySynonym.put(reg.getSynonym(), namespaces); - namespacesMapByURL.put(namespaceDefURL, namespaces); } } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyServiceType.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyServiceType.java 2007/06/08 20:30:22 1.9 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyServiceType.java 2007/06/09 21:58:26 1.10 @@ -77,19 +77,21 @@ * refreshing an in-memory cache. */ public static void loadServiceTypes(URL serviceDefURL, Registry reg) throws Exception{ - if(reg == null){ - reg = RegistryCache.getDefaultRegistry(); - } - - MobyServiceType[] servicetypes; - ServiceTypeParser p = new ServiceTypeParser(serviceDefURL); - servicetypes = p.getMobyServiceTypesFromRDF(); - - for(MobyServiceType servicetype: servicetypes){ - servicetype.setRegistry(reg); + synchronized(servicetypesMapBySynonym){ + if(reg == null){ + reg = RegistryCache.getDefaultRegistry(); + } + + MobyServiceType[] servicetypes; + ServiceTypeParser p = new ServiceTypeParser(serviceDefURL); + servicetypes = p.getMobyServiceTypesFromRDF(); + + for(MobyServiceType servicetype: servicetypes){ + servicetype.setRegistry(reg); + } + servicetypesMapBySynonym.put(reg.getSynonym(), servicetypes); + servicetypesMapByURL.put(serviceDefURL, servicetypes); } - servicetypesMapBySynonym.put(reg.getSynonym(), servicetypes); - servicetypesMapByURL.put(serviceDefURL, servicetypes); } public static MobyServiceType getServiceType(String className){ @@ -108,7 +110,11 @@ return null; } - MobyServiceType[] servicetypes = servicetypesMapBySynonym.get(reg.getSynonym()); + MobyServiceType[] servicetypes = null; + // sync makes sure we don't fetch it if it's currently being loaded by loadNamespaces + synchronized(servicetypesMapBySynonym){ + servicetypes = servicetypesMapBySynonym.get(reg.getSynonym()); + } // This method has not been called yet in the JVM, populate the datatypes synchronized(servicetypesMapByURL){ @@ -117,6 +123,7 @@ URL serviceDefURL = Registry.findResourceURL(reg, Central.SERVICE_TYPES_RESOURCE_NAME); servicetypes = servicetypesMapByURL.get(serviceDefURL); if(servicetypes == null){ + System.err.println("Fetching service type ontology from " + serviceDefURL); loadServiceTypes(serviceDefURL, reg); servicetypes = servicetypesMapByURL.get(serviceDefURL); } From gordonp at dev.open-bio.org Sat Jun 9 18:00:27 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Sat, 9 Jun 2007 18:00:27 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706092200.l59M0R1Q005326@dev.open-bio.org> gordonp Sat Jun 9 18:00:27 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util In directory dev.open-bio.org:/tmp/cvs-serv5291/src/main/ca/ucalgary/seahawk/util Modified Files: SeahawkOptions.java Log Message: Moved settings from working dir to home dir, other minor changes moby-live/Java/src/main/ca/ucalgary/seahawk/util SeahawkOptions.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/SeahawkOptions.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/SeahawkOptions.java 2007/06/08 20:30:21 1.2 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/SeahawkOptions.java 2007/06/09 22:00:27 1.3 @@ -17,10 +17,11 @@ public static final String REGISTRY_SYNONYM_PROP = "registrySynonym"; public static final String REGISTRY_ENDPOINT_PROP = "registryEndpoint"; public static final String REGISTRY_NAMESPACE_PROP = "registryNamespace"; - public static final String ANON_REGISTRY_SYNONYM = "anonymous"; + public static final String CUSTOM_REGISTRY_SYNONYM = "custom"; public static final String PROPS_FILE_NAME = "seahawkUserPrefs.xml"; - public static final String PROPS_FILE_COMMENT = "This is the only file Seahawk stores on your system indefinitely. If you delete it, your preferences will be reset the next time you run Seahawk."; + public static final String PROPS_FILE_COMMENT = "This is the only file Seahawk stores on your system indefinitely.\n" + + "If you delete it, your preferences will be reset the next time you run Seahawk."; public static final String PROPS_FILE_ENCODING = "UTF-8"; public static final String PROPS_FILE_SYS_PROPERTY = "seahawk.prefs"; @@ -199,7 +200,7 @@ "default registry instead."); } else{ - setRegistry(new Registry(ANON_REGISTRY_SYNONYM, regEndpoint, regNamespace)); + setRegistry(new Registry(CUSTOM_REGISTRY_SYNONYM, regEndpoint, regNamespace)); } } } @@ -223,8 +224,10 @@ /** * Saves the current values of the preferences to a default location that restoreSettings() will use too. + * + * @return true of the save was successful, false otherwise */ - public static void saveSettings(){ + public static boolean saveSettings(){ File defaultsFile = getDefaultsFile(); File defaultsParentFile = defaultsFile.getParentFile(); if(defaultsParentFile != null && @@ -234,7 +237,7 @@ ") is not writeable because its parent directory " + "could not be created, preferences will be lost when " + "Seahawk terminates."); - return; + return false; } } if(defaultsFile.isDirectory()){ @@ -242,13 +245,13 @@ ") is not writeable because a directory with the same " + "name already exists, preferences will be lost when " + "Seahawk terminates."); - return; + return false; } - if(!defaultsFile.canWrite()){ + if(defaultsFile.exists() && !defaultsFile.canWrite()){ System.err.println("Warning: the preferences file (" + defaultsFile + ") is not writeable, preferences will be lost when " + "Seahawk terminates."); - return; + return false; } try{ @@ -258,14 +261,16 @@ e.printStackTrace(); System.err.println("Warning: could not save preferences (file " + defaultsFile + "), they will be lost when Seahawk terminates."); + return false; } + return true; } /** * @return the file system location where preferences are stored (whether the file currently exists or not) */ public static File getDefaultsFile(){ - return new File(System.getProperty("user.dir"), PROPS_FILE_NAME); + return new File(System.getProperty("user.home"), PROPS_FILE_NAME); } /** From gordonp at dev.open-bio.org Sat Jun 9 18:01:15 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Sat, 9 Jun 2007 18:01:15 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706092201.l59M1FxS005371@dev.open-bio.org> gordonp Sat Jun 9 18:01:15 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services In directory dev.open-bio.org:/tmp/cvs-serv5336/src/main/ca/ucalgary/seahawk/services Modified Files: MobyComplexBuilder.java Log Message: Change so namespace without ID can be constructed moby-live/Java/src/main/ca/ucalgary/seahawk/services MobyComplexBuilder.java,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyComplexBuilder.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyComplexBuilder.java 2007/06/08 14:04:27 1.7 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyComplexBuilder.java 2007/06/09 22:01:15 1.8 @@ -142,9 +142,8 @@ MobyClient.WHITESPACE_ATTR_STRIP_FLANKING_VAL, null, data); - - // A non-blank value was the result of the evaluation - if(result.length() > 0){ + // A non-blank value was the result of the evaluation, or it's the only namespace we have + if(mobyNS.length == 1 || result.length() > 0){ if(!haveID){ // A namespace that has a value mobyObj.setPrimaryNamespace(mobyNS[i]); From gordonp at dev.open-bio.org Sat Jun 9 18:02:43 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Sat, 9 Jun 2007 18:02:43 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706092202.l59M2hYi005414@dev.open-bio.org> gordonp Sat Jun 9 18:02:43 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test In directory dev.open-bio.org:/tmp/cvs-serv5379/src/main/ca/ucalgary/seahawk/gui/test Modified Files: allDataTypes.xml Log Message: Added image to test data, temporarily removed BasicGFFSequenceFeature due to anonymous member moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test allDataTypes.xml,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test/allDataTypes.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test/allDataTypes.xml 2006/11/01 23:46:59 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test/allDataTypes.xml 2007/06/09 22:02:43 1.2 @@ -1,4 +1,6 @@ - + + + 4020973406 @@ -17,9 +19,9 @@ d2hhdCB3aWxsIHByaW50IG91dA== - + - + + + +/9j/4AAQSk +ZJRgABAQEASABIAAD//gAXQ3JlYXRlZCB3aXRoIFRoZSBHSU1Q/9sAQwAIBgYHBgUIBwcHCQkICgwUDQ +wLCwwZEhMPFB0aHx4dGhwcICQuJyAiLCMcHCg3KSwwMTQ0NB8nOT04MjwuMzQy/9sAQwEJCQkMCwwYDQ +0YMiEcITIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy/8AAEQ +gA+gCnAwEiAAIRAQMRAf/EABwAAAAHAQEAAAAAAAAAAAAAAAABAgMEBQYHCP/EADwQAAEDAwMCBQIEBA +QFBQAAAAECAxEABCEFEjFBUQYTImFxMpEjQoGhFLHB0QczUvAVFiRi4UNTgpKi/8QAFAEBAAAAAAAAAA +AAAAAAAAAAAP/EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAMAwEAAhEDEQA/AOkUR+tP603beeWv+oLe+f +8A05j96bfafLodbcP4YJSiYSskRBoJA+o/Ao0/SKryzfIcVdeeVFSQP4bG1JxkKiadC7tpYR5fmpTA37 +gJmZMe0fvQSl8D5FBStomobov3CFtrS0kEEtlIVujJz78fpTSn767QfJYDBSog+cJ3CORBoLKhMwRwai +peuI2Fv1iJVHpNUeseK29CsVC7a3XjaCooQCEKPsT+lBpepoFQCgO9cft/Fl/ePF/WNZctUuepti1KRt +HuBn71YnxdcaK4xc/8SRqNi6SAlXpWO4E9f2oOlrWQcUYUSkVRNeIE3dg3fs2qlWqxuDnmJ4zM9jVbcf +4haRZp/GWomRCUDd+4xQa0r9JOMKilT6yPasHaf4naO+8tp1t1oFfpcEKSfngitejUbZy7SELKkKb3B0 +Zb543cT7UEtUfTAjqKEguRGQOaiDUGFOuJlY2KCTKDHIGO9Beo2rV//Drdh0oBCdp4nvEUEoAHcPfNAg +SD2pLTiHFOhCpKF7Vexgf3qPc3ttb3DbT1w02teUpUoAn4oJBxIk5zQ7GTHam1uth/YXEBewnbuEx3ig +pxAaQvenaeDODigX055oUlKgUiCCIoUEtHB+aUeDTYckcoPaFUA7JiUfG6gWRKR+lJ/OfmjCldhHzSHn +27dtTrxQhtOStSgAPvQG86hhkrWYSkVzLxZ44uGVBjT31tSohW3BA7zzNPeIPHVpdn+Hs38pUqTwD0EH +rXNr1arp1biiJkDJoLw+OPELRX5WpPLQeC4Ez/ACqj1G/d1S5D77y1OEetSllU/A6VBWjy8qWoE9QKND +LihvAASlO+Z5ExQJ2qdSQ1lE5JmlJdYZdcS415pLZCBvgIUfzUhNylvdsQCVfUIppbrZIVsO/rHSgtG7 +5dxZIsy4sMoO/y1uHbPUgVVXD7jzhWXABMBPtS9q0FLpy2rijFupQVuUkKSJhfX4oCbR5biFLgIWMycE +Vs/DHi5zT2DprrjS7dQCkqfRvCFdo3D261knW1BILiISQE+0RimEo8u4ACZWkxtVxQdkb8bv29whFw1a +XDLgAhseS5kwIClKCh8GtZpFzZv2RbYZLAQSlbS4lJOehI+xrz7dXLt0hO8khsekJEBP2qfa+ILlId/i +UG7WsD1qVlEdqDujulWi2EJ2LACNo2uKGPvR2Ok2dmyUIQpwbiQXlFwjpgqkiuR6R4xU1clp27u22lJh +pxbhX5KxxP+pJ6gjHSuu6Vfpv9KtbwQA+2lyB0kTQA6eypKSSvfunfPqI/0z29qJGnMbFtubnWt0pbcg +pR0hI6CKnTIpIET80ENOnMtoKEekEyMcf7gfahUw+1CgdXb7iNrrjYAiEER/KlIZCUbVEr7lUZpykgnz +I6Z/pQRr65Y0+zU+4AEpGAB+1ca8Wa5catfuFxws26DtbSBie/ufeui+M7tDFg2p5xLbO8zJiYFcW1DU +xeLW0hKdpVMzmgiPW6g7KHVOpjKiOtFZutlRDilSBkiIH3ozdqbYKSMnkx0pllotDc6mUuJlJ5NAAQ89 +uKgUdCakJsy4kE3ADYBCfemQEpTgYI3TFJdeHmZJCYEZoFptiStLYTjGaN60C20qUttEAew4pDTpLZSJ +kj70amVqUkRgZmOlAh5LaUtFsKMJ9UnE0o+WZVBCiI2g08tovBO0Ddmlm1QkFanEhQnHWgrytaTshRT2 +miLvr3lR3EQrvU0Wa1pC+Eq4B6005p7ikqISlMYMZNAVrcK/iNyZSk4MHin0b279CVNxnKh2jj+dQPKU +1iDI6kVaMu7kJKjKo7cdqBu6S2h9CgNkYMHn9K6P8A4e+IFqdY0m4CIKCGj2jMc9v5VzO4yFTzPPap/h +++XY6zY3CFyG3QtX3z+1B6G2rg+kT8mkbXYA2J/wDuf7U6l5Czg9JpRIESeaCOErCsJxOfWaFPFaQmZx +QoH7dRW0FKmaMmN5HSKcACRAECgQIOKDjHj2/uL/0vqOxtZCUjgVhGW0edtCYVW88cMRfXiUApCXN0Cs +GHVNPpURtPSgcd8pbqlFJ8vIxzUFC1AxulIx8U75qylYSCZ+oRUZlIKzj9KB9Pr9IwDTjidkJcAUOJAm +pLDAVAAJPv/SrFnR3rlQATg+1BWWtu2tY2qJVPBFXVrYlx3YlMA4mKu9O8LoaKVKndPODWos9PYYja2N +x/NEUGXX4YLdqS2glYEYzA71BT4UfWjeAVHjvNdJQjAEcU6lrYCQkCTnFBzRvwncrbUFhQI4HSl/8AK9 +2hC/x0gHnFdEUn2plxuRQcv1DSHmGtymfMKewMVTJW4XUynYEngCus3dqlaSSAf0rMalpSSFFCRuPtQY +a6O9ZG3HIpFluNwhSVBKUmTJp3UmXGFEKGZpOmWzl06ENJKiTkAUHoDQ7tN7aruEq3IQotBQ/NHX94/S +rZQ3FKeqTNVvh7S0ad4ftrRCjhAJPcnJNWuyFlU0EYgFsJngkUKc8jH1dSaFBPkAD3o5Ex1oUAcmg5r4 +7swL9bichxGfmuTXQCXimJrv3jPT/4nS/OSJU2c46Vw/WLXyntwEbjIoIiNqVecjBjPQVHQQXSsAAk9K +OYSYmBzSbd5KHJIxNBqNKtg7sVsnvNbGxtktogAD4FZjw66lce/wDOtpbohIoH2W8gDirFliSMUywkYx +VmzHEUCEsRmKe8obeDNSAnEzFHMAwMUFatvJxFN7MZqY4PVxTKgYNBXXCBBxVNdtApI7VdXE5xVXcAbT +70HNvFbZafHp9J/nSfBcu+KLBoH6nIM9quvE9p51sVRJTVP4GKUeMtPCwmC5Hq+DQehUJCG0pSIAEAUd +CAITGAcUUgKOKA6FNqjakRg0KA2L5talgpcRBIlaYnjikp1JpIcJafGyJls5+O9S3Wm1pAUhKgCCJHY0 +pSErPqSDgjPagh3Fxbv27ra3EBK0Y3EAH4rhniFlIU4nKXGlkbVCDHxXcn9Ps3mmw7bNLSidoUkGJNc2 +8faS03q7jwaALrYIVFBy5XpBI5PIppKZUIp59BQsjoKQyIWBE0Gp8OJCXE5yOldAtDuSJrF+HbJaAHFJ +gd4ra242daCe2dpzU5pyBwagNmTUlkmYJoJ4fPWlh0K4pgRxNKDJ5BoFKIKuaZUCSRxUgMSZJpm6eYtU +bnFgfNBBuGxtyaqLrP00vUdfsWwQXgfiSazLnitkOFO1UHgkUD+oNJcbUFRnpWO08I0rxhaqVIQh5Ksd +prQXWtsOASCCeSMioP8Oh3xTpL8p2OOJTJEiQcUHZ39StWH/LW7tXHG0n+lA6pZFxaA96kgyNp/tU9KQ +EJEDjpRbE4wMcUEJ6/tmWWXXHQlC/pMHOKFPNWzLTri0IAUv6jPOSf60KCwJCpAIkHPtR9QaiBt2VBAa +BBEktkT+9OeW9H1NTGPR1+9A6QhaMEEdxWK8d26bhVulLiQoAzJ4FaspeDJKA1M4BaPM9prAPB5/xTfJ +uFoPIECOCOKDl+p2q7e7UFQROCODTNi2F3rST1Vmtrrem+e26qP8sxAHWspYNFrVEtnkKig6JZtJbYSk +CBFTvMhCc81HYH4AJ7VCumX7zahtZS1+aDzQS39dt7T0hxKiOSM1Cc8XONL3htAb6bjH7Uk2Wnaenznz +JSPzGqi+15pp1bLViGztkF1JE9hwTn9KCwc8d3efLQkn/tTxVho/ibUbu4h1ooSepkVDZ08HTLe8dLMv +DdtSqFJ/TrVgxallTZlKml/StIig1CL9YbGc+1ZbxC+683CXCF568VfWakLaUlY9XE1Q3zSXdTCHB6Og +NBk1W7ba0fxd0o7zhDaZUo+1LYudMuLZxadOfcaagLWoSBWoe0Zi5baReNl9LYMbQE/wAuaQ1olkykts +MKSg/lzmgorZrSb7DCEIMYApdzbptFW7vKbd9Dn6TmtA3pLTJ80NpCh2Gah31sbtKmUjLg2j5NB1JK0l +IhQiO9AqE8iotravNWjTanRuQgJMIHQUssuEf5v/5FA7gEmRQpjyH9x3Pgp6AIE0KCxDiT+YRyKMuJAm +RHFRwjYhMngEcd6UpB8sJ9wftQPBQVwa514ib/AOHeKP4hP+W8d0/PNdBBDcqJwayvji0CtKbuIlTS+f +Y0FczZl5NwoAepRgxXPH7Jy08QFpxG2F5xW/0u/Js0qCuRn5HSoesWzb7guXGdrhWFT3FAtkTbwe1SWU +EswnBqPbqG0AcRU1hMKoKx7w+0/cJduN7xmQJwKsrfSrRCpNkFnj1H+tTR6hjkUpO4YBoIybAIXuCUiO +AM0T6Ny0zG1sYgdamhK1nb0pi7QGlFRAAoItqSlwjPeoeptfjoWME0626DdQnPWnb5py4b9CZIzQLsbk +ONBCvqHepPlqOQPsKprR8JuUpWCCME1pmS04MRNBAeR+GcGqmP+pa7+Yn+daC6AgwKpUI83V7VtI+p5M +/E0G7W82gwTEe1F5yNu7dj4pLrCXCSYz/v+lJSyko29DQLLqAgKJgH2oU2UhZ8o8JzNCgmONKWiBEwKW +oEiR0BpVCaBt1CltwOZqPqNgnULNy2cPpWIOKmUKDkzbTuj6o9ZPH0lXX9jVxfKTdadGCoZHtWh8Q+Gm +9ZIebX5dwkRPQ1jdTstS0FLSXnUqQ5MRmgat3tsDkDrVwwsFMz8Vn1eh3nByPerC1eMbSeOKC5tzuXBN +WrLDe2Z5qiYV6pJ61YrutjUz0oHX3kW52tDctXFUd+XH7sJWqABPOKkpdgKeXyrj2FQXbhCnFBSQsTie +lAu0DTDu8rCzOQDV6q6tEtqUEEkpkCeKzT6GVpUp5AC04CxzFNFTimkhKlrSBAABJPzQBxZW8XNqQCc+ +1WTFxKQts+odO9UT1s8oyVYPbpT1m8u2VCpUmOeYoNG5cBbUg8ioeh/jeJWSchIUf2/wDNJSsLZUtNO+ +GEFWuqX0S0on7gUG2NJgDijJ+9JKhnPHNAW0A7oz3oUCRPPNCglZmZxQE5k88UlRiKAM7aAzIAG7PejJ +6zikOnA+aMn8P9KBXE5/8AFZH/ABA8oaQypawFpXjuRGa1KlkAmehNch8b6wu/vnilX4SD5aB7DmgXbu +C70xp4cgVItV7lAE5FV/hkeZpPlchKlD96eWtVtcZxBoNE2DEp5py4J8oTwTmo9k+HGwofrFTwhLtupJ +yU5oIDxccEJwiOtRRc2yVbT+I51SgTmnbth26aU22ooQMY5qqatdQ08/guq2bgqIkSKC+aRdLJ26a4RM +GRFTE6Zqi1+Wi1SxIkqcUCP261X2Gt6izv3gOlZk5iPgRxip73iG/WmENIbMcqM0EG/wBGctbdT1xf7C +AowkYxVLpD5ced9XmMzhZEYp69Tc37hL7ynCeZwn7VK05hLCICQcZoJhCUMukRB4qx8IshS7y4Ix6UA/ +cn+lZu4vkstOI3AhRxmtjoHk2OjMIWsB1frWnqCe4+IoLqUnI6YoiB2FQUalblCwFHeFkBv8yo6gdRRD +VGC7ACvK/93Gw8dfv9jQS3F7ciJoVAub+Ubra3duUSBuZgj9zQoJKWr+7AL6gxsVIDK53YjMilpYu21Q +h4KCFQneTkHmf6VPSIFJ/MfmgjKtXHyUPOqShJ9JbUQT80g2j4V5SX/wAE+kySVR896nxBPvSHXEMpLr +i0oQkSVKMAUGc8SBjSdKW6244Hlgtp3OEzPNcp1NP4baNxgDJNajxX4ga1jU/LtnN9syICuhPU1mL78T +B4AoLXwmQWHROPMMVcanYec1vQPUM1R+FYQHUDA3YrZIAWjaaDL6dem1dLLuJNXiL0ISQmTPaq7WNKJB +daELH71T29+oEtrJQ6ngKxQay1cBcAk+4p9QG8gVTWWotukeYob5iIq0DqVDcMUC3UgIJDYJHBFRlXLe +4t7fxBOOlPh5KwQInvFGLYEqUBmOelBDA3pLhmDG0U0XNjefzcVJuT5KIBAms9qGopabJJkZoIV7eqau +WkgpJSveRyMHrWx03xppLz0alaoYuFp2qeCJQr9eQK5qh1T7qrhf1K49hT60eY1tJlSRI/tQdvt1afcu +Iftv4dwxhaIJGO9PhpoM7Q2gJA4CRFcCbvLm2UC08pMcQa0OkeN9W08bXXf4lnql3JHweaDrraEoQAkA +DsBFCsnZeP9NeQBcIWwqO4UKFBti6ByUj5VSS+kD62x/8AKjSy02PQ2lIiMCs14h8YWGjpW02E3F0fyA +4HyaC7v9Ut9NtlP3LqEJHAnJPtXKvE3iy61p4sIUUWwP0Dg/PeqvVNZvdYufOunyrskfSn2AqsuSZBmA +OlBKtxsSYEyck048QVkntFNW5HlhQnk4FOck4oJWiXPk34QqYX/Ot5bGUCuZq9KwoEg8gitxoWofxlml +SiN6cLE9aC6W2FoKSJHaszrGheckuM4WMgjkVqEmRQcSFD1feg5ktTtvcDzQUOjqOFD5q0ttZKm1Nqwt +Ikwa0d7plu8CHEApV1FUVz4VaUrcy6tHbaeP0oJTGoNtqTKx2Pv71aMamz5ZCVDkiT0rLf8tauhUt3Da +k9NySKcVoV8hsqub0IH+ltNBN1DVkhSpcjH3rJ37jjrTq0SGkyCrueIFWlvozCn9z7jj0dFGBHwKRrmz +yEMoASncBAx1oKxkQ2nBJA44ipCDBBHPem221BBO0qSMTSFuqaTJQSZ4TQKu2RO9OEq/Y1ER6VZPNSmb +1hwqZcCkBXRQ/rTLyFNO7Sf16EUBGIg8e1ChJ6E/NCg6B4j8dP3gXbabuZZOC4fqV/asSt4kkq9SuSTS +N24ETTKgpB9JkdqB4OJJ6TSVpCgR/OmyAsAjBoBREAmgl252sjA3ZmnR9NNMbltiMAE06CNsDmgbXBFT +tGvjZX6CTDbkJVn96gnmiUMQD70HTmnJSM0tS8Yqg8PagLuxDaz+I3gz1FXBUQMGaBLijH9uKiqUQcYp +5SwTmo7hANAo3KkJ9REfNVl7d+b6RkU+6oRBNQVAKVAEmgQ2dqCo8niqbVRudCT0yfmr5TexsqX0Emsx +fLUt1bjcncTPtQOWu07m1YSsRJ6e9RHykJgHrA/SiLgQtKTu3geoJ4ntUdxZW4owMce1AkpCxBHweopb +biinylndt+lRGfiijcOaICVk9UxQOg8zQooIOMA9aFA4ps7tyTR7weT+lBTkKI6URAVzQKAzxSVJE88U +0tLqBIVIokPf6uaCZbGAtJIGQf9/apExOM1CZWlLoJMAgj9ef71M3SJHAoEkSaLIgmlkxiiPBKsADJNA +/YXpsbtL6Pp/MAeRW3Q8HG0rSZSoSDXNVqWsejA6TxPc1M07XrzT1JZPrTGUr+n9D0oN8riTFRnFJFVr +HiWzeQA8FMr6g5H3qe0tm6yy6hY67TNAwv1qgSaeZtv+2Ks7awSc4py98uxtHH1YCB96DH6/deURbNqI +VyqKoFL2o3T1wO5py4fVdXbtw4rkyT2Haoa3C4riEjAHYUCATuknPJpKRzJ5pZ6n9KIY44oDEJz1pBEG +QTkzRnJk89KChjtQOgFSO5TmhSEq2QQDA5oUD62wsSOabSdsg04hwEwTE0TgxMUA5NNOspXkGDSkkTBP +xR8iAKBluW1pUchJk/HWrTmQMjvVf7HNSrZRWyCcRg/pQOHuMRUZ10uQBhI496W8sElKT8mmozAoBtIO +MUZAUJUJpI55pQPINA2WU7YER2ijbaU2qQ4pB/7TFOBUEUoGeeaCwtNd1KwKSi9WtA/K56gf61Z6vr51 +fTGGkS26VEupHGKzJBTmlSSkkZ3YJ9v9xQJcO6EpJKBx7+9NRtE06oymBimXOI96AcpA60Sk+9FJKgmj +Md8CgHEk/agTx780UY5PejIO0fvQBMzAgR3oUnnB+9Cge2BeUmDRblJ9KsgUQ+metOOgeVMUCJBn7ijC +wTHJikCkAnf+tA8oHmjbWpvdE5Mgij/L+lEB6TQAcTFHRJ4ox9R+KAjunGKEd+lKPAovy/rQDPHelZ5o +hxR/l+9AlxUp2jk0TY2oSBnmaS79SaNonYnNAsiAYplWTTyuRTB6UCRO8ilSPekJ+pXxTnRXxQJSVcxn +pRqyCAfeaIUZ+hVAk5+KFA8ChQf//Z + + + + + + @@ -268,5 +386,5 @@ X2: 5 ( 9.9 bits) S1: 12 (24.3 bits) S2: 19 (38.2 bits) -]]> +]]> From gordonp at dev.open-bio.org Sat Jun 9 18:03:44 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Sat, 9 Jun 2007 18:03:44 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706092203.l59M3iOP005457@dev.open-bio.org> gordonp Sat Jun 9 18:03:44 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv5422/src/main/ca/ucalgary/seahawk/gui Modified Files: SeahawkOptionsGUI.java Log Message: First version of working options dialog moby-live/Java/src/main/ca/ucalgary/seahawk/gui SeahawkOptionsGUI.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/SeahawkOptionsGUI.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/SeahawkOptionsGUI.java 2007/06/08 20:30:21 1.2 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/SeahawkOptionsGUI.java 2007/06/09 22:03:44 1.3 @@ -1,5 +1,372 @@ package ca.ucalgary.seahawk.gui; -public class SeahawkOptionsGUI{ +import ca.ucalgary.seahawk.util.SeahawkOptions; + +import org.biomoby.registry.meta.*; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; + +/** + * A dialog box that allows the Seahawk user to configure + * options such as cache expiry and location, as well as + * the MOBY registry to use, and whether referrer headers + * should be sent to services. Settings are saved to a file + * by the SeahawkOptions class. + */ +public class SeahawkOptionsGUI extends JDialog implements ActionListener, WindowListener{ + public static final String CUSTOM_REGISTRY_SYNONYM = "Custom (set your own location & namespace)"; + public static final String CUSTOM_REGISTRY_DESC = "User-defined MOBY Central registry."; + public static final String DIALOG_TITLE = "Seahawk User Preferences"; + public static final boolean DIALOG_MODAL = true; + + private static final int MAX_DESC_WIDTH = 60; + + private JComboBox registryComboBox; + private JTextPane registryDescTextArea; + private JTextField registryEndpoint; + private JTextField registryNamespace; + + private JButton deleteCacheButton; + private JButton selectCacheDirButton; + private JTextField cacheExpiryTextField; + private JFileChooser cacheDirFileChooser; + + private JCheckBox sendReferrerCheckBox; + + private JButton resetButton; + private JButton okButton; + private JButton cancelButton; + + private RegistriesList registriesList; + private String[] registryNames; + private String lastCustomEndpoint = "http://yourdomain.org/cgi-bin/MOBY-Central.pl"; + private String lastCustomNamespace = "http://yourdomain.org/MOBY/Central"; + + /** + * @param owner the frame that launches this dialog + */ + public SeahawkOptionsGUI(Frame owner){ + super(owner, DIALOG_TITLE, DIALOG_MODAL); + + // Custom handling of window close operation + setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); + addWindowListener(this); + + // The dreaded GridBagLayout... + GridBagLayout gridbag = new GridBagLayout(); + GridBagConstraints c = new GridBagConstraints(); + c.fill = GridBagConstraints.BOTH; + setLayout(gridbag); + + registriesList = new RegistriesList(); + Registry[] registries = registriesList.getAll(); + registryNames = new String[registries.length+1]; + int i = 0; + for(; i < registries.length; i++){ + registryNames[i] = registries[i].getSynonym(); + } + registryNames[i] = CUSTOM_REGISTRY_SYNONYM; + + JLabel label = new JLabel("Registry server:"); + c.gridwidth = 1; + c.weightx = 0.0; + gridbag.setConstraints(label, c); + add(label); + registryComboBox = new JComboBox(registryNames); + registryComboBox.addActionListener(this); + c.gridwidth = GridBagConstraints.REMAINDER; + c.weightx = 1.0; + gridbag.setConstraints(registryComboBox, c); + add(registryComboBox); + + label = new JLabel("Description:"); + c.gridwidth = 1; + c.weightx = 0.0; + gridbag.setConstraints(label, c); + add(label); + registryDescTextArea = new JTextPane(); + registryDescTextArea.setEditable(false); + c.gridwidth = GridBagConstraints.REMAINDER; + c.weightx = 0.0; // 0 so long lines wrap in text area + c.weighty = 1.0; // absorb all extra vertical space in the desc + gridbag.setConstraints(registryDescTextArea, c); + add(registryDescTextArea); + c.weighty = 0.0; //reset + + label = new JLabel("Location:"); + c.gridwidth = 1; + c.weightx = 0.0; + gridbag.setConstraints(label, c); + add(label); + registryEndpoint = new JTextField(50); + registryEndpoint.setEditable(false); + c.gridwidth = GridBagConstraints.REMAINDER; + c.weightx = 1.0; + gridbag.setConstraints(registryEndpoint, c); + add(registryEndpoint); + + label = new JLabel("Namespace:"); + c.gridwidth = 1; + c.weightx = 0.0; + gridbag.setConstraints(label, c); + add(label); + registryNamespace = new JTextField(50); + registryNamespace.setEditable(false); + c.gridwidth = GridBagConstraints.REMAINDER; + c.weightx = 1.0; + gridbag.setConstraints(registryNamespace, c); + add(registryNamespace); + + JSeparator line = new JSeparator(); + c.gridwidth = GridBagConstraints.REMAINDER; + gridbag.setConstraints(line, c); + + sendReferrerCheckBox = new JCheckBox("Send referrer data to services"); + c.gridwidth = GridBagConstraints.REMAINDER; + gridbag.setConstraints(sendReferrerCheckBox, c); + add(sendReferrerCheckBox); + + line = new JSeparator(); + c.gridwidth = GridBagConstraints.REMAINDER; + gridbag.setConstraints(line, c); + + JPanel expiryPanel = new JPanel(new GridLayout(1,0)); + label = new JLabel("Cache expiry (in hours)"); + expiryPanel.add(label); + cacheExpiryTextField = new JTextField(3); + expiryPanel.add(cacheExpiryTextField); + c.gridwidth = 1; + gridbag.setConstraints(expiryPanel, c); + add(expiryPanel); + deleteCacheButton = new JButton("Delete cached items"); + deleteCacheButton.addActionListener(this); + c.gridwidth = 1; + gridbag.setConstraints(deleteCacheButton, c); + add(deleteCacheButton); + + selectCacheDirButton = new JButton("Change cache directory"); + selectCacheDirButton.addActionListener(this); + c.gridwidth = GridBagConstraints.REMAINDER; + gridbag.setConstraints(selectCacheDirButton, c); + add(selectCacheDirButton); + cacheDirFileChooser = new JFileChooser(); + cacheDirFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + + line = new JSeparator(); + c.gridwidth = GridBagConstraints.REMAINDER; + gridbag.setConstraints(line, c); + + resetButton = new JButton("Restore program defaults"); + resetButton.addActionListener(this); + c.gridwidth = 1; + gridbag.setConstraints(resetButton, c); + add(resetButton); + cancelButton = new JButton("Cancel"); + cancelButton.addActionListener(this); + c.gridwidth = 1; + gridbag.setConstraints(cancelButton, c); + add(cancelButton); + okButton = new JButton("Apply changes"); + okButton.addActionListener(this); + c.gridwidth = GridBagConstraints.REMAINDER; + gridbag.setConstraints(okButton, c); + add(okButton); + + setCurrentValues(); + pack(); + } + + public void actionPerformed(ActionEvent event){ + Object source = event.getSource(); + if(source == cancelButton){ + setCurrentValues(); + setVisible(false); + } + else if(source == okButton){ + saveSettings(); + } + else if(source == resetButton){ + setDefaultValues(); + } + else if(source == selectCacheDirButton){ + int choice = cacheDirFileChooser.showOpenDialog(this); + if (choice != JFileChooser.APPROVE_OPTION) { + cacheDirFileChooser.setSelectedFile(SeahawkOptions.getTempDir()); + } + } + else if(source == deleteCacheButton){ + RegistryCache.deleteAllCacheFiles(); + // Can we also delete the in-memory cache somehow? + } + else if(source == registryComboBox){ + updateRegistryFields(); + } + } + /** + * Use the values defined by SeahawkOptions. + */ + private void setCurrentValues(){ + Registry currentRegistry = SeahawkOptions.getRegistry(); + if(currentRegistry == null){ + registryComboBox.setSelectedItem(RegistriesList.DEFAULT_REGISTRY_SYNONYM); + } + else if(currentRegistry.getSynonym().equals(SeahawkOptions.CUSTOM_REGISTRY_SYNONYM)){ + registryComboBox.setSelectedItem(CUSTOM_REGISTRY_SYNONYM); // a bit more verbose than SO.CRS + lastCustomEndpoint = currentRegistry.getEndpoint(); + lastCustomNamespace = currentRegistry.getNamespace(); + } + else{ + registryComboBox.setSelectedItem(currentRegistry.getSynonym()); + } + updateRegistryFields(); + sendReferrerCheckBox.setSelected(SeahawkOptions.getSendReferrerPolicy()); + cacheExpiryTextField.setText(""+SeahawkOptions.getCacheExpiry()); + cacheDirFileChooser.setSelectedFile(SeahawkOptions.getTempDir()); + } + + private void saveSettings(){ + double expiry = SeahawkOptions.getCacheExpiry(); + try{ + expiry = Double.parseDouble(cacheExpiryTextField.getText()); + } catch(Exception e){ + JOptionPane.showMessageDialog(null, + "The cache expiry field is not a number,\nplease correct it to continue", + "Invalid Formatting", + JOptionPane.ERROR_MESSAGE); + return; + } + + Registry previousRegistry = SeahawkOptions.getRegistry(); + String selectedRegistryName = registryComboBox.getSelectedItem().toString(); + if(selectedRegistryName.equals(CUSTOM_REGISTRY_SYNONYM)){ + SeahawkOptions.setRegistry(new Registry(SeahawkOptions.CUSTOM_REGISTRY_SYNONYM, + registryEndpoint.getText(), + registryNamespace.getText())); + } + else{ + try{ + SeahawkOptions.setRegistry(registriesList.get(selectedRegistryName)); + } catch(Exception e){ + e.printStackTrace(); + JOptionPane.showMessageDialog(null, + "The registry information could not be saved properly,\n" + + "see the console for more details. Aborting save.", + "Registry Specification Error", + JOptionPane.ERROR_MESSAGE); + return; + } + } + + // Update SeahawkOptions with the values from the form + try{ + SeahawkOptions.setTempDir(cacheDirFileChooser.getSelectedFile()); + } catch(Exception e){ + e.printStackTrace(); + JOptionPane.showMessageDialog(null, + "Please select another directory for the cache.\n"+ + "The specified cache directory ("+ + cacheDirFileChooser.getSelectedFile()+ + ") is not suitable:\n"+ + e.getMessage(), + "Cache Specification Error", + JOptionPane.ERROR_MESSAGE); + SeahawkOptions.setRegistry(previousRegistry); // Roll back the change + return; + } + + SeahawkOptions.setSendReferrerPolicy(sendReferrerCheckBox.isSelected()); + SeahawkOptions.setCacheExpiry(expiry); + + // Saves the new values to a file, so they will perpetuate themselves between sessions + if(!SeahawkOptions.saveSettings()){ + JOptionPane.showMessageDialog(null, + "Sorry, but there was an error saving your preferences.\n"+ + "Please see the console for more details.", + "Error Saving Preferences", + JOptionPane.ERROR_MESSAGE); + } + setVisible(false); + } + + private void setDefaultValues(){ + // Restore the program defaults in subsequent JVM's by deleting the preferences file! + java.io.File defaultsFile = SeahawkOptions.getDefaultsFile(); + if(defaultsFile.exists()){ + defaultsFile.delete(); + } + + // We also need to reset the current session...TODO + JOptionPane.showMessageDialog(null, + "Please restart Seahawk to continue with the default settings.", + "Custom Settings Deleted", + JOptionPane.INFORMATION_MESSAGE); + setVisible(false); + } + + private void updateRegistryFields(){ + // Update all the registry fields if the name switches + String selectedRegistryName = registryComboBox.getSelectedItem().toString(); + if(selectedRegistryName.equals(CUSTOM_REGISTRY_SYNONYM)){ + registryDescTextArea.setText(CUSTOM_REGISTRY_DESC); + registryEndpoint.setEditable(true); + registryEndpoint.setText(lastCustomEndpoint); + registryNamespace.setEditable(true); + registryNamespace.setText(lastCustomNamespace); + pack(); + return; + } + if(registryDescTextArea.getText().equals(CUSTOM_REGISTRY_DESC)){ + lastCustomEndpoint = registryEndpoint.getText(); + lastCustomNamespace = registryNamespace.getText(); + } + + try{ + Registry selectedRegistry = registriesList.get(registryComboBox.getSelectedItem().toString()); + String desc = selectedRegistry.getDescription(); + String newDesc = ""; + if(desc != null){ + int charCount = 0; + int curLine = 0; + for(String word: desc.split(" ")){ + charCount += word.length() + 1; + if(charCount/MAX_DESC_WIDTH > curLine){ + curLine++; + charCount--; + newDesc += "\n"; + } + newDesc += word + " "; + } + } + registryDescTextArea.setText(newDesc); + registryEndpoint.setText(selectedRegistry.getEndpoint()); + registryEndpoint.setEditable(false); + registryNamespace.setText(selectedRegistry.getNamespace()); + registryNamespace.setEditable(false); + } catch(Exception e){ + e.printStackTrace(); + return; + } + + pack(); + } + + + public void windowActivated(WindowEvent e){} + public void windowClosed(WindowEvent e){} + /** + * Invoked when the user attempts to close the window from the window's system menu. + * Implemented as resetting the fields to their original values, and closing the + * window (same effect as the "Cancel" button). + */ + public void windowClosing(WindowEvent e){ + setCurrentValues(); + setVisible(false); + } + public void windowDeactivated(WindowEvent e){} + public void windowDeiconified(WindowEvent e){} + public void windowIconified(WindowEvent e){} + public void windowOpened(WindowEvent e){} } From gordonp at dev.open-bio.org Sat Jun 9 18:05:52 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Sat, 9 Jun 2007 18:05:52 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706092205.l59M5qcG005521@dev.open-bio.org> gordonp Sat Jun 9 18:05:52 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv5486/src/main/ca/ucalgary/seahawk/gui Modified Files: MobyContentPane.java Log Message: Removed debug statement moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyContentPane.java,1.9,1.10 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java 2007/06/08 20:30:21 1.9 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java 2007/06/09 22:05:52 1.10 @@ -237,6 +237,7 @@ return; } catch(Exception e){ + e.printStackTrace(); status.setText("Note: There was an error transforming the MOBY data " + "into presentation form, it may not be displayed correctly"); logger.error("Note: There was an error transforming the MOBY data " + @@ -308,15 +309,16 @@ logger.error("Failure in loading MOBYfied binary data:\n" + e); } // Shouldn't get here unless either not binary, or the binary data load failed - System.err.println("Is plain text"); editorPane.setContentType("text/html"); String body = getInputStreamContents(url.openStream()); // Is it already HTML? if(body.toLowerCase().indexOf("
"+
 						    body.replaceAll("&", "&").replaceAll("<","<")+
 						    "
"); From gordonp at dev.open-bio.org Sat Jun 9 18:06:28 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Sat, 9 Jun 2007 18:06:28 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706092206.l59M6SSJ005584@dev.open-bio.org> gordonp Sat Jun 9 18:06:28 EDT 2007 Update of /home/repository/moby/moby-live/Java/xmls In directory dev.open-bio.org:/tmp/cvs-serv5549/xmls Modified Files: seahawkBuild.xml Log Message: Revived splash screen for applet moby-live/Java/xmls seahawkBuild.xml,1.8,1.9 =================================================================== RCS file: /home/repository/moby/moby-live/Java/xmls/seahawkBuild.xml,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- /home/repository/moby/moby-live/Java/xmls/seahawkBuild.xml 2007/06/08 14:04:27 1.8 +++ /home/repository/moby/moby-live/Java/xmls/seahawkBuild.xml 2007/06/09 22:06:28 1.9 @@ -13,6 +13,7 @@ + @@ -221,7 +222,7 @@ basedir="${src.main}"> - +
From gordonp at dev.open-bio.org Sat Jun 9 18:15:06 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Sat, 9 Jun 2007 18:15:06 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706092215.l59MF69p005648@dev.open-bio.org> gordonp Sat Jun 9 18:15:06 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/meta In directory dev.open-bio.org:/tmp/cvs-serv5613/src/main/org/biomoby/registry/meta Modified Files: RegistryCache.java Log Message: Fixed javadoc warning moby-live/Java/src/main/org/biomoby/registry/meta RegistryCache.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/meta/RegistryCache.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/meta/RegistryCache.java 2007/06/09 18:21:43 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/meta/RegistryCache.java 2007/06/09 22:15:06 1.3 @@ -47,7 +47,7 @@ /** * Stores the given resource to a file for retrieval later with getOntologyFile(). * - * @param one of the resources listed in org.biomoby.shared.Central + * @param resourceName one of the resources listed in org.biomoby.shared.Central */ public static void cacheRegistryOntology(Registry reg, String resourceName) throws Exception{ if(resourceName == null){ From gordonp at dev.open-bio.org Sat Jun 9 18:16:54 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Sat, 9 Jun 2007 18:16:54 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706092216.l59MGs6s005691@dev.open-bio.org> gordonp Sat Jun 9 18:16:54 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv5656/src/main/ca/ucalgary/seahawk/gui Modified Files: MobyContentGUI.java Log Message: Better caching implemented moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyContentGUI.java,1.10,1.11 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java 2007/06/08 20:30:21 1.10 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java 2007/06/09 22:16:54 1.11 @@ -80,6 +80,8 @@ private MobyContentClipboard clipboard; private MobyContentHelpPane helpPane; private DataRecorder dataRecorder; // used for workflow export, etc. + private SeahawkOptionsGUI settingsGUI; + private boolean setup; private Map request2tab; private int activeTabIndex = -1; @@ -210,6 +212,7 @@ status); getContentPane().add(tabbedPane, java.awt.BorderLayout.CENTER); + settingsGUI = new SeahawkOptionsGUI(this); } public boolean allTabsVisible(){ @@ -727,6 +730,10 @@ showHelpTab(); return; } + else if(source == settingsButton){ + settingsGUI.setVisible(true); + return; + } String cmd = e.getActionCommand(); if(FILE_OPEN_OPTION.equals(cmd)){ @@ -924,7 +931,7 @@ // Asynchronously load up ontology data so it's ready when the user needs it. cacheOntologies(); - MobyContentGUI gui = ca.ucalgary.seahawk.util.MobyUtils.getMobyContentGUI(new JLabel()); + MobyContentGUI gui = MobyUtils.getMobyContentGUI(new JLabel()); gui.setDefaultCloseOperation(defaultCloseOperation); gui.setVisible(true); @@ -953,9 +960,37 @@ protected static void cacheOntologies(){ final Registry preferredRegistry = SeahawkOptions.getRegistry(); + // Remove stale cache files before doing anything else + long allowedAgeMillis = (long) SeahawkOptions.getCacheExpiry()*60*60*1000; // hours to milliseconds + RegistryCache.deleteExpiredCacheFiles(allowedAgeMillis); + // Redirect the registry endpoints to local cache files if available // preferredRegistry and/or dataDefURL may be null, if not cached, but that's okay to pass around + new Thread(){ + public void run(){ + File namespacesDefFile = RegistryCache.getOntologyFile(preferredRegistry, + Central.NAMESPACES_RESOURCE_NAME); + try{ + URL namespacesDefURL = namespacesDefFile.toURI().toURL(); + if(namespacesDefFile.exists()){ + // Use the cached file rather than actually going to the registry + MobyNamespace.loadNamespaces(namespacesDefURL, + preferredRegistry); + } + else{ + // Create it from the remote source, then load it + RegistryCache.cacheRegistryOntology(preferredRegistry, + Central.NAMESPACES_RESOURCE_NAME); + MobyNamespace.loadNamespaces(namespacesDefURL, + preferredRegistry); + } + } catch(Exception e){ + e.printStackTrace(); + } + } + }.start(); + // The following command will cache all data type definitions for this session new Thread(){ public void run(){ @@ -1002,6 +1037,7 @@ } } }.start(); + // And the service definitions //new Thread(){ // public void run(){org.biomoby.shared.MobyService.getService("","");} From kawas at dev.open-bio.org Thu Jun 14 09:44:53 2007 From: kawas at dev.open-bio.org (Eddie Kawas) Date: Thu, 14 Jun 2007 09:44:53 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706141344.l5EDirth022178@dev.open-bio.org> kawas Thu Jun 14 09:44:52 EDT 2007 Update of /home/repository/moby/moby-live/Perl/MOBY In directory dev.open-bio.org:/tmp/cvs-serv22143 Modified Files: Central.pm Log Message: fixed bug that allowed secondary inputs to be registered without articlenames. moby-live/Perl/MOBY Central.pm,1.283,1.284 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.283 retrieving revision 1.284 diff -u -r1.283 -r1.284 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2007/06/01 13:01:15 1.283 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2007/06/14 13:44:52 1.284 @@ -1608,6 +1608,9 @@ my $article = $parameter->getAttributeNode("articleName"); $article = $article->getValue() if $article; + return (-1,"Secondary inputs must be registered with articlenames.") + unless $article; + # make sure that the articlename is corrects return (-1,"Secondary input had an invalid articlename. Articlenames may not contain spaces or other special characters.") if $article =~ /([\+\=\':\s\"\&\<\>\[\]\^\`\{\|\}\~\(\)\\\/\$\#\@\,\|\?\.!\*\;])/; From gordonp at dev.open-bio.org Fri Jun 15 20:24:01 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 15 Jun 2007 20:24:01 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706160024.l5G0O14q029066@dev.open-bio.org> gordonp Fri Jun 15 20:24:00 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv29030/src/main/ca/ucalgary/seahawk/gui Modified Files: MobyContentPane.java Log Message: Fixed HTML page loading..must use setPage(), not setText due to JEditorPane bug, fixed indetation, removed cruft code, improved preformatting moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyContentPane.java,1.10,1.11 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java 2007/06/09 22:05:52 1.10 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java 2007/06/16 00:24:00 1.11 @@ -1,6 +1,7 @@ package ca.ucalgary.seahawk.gui; +// For external links import ca.ucalgary.seahawk.util.*; import org.biomoby.client.MobyRequest; @@ -86,6 +87,7 @@ editorPane = new PrintableJEditorPane(); editorPane.addKeyListener(this); editorPane.setTransferHandler(getTransferHandler()); + //editorPane.setPreferredSize(parentComponent.getPreferredSize()); editorPane.setEditable(false); editorPane.addMouseListener(this); editorPane.addHyperlinkListener(this); @@ -237,25 +239,23 @@ return; } catch(Exception e){ - e.printStackTrace(); status.setText("Note: There was an error transforming the MOBY data " + "into presentation form, it may not be displayed correctly"); logger.error("Note: There was an error transforming the MOBY data " + "into presentation form, it may not be displayed correctly"); } + // Get rid of inter-tag whitespaces + htmlContents = htmlContents.replaceAll(">[ \\t\\r\\n]+<", "><"); + int origHash = htmlContents.hashCode(); // Looks like tab-formatted text (at least 3 tabs)? - if(htmlContents.indexOf('\t') != -1){ - htmlContents = htmlContents.replaceAll(">(([^<]*\t){3,}[^<]+)", ">
$1
"); - } - // Looks like formatting whitespace - else if(htmlContents.indexOf(" ") != -1){ - htmlContents = htmlContents.replaceAll(">([^<]+ [^<]+)<", ">
$1
<"); - } - else{ + htmlContents = htmlContents.replaceAll(">(([^<]*\t){3,}[^<]+)<", ">
$1
<"); + // Looks like formatting whitespace? + htmlContents = htmlContents.replaceAll(">([^<]* [^<]*)<", ">
$1
<"); + // If no preformatting done, break up long DNA stretches + if(htmlContents.hashCode() == origHash){ // Break up any really long DNA/AA stretches - System.err.println("Trying to break up long streches"); - htmlContents = htmlContents.replaceAll("([a-zA-Z]{60})", "\n
$1"); - htmlContents = htmlContents.replaceAll("([a-zA-Z]{60})([a-zA-Z]{1,})", "$1\n
$2
\n"); + htmlContents = htmlContents.replaceAll("([a-zA-Z]{80})", "\n
$1"); + htmlContents = htmlContents.replaceAll("([a-zA-Z]{80})([a-zA-Z]{1,})", "$1\n
$2
\n"); } // Otherwise assume it's formatted resultBuffer.append(htmlContents); @@ -284,10 +284,25 @@ // Assume it's plain text, or whatever the JEditorPane can glean from the content-type // such as a remote HTML or RTF doc, because result buffer will be empty in condition below else{ + //editorPane.setContentType("text/plain"); isContentsXML = false; + //editorPane.setFont(java.awt.Font.getFont("Monospaced")); + editorPane.setContentType("text/html"); + String body = getInputStreamContents(url.openStream()); + if(body.toLowerCase().indexOf("
"+
+						    body.replaceAll("&", "&").replaceAll("<","<")+
+						    "
"); + } } - if(resultBuffer.length() == 0){ + if(resultBuffer == null){ // only happens if the url is already an HTML doc + editorPane.setPage(url); + } + else if(resultBuffer.length() == 0){ // Attempt to use MobyClient to convert the url's data into a Moby object // (e.g. if the file to load is an image, or a chromatogram) try{ @@ -309,21 +324,7 @@ logger.error("Failure in loading MOBYfied binary data:\n" + e); } // Shouldn't get here unless either not binary, or the binary data load failed - editorPane.setContentType("text/html"); - String body = getInputStreamContents(url.openStream()); - // Is it already HTML? - if(body.toLowerCase().indexOf("
"+
-						    body.replaceAll("&", "&").replaceAll("<","<")+
-						    "
"); - } - editorPane.setText(resultBuffer.toString()); + editorPane.setPage(url); } else{ editorPane.setText(resultBuffer.toString()); @@ -332,8 +333,6 @@ } // Regardless of the doc, scroll to a reference called "start:" if available. // By default the pane will annoyingly scroll to the bottom when new data is loaded. - try{Thread.sleep(1000);} // Give it time to paint before scrolling - catch(Exception te){} editorPane.scrollToReference("start"); } catch (java.io.IOException ioe) { @@ -403,13 +402,13 @@ tabbedPane.setTitleAt(tabbedPane.indexOfComponent(this), ""+requestEvent.getID()+"-"+requestEvent.getService().getName()); setWaitScreen(); - // Store the request being sent (w/ 2ndary params and all), - // for reference (e.g. when exporting a workflow) - try{ - dataRecorder.saveInputData(requestEvent); - } catch(Exception e){ - e.printStackTrace(); - } + // Store the request being sent (w/ 2ndary params and all), + // for reference (e.g. when exporting a workflow) + try{ + dataRecorder.saveInputData(requestEvent); + } catch(Exception e){ + e.printStackTrace(); + } } public void stop(MobyRequest request, int requestID){ @@ -495,17 +494,17 @@ } public String toScufl() throws Exception{ - URL[] historyToExport = (URL[]) history.toArray(new URL[history.size()]); - if(historyIndex != historyToExport.length-1){ - // Shorten the array if we aren't cuurently on the last doc (i.e. - // we don't want to export documents forward in the history) - URL[] truncatedHistory = new URL[historyIndex]; - System.arraycopy(historyToExport, 0, truncatedHistory, 0, historyIndex); - historyToExport = truncatedHistory; - } - ByteArrayOutputStream output = new ByteArrayOutputStream(); - dataRecorder.exportWorkflow(historyToExport, output, DataRecorder.TAVERNA15); - return output.toString(); + URL[] historyToExport = (URL[]) history.toArray(new URL[history.size()]); + if(historyIndex != historyToExport.length-1){ + // Shorten the array if we aren't cuurently on the last doc (i.e. + // we don't want to export documents forward in the history) + URL[] truncatedHistory = new URL[historyIndex]; + System.arraycopy(historyToExport, 0, truncatedHistory, 0, historyIndex); + historyToExport = truncatedHistory; + } + ByteArrayOutputStream output = new ByteArrayOutputStream(); + dataRecorder.exportWorkflow(historyToExport, output, DataRecorder.TAVERNA15); + return output.toString(); } // Save the MOBY data to a file, then tell NewBrowser to load that local file URL @@ -543,8 +542,8 @@ } try { - URL outputURL = dataRecorder.saveOutputData(mre); - gotoURL(outputURL, true); + URL outputURL = dataRecorder.saveOutputData(mre); + gotoURL(outputURL, true); } catch (Exception e) { failed("Could not write a local file"); editorPane.setText("ERROR: Could not write temporary file for MOBY results: " + e); @@ -554,31 +553,6 @@ succeeded(responseType); } - private String serviceToFilePrefix(MobyService service){ - return service.getAuthority()+"_SEAHAWk_"+service.getName()+"_SEAHAWk_"; - } - - private MobyService filePrefixToService(String filename) throws Exception{ - String tokens[] = filename.split("_SEAHAWk_"); - if(tokens == null || tokens.length < 2){ - return null; - } - - String auth = tokens[0]; - String name = tokens[1]; - - if(name == null){ - return null; - } - - MobyService service = new MobyService(name, auth); // template - MobyService[] validServices = servicesGUI.getMobyCentralImpl().findService(service); - if(validServices == null || validServices.length == 0){ - return null; - } - return validServices[0]; - } - protected boolean hasContents(MobyContentInstance responses){ MobyDataObjectSet retrievedObjects = responses.retrieveObjects(); return retrievedObjects != null && retrievedObjects.size() > 0; From gordonp at dev.open-bio.org Fri Jun 15 20:25:08 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 15 Jun 2007 20:25:08 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706160025.l5G0P88q029132@dev.open-bio.org> gordonp Fri Jun 15 20:25:08 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared In directory dev.open-bio.org:/tmp/cvs-serv29096/src/main/org/biomoby/shared Modified Files: MobyNamespace.java Log Message: Fixed namespace 'put' data typing moby-live/Java/src/main/org/biomoby/shared MobyNamespace.java,1.9,1.10 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyNamespace.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyNamespace.java 2007/06/09 21:58:26 1.9 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyNamespace.java 2007/06/16 00:25:08 1.10 @@ -38,7 +38,7 @@ protected Registry registry; //provenance of the namspace definition private static Map namespacesMapBySynonym = new HashMap(); - private static Map namespacesMapByURL = new HashMap(); + private static Map namespacesMapByURL = new HashMap(); /************************************************************************** * Default constructor. Other characteristics are empty - which is usually @@ -87,7 +87,7 @@ } namespacesMapBySynonym.put(reg.getSynonym(), namespaces); - namespacesMapByURL.put(namespaceDefURL.toString(), namespaces); + namespacesMapByURL.put(namespaceDefURL, namespaces); } } From gordonp at dev.open-bio.org Fri Jun 15 20:26:01 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 15 Jun 2007 20:26:01 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706160026.l5G0Q1fI029177@dev.open-bio.org> gordonp Fri Jun 15 20:26:01 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client In directory dev.open-bio.org:/tmp/cvs-serv29141/src/main/org/biomoby/client Modified Files: MobyRequest.java Log Message: Eliminated superfluous processEvent() call, once all data is loaded moby-live/Java/src/main/org/biomoby/client MobyRequest.java,1.26,1.27 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java 2007/06/08 14:04:27 1.26 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java 2007/06/16 00:26:01 1.27 @@ -293,7 +293,11 @@ Element mobyDOM = null; if(mobyService.isAsynchronous()){ // Async is "simpler", because it had to merge DOMs together into a single MobyContentInstance anyway - return performAsyncSOAPRequest(mobyService, inData, handler, requestId); + MobyContentInstance mci = performAsyncSOAPRequest(mobyService, inData, handler, requestId); + StringWriter writer = new StringWriter(); + MobyDataUtils.toXMLDocument(writer, mci); + contentsXML.append(writer.toString()); + return mci; } else{ String mobyXML = convertMOBYDataToMOBYRequest(inData); @@ -347,7 +351,12 @@ MobyDataUtils.toXMLDocument(xmlWriter, finalContents); mre.setContentsXML(xmlWriter.toString()); - handler.processEvent(mre); + if(!queryIDs.isEmpty()){ + // Send an update event only if we aren't finished yet. + // If we are finished, the client is going to get this event as the + // invocation thread finishes up (no need to double up). + handler.processEvent(mre); + } } } } catch (Exception e) { From gordonp at dev.open-bio.org Fri Jun 15 20:26:38 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 15 Jun 2007 20:26:38 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706160026.l5G0QcEh029221@dev.open-bio.org> gordonp Fri Jun 15 20:26:38 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util In directory dev.open-bio.org:/tmp/cvs-serv29185/src/main/ca/ucalgary/seahawk/util Modified Files: SeahawkOptions.java Log Message: Added check for null registry when saving preferences moby-live/Java/src/main/ca/ucalgary/seahawk/util SeahawkOptions.java,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/SeahawkOptions.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/SeahawkOptions.java 2007/06/09 22:00:27 1.3 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/SeahawkOptions.java 2007/06/16 00:26:38 1.4 @@ -213,9 +213,11 @@ properties.setProperty(CACHE_POLICY_PROP, ""+cacheExpiryInHours); properties.setProperty(REFERRER_POLICY_PROP, ""+referrerPolicy); properties.setProperty(TEMP_DIR_PROP, tmpDir.getCanonicalFile().getPath()); - properties.setProperty(REGISTRY_SYNONYM_PROP, registry.getSynonym()); - properties.setProperty(REGISTRY_ENDPOINT_PROP, registry.getEndpoint()); - properties.setProperty(REGISTRY_NAMESPACE_PROP, registry.getNamespace()); + if(registry != null){ + properties.setProperty(REGISTRY_SYNONYM_PROP, registry.getSynonym()); + properties.setProperty(REGISTRY_ENDPOINT_PROP, registry.getEndpoint()); + properties.setProperty(REGISTRY_NAMESPACE_PROP, registry.getNamespace()); + } properties.storeToXML(os, PROPS_FILE_COMMENT, From gordonp at dev.open-bio.org Fri Jun 15 20:27:44 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 15 Jun 2007 20:27:44 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706160027.l5G0Ri5E029265@dev.open-bio.org> gordonp Fri Jun 15 20:27:44 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util In directory dev.open-bio.org:/tmp/cvs-serv29229/src/main/ca/ucalgary/seahawk/util Modified Files: CloseTabIcon.java Log Message: Changed code to ensure close action is only active when the close icon is displayed moby-live/Java/src/main/ca/ucalgary/seahawk/util CloseTabIcon.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/CloseTabIcon.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/CloseTabIcon.java 2007/04/03 02:18:46 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/CloseTabIcon.java 2007/06/16 00:27:44 1.2 @@ -34,6 +34,10 @@ super(getIcon(), otherIcon, spacerWidth, orient); } + public Rectangle getCloseIconArea(){ + return closeIconArea; + } + public static Icon getIcon() throws Exception{ if(closeIcon == null){ URL u = Thread.currentThread().getContextClassLoader().getResource(CLOSE_TAB_ICON_RESOURCE); @@ -57,19 +61,51 @@ return; } tabbedPane = (JTabbedPane) c; - tabbedPane.addMouseListener(new MouseAdapter(){ - public void mouseReleased(MouseEvent e){ - // Did the user click in the close icon area? - if(!e.isConsumed() && closeIconArea.contains(e.getX(), e.getY())){ - int tabIndex = tabbedPane.getSelectedIndex(); - tabbedPane.remove(tabIndex); - e.consume(); // so other tabs aren't closed by mistake - } - } - }); + tabbedPane.addMouseListener(new Closer(this, tabbedPane)); } // The close Icon is the first of the two. Note its area so we can check for mouse clicks later closeIconArea = new Rectangle(x, y, getFirstIcon().getIconWidth(), getFirstIcon().getIconHeight()); } + + class Closer extends MouseAdapter{ + private CloseTabIcon icon; + private JTabbedPane tabbedPane; + private boolean active; + + public Closer(CloseTabIcon cti, JTabbedPane tp){ + icon = cti; + tabbedPane = tp; + active = false; + } + + public void mousePressed(MouseEvent e){ + if(!e.isConsumed() && getCloseIconArea() != null && + getCloseIconArea().contains(e.getX(), e.getY()) && + tabbedPane.getIconAt(tabbedPane.getSelectedIndex()) == icon){ + active = true; + } + else{ + active = false; + } + } + + public void mouseReleased(MouseEvent e){ + // Did the user click in the close icon area, when the icon was being displayed? + if(active && !e.isConsumed() && getCloseIconArea() != null && + getCloseIconArea().contains(e.getX(), e.getY())){ + int tabIndex = tabbedPane.getSelectedIndex(); + if(tabIndex < 0){ + return; + } + if(tabbedPane.getIconAt(tabIndex) != icon){ + // Don't respond unless the close tab icon is actually showing + return; + } + tabbedPane.remove(tabIndex); + e.consume(); // so other tabs aren't closed by mistake + tabbedPane.removeMouseListener(this); + } + } + } } From gordonp at dev.open-bio.org Fri Jun 15 20:28:11 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 15 Jun 2007 20:28:11 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706160028.l5G0SBSA029309@dev.open-bio.org> gordonp Fri Jun 15 20:28:11 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services In directory dev.open-bio.org:/tmp/cvs-serv29273/src/main/ca/ucalgary/seahawk/services Modified Files: MobyComplexBuilder.java Log Message: Removed debug message moby-live/Java/src/main/ca/ucalgary/seahawk/services MobyComplexBuilder.java,1.8,1.9 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyComplexBuilder.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyComplexBuilder.java 2007/06/09 22:01:15 1.8 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyComplexBuilder.java 2007/06/16 00:28:11 1.9 @@ -183,7 +183,7 @@ } } } - System.err.println("Namespace of object being returned is " + mobyObj.getPrimaryNamespace().getName()); + return mobyObj; } From gordonp at dev.open-bio.org Fri Jun 15 20:28:58 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 15 Jun 2007 20:28:58 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706160028.l5G0Swas029353@dev.open-bio.org> gordonp Fri Jun 15 20:28:58 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources In directory dev.open-bio.org:/tmp/cvs-serv29317/src/main/ca/ucalgary/seahawk/resources Modified Files: moby2HTML.xsl Log Message: Fixed documentation typos, referred to Bluejay instead of Seahawk moby-live/Java/src/main/ca/ucalgary/seahawk/resources moby2HTML.xsl,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/moby2HTML.xsl,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/moby2HTML.xsl 2006/10/26 01:32:06 1.2 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/moby2HTML.xsl 2007/06/16 00:28:57 1.3 @@ -2,7 +2,7 @@ - + @@ -57,7 +57,7 @@ - + From gordonp at dev.open-bio.org Fri Jun 15 20:29:40 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 15 Jun 2007 20:29:40 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706160029.l5G0TeFc029397@dev.open-bio.org> gordonp Fri Jun 15 20:29:39 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources In directory dev.open-bio.org:/tmp/cvs-serv29361/src/main/ca/ucalgary/seahawk/resources Modified Files: MobyContentGUIHelp.html Log Message: Minor doc updates moby-live/Java/src/main/ca/ucalgary/seahawk/resources MobyContentGUIHelp.html,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/MobyContentGUIHelp.html,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/MobyContentGUIHelp.html 2007/06/08 14:04:27 1.2 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/MobyContentGUIHelp.html 2007/06/16 00:29:39 1.3 @@ -16,6 +16,7 @@
  • How do I control tabs?
  • How do I avoid the secondary input window?
  • How do I save data?
  • +
  • Where do I report bugs?
  • Why is this application called Seahawk?

  • @@ -134,6 +135,11 @@ presentation purposes).

    + +

    Where do I report bugs?

    + Please report any bugs to Paul Gordon, gordonp at ucalgary.ca. Provide as much detail as possible so that the + buggy conditions can be recreated, including any messages from the Java console. +

    Why is this application called Seahawk?

    In the whaling novel Moby Dick, @@ -150,12 +156,5 @@

    An eagle flew thrice round Tarquin's head, removing his cap to replace it, and thereupon Tanaquil, his wife, declared that Tarquin would be king of Rome. But only by the replacing of the cap was that omen accounted good. Ahab's hat was never restored; the wild hawk flew on and on with it; far in advance of the prow: and at last disappeared; while from the point of that disappearance, a minute black spot was dimly discerned, falling from that vast height into the sea.

    -
    -
    -
    Paul Gordon
    - - -Last modified: Tue Jul 25 20:40:36 MDT 2006 - From gordonp at dev.open-bio.org Fri Jun 15 20:30:35 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 15 Jun 2007 20:30:35 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706160030.l5G0UZXH029441@dev.open-bio.org> gordonp Fri Jun 15 20:30:34 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test In directory dev.open-bio.org:/tmp/cvs-serv29405/src/main/ca/ucalgary/seahawk/gui/test Modified Files: SeahawkTestCase.java Log Message: Added tests for user preferences save/load, made hyperlink clicking more robust moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test SeahawkTestCase.java,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test/SeahawkTestCase.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test/SeahawkTestCase.java 2007/04/18 15:59:00 1.7 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test/SeahawkTestCase.java 2007/06/16 00:30:34 1.8 @@ -1,12 +1,7 @@ package ca.ucalgary.seahawk.gui.test; -import ca.ucalgary.seahawk.gui.MobyContentGUI; -import ca.ucalgary.seahawk.gui.MobyContentHelpPane; -import ca.ucalgary.seahawk.gui.MobyContentPane; -import ca.ucalgary.seahawk.gui.MobySaveDialog; -import ca.ucalgary.seahawk.gui.MobySecondaryInputGUI; -import ca.ucalgary.seahawk.gui.MobyServicesGUI; -import ca.ucalgary.seahawk.util.MobyUtils; +import ca.ucalgary.seahawk.gui.*; +import ca.ucalgary.seahawk.util.*; import org.biomoby.shared.MobyDataType; import org.biomoby.shared.data.*; @@ -605,7 +600,11 @@ Robot robot = new Robot(); robot.mouseMove(screenPos.x, screenPos.y+10); - sleep(1000); + sleep(2000); + robot.mouseMove(screenPos.x-10, screenPos.y+10); + sleep(2000); + robot.mouseMove(screenPos.x+10, screenPos.y+10); + sleep(2000); robot.mousePress(InputEvent.BUTTON1_MASK); robot.mouseRelease(InputEvent.BUTTON1_MASK); sleep(2000); @@ -728,6 +727,7 @@ Robot robot = new Robot(); JDialog secondaryParamsDialog = null; + sleep(10000); // wait for dialog to popup, may take a while when meta-data about the service is fetched DialogFinder dfinder = new DialogFinder(".*"); List showingDialogs = dfinder.findAll(); for(int i = 0; i < showingDialogs.size(); i++){ @@ -820,7 +820,7 @@ robot.mouseMove(screenEndPos.x+2, screenEndPos.y+2); robot.mousePress(InputEvent.BUTTON1_MASK); robot.mouseRelease(InputEvent.BUTTON1_MASK); - sleep(2000); + sleep(3000); finder.setName(MobyContentPane.MOBY_SERVICE_POPUP_NAME); Object servicePopup = finder.find(); assertNotNull("Clicking the highlighted region did not open the service options popup (was null)", @@ -862,7 +862,7 @@ showMenuItem((JMenu) serviceTypeChoices, servicePathChosen, robot); servicePathChosen.lastElement().doClick(300); - sleep(2000); + sleep(10000); DialogFinder dfinder = new DialogFinder(".*"); List showingDialogs = dfinder.findAll(); for(int i = 0; i < showingDialogs.size(); i++){ @@ -891,6 +891,50 @@ MobyContentGUI.main(new String[]{}); } + public void testUserPreferences() throws Exception{ + File tempFile = File.createTempFile("test-seahawk", ""); + try{ + java.io.FileOutputStream tempFileOS = new java.io.FileOutputStream(tempFile); + tempFileOS.write("junk".getBytes()); + tempFileOS.close(); + } catch(Exception e){ + e.printStackTrace(); + fail("Could not write to temporary file " + tempFile + ": " + e); + } + boolean failedAsShould = false; + try{ + SeahawkOptions.restoreSettings(tempFile.toURI().toURL()); + } catch(Exception e){ + failedAsShould = true; + } + assertTrue("No exception was thrown, despite a poorly formatted preference file", + failedAsShould); + + SeahawkOptions.setCacheExpiry(10.0); + assertTrue("Setting the cache expiry preference did not work, expected " + + "current value of 10, but found " + SeahawkOptions.getCacheExpiry(), + SeahawkOptions.getCacheExpiry() == 10.0); + try{ + java.io.FileOutputStream tempFileOS = new java.io.FileOutputStream(tempFile); + SeahawkOptions.saveSettings(tempFileOS); + tempFileOS.close(); + } catch(Exception e){ + e.printStackTrace(); + fail("Could not save Seahawk settings to file " + tempFile + ": " + e); + } + SeahawkOptions.setCacheExpiry(20.0); + try{ + SeahawkOptions.restoreSettings(tempFile.toURI().toURL()); + } catch(Exception e){ + e.printStackTrace(); + fail("Could not restore Seahawk settings from file " + tempFile + ": " + e); + } + assertTrue("The settings were not saved/restored properly, " + + "expected cache expiry of 10, but got 20", + SeahawkOptions.getCacheExpiry() == 10.0); + tempFile.delete(); + } + /** * @return a test suite for all the test methods of this test case. */ @@ -908,7 +952,8 @@ suite.addTest(new SeahawkTestCase("testRunAsynchronousService")); //done suite.addTest(new SeahawkTestCase("testRunServiceSecondariesAndSCUFL")); //done suite.addTest(new SeahawkTestCase("testHighlightOptions"));//done - suite.addTest(new SeahawkTestCase("testExternalBrowser"));//doney + suite.addTest(new SeahawkTestCase("testUserPreferences"));//done + suite.addTest(new SeahawkTestCase("testExternalBrowser"));//done return suite; } From gordonp at dev.open-bio.org Fri Jun 15 20:31:33 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 15 Jun 2007 20:31:33 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706160031.l5G0VXSq029485@dev.open-bio.org> gordonp Fri Jun 15 20:31:33 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv29449/src/main/ca/ucalgary/seahawk/gui Modified Files: MobySaveDialog.java Log Message: Fixed suffix-checking logic moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobySaveDialog.java,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobySaveDialog.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobySaveDialog.java 2007/06/08 14:04:27 1.3 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobySaveDialog.java 2007/06/16 00:31:33 1.4 @@ -48,15 +48,18 @@ File f = fileChooser.getSelectedFile(); String filename = f.getName(); javax.swing.filechooser.FileFilter filter = fileChooser.getFileFilter(); - if(filename.indexOf(XML_EXT) == filename.length()-XML_EXT.length()){ + if(filename.indexOf(XML_EXT) != -1 && + filename.indexOf(XML_EXT) == filename.length()-XML_EXT.length()){ // ends in xml suffix exportXML(document, f); } - else if(filename.indexOf(HTML_EXT) == filename.length()-HTML_EXT.length()){ + else if(filename.indexOf(HTML_EXT) != -1 && + filename.indexOf(HTML_EXT) == filename.length()-HTML_EXT.length()){ // ends in html suffix exportHTML(document, f); } - else if(filename.indexOf(SCUFL_EXT) == filename.length()-SCUFL_EXT.length()){ + else if(filename.indexOf(SCUFL_EXT) != -1 && + filename.indexOf(SCUFL_EXT) == filename.length()-SCUFL_EXT.length()){ // ends in html suffix exportSCUFL(document, f); } From gordonp at dev.open-bio.org Fri Jun 15 20:32:56 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 15 Jun 2007 20:32:56 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706160032.l5G0Wu6H029529@dev.open-bio.org> gordonp Fri Jun 15 20:32:56 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv29493/src/main/ca/ucalgary/seahawk/gui Modified Files: SeahawkOptionsGUI.java Log Message: Added division lines to logical separate parts of the pereferences moby-live/Java/src/main/ca/ucalgary/seahawk/gui SeahawkOptionsGUI.java,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/SeahawkOptionsGUI.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/SeahawkOptionsGUI.java 2007/06/09 22:03:44 1.3 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/SeahawkOptionsGUI.java 2007/06/16 00:32:56 1.4 @@ -122,6 +122,7 @@ JSeparator line = new JSeparator(); c.gridwidth = GridBagConstraints.REMAINDER; gridbag.setConstraints(line, c); + add(line); sendReferrerCheckBox = new JCheckBox("Send referrer data to services"); c.gridwidth = GridBagConstraints.REMAINDER; @@ -131,6 +132,7 @@ line = new JSeparator(); c.gridwidth = GridBagConstraints.REMAINDER; gridbag.setConstraints(line, c); + add(line); JPanel expiryPanel = new JPanel(new GridLayout(1,0)); label = new JLabel("Cache expiry (in hours)"); @@ -157,6 +159,7 @@ line = new JSeparator(); c.gridwidth = GridBagConstraints.REMAINDER; gridbag.setConstraints(line, c); + add(line); resetButton = new JButton("Restore program defaults"); resetButton.addActionListener(this); From gordonp at dev.open-bio.org Fri Jun 15 20:44:52 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 15 Jun 2007 20:44:52 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706160044.l5G0iqcS029597@dev.open-bio.org> gordonp Fri Jun 15 20:44:51 EDT 2007 Update of /home/repository/moby/moby-live/Java/xmls In directory dev.open-bio.org:/tmp/cvs-serv29561/xmls Modified Files: seahawkBuild.xml Log Message: Included all of Axis in applet, changed splasher moby-live/Java/xmls seahawkBuild.xml,1.9,1.10 =================================================================== RCS file: /home/repository/moby/moby-live/Java/xmls/seahawkBuild.xml,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- /home/repository/moby/moby-live/Java/xmls/seahawkBuild.xml 2007/06/09 22:06:28 1.9 +++ /home/repository/moby/moby-live/Java/xmls/seahawkBuild.xml 2007/06/16 00:44:51 1.10 @@ -17,8 +17,8 @@ - - + + @@ -75,7 +75,7 @@ - + From gordonp at dev.open-bio.org Sat Jun 16 15:31:59 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Sat, 16 Jun 2007 15:31:59 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706161931.l5GJVx9H032706@dev.open-bio.org> gordonp Sat Jun 16 15:31:58 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/splash In directory dev.open-bio.org:/tmp/cvs-serv32671/src/main/ca/ucalgary/seahawk/gui/splash Log Message: Directory /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/splash added to the repository moby-live/Java/src/main/ca/ucalgary/seahawk/gui/splash - New directory rcsdiff: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/splash/RCS/-,v: No such file or directory rcsdiff: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/splash/RCS/New,v: No such file or directory rcsdiff: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/splash/RCS/directory,v: No such file or directory From gordonp at dev.open-bio.org Sat Jun 16 15:34:36 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Sat, 16 Jun 2007 15:34:36 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706161934.l5GJYaUY000327@dev.open-bio.org> gordonp Sat Jun 16 15:34:36 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv32758/src/main/ca/ucalgary/seahawk/gui Modified Files: MobyContentGUI.java Log Message: Restored system properties for JAXp and JAXT because default transformer on Windows doesn't work properly moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyContentGUI.java,1.11,1.12 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java 2007/06/09 22:16:54 1.11 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java 2007/06/16 19:34:36 1.12 @@ -747,7 +747,12 @@ logger.warn("Cannot process close tab event: tab " + activeTabIndex +" no longer exists"); return; } - tabbedPane.remove(activeTabIndex); + if(tabbedPane.getComponentAt(activeTabIndex) instanceof MobyContentClipboard){ + // Don't close clipboard, if somehow we were asked... + } + else{ + tabbedPane.remove(activeTabIndex); + } } else if(MobyContentClipboard.CLEAR_CLIPBOARD_OPTION.equals(cmd)){ clipboard.clearData(); @@ -908,26 +913,31 @@ java.util.Locale.setDefault(java.util.Locale.ENGLISH); // Unless overridden on the command line, use xerces - //if(System.getProperty("javax.xml.parsers.DocumentBuilderFactory") == null){ - // System.setProperty("javax.xml.parsers.DocumentBuilderFactory", - // "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl"); - //} + if(System.getProperty("javax.xml.parsers.DocumentBuilderFactory") == null){ + System.setProperty("javax.xml.parsers.DocumentBuilderFactory", + "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl"); + } // Unless overridden on the command line, use xalan - //if(System.getProperty("javax.xml.transform.TransformerFactory") == null){ - // System.setProperty("javax.xml.transform.TransformerFactory", - // "org.apache.xalan.processor.TransformerFactoryImpl"); - //} + if(System.getProperty("javax.xml.transform.TransformerFactory") == null){ + System.setProperty("javax.xml.transform.TransformerFactory", + "org.apache.xalan.processor.TransformerFactoryImpl"); + } // Setting this explicitly prevents repeated calls to the META-INF file encoding the same - //if(System.getProperty("org.apache.xerces.xni.parser.XMLParserConfiguration") == null){ - // System.setProperty("org.apache.xerces.xni.parser.XMLParserConfiguration", - // "org.apache.xerces.parsers.StandardParserConfiguration"); - //} + if(System.getProperty("org.apache.xerces.xni.parser.XMLParserConfiguration") == null){ + System.setProperty("org.apache.xerces.xni.parser.XMLParserConfiguration", + "org.apache.xerces.parsers.StandardParserConfiguration"); + } // First, restore any user preferences (uses default settings file location) - SeahawkOptions.restoreSettings(); - + try{ + SeahawkOptions.restoreSettings(); + } catch(Exception e){ + e.printStackTrace(); + System.err.println("Using default settings, could not restore Seahawk settings from file " + + SeahawkOptions.getDefaultsFile()+": "+ e); + } // Asynchronously load up ontology data so it's ready when the user needs it. cacheOntologies(); From gordonp at dev.open-bio.org Sat Jun 16 15:36:58 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Sat, 16 Jun 2007 15:36:58 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706161936.l5GJawX4000383@dev.open-bio.org> gordonp Sat Jun 16 15:36:58 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/splash In directory dev.open-bio.org:/tmp/cvs-serv335/src/main/ca/ucalgary/seahawk/gui/splash Added Files: SeahawkSplasher.java SplashWindow.java Log Message: Moved splash screen classes to own package so applet can load them separately from the rest of the applet (faster startup) moby-live/Java/src/main/ca/ucalgary/seahawk/gui/splash SeahawkSplasher.java,NONE,1.1 SplashWindow.java,NONE,1.1 From gordonp at dev.open-bio.org Sat Jun 16 15:36:58 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Sat, 16 Jun 2007 15:36:58 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706161936.l5GJawFL000369@dev.open-bio.org> gordonp Sat Jun 16 15:36:58 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv335/src/main/ca/ucalgary/seahawk/gui Removed Files: SeahawkSplasher.java SplashWindow.java Log Message: Moved splash screen classes to own package so applet can load them separately from the rest of the applet (faster startup) moby-live/Java/src/main/ca/ucalgary/seahawk/gui SeahawkSplasher.java,1.2,NONE SplashWindow.java,1.3,NONE rcsdiff: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/RCS/SeahawkSplasher.java,v: No such file or directory rcsdiff: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/RCS/SplashWindow.java,v: No such file or directory From gordonp at dev.open-bio.org Mon Jun 18 16:01:12 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 18 Jun 2007 16:01:12 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706182001.l5IK1ClV011806@dev.open-bio.org> gordonp Mon Jun 18 16:01:12 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv11771/src/main/ca/ucalgary/seahawk/gui Modified Files: MobyContentPane.java Log Message: Fixed regression on binary file imports, were treated as text due to preformatting condition in previous revision of this file moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyContentPane.java,1.11,1.12 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java 2007/06/16 00:24:00 1.11 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java 2007/06/18 20:01:12 1.12 @@ -216,6 +216,7 @@ String protocol = url.getProtocol(); URLConnection urlCon = url.openConnection(); + boolean unformatted = false; // It's XML that needs to be transformed to HTML if(urlString.lastIndexOf(".xml") == urlString.length()-4 || "text/xml".equals(urlCon.getContentType())){ @@ -293,6 +294,7 @@ resultBuffer = null; } else{ + unformatted = true; resultBuffer = new StringBuffer("
    "+
     						    body.replaceAll("&", "&").replaceAll("<","<")+
     						    "
    "); @@ -302,7 +304,7 @@ if(resultBuffer == null){ // only happens if the url is already an HTML doc editorPane.setPage(url); } - else if(resultBuffer.length() == 0){ + else if(resultBuffer.length() == 0 || unformatted){ // Attempt to use MobyClient to convert the url's data into a Moby object // (e.g. if the file to load is an image, or a chromatogram) try{ @@ -324,7 +326,11 @@ logger.error("Failure in loading MOBYfied binary data:\n" + e); } // Shouldn't get here unless either not binary, or the binary data load failed - editorPane.setPage(url); + if(resultBuffer.length() == 0){ + editorPane.setPage(url); + } else{ + editorPane.setText(resultBuffer.toString()); + } } else{ editorPane.setText(resultBuffer.toString()); From gordonp at dev.open-bio.org Tue Jun 19 14:05:35 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Tue, 19 Jun 2007 14:05:35 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706191805.l5JI5ZMl015867@dev.open-bio.org> gordonp Tue Jun 19 14:05:35 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data In directory dev.open-bio.org:/tmp/cvs-serv15832/src/main/org/biomoby/shared/data Modified Files: MobyDataObject.java Log Message: Fixed CRIB block to deal with Object tags (not just XRefs) properly moby-live/Java/src/main/org/biomoby/shared/data MobyDataObject.java,1.16,1.17 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObject.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObject.java 2007/06/07 23:58:15 1.16 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObject.java 2007/06/19 18:05:35 1.17 @@ -603,8 +603,11 @@ crib.append(obj.toXML()+"\n"); ((MobyDataXref) obj).setXmlMode(MobyDataXref.CRIB_XML_MODE_OFF); } - else{ + else if(obj instanceof MobyDataObject){ + int oldXMLMode = ((MobyDataObject) obj).getXmlMode(); + ((MobyDataObject) obj).setXmlMode(xmlMode); crib.append(obj.toXML()+"\n"); + ((MobyDataObject) obj).setXmlMode(oldXMLMode); } } crib.append("\n"); From mwilkinson at dev.open-bio.org Tue Jun 19 16:45:31 2007 From: mwilkinson at dev.open-bio.org (Mark Wilkinson) Date: Tue, 19 Jun 2007 16:45:31 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706192045.l5JKjV1e016460@dev.open-bio.org> mwilkinson Tue Jun 19 16:45:31 EDT 2007 Update of /home/repository/moby/moby-live/Perl/MOBY In directory dev.open-bio.org:/tmp/cvs-serv16441/MOBY Modified Files: CommonSubs.pm Log Message: missing namespace declaration on queryID; couldn't retrieve query ID in some cases moby-live/Perl/MOBY CommonSubs.pm,1.98,1.99 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/CommonSubs.pm,v retrieving revision 1.98 retrieving revision 1.99 diff -u -r1.98 -r1.99 --- /home/repository/moby/moby-live/Perl/MOBY/CommonSubs.pm 2007/05/25 13:57:23 1.98 +++ /home/repository/moby/moby-live/Perl/MOBY/CommonSubs.pm 2007/06/19 20:45:31 1.99 @@ -432,6 +432,7 @@ my $moby = _string_to_DOM($XML); return '' unless ( $moby->nodeName =~ /^(moby:|)mobyData$/ ); my $qid = _moby_getAttribute($moby, 'queryID' ); + $qid ||= _moby_getAttribute($moby, 'moby:queryID' ); return defined( $qid ) ? $qid : ''; } @@ -1618,6 +1619,7 @@ my $moby = _string_to_DOM($XML); return '' unless ( $moby->nodeName =~ /^(moby:|)queryInput|mobyData$/ ); my $qid = _moby_getAttribute($moby, 'queryID' ); + $qid ||= _moby_getAttribute($moby, 'moby:queryID' ); return defined( $qid ) ? $qid : ''; } From mwilkinson at dev.open-bio.org Tue Jun 19 16:49:39 2007 From: mwilkinson at dev.open-bio.org (Mark Wilkinson) Date: Tue, 19 Jun 2007 16:49:39 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706192049.l5JKnd4T016512@dev.open-bio.org> mwilkinson Tue Jun 19 16:49:39 EDT 2007 Update of /home/repository/moby/moby-live/Perl/t In directory dev.open-bio.org:/tmp/cvs-serv16493/t Modified Files: CommonSubs.t Log Message: adding a test for the moby: namespace into the commonsubs test harness moby-live/Perl/t CommonSubs.t,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/CommonSubs.t,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Perl/t/CommonSubs.t 2007/02/09 00:19:01 1.7 +++ /home/repository/moby/moby-live/Perl/t/CommonSubs.t 2007/06/19 20:49:39 1.8 @@ -145,7 +145,7 @@ - + @@ -159,7 +159,7 @@ @ids = keys %{$responses}; ok (scalar(@ids) == 2) or die "serviceResponseParser didn't find right number of invocation messages when two were passed\n"; ok ($ids[0] eq "first") or die "serviceResponseParser didn't find the first query id\n"; -ok ($ids[1] eq "second") or die "serviceResponseParser didn't find the second query id\n"; +ok ($ids[1] eq "second") or die "serviceResponseParser didn't find the second query id that included a moby: namespace\n"; my $sequence = "TAGCTGATCGAGCTGATGCTGA"; From mwilkinson at dev.open-bio.org Tue Jun 19 17:02:13 2007 From: mwilkinson at dev.open-bio.org (Mark Wilkinson) Date: Tue, 19 Jun 2007 17:02:13 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706192102.l5JL2Dc5016566@dev.open-bio.org> mwilkinson Tue Jun 19 17:02:13 EDT 2007 Update of /home/repository/moby/moby-live/Perl/MOBY In directory dev.open-bio.org:/tmp/cvs-serv16547/MOBY Modified Files: CommonSubs.pm Log Message: being a little more forgiving as to what is sent into the getCrossReferences routine. you can either send XML or you can send the MOBY::Client::Simple object. moby-live/Perl/MOBY CommonSubs.pm,1.99,1.100 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/CommonSubs.pm,v retrieving revision 1.99 retrieving revision 1.100 diff -u -r1.99 -r1.100 --- /home/repository/moby/moby-live/Perl/MOBY/CommonSubs.pm 2007/06/19 20:45:31 1.99 +++ /home/repository/moby/moby-live/Perl/MOBY/CommonSubs.pm 2007/06/19 21:02:13 1.100 @@ -949,6 +949,7 @@ sub getCrossReferences { my ( $XML ) = @_; + if ($XML =~ /MOBY::Client/){$XML = $XML->XML} $XML = _string_to_DOM($XML); my @xrefs; my @XREFS; From mwilkinson at dev.open-bio.org Tue Jun 19 17:10:52 2007 From: mwilkinson at dev.open-bio.org (Mark Wilkinson) Date: Tue, 19 Jun 2007 17:10:52 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706192110.l5JLAqqT016618@dev.open-bio.org> mwilkinson Tue Jun 19 17:10:52 EDT 2007 Update of /home/repository/moby/moby-live/Perl/MOBY In directory dev.open-bio.org:/tmp/cvs-serv16599/MOBY Modified Files: CommonSubs.pm Log Message: being a little more forgiving as to what is sent into the getCrossReferences routine. you can either send XML or you can send the MOBY::Client::Simple object. moby-live/Perl/MOBY CommonSubs.pm,1.100,1.101 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/CommonSubs.pm,v retrieving revision 1.100 retrieving revision 1.101 diff -u -r1.100 -r1.101 --- /home/repository/moby/moby-live/Perl/MOBY/CommonSubs.pm 2007/06/19 21:02:13 1.100 +++ /home/repository/moby/moby-live/Perl/MOBY/CommonSubs.pm 2007/06/19 21:10:52 1.101 @@ -949,7 +949,7 @@ sub getCrossReferences { my ( $XML ) = @_; - if ($XML =~ /MOBY::Client/){$XML = $XML->XML} + if ($XML =~ /MOBY::Client/){$XML = $XML->XML_DOM} $XML = _string_to_DOM($XML); my @xrefs; my @XREFS; From gordonp at dev.open-bio.org Thu Jun 21 14:33:44 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 21 Jun 2007 14:33:44 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706211833.l5LIXiBP032752@dev.open-bio.org> gordonp Thu Jun 21 14:33:43 EDT 2007 Update of /home/repository/moby/moby-live/Java/docs In directory dev.open-bio.org:/tmp/cvs-serv32716/docs Modified Files: Seahawk.html Log Message: Moved Seahawk jar file location, adjusted the docs according moby-live/Java/docs Seahawk.html,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Java/docs/Seahawk.html,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Java/docs/Seahawk.html 2007/03/27 14:01:36 1.6 +++ /home/repository/moby/moby-live/Java/docs/Seahawk.html 2007/06/21 18:33:43 1.7 @@ -69,7 +69,7 @@

    The jar (Java archive) file containing all of the required classes (including those from Axis, Jena, Xalan, Xerces, etc.) is available - here, and is + here, and is signed by the University of Calgary Bioinformatics Lab. You can also build your own version of the jar with the jMOBY CVS Ant target "seahawk-jar". Either jar file can be used as an application with the command: From mwilkinson at dev.open-bio.org Thu Jun 21 18:12:52 2007 From: mwilkinson at dev.open-bio.org (Mark Wilkinson) Date: Thu, 21 Jun 2007 18:12:52 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706212212.l5LMCqol000894@dev.open-bio.org> mwilkinson Thu Jun 21 18:12:52 EDT 2007 Update of /home/repository/moby/moby-live/Docs/ProjectDocs In directory dev.open-bio.org:/tmp/cvs-serv875/Docs/ProjectDocs Modified Files: index.html Log Message: added the test registry connection detals to the list of registries moby-live/Docs/ProjectDocs index.html,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Docs/ProjectDocs/index.html,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Docs/ProjectDocs/index.html 2007/01/22 21:19:34 1.7 +++ /home/repository/moby/moby-live/Docs/ProjectDocs/index.html 2007/06/21 22:12:52 1.8 @@ -1,43 +1,51 @@ -

    MOBY Project General Documentation

    - -
    -
    jMoby documentation - -
    jMoby contains libraries for Java developers, and it -also contains ready-to-use clients for any Biomoby users, allowing -access to Biomoby registries and to Biomoby services) - -
    -

    - -

    Language Specific Documents

    -

    -
     

    - -

    FAQ's

    -


    - -

    Catalogue of Registries

    - - - - - - - - - - - - - - - - -
    LocationEndpointPublic?DescriptionPolicy
    iCAPTURE CentreEndpoint: http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/mobycentral.pl -
    URI: http://mobycentral.icapture.ubc.ca/MOBY/Central
    YESA curated public registry hosted at the iCAPTURE Centre, VancouverPolicy
    IRRI PhilippinesEndpoint: http://cropwiki.irri.org/cgi-bin/MOBY-Central.pl
    - URI: http://cropwiki.irri.org/MOBY/Central
    YESThe MOBY registry at the International Rice Research Institute -(IRRI) is intended mostly for Generation Challenge Program (GCP) -developers. It allows the registration of experimental moby entities -within GCP.Policy
    - +

    MOBY Project General Documentation

    + +
    +
    jMoby documentation + +
    jMoby contains libraries for Java developers, and it +also contains ready-to-use clients for any Biomoby users, allowing +access to Biomoby registries and to Biomoby services) + +
    +

    + +

    Language Specific Documents

    +

    +
     

    + +

    FAQ's

    +


    + +

    Catalogue of Registries

    + + + + + + + + + + + + + + + + + + + +
    LocationEndpointPublic?DescriptionPolicy
    iCAPTURE CentreEndpoint: http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/mobycentral.pl +
    URI: http://mobycentral.icapture.ubc.ca/MOBY/Central
    YESA curated public registry hosted at the iCAPTURE Centre, VancouverPolicy
    Open TEST registryEndpoint: http://bioinfo.icapture.ubc.ca/cgi-bin/mobycentral/MOBY-Central.pl +
    OntologyServer: http://bioinfo.icapture.ubc.ca/cgi-bin/mobycentral/OntologyServer.cgi +
    URI: http://bioinfo.icapture.ubc.ca/MOBY/Central
    YESA full-featured +registry for testing your code or pre-registering a service or whatever you wish. The codebase is generally kept up-to-date +relative to the "real" registry, but the ontologies are not, so ontology nodes that you need might not be there and you will have +to register them.For testing purposes only. No guarantee of stability of any kind.
    IRRI PhilippinesEndpoint: http://cropwiki.irri.org/cgi-bin/MOBY-Central.pl
    + URI: http://cropwiki.irri.org/MOBY/Central
    YESThe MOBY registry at the International Rice Research Institute +(IRRI) is intended mostly for Generation Challenge Program (GCP) +developers. It allows the registration of experimental moby entities +within GCP.Policy
    + From gordonp at dev.open-bio.org Tue Jun 26 17:22:25 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Tue, 26 Jun 2007 17:22:25 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706262122.l5QLMP6F023831@dev.open-bio.org> gordonp Tue Jun 26 17:22:24 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data In directory dev.open-bio.org:/tmp/cvs-serv23796/src/main/org/biomoby/shared/data Modified Files: MobyDataUtils.java Log Message: Added carriage return to serialized XML envelope, to avoid potential I/O buffering issues moby-live/Java/src/main/org/biomoby/shared/data MobyDataUtils.java,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataUtils.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataUtils.java 2007/06/07 23:58:15 1.7 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataUtils.java 2007/06/26 21:22:24 1.8 @@ -31,7 +31,7 @@ os.write("\n".getBytes()); os.write(("\n").getBytes()); os.write(mci.toXML().getBytes()); - os.write("\n".getBytes()); + os.write("\n\n".getBytes()); return true; } @@ -52,7 +52,7 @@ writer.write("\n"); writer.write(("\n")); writer.write(mci.toXML()); - writer.write("\n"); + writer.write("\n\n"); return true; } From gordonp at dev.open-bio.org Tue Jun 26 17:24:14 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Tue, 26 Jun 2007 17:24:14 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706262124.l5QLOECx023874@dev.open-bio.org> gordonp Tue Jun 26 17:24:14 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared In directory dev.open-bio.org:/tmp/cvs-serv23839/src/main/org/biomoby/shared Modified Files: PrimitiveTypes.java Log Message: Added Boolean to list of primitive types (was incorrectly missing), also added convenience method to check a data type name against the list moby-live/Java/src/main/org/biomoby/shared PrimitiveTypes.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/PrimitiveTypes.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/PrimitiveTypes.java 2005/07/22 05:30:38 1.1 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/PrimitiveTypes.java 2007/06/26 21:24:14 1.2 @@ -11,8 +11,17 @@ *

    email me at edward.kawas at gmail.com */ public class PrimitiveTypes { - public static final String[] PRIMS = {"Object", "String", "Integer", "Float", "DateTime"}; + public static final String[] PRIMS = {"Object", "String", "Integer", "Float", "Boolean", "DateTime"}; + public static boolean isPrimitive(String dataType){ + for(String primitive: PRIMS){ + if(primitive.equals(dataType)){ + return true; + } + } + return false; + } + public final Object clone() throws java.lang.CloneNotSupportedException { return super.clone(); } From gordonp at dev.open-bio.org Tue Jun 26 17:25:04 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Tue, 26 Jun 2007 17:25:04 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706262125.l5QLP4L8023917@dev.open-bio.org> gordonp Tue Jun 26 17:25:04 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data In directory dev.open-bio.org:/tmp/cvs-serv23882/src/main/org/biomoby/shared/data Modified Files: MobyDataObjectVector.java Log Message: Added properly service-mode serialization moby-live/Java/src/main/org/biomoby/shared/data MobyDataObjectVector.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectVector.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectVector.java 2007/02/08 16:59:58 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectVector.java 2007/06/26 21:25:04 1.3 @@ -38,7 +38,19 @@ StringBuffer concatXML = new StringBuffer(); Iterator iter = members.iterator(); while(iter.hasNext()){ - concatXML.append(iter.next().toXML()); + MobyDataObject mdsi = iter.next(); + if(!getName().equals(mdsi.getName())){ + mdsi.setName(getName()); + } + + int oldXmlMode = mdsi.getXmlMode(); + if(oldXmlMode != xmlMode){ + mdsi.setXmlMode(xmlMode); + } + concatXML.append(mdsi.toXML()+"\n"); + if(oldXmlMode != xmlMode){ + mdsi.setXmlMode(oldXmlMode); + } } return concatXML.toString(); } From kawas at dev.open-bio.org Wed Jun 27 11:46:34 2007 From: kawas at dev.open-bio.org (Eddie Kawas) Date: Wed, 27 Jun 2007 11:46:34 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706271546.l5RFkYVD029879@dev.open-bio.org> kawas Wed Jun 27 11:46:34 EDT 2007 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory dev.open-bio.org:/tmp/cvs-serv29844/Client Modified Files: ServiceInstance.pm Log Message: added signatureURL to the list of fields. moby-live/Perl/MOBY/Client ServiceInstance.pm,1.19,1.20 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/ServiceInstance.pm,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- /home/repository/moby/moby-live/Perl/MOBY/Client/ServiceInstance.pm 2007/02/08 18:50:24 1.19 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/ServiceInstance.pm 2007/06/27 15:46:34 1.20 @@ -212,6 +212,7 @@ my %_attr_data = # DEFAULT ACCESSIBILITY ( authority => [ undef, 'read/write' ], + signatureURL => [ undef, 'read/write' ], name => [ undef, 'read/write' ], type => [ undef, 'read/write' ], input => [ undef, 'read/write' ] From kawas at dev.open-bio.org Wed Jun 27 11:47:33 2007 From: kawas at dev.open-bio.org (Eddie Kawas) Date: Wed, 27 Jun 2007 11:47:33 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706271547.l5RFlX1P029955@dev.open-bio.org> kawas Wed Jun 27 11:47:33 EDT 2007 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory dev.open-bio.org:/tmp/cvs-serv29920/Client Modified Files: Central.pm Log Message: added signatureURL to the instance of MOBY::CLient::SecondaryInstance that is returned via find service. moby-live/Perl/MOBY/Client Central.pm,1.147,1.148 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v retrieving revision 1.147 retrieving revision 1.148 diff -u -r1.147 -r1.148 --- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2007/02/09 21:46:34 1.147 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2007/06/27 15:47:33 1.148 @@ -1924,6 +1924,7 @@ $lsid = ""; } my $Type = &_nodeTextContent( $Service, 'serviceType' ); + my $signatureURL = &_nodeTextContent( $Service, 'signatureURL' ); my $authoritative = &_nodeTextContent( $Service, 'authoritative' ); my $contactEmail = &_nodeTextContent( $Service, 'contactEmail' ); my $URL = &_nodeTextContent( $Service, 'URL' ); @@ -1996,6 +1997,7 @@ secondary => \@SECONDARIES, description => $Description, registry => $Registry, + signatureURL => $signatureURL, XML => $Service->toString, ); push @Services, $Instance; From kawas at dev.open-bio.org Wed Jun 27 11:50:00 2007 From: kawas at dev.open-bio.org (Eddie Kawas) Date: Wed, 27 Jun 2007 11:50:00 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706271550.l5RFo0Sp029998@dev.open-bio.org> kawas Wed Jun 27 11:50:00 EDT 2007 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory dev.open-bio.org:/tmp/cvs-serv29963/Client Modified Files: ServiceInstance.pm Log Message: some doc would be nice i guess ... moby-live/Perl/MOBY/Client ServiceInstance.pm,1.20,1.21 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/ServiceInstance.pm,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- /home/repository/moby/moby-live/Perl/MOBY/Client/ServiceInstance.pm 2007/06/27 15:46:34 1.20 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/ServiceInstance.pm 2007/06/27 15:50:00 1.21 @@ -186,7 +186,7 @@ =head2 LSID - Title : contactEmail + Title : LSID Usage : $email = $Service->LSID() Args : none Function : get (readonly) service instance LSID @@ -194,6 +194,16 @@ =cut +=head2 signatureURL + + Title : signatureURL + Usage : $email = $Service->signatureURL() + Args : (optional) string representing a URL + Function : get/set the location of the RDF document that describes this service + Returns : current value as scalar string + +=cut + =head2 registry Title : registry From kawas at dev.open-bio.org Wed Jun 27 11:50:27 2007 From: kawas at dev.open-bio.org (Eddie Kawas) Date: Wed, 27 Jun 2007 11:50:27 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706271550.l5RFoRtf030038@dev.open-bio.org> kawas Wed Jun 27 11:50:27 EDT 2007 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory dev.open-bio.org:/tmp/cvs-serv30003/Client Modified Files: ServiceInstance.pm Log Message: moby-live/Perl/MOBY/Client ServiceInstance.pm,1.21,1.22 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/ServiceInstance.pm,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- /home/repository/moby/moby-live/Perl/MOBY/Client/ServiceInstance.pm 2007/06/27 15:50:00 1.21 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/ServiceInstance.pm 2007/06/27 15:50:27 1.22 @@ -187,7 +187,7 @@ =head2 LSID Title : LSID - Usage : $email = $Service->LSID() + Usage : $lsid = $Service->LSID() Args : none Function : get (readonly) service instance LSID Returns : current value as scalar string @@ -197,7 +197,7 @@ =head2 signatureURL Title : signatureURL - Usage : $email = $Service->signatureURL() + Usage : $sig = $Service->signatureURL() Args : (optional) string representing a URL Function : get/set the location of the RDF document that describes this service Returns : current value as scalar string From gordonp at dev.open-bio.org Thu Jun 28 12:45:45 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 28 Jun 2007 12:45:45 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706281645.l5SGjjLj004527@dev.open-bio.org> gordonp Thu Jun 28 12:45:44 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services In directory dev.open-bio.org:/tmp/cvs-serv4488/src/main/ca/ucalgary/seahawk/services Modified Files: MobyClient.java MobyComplexBuilder.java Added Files: IterativeMatchResult.java RegexParser.java Log Message: Major changes to Seahawk 'services' package to make MOB rule parsing much more powerful moby-live/Java/src/main/ca/ucalgary/seahawk/services IterativeMatchResult.java,NONE,1.1 RegexParser.java,NONE,1.1 MobyClient.java,1.14,1.15 MobyComplexBuilder.java,1.9,1.10 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java 2007/06/08 20:30:21 1.14 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java 2007/06/28 16:45:44 1.15 @@ -37,6 +37,7 @@ public static final String DATA_MAPPING_XML_RESOURCE = "ca/ucalgary/seahawk/resources/mobyBuilderRules.xml"; public static final String RESOURCE_SYSTEM_PROPERTY = "seahawk.rules"; public static final String RULE_SET_TAG = "object"; + public static final String RULE_NAME_ATTR = "name"; public static final String PREFIX_TAG = "prefix"; public static final String PREFIX_ATTR = "value"; public static final String ARTICLENAME_RULE_TAG = "articlename"; @@ -47,6 +48,8 @@ public static final String DATATYPE_RULE_ATTR = "value"; public static final String MEMBER_RULE_TAG = "member"; public static final String MEMBER_RULE_ATTR = "value"; + public static final String MEMBERS_RULE_TAG = "inheritMembers"; + public static final String MEMBERS_RULE_ATTR = "rule"; public static final String URL_REGEX_TAG = "url_regex"; public static final String REGEX_TAG = "regex"; public static final String XPATH_TAG = "xpath"; @@ -55,6 +58,7 @@ public static final String WHITESPACE_ATTR_NORMALIZE_VAL = "normalize"; public static final String WHITESPACE_ATTR_STRIP_FLANKING_VAL = "flanking"; public static final String WHITESPACE_ATTR_KEEP_VAL = "keep"; + public static final String DATATYPE_ATTR = "datatype"; public static final String ENCODING_ATTR = "encoding"; public static final String ENCODING_ATTR_BASE64_VAL = "Base64"; public static final String ENCODING_ATTR_NONE_VAL = "none"; @@ -67,6 +71,8 @@ private HashMap xpathMap; private HashMap urlRegexMap; private Map regexMap; + private Map builderNameMap; + private Map patternNameMap; private URL dataMappingXMLURL; private DocumentBuilder docBuilder; private static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(MobyClient.class); @@ -88,6 +94,8 @@ xpathMap = new HashMap(); urlRegexMap = new HashMap(); regexMap = new HashMap(); + builderNameMap = new HashMap(); + patternNameMap = new HashMap(); nsContext = new NamespaceContextImpl(); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); @@ -201,6 +209,8 @@ continue; } + String ruleName = ruleSet.getAttribute(RULE_NAME_ATTR); + Vector regexStrings = new Vector(); Vector urlRegexStrings = new Vector(); Vector xpathStrings = new Vector(); @@ -250,7 +260,7 @@ dataTypeString = getDataType(ruleMember); } else if(isMemberRule(ruleMember)){ - addMemberMapping(ruleMember, memberMap); + addMemberMapping(ruleMember, memberMap, dataTypeString); } // TODO add other production rules else{ @@ -279,7 +289,7 @@ addXPathMapping((String) xpathStrings.elementAt(j), namespaceMap, articleNameString); } for(int j = 0; j < regexStrings.size(); j++){ - addRegexMapping((String) regexStrings.elementAt(j), namespaceMap, articleNameString); + addRegexMapping((String) regexStrings.elementAt(j), namespaceMap, articleNameString, ruleName); } for(int j = 0; j < urlRegexStrings.size(); j++){ addURLRegexMapping((String) urlRegexStrings.elementAt(j), namespaceMap, articleNameString); @@ -296,7 +306,7 @@ addXPathMapping((String) xpathStrings.elementAt(j), namespaceMap, dataTypeString, memberMap, articleNameString); } for(int j = 0; j < regexStrings.size(); j++){ - addRegexMapping((String) regexStrings.elementAt(j), namespaceMap, dataTypeString, memberMap, articleNameString); + addRegexMapping((String) regexStrings.elementAt(j), namespaceMap, dataTypeString, memberMap, articleNameString, ruleName); } for(int j = 0; j < urlRegexStrings.size(); j++){ addURLRegexMapping((String) urlRegexStrings.elementAt(j), namespaceMap, dataTypeString, memberMap, articleNameString); @@ -330,8 +340,15 @@ return e != null && ARTICLENAME_RULE_TAG.equals(e.getLocalName()); } + // Defined or inherited rule spec. public boolean isMemberRule(Element e){ - return e != null && MEMBER_RULE_TAG.equals(e.getLocalName()); + return e != null && (MEMBER_RULE_TAG.equals(e.getLocalName()) || + MEMBERS_RULE_TAG.equals(e.getLocalName())); + } + + // Inherited rule spec. + public boolean isMembersRule(Element e){ + return e != null && MEMBERS_RULE_TAG.equals(e.getLocalName()); } public boolean isNamespaceRule(Element e){ @@ -402,19 +419,58 @@ return str; } - protected void addMemberMapping(Element memTag, Map membersMap) throws Exception{ + protected void addMemberMapping(Element memTag, Map membersMap, String dataTypeName) + throws Exception{ if(!isMemberRule(memTag)){ throw new Exception("Element provided to addMemberMapping (" + (memTag == null ? null : memTag.getLocalName()) + ") was not a member rule element"); } - + String ruleValue = memTag.getTextContent(); String memberNameKey = memTag.getAttribute(DATATYPE_RULE_ATTR); + if(ruleValue == null || ruleValue.length() == 0){ + System.err.println("Object member " + memberNameKey + " has a blank value rule"); + } + + String memberDataTypeSetting = memTag.getAttribute(DATATYPE_ATTR); + if(isMembersRule(memTag)){ + String membersRuleName = memTag.getAttribute(MEMBERS_RULE_ATTR); + if(membersRuleName == null || membersRuleName.length() == 0){ + throw new Exception("Attribute "+MEMBERS_RULE_ATTR+" is missing from the " + + "member rule tag '" + memTag.getNodeName()+"'"); + } + MobyComplexBuilder membersBuilder = builderNameMap.get(membersRuleName); + if(membersBuilder == null){ + throw new Exception("Attribute "+MEMBERS_RULE_ATTR+" refers to a rule (" + + membersRuleName+") that does not exist"); + } + MobyDataType dataType = MobyDataType.getDataType(dataTypeName); + if(!dataType.inheritsFrom(membersBuilder.getDataType())){ + throw new Exception("Data type produced by inherited rule (" + membersRuleName + + ") is not a subtype of the current rule (" + dataType.getName() + ")"); + } + // Borrow members from the builder, unless they already exist in the + // production rule (i.e. "member" rules override "inheritMembers" rules), + // BUT, we need to tell the builder that the regex to match is not + // the one from the current rule, but the one from the inherited rule + // (applied to the value created by ruleValue) + // the stering array for the inheritance rule looks like ["ruleName1", "ruleSrcValueExpr1"] + if(membersMap.containsKey(MobyComplexBuilder.INHERITED_MEMBERS_SENTINEL)){ + throw new Exception("More than one member inheritance tag was given, which is illegal"); + } + String[] inheritanceRuleSpecs = new String[2]; + inheritanceRuleSpecs[0] = membersRuleName; + inheritanceRuleSpecs[1] = ruleValue; + membersMap.put(MobyComplexBuilder.INHERITED_MEMBERS_SENTINEL, inheritanceRuleSpecs); + return; + } + if(memberNameKey == null || memberNameKey.length() == 0){ throw new Exception("Element provided to addMemberMapping did not " + "have a non-blank " + DATATYPE_RULE_ATTR + " attribute as required"); } + String memberWhitespaceSetting = memTag.getAttribute(WHITESPACE_ATTR); if(memberWhitespaceSetting == null || memberWhitespaceSetting.length() == 0){ memberWhitespaceSetting = WHITESPACE_ATTR_KEEP_VAL; // default is to keep whitespace @@ -429,6 +485,7 @@ "), overriding with default of " + WHITESPACE_ATTR_KEEP_VAL); memberWhitespaceSetting = WHITESPACE_ATTR_KEEP_VAL; } + String memberEncodingSetting = memTag.getAttribute(ENCODING_ATTR); if(memberEncodingSetting == null || memberEncodingSetting.length() == 0){ memberEncodingSetting = ENCODING_ATTR_NONE_VAL; // default is to not encode @@ -446,13 +503,16 @@ return; } - String ruleValue = memTag.getTextContent(); - if(ruleValue == null || ruleValue.length() == 0){ - System.err.println("Object member " + memberNameKey + " has a blank value rule"); - } - membersMap.put(memberNameKey, new String[]{ruleValue, + // Leave memberRuleName blank unless we inherited members via + // a rule attrubute. If memberRuleName is null, + // in another method we will see if any capture value in the member + // rule refers to a \p{ruleName} string in the regex + String memberRuleName = memTag.getAttribute(MEMBERS_RULE_ATTR); + membersMap.put(memberNameKey, new String[]{ruleValue, + memberDataTypeSetting, memberWhitespaceSetting, - memberEncodingSetting}); + memberEncodingSetting, + memberRuleName}); } protected void addNamespaceMapping(Element nsTag, Map namespaceStrings) throws Exception{ @@ -1016,7 +1076,7 @@ for(int i = 0; i < mobyObj.length; i++){ nsRules.put(mobyObj[i], "$0"); } - addRegexMapping(regexp, nsRules, articleName); + addRegexMapping(regexp, nsRules, articleName, (String) null); } public void addURLRegexMapping(String url_regexp, String[] mobyObj, String articleName){ //mobyObj<--mobyNamespaces @@ -1035,11 +1095,58 @@ /** * Converts seahawk-specific regex syntax into generic Java syntax (e.g \N becomes a - * match for any IUPAC DNA character, \P any amino acid) + * match for any IUPAC DNA character, \P any amino acid). We pass in the member map so that + * this method can populate the last field of rules that inherit complex members (by virtue + * of using the capture group whose values is derived from \p{ruleName}), with ruleName */ - protected String processRegExp(String regex){ - return regex.replaceAll("\\\\N", "[acgtunxACGTUNX]") - .replaceAll("\\\\P", "[ARNDCQEGHILKMFPSTWYVBZXarndcqeghilkmfpstwyvbz*]"); + protected String processRegExp(String regex, Map membersMap) throws Exception{ + String returnValue = regex.replaceAll("\\\\N", "[acgtunxACGTUNX]") + .replaceAll("\\\\P", "[ARNDCQEGHILKMFPSTWYVBZXarndcqeghilkmfpstwyvbz*]"); + + // Now see if there are any references to other patterns (by rule name) + // with the \p{} syntax specific to Seahawk + Pattern charClassPattern = Pattern.compile("\\\\p\\{([A-Za-z0-9]+)\\}"); + Matcher charClassMatcher = charClassPattern.matcher(returnValue); + Map capGroup2RuleReference = new HashMap(); + while(charClassMatcher.find()){ + String reference = charClassMatcher.group(1); + if(RegexParser.isPosixCharacterClass(reference)){ + continue; + } + + if(!patternNameMap.containsKey(reference)){ + throw new Exception("\\p{"+reference+"} in regex does not refer " + + "to a known Seahawk rule, cannot build the regex"); + } + + int capGroup = RegexParser.locationToCaptureGroupNumber(regex, charClassMatcher.start(1)); + if(capGroup > 0){ // sanity check + capGroup2RuleReference.put(capGroup, reference); + } + + // Replace ref with regex, elinating any nested capture groups, for efficiency + // (otherwise we'd need to shift all the $# refs in the rules map to compensate) + returnValue = returnValue.replaceFirst("\\\\p\\{"+reference+"\\}", + patternNameMap.get(reference).pattern().replaceAll("\\\\", "\\\\\\\\").replaceAll("\\((?!\\?)", "(?:")); + } + + if(!capGroup2RuleReference.isEmpty()){ + // Update any member rule that uses one of the capture values referring to a + // \p{ruleName} reference + for(String[] rule: membersMap.values()){ + for(Integer capGroupNum: capGroup2RuleReference.keySet()){ + if(rule[0].matches("^\\s*\\$"+capGroupNum+"\\s*$")){ + // This is where the rule actually gets the subrule reference update, + // UNLESS it was already specified (probably by a inheritsMembers tag) + if(rule[4] == null || rule[4].length() == 0){ + rule[4] = capGroup2RuleReference.get(capGroupNum); + } + break; + } + } + } + } + return returnValue; } /** @@ -1060,13 +1167,13 @@ return url_regex_flexible; } - protected void addRegexMapping(String regexp, Map nsRules, String articleName){ //nsRules = Map + protected void addRegexMapping(String regexp, Map nsRules, String articleName, String ruleName){ //nsRules = Map if(nsRules == null || nsRules.size() == 0){ System.err.println("Ignoring empty namespace-only regex rule mappings"); return; } - addRegexMapping(regexp, nsRules, (String) null, (Map) null, articleName); + addRegexMapping(regexp, nsRules, (String) null, (Map) null, articleName, null); } protected void addURLRegexMapping(String url_regexp, Map url_nsRules, String articleName){ //nsRules = Map @@ -1080,29 +1187,128 @@ public void addRegexMapping(String regexp, Map nsRules, String mobyDataType, Map membersMap){ - addRegexMapping(regexp, nsRules, mobyDataType, membersMap, null); + addRegexMapping(regexp, nsRules, mobyDataType, membersMap, null, null); } - public void addRegexMapping(String regexp, Map nsRules, String mobyDataType, Map membersMap, String articleName){ + /** + * This method looks for HAS members in a rule, and if they exist creates new + * capture groups around the accessed capture groups so that they can be further + * processed in MobyComplexBuilder (e.g. (\d)+ become ((\d+)) so we can deconstruct + * that part of the regex as capture *each* \d for the HAS (0 or more) member relationship. + * We also need to modify all of the rules that access capture groups to bump up their + * numbers due to the added capture groups here (transparent to the user). + * + * membersMap, nsRules, and articleName get their capture group references modified accordingly, + * and the new regex is returned with its extract capture groups. + */ + private String handleHASMembers(String regexp, Map nsRules, String mobyDataType, + Map membersMap, StringBuffer articleName) throws Exception{ + if(mobyDataType == null){ + //System.err.println("Got null data type for regex "+regexp); + return regexp; //must be a base object + } + MobyDataType dataType = MobyDataType.getDataType(mobyDataType, SeahawkOptions.getRegistry()); + if(dataType == null){ + throw new Exception("Cannot find definition of data type "+mobyDataType+ + " in the ontology, therefore the rule cannot be properly parsed"); + } + MobyRelationship[] memberRelationships = dataType.getChildren(); + + String newRegexp = processRegExp(regexp, membersMap); + Map captured = new HashMap(); + for(MobyRelationship memberRelationship: memberRelationships){ + if(memberRelationship.getRelationshipType() == Central.iHAS){ + String[] rule = membersMap.get(memberRelationship.getName()); + if(rule == null){ + System.err.println("Skipping HAS member "+memberRelationship.getName() + + " without a rule"); + continue; + } + Pattern pattern = Pattern.compile(newRegexp, Pattern.DOTALL | Pattern.COMMENTS); + int groupCount = RegexParser.groupCount(pattern); + for(int i = 0; i < groupCount; i++){ + if(captured.containsKey(i)){ //autoboxed int + // Already encapsulated the capture group due to another + // HAS member, don't need to add anything + System.err.println("Skipping processing of capture group "+i+ + ", it's already been processed by another member in this rule"); + continue; + } + if(rule[0].matches("^.*\\$"+i+"(?=\\D.*|\\z)")){ + //System.err.println("Substituting "+i+" with encapsulating capture group, " + + // "due to HAS condition of member "+memberRelationship.getName() + + // " with rule " + rule[0]); + + // Now actually update the regex with the new cap group + // including any quantity modifier associated with it. + boolean INCL_QUANTIFIER = true; + int capGroupRange[] = RegexParser.getCaptureGroupRange(pattern, i, INCL_QUANTIFIER); + newRegexp = newRegexp.substring(0, capGroupRange[0])+"("+ + newRegexp.substring(capGroupRange[0], capGroupRange[1]+1) + ")" + + (capGroupRange[1]+1 < newRegexp.length() ? newRegexp.substring(capGroupRange[1]+1) : ""); + // Bump up all the capture group reference higher than this one, in all rules + for(int j = i; j < groupCount; j++){ + for(String memberName: membersMap.keySet()){ + String[] memberRule = membersMap.get(memberName); + memberRule[0] = memberRule[0].replaceAll("\\$"+i+"(?=\\D.*|\\z)", "\\$"+(i+1)); + } + for(String nsName: nsRules.keySet()){ + String nsRule = nsRules.get(nsName); + nsRules.put(nsName, nsRule.replaceAll("\\$"+i+"(?=\\D.*|\\z)", "\\$"+(i+1))); + } + articleName.replace(0, articleName.length(), + articleName.toString().replaceAll("\\$"+i+"(?=\\D.*|\\z)", "\\$"+(i+1))); + } + captured.put(i, true); //autobox both key and value + for(int j = groupCount; j >= i; j--){ + captured.remove(j); + captured.put(j+1, true); + } + } //end if (rule contains group reference) + } // end for(group count) + } // end if (member's relationship is HAS) + else{ + System.err.println("Relationship for member " + memberRelationship.getName() + " of "+ mobyDataType + + "is *not* HAS"); + } + } //end for(member replationships) + return newRegexp; + } + + public void addRegexMapping(String regexp, Map nsRules, String mobyDataType, + Map membersMap, String articleName, + String ruleName){ try{ + // Use a StringBuffer so it's mutable by handleHASMembers() + StringBuffer articleNameBuffer = new StringBuffer(articleName == null ? "" : articleName); + regexp = handleHASMembers(regexp, nsRules, mobyDataType, membersMap, articleNameBuffer); + // Pattern.DOTALL to allow ".*" to span multiple lines, also allow comments (# to EOL) and whitespace // for better readability in the rules file. - Pattern pattern = Pattern.compile(processRegExp(regexp), Pattern.DOTALL | Pattern.COMMENTS); + Pattern pattern = Pattern.compile(processRegExp(regexp, membersMap), Pattern.DOTALL | Pattern.COMMENTS); // Base object if(mobyDataType == null || mobyDataType.length() == 0){ regexMap.put(pattern, new MobyComplexBuilder("Object", membersMap, nsRules, - articleName)); - return; + this, + articleNameBuffer.toString())); } - // Complex Object - regexMap.put(pattern, new MobyComplexBuilder(mobyDataType, - membersMap, - nsRules, - articleName)); + else{ + regexMap.put(pattern, new MobyComplexBuilder(mobyDataType, + membersMap, + nsRules, + this, + articleNameBuffer.toString())); + } + + if(ruleName != null && ruleName.length() != 0){ + patternNameMap.put(ruleName, pattern); + builderNameMap.put(ruleName, regexMap.get(pattern)); + } + }catch(Exception e){ System.err.println("Could not create regular expression statement from '" + regexp + "': " + e); @@ -1121,6 +1327,7 @@ urlRegexMap.put(pattern, new MobyComplexBuilder("Object", membersMap, url_nsRules, + this, articleName)); return; } @@ -1129,6 +1336,7 @@ urlRegexMap.put(pattern, new MobyComplexBuilder(mobyDataType, membersMap, url_nsRules, + this, articleName)); }catch(Exception e){ System.err.println("Could not create URL regular expression statement from '" + @@ -1169,6 +1377,7 @@ xpathMap.put(xpath, new MobyComplexBuilder("Object", membersMap, nsRules, + this, articleName)); return; } @@ -1177,6 +1386,7 @@ xpathMap.put(xpath, new MobyComplexBuilder(mobyDataType, membersMap, nsRules, + this, articleName)); }catch(Exception e){ @@ -1286,5 +1496,19 @@ } return true; // be optimistic by default, assume it's alive } + + /** + * If a rule was given this name, the MOBY object builder for the rule is returned. + */ + public MobyComplexBuilder getBuilder(String ruleName){ + return builderNameMap.get(ruleName); + } + + /** + * If a rule was given this name, the regex pattern for the rule is returned. + */ + public Pattern getPattern(String ruleName){ + return patternNameMap.get(ruleName); + } } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyComplexBuilder.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyComplexBuilder.java 2007/06/16 00:28:11 1.9 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyComplexBuilder.java 2007/06/28 16:45:44 1.10 @@ -12,9 +12,8 @@ import javax.xml.parsers.*; import javax.xml.namespace.NamespaceContext; -import java.util.Iterator; -import java.util.Map; -import java.util.regex.Matcher; +import java.util.*; +import java.util.regex.*; /** * Class used by MobyClient to build the MOBY rule database from a configuration file. @@ -22,6 +21,7 @@ public class MobyComplexBuilder{ public static final String ANON_ARTICLE = "_seahawk_data"; + public static final String INHERITED_MEMBERS_SENTINEL = "_seahawk_member_inheritance"; private static XPathFactory xPathFactory; private static DocumentBuilder docBuilder; @@ -31,6 +31,7 @@ private MobyDataType mobyDataType; private MobyNamespace[] mobyNS; private MobyRelationship[] children; + private MobyClient client; static{ xPathFactory = XPathFactory.newInstance(); @@ -43,11 +44,11 @@ } } - public MobyComplexBuilder(String dataType, Map members, Map nameSpaces) throws Exception{ - this(dataType, members, nameSpaces, ANON_ARTICLE); + public MobyComplexBuilder(String dataType, Map members, Map nameSpaces, MobyClient cl) throws Exception{ + this(dataType, members, nameSpaces, cl, ANON_ARTICLE); } - public MobyComplexBuilder(String dataType, Map members, Map nameSpaces, String articleName) throws Exception{ + public MobyComplexBuilder(String dataType, Map members, Map nameSpaces, MobyClient cl, String articleName) throws Exception{ mobyDataType = MobyDataType.getDataType(dataType, SeahawkOptions.getRegistry()); // Not an existing Ontology data type if(mobyDataType == null){ @@ -56,6 +57,7 @@ articleNameRule = articleName; memberRules = members; + client = cl; if(mobyDataType != null && mobyDataType.getName() != null && !mobyDataType.getName().equals("Object")){ @@ -66,9 +68,21 @@ for(int i = 0; children != null && i < children.length; i++){ String childName = children[i].getName(); if(!memberRules.containsKey(childName)){ - throw new Exception("Ruleset for object " + mobyDataType.getName() + - " does not include a rule for required member " + - children[i]); + // See if there's an inherited member + if(!memberRules.containsKey(INHERITED_MEMBERS_SENTINEL)){ + throw new Exception("Ruleset for object " + mobyDataType.getName() + + " does not include a rule for required member '" + + childName+"'"); + } + String inheritedRuleName = memberRules.get(INHERITED_MEMBERS_SENTINEL)[0]; + MobyComplexBuilder inheritedBuilder = client.getBuilder(inheritedRuleName); + if(inheritedBuilder.getDataType().getChild(childName) == null){ + throw new Exception("Ruleset for object " + mobyDataType.getName() + + " does not include a rule for required member '" + + childName+"', nor does the inherited rule '"+ + inheritedRuleName+"'"); + } + } for(int j = 0; j < ruleNames.length; j++){ if(ruleNames[j] == childName){ @@ -82,11 +96,50 @@ System.err.println("Ignoring member rules for object type " + mobyDataType.getName() + " (not in the MOBY ontology):"); for(int i = 0; i < ruleNames.length; i++){ - if(ruleNames[i] != null){ + if(ruleNames[i] != null && !ruleNames[i].equals(INHERITED_MEMBERS_SENTINEL)){ System.err.println("Extra member: " + ruleNames[i]); } } } + + // Check that any casting done on members of the object is kosher + // (do this now because we now have the data type of the parent object for sure) + for(Map.Entry member: members.entrySet()){ + if(member.getKey().equals(INHERITED_MEMBERS_SENTINEL)){ + continue; + } + String memberDataTypeSetting = member.getValue()[1]; + if(memberDataTypeSetting != null && memberDataTypeSetting.length() > 0){ + MobyRelationship child = mobyDataType.getChild(member.getKey()); + String defaultDataTypeName = child.getDataTypeName(); + MobyDataType castType = MobyDataType.getDataType(memberDataTypeSetting, + SeahawkOptions.getRegistry()); + MobyDataType origType = MobyDataType.getDataType(defaultDataTypeName, + SeahawkOptions.getRegistry()); + if(castType == null){ + System.err.println("Could not find the data type "+memberDataTypeSetting+ + " in the ontology, ignoring the data type cast"+ + " that says it should override " + defaultDataTypeName); + member.getValue()[1] = null; + } + else if(origType == null){ + System.err.println("Could not find the data type "+defaultDataTypeName+ + " in the ontology, ignoring the data type cast" + + " that overrides it to data type (" + memberDataTypeSetting + + "), can't tell if the cast is legal or not)"); + member.getValue()[1] = null; + } + else if(!castType.inheritsFrom(origType)){ + System.err.println("The data type "+memberDataTypeSetting+ + " does not inherit from the member's type in the ontology (" + + defaultDataTypeName+"), ignoring the data type cast"); + member.getValue()[1] = null; + } + else{ + // It's safe it we got this far, leave it as-is + } + } + } } namespaceRules = nameSpaces; @@ -124,7 +177,8 @@ } // Set article name, if available - if(articleNameRule != null && articleNameRule.length() > 0){ + if(articleNameRule != null && articleNameRule.length() > 0 && + !articleNameRule.equals(ANON_ARTICLE)){ mobyObj.setName(evaluateRule(matcher, articleNameRule, MobyClient.WHITESPACE_ATTR_STRIP_FLANKING_VAL, @@ -159,36 +213,194 @@ } } - // Set members if available and required - if(mobyObj instanceof MobyDataComposite){ - if(children != null){ - for(int i = 0; i < children.length; i++){ - String memberName = children[i].getName(); - String[] resultSpec = memberRules.get(memberName); + // Done? + if(!(mobyObj instanceof MobyDataComposite) || children == null){ + return mobyObj; + } + + // There's another rule to populate members from + if(memberRules.containsKey(INHERITED_MEMBERS_SENTINEL)){ + // String[2] = {ruleName, ruleValue} + String[] ruleSpec = memberRules.get(INHERITED_MEMBERS_SENTINEL); + MobyComplexBuilder inheritedBuilder = client.getBuilder(ruleSpec[0]); + String result = evaluateRule(matcher, ruleSpec[1], null, null, data); + Matcher submatcher = client.getPattern(ruleSpec[0]).matcher(result); + if(!submatcher.find()){ + throw new MobyException("Pattern of inherited rule '"+ruleSpec[0]+ + "' does not match data given: " + result); + } + MobyDataObject inheritedResult = inheritedBuilder.apply(submatcher, result.getBytes()); + + // Now copy all the fields from the inheritedResults to our object + if(inheritedResult instanceof MobyDataComposite){ + ((MobyDataComposite) mobyObj).putAll((MobyDataComposite) inheritedResult); + } + } + + // Otherwise set members if available and required + for(int i = 0; i < children.length; i++){ + String memberName = children[i].getName(); + String[] resultSpec = memberRules.get(memberName); + if(resultSpec == null){ + // Must have been populated by the inherited rule? + if(!((MobyDataComposite) mobyObj).containsKey(memberName)){ + throw new MobyException("Member " +memberName+" does not have a rule, nor" + + " was not populated by any inherited rule"); + } + continue; + } - MobyRelationship memberRelationship = mobyDataType.getChild(memberName); - // Is the field a list rather than a single value? If so, - // we will need to reinterpret the member value specification - // as many times as the regex capture group matched... - if(memberRelationship.getRelationshipType() == Central.iHAS){ - + String dataTypeName = children[i].getDataTypeName(); + // First: does the rule cast the object to some subtype? + if(resultSpec[1] != null && resultSpec[1].length() > 0){ + // Safe to cast if we got this far (e.g. put String where an Object is specified) + dataTypeName = resultSpec[1]; + } + + // Is the field a list rather than a single value? If so, + // we will need to reinterpret the member value specification + // as many times as the regex capture group matched... + String[] results = new String[1]; + if(children[i].getRelationshipType() == Central.iHAS){ + // We need to reconstruct the capture group so that we + // can save each value, not just its last one. + try{ + // results may be more than one element in this case + results = evaluateIterativeRule(matcher, resultSpec[0], resultSpec[2], resultSpec[3], data); + } catch(Exception e){ + e.printStackTrace(); + throw new MobyException("Error while evaluating HAS (iterative evaluation) rule: " + e); + } + } + // else is iHASA, scalar context + else{ + // only one result to process and add the to object + results[0] = evaluateRule(matcher, resultSpec[0], resultSpec[2], resultSpec[3], data); + } + + for(String result: results){ + + if(PrimitiveTypes.isPrimitive(dataTypeName)){ + ((MobyDataComposite) mobyObj).put(memberName, + MobyDataObject.createInstanceFromString(dataTypeName, result)); + } + else{ + // Recursively call the object creator for complex members + + // Fetch the member's MobyComplexBuilder by name from the rule spec + String memberRuleName = resultSpec[4]; + if(memberRuleName == null || memberRuleName.length() == 0){ + throw new MobyException("Composite member "+memberName+ + " does not have an associated rule to produce it"); + } + MobyComplexBuilder memberBuilder = client.getBuilder(memberRuleName); + if(memberBuilder == null){ + throw new MobyException("The object builder for the rule " + memberRuleName + + " could not be found"); + } + Pattern memberPattern = client.getPattern(memberRuleName); + + // Now apply the regex for the capture group, so we can use + // the results in a recursive call to this method (stop condition + // is when all members are primitives). + Matcher memberMatcher = memberPattern.matcher(result); + + if(memberMatcher.find()){ + ((MobyDataComposite) mobyObj).put(memberName, + memberBuilder.apply(memberMatcher)); } - // else is iHASA, scalar context else{ - String result = evaluateRule(matcher, resultSpec[0], resultSpec[1], resultSpec[2], data); - - ((MobyDataComposite) mobyObj).put(memberName, - MobyDataObject.createInstanceFromString(children[i].getDataTypeName(), result)); + System.err.println("Could not match pattern \"" + memberPattern.pattern() + + "\" to string \"" + result + "\", abandoning " + + dataTypeName + " object creation"); } } + } //end for results + } //end for children + + return mobyObj; + } + + /** + * @return a list of rule values to interpret + */ + public String[] evaluateIterativeRule(Matcher matcher, String result, String whitespaceMode, String encodingMode, byte[] data) + throws MobyException, Exception{ + Vector capturedValues = new Vector(); + + // Figure out which capture group needs to be evaluated iteratively + Vector captureGroups = new Vector(); + // This only really works with 10 capture groups or less, otherwise $1 and $10 can get captured, etc. + for(int captureGroup = 1; captureGroup <= matcher.groupCount(); captureGroup++){ + if(result.indexOf("$"+captureGroup) != -1){ + //System.err.println("Adding capture group " + captureGroup + + // " to evaluation list due to its presence in rule " + result); + captureGroups.add(captureGroup); } } + // No capture group found, so just return single evaluation on whole expression (may use $0) + if(captureGroups.isEmpty()){ + return new String[]{evaluateRule(matcher, result, whitespaceMode, encodingMode, data)}; + } + + // Pull out the capture group's pattern, by counting parentheses + Map captureGroupRegexes = new HashMap(); + for(Integer captureGroup: captureGroups){ + captureGroupRegexes.put(captureGroup.intValue(), + RegexParser.getCaptureGroupRegex(matcher.pattern(), + captureGroup.intValue())); + } + + // Find all instances of the capture group, save their value + Map captureGroupSubvalues = new HashMap(); + for(Map.Entry entry: captureGroupRegexes.entrySet()){ + // Why fetch cap group # -1? Because we auto-encapsulated the cap groups the HAS member + // refers to, specifically so we get the whole match for processing, rather than just + // the last one, i.e. (\d)+ in a regex rule became ((\d)+) in MobyClient so we can + // find each \d in the whole match and add them indidivually as HAS (0 or more) members + // in the object instance. + String wholeMatch = matcher.group(entry.getKey().intValue()-1); + String regex = entry.getValue(); + if(regex.length() == 0){ + throw new Exception("Encountered empty regex in capture group " + entry.getKey()); + } + //System.err.println("Applying regex "+regex+" to "+wholeMatch+", whole pattern was "+matcher.pattern().pattern()); + // If the pattern matches more than once, the matches must be contiguous, hence the \G + Pattern captureGroupPattern = Pattern.compile("\\G"+regex, + Pattern.DOTALL | Pattern.COMMENTS); + Vector subValues = new Vector(); + Matcher subMatcher = captureGroupPattern.matcher(wholeMatch); + int lastSubMatcherEnd = -1; + while(subMatcher.find()){ + subValues.add(subMatcher.group()); + lastSubMatcherEnd = subMatcher.end(); + } - return mobyObj; + // For safety, we should do a sanity check that there's + // is no unmatched input left over, as we'd expect + if(lastSubMatcherEnd != -1 && lastSubMatcherEnd != wholeMatch.length()){ + throw new Exception("The submatcher for capture group "+entry.getKey()+ + " did not match to the last char of \"" + wholeMatch + + "\", should have ended match at index " + (wholeMatch.length()-1) + + ", but instead matched until " + (lastSubMatcherEnd-1)); + } + captureGroupSubvalues.put(entry.getKey().intValue(), + (String[]) subValues.toArray(new String[subValues.size()])); + } + + // Now, iteratively substitute each subvalue from each capture group into the rules + IterativeMatchResult iterMatch = new IterativeMatchResult(matcher, captureGroupSubvalues); + for(int i = 0; i < iterMatch.getNumIterations(); i++){ + iterMatch.setIteration(i); + capturedValues.add(evaluateRule(iterMatch, result, whitespaceMode, encodingMode, data)); + } + + // Return all the values we found + return (String[]) capturedValues.toArray(new String[capturedValues.size()]); } // takes a rule and evaluates $# variables and XPath expressions - private String evaluateRule(Matcher matcher, String result, String whitespaceMode, String encodingMode, byte[] data) + private String evaluateRule(MatchResult match, String result, String whitespaceMode, String encodingMode, byte[] data) throws MobyException{ byte[] resultBytes = result.getBytes(); boolean nonBasic = result.length() != 2 || result.indexOf("$") != 0; @@ -202,24 +414,24 @@ doc = docBuilder.newDocument(); } - // Replace any $0, $1, etc. in the replacement string with the values found in the matcher + // Replace any $0, $1, etc. in the replacement string with the values found in the match // Note that this is not perfect: if you had "$1 $2", and $1 had value "$250", you'd get $250$2, // then you'd substitute $2's value of "per metre", you'd get "per metre50 per metre" instead of // "$250 per metre". Not sure of a good way around this yet (i.e. when varValue had $k in it where k > j)... - for(int j = 0; j <= matcher.groupCount(); j++){ + for(int j = 0; j <= match.groupCount(); j++){ // A replaceAll() for binary data if(data != null && isBinary){ int srcPos = 0; for(int varIndex = result.indexOf("$"+j, srcPos); varIndex != -1; varIndex = result.indexOf("$"+j, srcPos)){ - int varValueLength = matcher.end(j)-matcher.start(j); + int varValueLength = match.end(j)-match.start(j); int varLen = ("$"+j).getBytes().length; byte[] newResultBytes = new byte[resultBytes.length+varValueLength-varLen]; if(varIndex > 0){ System.arraycopy(resultBytes, 0, newResultBytes, 0, varIndex); } - System.arraycopy(data, matcher.start(j), newResultBytes, varIndex, varValueLength); + System.arraycopy(data, match.start(j), newResultBytes, varIndex, varValueLength); int remaining = result.length()-varIndex-varLen; if(remaining > 0){ System.arraycopy(resultBytes, varIndex+varLen, newResultBytes, varIndex+varValueLength, @@ -230,8 +442,8 @@ } } // $# substitution in a string, considerably simpler! - else{ - String varValue = matcher.group(j); + else if(result.matches("^\\$"+j+"(?=\\D.*|\\z)")){ + String varValue = match.group(j); if(whitespaceMode == null){ // do nothing } @@ -244,7 +456,7 @@ else if(whitespaceMode.equals(MobyClient.WHITESPACE_ATTR_STRIP_FLANKING_VAL)){ varValue = varValue.trim(); // removes leading and trailing whitespace } - result = result.replaceAll("\\$"+j, varValue); + result = result.replaceAll("\\$"+j+"(?=\\D|\\z)", varValue); // Binary data and XPath are incompatible, since many bytes are not allowed in XML // so only create the node list if not Base64 encoding From gordonp at dev.open-bio.org Thu Jun 28 12:47:24 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 28 Jun 2007 12:47:24 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706281647.l5SGlNAT004587@dev.open-bio.org> gordonp Thu Jun 28 12:47:23 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/test In directory dev.open-bio.org:/tmp/cvs-serv4556/src/main/ca/ucalgary/seahawk/services/test Added Files: MobyClientTestCase.java RegexParserTestCase.java embossChargeOutput.txt mobyRules1.xml mobyRules2.xml mobyRules3.xml Log Message: Test suite for the MOB rule classes moby-live/Java/src/main/ca/ucalgary/seahawk/services/test MobyClientTestCase.java,NONE,1.1 RegexParserTestCase.java,NONE,1.1 embossChargeOutput.txt,NONE,1.1 mobyRules1.xml,NONE,1.1 mobyRules2.xml,NONE,1.1 mobyRules3.xml,NONE,1.1 From gordonp at dev.open-bio.org Sat Jun 30 18:21:57 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Sat, 30 Jun 2007 18:21:57 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706302221.l5UMLvZc013734@dev.open-bio.org> gordonp Sat Jun 30 18:21:57 EDT 2007 Update of /home/repository/moby/moby-live/Java/docs In directory dev.open-bio.org:/tmp/cvs-serv13699 Modified Files: Seahawk.html Log Message: Added journal article reference moby-live/Java/docs Seahawk.html,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Java/docs/Seahawk.html,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Java/docs/Seahawk.html 2007/06/21 18:33:43 1.7 +++ /home/repository/moby/moby-live/Java/docs/Seahawk.html 2007/06/30 22:21:56 1.8 @@ -11,6 +11,11 @@

    What is Seahawk?

    + While this page links to many extra technical details, the definitive + reference for an explanation of Seahawk and its features is: +

    Gordon P.M.K., Sensen C.W. (2007) Seahawk: Moving Beyond HTML in Web-based Bioinformatics Analysis. BMC Bioinformatics 8:208. Medline
    + Seahawk is a Java applet (or application component) that allows a naïve user to:
    1. Load text, HTML, Rich Text, or MOBY XML files from their local disk or a Web site
    2. @@ -30,11 +35,11 @@

      What is not?

      - Seahawk is not a visual programming environment for workflows. For that kind of functionality, please see - Taverna, or + Seahawk is not a visual programming environment for workflows, but rather allows workflow + construction by example (as opposed to Taverna or Remora. It is not for deploying services or seeing the guts of MOBY Objects - and service calls: please see Dashboard. + and service calls: for this please see Dashboard.

      Sections

      From gordonp at dev.open-bio.org Thu Jun 7 19:58:16 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 07 Jun 2007 23:58:16 -0000 Subject: [MOBY-guts] biomoby commit Message-ID: <200706072358.l57NwF5C025578@dev.open-bio.org> gordonp Thu Jun 7 19:58:15 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data In directory dev.open-bio.org:/tmp/cvs-serv25503/src/main/org/biomoby/shared/data Modified Files: MobyContentInstance.java MobyDataBoolean.java MobyDataBytes.java MobyDataComposite.java MobyDataDateTime.java MobyDataFloat.java MobyDataInt.java MobyDataObject.java MobyDataObjectSet.java MobyDataString.java MobyDataUtils.java Log Message: Updates to deal with fact that more than one registry can be used as the source of type information moby-live/Java/src/main/org/biomoby/shared/data MobyContentInstance.java,1.11,1.12 MobyDataBoolean.java,1.3,1.4 MobyDataBytes.java,1.6,1.7 MobyDataComposite.java,1.14,1.15 MobyDataDateTime.java,1.8,1.9 MobyDataFloat.java,1.6,1.7 MobyDataInt.java,1.5,1.6 MobyDataObject.java,1.15,1.16 MobyDataObjectSet.java,1.7,1.8 MobyDataString.java,1.5,1.6 MobyDataUtils.java,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyContentInstance.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyContentInstance.java 2007/05/30 17:44:19 1.11 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyContentInstance.java 2007/06/07 23:58:15 1.12 @@ -1,5 +1,6 @@ package org.biomoby.shared.data; +import org.biomoby.registry.meta.Registry; import org.biomoby.shared.*; import org.biomoby.shared.parser.MobyTags; import org.biomoby.shared.parser.ServiceException; @@ -80,6 +81,10 @@ * interface methods, with queryID as key, and MobyDataInstance Vectors (mobyData) as values. */ public MobyContentInstance(Element objectTag) throws MobyException{ + this(objectTag, null); + } + + public MobyContentInstance(Element objectTag, Registry registry) throws MobyException{ this(); if(!MobyTags.MOBYCONTENT.equals(objectTag.getLocalName())){ throw new MobyException("The content element provided (" + @@ -122,7 +127,7 @@ System.err.println("Warning: found null element in DOM results (very strange)"); continue; } - parseDataGroup(dataGroup); + parseDataGroup(dataGroup, registry); } // If we got to this stage, we're okay in the sytax department. @@ -185,7 +190,7 @@ debugPS = ps; } - public void parseDataGroup(Element dataGroupTag) throws MobyException{ + public void parseDataGroup(Element dataGroupTag, Registry registry) throws MobyException{ String groupID = null; MobyDataJob job = new MobyDataJob(); @@ -213,7 +218,7 @@ " collections in response " + groupID); } Element collectionTag = (Element) collections.item(j); - MobyDataObjectSet collection = (MobyDataObjectSet) (MobyDataObject.createInstanceFromDOM(collectionTag)); + MobyDataObjectSet collection = (MobyDataObjectSet) (MobyDataObject.createInstanceFromDOM(collectionTag, registry)); // Add completed collection to the output list job.put(collection.getName(), collection); @@ -237,11 +242,11 @@ throw new MobyException("Illegal XML: there is more than one tag in the response " + groupID + " with the articleName " + name); } - job.put(name, MobyDataObject.createInstanceFromDOM((Element) simples.item(j))); + job.put(name, MobyDataObject.createInstanceFromDOM((Element) simples.item(j), registry)); } // No anonymous data member yet else if(!job.containsKey("")){ - job.put("", MobyDataObject.createInstanceFromDOM((Element) simples.item(j))); + job.put("", MobyDataObject.createInstanceFromDOM((Element) simples.item(j), registry)); } else{ debugPS.println("More than one anonymous member, ignoring simple #" + j); =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataBoolean.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataBoolean.java 2006/07/07 04:12:40 1.3 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataBoolean.java 2007/06/07 23:58:15 1.4 @@ -1,7 +1,10 @@ package org.biomoby.shared.data; + +import org.biomoby.registry.meta.Registry; import org.biomoby.shared.MobyDataType; import org.biomoby.shared.MobyNamespace; +import org.biomoby.shared.parser.MobyTags; /** * A class representing a MOBY Boolean primitive. @@ -21,7 +24,11 @@ * @throws IllegalArgumentException if the element is not a String tag */ public MobyDataBoolean(org.w3c.dom.Element element) throws IllegalArgumentException{ - this(getName(element), getTextContents(element)); + this(element, null); + } + + public MobyDataBoolean(org.w3c.dom.Element element, Registry registry) throws IllegalArgumentException{ + this(getName(element), getTextContents(element), registry); setId(getId(element)); addNamespace(getNamespace(element)); } @@ -31,13 +38,22 @@ * (i.e. String, StringBuffer, CharBuffer or StringBuilder). */ public MobyDataBoolean(String articleName, Boolean b){ + this(articleName, b, null); + } + + /** Every c-tor eventually winds up here */ + public MobyDataBoolean(String articleName, Boolean b, Registry registry){ super(articleName); - setDataType(MobyDataType.getDataType("Boolean")); + setDataType(MobyDataType.getDataType(MobyTags.MOBYBOOLEAN, registry)); value = b; } public MobyDataBoolean(String articleName, boolean b){ - this(articleName, Boolean.valueOf(b)); + this(articleName, Boolean.valueOf(b), null); + } + + public MobyDataBoolean(String articleName, boolean b, Registry registry){ + this(articleName, Boolean.valueOf(b), registry); } /** @@ -46,21 +62,37 @@ * "Yes" and "1" are not acceptable. */ public MobyDataBoolean(String articleName, String booleanString){ - this(articleName, Boolean.valueOf(booleanString)); + this(articleName, Boolean.valueOf(booleanString), null); + } + + public MobyDataBoolean(String articleName, String booleanString, Registry registry){ + this(articleName, Boolean.valueOf(booleanString), registry); } public MobyDataBoolean(Boolean b){ this("", b); } + public MobyDataBoolean(Boolean b, Registry r){ + this("", b, r); + } + public MobyDataBoolean(boolean b){ this("", b); } + public MobyDataBoolean(boolean b, Registry r){ + this("", b, r); + } + public MobyDataBoolean(String booleanString){ this("", booleanString); } + public MobyDataBoolean(String booleanString, Registry r){ + this("", booleanString, r); + } + public String toString(){ return value.toString(); } @@ -117,7 +149,7 @@ public String toXML(){ MobyNamespace[] ns = getNamespaces(); if(xmlMode == MobyDataInstance.SERVICE_XML_MODE){ - return "" + value + ""; + return "<"+MobyTags.MOBYBOOLEAN+" "+ getAttrXML() + ">" + value + ""; } // Central mode, use default toXML provided by superclasses else{ =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataBytes.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataBytes.java 2007/04/13 01:55:36 1.6 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataBytes.java 2007/06/07 23:58:15 1.7 @@ -1,6 +1,7 @@ package org.biomoby.shared.data; +import org.biomoby.registry.meta.Registry; import org.biomoby.shared.MobyDataType; import org.biomoby.shared.MobyException; import java.io.*; @@ -34,12 +35,16 @@ * @throws IllegalArgumentException if the element is not a text-base64 tag, or doesn't inherit from it */ public MobyDataBytes(org.w3c.dom.Element element) throws MobyException{ - super(MobyDataType.getDataType(BASE64_DATATYPE), getName(element)); + this(element, null); + } + + public MobyDataBytes(org.w3c.dom.Element element, Registry registry) throws MobyException{ + super(MobyDataType.getDataType(BASE64_DATATYPE, registry), getName(element)); setId(getId(element)); addNamespace(getNamespace(element)); - MobyDataType inputDataType = MobyDataType.getDataType(element.getLocalName()); - if(!inputDataType.inheritsFrom(MobyDataType.getDataType(BASE64_DATATYPE))){ + MobyDataType inputDataType = MobyDataType.getDataType(element.getLocalName(), registry); + if(!inputDataType.inheritsFrom(MobyDataType.getDataType(BASE64_DATATYPE, registry))){ throw new MobyException("The given tag ("+ element.getLocalName() + ") does not inherit from " + BASE64_DATATYPE + " in the MOBY Object Class Ontology, cannot " + @@ -49,7 +54,7 @@ // Now, we know we have one field that represents the bytes, // and there may be others which we will treat as regular composite members - populateMembersFromDOM(element); + populateMembersFromDOM(element, registry); MobyDataObject contents = get(ENCODED_MEMBER_NAME); if(contents == null){ @@ -73,7 +78,11 @@ * @throws MobyException if the data provided is null, or could not be encoded(?!) */ public MobyDataBytes(String name, byte[] data) throws MobyException{ - super(MobyDataType.getDataType(BASE64_DATATYPE), name); + this(name, data, (Registry) null); + } + + public MobyDataBytes(String name, byte[] data, Registry registry) throws MobyException{ + super(MobyDataType.getDataType(BASE64_DATATYPE, registry), name); storeBytes(data); } @@ -82,7 +91,7 @@ */ public MobyDataBytes(String name, byte[] data, MobyDataType inputDataType) throws MobyException{ this(name, data); - if(!inputDataType.inheritsFrom(MobyDataType.getDataType(BASE64_DATATYPE))){ + if(!inputDataType.inheritsFrom(MobyDataType.getDataType(BASE64_DATATYPE, inputDataType.getRegistry()))){ throw new MobyException("The given data type ("+ inputDataType.getName() + ") does not inherit from " + BASE64_DATATYPE + " in the MOBY Object Class Ontology, cannot " + @@ -97,10 +106,14 @@ * Currently Base64 encoding is acceptable, UU Decoding has yet to be implemented.. */ public MobyDataBytes(String name, CharSequence data){ - super(MobyDataType.getDataType(BASE64_DATATYPE), name); - setDataType(MobyDataType.getDataType(BASE64_DATATYPE)); + this(name, data, (Registry) null); + } + + public MobyDataBytes(String name, CharSequence data, Registry registry){ + super(MobyDataType.getDataType(BASE64_DATATYPE, registry), name); + setDataType(MobyDataType.getDataType(BASE64_DATATYPE, registry)); // TODO: add check that the data is valid Base64 format! - put(ENCODED_MEMBER_NAME, new MobyDataString(ENCODED_MEMBER_NAME, data)); + put(ENCODED_MEMBER_NAME, new MobyDataString(ENCODED_MEMBER_NAME, data, registry)); } /** @@ -110,7 +123,7 @@ */ public MobyDataBytes(String name, CharSequence data, MobyDataType inputDataType) throws MobyException{ this(name, data); - if(!inputDataType.inheritsFrom(MobyDataType.getDataType(BASE64_DATATYPE))){ + if(!inputDataType.inheritsFrom(MobyDataType.getDataType(BASE64_DATATYPE, inputDataType.getRegistry()))){ throw new MobyException("The given data type ("+ inputDataType.getName() + ") does not inherit from " + BASE64_DATATYPE + " in the MOBY Object Class Ontology, cannot " + @@ -125,7 +138,11 @@ * @param resourceURL the URL of the resource to encode, such as "file:..." or "http:..." */ public MobyDataBytes(String name, java.net.URL resourceURL) throws MobyException, IOException{ - super(MobyDataType.getDataType(BASE64_DATATYPE), name); + this(name, resourceURL, (Registry) null); + } + + public MobyDataBytes(String name, java.net.URL resourceURL, Registry registry) throws MobyException, IOException{ + super(MobyDataType.getDataType(BASE64_DATATYPE, registry), name); if(resourceURL == null){ return; } @@ -151,7 +168,7 @@ */ public MobyDataBytes(String name, java.net.URL resourceURL, MobyDataType inputDataType) throws IOException, MobyException{ this(name, resourceURL); - if(!inputDataType.inheritsFrom(MobyDataType.getDataType(BASE64_DATATYPE))){ + if(!inputDataType.inheritsFrom(MobyDataType.getDataType(BASE64_DATATYPE, inputDataType.getRegistry()))){ throw new MobyException("The given data type ("+ inputDataType.getName() + ") does not inherit from " + BASE64_DATATYPE + " in the MOBY Object Class Ontology, cannot " + =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataComposite.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataComposite.java 2007/04/13 01:56:12 1.14 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataComposite.java 2007/06/07 23:58:15 1.15 @@ -9,12 +9,8 @@ import java.util.Set; import java.util.Vector; -import org.biomoby.shared.Central; -import org.biomoby.shared.MobyDataType; -import org.biomoby.shared.MobyException; -import org.biomoby.shared.MobyNamespace; -import org.biomoby.shared.MobyPrefixResolver; -import org.biomoby.shared.MobyRelationship; +import org.biomoby.registry.meta.Registry; +import org.biomoby.shared.*; import org.biomoby.shared.parser.MobyTags; /** @@ -32,12 +28,19 @@ * @throws MobyException if the element is not a MobyObject tag */ public MobyDataComposite(org.w3c.dom.Element element) throws MobyException{ - this(MobyDataType.getDataType(element.getLocalName()), getName(element), getNamespace(element), getId(element)); + this(element, null); + } + + public MobyDataComposite(org.w3c.dom.Element element, Registry registry) throws MobyException{ + this(MobyDataType.getDataType(element.getLocalName(), registry), + getName(element), + getNamespace(element), + getId(element)); - populateMembersFromDOM(element); + populateMembersFromDOM(element, registry); } - protected void populateMembersFromDOM(org.w3c.dom.Element element) throws MobyException{ + protected void populateMembersFromDOM(org.w3c.dom.Element element, Registry registry) throws MobyException{ // Decompose the children org.w3c.dom.NodeList substructures = MobyPrefixResolver.getChildElements(element, "*"); //wildcard int numSubstructures = substructures.getLength(); @@ -87,9 +90,13 @@ * ontology, otherwise the datatype will be null. */ public MobyDataComposite(String typeName, String name, String namespace, String id){ + this(typeName, name, namespace, id, (Registry) null); + } + + public MobyDataComposite(String typeName, String name, String namespace, String id, Registry registry){ super(namespace, id); setName(name); - setDataType(MobyDataType.getDataType(typeName)); + setDataType(MobyDataType.getDataType(typeName, registry)); members = new ConcurrentHashMap(); } @@ -111,7 +118,7 @@ setDataType(type); members = new ConcurrentHashMap(); - MobyDataType dt = MobyDataType.getDataType(type.getName()); + MobyDataType dt = MobyDataType.getDataType(type.getName(), type.getRegistry()); MobyRelationship[] children = dt.getAllChildren(); // If one arg, resolve it's name, set it, and we're done @@ -201,7 +208,11 @@ } public MobyDataComposite(String typeName, String name){ - this(MobyDataType.getDataType(typeName), name); + this(typeName, name, (Registry) null); + } + + public MobyDataComposite(String typeName, String name, Registry r){ + this(MobyDataType.getDataType(typeName, r), name); } public MobyDataComposite(MobyDataType type){ @@ -209,7 +220,11 @@ } public MobyDataComposite(String typeName){ - this(MobyDataType.getDataType(typeName)); + this(typeName, (Registry) null); + } + + public MobyDataComposite(String typeName, Registry r){ + this(MobyDataType.getDataType(typeName, r)); } public Object clone(){ @@ -394,7 +409,7 @@ MobyRelationship relationship = getDataType().getChild(fieldName); if(relationship == null){ - relationship = MobyDataType.getDataType(getDataType().getName()).getChild(fieldName); + relationship = MobyDataType.getDataType(getDataType().getName(), getDataType().getRegistry()).getChild(fieldName); if(relationship == null){ String memberNames = ""; for(MobyRelationship rel: getDataType().getChildren()){ @@ -405,7 +420,7 @@ getDataType().getName() + ", valid member names are:" + memberNames); } } - MobyDataType childDataType = MobyDataType.getDataType(relationship.getDataTypeName()); + MobyDataType childDataType = MobyDataType.getDataType(relationship.getDataTypeName(), getDataType().getRegistry()); if(!value.getDataType().inheritsFrom(childDataType)){ // Incompatible types throw new IllegalArgumentException("The member '" + fieldName + "' for object '"+ getName() + =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataDateTime.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataDateTime.java 2007/05/29 23:49:32 1.8 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataDateTime.java 2007/06/07 23:58:15 1.9 @@ -1,13 +1,12 @@ - package org.biomoby.shared.data; + +import org.biomoby.registry.meta.Registry; import org.biomoby.shared.MobyDataType; +import org.biomoby.shared.parser.MobyTags; + import java.text.DecimalFormat; import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.GregorianCalendar; -import java.util.NoSuchElementException; -import java.util.StringTokenizer; -import java.util.TimeZone; +import java.util.*; /** * A class representing a MOBY DateTime, which is a primitive in MOBY. @@ -36,7 +35,11 @@ * @throws IllegalArgumentException if the element is not a DateTime tag, or the text children of the element do not encode a valid ISO8601 date/time */ public MobyDataDateTime(org.w3c.dom.Element element) throws IllegalArgumentException{ - this(getName(element), getTextContents(element)); + this(element, null); + } + + public MobyDataDateTime(org.w3c.dom.Element element, Registry registry) throws IllegalArgumentException{ + this(getName(element), getTextContents(element), registry); setId(getId(element)); addNamespace(getNamespace(element)); } @@ -46,8 +49,12 @@ * @param stringISO8601 if null, the current local date and time is used */ public MobyDataDateTime(String articleName, String stringISO8601) throws IllegalArgumentException{ + this(articleName, stringISO8601, null); + } + + public MobyDataDateTime(String articleName, String stringISO8601, Registry registry) throws IllegalArgumentException{ super(articleName); - setDataType(MobyDataType.getDataType("DateTime")); + setDataType(MobyDataType.getDataType(MobyTags.MOBYDATETIME, registry)); value = parseISO8601(stringISO8601); } @@ -56,8 +63,12 @@ } public MobyDataDateTime(String articleName, GregorianCalendar cal){ + this(articleName, cal, (Registry) null); + } + + public MobyDataDateTime(String articleName, GregorianCalendar cal, Registry registry){ super(articleName, ""); - setDataType(MobyDataType.getDataType("DateTime")); + setDataType(MobyDataType.getDataType(MobyTags.MOBYDATETIME, registry)); value = cal; } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataFloat.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataFloat.java 2006/07/07 04:12:40 1.6 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataFloat.java 2007/06/07 23:58:15 1.7 @@ -3,8 +3,10 @@ import java.math.BigDecimal; import java.math.BigInteger; +import org.biomoby.registry.meta.Registry; import org.biomoby.shared.MobyDataType; import org.biomoby.shared.MobyNamespace; +import org.biomoby.shared.parser.MobyTags; /** * A class representing a MOBY Float primitive. Note that the @@ -26,7 +28,11 @@ * @throws IllegalArgumentException if the element is not a Float tag */ public MobyDataFloat(org.w3c.dom.Element element) throws IllegalArgumentException{ - this(getName(element), getTextContents(element)); + this(element, null); + } + + public MobyDataFloat(org.w3c.dom.Element element, Registry registry) throws IllegalArgumentException{ + this(getName(element), getTextContents(element), registry); setId(getId(element)); addNamespace(getNamespace(element)); } @@ -36,8 +42,12 @@ * Float, Double, Integer, BigDecimal, etc. */ public MobyDataFloat(String articleName, Number n){ + this(articleName, n, null); + } + + public MobyDataFloat(String articleName, Number n, Registry r){ super(articleName); - setDataType(MobyDataType.getDataType("Float")); + setDataType(MobyDataType.getDataType(MobyTags.MOBYFLOAT, r)); if(n instanceof BigDecimal){ value = (BigDecimal) n; } @@ -49,8 +59,12 @@ } } + public MobyDataFloat(Number n, Registry r){ + this("", n, r); + } + public MobyDataFloat(Number n){ - this("", n); + this("", n, null); } /** @@ -58,13 +72,21 @@ * If you want to pass in a float or int, cast it to a double. */ public MobyDataFloat(String articleName, double d){ + this(articleName, d, null); + } + + public MobyDataFloat(String articleName, double d, Registry registry){ super(articleName); - setDataType(MobyDataType.getDataType("Float")); + setDataType(MobyDataType.getDataType(MobyTags.MOBYFLOAT, registry)); value = new BigDecimal(d); } + public MobyDataFloat(double d, Registry r){ + this("", d, r); + } + public MobyDataFloat(double d){ - this("", d); + this("", d, null); } /** @@ -74,13 +96,21 @@ * @throws NumberFormatException if the string does not represent a number */ public MobyDataFloat(String articleName, String stringNumber) throws NumberFormatException{ + this(articleName, stringNumber, null); + } + + public MobyDataFloat(String articleName, String stringNumber, Registry registry) throws NumberFormatException{ super(articleName); - setDataType(MobyDataType.getDataType("Float")); + setDataType(MobyDataType.getDataType(MobyTags.MOBYFLOAT, registry)); value = new BigDecimal(stringNumber); } public MobyDataFloat(String stringNumber){ - this("", stringNumber); + this("", stringNumber, null); + } + + public MobyDataFloat(String stringNumber, Registry registry){ + this("", stringNumber, registry); } public Object clone(){ @@ -315,7 +345,8 @@ public String toXML(){ MobyNamespace[] ns = getNamespaces(); if(xmlMode == MobyDataInstance.SERVICE_XML_MODE){ - return "" + value.toString() + ""; + return "<" + MobyTags.MOBYFLOAT + " " + getAttrXML() + ">" + + value.toString() + ""; } else{ return super.toXML(); =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataInt.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataInt.java 2006/07/07 04:12:40 1.5 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataInt.java 2007/06/07 23:58:15 1.6 @@ -1,7 +1,8 @@ - package org.biomoby.shared.data; +import org.biomoby.registry.meta.Registry; import org.biomoby.shared.MobyDataType; +import org.biomoby.shared.parser.MobyTags; import java.math.BigDecimal; import java.math.BigInteger; @@ -26,7 +27,11 @@ * @throws IllegalArgumentException if the element is not a Integer tag */ public MobyDataInt(org.w3c.dom.Element element) throws IllegalArgumentException{ - this(getName(element), getTextContents(element)); + this(element, null); + } + + public MobyDataInt(org.w3c.dom.Element element, Registry registry) throws IllegalArgumentException{ + this(getName(element), getTextContents(element), registry); setId(getId(element)); addNamespace(getNamespace(element)); } @@ -37,8 +42,12 @@ * Real numbers will be converted to their integer equivalents. */ public MobyDataInt(String articleName, Number n){ + this(articleName, n, null); + } + + public MobyDataInt(String articleName, Number n, Registry registry){ super(articleName); - setDataType(MobyDataType.getDataType("Integer")); + setDataType(MobyDataType.getDataType(MobyTags.MOBYINTEGER, registry)); if(n instanceof BigInteger){ value = (BigInteger) n; } @@ -51,7 +60,11 @@ } public MobyDataInt(Number n){ - this("", n); + this("", n, null); + } + + public MobyDataInt(Number n, Registry r){ + this("", n, r); } /** @@ -59,8 +72,12 @@ * If you want to pass in a float or double, cast it to an int. */ public MobyDataInt(String articleName, int i){ + this(articleName, i, null); + } + + public MobyDataInt(String articleName, int i, Registry registry){ super(articleName); - setDataType(MobyDataType.getDataType("Integer")); + setDataType(MobyDataType.getDataType(MobyTags.MOBYINTEGER, registry)); value = new BigInteger(""+i); } @@ -74,8 +91,12 @@ * @throws NumberFormatException if the string does not represent an integer number */ public MobyDataInt(String articleName, String stringNumber) throws NumberFormatException{ + this(articleName, stringNumber, null); + } + + public MobyDataInt(String articleName, String stringNumber, Registry registry) throws NumberFormatException{ super(articleName); - setDataType(MobyDataType.getDataType("Integer")); + setDataType(MobyDataType.getDataType(MobyTags.MOBYINTEGER, registry)); value = new BigInteger(stringNumber); } @@ -273,7 +294,8 @@ public String toXML(){ if(xmlMode == MobyDataInstance.SERVICE_XML_MODE){ - return "" + value.toString() + ""; + return "<" + MobyTags.MOBYINTEGER + " " + getAttrXML() + ">" + + value.toString() + ""; } else{ return super.toXML(); =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObject.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObject.java 2007/04/27 13:45:29 1.15 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObject.java 2007/06/07 23:58:15 1.16 @@ -16,6 +16,7 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; +import org.biomoby.registry.meta.Registry; import org.biomoby.shared.*; import org.biomoby.shared.parser.MobyTags; @@ -44,7 +45,11 @@ * @throws MobyException if the element is not an Object tag, or is missing a required attribute */ public MobyDataObject(Element element) throws MobyException{ - this(getNamespace(element).getName(), getId(element)); + this(element, null); + } + + public MobyDataObject(Element element, Registry registry) throws MobyException{ + this(getNamespace(element).getName(), getId(element), registry); setName(getName(element)); } @@ -53,16 +58,24 @@ * Instance information can be filled out later with setId() and setNamespace(). */ public MobyDataObject(String name){ + this(name, (Registry) null); + } + + public MobyDataObject(String name, Registry registry){ super(name); - setDataType(MobyDataType.getDataType(MobyTags.MOBYOBJECT)); + setDataType(MobyDataType.getDataType(MobyTags.MOBYOBJECT, registry)); } /** * Constructor convenient for a base object with a namespace and ID. */ public MobyDataObject(String namespace, String id){ + this(namespace, id, null); + } + + public MobyDataObject(String namespace, String id, Registry registry){ super(""); - setDataType(MobyDataType.getDataType(MobyTags.MOBYOBJECT)); + setDataType(MobyDataType.getDataType(MobyTags.MOBYOBJECT, registry)); setId(id); MobyNamespace nsObj = MobyNamespace.getNamespace(namespace); @@ -91,30 +104,34 @@ * @throws MobyException if the requested datatype is not a primtive, or the value could not be used for that data type (e.g an integer out of the string "Bar") */ public static MobyDataObject createInstanceFromString(String typeName, String value) throws MobyException{ + return createInstanceFromString(typeName, value, null); + } + + public static MobyDataObject createInstanceFromString(String typeName, String value, Registry registry) throws MobyException{ if(typeName == null){ return null; } if(MobyTags.MOBYOBJECT.equals(typeName)){ - return new MobyDataObject("", value); + return new MobyDataObject("", value, registry); } else if(MobyTags.MOBYINTEGER.equals(typeName)){ - return new MobyDataInt("", value); + return new MobyDataInt("", value, registry); } else if(MobyTags.MOBYFLOAT.equals(typeName)){ - return new MobyDataFloat("", value); + return new MobyDataFloat("", value, registry); } else if(MobyTags.MOBYSTRING.equals(typeName)){ - return new MobyDataString("", value); + return new MobyDataString("", value, registry); } else if(MobyTags.MOBYBOOLEAN.equals(typeName)){ - return new MobyDataBoolean("", value); + return new MobyDataBoolean("", value, registry); } else if(MobyTags.MOBYDATETIME.equals(typeName)){ - return new MobyDataDateTime("", value); + return new MobyDataDateTime("", value, registry); } else{ - MobyDataType type = MobyDataType.getDataType(typeName); + MobyDataType type = MobyDataType.getDataType(typeName, registry); if(type != null && type.inheritsFrom(MobyDataBytes.BASE64_DATATYPE)){ return new MobyDataBytes("", value, type); } @@ -134,6 +151,10 @@ * @param objectTag the W3C DOM Element node corresponding to the object's enclosing tag, or a Simple tag */ public static MobyDataInstance createInstanceFromDOM(Element objectTag) throws MobyException{ + return createInstanceFromDOM(objectTag, null); + } + + public static MobyDataInstance createInstanceFromDOM(Element objectTag, Registry registry) throws MobyException{ MobyDataObject object = null; if(objectTag == null){ @@ -156,38 +177,38 @@ // There are six types of objects we can populate with data directly // plus Collections and Secondary Parameters. Otherwise it is a composite. else if(MobyTags.MOBYOBJECT.equals(objectClass)){ - return new MobyDataObject(objectTag); + return new MobyDataObject(objectTag, registry); } else if(MobyTags.MOBYINTEGER.equals(objectClass)){ - return new MobyDataInt(objectTag); + return new MobyDataInt(objectTag, registry); } else if(MobyTags.MOBYFLOAT.equals(objectClass)){ - return new MobyDataFloat(objectTag); + return new MobyDataFloat(objectTag, registry); } else if(MobyTags.MOBYSTRING.equals(objectClass)){ - return new MobyDataString(objectTag); + return new MobyDataString(objectTag, registry); } else if(MobyTags.MOBYBOOLEAN.equals(objectClass)){ - return new MobyDataBoolean(objectTag); + return new MobyDataBoolean(objectTag, registry); } else if(MobyTags.MOBYDATETIME.equals(objectClass)){ - return new MobyDataDateTime(objectTag); + return new MobyDataDateTime(objectTag, registry); } else if(MobyTags.COLLECTION.equals(objectClass)){ - return new MobyDataObjectSet(objectTag); + return new MobyDataObjectSet(objectTag, registry); } else if(MobyDataSecondaryInstance.ELEMENT_NAME.equals(objectClass)){ return new MobyDataSecondaryInstance(objectTag); } // Must otherwise be a composite else{ - MobyDataType type = MobyDataType.getDataType(objectClass); + MobyDataType type = MobyDataType.getDataType(objectClass, registry); // Treat base64-encoded binary data as a special case, as we have a convenience class for it if(type != null && type.inheritsFrom(MobyDataType.getDataType(MobyDataBytes.BASE64_DATATYPE))){ - return new MobyDataBytes(objectTag); + return new MobyDataBytes(objectTag, registry); } else{ - return new MobyDataComposite(objectTag); + return new MobyDataComposite(objectTag, registry); } } } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectSet.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectSet.java 2007/04/26 15:06:15 1.7 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectSet.java 2007/06/07 23:58:15 1.8 @@ -1,19 +1,10 @@ package org.biomoby.shared.data; -import java.util.Arrays; -import java.util.Collection; -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.Vector; - -import org.biomoby.shared.MobyDataType; -import org.biomoby.shared.MobyException; -import org.biomoby.shared.MobyNamespace; -import org.biomoby.shared.MobyPrimaryData; -import org.biomoby.shared.MobyPrimaryDataSet; -import org.biomoby.shared.MobyPrimaryDataSimple; -import org.biomoby.shared.MobyPrefixResolver; +import java.util.*; + +import org.biomoby.registry.meta.Registry; +import org.biomoby.shared.*; +import org.biomoby.shared.parser.MobyTags; /** * This class adds to MobyPrimaryDataSet the ability to get and set instantiated MOBY objects. @@ -33,7 +24,11 @@ private int xmlMode = MobyDataInstance.CENTRAL_XML_MODE; public MobyDataObjectSet(org.w3c.dom.Element e) throws MobyException{ - this(MobyDataObject.getName(e), getChildren(e)); + this(e, null); + } + + public MobyDataObjectSet(org.w3c.dom.Element e, Registry registry) throws MobyException{ + this(MobyDataObject.getName(e), getChildren(e, registry)); if(getName() == null){ throw new MobyException("Anonymous collections are not allowed (need articleName), input was :\n" + e); @@ -41,13 +36,13 @@ } - public static Collection getChildren(org.w3c.dom.Element e) throws MobyException{ + public static Collection getChildren(org.w3c.dom.Element e, Registry registry) throws MobyException{ Vector members = new Vector(); org.w3c.dom.NodeList children = MobyPrefixResolver.getChildElements(e, "*"); // wildcard int numChildren = children.getLength(); for(int i = 0; i < numChildren; i++){ - members.add(MobyDataObject.createInstanceFromDOM((org.w3c.dom.Element) children.item(i))); + members.add(MobyDataObject.createInstanceFromDOM((org.w3c.dom.Element) children.item(i), registry)); } return members; } @@ -516,39 +511,46 @@ StringBuffer collectionXml = new StringBuffer(); if(xmlMode == MobyDataInstance.SERVICE_XML_MODE){ - collectionXml.append("\n"); for(MobyDataObject mdsi: bag){ mdsi.setXmlMode(xmlMode); - collectionXml.append(""+mdsi.toXML()+""); + collectionXml.append("<"+MobyTags.SIMPLE+">"+mdsi.toXML()+""); } - collectionXml.append("\n\n"); + collectionXml.append("\n\n"); } // Otherwise it's MOBY Central query mode // We need to find out what object classes are present in the array, and // enumerate them (the types, not the instances). else{ - collectionXml.append("\n"); - Hashtable printed = new Hashtable(); - - for(MobyDataObject mdsi: bag){ - // Could the DataType be null? I hope not! - String objectClass = mdsi.getDataType().getName(); + collectionXml.append("<"+MobyTags.COLLECTION+">\n"); - // A new data type for the collection? - if(!printed.containsKey(objectClass)){ - mdsi.setXmlMode(xmlMode); + MobyDataObject commonDataTemplate = new MobyDataObject(""); + commonDataTemplate.setDataType(getDataType()); + commonDataTemplate.setNamespaces(getNamespaces()); + collectionXml.append(commonDataTemplate.toXML()); + + // Hashtable printed = new Hashtable(); +// for(MobyDataObject mdsi: bag){ +// // Could the DataType be null? I hope not! +// String objectClass = mdsi.getDataType().getName(); + +// // A new data type for the collection? Note to self (Paul), this doesn't seem right, should have one type only ...since the 0.86 spec +// if(!printed.containsKey(objectClass)){ +// mdsi.setXmlMode(xmlMode); - collectionXml.append(mdsi.toXML()); +// collectionXml.append(mdsi.toXML()); - printed.put(objectClass, "printed object type in MOBY central input collection"); - } - } - collectionXml.append("\n"); +// printed.put(objectClass, "printed object type in MOBY central input collection"); +// } +// } + + + collectionXml.append("\n"); } return collectionXml.toString(); =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataString.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataString.java 2006/07/07 04:12:40 1.5 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataString.java 2007/06/07 23:58:15 1.6 @@ -1,7 +1,9 @@ - package org.biomoby.shared.data; + +import org.biomoby.registry.meta.Registry; import org.biomoby.shared.MobyDataType; import org.biomoby.shared.MobyNamespace; +import org.biomoby.shared.parser.MobyTags; /** * A class representing a MOBY String primitive. @@ -21,7 +23,11 @@ * @throws IllegalArgumentException if the element is not a String tag */ public MobyDataString(org.w3c.dom.Element element) throws IllegalArgumentException{ - this(getName(element), getTextContents(element)); + this(element, null); + } + + public MobyDataString(org.w3c.dom.Element element, Registry registry) throws IllegalArgumentException{ + this(getName(element), getTextContents(element), registry); setId(getId(element)); addNamespace(getNamespace(element)); } @@ -31,13 +37,21 @@ * (i.e. String, StringBuffer, CharBuffer or StringBuilder). */ public MobyDataString(String articleName, CharSequence stringValue){ + this(articleName, stringValue, null); + } + + public MobyDataString(String articleName, CharSequence stringValue, Registry registry){ super(articleName); - setDataType(MobyDataType.getDataType("String")); + setDataType(MobyDataType.getDataType(MobyTags.MOBYSTRING, registry)); value = new StringBuffer(stringValue.toString()); } public MobyDataString(CharSequence stringValue){ - this("", stringValue); + this("", stringValue, null); + } + + public MobyDataString(CharSequence stringValue, Registry registry){ + this("", stringValue, registry); } public String toString(){ @@ -89,8 +103,9 @@ tmpValue = ""; } - return "" + tmpValue + ""; - } + return "<" + MobyTags.MOBYSTRING + " "+ getAttrXML() + " xml:space=\"preserve\">" + + tmpValue + ""; + } // Central mode, use default toXML provided by superclasses else{ return super.toXML(); =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataUtils.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataUtils.java 2007/03/29 19:40:52 1.6 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataUtils.java 2007/06/07 23:58:15 1.7 @@ -1,5 +1,6 @@ package org.biomoby.shared.data; +import org.biomoby.registry.meta.Registry; import org.biomoby.shared.parser.MobyTags; import org.biomoby.shared.*; import org.xml.sax.InputSource; @@ -59,7 +60,11 @@ * Create a MOBY Java object representation from a MOBY XML payload stored in a String. */ public static MobyContentInstance fromXMLDocument(String xmlData) throws Exception{ - return fromXMLDocument(new StringReader(xmlData)); + return fromXMLDocument(new StringReader(xmlData), null); + } + + public static MobyContentInstance fromXMLDocument(String xmlData, Registry registry) throws Exception{ + return fromXMLDocument(new StringReader(xmlData), registry); } /** @@ -67,6 +72,10 @@ * (a byte stream that will becoverted by the parser into character data). */ public static MobyContentInstance fromXMLDocument(InputStream is) throws Exception{ + return fromXMLDocument(is, null); + } + + public static MobyContentInstance fromXMLDocument(InputStream is, Registry registry) throws Exception{ // Load an XML document javax.xml.parsers.DocumentBuilder docBuilder = null; try{ @@ -91,13 +100,17 @@ // Select a node from the document and see if any of the mappings // work out, in which case we can check what services we can run Element doc_root = domDoc.getDocumentElement(); - return fromXMLDocument(doc_root); + return fromXMLDocument(doc_root, registry); } /** * Create a MOBY Java object representation from a MOBY XML payload at the given URL. */ public static MobyContentInstance fromXMLDocument(java.net.URL url) throws Exception{ + return fromXMLDocument(url, null); + } + + public static MobyContentInstance fromXMLDocument(java.net.URL url, Registry registry) throws Exception{ // Load an XML document javax.xml.parsers.DocumentBuilder docBuilder = null; try{ @@ -122,13 +135,17 @@ // Select a node from the document and see if any of the mappings // work out, in which case we can check what services we can run Element doc_root = domDoc.getDocumentElement(); - return fromXMLDocument(doc_root); + return fromXMLDocument(doc_root, registry); } /** * Create a MOBY Java object representation from a MOBY XML payload coming from a Reader (character data). */ public static MobyContentInstance fromXMLDocument(Reader reader) throws Exception{ + return fromXMLDocument(reader, null); + } + + public static MobyContentInstance fromXMLDocument(Reader reader, Registry registry) throws Exception{ // Load an XML document javax.xml.parsers.DocumentBuilder docBuilder = null; try{ @@ -153,7 +170,7 @@ // Select a node from the document and see if any of the mappings // work out, in which case we can check what services we can run Element doc_root = domDoc.getDocumentElement(); - return fromXMLDocument(doc_root); + return fromXMLDocument(doc_root, registry); } @@ -163,6 +180,16 @@ * @param doc_root the document's base MOBY tag */ public static MobyContentInstance fromXMLDocument(Element doc_root) throws Exception{ + return fromXMLDocument(doc_root, null); + } + + /** + * Create a MOBY Java object representation from a MOBY XML payload represented in a DOM. + * + * @param doc_root the document's base MOBY tag + * @param registry the Mony Central from which to retrieve the data type definitions, uses default registry if null + */ + public static MobyContentInstance fromXMLDocument(Element doc_root, Registry registry) throws Exception{ if(doc_root == null){ throw new MobyException("The passed in element was null"); } @@ -204,7 +231,7 @@ MobyPrefixResolver.MOBY_XML_NAMESPACE); } - MobyContentInstance contents = new MobyContentInstance((Element) envelope.item(0)); + MobyContentInstance contents = new MobyContentInstance((Element) envelope.item(0), registry); return contents; } From carrere at dev.open-bio.org Wed Jun 20 08:36:27 2007 From: carrere at dev.open-bio.org (Sebastien Carrere) Date: Wed, 20 Jun 2007 12:36:27 -0000 Subject: [MOBY-guts] biomoby commit Message-ID: <200706201236.l5KCaOOd019077@dev.open-bio.org> carrere Wed Jun 20 08:36:24 EDT 2007 Update of /home/repository/moby/moby-live/Perl/MOBY/xsl In directory dev.open-bio.org:/tmp/cvs-serv19023/xsl Modified Files: parseMobyMessage.xsl Log Message: Exceptions are now parsed moby-live/Perl/MOBY/xsl parseMobyMessage.xsl,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/xsl/parseMobyMessage.xsl,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Perl/MOBY/xsl/parseMobyMessage.xsl 2005/10/24 11:47:03 1.2 +++ /home/repository/moby/moby-live/Perl/MOBY/xsl/parseMobyMessage.xsl 2007/06/20 12:36:24 1.3 @@ -11,11 +11,8 @@ - #XSL_LIPM_MOBYPARSER_SERVICENOTES# - - #XSL_LIPM_MOBYPARSER_SERVICENOTES# - - + + @@ -221,12 +218,20 @@ #XSL_LIPM_MOBYPARSER_OBJECTCONTENT# - + + + + + + + + #XSL_LIPM_MOBYPARSER_OBJECTCONTENT# - + + @@ -250,6 +259,35 @@ + + + + + + + + + + + + + + + #XSL_LIPM_MOBYPARSER_OBJECTHASA_START# + + + + #XSL_LIPM_MOBYPARSER_OBJECTHASA_END# + + + + + + @@ -279,4 +317,159 @@ + + + + + + + + #XSL_LIPM_MOBYPARSER_PIB_START# + + + + + #XSL_LIPM_MOBYPARSER_SOFTWARE_START# + + #XSL_LIPM_MOBYPARSER_SOFTWARE_SEP# + + #XSL_LIPM_MOBYPARSER_SOFTWARE_SEP# + + #XSL_LIPM_MOBYPARSER_SOFTWARE_END# + + + + + + #XSL_LIPM_MOBYPARSER_DATABASE_START# + + #XSL_LIPM_MOBYPARSER_DATABASE_SEP# + + #XSL_LIPM_MOBYPARSER_DATABASE_SEP# + + #XSL_LIPM_MOBYPARSER_DATABASE_END# + + + + #XSL_LIPM_MOBYPARSER_COMMENT_START# + + #XSL_LIPM_MOBYPARSER_COMMENT_END# + + #XSL_LIPM_MOBYPARSER_PIB_END# + + + + + + + + + + + #XSL_LIPM_MOBYPARSER_SERVICENOTES# + + #XSL_LIPM_MOBYPARSER_SERVICENOTES_NOTES_START# + + #XSL_LIPM_MOBYPARSER_SERVICENOTES_NOTES_END# + + + + + + + + + + #XSL_LIPM_MOBYPARSER_SERVICENOTES# + + + + + + + + #XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_START# + + #XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_REFELEMENT_START# + + + + + + + + + #XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_REFELEMENT_END# + + #XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_REFQUERYID_START# + + + + + + + + + #XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_REFQUERYID_END# + + + #XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_SEVERITY_START# + + + + + + + + + #XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_SEVERITY_END# + + + + + #XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_CODE_START# + + #XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_CODE_END# + + + #XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_MESSAGE_START# + + #XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_MESSAGE_END# + + + #XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_END# + + + + + + + + #XSL_LIPM_MOBYPARSER_SERVICENOTES_NOTES_START# + + #XSL_LIPM_MOBYPARSER_SERVICENOTES_NOTES_END# + + + + From carrere at dev.open-bio.org Wed Jun 20 08:36:32 2007 From: carrere at dev.open-bio.org (Sebastien Carrere) Date: Wed, 20 Jun 2007 12:36:32 -0000 Subject: [MOBY-guts] biomoby commit Message-ID: <200706201236.l5KCaOKn019059@dev.open-bio.org> carrere Wed Jun 20 08:36:24 EDT 2007 Update of /home/repository/moby/moby-live/Perl/MOBY In directory dev.open-bio.org:/tmp/cvs-serv19023 Modified Files: MOBYXSLT.pm Log Message: Exceptions are now parsed moby-live/Perl/MOBY MOBYXSLT.pm,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/MOBYXSLT.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Perl/MOBY/MOBYXSLT.pm 2005/12/15 14:03:41 1.4 +++ /home/repository/moby/moby-live/Perl/MOBY/MOBYXSLT.pm 2007/06/20 12:36:23 1.5 @@ -2,7 +2,7 @@ my $TMP_DIR = '/tmp/';#Where your temporary files will be written my $XSLTPROC = '/usr/bin/xsltproc';#Where your xsltproc binary is located -my $XSL_SHEET = '/bioinfo/www/bioinfo/services/biomoby/cgi-bin/Services/LIPM/lib/parseMobyMessage.xsl';#Where your xsltproc style-sheet is located +my $XSL_SHEET = 'xsl/parseMobyMessage.xsl';#Where your xsltproc style-sheet is located #$Id$ @@ -150,21 +150,23 @@ my $parsed_message = `$XSLTPROC $XSL_SHEET $TMP_DIR$tmp_file`; -# open (PARSED, ">$TMP_DIR$tmp_file" . ".xsl"); -# print PARSED "$XSLTPROC $XSL_SHEET $TMP_DIR$tmp_file\n\n\n"; -# print PARSED "$parsed_message"; -# close PARSED; - + + my $servicenotes = ''; + my $ra_exceptions = (); my @a_queries = (); my $servicenotes_tag = '#XSL_LIPM_MOBYPARSER_SERVICENOTES#'; - - if ($parsed_message =~ /$servicenotes_tag(.+)$servicenotes_tag/) + $parsed_message =~ s/\n/__nl__/g; + if ($parsed_message =~ /$servicenotes_tag(.*)$servicenotes_tag/) { - ($servicenotes) = ($parsed_message =~ /$servicenotes_tag(.+)$servicenotes_tag/); + my $notes = $1; + + ($servicenotes,$ra_exceptions) = _AnalyseServiceNotes($notes); + #($servicenotes) = ($parsed_message =~ /$servicenotes_tag(.+)$servicenotes_tag/); } - + $parsed_message =~ s/__nl__/\n/g; + my $mobydata_tag = '#XSL_LIPM_MOBYPARSER_DATA_START#'; my ($header, @a_mobydata_blocs) = split($mobydata_tag, $parsed_message); @@ -239,7 +241,7 @@ } unlink("$TMP_DIR$tmp_file"); - return ($servicenotes, \@a_queries); + return ($servicenotes, \@a_queries, $ra_exceptions); } =head2 function getInputID @@ -322,14 +324,71 @@ { my $rh_simple_article = shift(); - if ($rh_simple_article->{'object_crossreference'} ne '') + if (defined $rh_simple_article->{'article_objects'}) { - return (@{$rh_simple_article->{'object_crossreference'}}); + if ($rh_simple_article->{'article_objects'}->{'object_crossreference'} ne '') + { + return (@{$rh_simple_article->{'article_objects'}->{'object_crossreference'}}); + } + else + { + return (); + } } else { - return (); + if ($rh_simple_article->{'object_crossreference'} ne '') + { + return @{$rh_simple_article->{'object_crossreference'}}; + } + else + { + return (); + } } + +} + +=head2 function getProvisionInformation + + Title : getProvisionInformation + Usage : my @a_pib =getProvisionInformation($rh_simple_article); + Prerequisite : + Function : Takes a simple article structure (from getArticles or getCollectedSimples) + and retrieve the list of Provision Information HASHREF + Returns : @a_pib: ARRAY of provisionInformation HASHREF + Args : $rh_simple_article: simple article HASHREF structure from getArticles or getCollectedSimples + Globals : none + +=cut + +sub getProvisionInformation +{ + my $rh_simple_article = shift(); + + if (defined $rh_simple_article->{'article_objects'}) + { + if ($rh_simple_article->{'article_objects'}->{'object_pib'} ne '') + { + return (@{$rh_simple_article->{'article_objects'}->{'object_pib'}}); + } + else + { + return (); + } + } + else + { + if ($rh_simple_article->{'object_pib'} ne '') + { + return @{$rh_simple_article->{'object_pib'}}; + } + else + { + return (); + } + } + } =head2 function getObjectHasaElements @@ -733,6 +792,7 @@ { my $simple_bloc = shift(); my @a_crossref = (); + my @a_pib = (); my @a_hasa = (); my ($object_type,$object_name,$object_id,$object_namespace) = ('','','',''); @@ -771,7 +831,8 @@ while ($simple_bloc =~ m/$crossref_start_tag(.*)$crossref_sep_tag(.*)$crossref_sep_tag(.*)$crossref_end_tag/g) { - my %h_crossref = ('type' => $1, 'id' => $2, 'namespace' => $3); + my %h_crossref = ('type' => $1, 'id' => $2, 'namespace' => $3); + $simple_bloc =~ s/$crossref_start_tag$1$crossref_sep_tag$2$crossref_sep_tag$3$crossref_end_tag//; push(@a_crossref, \%h_crossref); } @@ -781,16 +842,96 @@ $ra_crossref = ''; } + #19/12/2005 + #Provision Information Block + + my $pib_start_tag = '#XSL_LIPM_MOBYPARSER_PIB_START#'; + my $pib_end_tag = '#XSL_LIPM_MOBYPARSER_PIB_END#'; + my $pib_software_start_tag = '#XSL_LIPM_MOBYPARSER_SOFTWARE_START#'; + my $pib_software_end_tag = '#XSL_LIPM_MOBYPARSER_SOFTWARE_END#'; + my $pib_software_sep_tag = '#XSL_LIPM_MOBYPARSER_SOFTWARE_SEP#'; + my $pib_database_start_tag = '#XSL_LIPM_MOBYPARSER_DATABASE_START#'; + my $pib_database_end_tag = '#XSL_LIPM_MOBYPARSER_DATABASE_END#'; + my $pib_database_sep_tag = '#XSL_LIPM_MOBYPARSER_DATABASE_SEP#'; + my $pib_comment_start_tag = '#XSL_LIPM_MOBYPARSER_COMMENT_START#'; + my $pib_comment_end_tag = '#XSL_LIPM_MOBYPARSER_COMMENT_END#'; + + + while ($simple_bloc =~ m/$pib_start_tag(.*)$pib_end_tag/g) + { + my $provision_block = $1; + $simple_bloc =~ s/$pib_start_tag$provision_block$pib_end_tag//; + my ($software_name,$software_version,$software_comment) = ('','',''); + if ($provision_block =~ /$pib_software_start_tag(.*)$pib_software_end_tag/) + { + ($software_name,$software_version,$software_comment) = split (/$pib_software_sep_tag/,$1); + } + my ($database_name,$database_version,$database_comment) = ('','',''); + if ($provision_block =~ /$pib_database_start_tag(.*)$pib_database_end_tag/) + { + ($database_name,$database_version,$database_comment) = split (/$pib_database_sep_tag/,$1); + } + my ($service_comment) = (''); + if ($provision_block =~ /$pib_comment_start_tag(.*)$pib_comment_end_tag/) + { + ($service_comment) = ($1); + } + + my %h_pib = ( + 'software_name' => $software_name, + 'software_version' => $software_version, + 'software_comment' => $software_comment, + 'database_name' => $database_name, + 'database_version' => $database_version, + 'database_comment' => $database_comment, + 'service_comment' => $service_comment + ); + + open (TMP, ">>/tmp/pib.txt"); + print TMP < $software_name, +'software_version' => $software_version, +'software_comment' => $software_comment, +'database_name' => $database_name, +'database_version' => $database_version, +'database_comment' => $database_comment, +'service_comment' => $service_comment +END + close TMP; + chmod 0777, "/tmp/pib.txt"; + + push(@a_pib, \%h_pib); + } + + my $ra_pib = \@a_pib; + if ($#a_pib < 0) + { + $ra_pib = ''; + } + + + + + my $object_content_tag = '#XSL_LIPM_MOBYPARSER_OBJECTCONTENT#'; my ($before, $object_content, $after) = ('','',''); ($before, $object_content, $after) = split($object_content_tag, $simple_bloc); - my $object_hasa_start_tag = '#XSL_LIPM_MOBYPARSER_OBJECTHASA_START#'; + #Sebastien 21/12/2005 + # + $object_content =~ s/^\s+//g; + $object_content =~ s/\s+$//g; + # + + my $object_hasa_start_tag = '#XSL_LIPM_MOBYPARSER_OBJECTHASA_START#'; if ($simple_bloc =~ /$object_hasa_start_tag/) { my (@a_hasa_blocs) = split($object_hasa_start_tag, $simple_bloc); + #Sebastien 19/12/2005 + #le premier est le pere + #shift @a_hasa_blocs; foreach my $hasa_bloc (@a_hasa_blocs) { if ($hasa_bloc ne '') @@ -828,6 +969,7 @@ 'object_content' => $object_content, 'object_xml' => $object_xml, 'object_crossreference' => $ra_crossref, + 'object_pib' => $ra_pib, 'object_hasa' => $ra_hasa ); @@ -943,45 +1085,166 @@ } } + +=head2 complexResponse (stolen from MOBY::CommonSubs) + + name : complexResponse + function : wraps a set of articles in the one mobyData structure + usage : return responseHeader . &complexResponse(\@a_article_structures, $queryID) . responseFooter; + args : (in order) + \@a_article_structures - (optional) a listref of structured articles + %h_article = ( + article_type => 'collection/simple', + article_content => 'MOBY XML formatted content', + article_name => 'articleName attribut') + $queryID - (optional, but strongly recommended) the mobyData ID + to which you are responding +=cut + + +sub complexResponse +{ + my ($ra_data, $qID) = @_; + + $ra_data ||= []; + $qID ||= ''; + unless ((ref($ra_data) =~ /array/i) && $ra_data->[0]) + { # we're expecting an arrayref as input data,and it must not be empty + return ""; + } + my $moby_data_content = ''; + foreach my $rh_data_block (@{$ra_data}) + { + my $article_name = $rh_data_block->{article_name}; + my $article_content = $rh_data_block->{article_content}; + + if ($rh_data_block->{article_type} =~ /collection/i) + { + my $collection_content = "\n"; + if ((ref($article_content) =~ /array/i) && $article_content->[0]) + { + foreach my $simple_element (@{$article_content}) + { + $collection_content .= "\t\n\t$simple_element\n\t\n"; + } + } + else + { + $collection_content .= "\t\n"; + } + $collection_content .= "\n"; + + $moby_data_content .= $collection_content; + + } + else + { + my $simple_content = "\n\t$article_content\n"; + $moby_data_content .= $simple_content; + } + } + + return "\n\t$moby_data_content\n\n"; +} + + =head2 responseHeader (stolen from MOBY::CommonSubs) - name : responseHeader - function : print the XML string of a MOBY response header +/- serviceNotes - usage : responseHeader('illuminae.com') - responseHeader( +B print the XML string of a MOBY response header +/- serviceNotes +/- Exceptions + +B + + responseHeader('illuminae.com') + + responseHeader( -authority => 'illuminae.com', - -note => 'here is some data from the service provider') - args : a string representing the service providers authority URI, - OR a set of named arguments with the authority and the - service provision notes. - caveat : - notes : returns everything required up to the response articles themselves. - i.e. something like: + -note => 'here is some data from the service provider' + -exception=>'an xml encoded exception string') + + +B a string representing the service providers authority URI, OR +a set of named arguments with the authority and the service provision +notes which can include already xml encoded exceptions + +B< caveat :> + +B returns everything required up to the response articles themselves. i.e. something like: + - =cut -sub responseHeader -{ - use HTML::Entities (); - my ($auth, $notes) = &_rearrange([qw[AUTHORITY NOTE]], @_); - $auth ||= "not_provided"; - $notes ||= ""; - my $xml = - "" - . "" - . ""; - if ($notes) - { - my $encodednotes = HTML::Entities::encode($notes); - $xml .= "$encodednotes"; +sub responseHeader { + use HTML::Entities (); + my ( $auth, $notes, $exception ) = _rearrange( [qw[AUTHORITY NOTE EXCEPTION]], @_ ); + $auth ||= "not_provided"; + $notes ||= ""; + $exception ||=""; + my $xml = + "" + . "" + . ""; + if ($exception) { + $xml .= "$exception"; + if ( $notes ) { + my $encodednotes = HTML::Entities::encode( $notes ); + $xml .= "$encodednotes"; } - return $xml; + $xml .=""; + } + + elsif ( $notes ) { + my $encodednotes = HTML::Entities::encode( $notes ); + $xml .= "$encodednotes"; + } + return $xml; +} + + +=head2 encodeException (stolen from MOBY::CommonSubs) + +B wraps a Biomoby Exception with all its parameters into the appropiate MobyData structure + +B + + encodeException( + -refElement => 'refers to the queryID of the offending input mobyData', + -refQueryID => 'refers to the articleName of the offending input Simple or Collection' + -severity=>'error' + -exceptionCode=>'An error code ' + -exceptionMessage=>'a human readable description for the error code') + +Bthe different arguments required by the mobyException API + severity can be either error, warning or information + valid error codes are decribed on the biomoby website + + +B returns everything required to use for the responseHeader: + + + 600 + Unable to execute the service + + +=cut + +sub encodeException{ + use HTML::Entities (); + my ( $refElement, $refQueryID, $severity, $code, $message ) = _rearrange( [qw[REFELEMENT REFQUERYID SEVERITY EXCEPTIONCODE EXCEPTIONMESSAGE]], @_ ); + $refElement ||= ""; + defined($refQueryID) || ($refQueryID= ""); + $severity ||= ""; + defined($code) || ($code = ""); + $message ||= "not provided"; + my $xml="". + "$code". + "".HTML::Entities::encode($message)."". + ""; } + =head2 responseFooter (stolen from MOBY::CommonSubs) name : responseFooter @@ -1110,4 +1373,110 @@ return @param{@$order}; } + +=head2 function _AnalyseServiceNotes + + Title : _AnalyseServiceNotes + Usage : _AnalyseServiceNotes($simple_bloc) + Prerequisite : + Function : Analyse a "Simple Bloc" from XSL transformation parsing + Build a $rh_simple_article structure with fields: + 'object_name' => moby:articleName + 'object_type' => moby:Class + 'object_namespace' => moby:namespace + 'object_id' => moby:id + 'object_content' => text content of simple article + 'object_xml' => full xml content of article + 'object_hasa' => ARRAYREF of hasa elements + (each one is structured in a same + structured hash (recursivity) + 'object_crossreference' => ARRAYREF of crossreferences objects + (each one is structured in a hash with fields + 'type', 'id', 'namespace') + + Returns : $services_notes: article HASHREF + $ra_exceptions: article HASHREF + Args : $service_notes_bloc: from parsing of a "serviceNotes" XSLT transformation + Globals : none + +=cut + +sub _AnalyseServiceNotes +{ + my $service_notes_block = shift(); + my @a_exceptions = (); + my $service_notes = ''; + + + my $exception_start_tag = '#XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_START#'; + my $exception_end_tag = '#XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_END#'; + my $exception_refelement_start_tag = '#XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_REFELEMENT_START#'; + my $exception_refelement_end_tag = '#XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_REFELEMENT_END#'; + my $exception_refqueryid_start_tag = '#XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_REFQUERYID_START#'; + my $exception_refqueryid_end_tag = '#XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_REFQUERYID_END#'; + my $exception_severity_start_tag = '#XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_SEVERITY_START#'; + my $exception_severity_end_tag = '#XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_SEVERITY_END#'; + my $exception_code_start_tag = '#XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_CODE_START#'; + my $exception_code_end_tag = '#XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_CODE_END#'; + my $exception_message_start_tag = '#XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_MESSAGE_START#'; + my $exception_message_end_tag = '#XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_MESSAGE_END#'; + + + while ($service_notes_block =~ m/$exception_start_tag(.*)$exception_end_tag/g) + { + my $exception_block = $1; + my ($refelement,$refqueryid,$severity,$code,$message) = ('','','','',''); + if ($exception_block =~ /$exception_refelement_start_tag(.*)$exception_refelement_end_tag/) + { + $refelement = $1; + } + if ($exception_block =~ /$exception_refqueryid_start_tag(.*)$exception_refqueryid_end_tag/) + { + $refqueryid = $1; + } + if ($exception_block =~ /$exception_severity_start_tag(.*)$exception_severity_end_tag/) + { + $severity = $1; + } + if ($exception_block =~ /$exception_code_start_tag(.*)$exception_code_end_tag/) + { + $code = $1; + } + if ($exception_block =~ /$exception_message_start_tag(.*)$exception_message_end_tag/) + { + $message = $1; + $message =~ s/__nl__/\n/g; + + } + + my %h_exception = ( + 'refelement' => $refelement, + 'refqueryid' => $refqueryid, + 'severity' => $severity, + 'code' => $code, + 'message' => $message + ); + + + push(@a_exceptions, \%h_exception); + } + my $ra_exceptions = \@a_exceptions; + if ($#a_exceptions < 0) + { + $ra_exceptions = ''; + } + + + my $notes_start_tag = '#XSL_LIPM_MOBYPARSER_SERVICENOTES_NOTES_START#'; + my $notes_end_tag = '#XSL_LIPM_MOBYPARSER_SERVICENOTES_NOTES_END#'; + + if ($service_notes_block =~ /$notes_start_tag(.*)$notes_end_tag/) + { + $service_notes = $1; + } + + return ($service_notes,$ra_exceptions); +} + + 1; From kawas at dev.open-bio.org Fri Jun 1 13:01:16 2007 From: kawas at dev.open-bio.org (Eddie Kawas) Date: Fri, 1 Jun 2007 09:01:16 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706011301.l51D1GZ5007989@dev.open-bio.org> kawas Fri Jun 1 09:01:15 EDT 2007 Update of /home/repository/moby/moby-live/Perl/MOBY In directory dev.open-bio.org:/tmp/cvs-serv7954 Modified Files: Central.pm Log Message: fixed the embedded cdata bug found by irri what happened was that in the message child of a registration element, we try to let the user know why the rdf was bad. Unfortunately, it was wrapped in a CDATA element. Now it isnt. moby-live/Perl/MOBY Central.pm,1.282,1.283 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.282 retrieving revision 1.283 diff -u -r1.282 -r1.283 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2007/02/20 01:02:01 1.282 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2007/06/01 13:01:15 1.283 @@ -1447,8 +1447,9 @@ "Registration successful but RDF is not correctly formatted:\n\n $RDF", $SVC->lsid, "" ); } + # wrap RDF in CDATA - moved it here, so that we can return the 'bad' rdf above return &_success( "Registration successful", $SVC->lsid, - $RDF ); + "" ); } sub _getServiceInstanceRDF { @@ -1467,7 +1468,9 @@ my $response = $browser->get($url); if ($response) { my $rdfXML = $response->content; - return "" unless ( $rdfXML =~ /title>Service Instance Not FoundService Instance Not Found kawas Thu Jun 7 10:26:46 EDT 2007 Update of /home/repository/moby/moby-live/Docs/MOBY-S_API In directory dev.open-bio.org:/tmp/cvs-serv23214/MOBY-S_API Modified Files: XMLPayloads.html Log Message: retrieveService end element was missing a '/' moby-live/Docs/MOBY-S_API XMLPayloads.html,1.18,1.19 =================================================================== RCS file: /home/repository/moby/moby-live/Docs/MOBY-S_API/XMLPayloads.html,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- /home/repository/moby/moby-live/Docs/MOBY-S_API/XMLPayloads.html 2007/02/05 14:30:46 1.18 +++ /home/repository/moby/moby-live/Docs/MOBY-S_API/XMLPayloads.html 2007/06/07 14:26:46 1.19 @@ -382,7 +382,7 @@
               <retrieveService>
                   <Service authURI="authority.URI.here" serviceName="MyService"/>          
      -        <retrieveService>
      +        </retrieveService>
       

      Output XML

      From kawas at dev.open-bio.org Thu Jun 7 15:30:01 2007 From: kawas at dev.open-bio.org (Eddie Kawas) Date: Thu, 7 Jun 2007 11:30:01 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706071530.l57FU1SM023629@dev.open-bio.org> kawas Thu Jun 7 11:30:01 EDT 2007 Update of /home/repository/moby/moby-live/Docs/MOBY-S_API In directory dev.open-bio.org:/tmp/cvs-serv23593/MOBY-S_API Modified Files: XMLPayloads.html Log Message: xml from retrieveService was missing a '>' at the cdata element level moby-live/Docs/MOBY-S_API XMLPayloads.html,1.19,1.20 =================================================================== RCS file: /home/repository/moby/moby-live/Docs/MOBY-S_API/XMLPayloads.html,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- /home/repository/moby/moby-live/Docs/MOBY-S_API/XMLPayloads.html 2007/06/07 14:26:46 1.19 +++ /home/repository/moby/moby-live/Docs/MOBY-S_API/XMLPayloads.html 2007/06/07 15:30:01 1.20 @@ -392,7 +392,7 @@
                <Service authURI="authority.URI.here" serviceName="MyService" 
       	 lsid='urn:lsid:authority.uri:serviceinstance:id'>
      -              <![CDATA[WSDL document here]]
      +              <![CDATA[WSDL document here]]>
                </Service>
       
      From gordonp at dev.open-bio.org Thu Jun 7 23:55:42 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 7 Jun 2007 19:55:42 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706072355.l57Ntg5u025474@dev.open-bio.org> gordonp Thu Jun 7 19:55:42 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client In directory dev.open-bio.org:/tmp/cvs-serv25439/src/main/org/biomoby/client Modified Files: CentralCachedCallsImpl.java Log Message: First stage commit of update: now concurrent requests for the sameCentral call are blocked, excepted for the first one moby-live/Java/src/main/org/biomoby/client CentralCachedCallsImpl.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralCachedCallsImpl.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralCachedCallsImpl.java 2006/07/07 04:12:39 1.1 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralCachedCallsImpl.java 2007/06/07 23:55:42 1.2 @@ -1,13 +1,15 @@ /** * Implements the functionality of caching by reusing identical calls to * MOBY central (e.g. asking multiple times what services take a DNA - * sequence in the gi namespace). + * sequence in the gi namespace). This is an in-memory cache in CentralImpl, + * but a filesystem cache backs it up here, so calls can be cached between + * JVM instances. */ package org.biomoby.client; import org.biomoby.shared.MobyException; -import java.util.Properties; +import java.util.*; public class CentralCachedCallsImpl extends CentralImpl{ @@ -15,6 +17,8 @@ protected static final long THE_EPOCH = 0; // don't care when the call is made, it shouldn't affect the onto mapping of calls to IDs protected static final Properties PROPERTIES = null; // don't have any properties for the call + protected Map inProgressCalls; // used to synchronize concurrent, redundant calls to Central + /************************************************************************* * Default constructor. It connects to a default Moby registry * (as defined in {@link #DEFAULT_ENDPOINT}) using a default namespace @@ -23,6 +27,7 @@ public CentralCachedCallsImpl() throws MobyException { super (DEFAULT_ENDPOINT, DEFAULT_NAMESPACE); + inProgressCalls = new HashMap(); } /************************************************************************* @@ -34,6 +39,7 @@ public CentralCachedCallsImpl (String endpoint) throws MobyException { super (endpoint, DEFAULT_NAMESPACE); + inProgressCalls = new HashMap(); } /************************************************************************* @@ -47,20 +53,59 @@ public CentralCachedCallsImpl (String endpoint, String namespace) throws MobyException { super (endpoint, namespace); + inProgressCalls = new HashMap(); } + /** + * The implementation of this method is smart enough that if the same call + * is made more than once, even concurrently(!), we only go to the server once, + * and use a cached value for all other invocations. + */ protected Object doCall (String method, Object[] parameters) throws MobyException { - String callKey = createId(method, parameters); - if(getCacheMode() && existsInCache(callKey)){ - return getContents(callKey); - } + Object result = null; - Object result = super.doCall(method, parameters); - + String callKey = createId(method, parameters); if(getCacheMode()){ - setContents(callKey, result); + + // It's in the cache? + if(existsInCache(callKey)){ + return getContents(callKey); + } + + // The same request is already in progress, in another thread? + Object inProgressCall = null; + synchronized(inProgressCalls){ + String threadName = inProgressCalls.get(callKey); + if(threadName == null){ + // No one's currently doing this request...claim it for this thread + threadName = Thread.currentThread().getName(); + inProgressCalls.put(callKey, threadName); + } + inProgressCall = threadName; + } + + // The first thread making a call will block subsequent ones with the same callKey + synchronized(inProgressCall){ + // Should be true for subsequent calls + if(existsInCache(callKey)){ + return getContents(callKey); + } + // Should get here only if I'm the first caller for the callKey, + // or subsequent call when previous doCall() for this callKey throws an exception + // i.e. setContents() isn't called after doCall() + try{ + result = super.doCall(method, parameters); + setContents(callKey, result); + } finally{ + // Remove the blocker, regardless of whether an Exception was thrown or not. + inProgressCalls.remove(callKey); + } + } + } + else{ + result = super.doCall(method, parameters); } return result; From gordonp at dev.open-bio.org Fri Jun 8 14:03:01 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 8 Jun 2007 10:03:01 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706081403.l58E31vM028646@dev.open-bio.org> gordonp Fri Jun 8 10:03:01 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/test In directory dev.open-bio.org:/tmp/cvs-serv28612/src/main/ca/ucalgary/seahawk/util/test Log Message: Directory /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/test added to the repository moby-live/Java/src/main/ca/ucalgary/seahawk/util/test - New directory rcsdiff: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/test/RCS/-,v: No such file or directory rcsdiff: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/test/RCS/New,v: No such file or directory rcsdiff: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/test/RCS/directory,v: No such file or directory From gordonp at dev.open-bio.org Fri Jun 8 14:04:27 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 8 Jun 2007 10:04:27 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706081404.l58E4Rsh028710@dev.open-bio.org> gordonp Fri Jun 8 10:04:27 EDT 2007 Update of /home/repository/moby/moby-live/Java In directory dev.open-bio.org:/tmp/cvs-serv28675 Modified Files: build.xml Log Message: Commit of Seahawk 1.0 updates and associated core updates moby-live/Java build.xml,1.63,1.64 =================================================================== RCS file: /home/repository/moby/moby-live/Java/build.xml,v retrieving revision 1.63 retrieving revision 1.64 diff -u -r1.63 -r1.64 --- /home/repository/moby/moby-live/Java/build.xml 2007/02/08 17:00:21 1.63 +++ /home/repository/moby/moby-live/Java/build.xml 2007/06/08 14:04:27 1.64 @@ -552,7 +552,16 @@ - + + + + + + + + + + From gordonp at dev.open-bio.org Fri Jun 8 14:04:27 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 8 Jun 2007 10:04:27 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706081404.l58E4RT1028730@dev.open-bio.org> gordonp Fri Jun 8 10:04:27 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/Clients In directory dev.open-bio.org:/tmp/cvs-serv28675/src/Clients Modified Files: HelloMOBY2.java Log Message: Commit of Seahawk 1.0 updates and associated core updates moby-live/Java/src/Clients HelloMOBY2.java,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/Clients/HelloMOBY2.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/Clients/HelloMOBY2.java 2006/04/06 13:42:44 1.3 +++ /home/repository/moby/moby-live/Java/src/Clients/HelloMOBY2.java 2007/06/08 14:04:27 1.4 @@ -32,7 +32,9 @@ // Ignoring start of request here, nothing for us to do // requestID is a unique ID for this invocation - public void start(MobyRequest request, int requestID){ + public void start(MobyRequestEvent mre){ + System.out.println("Data being sent is: "); + System.out.println(mre.getContent().toString()); } // Called by MobyRequest when the response is available From gordonp at dev.open-bio.org Fri Jun 8 14:04:27 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 8 Jun 2007 10:04:27 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706081404.l58E4RrM028790@dev.open-bio.org> gordonp Fri Jun 8 10:04:27 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv28675/src/main/ca/ucalgary/seahawk/gui Modified Files: FileAndTextTransferHandler.java MobyContentClipboard.java MobyContentGUI.java MobyContentHelpPane.java MobyContentPane.java MobyDataObjectWidget.java MobyObjectTransferHandler.java MobySaveDialog.java MobyServicesGUI.java MobyShimmer.java Added Files: MobyContentProducer.java SeahawkOptionsGUI.java Log Message: Commit of Seahawk 1.0 updates and associated core updates moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyContentProducer.java,NONE,1.1 SeahawkOptionsGUI.java,NONE,1.1 FileAndTextTransferHandler.java,1.5,1.6 MobyContentClipboard.java,1.3,1.4 MobyContentGUI.java,1.8,1.9 MobyContentHelpPane.java,1.2,1.3 MobyContentPane.java,1.7,1.8 MobyDataObjectWidget.java,1.1,1.2 MobyObjectTransferHandler.java,1.1,1.2 MobySaveDialog.java,1.2,1.3 MobyServicesGUI.java,1.10,1.11 MobyShimmer.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/FileAndTextTransferHandler.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/FileAndTextTransferHandler.java 2007/04/26 15:15:45 1.5 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/FileAndTextTransferHandler.java 2007/06/08 14:04:27 1.6 @@ -33,7 +33,6 @@ } public boolean importData(JComponent c, Transferable t) { - System.err.println("importData called for file and text transfer handler"); if (!canImport(c, t.getTransferDataFlavors())) { System.err.println("Cannot drop data into Seahawk: " + t); return false; =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentClipboard.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentClipboard.java 2007/04/03 02:34:08 1.3 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentClipboard.java 2007/06/08 14:04:27 1.4 @@ -1,13 +1,10 @@ package ca.ucalgary.seahawk.gui; +import ca.ucalgary.seahawk.util.DataRecorder; + import org.biomoby.client.MobyRequestEventHandler; -import org.biomoby.shared.data.MobyContentInstance; -import org.biomoby.shared.data.MobyDataInstance; -import org.biomoby.shared.data.MobyDataJob; -import org.biomoby.shared.data.MobyDataObject; -import org.biomoby.shared.data.MobyDataObjectSet; -import org.biomoby.shared.data.MobyDataUtils; +import org.biomoby.shared.data.*; import javax.swing.ImageIcon; import javax.swing.JLabel; @@ -51,8 +48,8 @@ private MobyDataInstance itemToDelete; private static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(MobyContentClipboard.class); public MobyContentClipboard(MobyContentGUI cGUI, MobyServicesGUI sGUI, JTabbedPane parentComponent, - JLabel statusBar){ - super(cGUI, sGUI, parentComponent, statusBar); + DataRecorder recorder, JLabel statusBar){ + super(cGUI, sGUI, parentComponent, recorder, statusBar); ClassLoader cl = getClass().getClassLoader(); if(cl == null){ =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java 2007/04/26 15:23:59 1.8 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java 2007/06/08 14:04:27 1.9 @@ -19,8 +19,9 @@ import org.biomoby.client.MobyRequest; import org.biomoby.client.MobyRequestEvent; import org.biomoby.client.MobyRequestEventHandler; +import org.biomoby.shared.*; import org.biomoby.shared.data.*; -import ca.ucalgary.seahawk.util.DescriptiveFileFilter; +import ca.ucalgary.seahawk.util.*; /** * Main interface component: textually displays the data in a MOBY content XML document. @@ -38,6 +39,7 @@ public final static String SAVE_BUTTON_NAME = "MCGsaveButton"; public final static String PRINT_BUTTON_NAME = "MCGprintButton"; public final static String HELP_BUTTON_NAME = "MCGhelpButton"; + public final static String SETTINGS_BUTTON_NAME = "MCGsettingsButton"; public final static String OPEN_OPTION_NAME = "MCGopenPopup"; public final static String FILE_OPEN_OPTION_NAME = "MCGopenPopupFileOption"; public final static String WEB_OPEN_OPTION_NAME = "MCGopenPopupWebOption"; @@ -69,11 +71,13 @@ private JButton saveButton; private JButton printButton; private JButton helpButton; + private JButton settingsButton; private Transformer moby2HTMLConverter; // XSLT engine private MobyServicesGUI servicesGUI; private DocumentBuilder docBuilder = null; private MobyContentClipboard clipboard; private MobyContentHelpPane helpPane; + private DataRecorder dataRecorder; // used for workflow export, etc. private boolean setup; private Map request2tab; private int activeTabIndex = -1; @@ -163,6 +167,15 @@ gridbag.setConstraints(helpButton, c); statusPanel.add(helpButton); + settingsButton = new JButton(new ImageIcon(cl.getResource("ca/ucalgary/seahawk/resources/images/settings.gif"))); + settingsButton.setToolTipText("Show program options"); + settingsButton.setPreferredSize(buttonSize); + settingsButton.setEnabled(true); + settingsButton.addActionListener(this); + settingsButton.setName(SETTINGS_BUTTON_NAME); + gridbag.setConstraints(settingsButton, c); + statusPanel.add(settingsButton); + status = new JLabel(DEFAULT_STATUS_MSG, SwingConstants.LEFT); JPanel labelPanel = new JPanel(); labelPanel.setLayout(new BorderLayout()); @@ -182,9 +195,16 @@ tabbedPane.setToolTipText("Hit to display a new tab"); tabbedPane.addKeyListener(this); + try{ + dataRecorder = new DataRecorder(servicesGUI.getMobyCentralImpl()); + } catch(Exception e){ + e.printStackTrace(); + } + clipboard = new MobyContentClipboard(this, servicesGUI, - tabbedPane, + tabbedPane, + dataRecorder, status); getContentPane().add(tabbedPane, java.awt.BorderLayout.CENTER); @@ -293,19 +313,20 @@ * Called by MOBYRequest when the service request is being sent. We * can create the GUI and wait message here. */ - public void start(MobyRequest request, int requestID){ + public void start(MobyRequestEvent requestEvent){ if(!setup){ setup(); } MobyContentPane tab = createTab("New Request"); - request2tab.put(new Integer(requestID), tab); - tab.start(request, requestID); + request2tab.put(new Integer(requestEvent.getID()), tab); + tab.start(requestEvent); } protected MobyContentPane createTab(String title){ MobyContentPane tab = new MobyContentPane(this, servicesGUI, - tabbedPane, + tabbedPane, + dataRecorder, status); setVisible(true); tab.setPreferredSize(getContentSize()); @@ -469,9 +490,10 @@ public int showHelpTab(){ if(helpPane == null){ helpPane = new MobyContentHelpPane(this, - servicesGUI, - tabbedPane, - status); + servicesGUI, + tabbedPane, + dataRecorder, + status); } // Not a tab in the display yet @@ -877,44 +899,28 @@ java.util.Locale.setDefault(java.util.Locale.ENGLISH); // Unless overridden on the command line, use xerces - if(System.getProperty("javax.xml.parsers.DocumentBuilderFactory") == null){ - System.setProperty("javax.xml.parsers.DocumentBuilderFactory", - "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl"); - } + //if(System.getProperty("javax.xml.parsers.DocumentBuilderFactory") == null){ + // System.setProperty("javax.xml.parsers.DocumentBuilderFactory", + // "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl"); + //} // Unless overridden on the command line, use xalan - if(System.getProperty("javax.xml.transform.TransformerFactory") == null){ - System.setProperty("javax.xml.transform.TransformerFactory", - "org.apache.xalan.processor.TransformerFactoryImpl"); - } + //if(System.getProperty("javax.xml.transform.TransformerFactory") == null){ + // System.setProperty("javax.xml.transform.TransformerFactory", + // "org.apache.xalan.processor.TransformerFactoryImpl"); + //} // Setting this explicitly prevents repeated calls to the META-INF file encoding the same - if(System.getProperty("org.apache.xerces.xni.parser.XMLParserConfiguration") == null){ - System.setProperty("org.apache.xerces.xni.parser.XMLParserConfiguration", - "org.apache.xerces.parsers.StandardParserConfiguration"); - } + //if(System.getProperty("org.apache.xerces.xni.parser.XMLParserConfiguration") == null){ + // System.setProperty("org.apache.xerces.xni.parser.XMLParserConfiguration", + // "org.apache.xerces.parsers.StandardParserConfiguration"); + //} -// if(System.getProperty("org.apache.commons.logging.Log") == null){ -// System.setProperty("org.apache.commons.logging.Log", -// "org.apache.commons.logging.impl.SimpleLog"); -// } - -// if(System.getProperty("org.apache.commons.logging.simplelog.defaultlog") == null){ -// System.setProperty("org.apache.commons.logging.simplelog.defaultlog", -// "error"); -// } + // First, restore any user preferences (uses default settings file location) + SeahawkOptions.restoreSettings(); - // The following command will cache all data type definitions for this session - new Thread(){ - public void run(){org.biomoby.shared.MobyDataType.getDataType("Object");} - }.start(); - new Thread(){ - public void run(){org.biomoby.shared.MobyServiceType.getServiceType("Analysis");} - }.start(); - // And the service definitions - //new Thread(){ - // public void run(){org.biomoby.shared.MobyService.getService("","");} - // }.start(); + // Asynchronously load up ontology data so it's ready when the user needs it. + cacheOntologies(); MobyContentGUI gui = ca.ucalgary.seahawk.util.MobyUtils.getMobyContentGUI(new JLabel()); gui.setDefaultCloseOperation(defaultCloseOperation); @@ -942,6 +948,43 @@ } } + protected static void cacheOntologies(){ + final org.biomoby.registry.meta.Registry preferredRegistry = SeahawkOptions.getRegistry(); + + // Redirect the registry endpoints to local cache files if available + // preferredRegistry and/or dataDefURL may be null, if not cached, but that's okay to pass around + + // The following command will cache all data type definitions for this session + new Thread(){ + public void run(){ + URL dataDefURL = RegistryCache.getDataTypeOntologyURL(preferredRegistry); + if(dataDefURL != null){ + // Use the cached file rather than actually going to the registry + MobyDataType.loadDataTypes(dataDefURL, preferredRegistry); + } + else{ + MobyDataType.getDataType("Object", preferredRegistry); + } + } + }.start(); + new Thread(){ + public void run(){ + URL serviceTypeDefURL = RegistryCache.getServiceTypeOntologyURL(preferredRegistry); + if(serviceTypeDefURL != null){ + // Use the cached file rather than actually going to the registry + MobyServiceType.loadServiceTypes(serviceTypeDefURL, preferredRegistry); + } + else{ + MobyServiceType.getServiceType("Analysis", preferredRegistry); + } + } + }.start(); + // And the service definitions + //new Thread(){ + // public void run(){org.biomoby.shared.MobyService.getService("","");} + // }.start(); + } + /** * Method to be called when an applet is being decommissioned. */ =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentHelpPane.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentHelpPane.java 2007/02/08 16:59:57 1.2 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentHelpPane.java 2007/06/08 14:04:27 1.3 @@ -1,6 +1,8 @@ package ca.ucalgary.seahawk.gui; +import ca.ucalgary.seahawk.util.DataRecorder; + import org.biomoby.client.MobyRequestEventHandler; import org.biomoby.shared.data.MobyContentInstance; import org.biomoby.shared.data.MobyDataInstance; @@ -39,8 +41,8 @@ private static URL helpHTMLURL; private static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(MobyContentHelpPane.class); public MobyContentHelpPane(MobyContentGUI cGUI, MobyServicesGUI sGUI, JTabbedPane parentComponent, - JLabel statusBar){ - super(cGUI, sGUI, parentComponent, statusBar); + DataRecorder recorder, JLabel statusBar){ + super(cGUI, sGUI, parentComponent, recorder, statusBar); // So JFCUnit tests can find it setName(HELP_TAB_NAME); =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java 2007/04/18 16:04:06 1.7 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java 2007/06/08 14:04:27 1.8 @@ -1,8 +1,7 @@ package ca.ucalgary.seahawk.gui; -// For external links -import ca.ucalgary.seahawk.util.BrowserLauncher; +import ca.ucalgary.seahawk.util.*; import org.biomoby.client.MobyRequest; import org.biomoby.client.MobyRequestEvent; @@ -19,14 +18,10 @@ import org.apache.xpath.*; import org.apache.xpath.objects.*; -import ca.ucalgary.seahawk.util.*; - import javax.swing.*; import javax.swing.event.*; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Point; +import java.awt.*; import java.awt.print.*; import java.awt.event.*; import java.io.*; @@ -67,17 +62,19 @@ private int lastClickY = 1; private boolean hasFailed = false; private boolean isContentsXML = false; + private DataRecorder dataRecorder; // Text selection members private int dot; private int mark; private String selectedTextData; private static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(MobyContentPane.class); - public MobyContentPane(MobyContentGUI cGUI, MobyServicesGUI sGUI, JTabbedPane parentComponent, JLabel statusBar){ + public MobyContentPane(MobyContentGUI cGUI, MobyServicesGUI sGUI, JTabbedPane parentComponent, DataRecorder recorder, JLabel statusBar){ tabbedPane = parentComponent; status = statusBar; contentGUI = cGUI; servicesGUI = sGUI; + dataRecorder = recorder; // The next line is what provides the drag 'n' drop capability addKeyListener(this); @@ -89,7 +86,6 @@ editorPane = new PrintableJEditorPane(); editorPane.addKeyListener(this); editorPane.setTransferHandler(getTransferHandler()); - //editorPane.setPreferredSize(parentComponent.getPreferredSize()); editorPane.setEditable(false); editorPane.addMouseListener(this); editorPane.addHyperlinkListener(this); @@ -254,11 +250,12 @@ else if(htmlContents.indexOf(" ") != -1){ htmlContents = htmlContents.replaceAll(">([^<]+ [^<]+)<", ">
      $1
      <"); } - //else{ + else{ // Break up any really long DNA/AA stretches - htmlContents = htmlContents.replaceAll("([a-zA-Z]{60,})", "
      $1
      "); - htmlContents = htmlContents.replaceAll("([a-zA-Z]{60})", "$1\n"); - //} + System.err.println("Trying to break up long streches"); + htmlContents = htmlContents.replaceAll("([a-zA-Z]{60})", "\n
      $1"); + htmlContents = htmlContents.replaceAll("([a-zA-Z]{60})([a-zA-Z]{1,})", "$1\n
      $2
      \n"); + } // Otherwise assume it's formatted resultBuffer.append(htmlContents); } @@ -286,9 +283,7 @@ // Assume it's plain text, or whatever the JEditorPane can glean from the content-type // such as a remote HTML or RTF doc, because result buffer will be empty in condition below else{ - editorPane.setContentType("text/plain"); isContentsXML = false; - editorPane.setFont(java.awt.Font.getFont("Monospaced")); } if(resultBuffer.length() == 0){ @@ -313,7 +308,12 @@ logger.error("Failure in loading MOBYfied binary data:\n" + e); } // Shouldn't get here unless either not binary, or the binary data load failed - editorPane.setPage(url); + System.err.println("Is plain text"); + editorPane.setContentType("text/html"); + resultBuffer = new StringBuffer("
      "+
      +						getInputStreamContents(url.openStream()).replaceAll("&", "&").replaceAll("<","<")+
      +						"
      "); + editorPane.setText(resultBuffer.toString()); } else{ editorPane.setText(resultBuffer.toString()); @@ -322,6 +322,8 @@ } // Regardless of the doc, scroll to a reference called "start:" if available. // By default the pane will annoyingly scroll to the bottom when new data is loaded. + try{Thread.sleep(1000);} // Give it time to paint before scrolling + catch(Exception te){} editorPane.scrollToReference("start"); } catch (java.io.IOException ioe) { @@ -385,11 +387,19 @@ * Called by MOBYRequest when the service request is being sent. We * can create the GUI and wait message here. */ - public void start(MobyRequest request, int requestID){ + public void start(MobyRequestEvent requestEvent){ hasFailed = false; tabbedPane.setSelectedComponent(this); - tabbedPane.setTitleAt(tabbedPane.indexOfComponent(this), ""+requestID+"-"+request.getService().getName()); + tabbedPane.setTitleAt(tabbedPane.indexOfComponent(this), + ""+requestEvent.getID()+"-"+requestEvent.getService().getName()); setWaitScreen(); + // Store the request being sent (w/ 2ndary params and all), + // for reference (e.g. when exporting a workflow) + try{ + dataRecorder.saveInputData(requestEvent); + } catch(Exception e){ + e.printStackTrace(); + } } public void stop(MobyRequest request, int requestID){ @@ -474,6 +484,20 @@ return hasFailed; } + public String toScufl() throws Exception{ + URL[] historyToExport = (URL[]) history.toArray(new URL[history.size()]); + if(historyIndex != historyToExport.length-1){ + // Shorten the array if we aren't cuurently on the last doc (i.e. + // we don't want to export documents forward in the history) + URL[] truncatedHistory = new URL[historyIndex]; + System.arraycopy(historyToExport, 0, truncatedHistory, 0, historyIndex); + historyToExport = truncatedHistory; + } + ByteArrayOutputStream output = new ByteArrayOutputStream(); + dataRecorder.exportWorkflow(historyToExport, output, DataRecorder.TAVERNA15); + return output.toString(); + } + // Save the MOBY data to a file, then tell NewBrowser to load that local file URL protected void loadDataInBrowser(MobyRequestEvent mre){ @@ -509,21 +533,12 @@ } try { - // Create temp file. - File temp = File.createTempFile(serviceToFilePrefix(mobyRequest.getService()), ".xml"); - - // Delete temp file when program exits. - temp.deleteOnExit(); - - // Write to temp file - FileWriter out = new FileWriter(temp); - out.write(mre.getContentsXML()); - out.close(); - gotoURL(temp.toURL(), true); - } catch (IOException ioe) { + URL outputURL = dataRecorder.saveOutputData(mre); + gotoURL(outputURL, true); + } catch (Exception e) { failed("Could not write a local file"); - editorPane.setText("ERROR: Could not write temporary file for MOBY results: " + ioe); - ioe.printStackTrace(); + editorPane.setText("ERROR: Could not write temporary file for MOBY results: " + e); + e.printStackTrace(); return; } succeeded(responseType); @@ -821,12 +836,12 @@ } if(mobyString != null){ - mobyData = new MobyDataString("", mobyString); + mobyData = new MobyDataString("", mobyString, SeahawkOptions.getRegistry()); } else{ - mobyData = new MobyDataObject(""); + mobyData = new MobyDataObject("", SeahawkOptions.getRegistry()); } - mobyData.addNamespace(MobyNamespace.getNamespace(namespace)); + mobyData.addNamespace(MobyNamespace.getNamespace(namespace, SeahawkOptions.getRegistry())); if(mobyID != null){ mobyData.setId(mobyID); @@ -952,8 +967,8 @@ * This method tries to figure out what kinds of MOBY Data could be * created from the string given. e.g. Keywords, DNASequence, etc. */ - protected MobyDataInstance[] loadMobyDataFromString(String data, boolean reverseSelected){ - return MobyUtils.convertStringToObjects(data, reverseSelected); + protected MobyDataInstance[] loadMobyDataFromString(String data){ + return MobyUtils.convertStringToObjects(data); } public boolean isMobyURL(URL u){ @@ -964,8 +979,8 @@ // MouseListener interface implementation public void mouseClicked(MouseEvent e){ // Allow middle button paste - if(e.getButton() == MouseEvent.BUTTON3 || - e.getButton() == MouseEvent.BUTTON2 && e.isAltDown()){ + if(e.getButton() == MouseEvent.BUTTON2 || + e.getButton() == MouseEvent.BUTTON3 && e.isAltDown()){ paste(); } } @@ -999,7 +1014,7 @@ if(selectedTextData == null){ return; } - MobyDataInstance[] mobyData = loadMobyDataFromString(selectedTextData, mark > dot); + MobyDataInstance[] mobyData = loadMobyDataFromString(selectedTextData); if(mobyData == null || mobyData.length == 0){ logger.warn("No MobyData could be made from the selected text"); return; @@ -1066,111 +1081,6 @@ status.setText("Click your selection to use as MOBY data!"); } - private MobyService getService(int index) throws Exception{ - String filename = ((URL) history.elementAt(index)).getPath(); - if(filename.lastIndexOf('/') != -1){ - filename = filename.substring(filename.lastIndexOf('/')+1); - } - return filePrefixToService(filename); - } - - private String getScuflProcessor(int index) throws Exception{ - MobyService service = getService(index); - - if(service == null){ //data was loaded from file, not from a service - return ""; - } - - StringBuffer secondaryParams = new StringBuffer(); - // example input human - - return " \n"+ - " "+service.getDescription()+"\n" + - " \n"+ - " "+servicesGUI.getMobyCentralImpl().getRegistryEndpoint()+"\n"+ - " "+service.getName()+"\n"+ - " "+service.getAuthority()+"\n"+ - secondaryParams.toString() + - " \n"+ - " \n"; - - } - - public String toScufl() throws Exception{ - - StringBuffer scufl = new StringBuffer(); - scufl.append("\n" + - "\n" + - " \n"); - - // The first service to be called - int i = 0; - MobyService firstService = getService(i); - while(firstService == null){ - firstService = getService(++i); - } - MobyPrimaryData[] inputData = firstService.getPrimaryInputs(); - if(inputData != null && inputData.length != 0){ - // Seahawk only deals with single input services for now - scufl.append(" \n"+ - " Generates "+inputData[0].getDataType().getDescription()+"\n"+ - " \n"+ - " "+servicesGUI.getMobyCentralImpl().getRegistryEndpoint()+"\n"+ - " "+inputData[0].getDataType().getName()+"\n"+ - " \n"+ - " \n"+ - " \n"); - - MobyNamespace[] inputNS = inputData[0].getNamespaces(); - String nsNames = "Object"; - if(inputNS != null && inputNS.length != 0){ - String firstNS = inputNS[0].getName().replaceAll("urn:lsid:biomoby.org:namespacetype:(.*?):.*", "$1"); - nsNames = firstNS; - for(int j = 1; j < inputNS.length; j++){ - nsNames = nsNames + "_or_" + inputNS[j].getName().replaceAll("[^A-Za-z0-9_]", "_"); - } - nsNames = nsNames.replaceAll("[^A-Za-z0-9_]", "_"); - nsNames = nsNames + "_"; - // Predefine the namespace for the user since it's available - scufl.append("" - + firstNS + "\n"); - } - else{ - scufl.append("\n"); - } - scufl.append("\n" + - " text/plain\n"+ - "\n"); - - scufl.append(getScuflProcessor(i)); - - scufl.append("\n" + - "\n" + - ""); - } - else{ - // service has no input if we're here... - scufl.append(getScuflProcessor(i)); - } - - // for each history element, there was a service execution that generated the data - for(; i < historyIndex; i++){ - scufl.append(getScuflProcessor(i+1)); - scufl.append("\n"); - } - scufl.append("\n"); - scufl.append("" + - "text/xml"+ - "\n"); - scufl.append("\n"); - - return scufl.toString(); - } - /** * Implemented to provide paste functionality (control-v or the paste button on a Sun keyboard), * since the editor panes are not editable and therefore by default do not respond to =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyDataObjectWidget.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyDataObjectWidget.java 2007/04/26 15:19:58 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyDataObjectWidget.java 2007/06/08 14:04:27 1.2 @@ -16,7 +16,7 @@ * the user to drop data onto it via a MobyObjectTransferHandler * (hence the implementation of MobyObjectReceiver). */ -public class MobyDataObjectWidget extends JLabel implements MobyObjectReceiver{ +public class MobyDataObjectWidget extends JLabel implements MobyObjectReceiver, MobyContentProducer{ public static final int PARAM_TOOLTIP_WIDTH = 50; public static final Color INSTANTIATED_FG_COLOUR = Color.DARK_GRAY; public static final Color UNINSTANTIATED_FG_COLOUR = Color.RED; @@ -58,7 +58,17 @@ setTransferHandler(MobyObjectTransferHandler.getHandler(client)); } + // Enables copying of MOBY data to the clipboard + addMouseListener(new DragMouseAdapter()); + } + // Shamelessly copied from the Java DnD tutorial's LabalDND.java + private class DragMouseAdapter extends MouseAdapter { + public void mousePressed(MouseEvent e) { + JComponent c = (JComponent)e.getSource(); + TransferHandler handler = c.getTransferHandler(); + handler.exportAsDrag(c, e, TransferHandler.COPY); + } } private Icon getInstantiatedIcon(){ @@ -221,4 +231,11 @@ acceptableData.put(name, targetData); return acceptableData; } + + /** + * Used to send data out to the clipboard. + */ + public MobyContentInstance exportMobyContent(){ + return null; + } } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyObjectTransferHandler.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyObjectTransferHandler.java 2007/04/26 15:19:58 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyObjectTransferHandler.java 2007/06/08 14:04:27 1.2 @@ -1,6 +1,7 @@ package ca.ucalgary.seahawk.gui; import ca.ucalgary.seahawk.util.HTMLUtils; +import ca.ucalgary.seahawk.util.MobyUtils; import ca.ucalgary.seahawk.services.MobyClient; import org.biomoby.shared.MobyPrefixResolver; import org.biomoby.shared.*; @@ -28,7 +29,7 @@ * be convertible into a desired Moby Object data type in order to be dropped. Components using this * class as their TransferHandler should implement MobyObjectReceiver for this to do something meaningful. */ -public class MobyObjectTransferHandler extends FileAndTextTransferHandler { +public class MobyObjectTransferHandler extends FileAndTextTransferHandler implements ClipboardOwner{ private MobyClient client; private static Map handlers; @@ -309,5 +310,34 @@ keeper.put(key, entry.getValue()); } } -} + /** + * Drag and copy functiunality. + */ + public void exportToClipboard(JComponent comp, + Clipboard clip, + int action) throws IllegalStateException{ + Transferable createdData = null; + try{ + if(!(comp instanceof MobyContentProducer)){ + throw new IllegalStateException("Component calling exportToClipboard " + + "was not a MobyObjectProducer as expected, export aborted"); + } + createdData = MobyUtils.createTransferable(((MobyContentProducer) comp).exportMobyContent()); + clip.setContents(createdData, this); + } catch(IllegalStateException e){ + // To be consistent with the normal transfer handler, call exportDone + // even if we failed + exportDone(comp, createdData, TransferHandler.NONE); + throw e; + } + exportDone(comp, createdData, action); + } + + /** + * To satisfy the ClipboardOwner interface. + */ + public void lostOwnership(Clipboard clipboard, Transferable contents){ + + } +} =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobySaveDialog.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobySaveDialog.java 2007/02/08 16:59:57 1.2 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobySaveDialog.java 2007/06/08 14:04:27 1.3 @@ -113,6 +113,7 @@ ostream.flush(); ostream.close(); } catch (Exception ex) { + ex.printStackTrace(); JOptionPane.showMessageDialog(null, "Cannot save the Seahawk tab history as a Taverna workflow: "+ex, "Error saving", JOptionPane.ERROR_MESSAGE); } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyServicesGUI.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyServicesGUI.java 2007/04/26 15:26:24 1.10 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyServicesGUI.java 2007/06/08 14:04:27 1.11 @@ -2,20 +2,23 @@ import ca.ucalgary.seahawk.services.MobyClient; import ca.ucalgary.seahawk.util.HTMLUtils; -import javax.swing.*; -import org.w3c.dom.*; +import ca.ucalgary.seahawk.util.SeahawkOptions; + import org.biomoby.shared.*; import org.biomoby.shared.data.*; import org.biomoby.client.MobyRequest; import org.biomoby.client.MobyRequestEventHandler; -import java.lang.ref.WeakReference; +import org.w3c.dom.*; + import java.awt.event.*; import java.awt.*; import java.io.*; +import java.lang.ref.WeakReference; import java.text.Collator; import java.net.URL; import java.util.*; +import javax.swing.*; import javax.swing.event.PopupMenuListener; import javax.swing.event.PopupMenuEvent; @@ -249,8 +252,8 @@ // Need to choose among multiple parameters if(paramMatch.size() > 1){ targetParamName = (String) JOptionPane.showInputDialog(null, - "Choose the service parameter the chosen " + - "object represents", + "Choose the service parameter\n"+ + "the chosen object represents", "Service Parameter Choice", JOptionPane.QUESTION_MESSAGE, null, @@ -783,7 +786,8 @@ MobyDataType outputType = null; if(output != null && output.length != 0 && output[0] instanceof MobyPrimaryData){ - outputType = MobyDataType.getDataType(((MobyPrimaryData) output[0]).getDataType().getName()); + outputType = MobyDataType.getDataType(((MobyPrimaryData) output[0]).getDataType().getName(), + SeahawkOptions.getRegistry()); } if(outputType == null){ logger.warn("No output data type (ontology) was associated with service " + @@ -1176,7 +1180,7 @@ } // Make sure we have a fully documented data type object - mobyDataType = MobyDataType.getDataType(targetData.getDataType().getName()); + mobyDataType = MobyDataType.getDataType(targetData.getDataType().getName(), SeahawkOptions.getRegistry()); String desc = null; String datatype = null; if(mobyDataType == null){ =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyShimmer.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyShimmer.java 2007/02/08 16:59:57 1.2 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyShimmer.java 2007/06/08 14:04:27 1.3 @@ -115,7 +115,7 @@ } } - public void start(MobyRequest request, int requestID){ + public void start(MobyRequestEvent requestEvent){ } public void processEvent(MobyRequestEvent mre){ From gordonp at dev.open-bio.org Fri Jun 8 14:04:27 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 8 Jun 2007 10:04:27 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706081404.l58E4Rrh028892@dev.open-bio.org> gordonp Fri Jun 8 10:04:27 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util In directory dev.open-bio.org:/tmp/cvs-serv28675/src/main/ca/ucalgary/seahawk/util Modified Files: HTMLUtils.java MobyUtils.java Added Files: DataRecorder.java MobyDataTransferable.java RegistryCache.java SeahawkOptions.java Log Message: Commit of Seahawk 1.0 updates and associated core updates moby-live/Java/src/main/ca/ucalgary/seahawk/util DataRecorder.java,NONE,1.1 MobyDataTransferable.java,NONE,1.1 RegistryCache.java,NONE,1.1 SeahawkOptions.java,NONE,1.1 HTMLUtils.java,1.2,1.3 MobyUtils.java,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/HTMLUtils.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/HTMLUtils.java 2007/04/26 15:15:45 1.2 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/HTMLUtils.java 2007/06/08 14:04:27 1.3 @@ -180,21 +180,25 @@ org.w3c.dom.Element data = db.parse(new ByteArrayInputStream(xmltext.getBytes())).getDocumentElement(); if(data.getLocalName().equals(MobyTags.MOBY)){ - content = MobyDataUtils.fromXMLDocument(data); + content = MobyDataUtils.fromXMLDocument(data, SeahawkOptions.getRegistry()); } else if(data.getLocalName().equals(MobyTags.MOBYCONTENT)){ - content = new MobyContentInstance(data); + content = new MobyContentInstance(data, SeahawkOptions.getRegistry()); } else if(data.getLocalName().equals(MobyTags.MOBYDATA)){ content = new MobyContentInstance(); - content.parseDataGroup(data); + content.parseDataGroup(data, SeahawkOptions.getRegistry()); } else{ // Any other data can be processed by the base object class - content = new MobyContentInstance(MobyDataObject.createInstanceFromDOM(data), "Drag 'n' Drop data"); + content = new MobyContentInstance(MobyDataObject.createInstanceFromDOM(data, SeahawkOptions.getRegistry()), + "Drag 'n' Drop data"); } } catch(Exception e){ e.printStackTrace(); + System.err.println("This issue may be related to your choice of registry ("+ + (SeahawkOptions.getRegistry() == null ? "MOBY default" : SeahawkOptions.getRegistry().getSynonym()) + +")"); } return content; } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/MobyUtils.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/MobyUtils.java 2007/04/18 15:55:18 1.6 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/MobyUtils.java 2007/06/08 14:04:27 1.7 @@ -4,10 +4,12 @@ import ca.ucalgary.seahawk.gui.MobyServicesGUI; import ca.ucalgary.seahawk.services.MobyClient; +import org.biomoby.registry.meta.Registry; import org.biomoby.shared.data.*; import org.biomoby.shared.MobyDataType; import org.biomoby.shared.MobyNamespace; +import java.awt.datatransfer.Transferable; import java.io.ByteArrayOutputStream; import java.io.InputStream; import java.net.URL; @@ -24,6 +26,10 @@ private static MobyContentGUI mobyContentGUI = null; private static MobyServicesGUI mobyServicesGUI = null; + + public static Transferable createTransferable(MobyContentInstance contents){ + return null; + } /** * The purpose of this method is to create a MOBY document to encapsulate @@ -47,20 +53,22 @@ // Find MOBY Objects in it MobyDataObject[] foundObjects = client.getMobyObjects(bytes.toByteArray(), - MobyDataType.getDataType(MobyDataBytes.BASE64_DATATYPE)); + MobyDataType.getDataType(MobyDataBytes.BASE64_DATATYPE, + SeahawkOptions.getRegistry())); // Did we unambiguously find one binary object? if(foundObjects != null && foundObjects.length == 1){ MobyContentInstance mci = new MobyContentInstance(); String[] dataName = url.getPath().split("/"); MobyDataJob job = new MobyDataJob(); job.put(dataName[dataName.length-1], foundObjects[0]); + System.err.println("Namespace of found object was " + foundObjects[0].getPrimaryNamespace().getName()); mci.put(dataName[dataName.length-1], job); // name the data by the last part of the URL path return mci; } return null; } - public static MobyDataInstance[] convertStringToObjects(String data, boolean reverseSelected){ + public static MobyDataInstance[] convertStringToObjects(String data){ if(data == null){ return new MobyDataInstance[0]; } @@ -74,23 +82,13 @@ } // Can always use the data as a string - MobyDataString strObject = new MobyDataString(objectName, data); + MobyDataString strObject = new MobyDataString(objectName, data, SeahawkOptions.getRegistry()); strObject.setPrimaryNamespace(new MobyNamespace("seahawk")); objects.add(strObject); // See if it's sequence MobyDataComposite mdc = createMobySequence(data, "user-selection"); if(mdc != null){ - // reverse complement DNA if necessary - if(reverseSelected && - (mdc.getDataType() == MobyDataType.getDataType("DNASequence") || - mdc.getDataType() == MobyDataType.getDataType("RNASequence"))){ - - MobyDataComposite nucObject = (MobyDataComposite) mdc; - MobyDataString seq = (MobyDataString) nucObject.get("SequenceString"); - seq.setValue(Sequence.reverseComplement(seq.toString())); - } - mdc.setName(objectName); objects.add(mdc); } @@ -99,8 +97,9 @@ if(data.trim().matches("^[A-Za-z0-9_-]{3,35}$")){ objects.add(new MobyDataComposite("Global_Keyword", "dummy_name", - "seahawk", - data.trim())); + "unknown", + data.trim(), + SeahawkOptions.getRegistry())); } } @@ -163,19 +162,22 @@ sequence = new MobyDataComposite("DNASequence", "dummy_name", "seahawk", - id); + id, + SeahawkOptions.getRegistry()); } else if(Sequence.isRNA(sequenceData)){ sequence = new MobyDataComposite("RNASequence", "dummy_name", "seahawk", - id); + id, + SeahawkOptions.getRegistry()); } else if(Sequence.isProtein(sequenceData)){ sequence = new MobyDataComposite("AminoAcidSequence", "dummy_name", "seahawk", - id); + id, + SeahawkOptions.getRegistry()); } // Not a recognized type of sequence else{ @@ -183,8 +185,8 @@ } sequenceData = sequenceData.replaceAll("[ \t\r\n0-9]", ""); // strip whitespace and possible milestone digits - sequence.put("SequenceString", new MobyDataString(sequenceData)); - sequence.put("Length", new MobyDataInt(sequenceData.length())); + sequence.put("SequenceString", new MobyDataString(sequenceData, SeahawkOptions.getRegistry())); + sequence.put("Length", new MobyDataInt(sequenceData.length(), SeahawkOptions.getRegistry())); return sequence; } From gordonp at dev.open-bio.org Fri Jun 8 14:04:27 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 8 Jun 2007 10:04:27 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706081404.l58E4RdT028818@dev.open-bio.org> gordonp Fri Jun 8 10:04:27 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources In directory dev.open-bio.org:/tmp/cvs-serv28675/src/main/ca/ucalgary/seahawk/resources Modified Files: MobyContentGUIHelp.html mobyBuilderRules.xml startup.html Log Message: Commit of Seahawk 1.0 updates and associated core updates moby-live/Java/src/main/ca/ucalgary/seahawk/resources MobyContentGUIHelp.html,1.1,1.2 mobyBuilderRules.xml,1.4,1.5 startup.html,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/MobyContentGUIHelp.html,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/MobyContentGUIHelp.html 2006/10/25 02:33:22 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/MobyContentGUIHelp.html 2007/06/08 14:04:27 1.2 @@ -49,6 +49,12 @@

      How do I create data?

      +

      Drag and Drop / Cut and Paste

      +

      + The easiest way to create data is to simply drag a file, text selection, or Web link + onto the Seahawk interface. Seahawk will try to display the data you drop. +

      +

      Loading documents

      Click the folder/Web icon on the bottom toolbar will give you the option of @@ -64,14 +70,13 @@ With the mouse, you can highlight arbitrary sections of text in the Seahawk display. Clicking within selected text will raise a popup menu showing MOBY service options. Seahawk will try to determine the type of data highlighted are - potentially show services for the selection as a: + potentially show services for the selection as a, among other things:

      • String
      • Search Keyword
      • Database Identifier
      • Protein Sequence
      • -
      • DNA/RNA Sequence (note that highlighting sequence right-to-left - will create the reverse complement)
      • +
      • DNA/RNA Sequence

      =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/mobyBuilderRules.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/mobyBuilderRules.xml 2007/04/26 15:30:01 1.4 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/mobyBuilderRules.xml 2007/06/08 14:04:27 1.5 @@ -4,15 +4,26 @@ http://www.bioxml.info/dtd/tigrxml.dtd http://www.bioxml.info/dtd/Bioseq.dtd - + - (\N+(?:\x20|\r|\t|\n)?)+ + (\N*\s*(\N{10,}(?:\x20|\r|\t|\n)?)+\N*) - unknown + '' + + $1 + string-length('$1') + + + + + (\P*\s*(\P{10,}(?:\x20|\r|\t|\n)?)+\P*) + + + '' - $2 - string-length('$2') + $1 + string-length('$1') =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/startup.html,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/startup.html 2007/04/26 15:31:00 1.3 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/startup.html 2007/06/08 14:04:27 1.4 @@ -14,6 +14,8 @@ For example data, and more help on using Seahawk to automatically discover and run Web-based analysis services, please click the help icon at the bottom of this window. - +

      +Please help us improve Seahawk by completing a user survey! +

      From gordonp at dev.open-bio.org Fri Jun 8 14:04:28 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 8 Jun 2007 10:04:28 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706081404.l58E4Si0029000@dev.open-bio.org> gordonp Fri Jun 8 10:04:27 EDT 2007 Update of /home/repository/moby/moby-live/Java/xmls In directory dev.open-bio.org:/tmp/cvs-serv28675/xmls Modified Files: seahawkBuild.xml Log Message: Commit of Seahawk 1.0 updates and associated core updates moby-live/Java/xmls seahawkBuild.xml,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Java/xmls/seahawkBuild.xml,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Java/xmls/seahawkBuild.xml 2006/12/15 04:39:52 1.7 +++ /home/repository/moby/moby-live/Java/xmls/seahawkBuild.xml 2007/06/08 14:04:27 1.8 @@ -25,6 +25,10 @@ + + + + @@ -87,7 +91,7 @@ - + @@ -129,10 +133,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      + + + +
      +
      +
      + + + + + +
      + + - + + From gordonp at dev.open-bio.org Fri Jun 8 14:04:27 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 8 Jun 2007 10:04:27 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706081404.l58E4R6A028906@dev.open-bio.org> gordonp Fri Jun 8 10:04:27 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/test In directory dev.open-bio.org:/tmp/cvs-serv28675/src/main/ca/ucalgary/seahawk/util/test Added Files: DataRecorderTestCase.java Log Message: Commit of Seahawk 1.0 updates and associated core updates moby-live/Java/src/main/ca/ucalgary/seahawk/util/test DataRecorderTestCase.java,NONE,1.1 From gordonp at dev.open-bio.org Fri Jun 8 14:04:27 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 8 Jun 2007 10:04:27 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706081404.l58E4Rf5028832@dev.open-bio.org> gordonp Fri Jun 8 10:04:27 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/images In directory dev.open-bio.org:/tmp/cvs-serv28675/src/main/ca/ucalgary/seahawk/resources/images Added Files: settings.gif Log Message: Commit of Seahawk 1.0 updates and associated core updates moby-live/Java/src/main/ca/ucalgary/seahawk/resources/images settings.gif,NONE,1.1 From gordonp at dev.open-bio.org Fri Jun 8 14:04:27 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 8 Jun 2007 10:04:27 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706081404.l58E4Rf5028926@dev.open-bio.org> gordonp Fri Jun 8 10:04:27 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/resources In directory dev.open-bio.org:/tmp/cvs-serv28675/src/main/ca/ucalgary/services/resources Modified Files: acdRules.xml Log Message: Commit of Seahawk 1.0 updates and associated core updates moby-live/Java/src/main/ca/ucalgary/services/resources acdRules.xml,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/resources/acdRules.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/resources/acdRules.xml 2007/03/12 14:33:38 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/resources/acdRules.xml 2007/06/08 14:04:27 1.2 @@ -35,7 +35,7 @@ - >\s*(\S+)\s*([^\n]+)((?:\n\N+)+) + >\x20*(\S+)\x20+([^\n]+)((?:\n\N+)+) $1 @@ -46,7 +46,7 @@ - >\s*(\S*)\s*((?:\n\N+)+) + >\x20*(\S*)\x20*((?:\n\N+)+) $1 @@ -58,7 +58,7 @@ - >\s*(\S+)\s+([^\n]+)((?:\n\P+)+) + >\x20*(\S+)\x20+([^\n]+)((?:\n\P+)+) $1 @@ -69,7 +69,7 @@ - >\s*(\S*)\s*((?:\n\P+)+) + >\x20*(\S*)\x20*((?:\n\P+)+) $1 @@ -78,11 +78,58 @@ string-length('$2') - + + + + + + + \A.PNG\r\n\x1A\n.*\z - + + $0 + + + + + \AABIF.*\z + $0 From gordonp at dev.open-bio.org Fri Jun 8 14:04:27 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 8 Jun 2007 10:04:27 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706081404.l58E4R0Y028982@dev.open-bio.org> gordonp Fri Jun 8 10:04:27 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared In directory dev.open-bio.org:/tmp/cvs-serv28675/src/main/org/biomoby/shared Modified Files: MobyDataType.java MobyNamespace.java MobyService.java MobyServiceType.java Log Message: Commit of Seahawk 1.0 updates and associated core updates moby-live/Java/src/main/org/biomoby/shared MobyDataType.java,1.14,1.15 MobyNamespace.java,1.6,1.7 MobyService.java,1.18,1.19 MobyServiceType.java,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataType.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataType.java 2006/07/07 04:12:40 1.14 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataType.java 2007/06/08 14:04:27 1.15 @@ -7,8 +7,11 @@ package org.biomoby.shared; -import java.util.Comparator; -import java.util.Vector; +import java.net.URL; +import java.util.*; + +import org.biomoby.client.CentralImpl; +import org.biomoby.registry.meta.*; import org.biomoby.shared.extended.DataTypeParser; /** @@ -49,9 +52,11 @@ protected String id = null; protected String comment = null; protected String lsid = null; + protected Registry registry = null; // with which registry was the data type registered? - private static MobyDataType[] uninitializedDatatypes = new MobyDataType[0]; - private static MobyDataType[] datatypes = uninitializedDatatypes; + private static Map datatypesMapBySynonym = new HashMap(); + private static Map datatypesMapByURL = new HashMap(); + private static Registry defaultRegistry = null; /************************************************************************** * Default constructor. @@ -74,24 +79,111 @@ setName (name); } + public void setRegistry(Registry r){ + registry = r; + } + + public Registry getRegistry(){ + return registry; + } + + protected static String convertRegistryToDataTypeResourceURL(Registry reg) throws MobyException{ + CentralImpl central = new CentralImpl(reg.getEndpoint()); + MobyResourceRef[] resources = central.getResourceRefs(); + for(MobyResourceRef resource: resources){ + if(Central.DATA_TYPES_RESOURCE_NAME.equals(resource.getResourceName())){ + return resource.getResourceLocation().toString(); + } + } + System.err.println("Error! Could not find the data type resource from the registry " + reg.getSynonym()); + return null; + } + + public synchronized static Registry getDefaultRegistry(){ + if(defaultRegistry == null){ + try{ + defaultRegistry = (new RegistriesList()).get(Registries.DEFAULT_REGISTRY_SYNONYM); + } catch(Exception e){ + e.printStackTrace(); + } + if(defaultRegistry == null){ + System.err.println("Error! Could not find a default registry! No data types will be available."); + System.err.println("Sought " + Registries.DEFAULT_REGISTRY_SYNONYM + " but available options are:"); + for(String synonym: (new RegistriesList()).list()){ + System.err.println(synonym); + } + } + } + return defaultRegistry; + } + + /** + * Particularly useful for loading data types from cached file, or + * refreshing an in-memory cache. + */ + public static void loadDataTypes(URL dataDefURL, Registry reg){ + MobyDataType[] datatypes; + try{ + DataTypeParser p = new DataTypeParser(dataDefURL); + + datatypes = p.getMobyDataTypesFromRDF(); + for(MobyDataType dataType: datatypes){ + dataType.setRegistry(reg); + } + } + catch(Exception e){ + System.err.println("Cannot parse MOBY Object Ontology: " + e); + e.printStackTrace(); + return; + } + datatypesMapBySynonym.put(reg.getSynonym(), datatypes); + datatypesMapByURL.put(dataDefURL.toString(), datatypes); + } + public static MobyDataType getDataType(String className){ + return getDataType(className, null); + } + + /** + * Retrieves a datatype object from the registry's ontology. + */ + public static MobyDataType getDataType(String className, Registry reg){ if(className == null){ return null; } - + + if(reg == null){ + reg = getDefaultRegistry(); + } + if(reg == null){ + return null; + } + + MobyDataType[] datatypes = datatypesMapBySynonym.get(reg.getSynonym()); + // This method has not been called yet in the JVM, populate the datatypes - synchronized(datatypes){ - if(datatypes == uninitializedDatatypes){ + synchronized(datatypesMapByURL){ + if(datatypes == null){ + String dataDefURL = null; try{ - DataTypeParser p = new DataTypeParser("http://biomoby.org/RESOURCES/MOBY-S/Objects"); - //DataTypeParser p = new DataTypeParser(RdfParser.OBJECT_URI); - datatypes = p.getMobyDataTypesFromRDF(); + dataDefURL = convertRegistryToDataTypeResourceURL(reg); + datatypes = datatypesMapByURL.get(dataDefURL); + + if(datatypes == null){ + DataTypeParser p = new DataTypeParser(dataDefURL); + datatypes = p.getMobyDataTypesFromRDF(); + for(MobyDataType dataType: datatypes){ + dataType.setRegistry(reg); + } + } } catch(Exception e){ System.err.println("Cannot parse MOBY Object Ontology: " + e); e.printStackTrace(); return null; } + datatypesMapBySynonym.put(reg.getSynonym(), datatypes); + datatypesMapByURL.put(dataDefURL, datatypes); } } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyNamespace.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyNamespace.java 2006/09/22 22:55:38 1.6 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyNamespace.java 2007/06/08 14:04:27 1.7 @@ -7,9 +7,13 @@ package org.biomoby.shared; -import java.util.Comparator; +import org.biomoby.client.CentralImpl; +import org.biomoby.registry.meta.Registry; import org.biomoby.shared.extended.NamespaceParser; +import java.util.*; +import java.net.URL; + /** * A container representing a namespace used in the Moby registry. *

      @@ -30,9 +34,10 @@ protected String description = ""; protected String lsid = null; protected String id = null; + protected Registry registry; //provenance of the namspace definition - protected static MobyNamespace[] uninitializedNamespaces = new MobyNamespace[0]; - protected static MobyNamespace[] namespaces = uninitializedNamespaces; + private static Map namespacesMapBySynonym = new HashMap(); + private static Map namespacesMapByURL = new HashMap(); /************************************************************************** * Default constructor. Other characteristics are empty - which is usually @@ -42,23 +47,91 @@ this.name = name; } + protected static String convertRegistryToNamespaceResourceURL(Registry reg) throws MobyException{ + CentralImpl central = new CentralImpl(reg.getEndpoint()); + MobyResourceRef[] resources = central.getResourceRefs(); + for(MobyResourceRef resource: resources){ + if(Central.NAMESPACES_RESOURCE_NAME.equals(resource.getResourceName())){ + return resource.getResourceLocation().toString(); + } + } + System.err.println("Error! Could not find the namespace resource from the registry " + reg.getSynonym()); + return null; + } + + public Registry getRegistry(){ + return registry; + } + + public void setRegistry(Registry reg){ + reg = registry; + } + + /** + * Particularly useful for loading namespace definitions from cached file, or + * refreshing an in-memory cache. + */ + public static void loadNamespaces(URL namespaceDefURL, Registry reg){ + MobyNamespace[] namespaces; + try{ + NamespaceParser p = new NamespaceParser(namespaceDefURL); + namespaces = p.getMobyNamespacesFromRDF(); + + for(MobyNamespace namespace: namespaces){ + namespace.setRegistry(reg); + } + } + catch(Exception e){ + System.err.println("Cannot parse MOBY Namespace Ontology: " + e); + e.printStackTrace(); + return; + } + namespacesMapBySynonym.put(reg.getSynonym(), namespaces); + namespacesMapByURL.put(namespaceDefURL.toString(), namespaces); + } + public static MobyNamespace getNamespace(String ns){ + return getNamespace(ns, null); + } + + public static MobyNamespace getNamespace(String ns, Registry reg){ if(ns == null){ return null; } + if(reg == null){ + reg = MobyDataType.getDefaultRegistry(); + } + if(reg == null){ + return null; + } + + MobyNamespace[] namespaces = namespacesMapBySynonym.get(reg.getSynonym()); + // This method has not been called yet in the JVM, populate the datatypes - synchronized (namespaces){ - if(namespaces == uninitializedNamespaces){ + synchronized(namespacesMapByURL){ + if(namespaces == null){ + String namespaceDefURL = null; try{ - NamespaceParser p = new NamespaceParser("http://biomoby.org/RESOURCES/MOBY-S/Namespaces"); - namespaces = p.getMobyNamespacesFromRDF(); + namespaces = namespacesMapByURL.get(namespaceDefURL); + + if(namespaces == null){ + namespaceDefURL = convertRegistryToNamespaceResourceURL(reg); + NamespaceParser p = new NamespaceParser(namespaceDefURL); + namespaces = p.getMobyNamespacesFromRDF(); + + for(MobyNamespace namespace: namespaces){ + namespace.setRegistry(reg); + } + } } catch(Exception e){ System.err.println("Cannot parse MOBY Namespace Ontology: " + e); e.printStackTrace(); return null; } + namespacesMapBySynonym.put(reg.getSynonym(), namespaces); + namespacesMapByURL.put(namespaceDefURL, namespaces); } } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyService.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyService.java 2007/05/31 13:42:51 1.18 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyService.java 2007/06/08 14:04:27 1.19 @@ -7,9 +7,9 @@ package org.biomoby.shared; -import java.util.Comparator; -import java.util.Enumeration; -import java.util.Vector; +import java.util.*; +import java.net.URL; +import java.util.regex.Pattern; import org.biomoby.shared.extended.ServiceInstanceParser; /** @@ -76,6 +76,7 @@ // We need both, because you can't synchrinize on a null array protected static MobyService[] uninitializedServices = new MobyService[0]; protected static MobyService[] services = uninitializedServices; + protected static Map serviceMap = new HashMap(); // the elements of these Vectors are of type MobyData protected Vector primaryInputs = new Vector(); @@ -507,36 +508,68 @@ this.serviceType = (serviceType == null ? new MobyServiceType() : serviceType); } + public static MobyService getService(String lsid){ + String[] lsidParts = lsid.split(":"); + String[] sNameParts = lsidParts[4].split(","); + return getService(sNameParts[1], sNameParts[0]); + } + public static MobyService getService(String name, String authority){ if(name == null || authority == null){ return null; } - // This method has not been called yet in the JVM, populate the datatypes - synchronized (services){ - if(services == uninitializedServices){ - try{ - ServiceInstanceParser p = new ServiceInstanceParser("http://biomoby.org/RESOURCES/MOBY-S/ServiceInstances"); - services = p.getMobyServicesFromRDF(); + // Perform a linear search for the corresponding namespace and authority + String lsid = "urn:lsid:biomoby.org:serviceinstance:"+authority+","+name; + if(!serviceMap.containsKey(lsid)){ + try{ + URL lsidResolver = new URL("http://mobycentral.icapture.ubc.ca/authority/lsid/ResolveLSID?lsid="+lsid); + Object o = getContent(lsidResolver); + if(!(o instanceof String)){ + System.err.println("Response for "+lsid + " was not a String, but a " + o.getClass()); + } + String metadata = (String) o; + + String redirectPattern = "latest>"; + int redirectStringIndex = metadata.indexOf(redirectPattern+lsid); + String lsidFull = null; + if(redirectStringIndex != -1){ + int lsidFullIndex = redirectStringIndex+redirectPattern.length(); + lsidFull = metadata.substring(lsidFullIndex, lsidFullIndex+lsid.length()+21); + //System.err.println("Retrieving full LSID " + lsidFull); + lsidResolver = new URL("http://mobycentral.icapture.ubc.ca/authority/lsid/ResolveLSID?lsid="+lsidFull); + metadata = getContent(lsidResolver); } - catch(Exception e){ - System.err.println("Cannot parse MOBY Service Instance Database: " + e); - e.printStackTrace(); - return null; + metadata = Pattern.compile(".*(<\\?xml\\s.*RDF>).*", Pattern.DOTALL).matcher(metadata).replaceFirst("$1") + .replaceAll(">",">") + .replaceAll("<","<") + .replaceAll(""", "\"") + .replaceAll("&", "&"); + //System.err.println(metadata); + + ServiceInstanceParser p = new ServiceInstanceParser(); + services = p.getMobyServicesFromRDF(metadata); + if(services.length > 0){ + serviceMap.put(lsid, services[0]); + if(lsidFull != null){ + serviceMap.put(lsidFull, services[0]); + } } + } catch(Exception e){ + e.printStackTrace(); } } - // Perform a linear search for the corresponding namespace and authority - for(int i = 0; i < services.length; i++){ - if(name.equals(services[i].getName()) && - authority.equals(services[i].getAuthority())){ - return services[i]; - } - } + return serviceMap.get(lsid); + } - // Wasn't found if we got to here - return null; + private static String getContent(URL u) throws Exception{ + StringBuffer contents = new StringBuffer(); + java.io.LineNumberReader reader = new java.io.LineNumberReader(new java.io.InputStreamReader(u.openStream())); + for(String line = reader.readLine(); line != null; line = reader.readLine()){ + contents.append(line+"\n"); + } + return contents.toString(); } public boolean isAsynchronous(){ =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyServiceType.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyServiceType.java 2006/09/22 22:56:44 1.7 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyServiceType.java 2007/06/08 14:04:27 1.8 @@ -7,10 +7,13 @@ package org.biomoby.shared; -import java.util.Comparator; -import java.util.Vector; +import org.biomoby.client.CentralImpl; +import org.biomoby.registry.meta.Registry; import org.biomoby.shared.extended.ServiceTypeParser; +import java.util.*; +import java.net.URL; + /** * A container representing a service type used in the Moby registry. *

      @@ -33,9 +36,10 @@ protected String[] parentNames = new String[] { }; protected String id = null; protected String lsid = null; + protected Registry registry; // provenance of the service type definition - protected static MobyServiceType[] unintializedServicetypes = new MobyServiceType[0]; - protected static MobyServiceType[] servicetypes = unintializedServicetypes; + private static Map servicetypesMapBySynonym = new HashMap(); + private static Map servicetypesMapByURL = new HashMap(); public int compareTo (Object obj) { return name.compareToIgnoreCase ( ((MobyServiceType)obj).getName() ); @@ -59,23 +63,91 @@ setName (typeName); } + protected static String convertRegistryToServiceTypeResourceURL(Registry reg) throws MobyException{ + CentralImpl central = new CentralImpl(reg.getEndpoint()); + MobyResourceRef[] resources = central.getResourceRefs(); + for(MobyResourceRef resource: resources){ + if(Central.SERVICE_TYPES_RESOURCE_NAME.equals(resource.getResourceName())){ + return resource.getResourceLocation().toString(); + } + } + System.err.println("Error! Could not find the service type resource from the registry " + reg.getSynonym()); + return null; + } + + public Registry getRegistry(){ + return registry; + } + + public void setRegistry(Registry reg){ + reg = registry; + } + + /** + * Particularly useful for loading namespace definitions from cached file, or + * refreshing an in-memory cache. + */ + public static void loadServiceTypes(URL serviceDefURL, Registry reg){ + MobyServiceType[] servicetypes; + try{ + ServiceTypeParser p = new ServiceTypeParser(serviceDefURL); + servicetypes = p.getMobyServiceTypesFromRDF(); + + for(MobyServiceType servicetype: servicetypes){ + servicetype.setRegistry(reg); + } + } + catch(Exception e){ + System.err.println("Cannot parse MOBY Service Type Ontology: " + e); + e.printStackTrace(); + return; + } + servicetypesMapBySynonym.put(reg.getSynonym(), servicetypes); + servicetypesMapByURL.put(serviceDefURL.toString(), servicetypes); + } + public static MobyServiceType getServiceType(String className){ + return getServiceType(className, null); + } + + public static MobyServiceType getServiceType(String className, Registry reg){ if(className == null){ return null; } - synchronized(servicetypes){ - if(servicetypes == unintializedServicetypes){ + if(reg == null){ + reg = MobyDataType.getDefaultRegistry(); + } + if(reg == null){ + return null; + } + + MobyServiceType[] servicetypes = servicetypesMapBySynonym.get(reg.getSynonym()); + + // This method has not been called yet in the JVM, populate the datatypes + synchronized(servicetypesMapByURL){ + if(servicetypes == null){ + String serviceDefURL = null; try{ - // Using test server for now, as it deals with the RDF properly - ServiceTypeParser p = new ServiceTypeParser("http://biomoby.org/RESOURCES/MOBY-S/Services"); - servicetypes = p.getMobyServiceTypesFromRDF(); + servicetypes = servicetypesMapByURL.get(serviceDefURL); + + if(servicetypes == null){ + serviceDefURL = convertRegistryToServiceTypeResourceURL(reg); + ServiceTypeParser p = new ServiceTypeParser(serviceDefURL); + servicetypes = p.getMobyServiceTypesFromRDF(); + + for(MobyServiceType servicetype: servicetypes){ + servicetype.setRegistry(reg); + } + } } catch(Exception e){ System.err.println("Cannot parse MOBY Service Type Ontology: " + e); e.printStackTrace(); return null; } + servicetypesMapBySynonym.put(reg.getSynonym(), servicetypes); + servicetypesMapByURL.put(serviceDefURL, servicetypes); } } From gordonp at dev.open-bio.org Fri Jun 8 14:04:27 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 8 Jun 2007 10:04:27 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706081404.l58E4Rc4028952@dev.open-bio.org> gordonp Fri Jun 8 10:04:27 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client In directory dev.open-bio.org:/tmp/cvs-serv28675/src/main/org/biomoby/client Modified Files: MobyRequest.java MobyRequestEvent.java MobyRequestEventHandler.java Log Message: Commit of Seahawk 1.0 updates and associated core updates moby-live/Java/src/main/org/biomoby/client MobyRequest.java,1.25,1.26 MobyRequestEvent.java,1.4,1.5 MobyRequestEventHandler.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java 2007/04/26 15:08:03 1.25 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java 2007/06/08 14:04:27 1.26 @@ -273,17 +273,17 @@ * @throws SOAPException i.e. there was a problem with the underlying transaction/transport layer */ public MobyContentInstance invokeService() throws Exception, MobyException, SOAPException, NoSuccessException{ - return invokeService((StringBuffer) null); + return invokeService(inputData, (StringBuffer) null); } // Used internally for asynchronous thread calls that all need the XML data // and can't rely on the answer from thread-insensitive getResponseXML() - private MobyContentInstance invokeService(StringBuffer contentsXML) + private MobyContentInstance invokeService(MobyContentInstance inData, StringBuffer contentsXML) throws Exception, MobyException, SOAPException, NoSuccessException{ - return invokeService(contentsXML, null, 0); + return invokeService(inData, contentsXML, null, 0); } - private MobyContentInstance invokeService(StringBuffer contentsXML, MobyRequestEventHandler handler, int requestId) + private MobyContentInstance invokeService(MobyContentInstance inData, StringBuffer contentsXML, MobyRequestEventHandler handler, int requestId) throws Exception, MobyException, SOAPException, NoSuccessException{ if(mobyService == null){ @@ -293,10 +293,10 @@ Element mobyDOM = null; if(mobyService.isAsynchronous()){ // Async is "simpler", because it had to merge DOMs together into a single MobyContentInstance anyway - return performAsyncSOAPRequest(mobyService, inputData, handler, requestId); + return performAsyncSOAPRequest(mobyService, inData, handler, requestId); } else{ - String mobyXML = convertMOBYDataToMOBYRequest(inputData); + String mobyXML = convertMOBYDataToMOBYRequest(inData); Call call = getServiceFromWSDL(); mobyDOM = performSOAPRequest(call, mobyXML, contentsXML); // The following parses the DOM and extracts all the appropriate jMOBY objects to represent the XML in Java @@ -342,7 +342,7 @@ } // Inform the handler that some data has been added to the response (for incremental display?) - MobyRequestEvent mre = new MobyRequestEvent(finalContents, this, null, requestId); + MobyRequestEvent mre = new MobyRequestEvent(finalContents, this, mservice, null, requestId); StringWriter xmlWriter = new StringWriter(); MobyDataUtils.toXMLDocument(xmlWriter, finalContents); @@ -377,7 +377,7 @@ public synchronized int invokeService(MobyRequestEventHandler handler){ int id = autoID++; - Thread t = new InvocationThread(this, handler, id); // see internal class definition below + Thread t = new InvocationThread(this, inputData, handler, id); // see internal class definition below t.start(); return id; @@ -386,12 +386,14 @@ // This is the class that asynchronously calls the service and does a callback to // the handler specified in the invocation. class InvocationThread extends Thread { + MobyContentInstance data; MobyService mservice; MobyRequest mobyRequest; MobyRequestEventHandler handler; int requestId; - InvocationThread(MobyRequest mr, MobyRequestEventHandler h, int id){ + InvocationThread(MobyRequest mr, MobyContentInstance inData, MobyRequestEventHandler h, int id){ + data = inData; mobyRequest = mr; mservice = mobyRequest.getService(); handler = h; @@ -402,21 +404,24 @@ } public void run() { - MobyContentInstance content = null; + MobyRequestEvent requestEvent = new MobyRequestEvent(data, mobyRequest, mservice, null, requestId); + // Tell the handler we're starting the request, with the given data + handler.start(requestEvent); + MobyRequestEvent responseEvent = null; - handler.start(mobyRequest, requestId); + MobyContentInstance content = null; StringBuffer contentsXML = new StringBuffer(); //to be filled in by the RPC call below try{ - content = mobyRequest.invokeService(contentsXML, handler, requestId); //RPC call... + content = mobyRequest.invokeService(data, contentsXML, handler, requestId); //RPC call... } catch(Exception e){ - responseEvent = new MobyRequestEvent(content, mobyRequest, e, requestId); + responseEvent = new MobyRequestEvent(content, mobyRequest, mservice, e, requestId); } catch(Error err){ - responseEvent = new MobyRequestEvent(content, mobyRequest, err, requestId); + responseEvent = new MobyRequestEvent(content, mobyRequest, mservice, err, requestId); } if(responseEvent == null){ - responseEvent = new MobyRequestEvent(content, mobyRequest, null, requestId); + responseEvent = new MobyRequestEvent(content, mobyRequest, mservice, null, requestId); } // We've got the raw XML laying around, so why not provide it unmolested to the callback? responseEvent.setContentsXML(contentsXML.toString()); =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequestEvent.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequestEvent.java 2006/07/07 04:12:39 1.4 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequestEvent.java 2007/06/08 14:04:27 1.5 @@ -2,6 +2,7 @@ import java.io.ByteArrayOutputStream; import java.io.ByteArrayInputStream; +import org.biomoby.shared.MobyService; import org.biomoby.shared.data.MobyContentInstance; import org.biomoby.shared.data.MobyDataUtils; @@ -18,17 +19,26 @@ protected MobyContentInstance contents; protected MobyRequest originatingMobyRequest; protected String dataPayloadXML; + protected MobyService service; protected Throwable exception; private static int nextEventID = 0; - public MobyRequestEvent(MobyContentInstance mci, MobyRequest requestSource, Throwable e, int id){ + public MobyRequestEvent(MobyContentInstance mci, MobyRequest requestSource, MobyService serv, Throwable e, int id){ consumed = false; done = false; contents = mci; originatingMobyRequest = requestSource; exception = e; eventID = id; + service = serv; + } + + /** + * @return the name of the remote service generating the event + */ + public MobyService getService(){ + return service; } /** =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequestEventHandler.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequestEventHandler.java 2006/03/28 21:11:22 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequestEventHandler.java 2007/06/08 14:04:27 1.3 @@ -12,10 +12,10 @@ public interface MobyRequestEventHandler{ /** - * If a client, denotes that a service request has been sent. + * If a client, denotes that a service request has been sent (and the contents is exactly what is being sent to the service). * If a server, denotes that you should be ready to start receiving events (an init of sorts) */ - public void start(MobyRequest request, int requestID); + public void start(MobyRequestEvent request); public void processEvent(MobyRequestEvent mre); From gordonp at dev.open-bio.org Fri Jun 8 14:04:27 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 8 Jun 2007 10:04:27 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706081404.l58E4RGW028866@dev.open-bio.org> gordonp Fri Jun 8 10:04:27 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services In directory dev.open-bio.org:/tmp/cvs-serv28675/src/main/ca/ucalgary/seahawk/services Modified Files: MobyClient.java MobyComplexBuilder.java TextClient.java Log Message: Commit of Seahawk 1.0 updates and associated core updates moby-live/Java/src/main/ca/ucalgary/seahawk/services MobyClient.java,1.12,1.13 MobyComplexBuilder.java,1.6,1.7 TextClient.java,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java 2007/04/26 15:22:27 1.12 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java 2007/06/08 14:04:27 1.13 @@ -1,8 +1,10 @@ package ca.ucalgary.seahawk.services; import ca.ucalgary.seahawk.util.NamespaceContextImpl; +import ca.ucalgary.seahawk.util.SeahawkOptions; import org.biomoby.client.*; +import org.biomoby.registry.meta.Registry; import org.biomoby.shared.*; import org.biomoby.shared.data.*; @@ -15,12 +17,7 @@ import org.apache.xml.utils.PrefixResolver; import org.apache.xml.utils.PrefixResolverDefault; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -import javax.xml.parsers.*; +import org.w3c.dom.*; import java.io.*; import java.net.URL; @@ -28,6 +25,7 @@ import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; +import javax.xml.parsers.*; /** * The engine that finds MOBY data in unstructured text or DOM of other XML languages according @@ -76,7 +74,17 @@ private int serviceLevel = MobyService.UNCHECKED; public MobyClient() throws MobyException{ - c = new CentralCachedCallsImpl(); + Registry reg = SeahawkOptions.getRegistry(); + if(reg == null){ + reg = MobyDataType.getDefaultRegistry(); + } + + if(reg != null && reg.getEndpoint() != null){ + c = new CentralCachedCallsImpl(reg.getEndpoint()); + } + else{ + c = new CentralCachedCallsImpl(); + } xpathMap = new HashMap(); urlRegexMap = new HashMap(); regexMap = new HashMap(); @@ -657,7 +665,7 @@ */ public MobyDataObject[] getMobyObjects(byte[] rawData, MobyDataType targetDataType){ // Only do the magic check if the target data type inherits from MOBY's base64 class (i.e. might encode binary data) - if(!targetDataType.inheritsFrom(MobyDataType.getDataType(MobyDataBytes.BASE64_DATATYPE))){ + if(!targetDataType.inheritsFrom(MobyDataType.getDataType(MobyDataBytes.BASE64_DATATYPE, targetDataType.getRegistry()))){ //System.err.println("Data type does not inerit from Base64, continuing with string-based search..."); return getMobyObjects(new String(rawData), targetDataType); } @@ -959,7 +967,8 @@ //} mService[j].setStatus(MobyService.ALIVE, isServiceAlive(mService[j])); - mService[j].setServiceType(MobyServiceType.getServiceType(mService[j].getServiceType().getName())); + mService[j].setServiceType(MobyServiceType.getServiceType(mService[j].getServiceType().getName(), + SeahawkOptions.getRegistry())); if(serviceLevel != MobyService.UNCHECKED){ int serviceStatus = mService[j].getStatus(); //System.err.println("Service " + mService[j].getName() + " has status " + serviceStatus); =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyComplexBuilder.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyComplexBuilder.java 2007/04/18 15:58:08 1.6 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyComplexBuilder.java 2007/06/08 14:04:27 1.7 @@ -1,5 +1,7 @@ package ca.ucalgary.seahawk.services; +import ca.ucalgary.seahawk.util.SeahawkOptions; + import org.biomoby.shared.*; import org.biomoby.shared.data.MobyDataObject; import org.biomoby.shared.data.MobyDataComposite; @@ -46,7 +48,7 @@ } public MobyComplexBuilder(String dataType, Map members, Map nameSpaces, String articleName) throws Exception{ - mobyDataType = MobyDataType.getDataType(dataType); + mobyDataType = MobyDataType.getDataType(dataType, SeahawkOptions.getRegistry()); // Not an existing Ontology data type if(mobyDataType == null){ mobyDataType = new MobyDataType(dataType); @@ -96,7 +98,7 @@ String ns = (String) iter.next(); // Give the namespace a meaningful description from the MOBY registry - mobyNS[i] = MobyNamespace.getNamespace(ns); + mobyNS[i] = MobyNamespace.getNamespace(ns, SeahawkOptions.getRegistry()); if(mobyNS[i] == null){ System.err.println("Namespace '"+ns+"' is not registered in MOBY Central"); // Not a registered namespace in MOBY Central's ontology @@ -114,7 +116,7 @@ MobyDataObject mobyObj = null; if(mobyDataType.getName().equals("Object")){ - mobyObj = new MobyDataObject(""); + mobyObj = new MobyDataObject("", SeahawkOptions.getRegistry()); } // else ifs for other primitives in the future maybe? else{ @@ -152,7 +154,7 @@ } else{ // ... the subsequent ones are saved as cross-references - mobyObj.addCrossReference(new MobyDataObject(mobyNS[i].getName(), result)); + mobyObj.addCrossReference(new MobyDataObject(mobyNS[i].getName(), result, SeahawkOptions.getRegistry())); } } } @@ -182,6 +184,7 @@ } } } + System.err.println("Namespace of object being returned is " + mobyObj.getPrimaryNamespace().getName()); return mobyObj; } @@ -190,6 +193,7 @@ throws MobyException{ byte[] resultBytes = result.getBytes(); boolean nonBasic = result.length() != 2 || result.indexOf("$") != 0; + boolean isBinary = encodingMode != null && encodingMode.equals(MobyClient.ENCODING_ATTR_BASE64_VAL); MobyPrefixResolver.MobyNodeList nodeList = new MobyPrefixResolver.MobyNodeList(); @@ -205,7 +209,7 @@ // "$250 per metre". Not sure of a good way around this yet (i.e. when varValue had $k in it where k > j)... for(int j = 0; j <= matcher.groupCount(); j++){ // A replaceAll() for binary data - if(data != null){ + if(data != null && isBinary){ int srcPos = 0; for(int varIndex = result.indexOf("$"+j, srcPos); varIndex != -1; @@ -251,7 +255,7 @@ } } - if(encodingMode != null && encodingMode.equals(MobyClient.ENCODING_ATTR_BASE64_VAL)){ + if(isBinary){ //(new Exception("Base 64 encoding")).printStackTrace(); result = org.apache.axis.encoding.Base64.encode(data == null ? result.getBytes() : resultBytes); } @@ -281,7 +285,7 @@ MobyDataObject mobyObj = null; if(mobyDataType.getName().equals("Object")){ - mobyObj = new MobyDataObject(""); + mobyObj = new MobyDataObject("", SeahawkOptions.getRegistry()); } // else ifs for other primitives in the future maybe? else{ @@ -306,7 +310,7 @@ } else{ // ... the subsequent ones are saved as cross-references - mobyObj.addCrossReference(new MobyDataObject(mobyNS[i].getName(), value)); + mobyObj.addCrossReference(new MobyDataObject(mobyNS[i].getName(), value, SeahawkOptions.getRegistry())); } } } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/TextClient.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/TextClient.java 2007/04/18 16:07:41 1.3 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/TextClient.java 2007/06/08 14:04:27 1.4 @@ -1,5 +1,7 @@ package ca.ucalgary.seahawk.services; +import ca.ucalgary.seahawk.util.SeahawkOptions; + import org.biomoby.shared.*; import org.biomoby.shared.data.MobyDataInstance; @@ -92,7 +94,7 @@ } // See if the type exists in the ontology - MobyDataType type = MobyDataType.getDataType(templateNameParts[0]); + MobyDataType type = MobyDataType.getDataType(templateNameParts[0], SeahawkOptions.getRegistry()); if(type == null){ System.err.println("Ignoring template whose name attribute (" + templateName + ") uses a non-existent datatype (" + templateNameParts[0] + ")"); From gordonp at dev.open-bio.org Fri Jun 8 20:30:22 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 8 Jun 2007 16:30:22 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706082030.l58KUMbr029949@dev.open-bio.org> gordonp Fri Jun 8 16:30:21 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util In directory dev.open-bio.org:/tmp/cvs-serv29870/src/main/ca/ucalgary/seahawk/util Modified Files: SeahawkOptions.java Log Message: Code revamp to deal with new disk cache moby-live/Java/src/main/ca/ucalgary/seahawk/util SeahawkOptions.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/SeahawkOptions.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/SeahawkOptions.java 2007/06/08 14:04:27 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/SeahawkOptions.java 2007/06/08 20:30:21 1.2 @@ -265,7 +265,7 @@ * @return the file system location where preferences are stored (whether the file currently exists or not) */ public static File getDefaultsFile(){ - return new File(System.getProperty("java.io.tmpdir"), System.getProperty("user.name")+"."+PROPS_FILE_NAME); + return new File(System.getProperty("user.dir"), PROPS_FILE_NAME); } /** @@ -320,12 +320,12 @@ throw new IOException("The temporary data path given (" + dir.toString() + ") is not writeable as required"); } - // Uncomment if we ever need to do a directory listing - //if(!dir.canRead()){ - // throw new IOException("The temporary data path given (" + dir.toString() + - // ") is not readable as required"); - //} + if(!dir.canRead()){ + throw new IOException("The temporary data path given (" + dir.toString() + + ") is not readable as required"); + } tmpDir = dir; + RegistryCache.setTempDir(dir); } /** From gordonp at dev.open-bio.org Fri Jun 8 20:30:22 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 8 Jun 2007 16:30:22 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706082030.l58KUMQ8029985@dev.open-bio.org> gordonp Fri Jun 8 16:30:22 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/meta In directory dev.open-bio.org:/tmp/cvs-serv29870/src/main/org/biomoby/registry/meta Modified Files: Registry.java Log Message: Code revamp to deal with new disk cache moby-live/Java/src/main/org/biomoby/registry/meta Registry.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/meta/Registry.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/meta/Registry.java 2007/05/31 13:42:51 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/meta/Registry.java 2007/06/08 20:30:22 1.3 @@ -8,6 +8,10 @@ package org.biomoby.registry.meta; +import org.biomoby.client.CentralImpl; +import org.biomoby.shared.MobyResourceRef; +import org.biomoby.shared.MobyException; + /** * A container for meta data about a BioMoby registry.

      * @@ -172,4 +176,23 @@ isPublic = value; } + /** + * Learn the RDF location for resources of the registry. + * + * @param resourceName one of the org.biomoby.shared.Central RESOURCE constants + * + * @return the URL of the resource, or null if the resource does not exist + */ + public static java.net.URL findResourceURL(Registry reg, String resourceName) throws MobyException{ + CentralImpl central = new CentralImpl(reg.getEndpoint()); + MobyResourceRef[] resources = central.getResourceRefs(); + for(MobyResourceRef resource: resources){ + if(resourceName.equals(resource.getResourceName())){ + return resource.getResourceLocation(); + } + } + System.err.println("Error! Could not find the data type resource from the registry " + reg.getSynonym()); + return null; + } + } From gordonp at dev.open-bio.org Fri Jun 8 20:30:21 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 8 Jun 2007 16:30:21 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706082030.l58KULP4029931@dev.open-bio.org> gordonp Fri Jun 8 16:30:21 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services In directory dev.open-bio.org:/tmp/cvs-serv29870/src/main/ca/ucalgary/seahawk/services Modified Files: MobyClient.java Log Message: Code revamp to deal with new disk cache moby-live/Java/src/main/ca/ucalgary/seahawk/services MobyClient.java,1.13,1.14 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java 2007/06/08 14:04:27 1.13 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java 2007/06/08 20:30:21 1.14 @@ -4,7 +4,7 @@ import ca.ucalgary.seahawk.util.SeahawkOptions; import org.biomoby.client.*; -import org.biomoby.registry.meta.Registry; +import org.biomoby.registry.meta.*; import org.biomoby.shared.*; import org.biomoby.shared.data.*; @@ -76,7 +76,7 @@ public MobyClient() throws MobyException{ Registry reg = SeahawkOptions.getRegistry(); if(reg == null){ - reg = MobyDataType.getDefaultRegistry(); + reg = RegistryCache.getDefaultRegistry(); } if(reg != null && reg.getEndpoint() != null){ From gordonp at dev.open-bio.org Fri Jun 8 20:30:22 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 8 Jun 2007 16:30:22 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706082030.l58KUMFw030021@dev.open-bio.org> gordonp Fri Jun 8 16:30:22 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared In directory dev.open-bio.org:/tmp/cvs-serv29870/src/main/org/biomoby/shared Modified Files: MobyDataType.java MobyNamespace.java MobyServiceType.java Log Message: Code revamp to deal with new disk cache moby-live/Java/src/main/org/biomoby/shared MobyDataType.java,1.15,1.16 MobyNamespace.java,1.7,1.8 MobyServiceType.java,1.8,1.9 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataType.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataType.java 2007/06/08 14:04:27 1.15 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataType.java 2007/06/08 20:30:22 1.16 @@ -11,7 +11,8 @@ import java.util.*; import org.biomoby.client.CentralImpl; -import org.biomoby.registry.meta.*; +import org.biomoby.registry.meta.Registry; +import org.biomoby.registry.meta.RegistryCache; import org.biomoby.shared.extended.DataTypeParser; /** @@ -55,8 +56,7 @@ protected Registry registry = null; // with which registry was the data type registered? private static Map datatypesMapBySynonym = new HashMap(); - private static Map datatypesMapByURL = new HashMap(); - private static Registry defaultRegistry = null; + private static Map datatypesMapByURL = new HashMap(); /************************************************************************** * Default constructor. @@ -87,57 +87,24 @@ return registry; } - protected static String convertRegistryToDataTypeResourceURL(Registry reg) throws MobyException{ - CentralImpl central = new CentralImpl(reg.getEndpoint()); - MobyResourceRef[] resources = central.getResourceRefs(); - for(MobyResourceRef resource: resources){ - if(Central.DATA_TYPES_RESOURCE_NAME.equals(resource.getResourceName())){ - return resource.getResourceLocation().toString(); - } - } - System.err.println("Error! Could not find the data type resource from the registry " + reg.getSynonym()); - return null; - } - - public synchronized static Registry getDefaultRegistry(){ - if(defaultRegistry == null){ - try{ - defaultRegistry = (new RegistriesList()).get(Registries.DEFAULT_REGISTRY_SYNONYM); - } catch(Exception e){ - e.printStackTrace(); - } - if(defaultRegistry == null){ - System.err.println("Error! Could not find a default registry! No data types will be available."); - System.err.println("Sought " + Registries.DEFAULT_REGISTRY_SYNONYM + " but available options are:"); - for(String synonym: (new RegistriesList()).list()){ - System.err.println(synonym); - } - } - } - return defaultRegistry; - } - /** * Particularly useful for loading data types from cached file, or * refreshing an in-memory cache. */ - public static void loadDataTypes(URL dataDefURL, Registry reg){ - MobyDataType[] datatypes; - try{ - DataTypeParser p = new DataTypeParser(dataDefURL); - - datatypes = p.getMobyDataTypesFromRDF(); - for(MobyDataType dataType: datatypes){ - dataType.setRegistry(reg); - } + public static void loadDataTypes(URL dataDefURL, Registry reg) throws Exception{ + if(reg == null){ + reg = RegistryCache.getDefaultRegistry(); } - catch(Exception e){ - System.err.println("Cannot parse MOBY Object Ontology: " + e); - e.printStackTrace(); - return; + + MobyDataType[] datatypes; + DataTypeParser p = new DataTypeParser(dataDefURL); + + datatypes = p.getMobyDataTypesFromRDF(); + for(MobyDataType dataType: datatypes){ + dataType.setRegistry(reg); } datatypesMapBySynonym.put(reg.getSynonym(), datatypes); - datatypesMapByURL.put(dataDefURL.toString(), datatypes); + datatypesMapByURL.put(dataDefURL, datatypes); } public static MobyDataType getDataType(String className){ @@ -153,7 +120,7 @@ } if(reg == null){ - reg = getDefaultRegistry(); + reg = RegistryCache.getDefaultRegistry(); } if(reg == null){ return null; @@ -164,26 +131,20 @@ // This method has not been called yet in the JVM, populate the datatypes synchronized(datatypesMapByURL){ if(datatypes == null){ - String dataDefURL = null; try{ - dataDefURL = convertRegistryToDataTypeResourceURL(reg); - datatypes = datatypesMapByURL.get(dataDefURL); - + URL dataDefURL = Registry.findResourceURL(reg, Central.DATA_TYPES_RESOURCE_NAME); + datatypes = datatypesMapByURL.get(dataDefURL); if(datatypes == null){ - DataTypeParser p = new DataTypeParser(dataDefURL); - datatypes = p.getMobyDataTypesFromRDF(); - for(MobyDataType dataType: datatypes){ - dataType.setRegistry(reg); - } + loadDataTypes(dataDefURL, reg); + datatypes = datatypesMapByURL.get(dataDefURL); } + } catch(Exception e){ - System.err.println("Cannot parse MOBY Object Ontology: " + e); + System.err.println("Cannot parse MOBY Service Type Ontology: " + e); e.printStackTrace(); return null; } - datatypesMapBySynonym.put(reg.getSynonym(), datatypes); - datatypesMapByURL.put(dataDefURL, datatypes); } } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyNamespace.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyNamespace.java 2007/06/08 14:04:27 1.7 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyNamespace.java 2007/06/08 20:30:22 1.8 @@ -9,6 +9,7 @@ import org.biomoby.client.CentralImpl; import org.biomoby.registry.meta.Registry; +import org.biomoby.registry.meta.RegistryCache; import org.biomoby.shared.extended.NamespaceParser; import java.util.*; @@ -100,7 +101,7 @@ } if(reg == null){ - reg = MobyDataType.getDefaultRegistry(); + reg = RegistryCache.getDefaultRegistry(); } if(reg == null){ return null; =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyServiceType.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyServiceType.java 2007/06/08 14:04:27 1.8 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyServiceType.java 2007/06/08 20:30:22 1.9 @@ -9,6 +9,7 @@ import org.biomoby.client.CentralImpl; import org.biomoby.registry.meta.Registry; +import org.biomoby.registry.meta.RegistryCache; import org.biomoby.shared.extended.ServiceTypeParser; import java.util.*; @@ -39,7 +40,7 @@ protected Registry registry; // provenance of the service type definition private static Map servicetypesMapBySynonym = new HashMap(); - private static Map servicetypesMapByURL = new HashMap(); + private static Map servicetypesMapByURL = new HashMap(); public int compareTo (Object obj) { return name.compareToIgnoreCase ( ((MobyServiceType)obj).getName() ); @@ -63,19 +64,7 @@ setName (typeName); } - protected static String convertRegistryToServiceTypeResourceURL(Registry reg) throws MobyException{ - CentralImpl central = new CentralImpl(reg.getEndpoint()); - MobyResourceRef[] resources = central.getResourceRefs(); - for(MobyResourceRef resource: resources){ - if(Central.SERVICE_TYPES_RESOURCE_NAME.equals(resource.getResourceName())){ - return resource.getResourceLocation().toString(); - } - } - System.err.println("Error! Could not find the service type resource from the registry " + reg.getSynonym()); - return null; - } - - public Registry getRegistry(){ + public Registry getRegistry(){ return registry; } @@ -87,23 +76,20 @@ * Particularly useful for loading namespace definitions from cached file, or * refreshing an in-memory cache. */ - public static void loadServiceTypes(URL serviceDefURL, Registry reg){ - MobyServiceType[] servicetypes; - try{ - ServiceTypeParser p = new ServiceTypeParser(serviceDefURL); - servicetypes = p.getMobyServiceTypesFromRDF(); - - for(MobyServiceType servicetype: servicetypes){ - servicetype.setRegistry(reg); - } + public static void loadServiceTypes(URL serviceDefURL, Registry reg) throws Exception{ + if(reg == null){ + reg = RegistryCache.getDefaultRegistry(); } - catch(Exception e){ - System.err.println("Cannot parse MOBY Service Type Ontology: " + e); - e.printStackTrace(); - return; + + MobyServiceType[] servicetypes; + ServiceTypeParser p = new ServiceTypeParser(serviceDefURL); + servicetypes = p.getMobyServiceTypesFromRDF(); + + for(MobyServiceType servicetype: servicetypes){ + servicetype.setRegistry(reg); } servicetypesMapBySynonym.put(reg.getSynonym(), servicetypes); - servicetypesMapByURL.put(serviceDefURL.toString(), servicetypes); + servicetypesMapByURL.put(serviceDefURL, servicetypes); } public static MobyServiceType getServiceType(String className){ @@ -116,7 +102,7 @@ } if(reg == null){ - reg = MobyDataType.getDefaultRegistry(); + reg = RegistryCache.getDefaultRegistry(); } if(reg == null){ return null; @@ -127,18 +113,12 @@ // This method has not been called yet in the JVM, populate the datatypes synchronized(servicetypesMapByURL){ if(servicetypes == null){ - String serviceDefURL = null; try{ - servicetypes = servicetypesMapByURL.get(serviceDefURL); - + URL serviceDefURL = Registry.findResourceURL(reg, Central.SERVICE_TYPES_RESOURCE_NAME); + servicetypes = servicetypesMapByURL.get(serviceDefURL); if(servicetypes == null){ - serviceDefURL = convertRegistryToServiceTypeResourceURL(reg); - ServiceTypeParser p = new ServiceTypeParser(serviceDefURL); - servicetypes = p.getMobyServiceTypesFromRDF(); - - for(MobyServiceType servicetype: servicetypes){ - servicetype.setRegistry(reg); - } + loadServiceTypes(serviceDefURL, reg); + servicetypes = servicetypesMapByURL.get(serviceDefURL); } } catch(Exception e){ @@ -146,8 +126,6 @@ e.printStackTrace(); return null; } - servicetypesMapBySynonym.put(reg.getSynonym(), servicetypes); - servicetypesMapByURL.put(serviceDefURL, servicetypes); } } From gordonp at dev.open-bio.org Fri Jun 8 20:30:21 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 8 Jun 2007 16:30:21 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706082030.l58KULRt029913@dev.open-bio.org> gordonp Fri Jun 8 16:30:21 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv29870/src/main/ca/ucalgary/seahawk/gui Modified Files: MobyContentGUI.java MobyContentPane.java SeahawkOptionsGUI.java Log Message: Code revamp to deal with new disk cache moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyContentGUI.java,1.9,1.10 MobyContentPane.java,1.8,1.9 SeahawkOptionsGUI.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java 2007/06/08 14:04:27 1.9 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java 2007/06/08 20:30:21 1.10 @@ -19,8 +19,10 @@ import org.biomoby.client.MobyRequest; import org.biomoby.client.MobyRequestEvent; import org.biomoby.client.MobyRequestEventHandler; +import org.biomoby.registry.meta.*; import org.biomoby.shared.*; import org.biomoby.shared.data.*; + import ca.ucalgary.seahawk.util.*; /** @@ -949,7 +951,7 @@ } protected static void cacheOntologies(){ - final org.biomoby.registry.meta.Registry preferredRegistry = SeahawkOptions.getRegistry(); + final Registry preferredRegistry = SeahawkOptions.getRegistry(); // Redirect the registry endpoints to local cache files if available // preferredRegistry and/or dataDefURL may be null, if not cached, but that's okay to pass around @@ -957,25 +959,46 @@ // The following command will cache all data type definitions for this session new Thread(){ public void run(){ - URL dataDefURL = RegistryCache.getDataTypeOntologyURL(preferredRegistry); - if(dataDefURL != null){ - // Use the cached file rather than actually going to the registry - MobyDataType.loadDataTypes(dataDefURL, preferredRegistry); - } - else{ - MobyDataType.getDataType("Object", preferredRegistry); + File dataDefFile = RegistryCache.getOntologyFile(preferredRegistry, + Central.DATA_TYPES_RESOURCE_NAME); + try{ + URL dataDefURL = dataDefFile.toURI().toURL(); + if(dataDefFile.exists()){ + // Use the cached file rather than actually going to the registry + MobyDataType.loadDataTypes(dataDefURL, preferredRegistry); + } + else{ + // Create it from the remote source, then load it + RegistryCache.cacheRegistryOntology(preferredRegistry, + Central.DATA_TYPES_RESOURCE_NAME); + MobyDataType.loadDataTypes(dataDefURL, preferredRegistry); + } + }catch(Exception e){ + e.printStackTrace(); } } - }.start(); + }.start(); + new Thread(){ public void run(){ - URL serviceTypeDefURL = RegistryCache.getServiceTypeOntologyURL(preferredRegistry); - if(serviceTypeDefURL != null){ - // Use the cached file rather than actually going to the registry - MobyServiceType.loadServiceTypes(serviceTypeDefURL, preferredRegistry); - } - else{ - MobyServiceType.getServiceType("Analysis", preferredRegistry); + File serviceTypeDefFile = RegistryCache.getOntologyFile(preferredRegistry, + Central.SERVICE_TYPES_RESOURCE_NAME); + try{ + URL serviceTypeDefURL = serviceTypeDefFile.toURI().toURL(); + if(serviceTypeDefFile.exists()){ + // Use the cached file rather than actually going to the registry + MobyServiceType.loadServiceTypes(serviceTypeDefURL, + preferredRegistry); + } + else{ + // Create it from the remote source, then load it + RegistryCache.cacheRegistryOntology(preferredRegistry, + Central.SERVICE_TYPES_RESOURCE_NAME); + MobyServiceType.loadServiceTypes(serviceTypeDefURL, + preferredRegistry); + } + } catch(Exception e){ + e.printStackTrace(); } } }.start(); =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java 2007/06/08 14:04:27 1.8 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java 2007/06/08 20:30:21 1.9 @@ -310,9 +310,17 @@ // Shouldn't get here unless either not binary, or the binary data load failed System.err.println("Is plain text"); editorPane.setContentType("text/html"); - resultBuffer = new StringBuffer("

      "+
      -						getInputStreamContents(url.openStream()).replaceAll("&", "&").replaceAll("<","<")+
      -						"
      "); + String body = getInputStreamContents(url.openStream()); + // Is it already HTML? + if(body.toLowerCase().indexOf("
      "+
      +						    body.replaceAll("&", "&").replaceAll("<","<")+
      +						    "
      "); + } editorPane.setText(resultBuffer.toString()); } else{ =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/SeahawkOptionsGUI.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/SeahawkOptionsGUI.java 2007/06/08 14:04:27 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/SeahawkOptionsGUI.java 2007/06/08 20:30:21 1.2 @@ -1,4 +1,5 @@ package ca.ucalgary.seahawk.gui; public class SeahawkOptionsGUI{ + } From gordonp at dev.open-bio.org Fri Jun 8 20:30:22 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 8 Jun 2007 16:30:22 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706082030.l58KUMPM029967@dev.open-bio.org> gordonp Fri Jun 8 16:30:22 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client In directory dev.open-bio.org:/tmp/cvs-serv29870/src/main/org/biomoby/client Modified Files: CentralCachedCallsImpl.java Log Message: Code revamp to deal with new disk cache moby-live/Java/src/main/org/biomoby/client CentralCachedCallsImpl.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralCachedCallsImpl.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralCachedCallsImpl.java 2007/06/07 23:55:42 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralCachedCallsImpl.java 2007/06/08 20:30:22 1.3 @@ -8,11 +8,15 @@ package org.biomoby.client; +import org.biomoby.registry.meta.RegistryCache; + import org.biomoby.shared.MobyException; + +import java.io.*; import java.util.*; public class CentralCachedCallsImpl extends CentralImpl{ - + protected static String CHAR_ENCODING = "UTF-8"; protected static final String SYNTAX_TYPE = "xml"; protected static final long THE_EPOCH = 0; // don't care when the call is made, it shouldn't affect the onto mapping of calls to IDs protected static final Properties PROPERTIES = null; // don't have any properties for the call @@ -111,6 +115,71 @@ return result; } + // check existence of a cached object + public boolean existsInCache (String id) { + if(!getCacheMode()){ + return false; + } + if(super.existsInCache(id)){ + return true; + } + + File cachedDataFile = RegistryCache.getCentralCallFile(getRegistryEndpoint(), id); + // See if it's in the disk cache, if so, load it to memory + if(cachedDataFile != null){ + try{ + Object cachedValue = loadDataFromFile(cachedDataFile); + // Save the disk data to memory + super.setContents(id, cachedValue); + } catch(Exception e){ + e.printStackTrace(); + System.err.println("Could not load data from cache file " + cachedDataFile); + return false; + } + return true; + } + else{ + return false; + } + } + + protected Object loadDataFromFile(File cacheFile) throws Exception{ + char[] contentsBuffer = new char[(int) cacheFile.length()]; // assumes filesize < 2GB + FileReader cacheFileReader = new FileReader(cacheFile); + cacheFileReader.read(contentsBuffer); + return new String(contentsBuffer); + } + + protected void storeDataToFile(File cacheFile, Object data) throws Exception{ + if(data instanceof CharSequence){ + FileWriter cacheFileWriter = new FileWriter(cacheFile); + cacheFileWriter.write(((CharSequence) data).toString()); + cacheFileWriter.close(); + } + else if(data instanceof Serializable){ + throw new Exception("Serialization in cache not yet implemented"); + } + else{ + throw new Exception("Asked to serialize data that is neither a CharSequence, " + + "nor serializable. Found " + data.getClass().getName()); + } + } + + // cache an object + public void setContents (String id, java.lang.Object data) { + if(!getCacheMode()){ + return; + } + + super.setContents(id, data); + File cachedDataFile = RegistryCache.calcCentralCallFile(getRegistryEndpoint(), id); + try{ + storeDataToFile(cachedDataFile, data); + } catch(Exception e){ + System.err.println("Could not store data to cache file " + cachedDataFile); + } + } + protected String createId(String method, Object[] parameters){ // Set the semantics to the call parameters's string representation concatenated // If we were to be pedantic, we should covert the xml into a canonical format From gordonp at dev.open-bio.org Fri Jun 8 20:31:15 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 8 Jun 2007 16:31:15 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706082031.l58KVFF2030091@dev.open-bio.org> gordonp Fri Jun 8 16:31:15 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/meta In directory dev.open-bio.org:/tmp/cvs-serv30060/src/main/org/biomoby/registry/meta Added Files: RegistryCache.java Log Message: Moved from Seahawk, updated moby-live/Java/src/main/org/biomoby/registry/meta RegistryCache.java,NONE,1.1 From gordonp at dev.open-bio.org Fri Jun 8 20:32:04 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 8 Jun 2007 16:32:04 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706082032.l58KW43R030152@dev.open-bio.org> gordonp Fri Jun 8 16:32:04 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util In directory dev.open-bio.org:/tmp/cvs-serv30120/src/main/ca/ucalgary/seahawk/util Removed Files: RegistryCache.java Log Message: Moved to org/biomoby/registry/meta/RegistryCache.java moby-live/Java/src/main/ca/ucalgary/seahawk/util RegistryCache.java,1.1,NONE rcsdiff: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/RCS/RegistryCache.java,v: No such file or directory From gordonp at dev.open-bio.org Sat Jun 9 00:26:25 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 8 Jun 2007 20:26:25 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706090026.l590QPqW030470@dev.open-bio.org> gordonp Fri Jun 8 20:26:24 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/meta In directory dev.open-bio.org:/tmp/cvs-serv30435/src/main/org/biomoby/registry/meta Modified Files: RegistriesList.java Log Message: Changed illegal characters in INAB registry description to Unicode a-acute moby-live/Java/src/main/org/biomoby/registry/meta RegistriesList.java,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/meta/RegistriesList.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/meta/RegistriesList.java 2007/05/21 00:56:15 1.3 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/meta/RegistriesList.java 2007/06/09 00:26:24 1.4 @@ -60,7 +60,7 @@ "INAB, Spain", "", true, - "The MOBY registry at the Instituto Nacional de Bioinform??tica, Spain."), + "The MOBY registry at the Instituto Nacional de Bioinform\u00E1tica, Spain."), new Registry ("testing", From gordonp at dev.open-bio.org Sat Jun 9 18:12:53 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Sat, 9 Jun 2007 14:12:53 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706091812.l59ICrcT004820@dev.open-bio.org> gordonp Sat Jun 9 14:12:52 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data In directory dev.open-bio.org:/tmp/cvs-serv4785/src/main/org/biomoby/shared/data Modified Files: MobyDataComposite.java Log Message: Made error message for anonymous member more verbose moby-live/Java/src/main/org/biomoby/shared/data MobyDataComposite.java,1.15,1.16 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataComposite.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataComposite.java 2007/06/07 23:58:15 1.15 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataComposite.java 2007/06/09 18:12:52 1.16 @@ -59,7 +59,7 @@ if(fieldName == null || fieldName.length() == 0){ throw new MobyException("The subelement with index " + i + " does not have an article " + - "name, which is required"); + "name, which is required (tag "+element.getNodeName()+")"); } MobyDataObject childObject = (MobyDataObject) createInstanceFromDOM(child); if(childObject == null){ From gordonp at dev.open-bio.org Sat Jun 9 18:13:38 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Sat, 9 Jun 2007 14:13:38 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706091813.l59IDc7t004863@dev.open-bio.org> gordonp Sat Jun 9 14:13:38 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data In directory dev.open-bio.org:/tmp/cvs-serv4828/src/main/org/biomoby/shared/data Modified Files: MobyDataXref.java Log Message: Fixed DOM parsing so evidence abbrevation, rather than full code, is expected in XML attributes moby-live/Java/src/main/org/biomoby/shared/data MobyDataXref.java,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataXref.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataXref.java 2006/12/13 17:53:57 1.6 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataXref.java 2007/06/09 18:13:38 1.7 @@ -71,7 +71,7 @@ MobyPrefixResolver.getAttr(e, "serviceName"), MobyPrefixResolver.getAttr(e, "authURI")); - setEvidenceCode(MobyPrefixResolver.getAttr(e, "evidenceCode")); + setEvidenceCodeByAbbrev(MobyPrefixResolver.getAttr(e, "evidenceCode")); setXrefType(MobyPrefixResolver.getAttr(e, "xrefType")); String d = e.getTextContent(); @@ -102,6 +102,10 @@ serviceDescription = desc; } + public void setEvidenceCodeByAbbrev(String abbrev) throws IllegalArgumentException{ + setEvidenceCode(evidenceAbbrevToCode(abbrev)); + } + public void setEvidenceCode(String code) throws IllegalArgumentException{ if(code == null || code.length() == 0){ throw new IllegalArgumentException("Evidence code for an Xref cannot be blank"); @@ -115,8 +119,59 @@ } else{ throw new IllegalArgumentException("Evidence code to be set (" + - code + " was not a valid GO code"); + code + ") was not a valid GO code"); + } + } + + /** + * Given one of the static final evidence codes from this class, returns the 2 or 3 letter + * GO evidence abbreviations. See http://www.geneontology.org/doc/GO.evidence.html + */ + public static String evidenceAbbrevToCode(String abbrev) throws IllegalArgumentException{ + if(abbrev == null || abbrev.length() == 0){ + throw new IllegalArgumentException("Evidence code abbreviation for an Xref cannot be blank"); + } + if(abbrev.equals("IC")){ + return IC; + } + if(abbrev.equals("IDA")){ + return IDA; + } + if(abbrev.equals("IEA")){ + return IEA; + } + if(abbrev.equals("IEP")){ + return IEP; + } + if(abbrev.equals("IGI")){ + return IGI; + } + if(abbrev.equals("IMP")){ + return IMP; + } + if(abbrev.equals("IPI")){ + return IPI; + } + if(abbrev.equals("ISS")){ + return ISS; + } + if(abbrev.equals("NAS")){ + return NAS; + } + if(abbrev.equals("ND")){ + return ND; + } + if(abbrev.equals("RCA")){ + return RCA; + } + if(abbrev.equals("TAS")){ + return TAS; + } + if(abbrev.equals("NR")){ + return NR; } + throw new IllegalArgumentException("Evidence abbreviation to expand (" + + abbrev + " was not a valid GO code abbreviation"); } /** From gordonp at dev.open-bio.org Sat Jun 9 18:14:33 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Sat, 9 Jun 2007 14:14:33 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706091814.l59IEXko004918@dev.open-bio.org> gordonp Sat Jun 9 14:14:33 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data In directory dev.open-bio.org:/tmp/cvs-serv4871/src/main/org/biomoby/shared/data Modified Files: MobyDataBoolean.java MobyDataDateTime.java MobyDataFloat.java MobyDataInt.java Log Message: Added trim() calls to make primitives' parsing more robust moby-live/Java/src/main/org/biomoby/shared/data MobyDataBoolean.java,1.4,1.5 MobyDataDateTime.java,1.9,1.10 MobyDataFloat.java,1.7,1.8 MobyDataInt.java,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataBoolean.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataBoolean.java 2007/06/07 23:58:15 1.4 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataBoolean.java 2007/06/09 18:14:33 1.5 @@ -62,11 +62,11 @@ * "Yes" and "1" are not acceptable. */ public MobyDataBoolean(String articleName, String booleanString){ - this(articleName, Boolean.valueOf(booleanString), null); + this(articleName, Boolean.valueOf(booleanString.trim()), null); } public MobyDataBoolean(String articleName, String booleanString, Registry registry){ - this(articleName, Boolean.valueOf(booleanString), registry); + this(articleName, Boolean.valueOf(booleanString.trim()), registry); } public MobyDataBoolean(Boolean b){ =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataDateTime.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataDateTime.java 2007/06/07 23:58:15 1.9 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataDateTime.java 2007/06/09 18:14:33 1.10 @@ -55,7 +55,7 @@ public MobyDataDateTime(String articleName, String stringISO8601, Registry registry) throws IllegalArgumentException{ super(articleName); setDataType(MobyDataType.getDataType(MobyTags.MOBYDATETIME, registry)); - value = parseISO8601(stringISO8601); + value = parseISO8601(stringISO8601.trim()); } public MobyDataDateTime(String stringISO8601){ =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataFloat.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataFloat.java 2007/06/07 23:58:15 1.7 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataFloat.java 2007/06/09 18:14:33 1.8 @@ -102,7 +102,7 @@ public MobyDataFloat(String articleName, String stringNumber, Registry registry) throws NumberFormatException{ super(articleName); setDataType(MobyDataType.getDataType(MobyTags.MOBYFLOAT, registry)); - value = new BigDecimal(stringNumber); + value = new BigDecimal(stringNumber.trim()); } public MobyDataFloat(String stringNumber){ =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataInt.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataInt.java 2007/06/07 23:58:15 1.6 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataInt.java 2007/06/09 18:14:33 1.7 @@ -97,7 +97,7 @@ public MobyDataInt(String articleName, String stringNumber, Registry registry) throws NumberFormatException{ super(articleName); setDataType(MobyDataType.getDataType(MobyTags.MOBYINTEGER, registry)); - value = new BigInteger(stringNumber); + value = new BigInteger(stringNumber.trim()); } /** From gordonp at dev.open-bio.org Sat Jun 9 18:17:12 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Sat, 9 Jun 2007 14:17:12 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706091817.l59IHCdh004982@dev.open-bio.org> gordonp Sat Jun 9 14:17:12 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared In directory dev.open-bio.org:/tmp/cvs-serv4947/src/main/org/biomoby/shared Modified Files: MobyDataType.java Log Message: Shortcircuit on empty parent searches, for efficiency moby-live/Java/src/main/org/biomoby/shared MobyDataType.java,1.16,1.17 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataType.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataType.java 2007/06/08 20:30:22 1.16 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataType.java 2007/06/09 18:17:12 1.17 @@ -159,6 +159,7 @@ } // Wasn't found if we got to here + //(new Exception("Couldn't find data type for '"+className+"'")).printStackTrace(); return null; } @@ -275,7 +276,8 @@ } public MobyDataType getParent(){ - return getDataType(getParentName()); + String parentName = getParentName(); + return parentName == null || parentName.length() == 0 ? null : getDataType(parentName); } /** From gordonp at dev.open-bio.org Sat Jun 9 18:21:43 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Sat, 9 Jun 2007 14:21:43 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706091821.l59ILhQh005046@dev.open-bio.org> gordonp Sat Jun 9 14:21:43 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/meta In directory dev.open-bio.org:/tmp/cvs-serv5011/src/main/org/biomoby/registry/meta Modified Files: RegistryCache.java Log Message: Fixed javadoc, added cache deletion mechanisms, removed debug message moby-live/Java/src/main/org/biomoby/registry/meta RegistryCache.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/meta/RegistryCache.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/meta/RegistryCache.java 2007/06/08 20:31:15 1.1 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/meta/RegistryCache.java 2007/06/09 18:21:43 1.2 @@ -22,7 +22,7 @@ /** * Returns where a resource should be cached locally, whether it current exists or not. * - * @param one of the resources listed in org.biomoby.shared.Central + * @param resourceName one of the resources listed in org.biomoby.shared.Central */ public static File getOntologyFile(Registry reg, String resourceName){ File fileLocation = null; @@ -87,7 +87,6 @@ cacheFileWriter.write(line+"\n"); } cacheFileWriter.close(); - System.err.println("Wrote " + cacheFile); } public synchronized static Registry getDefaultRegistry(){ @@ -112,7 +111,7 @@ String regName = reg == null ? Registries.DEFAULT_REGISTRY_SYNONYM : reg.getSynonym(); String userName = System.getProperty("user.name") == null ? "" : "." + System.getProperty("user.name"); return new File(tempDir, - REG_CACHE_FILE_PREFIX+"DataType"+userName+"."+regName); + REG_CACHE_FILE_PREFIX+userName+"."+regName+".DataTypes.rdf"); } public static File getServiceTypeOntologyFile(Registry reg){ @@ -129,7 +128,7 @@ String regName = reg == null ? Registries.DEFAULT_REGISTRY_SYNONYM : reg.getSynonym(); String userName = System.getProperty("user.name") == null ? "" : "." + System.getProperty("user.name"); return new File(tempDir, - REG_CACHE_FILE_PREFIX+"ServiceType"+userName+"."+regName); + REG_CACHE_FILE_PREFIX+userName+"."+regName+".ServiceTypes.rdf"); } public static File getNamespaceOntologyFile(Registry reg){ @@ -146,7 +145,7 @@ String regName = reg == null ? Registries.DEFAULT_REGISTRY_SYNONYM : reg.getSynonym(); String userName = System.getProperty("user.name") == null ? "" : "." + System.getProperty("user.name"); return new File(tempDir, - REG_CACHE_FILE_PREFIX+"Namespace"+userName+"."+regName); + REG_CACHE_FILE_PREFIX+userName+"."+regName+".Namespaces.rdf"); } public static File getServiceOntologyFile(Registry reg){ @@ -163,7 +162,7 @@ String regName = reg == null ? Registries.DEFAULT_REGISTRY_SYNONYM : reg.getSynonym(); String userName = System.getProperty("user.name") == null ? "" : "." + System.getProperty("user.name"); return new File(tempDir, - REG_CACHE_FILE_PREFIX+"Service"+userName+"."+regName); + REG_CACHE_FILE_PREFIX+userName+"."+regName+".Services.rdf"); } /** @@ -204,4 +203,34 @@ public static void setTempDir(File dir){ tempDir = dir; } + + /** + * @param allowedAgeMillis files older than this are deleted, or if negative, all are deleted, or if zero, deleted at the end of the session + */ + public static void deleteExpiredCacheFiles(long allowedAgeMillis){ + String userName = System.getProperty("user.name") == null ? "" : "." + System.getProperty("user.name"); + String relativeRegFilePrefix = REG_CACHE_FILE_PREFIX+userName; + String relativeCallFilePrefix = CALL_CACHE_FILE_PREFIX+userName; + + long currentTime = System.currentTimeMillis(); + + for(File tempFile: tempDir.listFiles()){ + // See if it belongs to us, based on the name + if(tempFile.getName().startsWith(relativeRegFilePrefix) || + tempFile.getName().startsWith(relativeCallFilePrefix)){ + // 0 means "for this session only" + if(allowedAgeMillis == 0){ + tempFile.deleteOnExit(); + } + else if(allowedAgeMillis < 0 || + currentTime-tempFile.lastModified() > allowedAgeMillis){ + tempFile.delete(); + } + } + } + } + + public static void deleteAllCacheFiles(){ + deleteExpiredCacheFiles(-1); // negative time == delete all + } } From gordonp at dev.open-bio.org Sat Jun 9 21:58:26 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Sat, 9 Jun 2007 17:58:26 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706092158.l59LwQ8h005262@dev.open-bio.org> gordonp Sat Jun 9 17:58:26 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared In directory dev.open-bio.org:/tmp/cvs-serv5219/src/main/org/biomoby/shared Modified Files: MobyDataType.java MobyNamespace.java MobyServiceType.java Log Message: Changed to synchronize multi-thread access better (i.e. don't load an ontology more than once) moby-live/Java/src/main/org/biomoby/shared MobyDataType.java,1.17,1.18 MobyNamespace.java,1.8,1.9 MobyServiceType.java,1.9,1.10 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataType.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataType.java 2007/06/09 18:17:12 1.17 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataType.java 2007/06/09 21:58:26 1.18 @@ -92,19 +92,21 @@ * refreshing an in-memory cache. */ public static void loadDataTypes(URL dataDefURL, Registry reg) throws Exception{ - if(reg == null){ - reg = RegistryCache.getDefaultRegistry(); - } - - MobyDataType[] datatypes; - DataTypeParser p = new DataTypeParser(dataDefURL); - - datatypes = p.getMobyDataTypesFromRDF(); - for(MobyDataType dataType: datatypes){ - dataType.setRegistry(reg); + synchronized(datatypesMapBySynonym){ + if(reg == null){ + reg = RegistryCache.getDefaultRegistry(); + } + + MobyDataType[] datatypes; + DataTypeParser p = new DataTypeParser(dataDefURL); + + datatypes = p.getMobyDataTypesFromRDF(); + for(MobyDataType dataType: datatypes){ + dataType.setRegistry(reg); + } + datatypesMapBySynonym.put(reg.getSynonym(), datatypes); + datatypesMapByURL.put(dataDefURL, datatypes); } - datatypesMapBySynonym.put(reg.getSynonym(), datatypes); - datatypesMapByURL.put(dataDefURL, datatypes); } public static MobyDataType getDataType(String className){ @@ -125,8 +127,11 @@ if(reg == null){ return null; } - - MobyDataType[] datatypes = datatypesMapBySynonym.get(reg.getSynonym()); + MobyDataType[] datatypes = null; + // sync makes sure we don't fetch it if it's currently being loaded by loadDataTypes + synchronized(datatypesMapBySynonym){ + datatypes = datatypesMapBySynonym.get(reg.getSynonym()); + } // This method has not been called yet in the JVM, populate the datatypes synchronized(datatypesMapByURL){ @@ -135,7 +140,9 @@ URL dataDefURL = Registry.findResourceURL(reg, Central.DATA_TYPES_RESOURCE_NAME); datatypes = datatypesMapByURL.get(dataDefURL); if(datatypes == null){ + System.err.println("Fetching data type ontology from " + dataDefURL); loadDataTypes(dataDefURL, reg); + System.err.println(" ... done"); datatypes = datatypesMapByURL.get(dataDefURL); } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyNamespace.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyNamespace.java 2007/06/08 20:30:22 1.8 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyNamespace.java 2007/06/09 21:58:26 1.9 @@ -72,23 +72,23 @@ * Particularly useful for loading namespace definitions from cached file, or * refreshing an in-memory cache. */ - public static void loadNamespaces(URL namespaceDefURL, Registry reg){ - MobyNamespace[] namespaces; - try{ + public static void loadNamespaces(URL namespaceDefURL, Registry reg) throws Exception{ + synchronized(namespacesMapBySynonym){ + if(reg == null){ + reg = RegistryCache.getDefaultRegistry(); + } + + MobyNamespace[] namespaces; NamespaceParser p = new NamespaceParser(namespaceDefURL); namespaces = p.getMobyNamespacesFromRDF(); - + for(MobyNamespace namespace: namespaces){ namespace.setRegistry(reg); } + + namespacesMapBySynonym.put(reg.getSynonym(), namespaces); + namespacesMapByURL.put(namespaceDefURL.toString(), namespaces); } - catch(Exception e){ - System.err.println("Cannot parse MOBY Namespace Ontology: " + e); - e.printStackTrace(); - return; - } - namespacesMapBySynonym.put(reg.getSynonym(), namespaces); - namespacesMapByURL.put(namespaceDefURL.toString(), namespaces); } public static MobyNamespace getNamespace(String ns){ @@ -107,32 +107,30 @@ return null; } - MobyNamespace[] namespaces = namespacesMapBySynonym.get(reg.getSynonym()); + MobyNamespace[] namespaces = null; + // sync makes sure we don't fetch it if it's currently being loaded by loadNamespaces + synchronized(namespacesMapBySynonym){ + namespaces = namespacesMapBySynonym.get(reg.getSynonym()); + } - // This method has not been called yet in the JVM, populate the datatypes + // This method has not been called yet in the JVM, populate the namespaces synchronized(namespacesMapByURL){ if(namespaces == null){ - String namespaceDefURL = null; try{ - namespaces = namespacesMapByURL.get(namespaceDefURL); - + URL namespaceDefURL = Registry.findResourceURL(reg, Central.NAMESPACES_RESOURCE_NAME); + namespaces = namespacesMapByURL.get(namespaceDefURL); if(namespaces == null){ - namespaceDefURL = convertRegistryToNamespaceResourceURL(reg); - NamespaceParser p = new NamespaceParser(namespaceDefURL); - namespaces = p.getMobyNamespacesFromRDF(); - - for(MobyNamespace namespace: namespaces){ - namespace.setRegistry(reg); - } + System.err.println("Fetching namespace ontology from "+namespaceDefURL); + loadNamespaces(namespaceDefURL, reg); + namespaces = namespacesMapByURL.get(namespaceDefURL); } + } catch(Exception e){ System.err.println("Cannot parse MOBY Namespace Ontology: " + e); e.printStackTrace(); return null; } - namespacesMapBySynonym.put(reg.getSynonym(), namespaces); - namespacesMapByURL.put(namespaceDefURL, namespaces); } } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyServiceType.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyServiceType.java 2007/06/08 20:30:22 1.9 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyServiceType.java 2007/06/09 21:58:26 1.10 @@ -77,19 +77,21 @@ * refreshing an in-memory cache. */ public static void loadServiceTypes(URL serviceDefURL, Registry reg) throws Exception{ - if(reg == null){ - reg = RegistryCache.getDefaultRegistry(); - } - - MobyServiceType[] servicetypes; - ServiceTypeParser p = new ServiceTypeParser(serviceDefURL); - servicetypes = p.getMobyServiceTypesFromRDF(); - - for(MobyServiceType servicetype: servicetypes){ - servicetype.setRegistry(reg); + synchronized(servicetypesMapBySynonym){ + if(reg == null){ + reg = RegistryCache.getDefaultRegistry(); + } + + MobyServiceType[] servicetypes; + ServiceTypeParser p = new ServiceTypeParser(serviceDefURL); + servicetypes = p.getMobyServiceTypesFromRDF(); + + for(MobyServiceType servicetype: servicetypes){ + servicetype.setRegistry(reg); + } + servicetypesMapBySynonym.put(reg.getSynonym(), servicetypes); + servicetypesMapByURL.put(serviceDefURL, servicetypes); } - servicetypesMapBySynonym.put(reg.getSynonym(), servicetypes); - servicetypesMapByURL.put(serviceDefURL, servicetypes); } public static MobyServiceType getServiceType(String className){ @@ -108,7 +110,11 @@ return null; } - MobyServiceType[] servicetypes = servicetypesMapBySynonym.get(reg.getSynonym()); + MobyServiceType[] servicetypes = null; + // sync makes sure we don't fetch it if it's currently being loaded by loadNamespaces + synchronized(servicetypesMapBySynonym){ + servicetypes = servicetypesMapBySynonym.get(reg.getSynonym()); + } // This method has not been called yet in the JVM, populate the datatypes synchronized(servicetypesMapByURL){ @@ -117,6 +123,7 @@ URL serviceDefURL = Registry.findResourceURL(reg, Central.SERVICE_TYPES_RESOURCE_NAME); servicetypes = servicetypesMapByURL.get(serviceDefURL); if(servicetypes == null){ + System.err.println("Fetching service type ontology from " + serviceDefURL); loadServiceTypes(serviceDefURL, reg); servicetypes = servicetypesMapByURL.get(serviceDefURL); } From gordonp at dev.open-bio.org Sat Jun 9 22:00:27 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Sat, 9 Jun 2007 18:00:27 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706092200.l59M0R1Q005326@dev.open-bio.org> gordonp Sat Jun 9 18:00:27 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util In directory dev.open-bio.org:/tmp/cvs-serv5291/src/main/ca/ucalgary/seahawk/util Modified Files: SeahawkOptions.java Log Message: Moved settings from working dir to home dir, other minor changes moby-live/Java/src/main/ca/ucalgary/seahawk/util SeahawkOptions.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/SeahawkOptions.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/SeahawkOptions.java 2007/06/08 20:30:21 1.2 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/SeahawkOptions.java 2007/06/09 22:00:27 1.3 @@ -17,10 +17,11 @@ public static final String REGISTRY_SYNONYM_PROP = "registrySynonym"; public static final String REGISTRY_ENDPOINT_PROP = "registryEndpoint"; public static final String REGISTRY_NAMESPACE_PROP = "registryNamespace"; - public static final String ANON_REGISTRY_SYNONYM = "anonymous"; + public static final String CUSTOM_REGISTRY_SYNONYM = "custom"; public static final String PROPS_FILE_NAME = "seahawkUserPrefs.xml"; - public static final String PROPS_FILE_COMMENT = "This is the only file Seahawk stores on your system indefinitely. If you delete it, your preferences will be reset the next time you run Seahawk."; + public static final String PROPS_FILE_COMMENT = "This is the only file Seahawk stores on your system indefinitely.\n" + + "If you delete it, your preferences will be reset the next time you run Seahawk."; public static final String PROPS_FILE_ENCODING = "UTF-8"; public static final String PROPS_FILE_SYS_PROPERTY = "seahawk.prefs"; @@ -199,7 +200,7 @@ "default registry instead."); } else{ - setRegistry(new Registry(ANON_REGISTRY_SYNONYM, regEndpoint, regNamespace)); + setRegistry(new Registry(CUSTOM_REGISTRY_SYNONYM, regEndpoint, regNamespace)); } } } @@ -223,8 +224,10 @@ /** * Saves the current values of the preferences to a default location that restoreSettings() will use too. + * + * @return true of the save was successful, false otherwise */ - public static void saveSettings(){ + public static boolean saveSettings(){ File defaultsFile = getDefaultsFile(); File defaultsParentFile = defaultsFile.getParentFile(); if(defaultsParentFile != null && @@ -234,7 +237,7 @@ ") is not writeable because its parent directory " + "could not be created, preferences will be lost when " + "Seahawk terminates."); - return; + return false; } } if(defaultsFile.isDirectory()){ @@ -242,13 +245,13 @@ ") is not writeable because a directory with the same " + "name already exists, preferences will be lost when " + "Seahawk terminates."); - return; + return false; } - if(!defaultsFile.canWrite()){ + if(defaultsFile.exists() && !defaultsFile.canWrite()){ System.err.println("Warning: the preferences file (" + defaultsFile + ") is not writeable, preferences will be lost when " + "Seahawk terminates."); - return; + return false; } try{ @@ -258,14 +261,16 @@ e.printStackTrace(); System.err.println("Warning: could not save preferences (file " + defaultsFile + "), they will be lost when Seahawk terminates."); + return false; } + return true; } /** * @return the file system location where preferences are stored (whether the file currently exists or not) */ public static File getDefaultsFile(){ - return new File(System.getProperty("user.dir"), PROPS_FILE_NAME); + return new File(System.getProperty("user.home"), PROPS_FILE_NAME); } /** From gordonp at dev.open-bio.org Sat Jun 9 22:01:15 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Sat, 9 Jun 2007 18:01:15 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706092201.l59M1FxS005371@dev.open-bio.org> gordonp Sat Jun 9 18:01:15 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services In directory dev.open-bio.org:/tmp/cvs-serv5336/src/main/ca/ucalgary/seahawk/services Modified Files: MobyComplexBuilder.java Log Message: Change so namespace without ID can be constructed moby-live/Java/src/main/ca/ucalgary/seahawk/services MobyComplexBuilder.java,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyComplexBuilder.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyComplexBuilder.java 2007/06/08 14:04:27 1.7 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyComplexBuilder.java 2007/06/09 22:01:15 1.8 @@ -142,9 +142,8 @@ MobyClient.WHITESPACE_ATTR_STRIP_FLANKING_VAL, null, data); - - // A non-blank value was the result of the evaluation - if(result.length() > 0){ + // A non-blank value was the result of the evaluation, or it's the only namespace we have + if(mobyNS.length == 1 || result.length() > 0){ if(!haveID){ // A namespace that has a value mobyObj.setPrimaryNamespace(mobyNS[i]); From gordonp at dev.open-bio.org Sat Jun 9 22:02:43 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Sat, 9 Jun 2007 18:02:43 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706092202.l59M2hYi005414@dev.open-bio.org> gordonp Sat Jun 9 18:02:43 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test In directory dev.open-bio.org:/tmp/cvs-serv5379/src/main/ca/ucalgary/seahawk/gui/test Modified Files: allDataTypes.xml Log Message: Added image to test data, temporarily removed BasicGFFSequenceFeature due to anonymous member moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test allDataTypes.xml,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test/allDataTypes.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test/allDataTypes.xml 2006/11/01 23:46:59 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test/allDataTypes.xml 2007/06/09 22:02:43 1.2 @@ -1,4 +1,6 @@ - + + + 4020973406 @@ -17,9 +19,9 @@ d2hhdCB3aWxsIHByaW50IG91dA== - + - + + + +/9j/4AAQSk +ZJRgABAQEASABIAAD//gAXQ3JlYXRlZCB3aXRoIFRoZSBHSU1Q/9sAQwAIBgYHBgUIBwcHCQkICgwUDQ +wLCwwZEhMPFB0aHx4dGhwcICQuJyAiLCMcHCg3KSwwMTQ0NB8nOT04MjwuMzQy/9sAQwEJCQkMCwwYDQ +0YMiEcITIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy/8AAEQ +gA+gCnAwEiAAIRAQMRAf/EABwAAAAHAQEAAAAAAAAAAAAAAAABAgMEBQYHCP/EADwQAAEDAwMCBQIEBA +QFBQAAAAECAxEABCEFEjFBUQYTImFxMpEjQoGhFLHB0QczUvAVFiRi4UNTgpKi/8QAFAEBAAAAAAAAAA +AAAAAAAAAAAP/EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAMAwEAAhEDEQA/AOkUR+tP603beeWv+oLe+f +8A05j96bfafLodbcP4YJSiYSskRBoJA+o/Ao0/SKryzfIcVdeeVFSQP4bG1JxkKiadC7tpYR5fmpTA37 +gJmZMe0fvQSl8D5FBStomobov3CFtrS0kEEtlIVujJz78fpTSn767QfJYDBSog+cJ3CORBoLKhMwRwai +peuI2Fv1iJVHpNUeseK29CsVC7a3XjaCooQCEKPsT+lBpepoFQCgO9cft/Fl/ePF/WNZctUuepti1KRt +HuBn71YnxdcaK4xc/8SRqNi6SAlXpWO4E9f2oOlrWQcUYUSkVRNeIE3dg3fs2qlWqxuDnmJ4zM9jVbcf +4haRZp/GWomRCUDd+4xQa0r9JOMKilT6yPasHaf4naO+8tp1t1oFfpcEKSfngitejUbZy7SELKkKb3B0 +Zb543cT7UEtUfTAjqKEguRGQOaiDUGFOuJlY2KCTKDHIGO9Beo2rV//Drdh0oBCdp4nvEUEoAHcPfNAg +SD2pLTiHFOhCpKF7Vexgf3qPc3ttb3DbT1w02teUpUoAn4oJBxIk5zQ7GTHam1uth/YXEBewnbuEx3ig +pxAaQvenaeDODigX055oUlKgUiCCIoUEtHB+aUeDTYckcoPaFUA7JiUfG6gWRKR+lJ/OfmjCldhHzSHn +27dtTrxQhtOStSgAPvQG86hhkrWYSkVzLxZ44uGVBjT31tSohW3BA7zzNPeIPHVpdn+Hs38pUqTwD0EH +rXNr1arp1biiJkDJoLw+OPELRX5WpPLQeC4Ez/ACqj1G/d1S5D77y1OEetSllU/A6VBWjy8qWoE9QKND +LihvAASlO+Z5ExQJ2qdSQ1lE5JmlJdYZdcS415pLZCBvgIUfzUhNylvdsQCVfUIppbrZIVsO/rHSgtG7 +5dxZIsy4sMoO/y1uHbPUgVVXD7jzhWXABMBPtS9q0FLpy2rijFupQVuUkKSJhfX4oCbR5biFLgIWMycE +Vs/DHi5zT2DprrjS7dQCkqfRvCFdo3D261knW1BILiISQE+0RimEo8u4ACZWkxtVxQdkb8bv29whFw1a +XDLgAhseS5kwIClKCh8GtZpFzZv2RbYZLAQSlbS4lJOehI+xrz7dXLt0hO8khsekJEBP2qfa+ILlId/i +UG7WsD1qVlEdqDujulWi2EJ2LACNo2uKGPvR2Ok2dmyUIQpwbiQXlFwjpgqkiuR6R4xU1clp27u22lJh +pxbhX5KxxP+pJ6gjHSuu6Vfpv9KtbwQA+2lyB0kTQA6eypKSSvfunfPqI/0z29qJGnMbFtubnWt0pbcg +pR0hI6CKnTIpIET80ENOnMtoKEekEyMcf7gfahUw+1CgdXb7iNrrjYAiEER/KlIZCUbVEr7lUZpykgnz +I6Z/pQRr65Y0+zU+4AEpGAB+1ca8Wa5catfuFxws26DtbSBie/ufeui+M7tDFg2p5xLbO8zJiYFcW1DU +xeLW0hKdpVMzmgiPW6g7KHVOpjKiOtFZutlRDilSBkiIH3ozdqbYKSMnkx0pllotDc6mUuJlJ5NAAQ89 +uKgUdCakJsy4kE3ADYBCfemQEpTgYI3TFJdeHmZJCYEZoFptiStLYTjGaN60C20qUttEAew4pDTpLZSJ +kj70amVqUkRgZmOlAh5LaUtFsKMJ9UnE0o+WZVBCiI2g08tovBO0Ddmlm1QkFanEhQnHWgrytaTshRT2 +miLvr3lR3EQrvU0Wa1pC+Eq4B6005p7ikqISlMYMZNAVrcK/iNyZSk4MHin0b279CVNxnKh2jj+dQPKU +1iDI6kVaMu7kJKjKo7cdqBu6S2h9CgNkYMHn9K6P8A4e+IFqdY0m4CIKCGj2jMc9v5VzO4yFTzPPap/h +++XY6zY3CFyG3QtX3z+1B6G2rg+kT8mkbXYA2J/wDuf7U6l5Czg9JpRIESeaCOErCsJxOfWaFPFaQmZx +QoH7dRW0FKmaMmN5HSKcACRAECgQIOKDjHj2/uL/0vqOxtZCUjgVhGW0edtCYVW88cMRfXiUApCXN0Cs +GHVNPpURtPSgcd8pbqlFJ8vIxzUFC1AxulIx8U75qylYSCZ+oRUZlIKzj9KB9Pr9IwDTjidkJcAUOJAm +pLDAVAAJPv/SrFnR3rlQATg+1BWWtu2tY2qJVPBFXVrYlx3YlMA4mKu9O8LoaKVKndPODWos9PYYja2N +x/NEUGXX4YLdqS2glYEYzA71BT4UfWjeAVHjvNdJQjAEcU6lrYCQkCTnFBzRvwncrbUFhQI4HSl/8AK9 +2hC/x0gHnFdEUn2plxuRQcv1DSHmGtymfMKewMVTJW4XUynYEngCus3dqlaSSAf0rMalpSSFFCRuPtQY +a6O9ZG3HIpFluNwhSVBKUmTJp3UmXGFEKGZpOmWzl06ENJKiTkAUHoDQ7tN7aruEq3IQotBQ/NHX94/S +rZQ3FKeqTNVvh7S0ad4ftrRCjhAJPcnJNWuyFlU0EYgFsJngkUKc8jH1dSaFBPkAD3o5Ex1oUAcmg5r4 +7swL9bichxGfmuTXQCXimJrv3jPT/4nS/OSJU2c46Vw/WLXyntwEbjIoIiNqVecjBjPQVHQQXSsAAk9K +OYSYmBzSbd5KHJIxNBqNKtg7sVsnvNbGxtktogAD4FZjw66lce/wDOtpbohIoH2W8gDirFliSMUywkYx +VmzHEUCEsRmKe8obeDNSAnEzFHMAwMUFatvJxFN7MZqY4PVxTKgYNBXXCBBxVNdtApI7VdXE5xVXcAbT +70HNvFbZafHp9J/nSfBcu+KLBoH6nIM9quvE9p51sVRJTVP4GKUeMtPCwmC5Hq+DQehUJCG0pSIAEAUd +CAITGAcUUgKOKA6FNqjakRg0KA2L5talgpcRBIlaYnjikp1JpIcJafGyJls5+O9S3Wm1pAUhKgCCJHY0 +pSErPqSDgjPagh3Fxbv27ra3EBK0Y3EAH4rhniFlIU4nKXGlkbVCDHxXcn9Ps3mmw7bNLSidoUkGJNc2 +8faS03q7jwaALrYIVFBy5XpBI5PIppKZUIp59BQsjoKQyIWBE0Gp8OJCXE5yOldAtDuSJrF+HbJaAHFJ +gd4ra242daCe2dpzU5pyBwagNmTUlkmYJoJ4fPWlh0K4pgRxNKDJ5BoFKIKuaZUCSRxUgMSZJpm6eYtU +bnFgfNBBuGxtyaqLrP00vUdfsWwQXgfiSazLnitkOFO1UHgkUD+oNJcbUFRnpWO08I0rxhaqVIQh5Ksd +prQXWtsOASCCeSMioP8Oh3xTpL8p2OOJTJEiQcUHZ39StWH/LW7tXHG0n+lA6pZFxaA96kgyNp/tU9KQ +EJEDjpRbE4wMcUEJ6/tmWWXXHQlC/pMHOKFPNWzLTri0IAUv6jPOSf60KCwJCpAIkHPtR9QaiBt2VBAa +BBEktkT+9OeW9H1NTGPR1+9A6QhaMEEdxWK8d26bhVulLiQoAzJ4FaspeDJKA1M4BaPM9prAPB5/xTfJ +uFoPIECOCOKDl+p2q7e7UFQROCODTNi2F3rST1Vmtrrem+e26qP8sxAHWspYNFrVEtnkKig6JZtJbYSk +CBFTvMhCc81HYH4AJ7VCumX7zahtZS1+aDzQS39dt7T0hxKiOSM1Cc8XONL3htAb6bjH7Uk2Wnaenznz +JSPzGqi+15pp1bLViGztkF1JE9hwTn9KCwc8d3efLQkn/tTxVho/ibUbu4h1ooSepkVDZ08HTLe8dLMv +DdtSqFJ/TrVgxallTZlKml/StIig1CL9YbGc+1ZbxC+683CXCF568VfWakLaUlY9XE1Q3zSXdTCHB6Og +NBk1W7ba0fxd0o7zhDaZUo+1LYudMuLZxadOfcaagLWoSBWoe0Zi5baReNl9LYMbQE/wAuaQ1olkykts +MKSg/lzmgorZrSb7DCEIMYApdzbptFW7vKbd9Dn6TmtA3pLTJ80NpCh2Gah31sbtKmUjLg2j5NB1JK0l +IhQiO9AqE8iotravNWjTanRuQgJMIHQUssuEf5v/5FA7gEmRQpjyH9x3Pgp6AIE0KCxDiT+YRyKMuJAm +RHFRwjYhMngEcd6UpB8sJ9wftQPBQVwa514ib/AOHeKP4hP+W8d0/PNdBBDcqJwayvji0CtKbuIlTS+f +Y0FczZl5NwoAepRgxXPH7Jy08QFpxG2F5xW/0u/Js0qCuRn5HSoesWzb7guXGdrhWFT3FAtkTbwe1SWU +EswnBqPbqG0AcRU1hMKoKx7w+0/cJduN7xmQJwKsrfSrRCpNkFnj1H+tTR6hjkUpO4YBoIybAIXuCUiO +AM0T6Ny0zG1sYgdamhK1nb0pi7QGlFRAAoItqSlwjPeoeptfjoWME0626DdQnPWnb5py4b9CZIzQLsbk +ONBCvqHepPlqOQPsKprR8JuUpWCCME1pmS04MRNBAeR+GcGqmP+pa7+Yn+daC6AgwKpUI83V7VtI+p5M +/E0G7W82gwTEe1F5yNu7dj4pLrCXCSYz/v+lJSyko29DQLLqAgKJgH2oU2UhZ8o8JzNCgmONKWiBEwKW +oEiR0BpVCaBt1CltwOZqPqNgnULNy2cPpWIOKmUKDkzbTuj6o9ZPH0lXX9jVxfKTdadGCoZHtWh8Q+Gm +9ZIebX5dwkRPQ1jdTstS0FLSXnUqQ5MRmgat3tsDkDrVwwsFMz8Vn1eh3nByPerC1eMbSeOKC5tzuXBN +WrLDe2Z5qiYV6pJ61YrutjUz0oHX3kW52tDctXFUd+XH7sJWqABPOKkpdgKeXyrj2FQXbhCnFBSQsTie +lAu0DTDu8rCzOQDV6q6tEtqUEEkpkCeKzT6GVpUp5AC04CxzFNFTimkhKlrSBAABJPzQBxZW8XNqQCc+ +1WTFxKQts+odO9UT1s8oyVYPbpT1m8u2VCpUmOeYoNG5cBbUg8ioeh/jeJWSchIUf2/wDNJSsLZUtNO+ +GEFWuqX0S0on7gUG2NJgDijJ+9JKhnPHNAW0A7oz3oUCRPPNCglZmZxQE5k88UlRiKAM7aAzIAG7PejJ +6zikOnA+aMn8P9KBXE5/8AFZH/ABA8oaQypawFpXjuRGa1KlkAmehNch8b6wu/vnilX4SD5aB7DmgXbu +C70xp4cgVItV7lAE5FV/hkeZpPlchKlD96eWtVtcZxBoNE2DEp5py4J8oTwTmo9k+HGwofrFTwhLtupJ +yU5oIDxccEJwiOtRRc2yVbT+I51SgTmnbth26aU22ooQMY5qqatdQ08/guq2bgqIkSKC+aRdLJ26a4RM +GRFTE6Zqi1+Wi1SxIkqcUCP261X2Gt6izv3gOlZk5iPgRxip73iG/WmENIbMcqM0EG/wBGctbdT1xf7C +AowkYxVLpD5ced9XmMzhZEYp69Tc37hL7ynCeZwn7VK05hLCICQcZoJhCUMukRB4qx8IshS7y4Ix6UA/ +cn+lZu4vkstOI3AhRxmtjoHk2OjMIWsB1frWnqCe4+IoLqUnI6YoiB2FQUalblCwFHeFkBv8yo6gdRRD +VGC7ACvK/93Gw8dfv9jQS3F7ciJoVAub+Ubra3duUSBuZgj9zQoJKWr+7AL6gxsVIDK53YjMilpYu21Q +h4KCFQneTkHmf6VPSIFJ/MfmgjKtXHyUPOqShJ9JbUQT80g2j4V5SX/wAE+kySVR896nxBPvSHXEMpLr +i0oQkSVKMAUGc8SBjSdKW6244Hlgtp3OEzPNcp1NP4baNxgDJNajxX4ga1jU/LtnN9syICuhPU1mL78T +B4AoLXwmQWHROPMMVcanYec1vQPUM1R+FYQHUDA3YrZIAWjaaDL6dem1dLLuJNXiL0ISQmTPaq7WNKJB +daELH71T29+oEtrJQ6ngKxQay1cBcAk+4p9QG8gVTWWotukeYob5iIq0DqVDcMUC3UgIJDYJHBFRlXLe +4t7fxBOOlPh5KwQInvFGLYEqUBmOelBDA3pLhmDG0U0XNjefzcVJuT5KIBAms9qGopabJJkZoIV7eqau +WkgpJSveRyMHrWx03xppLz0alaoYuFp2qeCJQr9eQK5qh1T7qrhf1K49hT60eY1tJlSRI/tQdvt1afcu +Iftv4dwxhaIJGO9PhpoM7Q2gJA4CRFcCbvLm2UC08pMcQa0OkeN9W08bXXf4lnql3JHweaDrraEoQAkA +DsBFCsnZeP9NeQBcIWwqO4UKFBti6ByUj5VSS+kD62x/8AKjSy02PQ2lIiMCs14h8YWGjpW02E3F0fyA +4HyaC7v9Ut9NtlP3LqEJHAnJPtXKvE3iy61p4sIUUWwP0Dg/PeqvVNZvdYufOunyrskfSn2AqsuSZBmA +OlBKtxsSYEyck048QVkntFNW5HlhQnk4FOck4oJWiXPk34QqYX/Ot5bGUCuZq9KwoEg8gitxoWofxlml +SiN6cLE9aC6W2FoKSJHaszrGheckuM4WMgjkVqEmRQcSFD1feg5ktTtvcDzQUOjqOFD5q0ttZKm1Nqwt +Ikwa0d7plu8CHEApV1FUVz4VaUrcy6tHbaeP0oJTGoNtqTKx2Pv71aMamz5ZCVDkiT0rLf8tauhUt3Da +k9NySKcVoV8hsqub0IH+ltNBN1DVkhSpcjH3rJ37jjrTq0SGkyCrueIFWlvozCn9z7jj0dFGBHwKRrmz +yEMoASncBAx1oKxkQ2nBJA44ipCDBBHPem221BBO0qSMTSFuqaTJQSZ4TQKu2RO9OEq/Y1ER6VZPNSmb +1hwqZcCkBXRQ/rTLyFNO7Sf16EUBGIg8e1ChJ6E/NCg6B4j8dP3gXbabuZZOC4fqV/asSt4kkq9SuSTS +N24ETTKgpB9JkdqB4OJJ6TSVpCgR/OmyAsAjBoBREAmgl252sjA3ZmnR9NNMbltiMAE06CNsDmgbXBFT +tGvjZX6CTDbkJVn96gnmiUMQD70HTmnJSM0tS8Yqg8PagLuxDaz+I3gz1FXBUQMGaBLijH9uKiqUQcYp +5SwTmo7hANAo3KkJ9REfNVl7d+b6RkU+6oRBNQVAKVAEmgQ2dqCo8niqbVRudCT0yfmr5TexsqX0Emsx +fLUt1bjcncTPtQOWu07m1YSsRJ6e9RHykJgHrA/SiLgQtKTu3geoJ4ntUdxZW4owMce1AkpCxBHweopb +biinylndt+lRGfiijcOaICVk9UxQOg8zQooIOMA9aFA4ps7tyTR7weT+lBTkKI6URAVzQKAzxSVJE88U +0tLqBIVIokPf6uaCZbGAtJIGQf9/apExOM1CZWlLoJMAgj9ef71M3SJHAoEkSaLIgmlkxiiPBKsADJNA +/YXpsbtL6Pp/MAeRW3Q8HG0rSZSoSDXNVqWsejA6TxPc1M07XrzT1JZPrTGUr+n9D0oN8riTFRnFJFVr +HiWzeQA8FMr6g5H3qe0tm6yy6hY67TNAwv1qgSaeZtv+2Ks7awSc4py98uxtHH1YCB96DH6/deURbNqI +VyqKoFL2o3T1wO5py4fVdXbtw4rkyT2Haoa3C4riEjAHYUCATuknPJpKRzJ5pZ6n9KIY44oDEJz1pBEG +QTkzRnJk89KChjtQOgFSO5TmhSEq2QQDA5oUD62wsSOabSdsg04hwEwTE0TgxMUA5NNOspXkGDSkkTBP +xR8iAKBluW1pUchJk/HWrTmQMjvVf7HNSrZRWyCcRg/pQOHuMRUZ10uQBhI496W8sElKT8mmozAoBtIO +MUZAUJUJpI55pQPINA2WU7YER2ijbaU2qQ4pB/7TFOBUEUoGeeaCwtNd1KwKSi9WtA/K56gf61Z6vr51 +fTGGkS26VEupHGKzJBTmlSSkkZ3YJ9v9xQJcO6EpJKBx7+9NRtE06oymBimXOI96AcpA60Sk+9FJKgmj +Md8CgHEk/agTx780UY5PejIO0fvQBMzAgR3oUnnB+9Cge2BeUmDRblJ9KsgUQ+metOOgeVMUCJBn7ijC +wTHJikCkAnf+tA8oHmjbWpvdE5Mgij/L+lEB6TQAcTFHRJ4ox9R+KAjunGKEd+lKPAovy/rQDPHelZ5o +hxR/l+9AlxUp2jk0TY2oSBnmaS79SaNonYnNAsiAYplWTTyuRTB6UCRO8ilSPekJ+pXxTnRXxQJSVcxn +pRqyCAfeaIUZ+hVAk5+KFA8ChQf//Z + + + + + + @@ -268,5 +386,5 @@ X2: 5 ( 9.9 bits) S1: 12 (24.3 bits) S2: 19 (38.2 bits) -]]> +]]> From gordonp at dev.open-bio.org Sat Jun 9 22:03:44 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Sat, 9 Jun 2007 18:03:44 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706092203.l59M3iOP005457@dev.open-bio.org> gordonp Sat Jun 9 18:03:44 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv5422/src/main/ca/ucalgary/seahawk/gui Modified Files: SeahawkOptionsGUI.java Log Message: First version of working options dialog moby-live/Java/src/main/ca/ucalgary/seahawk/gui SeahawkOptionsGUI.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/SeahawkOptionsGUI.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/SeahawkOptionsGUI.java 2007/06/08 20:30:21 1.2 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/SeahawkOptionsGUI.java 2007/06/09 22:03:44 1.3 @@ -1,5 +1,372 @@ package ca.ucalgary.seahawk.gui; -public class SeahawkOptionsGUI{ +import ca.ucalgary.seahawk.util.SeahawkOptions; + +import org.biomoby.registry.meta.*; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; + +/** + * A dialog box that allows the Seahawk user to configure + * options such as cache expiry and location, as well as + * the MOBY registry to use, and whether referrer headers + * should be sent to services. Settings are saved to a file + * by the SeahawkOptions class. + */ +public class SeahawkOptionsGUI extends JDialog implements ActionListener, WindowListener{ + public static final String CUSTOM_REGISTRY_SYNONYM = "Custom (set your own location & namespace)"; + public static final String CUSTOM_REGISTRY_DESC = "User-defined MOBY Central registry."; + public static final String DIALOG_TITLE = "Seahawk User Preferences"; + public static final boolean DIALOG_MODAL = true; + + private static final int MAX_DESC_WIDTH = 60; + + private JComboBox registryComboBox; + private JTextPane registryDescTextArea; + private JTextField registryEndpoint; + private JTextField registryNamespace; + + private JButton deleteCacheButton; + private JButton selectCacheDirButton; + private JTextField cacheExpiryTextField; + private JFileChooser cacheDirFileChooser; + + private JCheckBox sendReferrerCheckBox; + + private JButton resetButton; + private JButton okButton; + private JButton cancelButton; + + private RegistriesList registriesList; + private String[] registryNames; + private String lastCustomEndpoint = "http://yourdomain.org/cgi-bin/MOBY-Central.pl"; + private String lastCustomNamespace = "http://yourdomain.org/MOBY/Central"; + + /** + * @param owner the frame that launches this dialog + */ + public SeahawkOptionsGUI(Frame owner){ + super(owner, DIALOG_TITLE, DIALOG_MODAL); + + // Custom handling of window close operation + setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); + addWindowListener(this); + + // The dreaded GridBagLayout... + GridBagLayout gridbag = new GridBagLayout(); + GridBagConstraints c = new GridBagConstraints(); + c.fill = GridBagConstraints.BOTH; + setLayout(gridbag); + + registriesList = new RegistriesList(); + Registry[] registries = registriesList.getAll(); + registryNames = new String[registries.length+1]; + int i = 0; + for(; i < registries.length; i++){ + registryNames[i] = registries[i].getSynonym(); + } + registryNames[i] = CUSTOM_REGISTRY_SYNONYM; + + JLabel label = new JLabel("Registry server:"); + c.gridwidth = 1; + c.weightx = 0.0; + gridbag.setConstraints(label, c); + add(label); + registryComboBox = new JComboBox(registryNames); + registryComboBox.addActionListener(this); + c.gridwidth = GridBagConstraints.REMAINDER; + c.weightx = 1.0; + gridbag.setConstraints(registryComboBox, c); + add(registryComboBox); + + label = new JLabel("Description:"); + c.gridwidth = 1; + c.weightx = 0.0; + gridbag.setConstraints(label, c); + add(label); + registryDescTextArea = new JTextPane(); + registryDescTextArea.setEditable(false); + c.gridwidth = GridBagConstraints.REMAINDER; + c.weightx = 0.0; // 0 so long lines wrap in text area + c.weighty = 1.0; // absorb all extra vertical space in the desc + gridbag.setConstraints(registryDescTextArea, c); + add(registryDescTextArea); + c.weighty = 0.0; //reset + + label = new JLabel("Location:"); + c.gridwidth = 1; + c.weightx = 0.0; + gridbag.setConstraints(label, c); + add(label); + registryEndpoint = new JTextField(50); + registryEndpoint.setEditable(false); + c.gridwidth = GridBagConstraints.REMAINDER; + c.weightx = 1.0; + gridbag.setConstraints(registryEndpoint, c); + add(registryEndpoint); + + label = new JLabel("Namespace:"); + c.gridwidth = 1; + c.weightx = 0.0; + gridbag.setConstraints(label, c); + add(label); + registryNamespace = new JTextField(50); + registryNamespace.setEditable(false); + c.gridwidth = GridBagConstraints.REMAINDER; + c.weightx = 1.0; + gridbag.setConstraints(registryNamespace, c); + add(registryNamespace); + + JSeparator line = new JSeparator(); + c.gridwidth = GridBagConstraints.REMAINDER; + gridbag.setConstraints(line, c); + + sendReferrerCheckBox = new JCheckBox("Send referrer data to services"); + c.gridwidth = GridBagConstraints.REMAINDER; + gridbag.setConstraints(sendReferrerCheckBox, c); + add(sendReferrerCheckBox); + + line = new JSeparator(); + c.gridwidth = GridBagConstraints.REMAINDER; + gridbag.setConstraints(line, c); + + JPanel expiryPanel = new JPanel(new GridLayout(1,0)); + label = new JLabel("Cache expiry (in hours)"); + expiryPanel.add(label); + cacheExpiryTextField = new JTextField(3); + expiryPanel.add(cacheExpiryTextField); + c.gridwidth = 1; + gridbag.setConstraints(expiryPanel, c); + add(expiryPanel); + deleteCacheButton = new JButton("Delete cached items"); + deleteCacheButton.addActionListener(this); + c.gridwidth = 1; + gridbag.setConstraints(deleteCacheButton, c); + add(deleteCacheButton); + + selectCacheDirButton = new JButton("Change cache directory"); + selectCacheDirButton.addActionListener(this); + c.gridwidth = GridBagConstraints.REMAINDER; + gridbag.setConstraints(selectCacheDirButton, c); + add(selectCacheDirButton); + cacheDirFileChooser = new JFileChooser(); + cacheDirFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + + line = new JSeparator(); + c.gridwidth = GridBagConstraints.REMAINDER; + gridbag.setConstraints(line, c); + + resetButton = new JButton("Restore program defaults"); + resetButton.addActionListener(this); + c.gridwidth = 1; + gridbag.setConstraints(resetButton, c); + add(resetButton); + cancelButton = new JButton("Cancel"); + cancelButton.addActionListener(this); + c.gridwidth = 1; + gridbag.setConstraints(cancelButton, c); + add(cancelButton); + okButton = new JButton("Apply changes"); + okButton.addActionListener(this); + c.gridwidth = GridBagConstraints.REMAINDER; + gridbag.setConstraints(okButton, c); + add(okButton); + + setCurrentValues(); + pack(); + } + + public void actionPerformed(ActionEvent event){ + Object source = event.getSource(); + if(source == cancelButton){ + setCurrentValues(); + setVisible(false); + } + else if(source == okButton){ + saveSettings(); + } + else if(source == resetButton){ + setDefaultValues(); + } + else if(source == selectCacheDirButton){ + int choice = cacheDirFileChooser.showOpenDialog(this); + if (choice != JFileChooser.APPROVE_OPTION) { + cacheDirFileChooser.setSelectedFile(SeahawkOptions.getTempDir()); + } + } + else if(source == deleteCacheButton){ + RegistryCache.deleteAllCacheFiles(); + // Can we also delete the in-memory cache somehow? + } + else if(source == registryComboBox){ + updateRegistryFields(); + } + } + /** + * Use the values defined by SeahawkOptions. + */ + private void setCurrentValues(){ + Registry currentRegistry = SeahawkOptions.getRegistry(); + if(currentRegistry == null){ + registryComboBox.setSelectedItem(RegistriesList.DEFAULT_REGISTRY_SYNONYM); + } + else if(currentRegistry.getSynonym().equals(SeahawkOptions.CUSTOM_REGISTRY_SYNONYM)){ + registryComboBox.setSelectedItem(CUSTOM_REGISTRY_SYNONYM); // a bit more verbose than SO.CRS + lastCustomEndpoint = currentRegistry.getEndpoint(); + lastCustomNamespace = currentRegistry.getNamespace(); + } + else{ + registryComboBox.setSelectedItem(currentRegistry.getSynonym()); + } + updateRegistryFields(); + sendReferrerCheckBox.setSelected(SeahawkOptions.getSendReferrerPolicy()); + cacheExpiryTextField.setText(""+SeahawkOptions.getCacheExpiry()); + cacheDirFileChooser.setSelectedFile(SeahawkOptions.getTempDir()); + } + + private void saveSettings(){ + double expiry = SeahawkOptions.getCacheExpiry(); + try{ + expiry = Double.parseDouble(cacheExpiryTextField.getText()); + } catch(Exception e){ + JOptionPane.showMessageDialog(null, + "The cache expiry field is not a number,\nplease correct it to continue", + "Invalid Formatting", + JOptionPane.ERROR_MESSAGE); + return; + } + + Registry previousRegistry = SeahawkOptions.getRegistry(); + String selectedRegistryName = registryComboBox.getSelectedItem().toString(); + if(selectedRegistryName.equals(CUSTOM_REGISTRY_SYNONYM)){ + SeahawkOptions.setRegistry(new Registry(SeahawkOptions.CUSTOM_REGISTRY_SYNONYM, + registryEndpoint.getText(), + registryNamespace.getText())); + } + else{ + try{ + SeahawkOptions.setRegistry(registriesList.get(selectedRegistryName)); + } catch(Exception e){ + e.printStackTrace(); + JOptionPane.showMessageDialog(null, + "The registry information could not be saved properly,\n" + + "see the console for more details. Aborting save.", + "Registry Specification Error", + JOptionPane.ERROR_MESSAGE); + return; + } + } + + // Update SeahawkOptions with the values from the form + try{ + SeahawkOptions.setTempDir(cacheDirFileChooser.getSelectedFile()); + } catch(Exception e){ + e.printStackTrace(); + JOptionPane.showMessageDialog(null, + "Please select another directory for the cache.\n"+ + "The specified cache directory ("+ + cacheDirFileChooser.getSelectedFile()+ + ") is not suitable:\n"+ + e.getMessage(), + "Cache Specification Error", + JOptionPane.ERROR_MESSAGE); + SeahawkOptions.setRegistry(previousRegistry); // Roll back the change + return; + } + + SeahawkOptions.setSendReferrerPolicy(sendReferrerCheckBox.isSelected()); + SeahawkOptions.setCacheExpiry(expiry); + + // Saves the new values to a file, so they will perpetuate themselves between sessions + if(!SeahawkOptions.saveSettings()){ + JOptionPane.showMessageDialog(null, + "Sorry, but there was an error saving your preferences.\n"+ + "Please see the console for more details.", + "Error Saving Preferences", + JOptionPane.ERROR_MESSAGE); + } + setVisible(false); + } + + private void setDefaultValues(){ + // Restore the program defaults in subsequent JVM's by deleting the preferences file! + java.io.File defaultsFile = SeahawkOptions.getDefaultsFile(); + if(defaultsFile.exists()){ + defaultsFile.delete(); + } + + // We also need to reset the current session...TODO + JOptionPane.showMessageDialog(null, + "Please restart Seahawk to continue with the default settings.", + "Custom Settings Deleted", + JOptionPane.INFORMATION_MESSAGE); + setVisible(false); + } + + private void updateRegistryFields(){ + // Update all the registry fields if the name switches + String selectedRegistryName = registryComboBox.getSelectedItem().toString(); + if(selectedRegistryName.equals(CUSTOM_REGISTRY_SYNONYM)){ + registryDescTextArea.setText(CUSTOM_REGISTRY_DESC); + registryEndpoint.setEditable(true); + registryEndpoint.setText(lastCustomEndpoint); + registryNamespace.setEditable(true); + registryNamespace.setText(lastCustomNamespace); + pack(); + return; + } + if(registryDescTextArea.getText().equals(CUSTOM_REGISTRY_DESC)){ + lastCustomEndpoint = registryEndpoint.getText(); + lastCustomNamespace = registryNamespace.getText(); + } + + try{ + Registry selectedRegistry = registriesList.get(registryComboBox.getSelectedItem().toString()); + String desc = selectedRegistry.getDescription(); + String newDesc = ""; + if(desc != null){ + int charCount = 0; + int curLine = 0; + for(String word: desc.split(" ")){ + charCount += word.length() + 1; + if(charCount/MAX_DESC_WIDTH > curLine){ + curLine++; + charCount--; + newDesc += "\n"; + } + newDesc += word + " "; + } + } + registryDescTextArea.setText(newDesc); + registryEndpoint.setText(selectedRegistry.getEndpoint()); + registryEndpoint.setEditable(false); + registryNamespace.setText(selectedRegistry.getNamespace()); + registryNamespace.setEditable(false); + } catch(Exception e){ + e.printStackTrace(); + return; + } + + pack(); + } + + + public void windowActivated(WindowEvent e){} + public void windowClosed(WindowEvent e){} + /** + * Invoked when the user attempts to close the window from the window's system menu. + * Implemented as resetting the fields to their original values, and closing the + * window (same effect as the "Cancel" button). + */ + public void windowClosing(WindowEvent e){ + setCurrentValues(); + setVisible(false); + } + public void windowDeactivated(WindowEvent e){} + public void windowDeiconified(WindowEvent e){} + public void windowIconified(WindowEvent e){} + public void windowOpened(WindowEvent e){} } From gordonp at dev.open-bio.org Sat Jun 9 22:05:52 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Sat, 9 Jun 2007 18:05:52 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706092205.l59M5qcG005521@dev.open-bio.org> gordonp Sat Jun 9 18:05:52 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv5486/src/main/ca/ucalgary/seahawk/gui Modified Files: MobyContentPane.java Log Message: Removed debug statement moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyContentPane.java,1.9,1.10 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java 2007/06/08 20:30:21 1.9 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java 2007/06/09 22:05:52 1.10 @@ -237,6 +237,7 @@ return; } catch(Exception e){ + e.printStackTrace(); status.setText("Note: There was an error transforming the MOBY data " + "into presentation form, it may not be displayed correctly"); logger.error("Note: There was an error transforming the MOBY data " + @@ -308,15 +309,16 @@ logger.error("Failure in loading MOBYfied binary data:\n" + e); } // Shouldn't get here unless either not binary, or the binary data load failed - System.err.println("Is plain text"); editorPane.setContentType("text/html"); String body = getInputStreamContents(url.openStream()); // Is it already HTML? if(body.toLowerCase().indexOf("
      "+
       						    body.replaceAll("&", "&").replaceAll("<","<")+
       						    "
      "); From gordonp at dev.open-bio.org Sat Jun 9 22:06:28 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Sat, 9 Jun 2007 18:06:28 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706092206.l59M6SSJ005584@dev.open-bio.org> gordonp Sat Jun 9 18:06:28 EDT 2007 Update of /home/repository/moby/moby-live/Java/xmls In directory dev.open-bio.org:/tmp/cvs-serv5549/xmls Modified Files: seahawkBuild.xml Log Message: Revived splash screen for applet moby-live/Java/xmls seahawkBuild.xml,1.8,1.9 =================================================================== RCS file: /home/repository/moby/moby-live/Java/xmls/seahawkBuild.xml,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- /home/repository/moby/moby-live/Java/xmls/seahawkBuild.xml 2007/06/08 14:04:27 1.8 +++ /home/repository/moby/moby-live/Java/xmls/seahawkBuild.xml 2007/06/09 22:06:28 1.9 @@ -13,6 +13,7 @@ + @@ -221,7 +222,7 @@ basedir="${src.main}"> - +
      From gordonp at dev.open-bio.org Sat Jun 9 22:15:06 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Sat, 9 Jun 2007 18:15:06 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706092215.l59MF69p005648@dev.open-bio.org> gordonp Sat Jun 9 18:15:06 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/meta In directory dev.open-bio.org:/tmp/cvs-serv5613/src/main/org/biomoby/registry/meta Modified Files: RegistryCache.java Log Message: Fixed javadoc warning moby-live/Java/src/main/org/biomoby/registry/meta RegistryCache.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/meta/RegistryCache.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/meta/RegistryCache.java 2007/06/09 18:21:43 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/meta/RegistryCache.java 2007/06/09 22:15:06 1.3 @@ -47,7 +47,7 @@ /** * Stores the given resource to a file for retrieval later with getOntologyFile(). * - * @param one of the resources listed in org.biomoby.shared.Central + * @param resourceName one of the resources listed in org.biomoby.shared.Central */ public static void cacheRegistryOntology(Registry reg, String resourceName) throws Exception{ if(resourceName == null){ From gordonp at dev.open-bio.org Sat Jun 9 22:16:54 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Sat, 9 Jun 2007 18:16:54 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706092216.l59MGs6s005691@dev.open-bio.org> gordonp Sat Jun 9 18:16:54 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv5656/src/main/ca/ucalgary/seahawk/gui Modified Files: MobyContentGUI.java Log Message: Better caching implemented moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyContentGUI.java,1.10,1.11 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java 2007/06/08 20:30:21 1.10 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java 2007/06/09 22:16:54 1.11 @@ -80,6 +80,8 @@ private MobyContentClipboard clipboard; private MobyContentHelpPane helpPane; private DataRecorder dataRecorder; // used for workflow export, etc. + private SeahawkOptionsGUI settingsGUI; + private boolean setup; private Map request2tab; private int activeTabIndex = -1; @@ -210,6 +212,7 @@ status); getContentPane().add(tabbedPane, java.awt.BorderLayout.CENTER); + settingsGUI = new SeahawkOptionsGUI(this); } public boolean allTabsVisible(){ @@ -727,6 +730,10 @@ showHelpTab(); return; } + else if(source == settingsButton){ + settingsGUI.setVisible(true); + return; + } String cmd = e.getActionCommand(); if(FILE_OPEN_OPTION.equals(cmd)){ @@ -924,7 +931,7 @@ // Asynchronously load up ontology data so it's ready when the user needs it. cacheOntologies(); - MobyContentGUI gui = ca.ucalgary.seahawk.util.MobyUtils.getMobyContentGUI(new JLabel()); + MobyContentGUI gui = MobyUtils.getMobyContentGUI(new JLabel()); gui.setDefaultCloseOperation(defaultCloseOperation); gui.setVisible(true); @@ -953,9 +960,37 @@ protected static void cacheOntologies(){ final Registry preferredRegistry = SeahawkOptions.getRegistry(); + // Remove stale cache files before doing anything else + long allowedAgeMillis = (long) SeahawkOptions.getCacheExpiry()*60*60*1000; // hours to milliseconds + RegistryCache.deleteExpiredCacheFiles(allowedAgeMillis); + // Redirect the registry endpoints to local cache files if available // preferredRegistry and/or dataDefURL may be null, if not cached, but that's okay to pass around + new Thread(){ + public void run(){ + File namespacesDefFile = RegistryCache.getOntologyFile(preferredRegistry, + Central.NAMESPACES_RESOURCE_NAME); + try{ + URL namespacesDefURL = namespacesDefFile.toURI().toURL(); + if(namespacesDefFile.exists()){ + // Use the cached file rather than actually going to the registry + MobyNamespace.loadNamespaces(namespacesDefURL, + preferredRegistry); + } + else{ + // Create it from the remote source, then load it + RegistryCache.cacheRegistryOntology(preferredRegistry, + Central.NAMESPACES_RESOURCE_NAME); + MobyNamespace.loadNamespaces(namespacesDefURL, + preferredRegistry); + } + } catch(Exception e){ + e.printStackTrace(); + } + } + }.start(); + // The following command will cache all data type definitions for this session new Thread(){ public void run(){ @@ -1002,6 +1037,7 @@ } } }.start(); + // And the service definitions //new Thread(){ // public void run(){org.biomoby.shared.MobyService.getService("","");} From kawas at dev.open-bio.org Thu Jun 14 13:44:53 2007 From: kawas at dev.open-bio.org (Eddie Kawas) Date: Thu, 14 Jun 2007 09:44:53 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706141344.l5EDirth022178@dev.open-bio.org> kawas Thu Jun 14 09:44:52 EDT 2007 Update of /home/repository/moby/moby-live/Perl/MOBY In directory dev.open-bio.org:/tmp/cvs-serv22143 Modified Files: Central.pm Log Message: fixed bug that allowed secondary inputs to be registered without articlenames. moby-live/Perl/MOBY Central.pm,1.283,1.284 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.283 retrieving revision 1.284 diff -u -r1.283 -r1.284 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2007/06/01 13:01:15 1.283 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2007/06/14 13:44:52 1.284 @@ -1608,6 +1608,9 @@ my $article = $parameter->getAttributeNode("articleName"); $article = $article->getValue() if $article; + return (-1,"Secondary inputs must be registered with articlenames.") + unless $article; + # make sure that the articlename is corrects return (-1,"Secondary input had an invalid articlename. Articlenames may not contain spaces or other special characters.") if $article =~ /([\+\=\':\s\"\&\<\>\[\]\^\`\{\|\}\~\(\)\\\/\$\#\@\,\|\?\.!\*\;])/; From gordonp at dev.open-bio.org Sat Jun 16 00:24:01 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 15 Jun 2007 20:24:01 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706160024.l5G0O14q029066@dev.open-bio.org> gordonp Fri Jun 15 20:24:00 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv29030/src/main/ca/ucalgary/seahawk/gui Modified Files: MobyContentPane.java Log Message: Fixed HTML page loading..must use setPage(), not setText due to JEditorPane bug, fixed indetation, removed cruft code, improved preformatting moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyContentPane.java,1.10,1.11 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java 2007/06/09 22:05:52 1.10 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java 2007/06/16 00:24:00 1.11 @@ -1,6 +1,7 @@ package ca.ucalgary.seahawk.gui; +// For external links import ca.ucalgary.seahawk.util.*; import org.biomoby.client.MobyRequest; @@ -86,6 +87,7 @@ editorPane = new PrintableJEditorPane(); editorPane.addKeyListener(this); editorPane.setTransferHandler(getTransferHandler()); + //editorPane.setPreferredSize(parentComponent.getPreferredSize()); editorPane.setEditable(false); editorPane.addMouseListener(this); editorPane.addHyperlinkListener(this); @@ -237,25 +239,23 @@ return; } catch(Exception e){ - e.printStackTrace(); status.setText("Note: There was an error transforming the MOBY data " + "into presentation form, it may not be displayed correctly"); logger.error("Note: There was an error transforming the MOBY data " + "into presentation form, it may not be displayed correctly"); } + // Get rid of inter-tag whitespaces + htmlContents = htmlContents.replaceAll(">[ \\t\\r\\n]+<", "><"); + int origHash = htmlContents.hashCode(); // Looks like tab-formatted text (at least 3 tabs)? - if(htmlContents.indexOf('\t') != -1){ - htmlContents = htmlContents.replaceAll(">(([^<]*\t){3,}[^<]+)", ">
      $1
      "); - } - // Looks like formatting whitespace - else if(htmlContents.indexOf(" ") != -1){ - htmlContents = htmlContents.replaceAll(">([^<]+ [^<]+)<", ">
      $1
      <"); - } - else{ + htmlContents = htmlContents.replaceAll(">(([^<]*\t){3,}[^<]+)<", ">
      $1
      <"); + // Looks like formatting whitespace? + htmlContents = htmlContents.replaceAll(">([^<]* [^<]*)<", ">
      $1
      <"); + // If no preformatting done, break up long DNA stretches + if(htmlContents.hashCode() == origHash){ // Break up any really long DNA/AA stretches - System.err.println("Trying to break up long streches"); - htmlContents = htmlContents.replaceAll("([a-zA-Z]{60})", "\n
      $1"); - htmlContents = htmlContents.replaceAll("([a-zA-Z]{60})([a-zA-Z]{1,})", "$1\n
      $2
      \n"); + htmlContents = htmlContents.replaceAll("([a-zA-Z]{80})", "\n
      $1"); + htmlContents = htmlContents.replaceAll("([a-zA-Z]{80})([a-zA-Z]{1,})", "$1\n
      $2
      \n"); } // Otherwise assume it's formatted resultBuffer.append(htmlContents); @@ -284,10 +284,25 @@ // Assume it's plain text, or whatever the JEditorPane can glean from the content-type // such as a remote HTML or RTF doc, because result buffer will be empty in condition below else{ + //editorPane.setContentType("text/plain"); isContentsXML = false; + //editorPane.setFont(java.awt.Font.getFont("Monospaced")); + editorPane.setContentType("text/html"); + String body = getInputStreamContents(url.openStream()); + if(body.toLowerCase().indexOf("
      "+
      +						    body.replaceAll("&", "&").replaceAll("<","<")+
      +						    "
      "); + } } - if(resultBuffer.length() == 0){ + if(resultBuffer == null){ // only happens if the url is already an HTML doc + editorPane.setPage(url); + } + else if(resultBuffer.length() == 0){ // Attempt to use MobyClient to convert the url's data into a Moby object // (e.g. if the file to load is an image, or a chromatogram) try{ @@ -309,21 +324,7 @@ logger.error("Failure in loading MOBYfied binary data:\n" + e); } // Shouldn't get here unless either not binary, or the binary data load failed - editorPane.setContentType("text/html"); - String body = getInputStreamContents(url.openStream()); - // Is it already HTML? - if(body.toLowerCase().indexOf("
      "+
      -						    body.replaceAll("&", "&").replaceAll("<","<")+
      -						    "
      "); - } - editorPane.setText(resultBuffer.toString()); + editorPane.setPage(url); } else{ editorPane.setText(resultBuffer.toString()); @@ -332,8 +333,6 @@ } // Regardless of the doc, scroll to a reference called "start:" if available. // By default the pane will annoyingly scroll to the bottom when new data is loaded. - try{Thread.sleep(1000);} // Give it time to paint before scrolling - catch(Exception te){} editorPane.scrollToReference("start"); } catch (java.io.IOException ioe) { @@ -403,13 +402,13 @@ tabbedPane.setTitleAt(tabbedPane.indexOfComponent(this), ""+requestEvent.getID()+"-"+requestEvent.getService().getName()); setWaitScreen(); - // Store the request being sent (w/ 2ndary params and all), - // for reference (e.g. when exporting a workflow) - try{ - dataRecorder.saveInputData(requestEvent); - } catch(Exception e){ - e.printStackTrace(); - } + // Store the request being sent (w/ 2ndary params and all), + // for reference (e.g. when exporting a workflow) + try{ + dataRecorder.saveInputData(requestEvent); + } catch(Exception e){ + e.printStackTrace(); + } } public void stop(MobyRequest request, int requestID){ @@ -495,17 +494,17 @@ } public String toScufl() throws Exception{ - URL[] historyToExport = (URL[]) history.toArray(new URL[history.size()]); - if(historyIndex != historyToExport.length-1){ - // Shorten the array if we aren't cuurently on the last doc (i.e. - // we don't want to export documents forward in the history) - URL[] truncatedHistory = new URL[historyIndex]; - System.arraycopy(historyToExport, 0, truncatedHistory, 0, historyIndex); - historyToExport = truncatedHistory; - } - ByteArrayOutputStream output = new ByteArrayOutputStream(); - dataRecorder.exportWorkflow(historyToExport, output, DataRecorder.TAVERNA15); - return output.toString(); + URL[] historyToExport = (URL[]) history.toArray(new URL[history.size()]); + if(historyIndex != historyToExport.length-1){ + // Shorten the array if we aren't cuurently on the last doc (i.e. + // we don't want to export documents forward in the history) + URL[] truncatedHistory = new URL[historyIndex]; + System.arraycopy(historyToExport, 0, truncatedHistory, 0, historyIndex); + historyToExport = truncatedHistory; + } + ByteArrayOutputStream output = new ByteArrayOutputStream(); + dataRecorder.exportWorkflow(historyToExport, output, DataRecorder.TAVERNA15); + return output.toString(); } // Save the MOBY data to a file, then tell NewBrowser to load that local file URL @@ -543,8 +542,8 @@ } try { - URL outputURL = dataRecorder.saveOutputData(mre); - gotoURL(outputURL, true); + URL outputURL = dataRecorder.saveOutputData(mre); + gotoURL(outputURL, true); } catch (Exception e) { failed("Could not write a local file"); editorPane.setText("ERROR: Could not write temporary file for MOBY results: " + e); @@ -554,31 +553,6 @@ succeeded(responseType); } - private String serviceToFilePrefix(MobyService service){ - return service.getAuthority()+"_SEAHAWk_"+service.getName()+"_SEAHAWk_"; - } - - private MobyService filePrefixToService(String filename) throws Exception{ - String tokens[] = filename.split("_SEAHAWk_"); - if(tokens == null || tokens.length < 2){ - return null; - } - - String auth = tokens[0]; - String name = tokens[1]; - - if(name == null){ - return null; - } - - MobyService service = new MobyService(name, auth); // template - MobyService[] validServices = servicesGUI.getMobyCentralImpl().findService(service); - if(validServices == null || validServices.length == 0){ - return null; - } - return validServices[0]; - } - protected boolean hasContents(MobyContentInstance responses){ MobyDataObjectSet retrievedObjects = responses.retrieveObjects(); return retrievedObjects != null && retrievedObjects.size() > 0; From gordonp at dev.open-bio.org Sat Jun 16 00:25:08 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 15 Jun 2007 20:25:08 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706160025.l5G0P88q029132@dev.open-bio.org> gordonp Fri Jun 15 20:25:08 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared In directory dev.open-bio.org:/tmp/cvs-serv29096/src/main/org/biomoby/shared Modified Files: MobyNamespace.java Log Message: Fixed namespace 'put' data typing moby-live/Java/src/main/org/biomoby/shared MobyNamespace.java,1.9,1.10 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyNamespace.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyNamespace.java 2007/06/09 21:58:26 1.9 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyNamespace.java 2007/06/16 00:25:08 1.10 @@ -38,7 +38,7 @@ protected Registry registry; //provenance of the namspace definition private static Map namespacesMapBySynonym = new HashMap(); - private static Map namespacesMapByURL = new HashMap(); + private static Map namespacesMapByURL = new HashMap(); /************************************************************************** * Default constructor. Other characteristics are empty - which is usually @@ -87,7 +87,7 @@ } namespacesMapBySynonym.put(reg.getSynonym(), namespaces); - namespacesMapByURL.put(namespaceDefURL.toString(), namespaces); + namespacesMapByURL.put(namespaceDefURL, namespaces); } } From gordonp at dev.open-bio.org Sat Jun 16 00:26:01 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 15 Jun 2007 20:26:01 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706160026.l5G0Q1fI029177@dev.open-bio.org> gordonp Fri Jun 15 20:26:01 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client In directory dev.open-bio.org:/tmp/cvs-serv29141/src/main/org/biomoby/client Modified Files: MobyRequest.java Log Message: Eliminated superfluous processEvent() call, once all data is loaded moby-live/Java/src/main/org/biomoby/client MobyRequest.java,1.26,1.27 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java 2007/06/08 14:04:27 1.26 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java 2007/06/16 00:26:01 1.27 @@ -293,7 +293,11 @@ Element mobyDOM = null; if(mobyService.isAsynchronous()){ // Async is "simpler", because it had to merge DOMs together into a single MobyContentInstance anyway - return performAsyncSOAPRequest(mobyService, inData, handler, requestId); + MobyContentInstance mci = performAsyncSOAPRequest(mobyService, inData, handler, requestId); + StringWriter writer = new StringWriter(); + MobyDataUtils.toXMLDocument(writer, mci); + contentsXML.append(writer.toString()); + return mci; } else{ String mobyXML = convertMOBYDataToMOBYRequest(inData); @@ -347,7 +351,12 @@ MobyDataUtils.toXMLDocument(xmlWriter, finalContents); mre.setContentsXML(xmlWriter.toString()); - handler.processEvent(mre); + if(!queryIDs.isEmpty()){ + // Send an update event only if we aren't finished yet. + // If we are finished, the client is going to get this event as the + // invocation thread finishes up (no need to double up). + handler.processEvent(mre); + } } } } catch (Exception e) { From gordonp at dev.open-bio.org Sat Jun 16 00:26:38 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 15 Jun 2007 20:26:38 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706160026.l5G0QcEh029221@dev.open-bio.org> gordonp Fri Jun 15 20:26:38 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util In directory dev.open-bio.org:/tmp/cvs-serv29185/src/main/ca/ucalgary/seahawk/util Modified Files: SeahawkOptions.java Log Message: Added check for null registry when saving preferences moby-live/Java/src/main/ca/ucalgary/seahawk/util SeahawkOptions.java,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/SeahawkOptions.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/SeahawkOptions.java 2007/06/09 22:00:27 1.3 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/SeahawkOptions.java 2007/06/16 00:26:38 1.4 @@ -213,9 +213,11 @@ properties.setProperty(CACHE_POLICY_PROP, ""+cacheExpiryInHours); properties.setProperty(REFERRER_POLICY_PROP, ""+referrerPolicy); properties.setProperty(TEMP_DIR_PROP, tmpDir.getCanonicalFile().getPath()); - properties.setProperty(REGISTRY_SYNONYM_PROP, registry.getSynonym()); - properties.setProperty(REGISTRY_ENDPOINT_PROP, registry.getEndpoint()); - properties.setProperty(REGISTRY_NAMESPACE_PROP, registry.getNamespace()); + if(registry != null){ + properties.setProperty(REGISTRY_SYNONYM_PROP, registry.getSynonym()); + properties.setProperty(REGISTRY_ENDPOINT_PROP, registry.getEndpoint()); + properties.setProperty(REGISTRY_NAMESPACE_PROP, registry.getNamespace()); + } properties.storeToXML(os, PROPS_FILE_COMMENT, From gordonp at dev.open-bio.org Sat Jun 16 00:27:44 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 15 Jun 2007 20:27:44 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706160027.l5G0Ri5E029265@dev.open-bio.org> gordonp Fri Jun 15 20:27:44 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util In directory dev.open-bio.org:/tmp/cvs-serv29229/src/main/ca/ucalgary/seahawk/util Modified Files: CloseTabIcon.java Log Message: Changed code to ensure close action is only active when the close icon is displayed moby-live/Java/src/main/ca/ucalgary/seahawk/util CloseTabIcon.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/CloseTabIcon.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/CloseTabIcon.java 2007/04/03 02:18:46 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/CloseTabIcon.java 2007/06/16 00:27:44 1.2 @@ -34,6 +34,10 @@ super(getIcon(), otherIcon, spacerWidth, orient); } + public Rectangle getCloseIconArea(){ + return closeIconArea; + } + public static Icon getIcon() throws Exception{ if(closeIcon == null){ URL u = Thread.currentThread().getContextClassLoader().getResource(CLOSE_TAB_ICON_RESOURCE); @@ -57,19 +61,51 @@ return; } tabbedPane = (JTabbedPane) c; - tabbedPane.addMouseListener(new MouseAdapter(){ - public void mouseReleased(MouseEvent e){ - // Did the user click in the close icon area? - if(!e.isConsumed() && closeIconArea.contains(e.getX(), e.getY())){ - int tabIndex = tabbedPane.getSelectedIndex(); - tabbedPane.remove(tabIndex); - e.consume(); // so other tabs aren't closed by mistake - } - } - }); + tabbedPane.addMouseListener(new Closer(this, tabbedPane)); } // The close Icon is the first of the two. Note its area so we can check for mouse clicks later closeIconArea = new Rectangle(x, y, getFirstIcon().getIconWidth(), getFirstIcon().getIconHeight()); } + + class Closer extends MouseAdapter{ + private CloseTabIcon icon; + private JTabbedPane tabbedPane; + private boolean active; + + public Closer(CloseTabIcon cti, JTabbedPane tp){ + icon = cti; + tabbedPane = tp; + active = false; + } + + public void mousePressed(MouseEvent e){ + if(!e.isConsumed() && getCloseIconArea() != null && + getCloseIconArea().contains(e.getX(), e.getY()) && + tabbedPane.getIconAt(tabbedPane.getSelectedIndex()) == icon){ + active = true; + } + else{ + active = false; + } + } + + public void mouseReleased(MouseEvent e){ + // Did the user click in the close icon area, when the icon was being displayed? + if(active && !e.isConsumed() && getCloseIconArea() != null && + getCloseIconArea().contains(e.getX(), e.getY())){ + int tabIndex = tabbedPane.getSelectedIndex(); + if(tabIndex < 0){ + return; + } + if(tabbedPane.getIconAt(tabIndex) != icon){ + // Don't respond unless the close tab icon is actually showing + return; + } + tabbedPane.remove(tabIndex); + e.consume(); // so other tabs aren't closed by mistake + tabbedPane.removeMouseListener(this); + } + } + } } From gordonp at dev.open-bio.org Sat Jun 16 00:28:11 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 15 Jun 2007 20:28:11 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706160028.l5G0SBSA029309@dev.open-bio.org> gordonp Fri Jun 15 20:28:11 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services In directory dev.open-bio.org:/tmp/cvs-serv29273/src/main/ca/ucalgary/seahawk/services Modified Files: MobyComplexBuilder.java Log Message: Removed debug message moby-live/Java/src/main/ca/ucalgary/seahawk/services MobyComplexBuilder.java,1.8,1.9 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyComplexBuilder.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyComplexBuilder.java 2007/06/09 22:01:15 1.8 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyComplexBuilder.java 2007/06/16 00:28:11 1.9 @@ -183,7 +183,7 @@ } } } - System.err.println("Namespace of object being returned is " + mobyObj.getPrimaryNamespace().getName()); + return mobyObj; } From gordonp at dev.open-bio.org Sat Jun 16 00:28:58 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 15 Jun 2007 20:28:58 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706160028.l5G0Swas029353@dev.open-bio.org> gordonp Fri Jun 15 20:28:58 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources In directory dev.open-bio.org:/tmp/cvs-serv29317/src/main/ca/ucalgary/seahawk/resources Modified Files: moby2HTML.xsl Log Message: Fixed documentation typos, referred to Bluejay instead of Seahawk moby-live/Java/src/main/ca/ucalgary/seahawk/resources moby2HTML.xsl,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/moby2HTML.xsl,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/moby2HTML.xsl 2006/10/26 01:32:06 1.2 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/moby2HTML.xsl 2007/06/16 00:28:57 1.3 @@ -2,7 +2,7 @@ - + @@ -57,7 +57,7 @@ - + From gordonp at dev.open-bio.org Sat Jun 16 00:29:40 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 15 Jun 2007 20:29:40 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706160029.l5G0TeFc029397@dev.open-bio.org> gordonp Fri Jun 15 20:29:39 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources In directory dev.open-bio.org:/tmp/cvs-serv29361/src/main/ca/ucalgary/seahawk/resources Modified Files: MobyContentGUIHelp.html Log Message: Minor doc updates moby-live/Java/src/main/ca/ucalgary/seahawk/resources MobyContentGUIHelp.html,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/MobyContentGUIHelp.html,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/MobyContentGUIHelp.html 2007/06/08 14:04:27 1.2 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/MobyContentGUIHelp.html 2007/06/16 00:29:39 1.3 @@ -16,6 +16,7 @@
    3. How do I control tabs?
    4. How do I avoid the secondary input window?
    5. How do I save data?
    6. +
    7. Where do I report bugs?
    8. Why is this application called Seahawk?

    9. @@ -134,6 +135,11 @@ presentation purposes).

      + +

      Where do I report bugs?

      + Please report any bugs to Paul Gordon, gordonp at ucalgary.ca. Provide as much detail as possible so that the + buggy conditions can be recreated, including any messages from the Java console. +

      Why is this application called Seahawk?

      In the whaling novel Moby Dick, @@ -150,12 +156,5 @@

      An eagle flew thrice round Tarquin's head, removing his cap to replace it, and thereupon Tanaquil, his wife, declared that Tarquin would be king of Rome. But only by the replacing of the cap was that omen accounted good. Ahab's hat was never restored; the wild hawk flew on and on with it; far in advance of the prow: and at last disappeared; while from the point of that disappearance, a minute black spot was dimly discerned, falling from that vast height into the sea.

      -
      -
      -
      Paul Gordon
      - - -Last modified: Tue Jul 25 20:40:36 MDT 2006 - From gordonp at dev.open-bio.org Sat Jun 16 00:30:35 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 15 Jun 2007 20:30:35 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706160030.l5G0UZXH029441@dev.open-bio.org> gordonp Fri Jun 15 20:30:34 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test In directory dev.open-bio.org:/tmp/cvs-serv29405/src/main/ca/ucalgary/seahawk/gui/test Modified Files: SeahawkTestCase.java Log Message: Added tests for user preferences save/load, made hyperlink clicking more robust moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test SeahawkTestCase.java,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test/SeahawkTestCase.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test/SeahawkTestCase.java 2007/04/18 15:59:00 1.7 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test/SeahawkTestCase.java 2007/06/16 00:30:34 1.8 @@ -1,12 +1,7 @@ package ca.ucalgary.seahawk.gui.test; -import ca.ucalgary.seahawk.gui.MobyContentGUI; -import ca.ucalgary.seahawk.gui.MobyContentHelpPane; -import ca.ucalgary.seahawk.gui.MobyContentPane; -import ca.ucalgary.seahawk.gui.MobySaveDialog; -import ca.ucalgary.seahawk.gui.MobySecondaryInputGUI; -import ca.ucalgary.seahawk.gui.MobyServicesGUI; -import ca.ucalgary.seahawk.util.MobyUtils; +import ca.ucalgary.seahawk.gui.*; +import ca.ucalgary.seahawk.util.*; import org.biomoby.shared.MobyDataType; import org.biomoby.shared.data.*; @@ -605,7 +600,11 @@ Robot robot = new Robot(); robot.mouseMove(screenPos.x, screenPos.y+10); - sleep(1000); + sleep(2000); + robot.mouseMove(screenPos.x-10, screenPos.y+10); + sleep(2000); + robot.mouseMove(screenPos.x+10, screenPos.y+10); + sleep(2000); robot.mousePress(InputEvent.BUTTON1_MASK); robot.mouseRelease(InputEvent.BUTTON1_MASK); sleep(2000); @@ -728,6 +727,7 @@ Robot robot = new Robot(); JDialog secondaryParamsDialog = null; + sleep(10000); // wait for dialog to popup, may take a while when meta-data about the service is fetched DialogFinder dfinder = new DialogFinder(".*"); List showingDialogs = dfinder.findAll(); for(int i = 0; i < showingDialogs.size(); i++){ @@ -820,7 +820,7 @@ robot.mouseMove(screenEndPos.x+2, screenEndPos.y+2); robot.mousePress(InputEvent.BUTTON1_MASK); robot.mouseRelease(InputEvent.BUTTON1_MASK); - sleep(2000); + sleep(3000); finder.setName(MobyContentPane.MOBY_SERVICE_POPUP_NAME); Object servicePopup = finder.find(); assertNotNull("Clicking the highlighted region did not open the service options popup (was null)", @@ -862,7 +862,7 @@ showMenuItem((JMenu) serviceTypeChoices, servicePathChosen, robot); servicePathChosen.lastElement().doClick(300); - sleep(2000); + sleep(10000); DialogFinder dfinder = new DialogFinder(".*"); List showingDialogs = dfinder.findAll(); for(int i = 0; i < showingDialogs.size(); i++){ @@ -891,6 +891,50 @@ MobyContentGUI.main(new String[]{}); } + public void testUserPreferences() throws Exception{ + File tempFile = File.createTempFile("test-seahawk", ""); + try{ + java.io.FileOutputStream tempFileOS = new java.io.FileOutputStream(tempFile); + tempFileOS.write("junk".getBytes()); + tempFileOS.close(); + } catch(Exception e){ + e.printStackTrace(); + fail("Could not write to temporary file " + tempFile + ": " + e); + } + boolean failedAsShould = false; + try{ + SeahawkOptions.restoreSettings(tempFile.toURI().toURL()); + } catch(Exception e){ + failedAsShould = true; + } + assertTrue("No exception was thrown, despite a poorly formatted preference file", + failedAsShould); + + SeahawkOptions.setCacheExpiry(10.0); + assertTrue("Setting the cache expiry preference did not work, expected " + + "current value of 10, but found " + SeahawkOptions.getCacheExpiry(), + SeahawkOptions.getCacheExpiry() == 10.0); + try{ + java.io.FileOutputStream tempFileOS = new java.io.FileOutputStream(tempFile); + SeahawkOptions.saveSettings(tempFileOS); + tempFileOS.close(); + } catch(Exception e){ + e.printStackTrace(); + fail("Could not save Seahawk settings to file " + tempFile + ": " + e); + } + SeahawkOptions.setCacheExpiry(20.0); + try{ + SeahawkOptions.restoreSettings(tempFile.toURI().toURL()); + } catch(Exception e){ + e.printStackTrace(); + fail("Could not restore Seahawk settings from file " + tempFile + ": " + e); + } + assertTrue("The settings were not saved/restored properly, " + + "expected cache expiry of 10, but got 20", + SeahawkOptions.getCacheExpiry() == 10.0); + tempFile.delete(); + } + /** * @return a test suite for all the test methods of this test case. */ @@ -908,7 +952,8 @@ suite.addTest(new SeahawkTestCase("testRunAsynchronousService")); //done suite.addTest(new SeahawkTestCase("testRunServiceSecondariesAndSCUFL")); //done suite.addTest(new SeahawkTestCase("testHighlightOptions"));//done - suite.addTest(new SeahawkTestCase("testExternalBrowser"));//doney + suite.addTest(new SeahawkTestCase("testUserPreferences"));//done + suite.addTest(new SeahawkTestCase("testExternalBrowser"));//done return suite; } From gordonp at dev.open-bio.org Sat Jun 16 00:31:33 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 15 Jun 2007 20:31:33 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706160031.l5G0VXSq029485@dev.open-bio.org> gordonp Fri Jun 15 20:31:33 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv29449/src/main/ca/ucalgary/seahawk/gui Modified Files: MobySaveDialog.java Log Message: Fixed suffix-checking logic moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobySaveDialog.java,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobySaveDialog.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobySaveDialog.java 2007/06/08 14:04:27 1.3 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobySaveDialog.java 2007/06/16 00:31:33 1.4 @@ -48,15 +48,18 @@ File f = fileChooser.getSelectedFile(); String filename = f.getName(); javax.swing.filechooser.FileFilter filter = fileChooser.getFileFilter(); - if(filename.indexOf(XML_EXT) == filename.length()-XML_EXT.length()){ + if(filename.indexOf(XML_EXT) != -1 && + filename.indexOf(XML_EXT) == filename.length()-XML_EXT.length()){ // ends in xml suffix exportXML(document, f); } - else if(filename.indexOf(HTML_EXT) == filename.length()-HTML_EXT.length()){ + else if(filename.indexOf(HTML_EXT) != -1 && + filename.indexOf(HTML_EXT) == filename.length()-HTML_EXT.length()){ // ends in html suffix exportHTML(document, f); } - else if(filename.indexOf(SCUFL_EXT) == filename.length()-SCUFL_EXT.length()){ + else if(filename.indexOf(SCUFL_EXT) != -1 && + filename.indexOf(SCUFL_EXT) == filename.length()-SCUFL_EXT.length()){ // ends in html suffix exportSCUFL(document, f); } From gordonp at dev.open-bio.org Sat Jun 16 00:32:56 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 15 Jun 2007 20:32:56 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706160032.l5G0Wu6H029529@dev.open-bio.org> gordonp Fri Jun 15 20:32:56 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv29493/src/main/ca/ucalgary/seahawk/gui Modified Files: SeahawkOptionsGUI.java Log Message: Added division lines to logical separate parts of the pereferences moby-live/Java/src/main/ca/ucalgary/seahawk/gui SeahawkOptionsGUI.java,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/SeahawkOptionsGUI.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/SeahawkOptionsGUI.java 2007/06/09 22:03:44 1.3 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/SeahawkOptionsGUI.java 2007/06/16 00:32:56 1.4 @@ -122,6 +122,7 @@ JSeparator line = new JSeparator(); c.gridwidth = GridBagConstraints.REMAINDER; gridbag.setConstraints(line, c); + add(line); sendReferrerCheckBox = new JCheckBox("Send referrer data to services"); c.gridwidth = GridBagConstraints.REMAINDER; @@ -131,6 +132,7 @@ line = new JSeparator(); c.gridwidth = GridBagConstraints.REMAINDER; gridbag.setConstraints(line, c); + add(line); JPanel expiryPanel = new JPanel(new GridLayout(1,0)); label = new JLabel("Cache expiry (in hours)"); @@ -157,6 +159,7 @@ line = new JSeparator(); c.gridwidth = GridBagConstraints.REMAINDER; gridbag.setConstraints(line, c); + add(line); resetButton = new JButton("Restore program defaults"); resetButton.addActionListener(this); From gordonp at dev.open-bio.org Sat Jun 16 00:44:52 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 15 Jun 2007 20:44:52 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706160044.l5G0iqcS029597@dev.open-bio.org> gordonp Fri Jun 15 20:44:51 EDT 2007 Update of /home/repository/moby/moby-live/Java/xmls In directory dev.open-bio.org:/tmp/cvs-serv29561/xmls Modified Files: seahawkBuild.xml Log Message: Included all of Axis in applet, changed splasher moby-live/Java/xmls seahawkBuild.xml,1.9,1.10 =================================================================== RCS file: /home/repository/moby/moby-live/Java/xmls/seahawkBuild.xml,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- /home/repository/moby/moby-live/Java/xmls/seahawkBuild.xml 2007/06/09 22:06:28 1.9 +++ /home/repository/moby/moby-live/Java/xmls/seahawkBuild.xml 2007/06/16 00:44:51 1.10 @@ -17,8 +17,8 @@ - - + + @@ -75,7 +75,7 @@ - + From gordonp at dev.open-bio.org Sat Jun 16 19:31:59 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Sat, 16 Jun 2007 15:31:59 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706161931.l5GJVx9H032706@dev.open-bio.org> gordonp Sat Jun 16 15:31:58 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/splash In directory dev.open-bio.org:/tmp/cvs-serv32671/src/main/ca/ucalgary/seahawk/gui/splash Log Message: Directory /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/splash added to the repository moby-live/Java/src/main/ca/ucalgary/seahawk/gui/splash - New directory rcsdiff: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/splash/RCS/-,v: No such file or directory rcsdiff: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/splash/RCS/New,v: No such file or directory rcsdiff: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/splash/RCS/directory,v: No such file or directory From gordonp at dev.open-bio.org Sat Jun 16 19:34:36 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Sat, 16 Jun 2007 15:34:36 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706161934.l5GJYaUY000327@dev.open-bio.org> gordonp Sat Jun 16 15:34:36 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv32758/src/main/ca/ucalgary/seahawk/gui Modified Files: MobyContentGUI.java Log Message: Restored system properties for JAXp and JAXT because default transformer on Windows doesn't work properly moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyContentGUI.java,1.11,1.12 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java 2007/06/09 22:16:54 1.11 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java 2007/06/16 19:34:36 1.12 @@ -747,7 +747,12 @@ logger.warn("Cannot process close tab event: tab " + activeTabIndex +" no longer exists"); return; } - tabbedPane.remove(activeTabIndex); + if(tabbedPane.getComponentAt(activeTabIndex) instanceof MobyContentClipboard){ + // Don't close clipboard, if somehow we were asked... + } + else{ + tabbedPane.remove(activeTabIndex); + } } else if(MobyContentClipboard.CLEAR_CLIPBOARD_OPTION.equals(cmd)){ clipboard.clearData(); @@ -908,26 +913,31 @@ java.util.Locale.setDefault(java.util.Locale.ENGLISH); // Unless overridden on the command line, use xerces - //if(System.getProperty("javax.xml.parsers.DocumentBuilderFactory") == null){ - // System.setProperty("javax.xml.parsers.DocumentBuilderFactory", - // "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl"); - //} + if(System.getProperty("javax.xml.parsers.DocumentBuilderFactory") == null){ + System.setProperty("javax.xml.parsers.DocumentBuilderFactory", + "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl"); + } // Unless overridden on the command line, use xalan - //if(System.getProperty("javax.xml.transform.TransformerFactory") == null){ - // System.setProperty("javax.xml.transform.TransformerFactory", - // "org.apache.xalan.processor.TransformerFactoryImpl"); - //} + if(System.getProperty("javax.xml.transform.TransformerFactory") == null){ + System.setProperty("javax.xml.transform.TransformerFactory", + "org.apache.xalan.processor.TransformerFactoryImpl"); + } // Setting this explicitly prevents repeated calls to the META-INF file encoding the same - //if(System.getProperty("org.apache.xerces.xni.parser.XMLParserConfiguration") == null){ - // System.setProperty("org.apache.xerces.xni.parser.XMLParserConfiguration", - // "org.apache.xerces.parsers.StandardParserConfiguration"); - //} + if(System.getProperty("org.apache.xerces.xni.parser.XMLParserConfiguration") == null){ + System.setProperty("org.apache.xerces.xni.parser.XMLParserConfiguration", + "org.apache.xerces.parsers.StandardParserConfiguration"); + } // First, restore any user preferences (uses default settings file location) - SeahawkOptions.restoreSettings(); - + try{ + SeahawkOptions.restoreSettings(); + } catch(Exception e){ + e.printStackTrace(); + System.err.println("Using default settings, could not restore Seahawk settings from file " + + SeahawkOptions.getDefaultsFile()+": "+ e); + } // Asynchronously load up ontology data so it's ready when the user needs it. cacheOntologies(); From gordonp at dev.open-bio.org Sat Jun 16 19:36:58 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Sat, 16 Jun 2007 15:36:58 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706161936.l5GJawX4000383@dev.open-bio.org> gordonp Sat Jun 16 15:36:58 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/splash In directory dev.open-bio.org:/tmp/cvs-serv335/src/main/ca/ucalgary/seahawk/gui/splash Added Files: SeahawkSplasher.java SplashWindow.java Log Message: Moved splash screen classes to own package so applet can load them separately from the rest of the applet (faster startup) moby-live/Java/src/main/ca/ucalgary/seahawk/gui/splash SeahawkSplasher.java,NONE,1.1 SplashWindow.java,NONE,1.1 From gordonp at dev.open-bio.org Sat Jun 16 19:36:58 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Sat, 16 Jun 2007 15:36:58 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706161936.l5GJawFL000369@dev.open-bio.org> gordonp Sat Jun 16 15:36:58 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv335/src/main/ca/ucalgary/seahawk/gui Removed Files: SeahawkSplasher.java SplashWindow.java Log Message: Moved splash screen classes to own package so applet can load them separately from the rest of the applet (faster startup) moby-live/Java/src/main/ca/ucalgary/seahawk/gui SeahawkSplasher.java,1.2,NONE SplashWindow.java,1.3,NONE rcsdiff: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/RCS/SeahawkSplasher.java,v: No such file or directory rcsdiff: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/RCS/SplashWindow.java,v: No such file or directory From gordonp at dev.open-bio.org Mon Jun 18 20:01:12 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 18 Jun 2007 16:01:12 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706182001.l5IK1ClV011806@dev.open-bio.org> gordonp Mon Jun 18 16:01:12 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv11771/src/main/ca/ucalgary/seahawk/gui Modified Files: MobyContentPane.java Log Message: Fixed regression on binary file imports, were treated as text due to preformatting condition in previous revision of this file moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyContentPane.java,1.11,1.12 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java 2007/06/16 00:24:00 1.11 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java 2007/06/18 20:01:12 1.12 @@ -216,6 +216,7 @@ String protocol = url.getProtocol(); URLConnection urlCon = url.openConnection(); + boolean unformatted = false; // It's XML that needs to be transformed to HTML if(urlString.lastIndexOf(".xml") == urlString.length()-4 || "text/xml".equals(urlCon.getContentType())){ @@ -293,6 +294,7 @@ resultBuffer = null; } else{ + unformatted = true; resultBuffer = new StringBuffer("
      "+
       						    body.replaceAll("&", "&").replaceAll("<","<")+
       						    "
      "); @@ -302,7 +304,7 @@ if(resultBuffer == null){ // only happens if the url is already an HTML doc editorPane.setPage(url); } - else if(resultBuffer.length() == 0){ + else if(resultBuffer.length() == 0 || unformatted){ // Attempt to use MobyClient to convert the url's data into a Moby object // (e.g. if the file to load is an image, or a chromatogram) try{ @@ -324,7 +326,11 @@ logger.error("Failure in loading MOBYfied binary data:\n" + e); } // Shouldn't get here unless either not binary, or the binary data load failed - editorPane.setPage(url); + if(resultBuffer.length() == 0){ + editorPane.setPage(url); + } else{ + editorPane.setText(resultBuffer.toString()); + } } else{ editorPane.setText(resultBuffer.toString()); From gordonp at dev.open-bio.org Tue Jun 19 18:05:35 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Tue, 19 Jun 2007 14:05:35 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706191805.l5JI5ZMl015867@dev.open-bio.org> gordonp Tue Jun 19 14:05:35 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data In directory dev.open-bio.org:/tmp/cvs-serv15832/src/main/org/biomoby/shared/data Modified Files: MobyDataObject.java Log Message: Fixed CRIB block to deal with Object tags (not just XRefs) properly moby-live/Java/src/main/org/biomoby/shared/data MobyDataObject.java,1.16,1.17 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObject.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObject.java 2007/06/07 23:58:15 1.16 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObject.java 2007/06/19 18:05:35 1.17 @@ -603,8 +603,11 @@ crib.append(obj.toXML()+"\n"); ((MobyDataXref) obj).setXmlMode(MobyDataXref.CRIB_XML_MODE_OFF); } - else{ + else if(obj instanceof MobyDataObject){ + int oldXMLMode = ((MobyDataObject) obj).getXmlMode(); + ((MobyDataObject) obj).setXmlMode(xmlMode); crib.append(obj.toXML()+"\n"); + ((MobyDataObject) obj).setXmlMode(oldXMLMode); } } crib.append("\n"); From mwilkinson at dev.open-bio.org Tue Jun 19 20:45:31 2007 From: mwilkinson at dev.open-bio.org (Mark Wilkinson) Date: Tue, 19 Jun 2007 16:45:31 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706192045.l5JKjV1e016460@dev.open-bio.org> mwilkinson Tue Jun 19 16:45:31 EDT 2007 Update of /home/repository/moby/moby-live/Perl/MOBY In directory dev.open-bio.org:/tmp/cvs-serv16441/MOBY Modified Files: CommonSubs.pm Log Message: missing namespace declaration on queryID; couldn't retrieve query ID in some cases moby-live/Perl/MOBY CommonSubs.pm,1.98,1.99 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/CommonSubs.pm,v retrieving revision 1.98 retrieving revision 1.99 diff -u -r1.98 -r1.99 --- /home/repository/moby/moby-live/Perl/MOBY/CommonSubs.pm 2007/05/25 13:57:23 1.98 +++ /home/repository/moby/moby-live/Perl/MOBY/CommonSubs.pm 2007/06/19 20:45:31 1.99 @@ -432,6 +432,7 @@ my $moby = _string_to_DOM($XML); return '' unless ( $moby->nodeName =~ /^(moby:|)mobyData$/ ); my $qid = _moby_getAttribute($moby, 'queryID' ); + $qid ||= _moby_getAttribute($moby, 'moby:queryID' ); return defined( $qid ) ? $qid : ''; } @@ -1618,6 +1619,7 @@ my $moby = _string_to_DOM($XML); return '' unless ( $moby->nodeName =~ /^(moby:|)queryInput|mobyData$/ ); my $qid = _moby_getAttribute($moby, 'queryID' ); + $qid ||= _moby_getAttribute($moby, 'moby:queryID' ); return defined( $qid ) ? $qid : ''; } From mwilkinson at dev.open-bio.org Tue Jun 19 20:49:39 2007 From: mwilkinson at dev.open-bio.org (Mark Wilkinson) Date: Tue, 19 Jun 2007 16:49:39 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706192049.l5JKnd4T016512@dev.open-bio.org> mwilkinson Tue Jun 19 16:49:39 EDT 2007 Update of /home/repository/moby/moby-live/Perl/t In directory dev.open-bio.org:/tmp/cvs-serv16493/t Modified Files: CommonSubs.t Log Message: adding a test for the moby: namespace into the commonsubs test harness moby-live/Perl/t CommonSubs.t,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/CommonSubs.t,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Perl/t/CommonSubs.t 2007/02/09 00:19:01 1.7 +++ /home/repository/moby/moby-live/Perl/t/CommonSubs.t 2007/06/19 20:49:39 1.8 @@ -145,7 +145,7 @@ - + @@ -159,7 +159,7 @@ @ids = keys %{$responses}; ok (scalar(@ids) == 2) or die "serviceResponseParser didn't find right number of invocation messages when two were passed\n"; ok ($ids[0] eq "first") or die "serviceResponseParser didn't find the first query id\n"; -ok ($ids[1] eq "second") or die "serviceResponseParser didn't find the second query id\n"; +ok ($ids[1] eq "second") or die "serviceResponseParser didn't find the second query id that included a moby: namespace\n"; my $sequence = "TAGCTGATCGAGCTGATGCTGA"; From mwilkinson at dev.open-bio.org Tue Jun 19 21:02:13 2007 From: mwilkinson at dev.open-bio.org (Mark Wilkinson) Date: Tue, 19 Jun 2007 17:02:13 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706192102.l5JL2Dc5016566@dev.open-bio.org> mwilkinson Tue Jun 19 17:02:13 EDT 2007 Update of /home/repository/moby/moby-live/Perl/MOBY In directory dev.open-bio.org:/tmp/cvs-serv16547/MOBY Modified Files: CommonSubs.pm Log Message: being a little more forgiving as to what is sent into the getCrossReferences routine. you can either send XML or you can send the MOBY::Client::Simple object. moby-live/Perl/MOBY CommonSubs.pm,1.99,1.100 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/CommonSubs.pm,v retrieving revision 1.99 retrieving revision 1.100 diff -u -r1.99 -r1.100 --- /home/repository/moby/moby-live/Perl/MOBY/CommonSubs.pm 2007/06/19 20:45:31 1.99 +++ /home/repository/moby/moby-live/Perl/MOBY/CommonSubs.pm 2007/06/19 21:02:13 1.100 @@ -949,6 +949,7 @@ sub getCrossReferences { my ( $XML ) = @_; + if ($XML =~ /MOBY::Client/){$XML = $XML->XML} $XML = _string_to_DOM($XML); my @xrefs; my @XREFS; From mwilkinson at dev.open-bio.org Tue Jun 19 21:10:52 2007 From: mwilkinson at dev.open-bio.org (Mark Wilkinson) Date: Tue, 19 Jun 2007 17:10:52 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706192110.l5JLAqqT016618@dev.open-bio.org> mwilkinson Tue Jun 19 17:10:52 EDT 2007 Update of /home/repository/moby/moby-live/Perl/MOBY In directory dev.open-bio.org:/tmp/cvs-serv16599/MOBY Modified Files: CommonSubs.pm Log Message: being a little more forgiving as to what is sent into the getCrossReferences routine. you can either send XML or you can send the MOBY::Client::Simple object. moby-live/Perl/MOBY CommonSubs.pm,1.100,1.101 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/CommonSubs.pm,v retrieving revision 1.100 retrieving revision 1.101 diff -u -r1.100 -r1.101 --- /home/repository/moby/moby-live/Perl/MOBY/CommonSubs.pm 2007/06/19 21:02:13 1.100 +++ /home/repository/moby/moby-live/Perl/MOBY/CommonSubs.pm 2007/06/19 21:10:52 1.101 @@ -949,7 +949,7 @@ sub getCrossReferences { my ( $XML ) = @_; - if ($XML =~ /MOBY::Client/){$XML = $XML->XML} + if ($XML =~ /MOBY::Client/){$XML = $XML->XML_DOM} $XML = _string_to_DOM($XML); my @xrefs; my @XREFS; From gordonp at dev.open-bio.org Thu Jun 21 18:33:44 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 21 Jun 2007 14:33:44 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706211833.l5LIXiBP032752@dev.open-bio.org> gordonp Thu Jun 21 14:33:43 EDT 2007 Update of /home/repository/moby/moby-live/Java/docs In directory dev.open-bio.org:/tmp/cvs-serv32716/docs Modified Files: Seahawk.html Log Message: Moved Seahawk jar file location, adjusted the docs according moby-live/Java/docs Seahawk.html,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Java/docs/Seahawk.html,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Java/docs/Seahawk.html 2007/03/27 14:01:36 1.6 +++ /home/repository/moby/moby-live/Java/docs/Seahawk.html 2007/06/21 18:33:43 1.7 @@ -69,7 +69,7 @@

      The jar (Java archive) file containing all of the required classes (including those from Axis, Jena, Xalan, Xerces, etc.) is available - here, and is + here, and is signed by the University of Calgary Bioinformatics Lab. You can also build your own version of the jar with the jMOBY CVS Ant target "seahawk-jar". Either jar file can be used as an application with the command: From mwilkinson at dev.open-bio.org Thu Jun 21 22:12:52 2007 From: mwilkinson at dev.open-bio.org (Mark Wilkinson) Date: Thu, 21 Jun 2007 18:12:52 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706212212.l5LMCqol000894@dev.open-bio.org> mwilkinson Thu Jun 21 18:12:52 EDT 2007 Update of /home/repository/moby/moby-live/Docs/ProjectDocs In directory dev.open-bio.org:/tmp/cvs-serv875/Docs/ProjectDocs Modified Files: index.html Log Message: added the test registry connection detals to the list of registries moby-live/Docs/ProjectDocs index.html,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Docs/ProjectDocs/index.html,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Docs/ProjectDocs/index.html 2007/01/22 21:19:34 1.7 +++ /home/repository/moby/moby-live/Docs/ProjectDocs/index.html 2007/06/21 22:12:52 1.8 @@ -1,43 +1,51 @@ -

      MOBY Project General Documentation

      - -
      -
      jMoby documentation - -
      jMoby contains libraries for Java developers, and it -also contains ready-to-use clients for any Biomoby users, allowing -access to Biomoby registries and to Biomoby services) - -
      -

      - -

      Language Specific Documents

      -

      -
       

      - -

      FAQ's

      -


      - -

      Catalogue of Registries

      - - - - - - - - - - - - - - - - -
      LocationEndpointPublic?DescriptionPolicy
      iCAPTURE CentreEndpoint: http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/mobycentral.pl -
      URI: http://mobycentral.icapture.ubc.ca/MOBY/Central
      YESA curated public registry hosted at the iCAPTURE Centre, VancouverPolicy
      IRRI PhilippinesEndpoint: http://cropwiki.irri.org/cgi-bin/MOBY-Central.pl
      - URI: http://cropwiki.irri.org/MOBY/Central
      YESThe MOBY registry at the International Rice Research Institute -(IRRI) is intended mostly for Generation Challenge Program (GCP) -developers. It allows the registration of experimental moby entities -within GCP.Policy
      - +

      MOBY Project General Documentation

      + +
      +
      jMoby documentation + +
      jMoby contains libraries for Java developers, and it +also contains ready-to-use clients for any Biomoby users, allowing +access to Biomoby registries and to Biomoby services) + +
      +

      + +

      Language Specific Documents

      +

      +
       

      + +

      FAQ's

      +


      + +

      Catalogue of Registries

      + + + + + + + + + + + + + + + + + + + +
      LocationEndpointPublic?DescriptionPolicy
      iCAPTURE CentreEndpoint: http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/mobycentral.pl +
      URI: http://mobycentral.icapture.ubc.ca/MOBY/Central
      YESA curated public registry hosted at the iCAPTURE Centre, VancouverPolicy
      Open TEST registryEndpoint: http://bioinfo.icapture.ubc.ca/cgi-bin/mobycentral/MOBY-Central.pl +
      OntologyServer: http://bioinfo.icapture.ubc.ca/cgi-bin/mobycentral/OntologyServer.cgi +
      URI: http://bioinfo.icapture.ubc.ca/MOBY/Central
      YESA full-featured +registry for testing your code or pre-registering a service or whatever you wish. The codebase is generally kept up-to-date +relative to the "real" registry, but the ontologies are not, so ontology nodes that you need might not be there and you will have +to register them.For testing purposes only. No guarantee of stability of any kind.
      IRRI PhilippinesEndpoint: http://cropwiki.irri.org/cgi-bin/MOBY-Central.pl
      + URI: http://cropwiki.irri.org/MOBY/Central
      YESThe MOBY registry at the International Rice Research Institute +(IRRI) is intended mostly for Generation Challenge Program (GCP) +developers. It allows the registration of experimental moby entities +within GCP.Policy
      + From gordonp at dev.open-bio.org Tue Jun 26 21:22:25 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Tue, 26 Jun 2007 17:22:25 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706262122.l5QLMP6F023831@dev.open-bio.org> gordonp Tue Jun 26 17:22:24 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data In directory dev.open-bio.org:/tmp/cvs-serv23796/src/main/org/biomoby/shared/data Modified Files: MobyDataUtils.java Log Message: Added carriage return to serialized XML envelope, to avoid potential I/O buffering issues moby-live/Java/src/main/org/biomoby/shared/data MobyDataUtils.java,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataUtils.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataUtils.java 2007/06/07 23:58:15 1.7 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataUtils.java 2007/06/26 21:22:24 1.8 @@ -31,7 +31,7 @@ os.write("\n".getBytes()); os.write(("\n").getBytes()); os.write(mci.toXML().getBytes()); - os.write("\n".getBytes()); + os.write("\n\n".getBytes()); return true; } @@ -52,7 +52,7 @@ writer.write("\n"); writer.write(("\n")); writer.write(mci.toXML()); - writer.write("\n"); + writer.write("\n\n"); return true; } From gordonp at dev.open-bio.org Tue Jun 26 21:24:14 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Tue, 26 Jun 2007 17:24:14 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706262124.l5QLOECx023874@dev.open-bio.org> gordonp Tue Jun 26 17:24:14 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared In directory dev.open-bio.org:/tmp/cvs-serv23839/src/main/org/biomoby/shared Modified Files: PrimitiveTypes.java Log Message: Added Boolean to list of primitive types (was incorrectly missing), also added convenience method to check a data type name against the list moby-live/Java/src/main/org/biomoby/shared PrimitiveTypes.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/PrimitiveTypes.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/PrimitiveTypes.java 2005/07/22 05:30:38 1.1 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/PrimitiveTypes.java 2007/06/26 21:24:14 1.2 @@ -11,8 +11,17 @@ *

      email me at edward.kawas at gmail.com */ public class PrimitiveTypes { - public static final String[] PRIMS = {"Object", "String", "Integer", "Float", "DateTime"}; + public static final String[] PRIMS = {"Object", "String", "Integer", "Float", "Boolean", "DateTime"}; + public static boolean isPrimitive(String dataType){ + for(String primitive: PRIMS){ + if(primitive.equals(dataType)){ + return true; + } + } + return false; + } + public final Object clone() throws java.lang.CloneNotSupportedException { return super.clone(); } From gordonp at dev.open-bio.org Tue Jun 26 21:25:04 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Tue, 26 Jun 2007 17:25:04 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706262125.l5QLP4L8023917@dev.open-bio.org> gordonp Tue Jun 26 17:25:04 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data In directory dev.open-bio.org:/tmp/cvs-serv23882/src/main/org/biomoby/shared/data Modified Files: MobyDataObjectVector.java Log Message: Added properly service-mode serialization moby-live/Java/src/main/org/biomoby/shared/data MobyDataObjectVector.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectVector.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectVector.java 2007/02/08 16:59:58 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectVector.java 2007/06/26 21:25:04 1.3 @@ -38,7 +38,19 @@ StringBuffer concatXML = new StringBuffer(); Iterator iter = members.iterator(); while(iter.hasNext()){ - concatXML.append(iter.next().toXML()); + MobyDataObject mdsi = iter.next(); + if(!getName().equals(mdsi.getName())){ + mdsi.setName(getName()); + } + + int oldXmlMode = mdsi.getXmlMode(); + if(oldXmlMode != xmlMode){ + mdsi.setXmlMode(xmlMode); + } + concatXML.append(mdsi.toXML()+"\n"); + if(oldXmlMode != xmlMode){ + mdsi.setXmlMode(oldXmlMode); + } } return concatXML.toString(); } From kawas at dev.open-bio.org Wed Jun 27 15:46:34 2007 From: kawas at dev.open-bio.org (Eddie Kawas) Date: Wed, 27 Jun 2007 11:46:34 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706271546.l5RFkYVD029879@dev.open-bio.org> kawas Wed Jun 27 11:46:34 EDT 2007 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory dev.open-bio.org:/tmp/cvs-serv29844/Client Modified Files: ServiceInstance.pm Log Message: added signatureURL to the list of fields. moby-live/Perl/MOBY/Client ServiceInstance.pm,1.19,1.20 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/ServiceInstance.pm,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- /home/repository/moby/moby-live/Perl/MOBY/Client/ServiceInstance.pm 2007/02/08 18:50:24 1.19 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/ServiceInstance.pm 2007/06/27 15:46:34 1.20 @@ -212,6 +212,7 @@ my %_attr_data = # DEFAULT ACCESSIBILITY ( authority => [ undef, 'read/write' ], + signatureURL => [ undef, 'read/write' ], name => [ undef, 'read/write' ], type => [ undef, 'read/write' ], input => [ undef, 'read/write' ] From kawas at dev.open-bio.org Wed Jun 27 15:47:33 2007 From: kawas at dev.open-bio.org (Eddie Kawas) Date: Wed, 27 Jun 2007 11:47:33 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706271547.l5RFlX1P029955@dev.open-bio.org> kawas Wed Jun 27 11:47:33 EDT 2007 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory dev.open-bio.org:/tmp/cvs-serv29920/Client Modified Files: Central.pm Log Message: added signatureURL to the instance of MOBY::CLient::SecondaryInstance that is returned via find service. moby-live/Perl/MOBY/Client Central.pm,1.147,1.148 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v retrieving revision 1.147 retrieving revision 1.148 diff -u -r1.147 -r1.148 --- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2007/02/09 21:46:34 1.147 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2007/06/27 15:47:33 1.148 @@ -1924,6 +1924,7 @@ $lsid = ""; } my $Type = &_nodeTextContent( $Service, 'serviceType' ); + my $signatureURL = &_nodeTextContent( $Service, 'signatureURL' ); my $authoritative = &_nodeTextContent( $Service, 'authoritative' ); my $contactEmail = &_nodeTextContent( $Service, 'contactEmail' ); my $URL = &_nodeTextContent( $Service, 'URL' ); @@ -1996,6 +1997,7 @@ secondary => \@SECONDARIES, description => $Description, registry => $Registry, + signatureURL => $signatureURL, XML => $Service->toString, ); push @Services, $Instance; From kawas at dev.open-bio.org Wed Jun 27 15:50:00 2007 From: kawas at dev.open-bio.org (Eddie Kawas) Date: Wed, 27 Jun 2007 11:50:00 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706271550.l5RFo0Sp029998@dev.open-bio.org> kawas Wed Jun 27 11:50:00 EDT 2007 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory dev.open-bio.org:/tmp/cvs-serv29963/Client Modified Files: ServiceInstance.pm Log Message: some doc would be nice i guess ... moby-live/Perl/MOBY/Client ServiceInstance.pm,1.20,1.21 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/ServiceInstance.pm,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- /home/repository/moby/moby-live/Perl/MOBY/Client/ServiceInstance.pm 2007/06/27 15:46:34 1.20 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/ServiceInstance.pm 2007/06/27 15:50:00 1.21 @@ -186,7 +186,7 @@ =head2 LSID - Title : contactEmail + Title : LSID Usage : $email = $Service->LSID() Args : none Function : get (readonly) service instance LSID @@ -194,6 +194,16 @@ =cut +=head2 signatureURL + + Title : signatureURL + Usage : $email = $Service->signatureURL() + Args : (optional) string representing a URL + Function : get/set the location of the RDF document that describes this service + Returns : current value as scalar string + +=cut + =head2 registry Title : registry From kawas at dev.open-bio.org Wed Jun 27 15:50:27 2007 From: kawas at dev.open-bio.org (Eddie Kawas) Date: Wed, 27 Jun 2007 11:50:27 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706271550.l5RFoRtf030038@dev.open-bio.org> kawas Wed Jun 27 11:50:27 EDT 2007 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory dev.open-bio.org:/tmp/cvs-serv30003/Client Modified Files: ServiceInstance.pm Log Message: moby-live/Perl/MOBY/Client ServiceInstance.pm,1.21,1.22 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/ServiceInstance.pm,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- /home/repository/moby/moby-live/Perl/MOBY/Client/ServiceInstance.pm 2007/06/27 15:50:00 1.21 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/ServiceInstance.pm 2007/06/27 15:50:27 1.22 @@ -187,7 +187,7 @@ =head2 LSID Title : LSID - Usage : $email = $Service->LSID() + Usage : $lsid = $Service->LSID() Args : none Function : get (readonly) service instance LSID Returns : current value as scalar string @@ -197,7 +197,7 @@ =head2 signatureURL Title : signatureURL - Usage : $email = $Service->signatureURL() + Usage : $sig = $Service->signatureURL() Args : (optional) string representing a URL Function : get/set the location of the RDF document that describes this service Returns : current value as scalar string From gordonp at dev.open-bio.org Thu Jun 28 16:45:45 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 28 Jun 2007 12:45:45 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706281645.l5SGjjLj004527@dev.open-bio.org> gordonp Thu Jun 28 12:45:44 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services In directory dev.open-bio.org:/tmp/cvs-serv4488/src/main/ca/ucalgary/seahawk/services Modified Files: MobyClient.java MobyComplexBuilder.java Added Files: IterativeMatchResult.java RegexParser.java Log Message: Major changes to Seahawk 'services' package to make MOB rule parsing much more powerful moby-live/Java/src/main/ca/ucalgary/seahawk/services IterativeMatchResult.java,NONE,1.1 RegexParser.java,NONE,1.1 MobyClient.java,1.14,1.15 MobyComplexBuilder.java,1.9,1.10 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java 2007/06/08 20:30:21 1.14 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java 2007/06/28 16:45:44 1.15 @@ -37,6 +37,7 @@ public static final String DATA_MAPPING_XML_RESOURCE = "ca/ucalgary/seahawk/resources/mobyBuilderRules.xml"; public static final String RESOURCE_SYSTEM_PROPERTY = "seahawk.rules"; public static final String RULE_SET_TAG = "object"; + public static final String RULE_NAME_ATTR = "name"; public static final String PREFIX_TAG = "prefix"; public static final String PREFIX_ATTR = "value"; public static final String ARTICLENAME_RULE_TAG = "articlename"; @@ -47,6 +48,8 @@ public static final String DATATYPE_RULE_ATTR = "value"; public static final String MEMBER_RULE_TAG = "member"; public static final String MEMBER_RULE_ATTR = "value"; + public static final String MEMBERS_RULE_TAG = "inheritMembers"; + public static final String MEMBERS_RULE_ATTR = "rule"; public static final String URL_REGEX_TAG = "url_regex"; public static final String REGEX_TAG = "regex"; public static final String XPATH_TAG = "xpath"; @@ -55,6 +58,7 @@ public static final String WHITESPACE_ATTR_NORMALIZE_VAL = "normalize"; public static final String WHITESPACE_ATTR_STRIP_FLANKING_VAL = "flanking"; public static final String WHITESPACE_ATTR_KEEP_VAL = "keep"; + public static final String DATATYPE_ATTR = "datatype"; public static final String ENCODING_ATTR = "encoding"; public static final String ENCODING_ATTR_BASE64_VAL = "Base64"; public static final String ENCODING_ATTR_NONE_VAL = "none"; @@ -67,6 +71,8 @@ private HashMap xpathMap; private HashMap urlRegexMap; private Map regexMap; + private Map builderNameMap; + private Map patternNameMap; private URL dataMappingXMLURL; private DocumentBuilder docBuilder; private static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(MobyClient.class); @@ -88,6 +94,8 @@ xpathMap = new HashMap(); urlRegexMap = new HashMap(); regexMap = new HashMap(); + builderNameMap = new HashMap(); + patternNameMap = new HashMap(); nsContext = new NamespaceContextImpl(); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); @@ -201,6 +209,8 @@ continue; } + String ruleName = ruleSet.getAttribute(RULE_NAME_ATTR); + Vector regexStrings = new Vector(); Vector urlRegexStrings = new Vector(); Vector xpathStrings = new Vector(); @@ -250,7 +260,7 @@ dataTypeString = getDataType(ruleMember); } else if(isMemberRule(ruleMember)){ - addMemberMapping(ruleMember, memberMap); + addMemberMapping(ruleMember, memberMap, dataTypeString); } // TODO add other production rules else{ @@ -279,7 +289,7 @@ addXPathMapping((String) xpathStrings.elementAt(j), namespaceMap, articleNameString); } for(int j = 0; j < regexStrings.size(); j++){ - addRegexMapping((String) regexStrings.elementAt(j), namespaceMap, articleNameString); + addRegexMapping((String) regexStrings.elementAt(j), namespaceMap, articleNameString, ruleName); } for(int j = 0; j < urlRegexStrings.size(); j++){ addURLRegexMapping((String) urlRegexStrings.elementAt(j), namespaceMap, articleNameString); @@ -296,7 +306,7 @@ addXPathMapping((String) xpathStrings.elementAt(j), namespaceMap, dataTypeString, memberMap, articleNameString); } for(int j = 0; j < regexStrings.size(); j++){ - addRegexMapping((String) regexStrings.elementAt(j), namespaceMap, dataTypeString, memberMap, articleNameString); + addRegexMapping((String) regexStrings.elementAt(j), namespaceMap, dataTypeString, memberMap, articleNameString, ruleName); } for(int j = 0; j < urlRegexStrings.size(); j++){ addURLRegexMapping((String) urlRegexStrings.elementAt(j), namespaceMap, dataTypeString, memberMap, articleNameString); @@ -330,8 +340,15 @@ return e != null && ARTICLENAME_RULE_TAG.equals(e.getLocalName()); } + // Defined or inherited rule spec. public boolean isMemberRule(Element e){ - return e != null && MEMBER_RULE_TAG.equals(e.getLocalName()); + return e != null && (MEMBER_RULE_TAG.equals(e.getLocalName()) || + MEMBERS_RULE_TAG.equals(e.getLocalName())); + } + + // Inherited rule spec. + public boolean isMembersRule(Element e){ + return e != null && MEMBERS_RULE_TAG.equals(e.getLocalName()); } public boolean isNamespaceRule(Element e){ @@ -402,19 +419,58 @@ return str; } - protected void addMemberMapping(Element memTag, Map membersMap) throws Exception{ + protected void addMemberMapping(Element memTag, Map membersMap, String dataTypeName) + throws Exception{ if(!isMemberRule(memTag)){ throw new Exception("Element provided to addMemberMapping (" + (memTag == null ? null : memTag.getLocalName()) + ") was not a member rule element"); } - + String ruleValue = memTag.getTextContent(); String memberNameKey = memTag.getAttribute(DATATYPE_RULE_ATTR); + if(ruleValue == null || ruleValue.length() == 0){ + System.err.println("Object member " + memberNameKey + " has a blank value rule"); + } + + String memberDataTypeSetting = memTag.getAttribute(DATATYPE_ATTR); + if(isMembersRule(memTag)){ + String membersRuleName = memTag.getAttribute(MEMBERS_RULE_ATTR); + if(membersRuleName == null || membersRuleName.length() == 0){ + throw new Exception("Attribute "+MEMBERS_RULE_ATTR+" is missing from the " + + "member rule tag '" + memTag.getNodeName()+"'"); + } + MobyComplexBuilder membersBuilder = builderNameMap.get(membersRuleName); + if(membersBuilder == null){ + throw new Exception("Attribute "+MEMBERS_RULE_ATTR+" refers to a rule (" + + membersRuleName+") that does not exist"); + } + MobyDataType dataType = MobyDataType.getDataType(dataTypeName); + if(!dataType.inheritsFrom(membersBuilder.getDataType())){ + throw new Exception("Data type produced by inherited rule (" + membersRuleName + + ") is not a subtype of the current rule (" + dataType.getName() + ")"); + } + // Borrow members from the builder, unless they already exist in the + // production rule (i.e. "member" rules override "inheritMembers" rules), + // BUT, we need to tell the builder that the regex to match is not + // the one from the current rule, but the one from the inherited rule + // (applied to the value created by ruleValue) + // the stering array for the inheritance rule looks like ["ruleName1", "ruleSrcValueExpr1"] + if(membersMap.containsKey(MobyComplexBuilder.INHERITED_MEMBERS_SENTINEL)){ + throw new Exception("More than one member inheritance tag was given, which is illegal"); + } + String[] inheritanceRuleSpecs = new String[2]; + inheritanceRuleSpecs[0] = membersRuleName; + inheritanceRuleSpecs[1] = ruleValue; + membersMap.put(MobyComplexBuilder.INHERITED_MEMBERS_SENTINEL, inheritanceRuleSpecs); + return; + } + if(memberNameKey == null || memberNameKey.length() == 0){ throw new Exception("Element provided to addMemberMapping did not " + "have a non-blank " + DATATYPE_RULE_ATTR + " attribute as required"); } + String memberWhitespaceSetting = memTag.getAttribute(WHITESPACE_ATTR); if(memberWhitespaceSetting == null || memberWhitespaceSetting.length() == 0){ memberWhitespaceSetting = WHITESPACE_ATTR_KEEP_VAL; // default is to keep whitespace @@ -429,6 +485,7 @@ "), overriding with default of " + WHITESPACE_ATTR_KEEP_VAL); memberWhitespaceSetting = WHITESPACE_ATTR_KEEP_VAL; } + String memberEncodingSetting = memTag.getAttribute(ENCODING_ATTR); if(memberEncodingSetting == null || memberEncodingSetting.length() == 0){ memberEncodingSetting = ENCODING_ATTR_NONE_VAL; // default is to not encode @@ -446,13 +503,16 @@ return; } - String ruleValue = memTag.getTextContent(); - if(ruleValue == null || ruleValue.length() == 0){ - System.err.println("Object member " + memberNameKey + " has a blank value rule"); - } - membersMap.put(memberNameKey, new String[]{ruleValue, + // Leave memberRuleName blank unless we inherited members via + // a rule attrubute. If memberRuleName is null, + // in another method we will see if any capture value in the member + // rule refers to a \p{ruleName} string in the regex + String memberRuleName = memTag.getAttribute(MEMBERS_RULE_ATTR); + membersMap.put(memberNameKey, new String[]{ruleValue, + memberDataTypeSetting, memberWhitespaceSetting, - memberEncodingSetting}); + memberEncodingSetting, + memberRuleName}); } protected void addNamespaceMapping(Element nsTag, Map namespaceStrings) throws Exception{ @@ -1016,7 +1076,7 @@ for(int i = 0; i < mobyObj.length; i++){ nsRules.put(mobyObj[i], "$0"); } - addRegexMapping(regexp, nsRules, articleName); + addRegexMapping(regexp, nsRules, articleName, (String) null); } public void addURLRegexMapping(String url_regexp, String[] mobyObj, String articleName){ //mobyObj<--mobyNamespaces @@ -1035,11 +1095,58 @@ /** * Converts seahawk-specific regex syntax into generic Java syntax (e.g \N becomes a - * match for any IUPAC DNA character, \P any amino acid) + * match for any IUPAC DNA character, \P any amino acid). We pass in the member map so that + * this method can populate the last field of rules that inherit complex members (by virtue + * of using the capture group whose values is derived from \p{ruleName}), with ruleName */ - protected String processRegExp(String regex){ - return regex.replaceAll("\\\\N", "[acgtunxACGTUNX]") - .replaceAll("\\\\P", "[ARNDCQEGHILKMFPSTWYVBZXarndcqeghilkmfpstwyvbz*]"); + protected String processRegExp(String regex, Map membersMap) throws Exception{ + String returnValue = regex.replaceAll("\\\\N", "[acgtunxACGTUNX]") + .replaceAll("\\\\P", "[ARNDCQEGHILKMFPSTWYVBZXarndcqeghilkmfpstwyvbz*]"); + + // Now see if there are any references to other patterns (by rule name) + // with the \p{} syntax specific to Seahawk + Pattern charClassPattern = Pattern.compile("\\\\p\\{([A-Za-z0-9]+)\\}"); + Matcher charClassMatcher = charClassPattern.matcher(returnValue); + Map capGroup2RuleReference = new HashMap(); + while(charClassMatcher.find()){ + String reference = charClassMatcher.group(1); + if(RegexParser.isPosixCharacterClass(reference)){ + continue; + } + + if(!patternNameMap.containsKey(reference)){ + throw new Exception("\\p{"+reference+"} in regex does not refer " + + "to a known Seahawk rule, cannot build the regex"); + } + + int capGroup = RegexParser.locationToCaptureGroupNumber(regex, charClassMatcher.start(1)); + if(capGroup > 0){ // sanity check + capGroup2RuleReference.put(capGroup, reference); + } + + // Replace ref with regex, elinating any nested capture groups, for efficiency + // (otherwise we'd need to shift all the $# refs in the rules map to compensate) + returnValue = returnValue.replaceFirst("\\\\p\\{"+reference+"\\}", + patternNameMap.get(reference).pattern().replaceAll("\\\\", "\\\\\\\\").replaceAll("\\((?!\\?)", "(?:")); + } + + if(!capGroup2RuleReference.isEmpty()){ + // Update any member rule that uses one of the capture values referring to a + // \p{ruleName} reference + for(String[] rule: membersMap.values()){ + for(Integer capGroupNum: capGroup2RuleReference.keySet()){ + if(rule[0].matches("^\\s*\\$"+capGroupNum+"\\s*$")){ + // This is where the rule actually gets the subrule reference update, + // UNLESS it was already specified (probably by a inheritsMembers tag) + if(rule[4] == null || rule[4].length() == 0){ + rule[4] = capGroup2RuleReference.get(capGroupNum); + } + break; + } + } + } + } + return returnValue; } /** @@ -1060,13 +1167,13 @@ return url_regex_flexible; } - protected void addRegexMapping(String regexp, Map nsRules, String articleName){ //nsRules = Map + protected void addRegexMapping(String regexp, Map nsRules, String articleName, String ruleName){ //nsRules = Map if(nsRules == null || nsRules.size() == 0){ System.err.println("Ignoring empty namespace-only regex rule mappings"); return; } - addRegexMapping(regexp, nsRules, (String) null, (Map) null, articleName); + addRegexMapping(regexp, nsRules, (String) null, (Map) null, articleName, null); } protected void addURLRegexMapping(String url_regexp, Map url_nsRules, String articleName){ //nsRules = Map @@ -1080,29 +1187,128 @@ public void addRegexMapping(String regexp, Map nsRules, String mobyDataType, Map membersMap){ - addRegexMapping(regexp, nsRules, mobyDataType, membersMap, null); + addRegexMapping(regexp, nsRules, mobyDataType, membersMap, null, null); } - public void addRegexMapping(String regexp, Map nsRules, String mobyDataType, Map membersMap, String articleName){ + /** + * This method looks for HAS members in a rule, and if they exist creates new + * capture groups around the accessed capture groups so that they can be further + * processed in MobyComplexBuilder (e.g. (\d)+ become ((\d+)) so we can deconstruct + * that part of the regex as capture *each* \d for the HAS (0 or more) member relationship. + * We also need to modify all of the rules that access capture groups to bump up their + * numbers due to the added capture groups here (transparent to the user). + * + * membersMap, nsRules, and articleName get their capture group references modified accordingly, + * and the new regex is returned with its extract capture groups. + */ + private String handleHASMembers(String regexp, Map nsRules, String mobyDataType, + Map membersMap, StringBuffer articleName) throws Exception{ + if(mobyDataType == null){ + //System.err.println("Got null data type for regex "+regexp); + return regexp; //must be a base object + } + MobyDataType dataType = MobyDataType.getDataType(mobyDataType, SeahawkOptions.getRegistry()); + if(dataType == null){ + throw new Exception("Cannot find definition of data type "+mobyDataType+ + " in the ontology, therefore the rule cannot be properly parsed"); + } + MobyRelationship[] memberRelationships = dataType.getChildren(); + + String newRegexp = processRegExp(regexp, membersMap); + Map captured = new HashMap(); + for(MobyRelationship memberRelationship: memberRelationships){ + if(memberRelationship.getRelationshipType() == Central.iHAS){ + String[] rule = membersMap.get(memberRelationship.getName()); + if(rule == null){ + System.err.println("Skipping HAS member "+memberRelationship.getName() + + " without a rule"); + continue; + } + Pattern pattern = Pattern.compile(newRegexp, Pattern.DOTALL | Pattern.COMMENTS); + int groupCount = RegexParser.groupCount(pattern); + for(int i = 0; i < groupCount; i++){ + if(captured.containsKey(i)){ //autoboxed int + // Already encapsulated the capture group due to another + // HAS member, don't need to add anything + System.err.println("Skipping processing of capture group "+i+ + ", it's already been processed by another member in this rule"); + continue; + } + if(rule[0].matches("^.*\\$"+i+"(?=\\D.*|\\z)")){ + //System.err.println("Substituting "+i+" with encapsulating capture group, " + + // "due to HAS condition of member "+memberRelationship.getName() + + // " with rule " + rule[0]); + + // Now actually update the regex with the new cap group + // including any quantity modifier associated with it. + boolean INCL_QUANTIFIER = true; + int capGroupRange[] = RegexParser.getCaptureGroupRange(pattern, i, INCL_QUANTIFIER); + newRegexp = newRegexp.substring(0, capGroupRange[0])+"("+ + newRegexp.substring(capGroupRange[0], capGroupRange[1]+1) + ")" + + (capGroupRange[1]+1 < newRegexp.length() ? newRegexp.substring(capGroupRange[1]+1) : ""); + // Bump up all the capture group reference higher than this one, in all rules + for(int j = i; j < groupCount; j++){ + for(String memberName: membersMap.keySet()){ + String[] memberRule = membersMap.get(memberName); + memberRule[0] = memberRule[0].replaceAll("\\$"+i+"(?=\\D.*|\\z)", "\\$"+(i+1)); + } + for(String nsName: nsRules.keySet()){ + String nsRule = nsRules.get(nsName); + nsRules.put(nsName, nsRule.replaceAll("\\$"+i+"(?=\\D.*|\\z)", "\\$"+(i+1))); + } + articleName.replace(0, articleName.length(), + articleName.toString().replaceAll("\\$"+i+"(?=\\D.*|\\z)", "\\$"+(i+1))); + } + captured.put(i, true); //autobox both key and value + for(int j = groupCount; j >= i; j--){ + captured.remove(j); + captured.put(j+1, true); + } + } //end if (rule contains group reference) + } // end for(group count) + } // end if (member's relationship is HAS) + else{ + System.err.println("Relationship for member " + memberRelationship.getName() + " of "+ mobyDataType + + "is *not* HAS"); + } + } //end for(member replationships) + return newRegexp; + } + + public void addRegexMapping(String regexp, Map nsRules, String mobyDataType, + Map membersMap, String articleName, + String ruleName){ try{ + // Use a StringBuffer so it's mutable by handleHASMembers() + StringBuffer articleNameBuffer = new StringBuffer(articleName == null ? "" : articleName); + regexp = handleHASMembers(regexp, nsRules, mobyDataType, membersMap, articleNameBuffer); + // Pattern.DOTALL to allow ".*" to span multiple lines, also allow comments (# to EOL) and whitespace // for better readability in the rules file. - Pattern pattern = Pattern.compile(processRegExp(regexp), Pattern.DOTALL | Pattern.COMMENTS); + Pattern pattern = Pattern.compile(processRegExp(regexp, membersMap), Pattern.DOTALL | Pattern.COMMENTS); // Base object if(mobyDataType == null || mobyDataType.length() == 0){ regexMap.put(pattern, new MobyComplexBuilder("Object", membersMap, nsRules, - articleName)); - return; + this, + articleNameBuffer.toString())); } - // Complex Object - regexMap.put(pattern, new MobyComplexBuilder(mobyDataType, - membersMap, - nsRules, - articleName)); + else{ + regexMap.put(pattern, new MobyComplexBuilder(mobyDataType, + membersMap, + nsRules, + this, + articleNameBuffer.toString())); + } + + if(ruleName != null && ruleName.length() != 0){ + patternNameMap.put(ruleName, pattern); + builderNameMap.put(ruleName, regexMap.get(pattern)); + } + }catch(Exception e){ System.err.println("Could not create regular expression statement from '" + regexp + "': " + e); @@ -1121,6 +1327,7 @@ urlRegexMap.put(pattern, new MobyComplexBuilder("Object", membersMap, url_nsRules, + this, articleName)); return; } @@ -1129,6 +1336,7 @@ urlRegexMap.put(pattern, new MobyComplexBuilder(mobyDataType, membersMap, url_nsRules, + this, articleName)); }catch(Exception e){ System.err.println("Could not create URL regular expression statement from '" + @@ -1169,6 +1377,7 @@ xpathMap.put(xpath, new MobyComplexBuilder("Object", membersMap, nsRules, + this, articleName)); return; } @@ -1177,6 +1386,7 @@ xpathMap.put(xpath, new MobyComplexBuilder(mobyDataType, membersMap, nsRules, + this, articleName)); }catch(Exception e){ @@ -1286,5 +1496,19 @@ } return true; // be optimistic by default, assume it's alive } + + /** + * If a rule was given this name, the MOBY object builder for the rule is returned. + */ + public MobyComplexBuilder getBuilder(String ruleName){ + return builderNameMap.get(ruleName); + } + + /** + * If a rule was given this name, the regex pattern for the rule is returned. + */ + public Pattern getPattern(String ruleName){ + return patternNameMap.get(ruleName); + } } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyComplexBuilder.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyComplexBuilder.java 2007/06/16 00:28:11 1.9 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyComplexBuilder.java 2007/06/28 16:45:44 1.10 @@ -12,9 +12,8 @@ import javax.xml.parsers.*; import javax.xml.namespace.NamespaceContext; -import java.util.Iterator; -import java.util.Map; -import java.util.regex.Matcher; +import java.util.*; +import java.util.regex.*; /** * Class used by MobyClient to build the MOBY rule database from a configuration file. @@ -22,6 +21,7 @@ public class MobyComplexBuilder{ public static final String ANON_ARTICLE = "_seahawk_data"; + public static final String INHERITED_MEMBERS_SENTINEL = "_seahawk_member_inheritance"; private static XPathFactory xPathFactory; private static DocumentBuilder docBuilder; @@ -31,6 +31,7 @@ private MobyDataType mobyDataType; private MobyNamespace[] mobyNS; private MobyRelationship[] children; + private MobyClient client; static{ xPathFactory = XPathFactory.newInstance(); @@ -43,11 +44,11 @@ } } - public MobyComplexBuilder(String dataType, Map members, Map nameSpaces) throws Exception{ - this(dataType, members, nameSpaces, ANON_ARTICLE); + public MobyComplexBuilder(String dataType, Map members, Map nameSpaces, MobyClient cl) throws Exception{ + this(dataType, members, nameSpaces, cl, ANON_ARTICLE); } - public MobyComplexBuilder(String dataType, Map members, Map nameSpaces, String articleName) throws Exception{ + public MobyComplexBuilder(String dataType, Map members, Map nameSpaces, MobyClient cl, String articleName) throws Exception{ mobyDataType = MobyDataType.getDataType(dataType, SeahawkOptions.getRegistry()); // Not an existing Ontology data type if(mobyDataType == null){ @@ -56,6 +57,7 @@ articleNameRule = articleName; memberRules = members; + client = cl; if(mobyDataType != null && mobyDataType.getName() != null && !mobyDataType.getName().equals("Object")){ @@ -66,9 +68,21 @@ for(int i = 0; children != null && i < children.length; i++){ String childName = children[i].getName(); if(!memberRules.containsKey(childName)){ - throw new Exception("Ruleset for object " + mobyDataType.getName() + - " does not include a rule for required member " + - children[i]); + // See if there's an inherited member + if(!memberRules.containsKey(INHERITED_MEMBERS_SENTINEL)){ + throw new Exception("Ruleset for object " + mobyDataType.getName() + + " does not include a rule for required member '" + + childName+"'"); + } + String inheritedRuleName = memberRules.get(INHERITED_MEMBERS_SENTINEL)[0]; + MobyComplexBuilder inheritedBuilder = client.getBuilder(inheritedRuleName); + if(inheritedBuilder.getDataType().getChild(childName) == null){ + throw new Exception("Ruleset for object " + mobyDataType.getName() + + " does not include a rule for required member '" + + childName+"', nor does the inherited rule '"+ + inheritedRuleName+"'"); + } + } for(int j = 0; j < ruleNames.length; j++){ if(ruleNames[j] == childName){ @@ -82,11 +96,50 @@ System.err.println("Ignoring member rules for object type " + mobyDataType.getName() + " (not in the MOBY ontology):"); for(int i = 0; i < ruleNames.length; i++){ - if(ruleNames[i] != null){ + if(ruleNames[i] != null && !ruleNames[i].equals(INHERITED_MEMBERS_SENTINEL)){ System.err.println("Extra member: " + ruleNames[i]); } } } + + // Check that any casting done on members of the object is kosher + // (do this now because we now have the data type of the parent object for sure) + for(Map.Entry member: members.entrySet()){ + if(member.getKey().equals(INHERITED_MEMBERS_SENTINEL)){ + continue; + } + String memberDataTypeSetting = member.getValue()[1]; + if(memberDataTypeSetting != null && memberDataTypeSetting.length() > 0){ + MobyRelationship child = mobyDataType.getChild(member.getKey()); + String defaultDataTypeName = child.getDataTypeName(); + MobyDataType castType = MobyDataType.getDataType(memberDataTypeSetting, + SeahawkOptions.getRegistry()); + MobyDataType origType = MobyDataType.getDataType(defaultDataTypeName, + SeahawkOptions.getRegistry()); + if(castType == null){ + System.err.println("Could not find the data type "+memberDataTypeSetting+ + " in the ontology, ignoring the data type cast"+ + " that says it should override " + defaultDataTypeName); + member.getValue()[1] = null; + } + else if(origType == null){ + System.err.println("Could not find the data type "+defaultDataTypeName+ + " in the ontology, ignoring the data type cast" + + " that overrides it to data type (" + memberDataTypeSetting + + "), can't tell if the cast is legal or not)"); + member.getValue()[1] = null; + } + else if(!castType.inheritsFrom(origType)){ + System.err.println("The data type "+memberDataTypeSetting+ + " does not inherit from the member's type in the ontology (" + + defaultDataTypeName+"), ignoring the data type cast"); + member.getValue()[1] = null; + } + else{ + // It's safe it we got this far, leave it as-is + } + } + } } namespaceRules = nameSpaces; @@ -124,7 +177,8 @@ } // Set article name, if available - if(articleNameRule != null && articleNameRule.length() > 0){ + if(articleNameRule != null && articleNameRule.length() > 0 && + !articleNameRule.equals(ANON_ARTICLE)){ mobyObj.setName(evaluateRule(matcher, articleNameRule, MobyClient.WHITESPACE_ATTR_STRIP_FLANKING_VAL, @@ -159,36 +213,194 @@ } } - // Set members if available and required - if(mobyObj instanceof MobyDataComposite){ - if(children != null){ - for(int i = 0; i < children.length; i++){ - String memberName = children[i].getName(); - String[] resultSpec = memberRules.get(memberName); + // Done? + if(!(mobyObj instanceof MobyDataComposite) || children == null){ + return mobyObj; + } + + // There's another rule to populate members from + if(memberRules.containsKey(INHERITED_MEMBERS_SENTINEL)){ + // String[2] = {ruleName, ruleValue} + String[] ruleSpec = memberRules.get(INHERITED_MEMBERS_SENTINEL); + MobyComplexBuilder inheritedBuilder = client.getBuilder(ruleSpec[0]); + String result = evaluateRule(matcher, ruleSpec[1], null, null, data); + Matcher submatcher = client.getPattern(ruleSpec[0]).matcher(result); + if(!submatcher.find()){ + throw new MobyException("Pattern of inherited rule '"+ruleSpec[0]+ + "' does not match data given: " + result); + } + MobyDataObject inheritedResult = inheritedBuilder.apply(submatcher, result.getBytes()); + + // Now copy all the fields from the inheritedResults to our object + if(inheritedResult instanceof MobyDataComposite){ + ((MobyDataComposite) mobyObj).putAll((MobyDataComposite) inheritedResult); + } + } + + // Otherwise set members if available and required + for(int i = 0; i < children.length; i++){ + String memberName = children[i].getName(); + String[] resultSpec = memberRules.get(memberName); + if(resultSpec == null){ + // Must have been populated by the inherited rule? + if(!((MobyDataComposite) mobyObj).containsKey(memberName)){ + throw new MobyException("Member " +memberName+" does not have a rule, nor" + + " was not populated by any inherited rule"); + } + continue; + } - MobyRelationship memberRelationship = mobyDataType.getChild(memberName); - // Is the field a list rather than a single value? If so, - // we will need to reinterpret the member value specification - // as many times as the regex capture group matched... - if(memberRelationship.getRelationshipType() == Central.iHAS){ - + String dataTypeName = children[i].getDataTypeName(); + // First: does the rule cast the object to some subtype? + if(resultSpec[1] != null && resultSpec[1].length() > 0){ + // Safe to cast if we got this far (e.g. put String where an Object is specified) + dataTypeName = resultSpec[1]; + } + + // Is the field a list rather than a single value? If so, + // we will need to reinterpret the member value specification + // as many times as the regex capture group matched... + String[] results = new String[1]; + if(children[i].getRelationshipType() == Central.iHAS){ + // We need to reconstruct the capture group so that we + // can save each value, not just its last one. + try{ + // results may be more than one element in this case + results = evaluateIterativeRule(matcher, resultSpec[0], resultSpec[2], resultSpec[3], data); + } catch(Exception e){ + e.printStackTrace(); + throw new MobyException("Error while evaluating HAS (iterative evaluation) rule: " + e); + } + } + // else is iHASA, scalar context + else{ + // only one result to process and add the to object + results[0] = evaluateRule(matcher, resultSpec[0], resultSpec[2], resultSpec[3], data); + } + + for(String result: results){ + + if(PrimitiveTypes.isPrimitive(dataTypeName)){ + ((MobyDataComposite) mobyObj).put(memberName, + MobyDataObject.createInstanceFromString(dataTypeName, result)); + } + else{ + // Recursively call the object creator for complex members + + // Fetch the member's MobyComplexBuilder by name from the rule spec + String memberRuleName = resultSpec[4]; + if(memberRuleName == null || memberRuleName.length() == 0){ + throw new MobyException("Composite member "+memberName+ + " does not have an associated rule to produce it"); + } + MobyComplexBuilder memberBuilder = client.getBuilder(memberRuleName); + if(memberBuilder == null){ + throw new MobyException("The object builder for the rule " + memberRuleName + + " could not be found"); + } + Pattern memberPattern = client.getPattern(memberRuleName); + + // Now apply the regex for the capture group, so we can use + // the results in a recursive call to this method (stop condition + // is when all members are primitives). + Matcher memberMatcher = memberPattern.matcher(result); + + if(memberMatcher.find()){ + ((MobyDataComposite) mobyObj).put(memberName, + memberBuilder.apply(memberMatcher)); } - // else is iHASA, scalar context else{ - String result = evaluateRule(matcher, resultSpec[0], resultSpec[1], resultSpec[2], data); - - ((MobyDataComposite) mobyObj).put(memberName, - MobyDataObject.createInstanceFromString(children[i].getDataTypeName(), result)); + System.err.println("Could not match pattern \"" + memberPattern.pattern() + + "\" to string \"" + result + "\", abandoning " + + dataTypeName + " object creation"); } } + } //end for results + } //end for children + + return mobyObj; + } + + /** + * @return a list of rule values to interpret + */ + public String[] evaluateIterativeRule(Matcher matcher, String result, String whitespaceMode, String encodingMode, byte[] data) + throws MobyException, Exception{ + Vector capturedValues = new Vector(); + + // Figure out which capture group needs to be evaluated iteratively + Vector captureGroups = new Vector(); + // This only really works with 10 capture groups or less, otherwise $1 and $10 can get captured, etc. + for(int captureGroup = 1; captureGroup <= matcher.groupCount(); captureGroup++){ + if(result.indexOf("$"+captureGroup) != -1){ + //System.err.println("Adding capture group " + captureGroup + + // " to evaluation list due to its presence in rule " + result); + captureGroups.add(captureGroup); } } + // No capture group found, so just return single evaluation on whole expression (may use $0) + if(captureGroups.isEmpty()){ + return new String[]{evaluateRule(matcher, result, whitespaceMode, encodingMode, data)}; + } + + // Pull out the capture group's pattern, by counting parentheses + Map captureGroupRegexes = new HashMap(); + for(Integer captureGroup: captureGroups){ + captureGroupRegexes.put(captureGroup.intValue(), + RegexParser.getCaptureGroupRegex(matcher.pattern(), + captureGroup.intValue())); + } + + // Find all instances of the capture group, save their value + Map captureGroupSubvalues = new HashMap(); + for(Map.Entry entry: captureGroupRegexes.entrySet()){ + // Why fetch cap group # -1? Because we auto-encapsulated the cap groups the HAS member + // refers to, specifically so we get the whole match for processing, rather than just + // the last one, i.e. (\d)+ in a regex rule became ((\d)+) in MobyClient so we can + // find each \d in the whole match and add them indidivually as HAS (0 or more) members + // in the object instance. + String wholeMatch = matcher.group(entry.getKey().intValue()-1); + String regex = entry.getValue(); + if(regex.length() == 0){ + throw new Exception("Encountered empty regex in capture group " + entry.getKey()); + } + //System.err.println("Applying regex "+regex+" to "+wholeMatch+", whole pattern was "+matcher.pattern().pattern()); + // If the pattern matches more than once, the matches must be contiguous, hence the \G + Pattern captureGroupPattern = Pattern.compile("\\G"+regex, + Pattern.DOTALL | Pattern.COMMENTS); + Vector subValues = new Vector(); + Matcher subMatcher = captureGroupPattern.matcher(wholeMatch); + int lastSubMatcherEnd = -1; + while(subMatcher.find()){ + subValues.add(subMatcher.group()); + lastSubMatcherEnd = subMatcher.end(); + } - return mobyObj; + // For safety, we should do a sanity check that there's + // is no unmatched input left over, as we'd expect + if(lastSubMatcherEnd != -1 && lastSubMatcherEnd != wholeMatch.length()){ + throw new Exception("The submatcher for capture group "+entry.getKey()+ + " did not match to the last char of \"" + wholeMatch + + "\", should have ended match at index " + (wholeMatch.length()-1) + + ", but instead matched until " + (lastSubMatcherEnd-1)); + } + captureGroupSubvalues.put(entry.getKey().intValue(), + (String[]) subValues.toArray(new String[subValues.size()])); + } + + // Now, iteratively substitute each subvalue from each capture group into the rules + IterativeMatchResult iterMatch = new IterativeMatchResult(matcher, captureGroupSubvalues); + for(int i = 0; i < iterMatch.getNumIterations(); i++){ + iterMatch.setIteration(i); + capturedValues.add(evaluateRule(iterMatch, result, whitespaceMode, encodingMode, data)); + } + + // Return all the values we found + return (String[]) capturedValues.toArray(new String[capturedValues.size()]); } // takes a rule and evaluates $# variables and XPath expressions - private String evaluateRule(Matcher matcher, String result, String whitespaceMode, String encodingMode, byte[] data) + private String evaluateRule(MatchResult match, String result, String whitespaceMode, String encodingMode, byte[] data) throws MobyException{ byte[] resultBytes = result.getBytes(); boolean nonBasic = result.length() != 2 || result.indexOf("$") != 0; @@ -202,24 +414,24 @@ doc = docBuilder.newDocument(); } - // Replace any $0, $1, etc. in the replacement string with the values found in the matcher + // Replace any $0, $1, etc. in the replacement string with the values found in the match // Note that this is not perfect: if you had "$1 $2", and $1 had value "$250", you'd get $250$2, // then you'd substitute $2's value of "per metre", you'd get "per metre50 per metre" instead of // "$250 per metre". Not sure of a good way around this yet (i.e. when varValue had $k in it where k > j)... - for(int j = 0; j <= matcher.groupCount(); j++){ + for(int j = 0; j <= match.groupCount(); j++){ // A replaceAll() for binary data if(data != null && isBinary){ int srcPos = 0; for(int varIndex = result.indexOf("$"+j, srcPos); varIndex != -1; varIndex = result.indexOf("$"+j, srcPos)){ - int varValueLength = matcher.end(j)-matcher.start(j); + int varValueLength = match.end(j)-match.start(j); int varLen = ("$"+j).getBytes().length; byte[] newResultBytes = new byte[resultBytes.length+varValueLength-varLen]; if(varIndex > 0){ System.arraycopy(resultBytes, 0, newResultBytes, 0, varIndex); } - System.arraycopy(data, matcher.start(j), newResultBytes, varIndex, varValueLength); + System.arraycopy(data, match.start(j), newResultBytes, varIndex, varValueLength); int remaining = result.length()-varIndex-varLen; if(remaining > 0){ System.arraycopy(resultBytes, varIndex+varLen, newResultBytes, varIndex+varValueLength, @@ -230,8 +442,8 @@ } } // $# substitution in a string, considerably simpler! - else{ - String varValue = matcher.group(j); + else if(result.matches("^\\$"+j+"(?=\\D.*|\\z)")){ + String varValue = match.group(j); if(whitespaceMode == null){ // do nothing } @@ -244,7 +456,7 @@ else if(whitespaceMode.equals(MobyClient.WHITESPACE_ATTR_STRIP_FLANKING_VAL)){ varValue = varValue.trim(); // removes leading and trailing whitespace } - result = result.replaceAll("\\$"+j, varValue); + result = result.replaceAll("\\$"+j+"(?=\\D|\\z)", varValue); // Binary data and XPath are incompatible, since many bytes are not allowed in XML // so only create the node list if not Base64 encoding From gordonp at dev.open-bio.org Thu Jun 28 16:47:24 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 28 Jun 2007 12:47:24 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706281647.l5SGlNAT004587@dev.open-bio.org> gordonp Thu Jun 28 12:47:23 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/test In directory dev.open-bio.org:/tmp/cvs-serv4556/src/main/ca/ucalgary/seahawk/services/test Added Files: MobyClientTestCase.java RegexParserTestCase.java embossChargeOutput.txt mobyRules1.xml mobyRules2.xml mobyRules3.xml Log Message: Test suite for the MOB rule classes moby-live/Java/src/main/ca/ucalgary/seahawk/services/test MobyClientTestCase.java,NONE,1.1 RegexParserTestCase.java,NONE,1.1 embossChargeOutput.txt,NONE,1.1 mobyRules1.xml,NONE,1.1 mobyRules2.xml,NONE,1.1 mobyRules3.xml,NONE,1.1 From gordonp at dev.open-bio.org Sat Jun 30 22:21:57 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Sat, 30 Jun 2007 18:21:57 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200706302221.l5UMLvZc013734@dev.open-bio.org> gordonp Sat Jun 30 18:21:57 EDT 2007 Update of /home/repository/moby/moby-live/Java/docs In directory dev.open-bio.org:/tmp/cvs-serv13699 Modified Files: Seahawk.html Log Message: Added journal article reference moby-live/Java/docs Seahawk.html,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Java/docs/Seahawk.html,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Java/docs/Seahawk.html 2007/06/21 18:33:43 1.7 +++ /home/repository/moby/moby-live/Java/docs/Seahawk.html 2007/06/30 22:21:56 1.8 @@ -11,6 +11,11 @@

      What is Seahawk?

      + While this page links to many extra technical details, the definitive + reference for an explanation of Seahawk and its features is: +

      Gordon P.M.K., Sensen C.W. (2007) Seahawk: Moving Beyond HTML in Web-based Bioinformatics Analysis. BMC Bioinformatics 8:208. Medline
      + Seahawk is a Java applet (or application component) that allows a naïve user to:
      1. Load text, HTML, Rich Text, or MOBY XML files from their local disk or a Web site
      2. @@ -30,11 +35,11 @@

        What is not?

        - Seahawk is not a visual programming environment for workflows. For that kind of functionality, please see - Taverna, or + Seahawk is not a visual programming environment for workflows, but rather allows workflow + construction by example (as opposed to Taverna or Remora. It is not for deploying services or seeing the guts of MOBY Objects - and service calls: please see Dashboard. + and service calls: for this please see Dashboard.

        Sections

        From gordonp at dev.open-bio.org Thu Jun 7 23:58:16 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 07 Jun 2007 23:58:16 -0000 Subject: [MOBY-guts] biomoby commit Message-ID: <200706072358.l57NwF5C025578@dev.open-bio.org> gordonp Thu Jun 7 19:58:15 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data In directory dev.open-bio.org:/tmp/cvs-serv25503/src/main/org/biomoby/shared/data Modified Files: MobyContentInstance.java MobyDataBoolean.java MobyDataBytes.java MobyDataComposite.java MobyDataDateTime.java MobyDataFloat.java MobyDataInt.java MobyDataObject.java MobyDataObjectSet.java MobyDataString.java MobyDataUtils.java Log Message: Updates to deal with fact that more than one registry can be used as the source of type information moby-live/Java/src/main/org/biomoby/shared/data MobyContentInstance.java,1.11,1.12 MobyDataBoolean.java,1.3,1.4 MobyDataBytes.java,1.6,1.7 MobyDataComposite.java,1.14,1.15 MobyDataDateTime.java,1.8,1.9 MobyDataFloat.java,1.6,1.7 MobyDataInt.java,1.5,1.6 MobyDataObject.java,1.15,1.16 MobyDataObjectSet.java,1.7,1.8 MobyDataString.java,1.5,1.6 MobyDataUtils.java,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyContentInstance.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyContentInstance.java 2007/05/30 17:44:19 1.11 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyContentInstance.java 2007/06/07 23:58:15 1.12 @@ -1,5 +1,6 @@ package org.biomoby.shared.data; +import org.biomoby.registry.meta.Registry; import org.biomoby.shared.*; import org.biomoby.shared.parser.MobyTags; import org.biomoby.shared.parser.ServiceException; @@ -80,6 +81,10 @@ * interface methods, with queryID as key, and MobyDataInstance Vectors (mobyData) as values. */ public MobyContentInstance(Element objectTag) throws MobyException{ + this(objectTag, null); + } + + public MobyContentInstance(Element objectTag, Registry registry) throws MobyException{ this(); if(!MobyTags.MOBYCONTENT.equals(objectTag.getLocalName())){ throw new MobyException("The content element provided (" + @@ -122,7 +127,7 @@ System.err.println("Warning: found null element in DOM results (very strange)"); continue; } - parseDataGroup(dataGroup); + parseDataGroup(dataGroup, registry); } // If we got to this stage, we're okay in the sytax department. @@ -185,7 +190,7 @@ debugPS = ps; } - public void parseDataGroup(Element dataGroupTag) throws MobyException{ + public void parseDataGroup(Element dataGroupTag, Registry registry) throws MobyException{ String groupID = null; MobyDataJob job = new MobyDataJob(); @@ -213,7 +218,7 @@ " collections in response " + groupID); } Element collectionTag = (Element) collections.item(j); - MobyDataObjectSet collection = (MobyDataObjectSet) (MobyDataObject.createInstanceFromDOM(collectionTag)); + MobyDataObjectSet collection = (MobyDataObjectSet) (MobyDataObject.createInstanceFromDOM(collectionTag, registry)); // Add completed collection to the output list job.put(collection.getName(), collection); @@ -237,11 +242,11 @@ throw new MobyException("Illegal XML: there is more than one tag in the response " + groupID + " with the articleName " + name); } - job.put(name, MobyDataObject.createInstanceFromDOM((Element) simples.item(j))); + job.put(name, MobyDataObject.createInstanceFromDOM((Element) simples.item(j), registry)); } // No anonymous data member yet else if(!job.containsKey("")){ - job.put("", MobyDataObject.createInstanceFromDOM((Element) simples.item(j))); + job.put("", MobyDataObject.createInstanceFromDOM((Element) simples.item(j), registry)); } else{ debugPS.println("More than one anonymous member, ignoring simple #" + j); =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataBoolean.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataBoolean.java 2006/07/07 04:12:40 1.3 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataBoolean.java 2007/06/07 23:58:15 1.4 @@ -1,7 +1,10 @@ package org.biomoby.shared.data; + +import org.biomoby.registry.meta.Registry; import org.biomoby.shared.MobyDataType; import org.biomoby.shared.MobyNamespace; +import org.biomoby.shared.parser.MobyTags; /** * A class representing a MOBY Boolean primitive. @@ -21,7 +24,11 @@ * @throws IllegalArgumentException if the element is not a String tag */ public MobyDataBoolean(org.w3c.dom.Element element) throws IllegalArgumentException{ - this(getName(element), getTextContents(element)); + this(element, null); + } + + public MobyDataBoolean(org.w3c.dom.Element element, Registry registry) throws IllegalArgumentException{ + this(getName(element), getTextContents(element), registry); setId(getId(element)); addNamespace(getNamespace(element)); } @@ -31,13 +38,22 @@ * (i.e. String, StringBuffer, CharBuffer or StringBuilder). */ public MobyDataBoolean(String articleName, Boolean b){ + this(articleName, b, null); + } + + /** Every c-tor eventually winds up here */ + public MobyDataBoolean(String articleName, Boolean b, Registry registry){ super(articleName); - setDataType(MobyDataType.getDataType("Boolean")); + setDataType(MobyDataType.getDataType(MobyTags.MOBYBOOLEAN, registry)); value = b; } public MobyDataBoolean(String articleName, boolean b){ - this(articleName, Boolean.valueOf(b)); + this(articleName, Boolean.valueOf(b), null); + } + + public MobyDataBoolean(String articleName, boolean b, Registry registry){ + this(articleName, Boolean.valueOf(b), registry); } /** @@ -46,21 +62,37 @@ * "Yes" and "1" are not acceptable. */ public MobyDataBoolean(String articleName, String booleanString){ - this(articleName, Boolean.valueOf(booleanString)); + this(articleName, Boolean.valueOf(booleanString), null); + } + + public MobyDataBoolean(String articleName, String booleanString, Registry registry){ + this(articleName, Boolean.valueOf(booleanString), registry); } public MobyDataBoolean(Boolean b){ this("", b); } + public MobyDataBoolean(Boolean b, Registry r){ + this("", b, r); + } + public MobyDataBoolean(boolean b){ this("", b); } + public MobyDataBoolean(boolean b, Registry r){ + this("", b, r); + } + public MobyDataBoolean(String booleanString){ this("", booleanString); } + public MobyDataBoolean(String booleanString, Registry r){ + this("", booleanString, r); + } + public String toString(){ return value.toString(); } @@ -117,7 +149,7 @@ public String toXML(){ MobyNamespace[] ns = getNamespaces(); if(xmlMode == MobyDataInstance.SERVICE_XML_MODE){ - return "" + value + ""; + return "<"+MobyTags.MOBYBOOLEAN+" "+ getAttrXML() + ">" + value + ""; } // Central mode, use default toXML provided by superclasses else{ =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataBytes.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataBytes.java 2007/04/13 01:55:36 1.6 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataBytes.java 2007/06/07 23:58:15 1.7 @@ -1,6 +1,7 @@ package org.biomoby.shared.data; +import org.biomoby.registry.meta.Registry; import org.biomoby.shared.MobyDataType; import org.biomoby.shared.MobyException; import java.io.*; @@ -34,12 +35,16 @@ * @throws IllegalArgumentException if the element is not a text-base64 tag, or doesn't inherit from it */ public MobyDataBytes(org.w3c.dom.Element element) throws MobyException{ - super(MobyDataType.getDataType(BASE64_DATATYPE), getName(element)); + this(element, null); + } + + public MobyDataBytes(org.w3c.dom.Element element, Registry registry) throws MobyException{ + super(MobyDataType.getDataType(BASE64_DATATYPE, registry), getName(element)); setId(getId(element)); addNamespace(getNamespace(element)); - MobyDataType inputDataType = MobyDataType.getDataType(element.getLocalName()); - if(!inputDataType.inheritsFrom(MobyDataType.getDataType(BASE64_DATATYPE))){ + MobyDataType inputDataType = MobyDataType.getDataType(element.getLocalName(), registry); + if(!inputDataType.inheritsFrom(MobyDataType.getDataType(BASE64_DATATYPE, registry))){ throw new MobyException("The given tag ("+ element.getLocalName() + ") does not inherit from " + BASE64_DATATYPE + " in the MOBY Object Class Ontology, cannot " + @@ -49,7 +54,7 @@ // Now, we know we have one field that represents the bytes, // and there may be others which we will treat as regular composite members - populateMembersFromDOM(element); + populateMembersFromDOM(element, registry); MobyDataObject contents = get(ENCODED_MEMBER_NAME); if(contents == null){ @@ -73,7 +78,11 @@ * @throws MobyException if the data provided is null, or could not be encoded(?!) */ public MobyDataBytes(String name, byte[] data) throws MobyException{ - super(MobyDataType.getDataType(BASE64_DATATYPE), name); + this(name, data, (Registry) null); + } + + public MobyDataBytes(String name, byte[] data, Registry registry) throws MobyException{ + super(MobyDataType.getDataType(BASE64_DATATYPE, registry), name); storeBytes(data); } @@ -82,7 +91,7 @@ */ public MobyDataBytes(String name, byte[] data, MobyDataType inputDataType) throws MobyException{ this(name, data); - if(!inputDataType.inheritsFrom(MobyDataType.getDataType(BASE64_DATATYPE))){ + if(!inputDataType.inheritsFrom(MobyDataType.getDataType(BASE64_DATATYPE, inputDataType.getRegistry()))){ throw new MobyException("The given data type ("+ inputDataType.getName() + ") does not inherit from " + BASE64_DATATYPE + " in the MOBY Object Class Ontology, cannot " + @@ -97,10 +106,14 @@ * Currently Base64 encoding is acceptable, UU Decoding has yet to be implemented.. */ public MobyDataBytes(String name, CharSequence data){ - super(MobyDataType.getDataType(BASE64_DATATYPE), name); - setDataType(MobyDataType.getDataType(BASE64_DATATYPE)); + this(name, data, (Registry) null); + } + + public MobyDataBytes(String name, CharSequence data, Registry registry){ + super(MobyDataType.getDataType(BASE64_DATATYPE, registry), name); + setDataType(MobyDataType.getDataType(BASE64_DATATYPE, registry)); // TODO: add check that the data is valid Base64 format! - put(ENCODED_MEMBER_NAME, new MobyDataString(ENCODED_MEMBER_NAME, data)); + put(ENCODED_MEMBER_NAME, new MobyDataString(ENCODED_MEMBER_NAME, data, registry)); } /** @@ -110,7 +123,7 @@ */ public MobyDataBytes(String name, CharSequence data, MobyDataType inputDataType) throws MobyException{ this(name, data); - if(!inputDataType.inheritsFrom(MobyDataType.getDataType(BASE64_DATATYPE))){ + if(!inputDataType.inheritsFrom(MobyDataType.getDataType(BASE64_DATATYPE, inputDataType.getRegistry()))){ throw new MobyException("The given data type ("+ inputDataType.getName() + ") does not inherit from " + BASE64_DATATYPE + " in the MOBY Object Class Ontology, cannot " + @@ -125,7 +138,11 @@ * @param resourceURL the URL of the resource to encode, such as "file:..." or "http:..." */ public MobyDataBytes(String name, java.net.URL resourceURL) throws MobyException, IOException{ - super(MobyDataType.getDataType(BASE64_DATATYPE), name); + this(name, resourceURL, (Registry) null); + } + + public MobyDataBytes(String name, java.net.URL resourceURL, Registry registry) throws MobyException, IOException{ + super(MobyDataType.getDataType(BASE64_DATATYPE, registry), name); if(resourceURL == null){ return; } @@ -151,7 +168,7 @@ */ public MobyDataBytes(String name, java.net.URL resourceURL, MobyDataType inputDataType) throws IOException, MobyException{ this(name, resourceURL); - if(!inputDataType.inheritsFrom(MobyDataType.getDataType(BASE64_DATATYPE))){ + if(!inputDataType.inheritsFrom(MobyDataType.getDataType(BASE64_DATATYPE, inputDataType.getRegistry()))){ throw new MobyException("The given data type ("+ inputDataType.getName() + ") does not inherit from " + BASE64_DATATYPE + " in the MOBY Object Class Ontology, cannot " + =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataComposite.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataComposite.java 2007/04/13 01:56:12 1.14 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataComposite.java 2007/06/07 23:58:15 1.15 @@ -9,12 +9,8 @@ import java.util.Set; import java.util.Vector; -import org.biomoby.shared.Central; -import org.biomoby.shared.MobyDataType; -import org.biomoby.shared.MobyException; -import org.biomoby.shared.MobyNamespace; -import org.biomoby.shared.MobyPrefixResolver; -import org.biomoby.shared.MobyRelationship; +import org.biomoby.registry.meta.Registry; +import org.biomoby.shared.*; import org.biomoby.shared.parser.MobyTags; /** @@ -32,12 +28,19 @@ * @throws MobyException if the element is not a MobyObject tag */ public MobyDataComposite(org.w3c.dom.Element element) throws MobyException{ - this(MobyDataType.getDataType(element.getLocalName()), getName(element), getNamespace(element), getId(element)); + this(element, null); + } + + public MobyDataComposite(org.w3c.dom.Element element, Registry registry) throws MobyException{ + this(MobyDataType.getDataType(element.getLocalName(), registry), + getName(element), + getNamespace(element), + getId(element)); - populateMembersFromDOM(element); + populateMembersFromDOM(element, registry); } - protected void populateMembersFromDOM(org.w3c.dom.Element element) throws MobyException{ + protected void populateMembersFromDOM(org.w3c.dom.Element element, Registry registry) throws MobyException{ // Decompose the children org.w3c.dom.NodeList substructures = MobyPrefixResolver.getChildElements(element, "*"); //wildcard int numSubstructures = substructures.getLength(); @@ -87,9 +90,13 @@ * ontology, otherwise the datatype will be null. */ public MobyDataComposite(String typeName, String name, String namespace, String id){ + this(typeName, name, namespace, id, (Registry) null); + } + + public MobyDataComposite(String typeName, String name, String namespace, String id, Registry registry){ super(namespace, id); setName(name); - setDataType(MobyDataType.getDataType(typeName)); + setDataType(MobyDataType.getDataType(typeName, registry)); members = new ConcurrentHashMap(); } @@ -111,7 +118,7 @@ setDataType(type); members = new ConcurrentHashMap(); - MobyDataType dt = MobyDataType.getDataType(type.getName()); + MobyDataType dt = MobyDataType.getDataType(type.getName(), type.getRegistry()); MobyRelationship[] children = dt.getAllChildren(); // If one arg, resolve it's name, set it, and we're done @@ -201,7 +208,11 @@ } public MobyDataComposite(String typeName, String name){ - this(MobyDataType.getDataType(typeName), name); + this(typeName, name, (Registry) null); + } + + public MobyDataComposite(String typeName, String name, Registry r){ + this(MobyDataType.getDataType(typeName, r), name); } public MobyDataComposite(MobyDataType type){ @@ -209,7 +220,11 @@ } public MobyDataComposite(String typeName){ - this(MobyDataType.getDataType(typeName)); + this(typeName, (Registry) null); + } + + public MobyDataComposite(String typeName, Registry r){ + this(MobyDataType.getDataType(typeName, r)); } public Object clone(){ @@ -394,7 +409,7 @@ MobyRelationship relationship = getDataType().getChild(fieldName); if(relationship == null){ - relationship = MobyDataType.getDataType(getDataType().getName()).getChild(fieldName); + relationship = MobyDataType.getDataType(getDataType().getName(), getDataType().getRegistry()).getChild(fieldName); if(relationship == null){ String memberNames = ""; for(MobyRelationship rel: getDataType().getChildren()){ @@ -405,7 +420,7 @@ getDataType().getName() + ", valid member names are:" + memberNames); } } - MobyDataType childDataType = MobyDataType.getDataType(relationship.getDataTypeName()); + MobyDataType childDataType = MobyDataType.getDataType(relationship.getDataTypeName(), getDataType().getRegistry()); if(!value.getDataType().inheritsFrom(childDataType)){ // Incompatible types throw new IllegalArgumentException("The member '" + fieldName + "' for object '"+ getName() + =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataDateTime.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataDateTime.java 2007/05/29 23:49:32 1.8 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataDateTime.java 2007/06/07 23:58:15 1.9 @@ -1,13 +1,12 @@ - package org.biomoby.shared.data; + +import org.biomoby.registry.meta.Registry; import org.biomoby.shared.MobyDataType; +import org.biomoby.shared.parser.MobyTags; + import java.text.DecimalFormat; import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.GregorianCalendar; -import java.util.NoSuchElementException; -import java.util.StringTokenizer; -import java.util.TimeZone; +import java.util.*; /** * A class representing a MOBY DateTime, which is a primitive in MOBY. @@ -36,7 +35,11 @@ * @throws IllegalArgumentException if the element is not a DateTime tag, or the text children of the element do not encode a valid ISO8601 date/time */ public MobyDataDateTime(org.w3c.dom.Element element) throws IllegalArgumentException{ - this(getName(element), getTextContents(element)); + this(element, null); + } + + public MobyDataDateTime(org.w3c.dom.Element element, Registry registry) throws IllegalArgumentException{ + this(getName(element), getTextContents(element), registry); setId(getId(element)); addNamespace(getNamespace(element)); } @@ -46,8 +49,12 @@ * @param stringISO8601 if null, the current local date and time is used */ public MobyDataDateTime(String articleName, String stringISO8601) throws IllegalArgumentException{ + this(articleName, stringISO8601, null); + } + + public MobyDataDateTime(String articleName, String stringISO8601, Registry registry) throws IllegalArgumentException{ super(articleName); - setDataType(MobyDataType.getDataType("DateTime")); + setDataType(MobyDataType.getDataType(MobyTags.MOBYDATETIME, registry)); value = parseISO8601(stringISO8601); } @@ -56,8 +63,12 @@ } public MobyDataDateTime(String articleName, GregorianCalendar cal){ + this(articleName, cal, (Registry) null); + } + + public MobyDataDateTime(String articleName, GregorianCalendar cal, Registry registry){ super(articleName, ""); - setDataType(MobyDataType.getDataType("DateTime")); + setDataType(MobyDataType.getDataType(MobyTags.MOBYDATETIME, registry)); value = cal; } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataFloat.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataFloat.java 2006/07/07 04:12:40 1.6 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataFloat.java 2007/06/07 23:58:15 1.7 @@ -3,8 +3,10 @@ import java.math.BigDecimal; import java.math.BigInteger; +import org.biomoby.registry.meta.Registry; import org.biomoby.shared.MobyDataType; import org.biomoby.shared.MobyNamespace; +import org.biomoby.shared.parser.MobyTags; /** * A class representing a MOBY Float primitive. Note that the @@ -26,7 +28,11 @@ * @throws IllegalArgumentException if the element is not a Float tag */ public MobyDataFloat(org.w3c.dom.Element element) throws IllegalArgumentException{ - this(getName(element), getTextContents(element)); + this(element, null); + } + + public MobyDataFloat(org.w3c.dom.Element element, Registry registry) throws IllegalArgumentException{ + this(getName(element), getTextContents(element), registry); setId(getId(element)); addNamespace(getNamespace(element)); } @@ -36,8 +42,12 @@ * Float, Double, Integer, BigDecimal, etc. */ public MobyDataFloat(String articleName, Number n){ + this(articleName, n, null); + } + + public MobyDataFloat(String articleName, Number n, Registry r){ super(articleName); - setDataType(MobyDataType.getDataType("Float")); + setDataType(MobyDataType.getDataType(MobyTags.MOBYFLOAT, r)); if(n instanceof BigDecimal){ value = (BigDecimal) n; } @@ -49,8 +59,12 @@ } } + public MobyDataFloat(Number n, Registry r){ + this("", n, r); + } + public MobyDataFloat(Number n){ - this("", n); + this("", n, null); } /** @@ -58,13 +72,21 @@ * If you want to pass in a float or int, cast it to a double. */ public MobyDataFloat(String articleName, double d){ + this(articleName, d, null); + } + + public MobyDataFloat(String articleName, double d, Registry registry){ super(articleName); - setDataType(MobyDataType.getDataType("Float")); + setDataType(MobyDataType.getDataType(MobyTags.MOBYFLOAT, registry)); value = new BigDecimal(d); } + public MobyDataFloat(double d, Registry r){ + this("", d, r); + } + public MobyDataFloat(double d){ - this("", d); + this("", d, null); } /** @@ -74,13 +96,21 @@ * @throws NumberFormatException if the string does not represent a number */ public MobyDataFloat(String articleName, String stringNumber) throws NumberFormatException{ + this(articleName, stringNumber, null); + } + + public MobyDataFloat(String articleName, String stringNumber, Registry registry) throws NumberFormatException{ super(articleName); - setDataType(MobyDataType.getDataType("Float")); + setDataType(MobyDataType.getDataType(MobyTags.MOBYFLOAT, registry)); value = new BigDecimal(stringNumber); } public MobyDataFloat(String stringNumber){ - this("", stringNumber); + this("", stringNumber, null); + } + + public MobyDataFloat(String stringNumber, Registry registry){ + this("", stringNumber, registry); } public Object clone(){ @@ -315,7 +345,8 @@ public String toXML(){ MobyNamespace[] ns = getNamespaces(); if(xmlMode == MobyDataInstance.SERVICE_XML_MODE){ - return "" + value.toString() + ""; + return "<" + MobyTags.MOBYFLOAT + " " + getAttrXML() + ">" + + value.toString() + ""; } else{ return super.toXML(); =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataInt.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataInt.java 2006/07/07 04:12:40 1.5 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataInt.java 2007/06/07 23:58:15 1.6 @@ -1,7 +1,8 @@ - package org.biomoby.shared.data; +import org.biomoby.registry.meta.Registry; import org.biomoby.shared.MobyDataType; +import org.biomoby.shared.parser.MobyTags; import java.math.BigDecimal; import java.math.BigInteger; @@ -26,7 +27,11 @@ * @throws IllegalArgumentException if the element is not a Integer tag */ public MobyDataInt(org.w3c.dom.Element element) throws IllegalArgumentException{ - this(getName(element), getTextContents(element)); + this(element, null); + } + + public MobyDataInt(org.w3c.dom.Element element, Registry registry) throws IllegalArgumentException{ + this(getName(element), getTextContents(element), registry); setId(getId(element)); addNamespace(getNamespace(element)); } @@ -37,8 +42,12 @@ * Real numbers will be converted to their integer equivalents. */ public MobyDataInt(String articleName, Number n){ + this(articleName, n, null); + } + + public MobyDataInt(String articleName, Number n, Registry registry){ super(articleName); - setDataType(MobyDataType.getDataType("Integer")); + setDataType(MobyDataType.getDataType(MobyTags.MOBYINTEGER, registry)); if(n instanceof BigInteger){ value = (BigInteger) n; } @@ -51,7 +60,11 @@ } public MobyDataInt(Number n){ - this("", n); + this("", n, null); + } + + public MobyDataInt(Number n, Registry r){ + this("", n, r); } /** @@ -59,8 +72,12 @@ * If you want to pass in a float or double, cast it to an int. */ public MobyDataInt(String articleName, int i){ + this(articleName, i, null); + } + + public MobyDataInt(String articleName, int i, Registry registry){ super(articleName); - setDataType(MobyDataType.getDataType("Integer")); + setDataType(MobyDataType.getDataType(MobyTags.MOBYINTEGER, registry)); value = new BigInteger(""+i); } @@ -74,8 +91,12 @@ * @throws NumberFormatException if the string does not represent an integer number */ public MobyDataInt(String articleName, String stringNumber) throws NumberFormatException{ + this(articleName, stringNumber, null); + } + + public MobyDataInt(String articleName, String stringNumber, Registry registry) throws NumberFormatException{ super(articleName); - setDataType(MobyDataType.getDataType("Integer")); + setDataType(MobyDataType.getDataType(MobyTags.MOBYINTEGER, registry)); value = new BigInteger(stringNumber); } @@ -273,7 +294,8 @@ public String toXML(){ if(xmlMode == MobyDataInstance.SERVICE_XML_MODE){ - return "" + value.toString() + ""; + return "<" + MobyTags.MOBYINTEGER + " " + getAttrXML() + ">" + + value.toString() + ""; } else{ return super.toXML(); =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObject.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObject.java 2007/04/27 13:45:29 1.15 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObject.java 2007/06/07 23:58:15 1.16 @@ -16,6 +16,7 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; +import org.biomoby.registry.meta.Registry; import org.biomoby.shared.*; import org.biomoby.shared.parser.MobyTags; @@ -44,7 +45,11 @@ * @throws MobyException if the element is not an Object tag, or is missing a required attribute */ public MobyDataObject(Element element) throws MobyException{ - this(getNamespace(element).getName(), getId(element)); + this(element, null); + } + + public MobyDataObject(Element element, Registry registry) throws MobyException{ + this(getNamespace(element).getName(), getId(element), registry); setName(getName(element)); } @@ -53,16 +58,24 @@ * Instance information can be filled out later with setId() and setNamespace(). */ public MobyDataObject(String name){ + this(name, (Registry) null); + } + + public MobyDataObject(String name, Registry registry){ super(name); - setDataType(MobyDataType.getDataType(MobyTags.MOBYOBJECT)); + setDataType(MobyDataType.getDataType(MobyTags.MOBYOBJECT, registry)); } /** * Constructor convenient for a base object with a namespace and ID. */ public MobyDataObject(String namespace, String id){ + this(namespace, id, null); + } + + public MobyDataObject(String namespace, String id, Registry registry){ super(""); - setDataType(MobyDataType.getDataType(MobyTags.MOBYOBJECT)); + setDataType(MobyDataType.getDataType(MobyTags.MOBYOBJECT, registry)); setId(id); MobyNamespace nsObj = MobyNamespace.getNamespace(namespace); @@ -91,30 +104,34 @@ * @throws MobyException if the requested datatype is not a primtive, or the value could not be used for that data type (e.g an integer out of the string "Bar") */ public static MobyDataObject createInstanceFromString(String typeName, String value) throws MobyException{ + return createInstanceFromString(typeName, value, null); + } + + public static MobyDataObject createInstanceFromString(String typeName, String value, Registry registry) throws MobyException{ if(typeName == null){ return null; } if(MobyTags.MOBYOBJECT.equals(typeName)){ - return new MobyDataObject("", value); + return new MobyDataObject("", value, registry); } else if(MobyTags.MOBYINTEGER.equals(typeName)){ - return new MobyDataInt("", value); + return new MobyDataInt("", value, registry); } else if(MobyTags.MOBYFLOAT.equals(typeName)){ - return new MobyDataFloat("", value); + return new MobyDataFloat("", value, registry); } else if(MobyTags.MOBYSTRING.equals(typeName)){ - return new MobyDataString("", value); + return new MobyDataString("", value, registry); } else if(MobyTags.MOBYBOOLEAN.equals(typeName)){ - return new MobyDataBoolean("", value); + return new MobyDataBoolean("", value, registry); } else if(MobyTags.MOBYDATETIME.equals(typeName)){ - return new MobyDataDateTime("", value); + return new MobyDataDateTime("", value, registry); } else{ - MobyDataType type = MobyDataType.getDataType(typeName); + MobyDataType type = MobyDataType.getDataType(typeName, registry); if(type != null && type.inheritsFrom(MobyDataBytes.BASE64_DATATYPE)){ return new MobyDataBytes("", value, type); } @@ -134,6 +151,10 @@ * @param objectTag the W3C DOM Element node corresponding to the object's enclosing tag, or a Simple tag */ public static MobyDataInstance createInstanceFromDOM(Element objectTag) throws MobyException{ + return createInstanceFromDOM(objectTag, null); + } + + public static MobyDataInstance createInstanceFromDOM(Element objectTag, Registry registry) throws MobyException{ MobyDataObject object = null; if(objectTag == null){ @@ -156,38 +177,38 @@ // There are six types of objects we can populate with data directly // plus Collections and Secondary Parameters. Otherwise it is a composite. else if(MobyTags.MOBYOBJECT.equals(objectClass)){ - return new MobyDataObject(objectTag); + return new MobyDataObject(objectTag, registry); } else if(MobyTags.MOBYINTEGER.equals(objectClass)){ - return new MobyDataInt(objectTag); + return new MobyDataInt(objectTag, registry); } else if(MobyTags.MOBYFLOAT.equals(objectClass)){ - return new MobyDataFloat(objectTag); + return new MobyDataFloat(objectTag, registry); } else if(MobyTags.MOBYSTRING.equals(objectClass)){ - return new MobyDataString(objectTag); + return new MobyDataString(objectTag, registry); } else if(MobyTags.MOBYBOOLEAN.equals(objectClass)){ - return new MobyDataBoolean(objectTag); + return new MobyDataBoolean(objectTag, registry); } else if(MobyTags.MOBYDATETIME.equals(objectClass)){ - return new MobyDataDateTime(objectTag); + return new MobyDataDateTime(objectTag, registry); } else if(MobyTags.COLLECTION.equals(objectClass)){ - return new MobyDataObjectSet(objectTag); + return new MobyDataObjectSet(objectTag, registry); } else if(MobyDataSecondaryInstance.ELEMENT_NAME.equals(objectClass)){ return new MobyDataSecondaryInstance(objectTag); } // Must otherwise be a composite else{ - MobyDataType type = MobyDataType.getDataType(objectClass); + MobyDataType type = MobyDataType.getDataType(objectClass, registry); // Treat base64-encoded binary data as a special case, as we have a convenience class for it if(type != null && type.inheritsFrom(MobyDataType.getDataType(MobyDataBytes.BASE64_DATATYPE))){ - return new MobyDataBytes(objectTag); + return new MobyDataBytes(objectTag, registry); } else{ - return new MobyDataComposite(objectTag); + return new MobyDataComposite(objectTag, registry); } } } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectSet.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectSet.java 2007/04/26 15:06:15 1.7 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectSet.java 2007/06/07 23:58:15 1.8 @@ -1,19 +1,10 @@ package org.biomoby.shared.data; -import java.util.Arrays; -import java.util.Collection; -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.Vector; - -import org.biomoby.shared.MobyDataType; -import org.biomoby.shared.MobyException; -import org.biomoby.shared.MobyNamespace; -import org.biomoby.shared.MobyPrimaryData; -import org.biomoby.shared.MobyPrimaryDataSet; -import org.biomoby.shared.MobyPrimaryDataSimple; -import org.biomoby.shared.MobyPrefixResolver; +import java.util.*; + +import org.biomoby.registry.meta.Registry; +import org.biomoby.shared.*; +import org.biomoby.shared.parser.MobyTags; /** * This class adds to MobyPrimaryDataSet the ability to get and set instantiated MOBY objects. @@ -33,7 +24,11 @@ private int xmlMode = MobyDataInstance.CENTRAL_XML_MODE; public MobyDataObjectSet(org.w3c.dom.Element e) throws MobyException{ - this(MobyDataObject.getName(e), getChildren(e)); + this(e, null); + } + + public MobyDataObjectSet(org.w3c.dom.Element e, Registry registry) throws MobyException{ + this(MobyDataObject.getName(e), getChildren(e, registry)); if(getName() == null){ throw new MobyException("Anonymous collections are not allowed (need articleName), input was :\n" + e); @@ -41,13 +36,13 @@ } - public static Collection getChildren(org.w3c.dom.Element e) throws MobyException{ + public static Collection getChildren(org.w3c.dom.Element e, Registry registry) throws MobyException{ Vector members = new Vector(); org.w3c.dom.NodeList children = MobyPrefixResolver.getChildElements(e, "*"); // wildcard int numChildren = children.getLength(); for(int i = 0; i < numChildren; i++){ - members.add(MobyDataObject.createInstanceFromDOM((org.w3c.dom.Element) children.item(i))); + members.add(MobyDataObject.createInstanceFromDOM((org.w3c.dom.Element) children.item(i), registry)); } return members; } @@ -516,39 +511,46 @@ StringBuffer collectionXml = new StringBuffer(); if(xmlMode == MobyDataInstance.SERVICE_XML_MODE){ - collectionXml.append("\n"); for(MobyDataObject mdsi: bag){ mdsi.setXmlMode(xmlMode); - collectionXml.append(""+mdsi.toXML()+""); + collectionXml.append("<"+MobyTags.SIMPLE+">"+mdsi.toXML()+""); } - collectionXml.append("\n\n"); + collectionXml.append("\n\n"); } // Otherwise it's MOBY Central query mode // We need to find out what object classes are present in the array, and // enumerate them (the types, not the instances). else{ - collectionXml.append("\n"); - Hashtable printed = new Hashtable(); - - for(MobyDataObject mdsi: bag){ - // Could the DataType be null? I hope not! - String objectClass = mdsi.getDataType().getName(); + collectionXml.append("<"+MobyTags.COLLECTION+">\n"); - // A new data type for the collection? - if(!printed.containsKey(objectClass)){ - mdsi.setXmlMode(xmlMode); + MobyDataObject commonDataTemplate = new MobyDataObject(""); + commonDataTemplate.setDataType(getDataType()); + commonDataTemplate.setNamespaces(getNamespaces()); + collectionXml.append(commonDataTemplate.toXML()); + + // Hashtable printed = new Hashtable(); +// for(MobyDataObject mdsi: bag){ +// // Could the DataType be null? I hope not! +// String objectClass = mdsi.getDataType().getName(); + +// // A new data type for the collection? Note to self (Paul), this doesn't seem right, should have one type only ...since the 0.86 spec +// if(!printed.containsKey(objectClass)){ +// mdsi.setXmlMode(xmlMode); - collectionXml.append(mdsi.toXML()); +// collectionXml.append(mdsi.toXML()); - printed.put(objectClass, "printed object type in MOBY central input collection"); - } - } - collectionXml.append("\n"); +// printed.put(objectClass, "printed object type in MOBY central input collection"); +// } +// } + + + collectionXml.append("\n"); } return collectionXml.toString(); =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataString.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataString.java 2006/07/07 04:12:40 1.5 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataString.java 2007/06/07 23:58:15 1.6 @@ -1,7 +1,9 @@ - package org.biomoby.shared.data; + +import org.biomoby.registry.meta.Registry; import org.biomoby.shared.MobyDataType; import org.biomoby.shared.MobyNamespace; +import org.biomoby.shared.parser.MobyTags; /** * A class representing a MOBY String primitive. @@ -21,7 +23,11 @@ * @throws IllegalArgumentException if the element is not a String tag */ public MobyDataString(org.w3c.dom.Element element) throws IllegalArgumentException{ - this(getName(element), getTextContents(element)); + this(element, null); + } + + public MobyDataString(org.w3c.dom.Element element, Registry registry) throws IllegalArgumentException{ + this(getName(element), getTextContents(element), registry); setId(getId(element)); addNamespace(getNamespace(element)); } @@ -31,13 +37,21 @@ * (i.e. String, StringBuffer, CharBuffer or StringBuilder). */ public MobyDataString(String articleName, CharSequence stringValue){ + this(articleName, stringValue, null); + } + + public MobyDataString(String articleName, CharSequence stringValue, Registry registry){ super(articleName); - setDataType(MobyDataType.getDataType("String")); + setDataType(MobyDataType.getDataType(MobyTags.MOBYSTRING, registry)); value = new StringBuffer(stringValue.toString()); } public MobyDataString(CharSequence stringValue){ - this("", stringValue); + this("", stringValue, null); + } + + public MobyDataString(CharSequence stringValue, Registry registry){ + this("", stringValue, registry); } public String toString(){ @@ -89,8 +103,9 @@ tmpValue = ""; } - return "" + tmpValue + ""; - } + return "<" + MobyTags.MOBYSTRING + " "+ getAttrXML() + " xml:space=\"preserve\">" + + tmpValue + ""; + } // Central mode, use default toXML provided by superclasses else{ return super.toXML(); =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataUtils.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataUtils.java 2007/03/29 19:40:52 1.6 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataUtils.java 2007/06/07 23:58:15 1.7 @@ -1,5 +1,6 @@ package org.biomoby.shared.data; +import org.biomoby.registry.meta.Registry; import org.biomoby.shared.parser.MobyTags; import org.biomoby.shared.*; import org.xml.sax.InputSource; @@ -59,7 +60,11 @@ * Create a MOBY Java object representation from a MOBY XML payload stored in a String. */ public static MobyContentInstance fromXMLDocument(String xmlData) throws Exception{ - return fromXMLDocument(new StringReader(xmlData)); + return fromXMLDocument(new StringReader(xmlData), null); + } + + public static MobyContentInstance fromXMLDocument(String xmlData, Registry registry) throws Exception{ + return fromXMLDocument(new StringReader(xmlData), registry); } /** @@ -67,6 +72,10 @@ * (a byte stream that will becoverted by the parser into character data). */ public static MobyContentInstance fromXMLDocument(InputStream is) throws Exception{ + return fromXMLDocument(is, null); + } + + public static MobyContentInstance fromXMLDocument(InputStream is, Registry registry) throws Exception{ // Load an XML document javax.xml.parsers.DocumentBuilder docBuilder = null; try{ @@ -91,13 +100,17 @@ // Select a node from the document and see if any of the mappings // work out, in which case we can check what services we can run Element doc_root = domDoc.getDocumentElement(); - return fromXMLDocument(doc_root); + return fromXMLDocument(doc_root, registry); } /** * Create a MOBY Java object representation from a MOBY XML payload at the given URL. */ public static MobyContentInstance fromXMLDocument(java.net.URL url) throws Exception{ + return fromXMLDocument(url, null); + } + + public static MobyContentInstance fromXMLDocument(java.net.URL url, Registry registry) throws Exception{ // Load an XML document javax.xml.parsers.DocumentBuilder docBuilder = null; try{ @@ -122,13 +135,17 @@ // Select a node from the document and see if any of the mappings // work out, in which case we can check what services we can run Element doc_root = domDoc.getDocumentElement(); - return fromXMLDocument(doc_root); + return fromXMLDocument(doc_root, registry); } /** * Create a MOBY Java object representation from a MOBY XML payload coming from a Reader (character data). */ public static MobyContentInstance fromXMLDocument(Reader reader) throws Exception{ + return fromXMLDocument(reader, null); + } + + public static MobyContentInstance fromXMLDocument(Reader reader, Registry registry) throws Exception{ // Load an XML document javax.xml.parsers.DocumentBuilder docBuilder = null; try{ @@ -153,7 +170,7 @@ // Select a node from the document and see if any of the mappings // work out, in which case we can check what services we can run Element doc_root = domDoc.getDocumentElement(); - return fromXMLDocument(doc_root); + return fromXMLDocument(doc_root, registry); } @@ -163,6 +180,16 @@ * @param doc_root the document's base MOBY tag */ public static MobyContentInstance fromXMLDocument(Element doc_root) throws Exception{ + return fromXMLDocument(doc_root, null); + } + + /** + * Create a MOBY Java object representation from a MOBY XML payload represented in a DOM. + * + * @param doc_root the document's base MOBY tag + * @param registry the Mony Central from which to retrieve the data type definitions, uses default registry if null + */ + public static MobyContentInstance fromXMLDocument(Element doc_root, Registry registry) throws Exception{ if(doc_root == null){ throw new MobyException("The passed in element was null"); } @@ -204,7 +231,7 @@ MobyPrefixResolver.MOBY_XML_NAMESPACE); } - MobyContentInstance contents = new MobyContentInstance((Element) envelope.item(0)); + MobyContentInstance contents = new MobyContentInstance((Element) envelope.item(0), registry); return contents; } From carrere at dev.open-bio.org Wed Jun 20 12:36:27 2007 From: carrere at dev.open-bio.org (Sebastien Carrere) Date: Wed, 20 Jun 2007 12:36:27 -0000 Subject: [MOBY-guts] biomoby commit Message-ID: <200706201236.l5KCaOOd019077@dev.open-bio.org> carrere Wed Jun 20 08:36:24 EDT 2007 Update of /home/repository/moby/moby-live/Perl/MOBY/xsl In directory dev.open-bio.org:/tmp/cvs-serv19023/xsl Modified Files: parseMobyMessage.xsl Log Message: Exceptions are now parsed moby-live/Perl/MOBY/xsl parseMobyMessage.xsl,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/xsl/parseMobyMessage.xsl,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Perl/MOBY/xsl/parseMobyMessage.xsl 2005/10/24 11:47:03 1.2 +++ /home/repository/moby/moby-live/Perl/MOBY/xsl/parseMobyMessage.xsl 2007/06/20 12:36:24 1.3 @@ -11,11 +11,8 @@ - #XSL_LIPM_MOBYPARSER_SERVICENOTES# - - #XSL_LIPM_MOBYPARSER_SERVICENOTES# - - + + @@ -221,12 +218,20 @@ #XSL_LIPM_MOBYPARSER_OBJECTCONTENT# - + + + + + + + + #XSL_LIPM_MOBYPARSER_OBJECTCONTENT# - + + @@ -250,6 +259,35 @@ + + + + + + + + + + + + + + + #XSL_LIPM_MOBYPARSER_OBJECTHASA_START# + + + + #XSL_LIPM_MOBYPARSER_OBJECTHASA_END# + + + + + + @@ -279,4 +317,159 @@ + + + + + + + + #XSL_LIPM_MOBYPARSER_PIB_START# + + + + + #XSL_LIPM_MOBYPARSER_SOFTWARE_START# + + #XSL_LIPM_MOBYPARSER_SOFTWARE_SEP# + + #XSL_LIPM_MOBYPARSER_SOFTWARE_SEP# + + #XSL_LIPM_MOBYPARSER_SOFTWARE_END# + + + + + + #XSL_LIPM_MOBYPARSER_DATABASE_START# + + #XSL_LIPM_MOBYPARSER_DATABASE_SEP# + + #XSL_LIPM_MOBYPARSER_DATABASE_SEP# + + #XSL_LIPM_MOBYPARSER_DATABASE_END# + + + + #XSL_LIPM_MOBYPARSER_COMMENT_START# + + #XSL_LIPM_MOBYPARSER_COMMENT_END# + + #XSL_LIPM_MOBYPARSER_PIB_END# + + + + + + + + + + + #XSL_LIPM_MOBYPARSER_SERVICENOTES# + + #XSL_LIPM_MOBYPARSER_SERVICENOTES_NOTES_START# + + #XSL_LIPM_MOBYPARSER_SERVICENOTES_NOTES_END# + + + + + + + + + + #XSL_LIPM_MOBYPARSER_SERVICENOTES# + + + + + + + + #XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_START# + + #XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_REFELEMENT_START# + + + + + + + + + #XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_REFELEMENT_END# + + #XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_REFQUERYID_START# + + + + + + + + + #XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_REFQUERYID_END# + + + #XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_SEVERITY_START# + + + + + + + + + #XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_SEVERITY_END# + + + + + #XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_CODE_START# + + #XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_CODE_END# + + + #XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_MESSAGE_START# + + #XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_MESSAGE_END# + + + #XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_END# + + + + + + + + #XSL_LIPM_MOBYPARSER_SERVICENOTES_NOTES_START# + + #XSL_LIPM_MOBYPARSER_SERVICENOTES_NOTES_END# + + + + From carrere at dev.open-bio.org Wed Jun 20 12:36:32 2007 From: carrere at dev.open-bio.org (Sebastien Carrere) Date: Wed, 20 Jun 2007 12:36:32 -0000 Subject: [MOBY-guts] biomoby commit Message-ID: <200706201236.l5KCaOKn019059@dev.open-bio.org> carrere Wed Jun 20 08:36:24 EDT 2007 Update of /home/repository/moby/moby-live/Perl/MOBY In directory dev.open-bio.org:/tmp/cvs-serv19023 Modified Files: MOBYXSLT.pm Log Message: Exceptions are now parsed moby-live/Perl/MOBY MOBYXSLT.pm,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/MOBYXSLT.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Perl/MOBY/MOBYXSLT.pm 2005/12/15 14:03:41 1.4 +++ /home/repository/moby/moby-live/Perl/MOBY/MOBYXSLT.pm 2007/06/20 12:36:23 1.5 @@ -2,7 +2,7 @@ my $TMP_DIR = '/tmp/';#Where your temporary files will be written my $XSLTPROC = '/usr/bin/xsltproc';#Where your xsltproc binary is located -my $XSL_SHEET = '/bioinfo/www/bioinfo/services/biomoby/cgi-bin/Services/LIPM/lib/parseMobyMessage.xsl';#Where your xsltproc style-sheet is located +my $XSL_SHEET = 'xsl/parseMobyMessage.xsl';#Where your xsltproc style-sheet is located #$Id$ @@ -150,21 +150,23 @@ my $parsed_message = `$XSLTPROC $XSL_SHEET $TMP_DIR$tmp_file`; -# open (PARSED, ">$TMP_DIR$tmp_file" . ".xsl"); -# print PARSED "$XSLTPROC $XSL_SHEET $TMP_DIR$tmp_file\n\n\n"; -# print PARSED "$parsed_message"; -# close PARSED; - + + my $servicenotes = ''; + my $ra_exceptions = (); my @a_queries = (); my $servicenotes_tag = '#XSL_LIPM_MOBYPARSER_SERVICENOTES#'; - - if ($parsed_message =~ /$servicenotes_tag(.+)$servicenotes_tag/) + $parsed_message =~ s/\n/__nl__/g; + if ($parsed_message =~ /$servicenotes_tag(.*)$servicenotes_tag/) { - ($servicenotes) = ($parsed_message =~ /$servicenotes_tag(.+)$servicenotes_tag/); + my $notes = $1; + + ($servicenotes,$ra_exceptions) = _AnalyseServiceNotes($notes); + #($servicenotes) = ($parsed_message =~ /$servicenotes_tag(.+)$servicenotes_tag/); } - + $parsed_message =~ s/__nl__/\n/g; + my $mobydata_tag = '#XSL_LIPM_MOBYPARSER_DATA_START#'; my ($header, @a_mobydata_blocs) = split($mobydata_tag, $parsed_message); @@ -239,7 +241,7 @@ } unlink("$TMP_DIR$tmp_file"); - return ($servicenotes, \@a_queries); + return ($servicenotes, \@a_queries, $ra_exceptions); } =head2 function getInputID @@ -322,14 +324,71 @@ { my $rh_simple_article = shift(); - if ($rh_simple_article->{'object_crossreference'} ne '') + if (defined $rh_simple_article->{'article_objects'}) { - return (@{$rh_simple_article->{'object_crossreference'}}); + if ($rh_simple_article->{'article_objects'}->{'object_crossreference'} ne '') + { + return (@{$rh_simple_article->{'article_objects'}->{'object_crossreference'}}); + } + else + { + return (); + } } else { - return (); + if ($rh_simple_article->{'object_crossreference'} ne '') + { + return @{$rh_simple_article->{'object_crossreference'}}; + } + else + { + return (); + } } + +} + +=head2 function getProvisionInformation + + Title : getProvisionInformation + Usage : my @a_pib =getProvisionInformation($rh_simple_article); + Prerequisite : + Function : Takes a simple article structure (from getArticles or getCollectedSimples) + and retrieve the list of Provision Information HASHREF + Returns : @a_pib: ARRAY of provisionInformation HASHREF + Args : $rh_simple_article: simple article HASHREF structure from getArticles or getCollectedSimples + Globals : none + +=cut + +sub getProvisionInformation +{ + my $rh_simple_article = shift(); + + if (defined $rh_simple_article->{'article_objects'}) + { + if ($rh_simple_article->{'article_objects'}->{'object_pib'} ne '') + { + return (@{$rh_simple_article->{'article_objects'}->{'object_pib'}}); + } + else + { + return (); + } + } + else + { + if ($rh_simple_article->{'object_pib'} ne '') + { + return @{$rh_simple_article->{'object_pib'}}; + } + else + { + return (); + } + } + } =head2 function getObjectHasaElements @@ -733,6 +792,7 @@ { my $simple_bloc = shift(); my @a_crossref = (); + my @a_pib = (); my @a_hasa = (); my ($object_type,$object_name,$object_id,$object_namespace) = ('','','',''); @@ -771,7 +831,8 @@ while ($simple_bloc =~ m/$crossref_start_tag(.*)$crossref_sep_tag(.*)$crossref_sep_tag(.*)$crossref_end_tag/g) { - my %h_crossref = ('type' => $1, 'id' => $2, 'namespace' => $3); + my %h_crossref = ('type' => $1, 'id' => $2, 'namespace' => $3); + $simple_bloc =~ s/$crossref_start_tag$1$crossref_sep_tag$2$crossref_sep_tag$3$crossref_end_tag//; push(@a_crossref, \%h_crossref); } @@ -781,16 +842,96 @@ $ra_crossref = ''; } + #19/12/2005 + #Provision Information Block + + my $pib_start_tag = '#XSL_LIPM_MOBYPARSER_PIB_START#'; + my $pib_end_tag = '#XSL_LIPM_MOBYPARSER_PIB_END#'; + my $pib_software_start_tag = '#XSL_LIPM_MOBYPARSER_SOFTWARE_START#'; + my $pib_software_end_tag = '#XSL_LIPM_MOBYPARSER_SOFTWARE_END#'; + my $pib_software_sep_tag = '#XSL_LIPM_MOBYPARSER_SOFTWARE_SEP#'; + my $pib_database_start_tag = '#XSL_LIPM_MOBYPARSER_DATABASE_START#'; + my $pib_database_end_tag = '#XSL_LIPM_MOBYPARSER_DATABASE_END#'; + my $pib_database_sep_tag = '#XSL_LIPM_MOBYPARSER_DATABASE_SEP#'; + my $pib_comment_start_tag = '#XSL_LIPM_MOBYPARSER_COMMENT_START#'; + my $pib_comment_end_tag = '#XSL_LIPM_MOBYPARSER_COMMENT_END#'; + + + while ($simple_bloc =~ m/$pib_start_tag(.*)$pib_end_tag/g) + { + my $provision_block = $1; + $simple_bloc =~ s/$pib_start_tag$provision_block$pib_end_tag//; + my ($software_name,$software_version,$software_comment) = ('','',''); + if ($provision_block =~ /$pib_software_start_tag(.*)$pib_software_end_tag/) + { + ($software_name,$software_version,$software_comment) = split (/$pib_software_sep_tag/,$1); + } + my ($database_name,$database_version,$database_comment) = ('','',''); + if ($provision_block =~ /$pib_database_start_tag(.*)$pib_database_end_tag/) + { + ($database_name,$database_version,$database_comment) = split (/$pib_database_sep_tag/,$1); + } + my ($service_comment) = (''); + if ($provision_block =~ /$pib_comment_start_tag(.*)$pib_comment_end_tag/) + { + ($service_comment) = ($1); + } + + my %h_pib = ( + 'software_name' => $software_name, + 'software_version' => $software_version, + 'software_comment' => $software_comment, + 'database_name' => $database_name, + 'database_version' => $database_version, + 'database_comment' => $database_comment, + 'service_comment' => $service_comment + ); + + open (TMP, ">>/tmp/pib.txt"); + print TMP < $software_name, +'software_version' => $software_version, +'software_comment' => $software_comment, +'database_name' => $database_name, +'database_version' => $database_version, +'database_comment' => $database_comment, +'service_comment' => $service_comment +END + close TMP; + chmod 0777, "/tmp/pib.txt"; + + push(@a_pib, \%h_pib); + } + + my $ra_pib = \@a_pib; + if ($#a_pib < 0) + { + $ra_pib = ''; + } + + + + + my $object_content_tag = '#XSL_LIPM_MOBYPARSER_OBJECTCONTENT#'; my ($before, $object_content, $after) = ('','',''); ($before, $object_content, $after) = split($object_content_tag, $simple_bloc); - my $object_hasa_start_tag = '#XSL_LIPM_MOBYPARSER_OBJECTHASA_START#'; + #Sebastien 21/12/2005 + # + $object_content =~ s/^\s+//g; + $object_content =~ s/\s+$//g; + # + + my $object_hasa_start_tag = '#XSL_LIPM_MOBYPARSER_OBJECTHASA_START#'; if ($simple_bloc =~ /$object_hasa_start_tag/) { my (@a_hasa_blocs) = split($object_hasa_start_tag, $simple_bloc); + #Sebastien 19/12/2005 + #le premier est le pere + #shift @a_hasa_blocs; foreach my $hasa_bloc (@a_hasa_blocs) { if ($hasa_bloc ne '') @@ -828,6 +969,7 @@ 'object_content' => $object_content, 'object_xml' => $object_xml, 'object_crossreference' => $ra_crossref, + 'object_pib' => $ra_pib, 'object_hasa' => $ra_hasa ); @@ -943,45 +1085,166 @@ } } + +=head2 complexResponse (stolen from MOBY::CommonSubs) + + name : complexResponse + function : wraps a set of articles in the one mobyData structure + usage : return responseHeader . &complexResponse(\@a_article_structures, $queryID) . responseFooter; + args : (in order) + \@a_article_structures - (optional) a listref of structured articles + %h_article = ( + article_type => 'collection/simple', + article_content => 'MOBY XML formatted content', + article_name => 'articleName attribut') + $queryID - (optional, but strongly recommended) the mobyData ID + to which you are responding +=cut + + +sub complexResponse +{ + my ($ra_data, $qID) = @_; + + $ra_data ||= []; + $qID ||= ''; + unless ((ref($ra_data) =~ /array/i) && $ra_data->[0]) + { # we're expecting an arrayref as input data,and it must not be empty + return ""; + } + my $moby_data_content = ''; + foreach my $rh_data_block (@{$ra_data}) + { + my $article_name = $rh_data_block->{article_name}; + my $article_content = $rh_data_block->{article_content}; + + if ($rh_data_block->{article_type} =~ /collection/i) + { + my $collection_content = "\n"; + if ((ref($article_content) =~ /array/i) && $article_content->[0]) + { + foreach my $simple_element (@{$article_content}) + { + $collection_content .= "\t\n\t$simple_element\n\t\n"; + } + } + else + { + $collection_content .= "\t\n"; + } + $collection_content .= "\n"; + + $moby_data_content .= $collection_content; + + } + else + { + my $simple_content = "\n\t$article_content\n"; + $moby_data_content .= $simple_content; + } + } + + return "\n\t$moby_data_content\n\n"; +} + + =head2 responseHeader (stolen from MOBY::CommonSubs) - name : responseHeader - function : print the XML string of a MOBY response header +/- serviceNotes - usage : responseHeader('illuminae.com') - responseHeader( +B print the XML string of a MOBY response header +/- serviceNotes +/- Exceptions + +B + + responseHeader('illuminae.com') + + responseHeader( -authority => 'illuminae.com', - -note => 'here is some data from the service provider') - args : a string representing the service providers authority URI, - OR a set of named arguments with the authority and the - service provision notes. - caveat : - notes : returns everything required up to the response articles themselves. - i.e. something like: + -note => 'here is some data from the service provider' + -exception=>'an xml encoded exception string') + + +B a string representing the service providers authority URI, OR +a set of named arguments with the authority and the service provision +notes which can include already xml encoded exceptions + +B< caveat :> + +B returns everything required up to the response articles themselves. i.e. something like: + - =cut -sub responseHeader -{ - use HTML::Entities (); - my ($auth, $notes) = &_rearrange([qw[AUTHORITY NOTE]], @_); - $auth ||= "not_provided"; - $notes ||= ""; - my $xml = - "" - . "" - . ""; - if ($notes) - { - my $encodednotes = HTML::Entities::encode($notes); - $xml .= "$encodednotes"; +sub responseHeader { + use HTML::Entities (); + my ( $auth, $notes, $exception ) = _rearrange( [qw[AUTHORITY NOTE EXCEPTION]], @_ ); + $auth ||= "not_provided"; + $notes ||= ""; + $exception ||=""; + my $xml = + "" + . "" + . ""; + if ($exception) { + $xml .= "$exception"; + if ( $notes ) { + my $encodednotes = HTML::Entities::encode( $notes ); + $xml .= "$encodednotes"; } - return $xml; + $xml .=""; + } + + elsif ( $notes ) { + my $encodednotes = HTML::Entities::encode( $notes ); + $xml .= "$encodednotes"; + } + return $xml; +} + + +=head2 encodeException (stolen from MOBY::CommonSubs) + +B wraps a Biomoby Exception with all its parameters into the appropiate MobyData structure + +B + + encodeException( + -refElement => 'refers to the queryID of the offending input mobyData', + -refQueryID => 'refers to the articleName of the offending input Simple or Collection' + -severity=>'error' + -exceptionCode=>'An error code ' + -exceptionMessage=>'a human readable description for the error code') + +Bthe different arguments required by the mobyException API + severity can be either error, warning or information + valid error codes are decribed on the biomoby website + + +B returns everything required to use for the responseHeader: + + + 600 + Unable to execute the service + + +=cut + +sub encodeException{ + use HTML::Entities (); + my ( $refElement, $refQueryID, $severity, $code, $message ) = _rearrange( [qw[REFELEMENT REFQUERYID SEVERITY EXCEPTIONCODE EXCEPTIONMESSAGE]], @_ ); + $refElement ||= ""; + defined($refQueryID) || ($refQueryID= ""); + $severity ||= ""; + defined($code) || ($code = ""); + $message ||= "not provided"; + my $xml="". + "$code". + "".HTML::Entities::encode($message)."". + ""; } + =head2 responseFooter (stolen from MOBY::CommonSubs) name : responseFooter @@ -1110,4 +1373,110 @@ return @param{@$order}; } + +=head2 function _AnalyseServiceNotes + + Title : _AnalyseServiceNotes + Usage : _AnalyseServiceNotes($simple_bloc) + Prerequisite : + Function : Analyse a "Simple Bloc" from XSL transformation parsing + Build a $rh_simple_article structure with fields: + 'object_name' => moby:articleName + 'object_type' => moby:Class + 'object_namespace' => moby:namespace + 'object_id' => moby:id + 'object_content' => text content of simple article + 'object_xml' => full xml content of article + 'object_hasa' => ARRAYREF of hasa elements + (each one is structured in a same + structured hash (recursivity) + 'object_crossreference' => ARRAYREF of crossreferences objects + (each one is structured in a hash with fields + 'type', 'id', 'namespace') + + Returns : $services_notes: article HASHREF + $ra_exceptions: article HASHREF + Args : $service_notes_bloc: from parsing of a "serviceNotes" XSLT transformation + Globals : none + +=cut + +sub _AnalyseServiceNotes +{ + my $service_notes_block = shift(); + my @a_exceptions = (); + my $service_notes = ''; + + + my $exception_start_tag = '#XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_START#'; + my $exception_end_tag = '#XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_END#'; + my $exception_refelement_start_tag = '#XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_REFELEMENT_START#'; + my $exception_refelement_end_tag = '#XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_REFELEMENT_END#'; + my $exception_refqueryid_start_tag = '#XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_REFQUERYID_START#'; + my $exception_refqueryid_end_tag = '#XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_REFQUERYID_END#'; + my $exception_severity_start_tag = '#XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_SEVERITY_START#'; + my $exception_severity_end_tag = '#XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_SEVERITY_END#'; + my $exception_code_start_tag = '#XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_CODE_START#'; + my $exception_code_end_tag = '#XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_CODE_END#'; + my $exception_message_start_tag = '#XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_MESSAGE_START#'; + my $exception_message_end_tag = '#XSL_LIPM_MOBYPARSER_SERVICENOTES_EXCEPTION_MESSAGE_END#'; + + + while ($service_notes_block =~ m/$exception_start_tag(.*)$exception_end_tag/g) + { + my $exception_block = $1; + my ($refelement,$refqueryid,$severity,$code,$message) = ('','','','',''); + if ($exception_block =~ /$exception_refelement_start_tag(.*)$exception_refelement_end_tag/) + { + $refelement = $1; + } + if ($exception_block =~ /$exception_refqueryid_start_tag(.*)$exception_refqueryid_end_tag/) + { + $refqueryid = $1; + } + if ($exception_block =~ /$exception_severity_start_tag(.*)$exception_severity_end_tag/) + { + $severity = $1; + } + if ($exception_block =~ /$exception_code_start_tag(.*)$exception_code_end_tag/) + { + $code = $1; + } + if ($exception_block =~ /$exception_message_start_tag(.*)$exception_message_end_tag/) + { + $message = $1; + $message =~ s/__nl__/\n/g; + + } + + my %h_exception = ( + 'refelement' => $refelement, + 'refqueryid' => $refqueryid, + 'severity' => $severity, + 'code' => $code, + 'message' => $message + ); + + + push(@a_exceptions, \%h_exception); + } + my $ra_exceptions = \@a_exceptions; + if ($#a_exceptions < 0) + { + $ra_exceptions = ''; + } + + + my $notes_start_tag = '#XSL_LIPM_MOBYPARSER_SERVICENOTES_NOTES_START#'; + my $notes_end_tag = '#XSL_LIPM_MOBYPARSER_SERVICENOTES_NOTES_END#'; + + if ($service_notes_block =~ /$notes_start_tag(.*)$notes_end_tag/) + { + $service_notes = $1; + } + + return ($service_notes,$ra_exceptions); +} + + 1;