From deandres at dev.open-bio.org Mon Apr 2 03:43:46 2007 From: deandres at dev.open-bio.org (Enrique de Andres Saiz) Date: Mon, 2 Apr 2007 03:43:46 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704020743.l327hkg1004097@dev.open-bio.org> deandres Mon Apr 2 03:43:46 EDT 2007 Update of /home/repository/moby/moby-live/Perl/MOBY/Async In directory dev.open-bio.org:/tmp/cvs-serv4062 Modified Files: Service.pm Log Message: Catched INT andt TERM signals for destroying resource moby-live/Perl/MOBY/Async Service.pm,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Async/Service.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Perl/MOBY/Async/Service.pm 2007/03/15 09:50:50 1.4 +++ /home/repository/moby/moby-live/Perl/MOBY/Async/Service.pm 2007/04/02 07:43:45 1.5 @@ -151,20 +151,16 @@ sub execute { my ($self, %args) = @_; - print "Creating WS-Resource...\n\n" unless ($self->{silent}); - my $start = time; my ($EPR, @queryIDs) = $self->submit(%args); - print XML::LibXML->new->parse_string($EPR->XML)->getDocumentElement()->toString."\n\n" unless ($self->{silent}); - my $pollingTime; my ($i, $j) = (0, 1); my @status; while ( $pollingTime = &_getPollingTime($i, $j, $start, @status) ) { ($i, $j) = ($j, $i+$j); - print "Next polling in $pollingTime seconds...\n\n" unless ($self->{silent}); + print "(next polling in $pollingTime seconds)\n\n" unless ($self->{silent}); sleep $pollingTime; @status = $self->poll($EPR, @queryIDs); @@ -177,13 +173,11 @@ } } - print "Retrieving results and destroying WS-Resource...\n\n" unless ($self->{silent}); - my @responses = $self->result($EPR, @queryIDs); $self->destroy($EPR); my $response = &_composeResponse(@responses); - print "Finished.\n" unless ($self->{silent}); + print "Finished.\n\n" unless ($self->{silent}); return $response; } @@ -191,6 +185,8 @@ sub submit { my ($self, %args) = @_; + print "Creating WS-Resource...\n\n" unless ($self->{silent}); + # Compose the moby message (part of this block is copied from MOBY::Client::Service) die "ERROR: expected listref for XMLinputlist" unless ( ref( $args{XMLinputlist} ) eq 'ARRAY' ); my @inputs = @{ $args{XMLinputlist} }; @@ -269,6 +265,19 @@ $EPR->Address($address); $EPR->ReferenceParameters(''.$identifier.''); + print XML::LibXML->new->parse_string($EPR->XML)->getDocumentElement()->toString."\n\n" unless ($self->{silent}); + + $SIG{TERM} = sub { + $self->destroy($EPR); + print "Finished.\n\n" unless ($self->{silent}); + exit; + }; + $SIG{INT} = sub { + $self->destroy($EPR); + print "Finished.\n\n" unless ($self->{silent}); + exit; + }; + # Return Endpoint Reference and the queryIDs return ($EPR, @queryIDs); } @@ -281,15 +290,13 @@ my $start = time; my ($EPR, @queryIDs) = $self->enumerated_submit(%args); - print XML::LibXML->new->parse_string($EPR->XML)->getDocumentElement()->toString."\n\n" unless ($self->{silent}); - my $pollingTime; my ($i, $j) = (0, 1); my @status; while ( $pollingTime = &_getPollingTime($i, $j, $start, @status) ) { ($i, $j) = ($j, $i+$j); - print "Next polling in $pollingTime seconds...\n\n" unless ($self->{silent}); + print "(next polling in $pollingTime seconds)\n\n" unless ($self->{silent}); sleep $pollingTime; @status = $self->poll($EPR, @queryIDs); @@ -302,13 +309,11 @@ } } - print "Retrieving results and destroying WS-Resource...\n\n" unless ($self->{silent}); - my @responses = $self->result($EPR, @queryIDs); $self->destroy($EPR); my $response = &_composeResponse(@responses); - print "Finished.\n" unless ($self->{silent}); + print "Finished.\n\n" unless ($self->{silent}); return $response; } @@ -316,6 +321,8 @@ sub enumerated_submit { my ($self, %args) = @_; + print "Creating WS-Resource...\n\n" unless ($self->{silent}); + # Compose the moby message (part of this block is copied from MOBY::Client::Service) die "ERROR: expected Input to be a HASH ref" unless ( ref( $args{Input} ) eq 'HASH' ); my %inputs = %{$args{Input}}; @@ -393,6 +400,19 @@ $EPR->Address($address); $EPR->ReferenceParameters(''.$identifier.''); + print XML::LibXML->new->parse_string($EPR->XML)->getDocumentElement()->toString."\n\n" unless ($self->{silent}); + + $SIG{TERM} = sub { + $self->destroy($EPR); + print "Finished.\n\n" unless ($self->{silent}); + exit; + }; + $SIG{INT} = sub { + $self->destroy($EPR); + print "Finished.\n\n" unless ($self->{silent}); + exit; + }; + # Return Endpoint Reference and the queryIDs return ($EPR, @queryIDs); } @@ -400,6 +420,8 @@ sub poll { my ($self, $EPR, @queryIDs) = @_; + print "Polling...\n\n" unless ($self->{silent}); + my $searchTerm = ""; foreach my $queryID (@queryIDs) { $searchTerm .= ""; @@ -434,6 +456,8 @@ sub result { my ($self, $EPR, @queryIDs) = @_; + print "Retrieving results...\n\n" unless ($self->{silent}); + my $searchTerm = ""; foreach my $queryID (@queryIDs) { $searchTerm .= ""; @@ -467,6 +491,8 @@ sub destroy { my ($self, $EPR) = @_; + print "Destroying WS-Resource...\n\n" unless ($self->{silent}); + my $ans = WSRF::Lite -> uri($WSRF::Constants::WSRL) -> on_action( sub {sprintf '%s/%s', @_} ) From deandres at dev.open-bio.org Mon Apr 2 05:16:22 2007 From: deandres at dev.open-bio.org (Enrique de Andres Saiz) Date: Mon, 2 Apr 2007 05:16:22 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704020916.l329GMtp004787@dev.open-bio.org> deandres Mon Apr 2 05:16:22 EDT 2007 Update of /home/repository/moby/moby-live/Perl/MOBY/Async In directory dev.open-bio.org:/tmp/cvs-serv4752 Modified Files: Service.pm Log Message: Deleted a duplicated message into enumerated_execute moby-live/Perl/MOBY/Async Service.pm,1.5,1.6 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Async/Service.pm,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Perl/MOBY/Async/Service.pm 2007/04/02 07:43:45 1.5 +++ /home/repository/moby/moby-live/Perl/MOBY/Async/Service.pm 2007/04/02 09:16:21 1.6 @@ -285,8 +285,6 @@ sub enumerated_execute { my ($self, %args) = @_; - print "Creating WS-Resource...\n\n" unless ($self->{silent}); - my $start = time; my ($EPR, @queryIDs) = $self->enumerated_submit(%args); From deandres at dev.open-bio.org Mon Apr 2 08:13:32 2007 From: deandres at dev.open-bio.org (Enrique de Andres Saiz) Date: Mon, 2 Apr 2007 08:13:32 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704021213.l32CDW1E005063@dev.open-bio.org> deandres Mon Apr 2 08:13:32 EDT 2007 Update of /home/repository/moby/moby-live/Perl/MOBY/Async In directory dev.open-bio.org:/tmp/cvs-serv5016 Modified Files: LSAE.pm Service.pm SimpleServer.pm WSRF.pm Log Message: Modified pod title moby-live/Perl/MOBY/Async LSAE.pm,1.2,1.3 Service.pm,1.6,1.7 SimpleServer.pm,1.2,1.3 WSRF.pm,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Async/LSAE.pm,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Perl/MOBY/Async/LSAE.pm 2007/02/07 19:43:49 1.2 +++ /home/repository/moby/moby-live/Perl/MOBY/Async/LSAE.pm 2007/04/02 12:13:32 1.3 @@ -2,7 +2,7 @@ =head1 NAME -MOBY::Async::LSAE +MOBY::Async::LSAE - utilities to work with LSAE analysis event blocks =head1 AUTHORS =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Async/Service.pm,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Perl/MOBY/Async/Service.pm 2007/04/02 09:16:21 1.6 +++ /home/repository/moby/moby-live/Perl/MOBY/Async/Service.pm 2007/04/02 12:13:32 1.7 @@ -2,7 +2,7 @@ =head1 NAME -MOBY::Async::Service +MOBY::Async::Service - an object for communicating with Asynchronous MOBY Services =head1 AUTHORS =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Async/SimpleServer.pm,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Perl/MOBY/Async/SimpleServer.pm 2007/03/13 15:50:58 1.2 +++ /home/repository/moby/moby-live/Perl/MOBY/Async/SimpleServer.pm 2007/04/02 12:13:32 1.3 @@ -2,7 +2,7 @@ =head1 NAME -MOBY::Async::SimpleServer +MOBY::Async::SimpleServer - a base class for simple Asynchronous MOBY Services =head1 AUTHORS =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Async/WSRF.pm,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Perl/MOBY/Async/WSRF.pm 2006/12/04 08:27:52 1.1 +++ /home/repository/moby/moby-live/Perl/MOBY/Async/WSRF.pm 2007/04/02 12:13:32 1.2 @@ -2,7 +2,7 @@ =head1 NAME -MOBY::Async::WSRF +MOBY::Async::WSRF - utilities to work with WSRF in MOBY =head1 AUTHORS From gordonp at dev.open-bio.org Mon Apr 2 22:18:46 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 2 Apr 2007 22:18:46 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704030218.l332IknY006474@dev.open-bio.org> gordonp Mon Apr 2 22:18:46 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util In directory dev.open-bio.org:/tmp/cvs-serv6443/src/main/ca/ucalgary/seahawk/util Added Files: CloseTabIcon.java CombinedIcon.java NullIcon.java Log Message: Icon support for Seahawk tabs augmented to include close icon moby-live/Java/src/main/ca/ucalgary/seahawk/util CloseTabIcon.java,NONE,1.1 CombinedIcon.java,NONE,1.1 NullIcon.java,NONE,1.1 From gordonp at dev.open-bio.org Mon Apr 2 22:20:50 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 2 Apr 2007 22:20:50 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704030220.l332KonZ006555@dev.open-bio.org> gordonp Mon Apr 2 22:20:50 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-serv6524/src/main/ca/ucalgary/seahawk/resources/images Added Files: tabclose.gif tabclose_d.gif Log Message: Icon support for Seahawk tabs augmented to include close icon moby-live/Java/src/main/ca/ucalgary/seahawk/resources/images tabclose.gif,NONE,1.1 tabclose_d.gif,NONE,1.1 From gordonp at dev.open-bio.org Mon Apr 2 22:22:57 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 2 Apr 2007 22:22:57 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704030222.l332Mvde006640@dev.open-bio.org> gordonp Mon Apr 2 22:22:56 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client In directory dev.open-bio.org:/tmp/cvs-serv6605/src/main/org/biomoby/client Modified Files: MobyRequest.java Log Message: Added support for asynchronous service calls moby-live/Java/src/main/org/biomoby/client MobyRequest.java,1.23,1.24 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java 2007/03/30 21:17:27 1.23 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java 2007/04/03 02:22:56 1.24 @@ -121,6 +121,7 @@ debugPS.println("Syntax error encountered while compiling XPath " + "statements for internal use (code bug?): " + te); } + setDebugMode(System.getProperty("moby.debug") != null); } /** @@ -317,17 +318,17 @@ } } - // Parse and merge the new data into the existing contents - InputStream resultStream = AsyncClient.getResultStream(epr, newDataAvailable); - Element mobyDOM = asyncSoapTextToMobyDOM(resultStream); - MobyContentInstance newResults = MobyDataUtils.fromXMLDocument(mobyDOM); - // The merge - for(String jobid: newResults.keySet()){ - finalContents.put(jobid, newResults.get(jobid)); - } - - // Inform the handler that some data has been added to the response (for incremental display?) if(newDataAvailable.size() > 0 && handler != null){ + // Parse and merge the new data into the existing contents + InputStream resultStream = AsyncClient.getResultStream(epr, newDataAvailable); + Element mobyDOM = asyncSoapTextToMobyDOM(resultStream); + MobyContentInstance newResults = MobyDataUtils.fromXMLDocument(mobyDOM); + // The merge + for(String jobid: newResults.keySet()){ + finalContents.put(jobid, newResults.get(jobid)); + } + + // Inform the handler that some data has been added to the response (for incremental display?) MobyRequestEvent mre = new MobyRequestEvent(finalContents, this, null, requestId); StringWriter xmlWriter = new StringWriter(); MobyDataUtils.toXMLDocument(xmlWriter, finalContents); From gordonp at dev.open-bio.org Mon Apr 2 22:27:33 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 2 Apr 2007 22:27:33 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704030227.l332RXsx006685@dev.open-bio.org> gordonp Mon Apr 2 22:27: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-serv6650/src/main/org/biomoby/shared/data Modified Files: MobyDataDateTime.java Log Message: Belatedly made DateTime inherit directly from Object, since it's a primitive (it wasn't a couple of years ago when I first committed this class) moby-live/Java/src/main/org/biomoby/shared/data MobyDataDateTime.java,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataDateTime.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/MobyDataDateTime.java 2006/07/07 04:12:40 1.6 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataDateTime.java 2007/04/03 02:27:33 1.7 @@ -10,20 +10,23 @@ import java.util.TimeZone; /** - * A class representing a MOBY DateTime. - * DateTime is not a primitive in MOBY, but this is a useful utility - * class parses and outputs dates and times in proper ISO 8601 format + * A class representing a MOBY DateTime, which is a primitive in MOBY. + * This is a useful utility + * class that parses and outputs dates and times in proper ISO 8601 format * as required by the MOBY object description. * * For a description of ISO 8601 as used on the Web, see * http://www.w3.org/TR/NOTE-datetime * * Because getObject() will return a mutable GregorianCalendar, you can use - * its methods to modify the underlying date of this MOBY object. + * its methods to modify the underlying date of this MOBY object. Since it + * is a Gregorian calendar, if you + * are representing dates before September 14th, 1752, I guarantee nothing. * + * @author Paul Gordon */ -public class MobyDataDateTime extends MobyDataString{ +public class MobyDataDateTime extends MobyDataObject{ private GregorianCalendar value; @@ -285,7 +288,7 @@ } public Object clone(){ - MobyDataString copy = new MobyDataDateTime(getName(), getValue()); + MobyDataDateTime copy = new MobyDataDateTime(getName(), getValue()); copy.setDataType(getDataType()); copy.setId(getId()); copy.setNamespaces(getNamespaces()); From gordonp at dev.open-bio.org Mon Apr 2 22:29:54 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 2 Apr 2007 22:29:54 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704030229.l332TsUC006753@dev.open-bio.org> gordonp Mon Apr 2 22:29:54 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services In directory dev.open-bio.org:/tmp/cvs-serv6718/src/main/ca/ucalgary/seahawk/services Modified Files: MobyClient.java Log Message: Flanking whitespace processing for rules, plus disabled isAlive() check until we can do it more efficiently moby-live/Java/src/main/ca/ucalgary/seahawk/services MobyClient.java,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.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/MobyClient.java 2007/03/21 16:23:43 1.7 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java 2007/04/03 02:29:54 1.8 @@ -54,6 +54,7 @@ public static final String WHITESPACE_ATTR = "whitespace"; public static final String WHITESPACE_ATTR_STRIP_VAL = "strip"; 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 ENCODING_ATTR = "encoding"; public static final String ENCODING_ATTR_BASE64_VAL = "Base64"; @@ -395,10 +396,12 @@ } else if(!memberWhitespaceSetting.equals(WHITESPACE_ATTR_KEEP_VAL) && !memberWhitespaceSetting.equals(WHITESPACE_ATTR_NORMALIZE_VAL) && + !memberWhitespaceSetting.equals(WHITESPACE_ATTR_STRIP_FLANKING_VAL) && !memberWhitespaceSetting.equals(WHITESPACE_ATTR_STRIP_VAL)){ System.err.println("Object member " + memberNameKey + " has an unrecognized value for the " + WHITESPACE_ATTR + - " attribute, overriding with default of " + WHITESPACE_ATTR_KEEP_VAL); + " attribute (" + memberWhitespaceSetting + + "), overriding with default of " + WHITESPACE_ATTR_KEEP_VAL); memberWhitespaceSetting = WHITESPACE_ATTR_KEEP_VAL; } String memberEncodingSetting = memTag.getAttribute(ENCODING_ATTR); @@ -890,16 +893,20 @@ for(int i = 0; i < mdos.length; i++){ MobyService templateServices = new MobyService(""); templateServices.addInput(mdos[i]); + // Normally category is "moby", which excludes async services. + // Turn it into a wildcard instead by making the template category blank + templateServices.setCategory(""); MobyService[] mService = c.findService(templateServices); Vector filteredServices = new Vector(); // Let's make sure all of the services have their service type properly instantiated // for ontology checks later on for(int j = 0; j < mService.length; j++){ - MobyService service = MobyService.getService(mService[j].getName(), mService[j].getAuthority()); - if(service != null){ - mService[j] = service; - } + // Paul: commenting out is temporary until we can fetch the services more quickly + //MobyService service = MobyService.getService(mService[j].getName(), mService[j].getAuthority()); + //if(service != null){ + //mService[j] = service; + //} mService[j].setServiceType(MobyServiceType.getServiceType(mService[j].getServiceType().getName())); if(serviceLevel != MobyService.UNCHECKED){ @@ -911,7 +918,8 @@ } } - if(serviceLevel != MobyService.UNCHECKED){ + // Paul: false is temporary until we can fetch the services more quickly (and check isAlive) + if(false && serviceLevel != MobyService.UNCHECKED){ mService = (MobyService []) filteredServices.toArray(new MobyService[filteredServices.size()]); } From gordonp at dev.open-bio.org Mon Apr 2 22:30:36 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 2 Apr 2007 22:30:36 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704030230.l332UapC006796@dev.open-bio.org> gordonp Mon Apr 2 22:30:36 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services In directory dev.open-bio.org:/tmp/cvs-serv6761/src/main/ca/ucalgary/seahawk/services Modified Files: MobyComplexBuilder.java Log Message: Flanking whitespace processing for rules, start of implicit iteration code for HAS rules moby-live/Java/src/main/ca/ucalgary/seahawk/services MobyComplexBuilder.java,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyComplexBuilder.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/MobyComplexBuilder.java 2007/03/12 14:38:38 1.3 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyComplexBuilder.java 2007/04/03 02:30:36 1.4 @@ -148,10 +148,19 @@ for(int i = 0; i < children.length; i++){ String memberName = children[i].getName(); String[] resultSpec = (String[]) memberRules.get(memberName); + MobyRelationship memberRelationship = mobyDataType.getChild(memberName); String result = resultSpec[0]; byte[] resultBytes = result.getBytes(); String whitespaceMode = resultSpec[1]; String encodingMode = resultSpec[2]; + + // 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){ + + } + // else is iHASA, scalar context boolean nonBasic = result.length() != 2 || result.indexOf("$") != 0; MobyPrefixResolver.MobyNodeList nodeList = new MobyPrefixResolver.MobyNodeList(); @@ -192,6 +201,9 @@ else if(whitespaceMode.equals(MobyClient.WHITESPACE_ATTR_STRIP_VAL)){ varValue = varValue.replaceAll("\\s+",""); } + else if(whitespaceMode.equals(MobyClient.WHITESPACE_ATTR_STRIP_FLANKING_VAL)){ + varValue = varValue.trim(); // removes leading and trailing whitespace + } result = result.replaceAll("\\$"+j, varValue); // Binary data and XPath are incompatible, since many bytes are not allowed in XML @@ -201,12 +213,12 @@ } if(encodingMode.equals(MobyClient.ENCODING_ATTR_BASE64_VAL)){ - (new Exception("Base 64 encoding")).printStackTrace(); + //(new Exception("Base 64 encoding")).printStackTrace(); result = org.apache.axis.encoding.Base64.encode(data == null ? result.getBytes() : resultBytes); } else{ - System.err.println("NO BASE64 (" + MobyClient.ENCODING_ATTR_BASE64_VAL + - ") ENCODING for " +memberName+": " + encodingMode); + //System.err.println("NO BASE64 (" + MobyClient.ENCODING_ATTR_BASE64_VAL + + // ") ENCODING for " +memberName+": " + encodingMode); } // If the value contains anything other than $#, treat it as a XPath expression From gordonp at dev.open-bio.org Mon Apr 2 22:31:29 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 2 Apr 2007 22:31:29 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704030231.l332VTnH006841@dev.open-bio.org> gordonp Mon Apr 2 22:31:29 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-serv6806/src/main/ca/ucalgary/seahawk/resources/images Modified Files: document.gif Log Message: Made background transparent moby-live/Java/src/main/ca/ucalgary/seahawk/resources/images document.gif,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/images/document.gif,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 Binary files /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/images/document.gif 2006/10/25 02:33:22 1.1 and /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/images/document.gif 2007/04/03 02:31:29 1.2 differ rcsdiff: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/images/document.gif: diff failed From gordonp at dev.open-bio.org Mon Apr 2 22:32:15 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 2 Apr 2007 22:32:15 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704030232.l332WFu2006884@dev.open-bio.org> gordonp Mon Apr 2 22:32:14 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-serv6849/src/main/ca/ucalgary/seahawk/gui/test Modified Files: SeahawkTestCase.java Log Message: Refactoring, plus addition of asynchronous service test case moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test SeahawkTestCase.java,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test/SeahawkTestCase.java,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/gui/test/SeahawkTestCase.java 2007/02/08 16:59:58 1.4 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test/SeahawkTestCase.java 2007/04/03 02:32:14 1.5 @@ -37,6 +37,7 @@ private final static String TEST_MOBY_XML = "ca/ucalgary/seahawk/gui/test/allDataTypes.xml"; private final static String TEST_EXTERNAL_URL = "http://www.google.com/"; private final static String TEST_DNA_SEQ = "AAGCTTGGCCAACGTAAATCTTTCGGCGGCA"; + private final static String TEST_AA_SEQ = "MPGGFILAIDEGTTSARAIIYNQDLEVLGIGQYDFPQHYPSP"; private JFCTestHelper helper = null; @@ -156,7 +157,7 @@ dnaDataType, clipSet.getDataType()); // add an object of another type (AminoAcidSequence) - MobyDataObject mobyObject3 = MobyUtils.createMobySequence("MPGGFILAIDEGTTSARAIIY", "baz"); + MobyDataObject mobyObject3 = MobyUtils.createMobySequence(TEST_AA_SEQ, "baz"); clipSet = contentGUI.addToClipboard(mobyObject3); assertNotNull("The clipboard is null, but should be initialized, with two objects", clipSet); assertTrue("The clipboard contains the wrong number (" + clipSet.size() + ") of items, expected 3", @@ -569,9 +570,9 @@ public void testCloseOtherTabs(){ } - public void testRunServices() throws Exception{ + public void findService(String sequenceData, String targetMenuText, String targetServiceLabelText) throws Exception{ // load a dna sequence in a tab - MobyDataObject mobyObject = MobyUtils.createMobySequence(TEST_DNA_SEQ, "foo"); + MobyDataObject mobyObject = MobyUtils.createMobySequence(sequenceData, "foo"); contentGUI.loadPaneFromObject(new MobyContentInstance(mobyObject, "hyperlink-test"), true); //true = load in new tab // give the JVM time to paint the new data @@ -584,8 +585,9 @@ String text = pane.getDocument().getText(0, pane.getDocument().getLength()); // Find the position of the first XPointer link (should be a reference // to the file version of the DNASequence we created above) - int hyperlinkModelIndex = text.indexOf("DNASequence"); - assertFalse("Could not find a MOBY link in the DNASequence representation", hyperlinkModelIndex == -1); + String dataType = mobyObject.getDataType().getName(); + int hyperlinkModelIndex = text.indexOf(dataType); + assertFalse("Could not find a MOBY link in the "+dataType+" representation", hyperlinkModelIndex == -1); try{ Rectangle linkPos = pane.modelToView(hyperlinkModelIndex+4); @@ -601,7 +603,8 @@ } Robot robot = new Robot(); - robot.mouseMove(screenPos.x, screenPos.y); + robot.mouseMove(screenPos.x, screenPos.y+10); + sleep(1000); robot.mousePress(InputEvent.BUTTON1_MASK); robot.mouseRelease(InputEvent.BUTTON1_MASK); sleep(2000); @@ -614,7 +617,7 @@ openPopup instanceof JPopupMenu); // Move the mouse a bit to the right to bring up the submenu - robot.mouseMove(screenPos.x+10, screenPos.y); + robot.mouseMove(screenPos.x+10, screenPos.y+8); // Find a submenu with services Component serviceTypeChoices = getSubComponentByName((JPopupMenu) openPopup, @@ -631,7 +634,7 @@ JMenuItem serviceTypeChosen = ((JMenu) serviceTypeChoices).getItem(1); for(int i = 2; - serviceTypeChosen.getText().indexOf("Analysis") == -1 && + serviceTypeChosen.getText().indexOf(targetMenuText) == -1 && i <= ((JMenu) serviceTypeChoices).getItemCount(); i++){ if(i == ((JMenu) serviceTypeChoices).getItemCount()){ @@ -649,64 +652,55 @@ sleep(1000); serviceTypeChoices = serviceTypeChosen; - Vector servicePathChosen = findMenuItem((JMenu) serviceTypeChosen, "..."); + Vector servicePathChosen = findMenuItem((JMenu) serviceTypeChosen, targetServiceLabelText); if(servicePathChosen == null || servicePathChosen.size() == 0){ - System.err.println("WARNING: Skipping test of secondary param services, none were found ending in '...'"); - return; + throw new Exception("Cannot find a target service, "+ + "none were found ending in '"+targetServiceLabelText+"'"); } - else{ - // Make sure it's visible - showMenuItem((JMenu) serviceTypeChosen, servicePathChosen, robot); - Point serviceMenuItemLoc = servicePathChosen.lastElement().getLocationOnScreen(); //so move the mouse there too - // and click the service button - robot.mouseMove(serviceMenuItemLoc.x+2, serviceMenuItemLoc.y+2); - robot.keyPress(KeyEvent.VK_SHIFT); - robot.mousePress(InputEvent.BUTTON1_MASK); - robot.mouseRelease(InputEvent.BUTTON1_MASK); - robot.keyRelease(KeyEvent.VK_SHIFT); - //serviceChosen.doClick(300); - sleep(2000); - JDialog secondaryParamsDialog = null; + // Make sure it's visible + showMenuItem((JMenu) serviceTypeChosen, servicePathChosen, robot); + Point serviceMenuItemLoc = servicePathChosen.lastElement().getLocationOnScreen(); //so move the mouse there too + // and click the service button + robot.mouseMove(serviceMenuItemLoc.x+2, serviceMenuItemLoc.y+2); + robot.keyPress(KeyEvent.VK_SHIFT); + robot.mousePress(InputEvent.BUTTON1_MASK); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + robot.keyRelease(KeyEvent.VK_SHIFT); + //serviceChosen.doClick(300); + sleep(2000); + } - DialogFinder dfinder = new DialogFinder(".*"); - List showingDialogs = dfinder.findAll(); - for(int i = 0; i < showingDialogs.size(); i++){ - JDialog dialog = (JDialog) showingDialogs.get(i); - if(MobySecondaryInputGUI.TITLE.equals(dialog.getTitle())){ - secondaryParamsDialog = dialog; - break; - } - } + public void testRunAsynchronousService() throws Exception{ + try{ + findService(TEST_AA_SEQ, "Bioinformatics", "(async)"); + } catch(Exception e){ + e.printStackTrace(); + fail("Error while finding a service ending with \"(async)\" " + + "(asynchronous execution) under \"Bioinformatics\" in the popup"); + } - assertNotNull("Requesting a service with secondary parameters did not launch " + - "a secondary parameter input component (was null)", - secondaryParamsDialog); - assertTrue("Secondary parameter input component was not a JDialog as expected (was a " + - secondaryParamsDialog.getClass().getName(), - secondaryParamsDialog instanceof JDialog); - Component okButton = getSubComponentByName(secondaryParamsDialog.getContentPane(), - MobySecondaryInputGUI.OK_BUTTON_NAME); - assertNotNull("Could not find the OK button in the secondary input GUI dialog", okButton); - Point okLoc = okButton.getLocationOnScreen(); //so move the mouse there too - // and click the OK button - robot.mouseMove(okLoc.x+2, okLoc.y+2); - robot.mousePress(InputEvent.BUTTON1_MASK); - robot.mouseRelease(InputEvent.BUTTON1_MASK); - sleep(2000); + fillInSecondariesAndExecute(); - showingDialogs = dfinder.findAll(); - for(int i = 0; i < showingDialogs.size(); i++){ - JDialog dialog = (JDialog) showingDialogs.get(i); - if(dialog.isVisible()){ - assertFalse("The secondary parameter window did not disappear when enter was pressed (" + - "either the approval button does not have the default focus, or " + - " there is an internal problem with the dialog validation)", - MobySecondaryInputGUI.TITLE.equals(dialog.getTitle())); - } + // Wait until the job is finished to proceed to the next test + while(contentGUI.getCurrentURL() == null){ + sleep(1000); + if(contentGUI.isShowingFailure()){ + break; } - } - + sleep(2000); //just to ensure HTML rendering finishes + } + + public void testRunServiceSecondariesAndSCUFL() throws Exception{ + try{ + findService(TEST_DNA_SEQ, "Bioinformatics", "..."); + } catch(Exception e){ + e.printStackTrace(); + fail("Error while a finding service ending with \"...\" " + + "(secondary input) under \"Analysis\" in the popup"); + } + fillInSecondariesAndExecute(); + // Wait until the job is finished to proceed to the next test while(contentGUI.getCurrentURL() == null){ sleep(1000); @@ -724,6 +718,49 @@ assertTrue("The SCUFL saved data file was empty", testFile.length() != 0); } + public void fillInSecondariesAndExecute() throws Exception{ + Robot robot = new Robot(); + JDialog secondaryParamsDialog = null; + + DialogFinder dfinder = new DialogFinder(".*"); + List showingDialogs = dfinder.findAll(); + for(int i = 0; i < showingDialogs.size(); i++){ + JDialog dialog = (JDialog) showingDialogs.get(i); + if(MobySecondaryInputGUI.TITLE.equals(dialog.getTitle())){ + secondaryParamsDialog = dialog; + break; + } + } + + assertNotNull("Requesting a service with secondary parameters did not launch " + + "a secondary parameter input component (was null)", + secondaryParamsDialog); + assertTrue("Secondary parameter input component was not a JDialog as expected (was a " + + secondaryParamsDialog.getClass().getName(), + secondaryParamsDialog instanceof JDialog); + Component okButton = getSubComponentByName(secondaryParamsDialog.getContentPane(), + MobySecondaryInputGUI.OK_BUTTON_NAME); + assertNotNull("Could not find the OK button in the secondary input GUI dialog", okButton); + Point okLoc = okButton.getLocationOnScreen(); //so move the mouse there too + // and click the OK button + robot.mouseMove(okLoc.x+2, okLoc.y+2); + robot.mousePress(InputEvent.BUTTON1_MASK); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + sleep(2000); + + showingDialogs = dfinder.findAll(); + for(int i = 0; i < showingDialogs.size(); i++){ + JDialog dialog = (JDialog) showingDialogs.get(i); + if(dialog.isVisible()){ + assertFalse("The secondary parameter window did not disappear when enter was pressed (" + + "either the approval button does not have the default focus, or " + + "there is an internal problem with the dialog validation)", + MobySecondaryInputGUI.TITLE.equals(dialog.getTitle())); + } + } + + } + // Load a document, then highlight a salient section that can be turned into Web Service choices // via MobyServicesGUI. public void testHighlightOptions() throws Exception{ @@ -853,17 +890,18 @@ public static Test suite() { TestSuite suite = new TestSuite(); - suite.addTest(new SeahawkTestCase("testMain")); //done - suite.addTest(new SeahawkTestCase("testHelpTab")); //done - suite.addTest(new SeahawkTestCase("testHelpButton")); //done - suite.addTest(new SeahawkTestCase("testClipboardTab")); //done - suite.addTest(new SeahawkTestCase("testOpenButton")); //done - suite.addTest(new SeahawkTestCase("testSave")); //done - suite.addTest(new SeahawkTestCase("testPrint")); //done - suite.addTest(new SeahawkTestCase("testNavigationButtons")); //done - suite.addTest(new SeahawkTestCase("testRunServices")); //done - suite.addTest(new SeahawkTestCase("testHighlightOptions"));//done - suite.addTest(new SeahawkTestCase("testExternalBrowser"));//done + suite.addTest(new SeahawkTestCase("testMain")); //done + suite.addTest(new SeahawkTestCase("testHelpTab")); //done + suite.addTest(new SeahawkTestCase("testHelpButton")); //done + suite.addTest(new SeahawkTestCase("testClipboardTab")); //done + suite.addTest(new SeahawkTestCase("testOpenButton")); //done + suite.addTest(new SeahawkTestCase("testSave")); //done + suite.addTest(new SeahawkTestCase("testPrint")); //done + suite.addTest(new SeahawkTestCase("testNavigationButtons")); //done + suite.addTest(new SeahawkTestCase("testRunAsynchronousService")); //done + suite.addTest(new SeahawkTestCase("testRunServiceSecondariesAndSCUFL")); //done + suite.addTest(new SeahawkTestCase("testHighlightOptions"));//done + suite.addTest(new SeahawkTestCase("testExternalBrowser"));//doney return suite; } @@ -906,15 +944,19 @@ } public boolean findMenuItem(JMenu menu, String pattern, Vector result){ - JMenuItem serviceChosen = menu.getItem(0); - for(int i = 1; - serviceChosen.getText().indexOf(pattern) == -1 && i <= menu.getItemCount(); + JMenuItem serviceChosen = null; + for(int i = 0; + i <= menu.getItemCount(); i++){ if(i == menu.getItemCount()){ return false; } + + serviceChosen = menu.getItem(i); + if(serviceChosen.getText().indexOf(pattern) != -1){ + break; + } else{ - serviceChosen = menu.getItem(i); // Nested menu if(serviceChosen instanceof JMenu){ if(findMenuItem((JMenu) serviceChosen, pattern, result)){ From gordonp at dev.open-bio.org Mon Apr 2 22:33:57 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 2 Apr 2007 22:33:57 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704030233.l332XvsP006948@dev.open-bio.org> gordonp Mon Apr 2 22:33:57 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv6913/src/main/ca/ucalgary/seahawk/gui Modified Files: MobySecondaryInputGUI.java Log Message: Added paste functionality miscellanea, and better tab interaction (close icon, ctrl-T for new) moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobySecondaryInputGUI.java,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobySecondaryInputGUI.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/MobySecondaryInputGUI.java 2007/03/27 14:02:53 1.3 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobySecondaryInputGUI.java 2007/04/03 02:33:57 1.4 @@ -33,6 +33,7 @@ private Map data2widget; private ActionListener listener; private int handlerCode = 0; // callback event ID provided by caller to c-tor + private boolean showingNew = false; private static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(MobySecondaryInputGUI.class); @@ -50,6 +51,7 @@ listener = al; handlerCode = actionCommandID; setVisible(false); + showingNew = false; setName(TITLE); } @@ -166,11 +168,20 @@ pack(); toFront(); requestFocus(); + showingNew = true; confirmButton.requestFocusInWindow(); } } } + public boolean isNewShowing(){ + boolean ret = showingNew; + if(ret){ + showingNew = false; + } + return ret; + } + public Component makeWidget(MobyDataSecondaryInstance msdi){ String dataType = msdi.getDataType(); From gordonp at dev.open-bio.org Mon Apr 2 22:34:09 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 2 Apr 2007 22:34:09 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704030234.l332Y90U007007@dev.open-bio.org> gordonp Mon Apr 2 22:34:08 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv6956/src/main/ca/ucalgary/seahawk/gui Modified Files: MobyContentClipboard.java MobyContentGUI.java MobyContentPane.java MobyServicesGUI.java SplashWindow.java Log Message: Added paste functionality miscellanea, and better tab interaction (close icon, ctrl-T for new) moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyContentClipboard.java,1.2,1.3 MobyContentGUI.java,1.5,1.6 MobyContentPane.java,1.5,1.6 MobyServicesGUI.java,1.7,1.8 SplashWindow.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentClipboard.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/MobyContentClipboard.java 2007/02/08 16:59:57 1.2 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentClipboard.java 2007/04/03 02:34:08 1.3 @@ -89,6 +89,10 @@ sGUI.setClipboard(this); } + // By overriding this with a blank method body, we avoid adding a close icon to the tab + public void stateChanged(javax.swing.event.ChangeEvent ce){ + } + /** Sets up temporary files, icons, etc. */ public void init(){ int index = tabbedPane.indexOfComponent(this); =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.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/MobyContentGUI.java 2007/03/21 16:24:42 1.5 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java 2007/04/03 02:34:08 1.6 @@ -10,6 +10,7 @@ import java.util.TreeMap; import javax.swing.*; +import javax.swing.event.*; import javax.xml.transform.stream.*; import javax.xml.transform.*; @@ -28,7 +29,7 @@ * @author Paul Gordon (gordonp at ucalgary.ca) */ -public class MobyContentGUI extends JFrame implements ActionListener, ComponentListener, MobyRequestEventHandler, MouseListener{ +public class MobyContentGUI extends JFrame implements ActionListener, ComponentListener, KeyListener, MobyRequestEventHandler, MouseListener{ // Variables used to coordinate component finding with the unit test cases public final static String BACK_BUTTON_NAME = "MCGbackButton"; @@ -50,6 +51,8 @@ public final static String DEFAULT_STARTUP_PAGE_RESOURCE = "ca/ucalgary/seahawk/resources/startup.html"; public final static String DEFAULT_XSLT_CONVERTER_URL = "ca/ucalgary/seahawk/resources/moby2HTML.xsl"; public final static int MAX_TAB_NAME_LENGTH = 25; + public final static String CLIPBOARD_TAB_TOOLTIP = "Right-click for clipboard options"; + public final static String TAB_TOOLTIP = "Right-click for tab options, or Ctrl-T for new tab"; public final static String CLOSE_TAB_OPTION = "Close This Tab"; public final static String CLOSE_OTHERS_OPTION = "Close Other Tabs"; public final static String FILE_OPEN_OPTION = "Open File"; @@ -176,6 +179,8 @@ // See OptionsTabbedPaneUI class definiton at the end of this file (overrides right-click behaviour) tabbedPane.setUI(new OptionsTabbedPaneUI(this)); tabbedPane.setSize(getContentSize()); + tabbedPane.setToolTipText("Hit to display a new tab"); + tabbedPane.addKeyListener(this); clipboard = new MobyContentClipboard(this, servicesGUI, @@ -185,6 +190,18 @@ } + public boolean allTabsVisible(){ + if(tabbedPane.getTabLayoutPolicy() == JTabbedPane.WRAP_TAB_LAYOUT){ + return true; + } + for(int i = 0; i < tabbedPane.getTabCount(); i++){ + if(tabbedPane.getBoundsAt(i) == null){ + return false; //bounds null if not showing on screen + } + } + return true; + } + public JPanel getToolbar(){ return statusPanel; } @@ -205,6 +222,24 @@ } /** + * 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 + * paste events. + */ + public void keyPressed(KeyEvent e){ + // Ctrl-T for new tab, like regular Web browsers + if(e.getKeyCode() == KeyEvent.VK_T && e.isControlDown()){ + MobyContentPane tab = createTab("New Tab"); + tabbedPane.setSelectedComponent(tab); + tab.getDisplay().setText("Use the file/globe icon at the bottom of this window to load data," + + "or drag'n'drop/paste data from your desktop or Web browser."); + } + } + + public void keyReleased(KeyEvent e){} + public void keyTyped(KeyEvent e){} + + /** * This method sets the layout, basic GUI elements, * initializes conditions, and so on so it'll be ready to go when gotoURL is called * to load a MOBY document for the first time. @@ -245,6 +280,10 @@ setVisible(true); tabbedPane.add(clipboard); + int clipboardIndex = tabbedPane.indexOfComponent(clipboard); + if(clipboardIndex != -1){ + tabbedPane.setToolTipTextAt(clipboardIndex, CLIPBOARD_TAB_TOOLTIP); + } clipboard.setPreferredSize(getContentSize()); clipboard.init(); setup = true; @@ -271,6 +310,10 @@ setVisible(true); tab.setPreferredSize(getContentSize()); tabbedPane.addTab(title, tab); + int tabIndex = tabbedPane.indexOfComponent(tab); + if(tabIndex != -1){ + tabbedPane.setToolTipTextAt(tabIndex, TAB_TOOLTIP); + } return tab; } @@ -792,7 +835,7 @@ item.addActionListener(gui); tabOptions.add(item); } - else{ + else if(tabbedPane.getTabCount() > 1){ item = new JMenuItem(MobyContentGUI.CLOSE_TAB_OPTION); item.setActionCommand(MobyContentGUI.CLOSE_TAB_OPTION); item.addActionListener(gui); @@ -861,16 +904,19 @@ new Thread(){ public void run(){org.biomoby.shared.MobyDataType.getDataType("Object");} }.start(); - // And the service definitions new Thread(){ - public void run(){org.biomoby.shared.MobyService.getService("","");} + 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(); MobyContentGUI gui = ca.ucalgary.seahawk.util.MobyUtils.getMobyContentGUI(new JLabel()); gui.setDefaultCloseOperation(defaultCloseOperation); gui.setVisible(true); - if(argv.length != 0){ + if(argv.length != 0 && argv[0] != null && argv[0].length() != 0){ try{ gui.loadPaneFromURL(new URL(argv[0]), true); } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.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/MobyContentPane.java 2007/03/23 20:22:52 1.5 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java 2007/04/03 02:34:08 1.6 @@ -19,9 +19,7 @@ import org.apache.xpath.*; import org.apache.xpath.objects.*; -import ca.ucalgary.seahawk.util.DynamicJPopupMenu; -import ca.ucalgary.seahawk.util.PrintableJEditorPane; -import ca.ucalgary.seahawk.util.MobyUtils; +import ca.ucalgary.seahawk.util.*; import javax.swing.*; import javax.swing.event.*; @@ -41,15 +39,17 @@ * Also provides link handling (including service options popup) and drag 'n' drop capabilities. */ -public class MobyContentPane extends JPanel implements Printable, CaretListener, HyperlinkListener, MouseListener, MobyRequestEventHandler, KeyListener{ +public class MobyContentPane extends JPanel implements Printable, CaretListener, HyperlinkListener, MouseListener, MobyRequestEventHandler, KeyListener, ChangeListener{ public static final String MOBY_SERVICE_POPUP_NAME = "seahawkServicePopup"; public static final String WAITING_TAB_ICON_RESOURCE = "ca/ucalgary/seahawk/resources/images/hourglass.gif"; public static final String FAILED_TAB_ICON_RESOURCE = "ca/ucalgary/seahawk/resources/images/failed.gif"; public static final String LOADED_TAB_ICON_RESOURCE = "ca/ucalgary/seahawk/resources/images/document.gif"; + private static final int TAB_ICON_SPACER = 2; private static ImageIcon hourglassIcon; private static ImageIcon failedIcon; private static ImageIcon loadedIcon; + private static ImageIcon closeIcon; /** The name of the param in the stylesheet that will hold the Moby doc URL for XPointer usage */ public final static String XSL_DOC_SOURCE_PARAM = "sourceURL"; @@ -83,6 +83,8 @@ addKeyListener(this); setTransferHandler(new FileAndTextTransferHandler(cGUI)); + tabbedPane.addChangeListener(this); + // The following is a non-user editable pane for showing HTML editorPane = new PrintableJEditorPane(); editorPane.addKeyListener(this); @@ -131,6 +133,35 @@ } } + public void stateChanged(ChangeEvent ce){ + int tabIndex = tabbedPane.indexOfComponent(this); + Icon currentIcon = tabIndex < 0 ? null : tabbedPane.getIconAt(tabIndex); + if(tabIndex == tabbedPane.getSelectedIndex() && + tabbedPane.getTabCount() > 1){ + try{ + if(currentIcon == null){ + tabbedPane.setIconAt(tabIndex, new CloseTabIcon()); + return; + } + // If there's a real (non-close-tab) single icon, add the close tab icon + if(!(currentIcon instanceof CloseTabIcon)){ + try{tabbedPane.setIconAt(tabIndex, new CloseTabIcon(currentIcon, TAB_ICON_SPACER));} + catch(Exception e){e.printStackTrace();} + tabbedPane.setDisabledIconAt(tabIndex, currentIcon); + } + } + catch(Exception e){ + e.printStackTrace(); + } + + } else{ + if(currentIcon != null && currentIcon instanceof CloseTabIcon){ + tabbedPane.setIconAt(tabIndex, ((CloseTabIcon) currentIcon).getSecondIcon()); + tabbedPane.setDisabledIconAt(tabIndex, ((CloseTabIcon) currentIcon).getSecondIcon()); + } + } + } + public void setPreferredSize(Dimension dims){ super.setPreferredSize(dims); scrollPane.setPreferredSize(dims); @@ -370,8 +401,19 @@ } public void failed(String msg){ - tabbedPane.setIconAt(tabbedPane.indexOfComponent(this), failedIcon); - tabbedPane.setTitleAt(tabbedPane.indexOfComponent(this), msg); + int tabIndex = tabbedPane.indexOfComponent(this); + if(tabIndex > -1){ + try{tabbedPane.setIconAt(tabIndex, + new CloseTabIcon(failedIcon, TAB_ICON_SPACER));} + catch(Exception e){e.printStackTrace(); + tabbedPane.setIconAt(tabIndex, failedIcon);} + } + else{ + tabbedPane.setIconAt(tabIndex, failedIcon); + } + tabbedPane.setDisabledIconAt(tabIndex, failedIcon); + + tabbedPane.setTitleAt(tabIndex, msg); // Add the ability to back track from the error to the previous document if(historyIndex != -1){ historyIndex++; @@ -382,8 +424,18 @@ } public void succeeded(String msg){ - tabbedPane.setIconAt(tabbedPane.indexOfComponent(this), loadedIcon); - tabbedPane.setTitleAt(tabbedPane.indexOfComponent(this), msg); + int tabIndex = tabbedPane.indexOfComponent(this); + if(tabIndex > -1 && tabbedPane.getTabCount() > 1){ + try{tabbedPane.setIconAt(tabIndex, + new CloseTabIcon(loadedIcon, TAB_ICON_SPACER));} + catch(Exception e){e.printStackTrace(); + tabbedPane.setIconAt(tabIndex, loadedIcon);} + } + else{ + tabbedPane.setIconAt(tabIndex, loadedIcon); + } + tabbedPane.setDisabledIconAt(tabIndex, loadedIcon); + tabbedPane.setTitleAt(tabIndex, msg); // Store the latest title for the URL loaded, in case we revisit historyTabLabels.put(history.elementAt(historyIndex), msg); hasFailed = false; @@ -685,7 +737,17 @@ // Set the icon for the tab to an hourglass if(tabbedPane != null){ - tabbedPane.setIconAt(tabbedPane.indexOfComponent(this), hourglassIcon); + int tabIndex = tabbedPane.indexOfComponent(this); + if(tabIndex > -1){ + try{tabbedPane.setIconAt(tabIndex, + new CloseTabIcon(hourglassIcon, TAB_ICON_SPACER));} + catch(Exception e){e.printStackTrace(); + tabbedPane.setIconAt(tabIndex, hourglassIcon);} + } + else{ + tabbedPane.setIconAt(tabIndex, hourglassIcon); + } + tabbedPane.setDisabledIconAt(tabIndex, hourglassIcon); } } @@ -885,6 +947,15 @@ * like Control-v to paste. */ public void mouseEntered(MouseEvent e){ + // There is one situation where we *don't* want to take the focus, when + // the secondary parameter dialog has just been displayed. We get a mouseEntered + // callback when the popup menu used to select the service disappears, + // and the secondary parameter dialog gets hidden behind the main window where + // the user can't see it! + if(servicesGUI.isSecondaryParamDialogNew()){ + return; + } + if(!requestFocusInWindow()){ requestFocus(); } @@ -1072,17 +1143,22 @@ } /** - * Implemented to provide paste functonality (control-v or the paste button on a Sun keyboard), + * 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 * paste events. */ public void keyPressed(KeyEvent e){ - System.err.println("Key pressed " + e.getKeyChar()); if(e.getKeyCode() == KeyEvent.VK_PASTE || e.getKeyCode() == KeyEvent.VK_V && e.isControlDown()){ - System.err.println("Paste (pressed)!"); paste(); } + // Ctrl-T for new tab, like regular Web browsers + if(e.getKeyCode() == KeyEvent.VK_T && e.isControlDown()){ + MobyContentPane tab = contentGUI.createTab("New Tab"); + tabbedPane.setSelectedComponent(tab); + tab.getDisplay().setText("Use the file/globe icon at the bottom of this window to load data," + + "or drag'n'drop/paste data from your desktop or Web browser."); + } } public void keyReleased(KeyEvent e){} =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyServicesGUI.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/MobyServicesGUI.java 2007/02/08 16:59:57 1.7 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyServicesGUI.java 2007/04/03 02:34:08 1.8 @@ -218,6 +218,13 @@ public void popupMenuWillBecomeVisible(PopupMenuEvent e){ } + public boolean isSecondaryParamDialogNew(){ + if(secondaryGUI == null){ + return false; + } + return secondaryGUI.isNewShowing(); + } + /** * Launches a dialog that the user can configure secondary parameters in, * or tries to fill in and use all defaults if valid and useDefaults is specified. @@ -925,7 +932,7 @@ // Visual indicate secondary input usage in the service with an ellipsis at the end of the name JMenuItem mobyItem = new JMenuItem("Run " + service.getName() + - (hasSecondaryInput(service) ? "..." : "")); + (hasSecondaryInput(service) ? "..." : "")+(service.isAsynchronous() ? "(async)":"")); mobyItem.setActionCommand("MOBY:"+dataIndex+":"+serviceIndex+(handler == null ? "" : ":"+handler.hashCode())); mobyItem.addActionListener(this); String sdesc = "No description provided"; =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/SplashWindow.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/SplashWindow.java 2006/10/25 13:54:50 1.2 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/SplashWindow.java 2007/04/03 02:34:08 1.3 @@ -251,6 +251,7 @@ // Show the window. instance.setVisible(true); + instance.toFront(); // Note: To make sure the user gets a chance to see the // splash window we wait until its paint method has been From gordonp at dev.open-bio.org Mon Apr 2 22:37:43 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 2 Apr 2007 22:37:43 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704030237.l332bh6A007091@dev.open-bio.org> gordonp Mon Apr 2 22:37:43 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources In directory dev.open-bio.org:/tmp/cvs-serv7056/src/main/ca/ucalgary/seahawk/resources Modified Files: mobyBuilderRules.xml Log Message: Added PMID and DOI parsing rules moby-live/Java/src/main/ca/ucalgary/seahawk/resources mobyBuilderRules.xml,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/mobyBuilderRules.xml,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/mobyBuilderRules.xml 2006/12/14 19:38:34 1.2 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/mobyBuilderRules.xml 2007/04/03 02:37:43 1.3 @@ -4,6 +4,39 @@ http://www.bioxml.info/dtd/tigrxml.dtd http://www.bioxml.info/dtd/Bioseq.dtd + + + (?:GI|gi)[|:](\d+) + substring-before(substring-after(self::tigr:TU//tigr:ACCESSION/@DBXREF, 'gi|'), '|') + + $1 + + + + + + (?:PMID|pmid):?\s*(\d{5,}) + + $1 + + + + + + (?:DOI|doi):?\s*(10\.\d+/[^%"\# \t\r\n]+) + + $1 + + + + + + (?:\s|\A|/)(10\.\d+/[A-Za-z]+[^%"\# \t\r\n]+) + + $1 + + + \s*(LOCUS\s+(\S+)(?:.*|\n)+?\n//(?:\n|$)) @@ -28,15 +61,6 @@ - - - (?:GI|gi)[|:](\d+) - substring-before(substring-after(self::tigr:TU//tigr:ACCESSION/@DBXREF, 'gi|'), '|') - - $1 - - - From gordonp at dev.open-bio.org Mon Apr 2 22:39:52 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 2 Apr 2007 22:39:52 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704030239.l332dqgd007178@dev.open-bio.org> gordonp Mon Apr 2 22:39:51 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/test In directory dev.open-bio.org:/tmp/cvs-serv7142/src/main/org/biomoby/client/test Modified Files: AsyncClientTestCase.java Added Files: TestAASeq.xml Removed Files: TestFASTACollection.xml Log Message: Updated test case service to run, and made a hard timeout too moby-live/Java/src/main/org/biomoby/client/test TestAASeq.xml,NONE,1.1 AsyncClientTestCase.java,1.1,1.2 TestFASTACollection.xml,1.1,NONE =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/test/AsyncClientTestCase.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/test/AsyncClientTestCase.java 2007/03/30 21:17:27 1.1 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/test/AsyncClientTestCase.java 2007/04/03 02:39:51 1.2 @@ -18,10 +18,11 @@ import java.util.Set; public class AsyncClientTestCase extends TestCase{ - private final static String TEST_INPUT_RESOURCE = "org/biomoby/client/test/TestFASTACollection.xml"; - private final static String TEST_SERVICE_NAME = "runClustalwFast"; - private final static String TEST_SERVICE_AUTHORITY = "inb.bsc.es"; + private final static String TEST_INPUT_RESOURCE = "org/biomoby/client/test/TestAASeq.xml"; + private final static String TEST_SERVICE_NAME = "runFunCUT"; + private final static String TEST_SERVICE_AUTHORITY = "cnio.es"; private final static int POLLING_WAITTIME_MS = 5000; // ms between checks to see if the job is done + private final static int MAX_WAITTIME_MS = 600000; // allow 10 minutes for the service to run /** * @param name Test case name. @@ -92,12 +93,17 @@ assertNotNull("Could not load the test data (" + dataURL + ")", data); for(MobyDataJob job: data.values()){ + String jobKeys = ""; + for(String key: job.keySet()){ + jobKeys += key + " "; + } + for(MobyPrimaryData input: inputs){ if(!job.containsKey(input.getName())){ System.err.println("Test Input Data: " + job); fail("The service requires an input ("+input.getName() + ") that was not provided in the test input data (" + - dataURL + ")"); + dataURL + "). The provided input: "+jobKeys); } if(!(job.get(input.getName()) instanceof MobyPrimaryData)){ System.err.println("Test Input Data: " + job); @@ -128,18 +134,28 @@ fail("Exception while sending request to service: " + e); } + long startTime = System.currentTimeMillis(); // Essentially cloning, so removing ids doesn't change the // MobyContentInstance "data" (which we will use again later on) Set queryIDs = new HashSet(data.keySet()); try { - // Should add some timeout here... while(!queryIDs.isEmpty()){ + if(System.currentTimeMillis()-startTime > MAX_WAITTIME_MS){ + destroyEPR(epr); + fail("The service ("+serviceName + + ") took longer than the maximum allowed time to execute ("+ + MAX_WAITTIME_MS+"ms)"); + } + Thread.sleep(POLLING_WAITTIME_MS); AnalysisEvent[] events = AsyncClient.poll(epr, queryIDs); for(AnalysisEvent event: events){ - if(event != null && event.isCompleted()){ - queryIDs.remove(event.getQueryId()); + if(event != null){ + System.err.println("Event: " + event); + if(event.isCompleted()){ + queryIDs.remove(event.getQueryId()); + } } } } rcsdiff: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/test/RCS/TestFASTACollection.xml,v: No such file or directory From gordonp at dev.open-bio.org Mon Apr 2 22:42:23 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 2 Apr 2007 22:42:23 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704030242.l332gN3J007221@dev.open-bio.org> gordonp Mon Apr 2 22:42:23 EDT 2007 Update of /home/repository/moby/moby-live/Java/docs In directory dev.open-bio.org:/tmp/cvs-serv7186/docs Modified Files: ChangeLog Log Message: Async client support + Seahawk UI updates noted moby-live/Java/docs ChangeLog,1.75,1.76 =================================================================== RCS file: /home/repository/moby/moby-live/Java/docs/ChangeLog,v retrieving revision 1.75 retrieving revision 1.76 diff -u -r1.75 -r1.76 --- /home/repository/moby/moby-live/Java/docs/ChangeLog 2006/11/21 13:04:15 1.75 +++ /home/repository/moby/moby-live/Java/docs/ChangeLog 2007/04/03 02:42:23 1.76 @@ -1,3 +1,9 @@ +2007-04-02 Paul Gordon + + * Added asynchronous service call support to MobyRequest, Seahawk, based on client code originally provided by Eddie Kawas. + + * UI updates to Seahawk for tab management and drag 'n' drop/paste functionality + 2006-11-21 Martin Senger * Added 'Released-Date' tag to joMby jar files From gordonp at dev.open-bio.org Tue Apr 3 21:29:20 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Tue, 3 Apr 2007 21:29:20 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704040129.l341TKVK009378@dev.open-bio.org> gordonp Tue Apr 3 21:29:20 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-serv9342/src/main/ca/ucalgary/seahawk/gui/test Modified Files: SeahawkTestCase.java Log Message: Mouse movement tweaks for more robust popup usage, check if async service also has secondary params moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test SeahawkTestCase.java,1.5,1.6 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test/SeahawkTestCase.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/test/SeahawkTestCase.java 2007/04/03 02:32:14 1.5 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test/SeahawkTestCase.java 2007/04/04 01:29:20 1.6 @@ -570,7 +570,8 @@ public void testCloseOtherTabs(){ } - public void findService(String sequenceData, String targetMenuText, String targetServiceLabelText) throws Exception{ + // returns the text label of the service menu item invoked + public String findService(String sequenceData, String targetMenuText, String targetServiceLabelText) throws Exception{ // load a dna sequence in a tab MobyDataObject mobyObject = MobyUtils.createMobySequence(sequenceData, "foo"); contentGUI.loadPaneFromObject(new MobyContentInstance(mobyObject, "hyperlink-test"), true); //true = load in new tab @@ -617,7 +618,7 @@ openPopup instanceof JPopupMenu); // Move the mouse a bit to the right to bring up the submenu - robot.mouseMove(screenPos.x+10, screenPos.y+8); + robot.mouseMove(screenPos.x+10, screenPos.y+10); // Find a submenu with services Component serviceTypeChoices = getSubComponentByName((JPopupMenu) openPopup, @@ -668,18 +669,23 @@ robot.keyRelease(KeyEvent.VK_SHIFT); //serviceChosen.doClick(300); sleep(2000); + + return servicePathChosen.elementAt(servicePathChosen.size()-1).getText(); } public void testRunAsynchronousService() throws Exception{ + String serviceLabel = null; try{ - findService(TEST_AA_SEQ, "Bioinformatics", "(async)"); + serviceLabel = findService(TEST_AA_SEQ, "Bioinformatics", "(async)"); } catch(Exception e){ e.printStackTrace(); fail("Error while finding a service ending with \"(async)\" " + "(asynchronous execution) under \"Bioinformatics\" in the popup"); } - fillInSecondariesAndExecute(); + if(serviceLabel.indexOf("...") != 0){ + fillInSecondariesAndExecute(); + } // Wait until the job is finished to proceed to the next test while(contentGUI.getCurrentURL() == null){ @@ -811,6 +817,7 @@ robot.mouseMove(screenEndPos.x, screenEndPos.y); robot.mouseRelease(InputEvent.BUTTON1_MASK); sleep(1000); + robot.mouseMove(screenEndPos.x+2, screenEndPos.y+2); robot.mousePress(InputEvent.BUTTON1_MASK); robot.mouseRelease(InputEvent.BUTTON1_MASK); sleep(2000); From gordonp at dev.open-bio.org Tue Apr 3 21:31:38 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Tue, 3 Apr 2007 21:31:38 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704040131.l341Vc0F009446@dev.open-bio.org> gordonp Tue Apr 3 21:31:38 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services In directory dev.open-bio.org:/tmp/cvs-serv9410/src/main/ca/ucalgary/seahawk/services Modified Files: MobyClient.java Log Message: Temporarily adding a call to Eddie's ValidateService applet as a substitute for isAlive metadata check (much, much faster) moby-live/Java/src/main/ca/ucalgary/seahawk/services MobyClient.java,1.8,1.9 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.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/MobyClient.java 2007/04/03 02:29:54 1.8 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java 2007/04/04 01:31:38 1.9 @@ -22,7 +22,7 @@ import javax.xml.parsers.*; -import java.io.File; +import java.io.*; import java.net.URL; import java.net.MalformedURLException; import java.util.*; @@ -60,9 +60,11 @@ public static final String ENCODING_ATTR_BASE64_VAL = "Base64"; public static final String ENCODING_ATTR_NONE_VAL = "none"; public static final String SINGLE_RETURNED_VALUE_KEY = "_no_acd_param_should_have_this_name"; + public static final String IS_ALIVE_SERVICE_URL = "http://mobycentral.icapture.ubc.ca:8090/authority/ValidateService"; private NamespaceContextImpl nsContext; private CentralImpl c; + private Map isDeadMap; private HashMap xpathMap; private HashMap urlRegexMap; private Map regexMap; @@ -905,9 +907,10 @@ // Paul: commenting out is temporary until we can fetch the services more quickly //MobyService service = MobyService.getService(mService[j].getName(), mService[j].getAuthority()); //if(service != null){ - //mService[j] = service; + // mService[j] = service; //} + mService[j].setStatus(MobyService.ALIVE, isServiceAlive(mService[j])); mService[j].setServiceType(MobyServiceType.getServiceType(mService[j].getServiceType().getName())); if(serviceLevel != MobyService.UNCHECKED){ int serviceStatus = mService[j].getStatus(); @@ -919,7 +922,7 @@ } // Paul: false is temporary until we can fetch the services more quickly (and check isAlive) - if(false && serviceLevel != MobyService.UNCHECKED){ + if(serviceLevel != MobyService.UNCHECKED){ mService = (MobyService []) filteredServices.toArray(new MobyService[filteredServices.size()]); } @@ -1160,5 +1163,55 @@ } return false; } + + /** + * @return true unless we can contact ValidateService, and it tells us the service is dead + */ + private boolean isServiceAlive(MobyService service){ + // first time method is called + if(isDeadMap == null){ + isDeadMap = new HashMap(); // keys are authority:serviceName + try{ + URL u = new URL(IS_ALIVE_SERVICE_URL); + LineNumberReader reader = new LineNumberReader(new InputStreamReader(u.openStream())); + String currentAuthority = null; + for(String line = reader.readLine(); + line != null; + line = reader.readLine()){ + // authority declarations look like " host.domain.tld" + if(line.indexOf(" ") == 0){ + currentAuthority = line.trim(); + } + else if(line.indexOf("\t") == 0){ + String[] fields = line.trim().split(","); + if(fields.length != 2){ + System.err.println("Unrecognized line (not 2 comma delimited fields) " + + "from ValidateService: " + line.trim()); + } + else if(fields[1].equals("true")){ + // service is okay, don't add to dead map + } + else if(fields[1].equals("false")){ + isDeadMap.put(currentAuthority+":"+fields[0], "dead"); + } + else{ + System.err.println("Unrecognized line (second field not 'true' or 'false') " + + "from ValidateService: " + line.trim()); + } + } + } + + } catch(Exception e){ + e.printStackTrace(); + // will not attempt to retrieve map again, as it's not null anymore + return true; + } + } + + if(isDeadMap.containsKey(service.getAuthority()+":"+service.getName())){ + return false; // dead for sure + } + return true; // be optimistic by default, assume it's alive + } } From senger at dev.open-bio.org Thu Apr 5 10:24:58 2007 From: senger at dev.open-bio.org (Martin Senger) Date: Thu, 5 Apr 2007 10:24:58 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704051424.l35EOw1F015561@dev.open-bio.org> senger Thu Apr 5 10:24:57 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard In directory dev.open-bio.org:/tmp/cvs-serv15542 Modified Files: ServiceCallerModel.java Log Message: moby-live/Java/src/main/org/biomoby/service/dashboard ServiceCallerModel.java,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/ServiceCallerModel.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/service/dashboard/ServiceCallerModel.java 2006/02/20 05:51:10 1.3 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/ServiceCallerModel.java 2007/04/05 14:24:57 1.4 @@ -134,7 +134,7 @@ MobyService selService = (MobyService)propertyChannel.get (DP_SC_SERVICE); if (selService == null) throw new MobyException ("No service given."); - MobyService clonedService = new MobyService (selService.getName()); + MobyService clonedService = new MobyService (selService.getName(), selService.getAuthority()); clonedService.setURL (selService.getURL()); setService (clonedService); From gordonp at dev.open-bio.org Sun Apr 8 13:26:25 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Sun, 8 Apr 2007 13:26:25 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704081726.l38HQPRY021059@dev.open-bio.org> gordonp Sun Apr 8 13:26:25 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services In directory dev.open-bio.org:/tmp/cvs-serv21020/src/main/ca/ucalgary/seahawk/services Modified Files: MobyClient.java MobyComplexBuilder.java Log Message: Refactored rule evaluation code for reuse, and added support for assigning an article name to created objects moby-live/Java/src/main/ca/ucalgary/seahawk/services MobyClient.java,1.9,1.10 MobyComplexBuilder.java,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.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/MobyClient.java 2007/04/04 01:31:38 1.9 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java 2007/04/08 17:26:24 1.10 @@ -41,6 +41,7 @@ public static final String RULE_SET_TAG = "object"; public static final String PREFIX_TAG = "prefix"; public static final String PREFIX_ATTR = "value"; + public static final String ARTICLENAME_RULE_TAG = "articlename"; public static final String NAMESPACE_RULE_TAG = "namespace"; public static final String NAMESPACE_VALUE_TAG = "ns"; public static final String NAMESPACE_VALUE_ATTR = "value"; @@ -195,9 +196,10 @@ Vector regexStrings = new Vector(); Vector urlRegexStrings = new Vector(); Vector xpathStrings = new Vector(); - Map namespaceMap = new HashMap(); - Map memberMap = new HashMap(); + Map namespaceMap = new HashMap(); + Map memberMap = new HashMap(); String dataTypeString = null; + String articleNameString = null; NodeList ruleMembers = ruleSet.getChildNodes(); for(int j = 0; j < ruleMembers.getLength(); j++){ @@ -221,6 +223,15 @@ else if(isNamespaceRule(ruleMember)){ addNamespaceMapping(ruleMember, namespaceMap); } + else if(isArticleNameRule(ruleMember)){ + if(articleNameString != null && articleNameString.length() != 0){ + System.err.println("Skipping unexpected article name definition node, " + + "a valid article name rule has already been " + + "created for this ruleset"); + continue; + } + articleNameString = ruleMember.getTextContent(); + } else if(isDataTypeRule(ruleMember)){ if(dataTypeString != null && dataTypeString.length() != 0){ System.err.println("Skipping unexpected datatype definition node, " + @@ -257,13 +268,13 @@ } for(int j = 0; j < xpathStrings.size(); j++){ - addXPathMapping((String) xpathStrings.elementAt(j), namespaceMap); + addXPathMapping((String) xpathStrings.elementAt(j), namespaceMap, articleNameString); } for(int j = 0; j < regexStrings.size(); j++){ - addRegexMapping((String) regexStrings.elementAt(j), namespaceMap); + addRegexMapping((String) regexStrings.elementAt(j), namespaceMap, articleNameString); } for(int j = 0; j < urlRegexStrings.size(); j++){ - addURLRegexMapping((String) urlRegexStrings.elementAt(j), namespaceMap); + addURLRegexMapping((String) urlRegexStrings.elementAt(j), namespaceMap, articleNameString); } } // Build complex object @@ -274,13 +285,13 @@ } for(int j = 0; j < xpathStrings.size(); j++){ - addXPathMapping((String) xpathStrings.elementAt(j), namespaceMap, dataTypeString, memberMap); + 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); + addRegexMapping((String) regexStrings.elementAt(j), namespaceMap, dataTypeString, memberMap, articleNameString); } for(int j = 0; j < urlRegexStrings.size(); j++){ - addURLRegexMapping((String) urlRegexStrings.elementAt(j), namespaceMap, dataTypeString, memberMap); + addURLRegexMapping((String) urlRegexStrings.elementAt(j), namespaceMap, dataTypeString, memberMap, articleNameString); } } @@ -307,6 +318,10 @@ return e != null && DATATYPE_RULE_TAG.equals(e.getLocalName()); } + public boolean isArticleNameRule(Element e){ + return e != null && ARTICLENAME_RULE_TAG.equals(e.getLocalName()); + } + public boolean isMemberRule(Element e){ return e != null && MEMBER_RULE_TAG.equals(e.getLocalName()); } @@ -379,7 +394,7 @@ return str; } - protected void addMemberMapping(Element memTag, Map membersMap) throws Exception{ + protected void addMemberMapping(Element memTag, Map membersMap) throws Exception{ if(!isMemberRule(memTag)){ throw new Exception("Element provided to addMemberMapping (" + (memTag == null ? null : memTag.getLocalName()) + @@ -432,7 +447,7 @@ memberEncodingSetting}); } - protected void addNamespaceMapping(Element nsTag, Map namespaceStrings) throws Exception{ + protected void addNamespaceMapping(Element nsTag, Map namespaceStrings) throws Exception{ if(!isNamespaceRule(nsTag)){ throw new Exception("Element provided to createNamespaceMapping (" + (nsTag == null ? null : nsTag.getLocalName()) + @@ -945,20 +960,24 @@ } public void addRegexMapping(String regexp, String[] mobyObj){ //mobyObj<--mobyNamespaces + addRegexMapping(regexp, mobyObj, null); + } + + public void addRegexMapping(String regexp, String[] mobyObj, String articleName){ //mobyObj<--mobyNamespaces if(mobyObj == null){ System.err.println("Ignoring empty namespace-only regex rule mappings"); return; } - Map nsRules = new HashMap(); + Map nsRules = new HashMap(); // Default the rule to taking the whole matched expression ($0) for(int i = 0; i < mobyObj.length; i++){ nsRules.put(mobyObj[i], "$0"); } - addRegexMapping(regexp, nsRules); + addRegexMapping(regexp, nsRules, articleName); } - public void addURLRegexMapping(String url_regexp, String[] mobyObj){ //mobyObj<--mobyNamespaces + public void addURLRegexMapping(String url_regexp, String[] mobyObj, String articleName){ //mobyObj<--mobyNamespaces if(mobyObj == null){ System.err.println("Ignoring empty namespace-only url regex rule mappings"); return; @@ -969,7 +988,7 @@ for(int i = 0; i < mobyObj.length; i++){ url_nsRules.put(mobyObj[i], "$1"); } - addURLRegexMapping(url_regexp, url_nsRules); + addURLRegexMapping(url_regexp, url_nsRules, articleName); } /** @@ -999,25 +1018,30 @@ return url_regex_flexible; } - protected void addRegexMapping(String regexp, Map nsRules){ //nsRules = Map + protected void addRegexMapping(String regexp, Map nsRules, String articleName){ //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); + addRegexMapping(regexp, nsRules, (String) null, (Map) null, articleName); } - protected void addURLRegexMapping(String url_regexp, Map url_nsRules){ //nsRules = Map + protected void addURLRegexMapping(String url_regexp, Map url_nsRules, String articleName){ //nsRules = Map if(url_nsRules == null || url_nsRules.size() == 0){ System.err.println("Ignoring empty namespace-only url regex rule mappings"); return; } - addURLRegexMapping(url_regexp, url_nsRules, (String) null, (Map) null); + addURLRegexMapping(url_regexp, url_nsRules, (String) null, (Map) null, articleName); + } + + public void addRegexMapping(String regexp, Map nsRules, + String mobyDataType, Map membersMap){ + addRegexMapping(regexp, nsRules, mobyDataType, membersMap, null); } - public void addRegexMapping(String regexp, Map nsRules, String mobyDataType, Map membersMap){ //mobyObj<--mobyNamespaces + public void addRegexMapping(String regexp, Map nsRules, String mobyDataType, Map membersMap, String articleName){ try{ // Pattern.DOTALL to allow ".*" to span multiple lines, also allow comments (# to EOL) and whitespace // for better readability in the rules file. @@ -1027,14 +1051,16 @@ if(mobyDataType == null || mobyDataType.length() == 0){ regexMap.put(pattern, new MobyComplexBuilder("Object", membersMap, - nsRules)); + nsRules, + articleName)); return; } // Complex Object regexMap.put(pattern, new MobyComplexBuilder(mobyDataType, membersMap, - nsRules)); + nsRules, + articleName)); }catch(Exception e){ System.err.println("Could not create regular expression statement from '" + regexp + "': " + e); @@ -1043,7 +1069,7 @@ } public void addURLRegexMapping(String url_regexp, Map url_nsRules, - String mobyDataType, Map membersMap){ //mobyObj<--mobyNamespaces + String mobyDataType, Map membersMap, String articleName){ //mobyObj<--mobyNamespaces //System.out.println("url regex addMapping: " + url_regexp); try{ Pattern pattern = Pattern.compile(processURLRegExp(url_regexp)); @@ -1052,14 +1078,16 @@ if(mobyDataType == null || mobyDataType.length() == 0){ urlRegexMap.put(pattern, new MobyComplexBuilder("Object", membersMap, - url_nsRules)); + url_nsRules, + articleName)); return; } // Complex Object urlRegexMap.put(pattern, new MobyComplexBuilder(mobyDataType, membersMap, - url_nsRules)); + url_nsRules, + articleName)); }catch(Exception e){ System.err.println("Could not create URL regular expression statement from '" + url_regexp + "': " + e); @@ -1078,14 +1106,15 @@ for(int i = 0; i < mobyObj.length; i++){ nsRules.put(mobyObj[i], "."); } - addXPathMapping(xpath, nsRules); + addXPathMapping(xpath, nsRules, null); } - public void addXPathMapping(String xpath_exp, Map nsRules){ //mobyObj<--mobyNamespaces - addXPathMapping(xpath_exp, nsRules, (String) null, (Map) null); + public void addXPathMapping(String xpath_exp, Map nsRules, String articleName){ //mobyObj<--mobyNamespaces + addXPathMapping(xpath_exp, nsRules, (String) null, (Map) null, articleName); } - public void addXPathMapping(String xpath_exp, Map nsRules, String mobyDataType, Map membersMap){ //mobyObj<--mobyNamespaces + public void addXPathMapping(String xpath_exp, Map nsRules, String mobyDataType, + Map membersMap, String articleName){ //mobyObj<--mobyNamespaces //System.out.println("xpath addMapping: " + xpath_exp); try{ XPath xpath = new XPath(xpath_exp, @@ -1097,14 +1126,16 @@ if(mobyDataType == null || mobyDataType.length() == 0){ xpathMap.put(xpath, new MobyComplexBuilder("Object", membersMap, - nsRules)); + nsRules, + articleName)); return; } // Complex Object xpathMap.put(xpath, new MobyComplexBuilder(mobyDataType, membersMap, - nsRules)); + nsRules, + articleName)); }catch(Exception e){ logger.warn("Could not create XPath select statement from '" + =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyComplexBuilder.java,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/services/MobyComplexBuilder.java 2007/04/03 02:30:36 1.4 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyComplexBuilder.java 2007/04/08 17:26:24 1.5 @@ -19,12 +19,13 @@ */ public class MobyComplexBuilder{ - + public static final String ANON_ARTICLE = "_seahawk_data"; private static XPathFactory xPathFactory; private static DocumentBuilder docBuilder; - private Map namespaceRules; - private Map memberRules; + private Map namespaceRules; // ns, template + private Map memberRules; // member name, [template, whitespace rule, encoding rule] + private String articleNameRule; private MobyDataType mobyDataType; private MobyNamespace[] mobyNS; private MobyRelationship[] children; @@ -40,13 +41,18 @@ } } - public MobyComplexBuilder(String dataType, Map members, Map nameSpaces) throws Exception{ + public MobyComplexBuilder(String dataType, Map members, Map nameSpaces) throws Exception{ + this(dataType, members, nameSpaces, ANON_ARTICLE); + } + + public MobyComplexBuilder(String dataType, Map members, Map nameSpaces, String articleName) throws Exception{ mobyDataType = MobyDataType.getDataType(dataType); // Not an existing Ontology data type if(mobyDataType == null){ mobyDataType = new MobyDataType(dataType); } + articleNameRule = articleName; memberRules = members; if(mobyDataType != null && mobyDataType.getName() != null && @@ -115,15 +121,26 @@ mobyObj = new MobyDataComposite(mobyDataType); } + // Set article name, if available + if(articleNameRule != null && articleNameRule.length() > 0){ + mobyObj.setName(evaluateRule(matcher, + articleNameRule, + MobyClient.WHITESPACE_ATTR_STRIP_FLANKING_VAL, + null, + data)); + } + // Set namespaces if available if(namespaceRules != null && namespaceRules.size() > 0){ boolean haveID = false; for(int i = 0; mobyNS != null && i < mobyNS.length; i++){ - String result = (String) namespaceRules.get(mobyNS[i].getName()); - // Replace any $0, $1, etc. in the replacement string with the values found in the matcher - for(int j = 0; j <= matcher.groupCount(); j++){ - result = result.replaceAll("\\$"+j, matcher.group(j)); - } + String resultSpec = namespaceRules.get(mobyNS[i].getName()); + String result = evaluateRule(matcher, + resultSpec, + MobyClient.WHITESPACE_ATTR_STRIP_FLANKING_VAL, + null, + data); + // A non-blank value was the result of the evaluation if(result.length() > 0){ if(!haveID){ @@ -141,19 +158,14 @@ } } - Document doc = docBuilder.newDocument(); // 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 = (String[]) memberRules.get(memberName); + String[] resultSpec = memberRules.get(memberName); + MobyRelationship memberRelationship = mobyDataType.getChild(memberName); - String result = resultSpec[0]; - byte[] resultBytes = result.getBytes(); - String whitespaceMode = resultSpec[1]; - String encodingMode = resultSpec[2]; - // 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... @@ -161,88 +173,109 @@ } // else is iHASA, scalar context - - boolean nonBasic = result.length() != 2 || result.indexOf("$") != 0; - MobyPrefixResolver.MobyNodeList nodeList = new MobyPrefixResolver.MobyNodeList(); - // Replace any $0, $1, etc. in the replacement string with the values found in the matcher - // 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++){ - // A replaceAll() for binary data - if(data != null){ - (new Exception("Binary replaceAll()")).printStackTrace(); - 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)+1; - - byte[] newResultBytes = new byte[resultBytes.length+varValueLength]; - if(varIndex > 0){ - System.arraycopy(resultBytes, 0, newResultBytes, 0, varIndex); - } - System.arraycopy(data, matcher.start(j), newResultBytes, varIndex, varValueLength); - int remaining = result.length()-varIndex-2; - if(remaining > 0){ - System.arraycopy(resultBytes, varIndex+2, newResultBytes, varIndex+varValueLength, - result.length()-varIndex-2); - } - srcPos += varIndex + varValueLength + 1; - resultBytes = newResultBytes; - } - } - // $# substitution in a string, considerably simpler! - else{ - String varValue = matcher.group(j); - if(whitespaceMode.equals(MobyClient.WHITESPACE_ATTR_NORMALIZE_VAL)){ - varValue = varValue.replaceAll("\\s+"," "); - } - else if(whitespaceMode.equals(MobyClient.WHITESPACE_ATTR_STRIP_VAL)){ - varValue = varValue.replaceAll("\\s+",""); - } - else if(whitespaceMode.equals(MobyClient.WHITESPACE_ATTR_STRIP_FLANKING_VAL)){ - varValue = varValue.trim(); // removes leading and trailing whitespace - } - result = result.replaceAll("\\$"+j, 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 - nodeList.add(doc.createTextNode(result)); - } - } - - if(encodingMode.equals(MobyClient.ENCODING_ATTR_BASE64_VAL)){ - //(new Exception("Base 64 encoding")).printStackTrace(); - result = org.apache.axis.encoding.Base64.encode(data == null ? result.getBytes() : resultBytes); - } else{ - //System.err.println("NO BASE64 (" + MobyClient.ENCODING_ATTR_BASE64_VAL + - // ") ENCODING for " +memberName+": " + encodingMode); - } + String result = evaluateRule(matcher, resultSpec[0], resultSpec[1], resultSpec[2], data); - // If the value contains anything other than $#, treat it as a XPath expression - // to be evaluated on a text node containing the result value - if(nonBasic && data == null){ - XPath xpath = xPathFactory.newXPath(); - try{ - result = xpath.evaluate(result, nodeList); - }catch(Exception e){ - e.printStackTrace(); - throw new MobyException("Could not evaluate result of XPath expression for object member " + - memberName + " (" + result + "): " + e); - } + ((MobyDataComposite) mobyObj).put(memberName, + MobyDataObject.createInstanceFromString(children[i].getDataTypeName(), result)); } - - ((MobyDataComposite) mobyObj).put(memberName, - MobyDataObject.createInstanceFromString(children[i].getDataTypeName(), result)); } } } - return mobyObj; } + // takes a rule and evaluates $# variables and XPath expressions + private String evaluateRule(Matcher matcher, String result, String whitespaceMode, String encodingMode, byte[] data) + throws MobyException{ + byte[] resultBytes = result.getBytes(); + boolean nonBasic = result.length() != 2 || result.indexOf("$") != 0; + + MobyPrefixResolver.MobyNodeList nodeList = new MobyPrefixResolver.MobyNodeList(); + + Document doc = null; + // Only get a DOM instance (for text node creation) if we're going to evaluate an XPath in the end + if(nonBasic){ + doc = docBuilder.newDocument(); + } + + // Replace any $0, $1, etc. in the replacement string with the values found in the matcher + // 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++){ + // A replaceAll() for binary data + if(data != null){ + (new Exception("Binary replaceAll()")).printStackTrace(); + 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)+1; + + byte[] newResultBytes = new byte[resultBytes.length+varValueLength]; + if(varIndex > 0){ + System.arraycopy(resultBytes, 0, newResultBytes, 0, varIndex); + } + System.arraycopy(data, matcher.start(j), newResultBytes, varIndex, varValueLength); + int remaining = result.length()-varIndex-2; + if(remaining > 0){ + System.arraycopy(resultBytes, varIndex+2, newResultBytes, varIndex+varValueLength, + result.length()-varIndex-2); + } + srcPos += varIndex + varValueLength + 1; + resultBytes = newResultBytes; + } + } + // $# substitution in a string, considerably simpler! + else{ + String varValue = matcher.group(j); + if(whitespaceMode == null){ + // do nothing + } + else if(whitespaceMode.equals(MobyClient.WHITESPACE_ATTR_NORMALIZE_VAL)){ + varValue = varValue.replaceAll("\\s+"," "); + } + else if(whitespaceMode.equals(MobyClient.WHITESPACE_ATTR_STRIP_VAL)){ + varValue = varValue.replaceAll("\\s+",""); + } + else if(whitespaceMode.equals(MobyClient.WHITESPACE_ATTR_STRIP_FLANKING_VAL)){ + varValue = varValue.trim(); // removes leading and trailing whitespace + } + result = result.replaceAll("\\$"+j, 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 + if(nonBasic){ + nodeList.add(doc.createTextNode(result)); + } + } + } + + if(encodingMode != null && encodingMode.equals(MobyClient.ENCODING_ATTR_BASE64_VAL)){ + //(new Exception("Base 64 encoding")).printStackTrace(); + result = org.apache.axis.encoding.Base64.encode(data == null ? result.getBytes() : resultBytes); + } + else{ + //System.err.println("NO BASE64 (" + MobyClient.ENCODING_ATTR_BASE64_VAL + + // ") ENCODING for " +memberName+": " + encodingMode); + } + + // If the value contains anything other than $#, treat it as a XPath expression + // to be evaluated on a text node containing the result value + if(nonBasic && data == null){ + XPath xpath = xPathFactory.newXPath(); + try{ + result = xpath.evaluate(result, nodeList); + }catch(Exception e){ + e.printStackTrace(); + throw new MobyException("Could not evaluate result of XPath expression " + + "('" + result + "'): " + e); + } + } + return result; + } + public MobyDataObject applyXPath(Object result, NamespaceContext nsContext) throws MobyException, XPathExpressionException{ XPath xpath = xPathFactory.newXPath(); xpath.setNamespaceContext(nsContext); @@ -260,7 +293,7 @@ if(namespaceRules != null && namespaceRules.size() > 0){ boolean haveID = false; for(int i = 0; mobyNS != null && i < mobyNS.length; i++){ - String expr = (String) namespaceRules.get(mobyNS[i].getName()); + String expr = namespaceRules.get(mobyNS[i].getName()); String value = xpath.evaluate(expr, result); // A non-blank value was the result of the evaluation @@ -285,7 +318,7 @@ if(children != null){ for(int i = 0; i < children.length; i++){ String memberName = children[i].getName(); - String expr = ((String[]) memberRules.get(memberName))[0]; + String expr = memberRules.get(memberName)[0]; String value = xpath.evaluate(expr, result); ((MobyDataComposite) mobyObj).put(memberName, From gordonp at dev.open-bio.org Sun Apr 8 13:29:29 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Sun, 8 Apr 2007 13:29:29 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704081729.l38HTTec021123@dev.open-bio.org> gordonp Sun Apr 8 13:29:29 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data In directory dev.open-bio.org:/tmp/cvs-serv21088/src/main/org/biomoby/shared/data Modified Files: MobyDataComposite.java Log Message: Made member data type enforcement more consistent, now you can't manually add field of the wrong type either (with the put() method) moby-live/Java/src/main/org/biomoby/shared/data MobyDataComposite.java,1.12,1.13 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataComposite.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataComposite.java 2007/03/12 17:02:30 1.12 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataComposite.java 2007/04/08 17:29:29 1.13 @@ -54,12 +54,16 @@ // will be a problem for member association (i.e. it's an anonymous variable) String fieldName = getName(child); if(fieldName == null || fieldName.length() == 0){ - throw new IllegalArgumentException("The subelement with index " + i + - " does not have an article " + - "name, which is required"); + throw new MobyException("The subelement with index " + i + + " does not have an article " + + "name, which is required"); } - - put(fieldName, (MobyDataObject) createInstanceFromDOM(child)); + MobyDataObject childObject = (MobyDataObject) createInstanceFromDOM(child); + if(childObject == null){ + throw new MobyException("The object member '" + fieldName + "' for object '"+ getName() + + " could not be properly parsed into a MOBY object"); + } + put(fieldName, childObject); } } } @@ -251,8 +255,7 @@ // Print out the sorted fields' XML for(int i = 0; i < fieldNames.length; i++){ - //MobyDataObject mdsi = members.get(fieldNames[i]); //Java1.5 - MobyDataObject mdsi = (MobyDataObject) members.get(fieldNames[i]); + MobyDataObject mdsi = members.get(fieldNames[i]); // ensure the articleName is set correctly for the requirements of this object if(!fieldNames[i].toString().equals(mdsi.getName())){ mdsi.setName(fieldNames[i].toString()); @@ -378,11 +381,28 @@ * e.g. creating a GenericSequence involves putting a 'length' member (MobyDataInt), * then putting a 'sequence' member (MobyDataString). * + * This method will throw an IllegalArgumentException if the value does not inherit from the type defined by Moby Central + * * NOTE: if the field already exists and is defined with the HAS relationship in the DataType ontology, * the previous value is NOT overwritten, rather the MobyDataObject is switched into a MobyDataObjectVector. * Replace mode will be used unless the data type and relationship are properly defined. */ public MobyDataObject put(String fieldName, MobyDataObject value){ + if(value == null){ + return null; + } + + MobyRelationship relationship = getDataType().getChild(fieldName); + MobyDataType childDataType = MobyDataType.getDataType(relationship.getDataTypeName()); + if(!value.getDataType().inheritsFrom(childDataType)){ + // Incompatible types + throw new IllegalArgumentException("The object member '" + fieldName + "' for object '"+ getName() + + "' does not inherit from the required data type " + + "(found data type " + value.getDataType().getName()+ + ", but require subclass of " + + childDataType.getName() +")"); + } + // If the field already exists, see if the HAS (1-to-many) relationship exists if(members.containsKey(fieldName)){ MobyDataObject existingMember = members.get(fieldName); @@ -393,12 +413,11 @@ return existingMember; } - // Use replace mode if the data type or relatioship is unavailable + // Use replace mode if the data type or relationship is unavailable MobyDataType dt = getDataType(); if(dt == null){ return members.put(fieldName, value); } - MobyRelationship relationship = getDataType().getChild(fieldName); if(relationship == null){ return members.put(fieldName, value); } From gordonp at dev.open-bio.org Wed Apr 11 20:40:23 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 11 Apr 2007 20:40:23 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704120040.l3C0eN4W030342@dev.open-bio.org> gordonp Wed Apr 11 20:40:23 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/test In directory dev.open-bio.org:/tmp/cvs-serv30306/src/main/org/biomoby/service/test Modified Files: TestServletContext.java Log Message: Minor change to conform to j2EE spec, empty enumeration for parameter names rather than null moby-live/Java/src/main/org/biomoby/service/test TestServletContext.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/test/TestServletContext.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/service/test/TestServletContext.java 2006/12/06 16:07:10 1.1 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/test/TestServletContext.java 2007/04/12 00:40:22 1.2 @@ -30,7 +30,7 @@ public java.util.Enumeration getAttributeNames(){return null;} public ServletContext getContext(String uripath){return null;} public String getInitParameter(String name){return null;} - public java.util.Enumeration getInitParameterNames(){return null;} + public java.util.Enumeration getInitParameterNames(){return (new Vector()).elements();} public int getMajorVersion(){return 0;} public String getMimeType(String file){return null;} public int getMinorVersion(){return 0;} From gordonp at dev.open-bio.org Wed Apr 11 20:51:45 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 11 Apr 2007 20:51:45 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704120051.l3C0pj3w030408@dev.open-bio.org> gordonp Wed Apr 11 20:51:45 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/service In directory dev.open-bio.org:/tmp/cvs-serv30372/src/main/org/biomoby/service Modified Files: MobyServlet.java Log Message: Made servlet parameter fethcing more robust by always checking servlet config AND context for a non-null value moby-live/Java/src/main/org/biomoby/service MobyServlet.java,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/MobyServlet.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/service/MobyServlet.java 2007/03/12 16:57:30 1.6 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/MobyServlet.java 2007/04/12 00:51:45 1.7 @@ -625,8 +625,8 @@ MobyDataType.getDataType("Object"); // Not sure we actually need MobyRequest yet... - if(getInitParameter(MOBY_CENTRAL_URL_PARAM) != null){ - mobyRequest = new MobyRequest(new CentralCachedCallsImpl(getInitParameter(MOBY_CENTRAL_URL_PARAM))); + if(getCoCInitParameter(MOBY_CENTRAL_URL_PARAM) != null){ + mobyRequest = new MobyRequest(new CentralCachedCallsImpl(getCoCInitParameter(MOBY_CENTRAL_URL_PARAM))); } else{ mobyRequest = new MobyRequest(new CentralCachedCallsImpl()); @@ -640,6 +640,22 @@ isInitialized = true; } + protected String getCoCInitParameter(String paramName){ + javax.servlet.ServletConfig config = getServletConfig(); + if(config != null){ + if(config.getInitParameter(paramName) != null){ + return config.getInitParameter(paramName); + } + } + javax.servlet.ServletContext context = getServletContext(); + if(context != null){ + if(context.getInitParameter(paramName) != null){ + return context.getInitParameter(paramName); + } + } + return getInitParameter(paramName); + } + public synchronized MobyService createServiceFromConfig(HttpServletRequest request) throws Exception{ MobyService service = new MobyService(getServiceName()); @@ -671,8 +687,8 @@ // Inputs and outputs and service type must be defined String[] ins = ann.in(); - if(config != null && config.getInitParameter(MOBY_INPUT_PARAM) != null){ - ins = config.getInitParameter(MOBY_INPUT_PARAM).split(","); + if(getCoCInitParameter(MOBY_INPUT_PARAM) != null){ + ins = getCoCInitParameter(MOBY_INPUT_PARAM).split(","); } if(ins == null){ throw new Exception("Could not find required " + MOBY_INPUT_PARAM + @@ -684,8 +700,8 @@ } String[] outs = ann.out(); - if(config != null && config.getInitParameter(MOBY_OUTPUT_PARAM) != null){ - outs = config.getInitParameter(MOBY_OUTPUT_PARAM).split(","); + if(getCoCInitParameter(MOBY_OUTPUT_PARAM) != null){ + outs = getCoCInitParameter(MOBY_OUTPUT_PARAM).split(","); } if(outs == null){ throw new Exception("Could not find required " + MOBY_OUTPUT_PARAM + @@ -698,8 +714,8 @@ } String[] secondaries = ann.secondaryParams(); - if(config != null && config.getInitParameter(MOBY_SECONDARYINPUT_PARAM) != null){ - secondaries = config.getInitParameter(MOBY_SECONDARYINPUT_PARAM).split(","); + if(getCoCInitParameter(MOBY_SECONDARYINPUT_PARAM) != null){ + secondaries = getCoCInitParameter(MOBY_SECONDARYINPUT_PARAM).split(","); } if(secondaries != null && secondaries.length > 0){ for(String secondary: secondaries){ @@ -713,8 +729,8 @@ // A description and provider URI must be available too String param = ann.type(); // Did we override the service type in the web.xml? - if(config != null && config.getInitParameter(MOBY_SERVICETYPE_PARAM) != null){ - param = config.getInitParameter(MOBY_SERVICETYPE_PARAM); + if(getCoCInitParameter(MOBY_SERVICETYPE_PARAM) != null){ + param = getCoCInitParameter(MOBY_SERVICETYPE_PARAM); } if(param == null){ throw new Exception("Could not find required " + MOBY_SERVICETYPE_PARAM + @@ -733,9 +749,9 @@ String[] desc = ann.description(); // Did we override the service type in the web.xml? - if(config != null && config.getInitParameter(MOBY_SERVICETYPE_PARAM) != null){ + if(getCoCInitParameter(MOBY_SERVICETYPE_PARAM) != null){ desc = new String[1]; - desc[0] = config.getInitParameter(MOBY_SERVICETYPE_PARAM); + desc[0] = getCoCInitParameter(MOBY_SERVICETYPE_PARAM); } if(desc == null){ throw new Exception("Could not find required " + MOBY_SERVICE_DESC_PARAM + @@ -753,8 +769,8 @@ param = ann.provider(); // Did we override the provider info in web.xml? - if(config != null && config.getInitParameter(MOBY_PROVIDER_URI_PARAM) != null){ - param = config.getInitParameter(MOBY_PROVIDER_URI_PARAM); + if(getCoCInitParameter(MOBY_PROVIDER_URI_PARAM) != null){ + param = getCoCInitParameter(MOBY_PROVIDER_URI_PARAM); } if(param == null){ throw new Exception("Could not find required " + MOBY_PROVIDER_URI_PARAM + @@ -774,8 +790,8 @@ param = ann.author(); // Did we override the contact info in web.xml? - if(config != null && config.getInitParameter(MOBY_CONTACT_PARAM) != null){ - param = config.getInitParameter(MOBY_CONTACT_PARAM); + if(getCoCInitParameter(MOBY_CONTACT_PARAM) != null){ + param = getCoCInitParameter(MOBY_CONTACT_PARAM); } if(param == null){ throw new Exception("Could not find required " + MOBY_CONTACT_PARAM + @@ -803,7 +819,7 @@ service.setSignatureURL(endPointURL+"?"+MODE_HTTP_PARAM+"="+RDF_MODE); // Other fields (authoritative and contact info) are highly recommended, but optional if(config != null){ - param = config.getInitParameter(MOBY_AUTHORITATIVE_PARAM); + param = getCoCInitParameter(MOBY_AUTHORITATIVE_PARAM); if(param != null){ if("YES".equals(param.toUpperCase()) || "Y".equals(param.toUpperCase()) || "1".equals(param)){ service.setAuthoritative(true); @@ -833,11 +849,10 @@ mobyService ann = this.getClass().getAnnotation(mobyService.class); - javax.servlet.ServletConfig config = getServletConfig(); String param = null; // Did we override the service type in the web.xml? - if(config != null && config.getInitParameter(MOBY_SERVICENAME_PARAM) != null){ - param = config.getInitParameter(MOBY_SERVICENAME_PARAM); + if(getCoCInitParameter(MOBY_SERVICENAME_PARAM) != null){ + param = getCoCInitParameter(MOBY_SERVICENAME_PARAM); if(param != null && param.length() != 0){ return param; } From gordonp at dev.open-bio.org Wed Apr 11 20:53:31 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 11 Apr 2007 20:53:31 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704120053.l3C0rV11030452@dev.open-bio.org> gordonp Wed Apr 11 20:53:31 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/test In directory dev.open-bio.org:/tmp/cvs-serv30416/src/main/org/biomoby/service/test Modified Files: ServletTester.java Log Message: Added ability to load sample data as resource, specify alternative web.xml location, and stricter on testing URL to avoid localhost references moby-live/Java/src/main/org/biomoby/service/test ServletTester.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/test/ServletTester.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/service/test/ServletTester.java 2007/03/12 16:57:30 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/test/ServletTester.java 2007/04/12 00:53:31 1.3 @@ -21,6 +21,23 @@ import java.io.*; public class ServletTester{ + private String alternateWebXML; + + /** + * Runs a test on the service described in WEB-INF/web.xml + */ + public ServletTester(){ + this(null); + } + + /** + * Mainly for JUnit tests, specify a web.xml file to be used for configuring the test run, + * rather than using the default WEB-INF/web.xml in the class path. + */ + public ServletTester(String altWebXML){ + alternateWebXML = altWebXML; + } + public static void main(String[] args) throws Exception{ if(args.length != 2 && args.length != 3 || @@ -29,19 +46,23 @@ " "); throw new Exception("Incorrect command arguments"); } - if(args[0].indexOf("http://localhost") == 0){ + if(args[0].indexOf("http://localhost") == 0 || args[0].indexOf("http://127.0.0.1/") == 0){ System.err.println("The servlet URL must be fully qualified " + - "(\"localhost\" is not acceptable)"); + "(\"localhost\" or \"127.0.0.1\" are not acceptable)"); throw new Exception("Servlet URL not fully qualified"); } ServletTester tester = new ServletTester(); + tester.runService(args); + } + public void runService(String[] args) throws Exception{ // Open the web.xml file to determine the service name and inputs/outputs. - java.net.URL webXmlURL = tester.getClass().getClassLoader().getResource("WEB-INF/web.xml"); + String webXMLPath = alternateWebXML != null ? alternateWebXML : "WEB-INF/web.xml"; + java.net.URL webXmlURL = getClass().getClassLoader().getResource(webXMLPath); if(webXmlURL == null){ - System.err.println("Could not find \"WEB-INF/web.xml\", aborting!"); - throw new Exception("No WEB-INF/web.xml in the code archive"); + System.err.println("Could not find \""+webXMLPath+"\", aborting!"); + throw new Exception("No \""+ webXMLPath+"\" in the resource path"); } String centralURL = null; @@ -108,12 +129,29 @@ try{ dataIn = (new URL(args[1])).openStream(); } catch(Exception e){ - e.printStackTrace(); + //e.printStackTrace(); } } + // Last ditch, try as a resource if(dataIn == null){ - System.err.println("Could not read example data file \"" + args[1] + "\", aborting!"); - throw new Exception("Example data file was unreadable: " + args[1]); + ClassLoader cl = getClass().getClassLoader(); + if(cl == null){ + cl = ClassLoader.getSystemClassLoader(); + } + System.err.println("Trying to load as resource with " + cl); + URL resourceURL = null; + if(cl != null){ + resourceURL = cl.getResource(args[1]); + } + if(resourceURL == null){ + System.err.println("Could not find the example data named \"" + args[1] + "\", aborting!"); + throw new Exception("Example data was not found: " + args[1]); + } + try{ + dataIn = resourceURL.openStream(); + } catch(Exception e){ + e.printStackTrace(); + } } // Create the data and service instances. From gordonp at dev.open-bio.org Wed Apr 11 20:54:16 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 11 Apr 2007 20:54:16 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704120054.l3C0sGEw030496@dev.open-bio.org> gordonp Wed Apr 11 20:54:16 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/test In directory dev.open-bio.org:/tmp/cvs-serv30460/src/main/org/biomoby/service/test Modified Files: MobyServletTestCase.java Log Message: Several changes to improve extensibility of tests by subclasses moby-live/Java/src/main/org/biomoby/service/test MobyServletTestCase.java,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/test/MobyServletTestCase.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/service/test/MobyServletTestCase.java 2007/03/12 16:57:30 1.3 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/test/MobyServletTestCase.java 2007/04/12 00:54:16 1.4 @@ -21,8 +21,10 @@ public class MobyServletTestCase extends TestCase{ private final static String TEST_MOBY_XML = "org/biomoby/service/test/mobyAASeq.xml"; + private final static String SERVLET_TEST_WEBXML = "org/biomoby/service/test/web.xml"; private final static String SERVLET_TEST_URL = "http://moby.ucalgary.ca:8089/MobyServlet"; private final static String TEST_MAIN_CLASS_NAME = "org.biomoby.service.test.ConvertAAtoFASTA_AA"; + /** * @param name Test case name. */ @@ -94,11 +96,35 @@ } public void testRDF(){ - TestServletConfig config = new TestServletConfig("ConvertAAtoFASTA_AA", new TestServletContext()); - //config.addInitParameter(); - MobyServlet servlet = new ConvertAAtoFASTA_AA(); + String webXMLPath = "WEB-INF/web.xml"; + java.net.URL webXmlURL = getClass().getClassLoader().getResource(webXMLPath); + assertNotNull("No \""+ webXMLPath+"\" in the resource path", webXmlURL); + TestServletConfig servletConfig = null; try{ - servlet.init(config); + servletConfig = new TestServletConfig(new TestServletContext(), webXmlURL); + } catch(Exception e){ + e.printStackTrace(); + fail("Could not create servlet configuration from " + webXmlURL + ": " + e); + } + + MobyServlet servlet = null; + try{ + // This line can throw many different exception if you didn't get the class right! + Class servletClass = MobyServlet.class.getClassLoader().loadClass(servletConfig.getServletClassName()); + if(servletClass == null){ + throw new ClassNotFoundException("The servlet Class to run (" + + servletConfig.getServletClassName() + + ") was not found, please ensure the web.xml is up-to-date."); + } + servlet = (MobyServlet) servletClass.newInstance(); + } catch(Exception e){ + e.printStackTrace(); + fail("The servlet Class was not specified properly in " + webXmlURL + + " (the servlet-class tag was not useable): " + e); + } + + try{ + servlet.init(servletConfig); } catch(Exception e){ e.printStackTrace(); @@ -106,9 +132,8 @@ } TestHttpServletRequest request = new TestHttpServletRequest(); - request.addHeader("SOAPAction", "MobyServlet"); request.setParameter(MobyServlet.MODE_HTTP_PARAM, MobyServlet.RDF_MODE); - request.setRequestURL("http://moby.ucalgary.ca:8089/ConvertAAtoFASTA_AA"); + request.setRequestURL("http://hostname.domain.tld:8089/UnImportantServiceName"); TestHttpServletResponse response = new TestHttpServletResponse(); StringBufferServletOutputStream out = new StringBufferServletOutputStream(); @@ -237,7 +262,17 @@ public void testServletTester(){ try{ - ServletTester.main(new String[]{getExampleServlet(), getExampleURL().toString()}); + // Use the specific, basic servlet test, with the defined web.xml + // because we want to be able to do this test regardless of the + // class environment we find ourselves in (i.e. a WEB-INF/web.xml + // that is for a more specialized service such as ACDService) + ServletTester tester = new ServletTester(SERVLET_TEST_WEBXML); + + // A useful side effect of an object instance is that it + // can use the classloader that loaded it to find resources + // (there is no class instance get a classloader from in static methods) + tester.runService(new String[]{SERVLET_TEST_URL, TEST_MOBY_XML}); + } catch(Exception e){ e.printStackTrace(); fail("Could not run servlet tester successfully: " + e); From gordonp at dev.open-bio.org Wed Apr 11 20:56:04 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 11 Apr 2007 20:56:04 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704120056.l3C0u4hV030602@dev.open-bio.org> gordonp Wed Apr 11 20:56:03 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/test In directory dev.open-bio.org:/tmp/cvs-serv30570/src/main/org/biomoby/service/test Added Files: web.xml Log Message: web.xml for base MobyServlet, added here so it can be loaded explicitly by the ServletTester when the normal web.xml is describing another more specialized service moby-live/Java/src/main/org/biomoby/service/test web.xml,NONE,1.1 From gordonp at dev.open-bio.org Wed Apr 11 20:57:32 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 11 Apr 2007 20:57:32 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704120057.l3C0vW7l030668@dev.open-bio.org> gordonp Wed Apr 11 20:57:32 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/test In directory dev.open-bio.org:/tmp/cvs-serv30632/src/main/ca/ucalgary/services/test Modified Files: ACDServiceTestCase.java Log Message: Now correctly tests the command-line servlet tester class moby-live/Java/src/main/ca/ucalgary/services/test ACDServiceTestCase.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/test/ACDServiceTestCase.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/services/test/ACDServiceTestCase.java 2007/03/12 14:33:38 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/test/ACDServiceTestCase.java 2007/04/12 00:57:32 1.2 @@ -9,6 +9,7 @@ import ca.ucalgary.seahawk.services.MobyClient; import org.biomoby.service.test.MobyServletTestCase; +import org.biomoby.service.test.ServletTester; import org.biomoby.shared.MobyDataType; import org.biomoby.shared.data.*; @@ -25,9 +26,6 @@ private final static String ACDTEST_BINARY_DATA2 = "ca/ucalgary/services/test/mobyTest2.png"; private final static String MOBY_PNG_DATATYPE = "b64_Encoded_PNG"; - // Sync with acdweb.xml's example EMBOSS service - //private final static String ACDSERVLET_TEST_URL = "http://moby.ucalgary.ca:8089/transeq"; - public ACDServiceTestCase(String name){ super(name); } @@ -45,10 +43,6 @@ return ACDTEST_CLASS_NAME; } -// protected String getExampleServlet(){ -// return ACDSERVLET_TEST_URL; -// } - /** * Loads a binary file, then tests it against a regex, creates a MOBY object, and * then the new object is compared to the original file data (they should be @@ -154,7 +148,7 @@ suite.addTest(new ACDServiceTestCase("testMain")); suite.addTest(new ACDServiceTestCase("testBinaryRegex")); suite.addTest(new MobyServletTestCase("testSecondaryParams")); - //suite.addTest(new MobyServletTestCase("testServletTester")); + suite.addTest(new MobyServletTestCase("testServletTester")); return suite; } From gordonp at dev.open-bio.org Wed Apr 11 20:59:42 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 11 Apr 2007 20:59:42 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704120059.l3C0xgQE030712@dev.open-bio.org> gordonp Wed Apr 11 20:59:42 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services In directory dev.open-bio.org:/tmp/cvs-serv30676/src/main/ca/ucalgary/seahawk/services Modified Files: TextClient.java Log Message: Translated spaces to hyphens in target types because XSLT doesn't allow spaces in mode names moby-live/Java/src/main/ca/ucalgary/seahawk/services TextClient.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/TextClient.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/services/TextClient.java 2007/03/12 14:30:56 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/TextClient.java 2007/04/12 00:59:42 1.2 @@ -116,6 +116,8 @@ if(textType == null){ return false; } + // Spaces are not allowed in mode names + textType = textType.replace(' ', '-'); // Search for templates matching the given type or one of its parent types, // and see if they create the given text type (indicated by the template's mode attribute) @@ -156,6 +158,8 @@ if(targetTextType == null || mobyData == null || !(mobyData instanceof MobyPrimaryData)){ return null; } + // Spaces are not allowed in mode names + targetTextType = targetTextType.replace(' ', '-'); Vector candidateTypes = new Vector(); for(MobyDataType type = ((MobyPrimaryData) mobyData).getDataType(); From gordonp at dev.open-bio.org Wed Apr 11 21:02:29 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 11 Apr 2007 21:02:29 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704120102.l3C12T3P030758@dev.open-bio.org> gordonp Wed Apr 11 21:02:29 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services In directory dev.open-bio.org:/tmp/cvs-serv30722/src/main/ca/ucalgary/services Modified Files: ACDService.java Log Message: Made servlet param fetching more robust, allow advanced parameters in ACD files to be optionally published, service name now carried from MobyServlet.getServiceName() moby-live/Java/src/main/ca/ucalgary/services ACDService.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/ACDService.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/services/ACDService.java 2007/03/12 14:32:02 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/ACDService.java 2007/04/12 01:02:29 1.2 @@ -27,6 +27,7 @@ // Used for web.xml configuration public final static String EMBOSS_ROOT_PARAM = "embossRoot"; public final static String EMBOSS_PARAMS_PARAM = "embossParams"; + public final static String EMBOSS_ADV_PARAMS_PARAM = "embossUseAdvancedParams"; public final static String EMBOSS_OUTPUT_PARAM = "embossOutput"; public final static String ACD_FILE_PARAM = "acdFile"; public final static String ACD_RULES_LOCATION_PARAM = "regexRulesLoc"; @@ -43,6 +44,7 @@ private MobyClient mobyClient; // For converting MOBY data to plain-text representation private TextClient textClient; + private MobyDataType binaryDataType; // Keep track of what MOBY input parameters are to be converted to what ACD types private Map acdTypes; @@ -111,7 +113,7 @@ MobyServiceException.INTERNAL_PROCESSING_ERROR, request.getID(), "The requested output parameter in the servlet configuration (" + - outputName + "could not be created from the program's results data, please " + + outputName + ") could not be created from the program's results data, please " + " ask the service provider to correct the output transformation rules"); } result.put(outputName, mdi); @@ -134,30 +136,48 @@ Map tempFiles = new HashMap(); // Primary input - String stdin = ""; + byte[] stdin = null; for(MobyPrimaryData mobyInputTemplate: inputs){ // Retrieve the input with the same name as the service template specifies String paramName = mobyInputTemplate.getName(); MobyDataInstance inputData = request.get(paramName); - String inputTextData = textClient.getText(inputData, acdTypes.get(mobyInputTemplate.getName())); + byte[] inputDataBytes = null; + + // Transform the moby data to text, unless it's binary data, which will be passed as decoded bytes + // Now, for binary data, we have to ignore any fields other than the Base64 encoded one. Sorry! + String tempFileSuffix = ".txt"; + if(mobyInputTemplate.getDataType().inheritsFrom(binaryDataType)){ + inputDataBytes = org.apache.axis.encoding.Base64.decode(MobyDataBytes.ENCODED_MEMBER_NAME); + tempFileSuffix = ".bin"; + } + else{ + String inputTextData = textClient.getText(inputData, acdTypes.get(mobyInputTemplate.getName())); + if(inputTextData == null){ + throw new NullPointerException("The TextClient returned null after transforming the " + + "input parameter " + mobyInputTemplate.getName() + + " to text type " + acdTypes.get(mobyInputTemplate.getName())); + } + inputDataBytes = inputTextData.getBytes(); + } // Create the required command-line flag for the parameter if(inputs.length == 1){ // If only one input, we can pass it via stdin command.add("-"+paramName); command.add("stdin"); - stdin = inputTextData; + stdin = inputDataBytes; } else{ // Otherwise we need to create temporary files to store the data - File tempFile = File.createTempFile("ACDService."+programBinaryFile.getName()+".input."+paramName, ".txt"); + File tempFile = File.createTempFile("ACDService."+programBinaryFile.getName()+".input."+paramName, + tempFileSuffix); command.add("-"+paramName); command.add(tempFile.toString()); tempFiles.put(paramName, tempFile); // Write the data to the file - FileWriter fileWriter = new FileWriter(tempFile); - fileWriter.write(inputTextData); - fileWriter.close(); + FileOutputStream fileOS = new FileOutputStream(tempFile); + fileOS.write(inputDataBytes); + fileOS.close(); } } @@ -179,7 +199,7 @@ // Primary output for(MobyPrimaryData mobyOutputTemplate: outputs){ - // Retrieve the input with the same name as the service template specifies + // Retrieve the output with the same name as the service template specifies String paramName = mobyOutputTemplate.getName(); // Create the required command-line flag for the parameter @@ -190,7 +210,12 @@ } else{ // Otherwise we need to create temporary files to store the data - File tempFile = File.createTempFile("ACDService."+programBinaryFile.getName()+".output."+paramName, ".txt"); + String tempFileSuffix = ".txt"; + if(mobyOutputTemplate.getDataType().inheritsFrom(binaryDataType)){ + tempFileSuffix = ".bin"; + } + File tempFile = File.createTempFile("ACDService."+programBinaryFile.getName()+".output."+paramName, + tempFileSuffix); command.add("-"+paramName); command.add(tempFile.toString()); tempFiles.put(paramName, tempFile); @@ -271,7 +296,7 @@ /** * @return the standard output of the command */ - private String runProgram(MobyDataJob request, String[] command, File workingDir, final String input) throws Exception{ + private String runProgram(MobyDataJob request, String[] command, File workingDir, final byte[] input) throws Exception{ // TODO: ensure $embossRootDirName/lib is in the LD_LIBRARY_PATH, // what is the equivalent in Windows? Process process = runtime.exec(command, @@ -302,10 +327,18 @@ new Thread(){ public void run(){ try{ - for(String line: input.split("\n")){ - // Feed in the data one line at a time - stdin.write((line+"\n").getBytes()); - stdin.flush(); + final int SENDING_BLOCK_SIZE = 1024; + for(int i = 0; i < input.length; i += SENDING_BLOCK_SIZE){ + // Last chunk + if(i + SENDING_BLOCK_SIZE > input.length){ + stdin.write(input, i, input.length-i); + break; + } + // Feed the data to the command-line process in chunks + else{ + stdin.write(input, i, SENDING_BLOCK_SIZE); + stdin.flush(); + } } stdin.flush(); stdin.close(); @@ -366,17 +399,13 @@ throws java.lang.Exception{ MobyService service = super.createServiceFromConfig(request); - javax.servlet.ServletConfig config = getServletConfig(); - - if(config == null){ - throw new Exception("There is no servlet configuration available"); + if(getCoCInitParameter(EMBOSS_ROOT_PARAM) != null){ + embossRootDirName = getCoCInitParameter(EMBOSS_ROOT_PARAM); } - - if(config.getInitParameter(EMBOSS_ROOT_PARAM) == null){ + else{ throw new Exception("No parameter called " + EMBOSS_ROOT_PARAM + " was found in the servlet configuration"); } - embossRootDirName = config.getInitParameter(EMBOSS_ROOT_PARAM); if(embossRootDirName.length() == 0){ throw new Exception("Parameter " + EMBOSS_ROOT_PARAM + " was blank in the servlet configuration"); @@ -393,7 +422,8 @@ ") exists, but is not a directory, as expected"); } // See if it's really the emboss root (has bin dir) - String embossBinDirName = embossRootDirName+File.separator+"bin"; + String slash = File.separator; + String embossBinDirName = embossRootDirName+slash+"bin"; File embossBinDir = new File(embossBinDirName); if(!embossBinDir.exists()){ throw new Exception("The EMBOSS binaries directory inferred from " + @@ -405,8 +435,23 @@ "the servlet configuration (" + embossBinDirName + ") exists, but is not a directory, as expected"); } - String programName = config.getServletName(); - + + String programName = null; + if(getServletConfig() != null){ + programName = getServletConfig().getServletName(); + } + if(programName == null && getServletContext() != null){ + programName = getServletContext().getServletContextName(); + } + if(programName == null || programName.length() == 0){ + throw new Exception("Could not determine the program name, no servlet " + + "name or servlet context name is available"); + } + if(programName.length() == 0){ + throw new Exception("The program name is blank, based on the available " + + "servlet and servlet context names"); + } + // See that the emboss root and program work together programBinaryFile = new File(embossBinDir, programName); if(!programBinaryFile.exists()){ @@ -420,13 +465,12 @@ ") exists, but is not a file, as expected"); } - String slash = File.separator; // The default location EMBOSS uses is the default we'll use... String acdFileName = embossRootDir.getPath()+slash+"share"+slash+"EMBOSS"+slash+ "acd"+slash+programName+".acd"; // Unless overriden in the config... - if(config.getInitParameter(ACD_FILE_PARAM) != null){ - acdFileName = config.getInitParameter(ACD_FILE_PARAM); + if(getCoCInitParameter(ACD_FILE_PARAM) != null){ + acdFileName = getCoCInitParameter(ACD_FILE_PARAM); if(acdFileName.length() == 0){ throw new Exception("Parameter " + ACD_FILE_PARAM + " was blank in the servlet configuration"); @@ -444,8 +488,8 @@ acdRootDirName = acdFile.getParent(); URL regexRulesURL = null; - if(config.getInitParameter(ACD_RULES_LOCATION_PARAM) != null){ - String rulesLocationName = config.getInitParameter(ACD_RULES_LOCATION_PARAM); + if(getCoCInitParameter(ACD_RULES_LOCATION_PARAM) != null){ + String rulesLocationName = getCoCInitParameter(ACD_RULES_LOCATION_PARAM); if(rulesLocationName.length() == 0){ throw new Exception("Parameter " + ACD_RULES_LOCATION_PARAM + " was blank in the servlet configuration (please " + @@ -489,8 +533,8 @@ } URL xsltRulesURL = null; - if(config.getInitParameter(MOBY_RULES_LOCATION_PARAM) != null){ - String rulesLocationName = config.getInitParameter(MOBY_RULES_LOCATION_PARAM); + if(getCoCInitParameter(MOBY_RULES_LOCATION_PARAM) != null){ + String rulesLocationName = getCoCInitParameter(MOBY_RULES_LOCATION_PARAM); if(rulesLocationName.length() == 0){ throw new Exception("Parameter " + MOBY_RULES_LOCATION_PARAM + " was blank in the servlet configuration (please " + @@ -543,19 +587,21 @@ textClient = new TextClient(); textClient.addMappingsFromURL(xsltRulesURL); + boolean useAdvancedParams = Boolean.parseBoolean(getCoCInitParameter(EMBOSS_ADV_PARAMS_PARAM)); + // All the parameters have been specified correctly, now check the ACD file // and create the MOBYService signature from it. try{ - configureServiceFromACDFile(service, acdFile); + configureServiceFromACDFile(service, acdFile, useAdvancedParams); } catch(Exception e){ log("While parsing the ACD file (" + acdFileName + ")", e); throw new Exception("While parsing the ACD file (" + acdFileName + "): " + e); } - // Override params? - if(config.getInitParameter(EMBOSS_PARAMS_PARAM) != null){ - for(String param: config.getInitParameter(EMBOSS_PARAMS_PARAM).split(",")){ + // Override params? (will also add non-existing params if you really want) + if(getCoCInitParameter(EMBOSS_PARAMS_PARAM) != null){ + for(String param: getCoCInitParameter(EMBOSS_PARAMS_PARAM).split(",")){ String[] specs = param.split(":"); if(specs.length != 2){ log("While parsing the " + EMBOSS_PARAMS_PARAM + " specs, item \""+ @@ -573,8 +619,8 @@ // A parameter telling us what hard-coded output file name patterns // are used in the ACD program (i.e. ones we can't specify ourselves on the command line, // so we need to know them in order to hand them back to the user). - if(config.getInitParameter(EMBOSS_OUTPUT_PARAM) != null){ - String[] specs = config.getInitParameter(EMBOSS_OUTPUT_PARAM).split(":"); + if(getCoCInitParameter(EMBOSS_OUTPUT_PARAM) != null){ + String[] specs = getCoCInitParameter(EMBOSS_OUTPUT_PARAM).split(":"); if(specs.length != 2){ throw new Exception("While parsing the " + EMBOSS_OUTPUT_PARAM + " specs, "+ "the value did not have the expected \"name:regex\" format"); @@ -599,19 +645,24 @@ } } + binaryDataType = MobyDataType.getDataType(MobyDataBytes.BASE64_DATATYPE); + return service; } /** * Parses the ACD file and sets the MOBY signature parameters appropriately. */ - public void configureServiceFromACDFile(MobyService service, File acdFile) throws Exception{ + public void configureServiceFromACDFile(MobyService service, File acdFile, boolean useAdvancedParams) + throws Exception{ ACDFile parsedACDData = new ACDFile(acdFile); configureServiceFromACDApplication(service, parsedACDData.getApplicationSection()); configureServiceFromACDInput(service, parsedACDData.getInputSection()); configureServiceFromACDParams(service, parsedACDData.getAdditionalParamsSection()); - configureServiceFromACDParams(service, parsedACDData.getAdvancedParamsSection()); + if(useAdvancedParams){ + configureServiceFromACDParams(service, parsedACDData.getAdvancedParamsSection()); + } configureServiceFromACDOutput(service, parsedACDData.getOutputSection()); } @@ -632,8 +683,8 @@ "but got \"" + entries.get(ACDFile.BLOCK_TYPE_KEY) + "\""); } - // Get the service name and description - service.setName(entries.get(ACDFile.BLOCK_NAME_KEY)); + // service.setName(entries.get(ACDFile.BLOCK_NAME_KEY)); + // Get the service description if(entries.containsKey("documentation")){ service.setDescription(entries.get("documentation")); } @@ -660,9 +711,13 @@ // Make sure it maps to a MOBY Input if(!paramUsed.containsKey(acdInputName)){ + String declInputNames = ""; + for(String inputName: paramUsed.keySet()){ + declInputNames = inputName+" "; + } throw new Exception("A required ACD input parameter ("+acdInputName+ ") does not have a matching declaration in the " + - "servlet configuration"); + "servlet configuration ( "+declInputNames+")"); } MobyPrimaryData mobyPrimaryInput = paramUsed.get(acdInputName); From gordonp at dev.open-bio.org Wed Apr 11 21:03:15 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 11 Apr 2007 21:03:15 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704120103.l3C13FqL030802@dev.open-bio.org> gordonp Wed Apr 11 21:03:14 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv30766/src/main/ca/ucalgary/seahawk/gui Modified Files: MobySecondaryInputGUI.java Log Message: Fixed boolean param parsing moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobySecondaryInputGUI.java,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobySecondaryInputGUI.java,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/gui/MobySecondaryInputGUI.java 2007/04/03 02:33:57 1.4 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobySecondaryInputGUI.java 2007/04/12 01:03:14 1.5 @@ -246,8 +246,10 @@ widget.add(makeJLabel(msdi)); JCheckBox checkbox = new JCheckBox(); checkbox.setSelected(defaultValue.toLowerCase().equals("true") || + defaultValue.toLowerCase().equals("yes") || defaultValue.equals("1") || - defaultValue.equals("T")); + defaultValue.equals("T") || + defaultValue.equals("Y")); data2widget.put(msdi, checkbox); widget.add(checkbox); @@ -463,10 +465,13 @@ newValue = ((JTextComponent) widget).getText(); msdi.setValue(newValue.toString()); } + else if(widget instanceof JCheckBox){ + msdi.setValue(""+((JCheckBox) widget).isSelected()); + } else{ logger.error("IllegalArgumentException: GUI Component for " + msdi.getName() + " was neither a JComboBox nor a " + - "JTextComponent as expected"); + "JTextComponent nor a JCheckBox as expected"); throw new IllegalArgumentException(); } } From mwilkinson at dev.open-bio.org Thu Apr 12 14:22:16 2007 From: mwilkinson at dev.open-bio.org (Mark Wilkinson) Date: Thu, 12 Apr 2007 14:22:16 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704121822.l3CIMGHW032668@dev.open-bio.org> mwilkinson Thu Apr 12 14:22:16 EDT 2007 Update of /home/repository/moby/moby-live/Docs In directory dev.open-bio.org:/tmp/cvs-serv32642 Added Files: BioMoby 1_0 version 11.pdf Removed Files: BioMoby 1_0 version 6.pdf BioMoby 1_0 version 7.pdf Log Message: final version of the manuscript moby-live/Docs BioMoby 1_0 version 11.pdf,NONE,1.1 BioMoby 1_0 version 6.pdf,1.1,NONE BioMoby 1_0 version 7.pdf,1.1,NONE rcsdiff: /home/repository/moby/moby-live/Docs/RCS/BioMoby,v: No such file or directory rcsdiff: /home/repository/moby/moby-live/Docs/RCS/1_0,v: No such file or directory rcsdiff: /home/repository/moby/moby-live/Docs/RCS/version,v: No such file or directory rcsdiff: /home/repository/moby/moby-live/Docs/RCS/BioMoby,v: No such file or directory rcsdiff: /home/repository/moby/moby-live/Docs/RCS/1_0,v: No such file or directory rcsdiff: /home/repository/moby/moby-live/Docs/RCS/version,v: No such file or directory rcsdiff: /home/repository/moby/moby-live/Docs/RCS/6.pdf,v: No such file or directory rcsdiff: /home/repository/moby/moby-live/Docs/RCS/BioMoby,v: No such file or directory rcsdiff: /home/repository/moby/moby-live/Docs/RCS/1_0,v: No such file or directory rcsdiff: /home/repository/moby/moby-live/Docs/RCS/version,v: No such file or directory rcsdiff: /home/repository/moby/moby-live/Docs/RCS/7.pdf,v: No such file or directory From gordonp at dev.open-bio.org Thu Apr 12 21:55:36 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 12 Apr 2007 21:55:36 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704130155.l3D1ta62000908@dev.open-bio.org> gordonp Thu Apr 12 21:55:36 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data In directory dev.open-bio.org:/tmp/cvs-serv872/src/main/org/biomoby/shared/data Modified Files: MobyDataBytes.java Log Message: Fixed contenmt member typo, made more verbose error messaging moby-live/Java/src/main/org/biomoby/shared/data MobyDataBytes.java,1.5,1.6 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataBytes.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/MobyDataBytes.java 2007/03/12 17:01:29 1.5 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataBytes.java 2007/04/13 01:55:36 1.6 @@ -23,7 +23,7 @@ public class MobyDataBytes extends MobyDataComposite{ public static final String BASE64_DATATYPE = "text-base64"; - public static final String ENCODED_MEMBER_NAME = "contents"; + public static final String ENCODED_MEMBER_NAME = "content"; /** How much is read from a input stream (e.g. file) at once */ public static final int BYTE_READ_SIZE = 4096; @@ -52,6 +52,13 @@ populateMembersFromDOM(element); MobyDataObject contents = get(ENCODED_MEMBER_NAME); + if(contents == null){ + throw new MobyException("The encoded binary member (" + ENCODED_MEMBER_NAME + + ") of the given element (" + + element.getLocalName()+ + ") was missing, but must exist to be a proper " + + BASE64_DATATYPE + " object"); + } if(!(contents instanceof MobyDataString)){ throw new MobyException("The encoded binary member (" + ENCODED_MEMBER_NAME + ") of the given element (" + From gordonp at dev.open-bio.org Thu Apr 12 21:56:12 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 12 Apr 2007 21:56:12 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704130156.l3D1uCqs000952@dev.open-bio.org> gordonp Thu Apr 12 21:56:12 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data In directory dev.open-bio.org:/tmp/cvs-serv916/src/main/org/biomoby/shared/data Modified Files: MobyDataComposite.java Log Message: More data type error checking moby-live/Java/src/main/org/biomoby/shared/data MobyDataComposite.java,1.13,1.14 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataComposite.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataComposite.java 2007/04/08 17:29:29 1.13 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataComposite.java 2007/04/13 01:56:12 1.14 @@ -393,10 +393,22 @@ } MobyRelationship relationship = getDataType().getChild(fieldName); + if(relationship == null){ + relationship = MobyDataType.getDataType(getDataType().getName()).getChild(fieldName); + if(relationship == null){ + String memberNames = ""; + for(MobyRelationship rel: getDataType().getChildren()){ + memberNames += " "+rel.getName(); + } + throw new IllegalArgumentException("The member '" + fieldName + "' for object '"+ getName() + + "' does not exist in the Moby ontology definition for "+ + getDataType().getName() + ", valid member names are:" + memberNames); + } + } MobyDataType childDataType = MobyDataType.getDataType(relationship.getDataTypeName()); if(!value.getDataType().inheritsFrom(childDataType)){ // Incompatible types - throw new IllegalArgumentException("The object member '" + fieldName + "' for object '"+ getName() + + throw new IllegalArgumentException("The member '" + fieldName + "' for object '"+ getName() + "' does not inherit from the required data type " + "(found data type " + value.getDataType().getName()+ ", but require subclass of " + From gordonp at dev.open-bio.org Wed Apr 18 11:28:07 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 18 Apr 2007 11:28:07 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704181528.l3IFS7xQ012123@dev.open-bio.org> gordonp Wed Apr 18 11:28:07 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/resources In directory dev.open-bio.org:/tmp/cvs-serv12088/src/main/ca/ucalgary/services/resources Modified Files: mobyRules.xsl Log Message: Added rules for ABI traces, and DNA sequence-to-plain string moby-live/Java/src/main/ca/ucalgary/services/resources mobyRules.xsl,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/resources/mobyRules.xsl,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/mobyRules.xsl 2007/03/12 14:33:38 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/resources/mobyRules.xsl 2007/04/18 15:28:07 1.2 @@ -52,11 +52,14 @@ because XSLT does not handle variables in the mode attribute. Therefore for each target text data type included in this stylesheet, you must include an if condition here. See http://www.dpawson.co.uk/xsl/sect2/nono.html#d1905e383 - --> + --> + + + @@ -68,6 +71,11 @@ + + + + + + + + + + + + + From gordonp at dev.open-bio.org Wed Apr 18 11:53:59 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 18 Apr 2007 11:53:59 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704181553.l3IFrxH3012189@dev.open-bio.org> gordonp Wed Apr 18 11:53:58 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services In directory dev.open-bio.org:/tmp/cvs-serv12154/src/main/ca/ucalgary/services Modified Files: ACDService.java Log Message: Added support for binary data passthrough, better ACD parameter handling, and change from stdin to temp files for input due to EMBOSS inconsistency of implementing acceptance of stdin moby-live/Java/src/main/ca/ucalgary/services ACDService.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/ACDService.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/services/ACDService.java 2007/04/12 01:02:29 1.2 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/ACDService.java 2007/04/18 15:53:58 1.3 @@ -48,6 +48,7 @@ // Keep track of what MOBY input parameters are to be converted to what ACD types private Map acdTypes; + private Map acdBasicTypes; //holds e.g. string, when acdType for same key is "nucleotide sequence" // For launching command-line programs private Runtime runtime; Vector fixedSecondaryData; @@ -57,6 +58,7 @@ public void init(){ super.init(); acdTypes = new HashMap(); + acdBasicTypes = new HashMap(); runtime = Runtime.getRuntime(); fixedSecondaryData = new Vector(); } @@ -146,8 +148,9 @@ // Transform the moby data to text, unless it's binary data, which will be passed as decoded bytes // Now, for binary data, we have to ignore any fields other than the Base64 encoded one. Sorry! String tempFileSuffix = ".txt"; - if(mobyInputTemplate.getDataType().inheritsFrom(binaryDataType)){ - inputDataBytes = org.apache.axis.encoding.Base64.decode(MobyDataBytes.ENCODED_MEMBER_NAME); + if(inputData instanceof MobyDataBytes){ + //System.err.println("Passing binary data to service"); + inputDataBytes = ((MobyDataBytes) inputData).getBytes(); tempFileSuffix = ".bin"; } else{ @@ -161,11 +164,15 @@ } // Create the required command-line flag for the parameter - if(inputs.length == 1){ + + // Is it a primary param whose value must be passed in directly, as opposed to in a file? + String basicType = acdBasicTypes.get(paramName); + if(basicType != null && + (basicType.equals("string") || basicType.equals("integer") || + basicType.equals("float") || basicType.equals("boolean"))){ // If only one input, we can pass it via stdin command.add("-"+paramName); - command.add("stdin"); - stdin = inputDataBytes; + command.add(new String(inputDataBytes)); } else{ // Otherwise we need to create temporary files to store the data @@ -183,7 +190,10 @@ // User-selected Secondary input for(MobyDataSecondaryInstance mobySecondary: request.getSecondaryData()){ - // Make that no funny business is going on with shell escape characters. + // ASSUMPTION: Don't need to make sure that no funny business is + // going on with shell escape characters in the secondary names and + // values (potential security problem), because we call the string + // array form of Runtime.exec() later, which does not invoke a shell. command.add("-"+mobySecondary.getName()); command.add(mobySecondary.getObject().toString()); } @@ -204,7 +214,7 @@ // Create the required command-line flag for the parameter if(outputs.length == 1){ - // If only one input, we can pass it via stdin + // If only one output, we can grab it via stdout command.add("-"+paramName); command.add("stdout"); } @@ -299,13 +309,18 @@ private String runProgram(MobyDataJob request, String[] command, File workingDir, final byte[] input) throws Exception{ // TODO: ensure $embossRootDirName/lib is in the LD_LIBRARY_PATH, // what is the equivalent in Windows? - Process process = runtime.exec(command, - new String[]{"EMBOSS="+embossRootDirName, - "EMBOSS_ACDROOT="+acdRootDirName}, - workingDir); + //for(String cmdpart: command){ + // System.err.print(cmdpart+" "); + //} + //System.err.println(""); + final Process process = runtime.exec(command, + new String[]{"EMBOSS="+embossRootDirName, + "EMBOSS_ACDROOT="+acdRootDirName}, + workingDir); final OutputStream stdin = process.getOutputStream(); final InputStream stderr = process.getErrorStream(); final InputStream stdout = process.getInputStream(); + final StringBuffer output = new StringBuffer(); // Echo the program's stderr new Thread(){ @@ -323,51 +338,71 @@ } }.start(); - // Write the data to the command's stdin, one line at a time + // Write the data to the command's stdin, in one fell swoop new Thread(){ public void run(){ try{ - final int SENDING_BLOCK_SIZE = 1024; - for(int i = 0; i < input.length; i += SENDING_BLOCK_SIZE){ - // Last chunk - if(i + SENDING_BLOCK_SIZE > input.length){ - stdin.write(input, i, input.length-i); - break; - } - // Feed the data to the command-line process in chunks - else{ - stdin.write(input, i, SENDING_BLOCK_SIZE); - stdin.flush(); - } - } + stdin.write(input); stdin.flush(); stdin.close(); } catch(Exception e){ - System.err.println("Caught exception while sending data to the command: "+e); + // Okay, so sometimes Java sits there waiting to write data + // even after the write call (due to buffering?), then throws + // an Exception because the stream was closed in the main thread + // below. How do we distinguish between genuine write issues and this? + // By checking if the job is finished already and exited normally and produced data. + // If so, don't bother reporting the error, otherwise report it + // because the program may be missing data! + try{ + Thread.sleep(1000);} + catch(Exception te){ + System.err.println("Warning: grace period for stdin close " + + "not met, thread was interrupted: " + te); + } + //grace period between stream close and process end + boolean completed = true; + int eVal = 0; + try{ + eVal = process.exitValue(); + } catch(IllegalThreadStateException itse){ + completed = false; + } + // 3 conditions, from more most severe to least + if(!completed){ + System.err.println("Caught exception while sending data to the command" + + "(while process is still running): "+e); + } + else if(eVal != 0){ + System.err.println("Caught exception while sending data to the command" + + "(and the process had a non-zero return value): "+e); + } + else if(output.length() == 0){ + System.err.println("Caught exception while sending data to the command " + + "(and the process output is blank): "+e); + // Not *necessarily* a real error + // (grace time may be exceeded), but maybe, + // so print it anyway + e.printStackTrace(); + } + else{ + return; //all okay, we only got here becuase of the java superfluous buffering issue + } e.printStackTrace(); } } }.start(); - final StringBuffer output = new StringBuffer(); - // Read the program's output (in a thread, to avoid deadlocks) - new Thread(){ - public void run(){ - try{ - byte[] data = new byte[1024]; - for(int c = stdout.read(data, 0, data.length); c != -1; c = stdout.read(data, 0, 1024)){ - output.append(new String(data, 0, c)); - } - } - catch(Exception e){ - System.err.println("Caught exception while receiving data from the command-line program: "+e); - e.printStackTrace(); - } + try{ + byte[] data = new byte[1024]; + for(int c = stdout.read(data, 0, data.length); c != -1; c = stdout.read(data, 0, 1024)){ + output.append(new String(data, 0, c)); + } + } + catch(Exception e){ + throw new Exception("Caught exception while receiving data from the command-line program: "+e); + } - } - }.start(); - int exitVal = process.waitFor(); if(exitVal != 0){ addException(new MobyServiceException(MobyServiceException.WARNING, @@ -658,7 +693,11 @@ ACDFile parsedACDData = new ACDFile(acdFile); configureServiceFromACDApplication(service, parsedACDData.getApplicationSection()); - configureServiceFromACDInput(service, parsedACDData.getInputSection()); + List> combinedInput = new ArrayList>(parsedACDData.getInputSection()); + combinedInput.addAll(parsedACDData.getRequiredParamsSection()); + configureServiceFromACDInput(service, combinedInput); + //configureServiceFromACDInput(service, parsedACDData.getInputSection()); + //configureServiceFromACDInput(service, parsedACDData.getRequiredParamsSection()); configureServiceFromACDParams(service, parsedACDData.getAdditionalParamsSection()); if(useAdvancedParams){ configureServiceFromACDParams(service, parsedACDData.getAdvancedParamsSection()); @@ -699,10 +738,10 @@ protected void configureServiceFromACDInput(MobyService service, List> spec) throws Exception{ MobyPrimaryData[] mobyInputTypes = service.getPrimaryInputs(); - Map paramUsed = new HashMap(); + Map paramUnused = new HashMap(); for(MobyPrimaryData mobyPrimaryInput: mobyInputTypes){ - paramUsed.put(mobyPrimaryInput.getName(), mobyPrimaryInput); + paramUnused.put(mobyPrimaryInput.getName(), mobyPrimaryInput); } for(MobyData acdInput: specToMoby(spec)){ @@ -710,9 +749,9 @@ String acdInputName = acdInput.getName(); // Make sure it maps to a MOBY Input - if(!paramUsed.containsKey(acdInputName)){ + if(!paramUnused.containsKey(acdInputName)){ String declInputNames = ""; - for(String inputName: paramUsed.keySet()){ + for(String inputName: paramUnused.keySet()){ declInputNames = inputName+" "; } throw new Exception("A required ACD input parameter ("+acdInputName+ @@ -720,25 +759,26 @@ "servlet configuration ( "+declInputNames+")"); } - MobyPrimaryData mobyPrimaryInput = paramUsed.get(acdInputName); + MobyPrimaryData mobyPrimaryInput = paramUnused.get(acdInputName); if(!textClient.canProduceTextTypeFromMoby(acdTypes.get(acdInputName), mobyPrimaryInput)){ throw new Exception("No XSLT rules exist that can produce the requested " + "text type '" + acdTypes.get(acdInputName) + - "' from the given MOBY object type (" + + "' (acd input parameter " + acdInputName + + ") from the given MOBY object type (" + mobyPrimaryInput.getDataType().getName()+")"); } // If it exists, make sure it's of the right type if(acdInput instanceof MobyPrimaryDataSimple && - paramUsed.get(acdInputName) instanceof MobyPrimaryDataSet){ + paramUnused.get(acdInputName) instanceof MobyPrimaryDataSet){ throw new Exception("The MOBY input parameter \""+acdInputName+ "\" is a Collection, but the ACD input parameter is " + "a simple (expected a declaration like \""+acdInputName+":"+ ""+ - paramUsed.get(acdInputName).getDataType().getName()+ + paramUnused.get(acdInputName).getDataType().getName()+ "\")"); } - paramUsed.remove(acdInputName); + paramUnused.remove(acdInputName); } // Secondary params read from the ACD spec always get included else if(acdInput instanceof MobySecondaryData){ @@ -751,9 +791,9 @@ } } - if(!paramUsed.isEmpty()){ + if(!paramUnused.isEmpty()){ String unmappedParams = ""; - for(String param: paramUsed.keySet()){ + for(String param: paramUnused.keySet()){ unmappedParams += " "+param; } throw new Exception("There are superfluous MOBY input parameters specified that do " + @@ -852,26 +892,27 @@ // Secondary Parameter types String additional = block.get("additional"); String deFault = block.get("default"); - if(additional != null && additional.toUpperCase().equals("Y") || - deFault != null && deFault.toUpperCase().equals("N")){ + //System.err.println("param: " + acdName + "/" + acdType +" " + additional +" ("+deFault+")"); + if((additional != null && additional.toUpperCase().equals("Y")) || + deFault != null){ if("boolean".equals(acdType) || "toggle".equals(acdType)){ MobySecondaryData bool = new MobySecondaryData(acdName); bool.setDataType(MobySecondaryData.BOOLEAN_TYPE); - bool.setDefaultValue(block.get("default")); + bool.setDefaultValue(deFault); bool.setDescription(block.get("help")); mobyDataType = bool; } else if("string".equals(acdType) || "range".equals(acdType)){ MobySecondaryData string = new MobySecondaryData(acdName); string.setDataType(MobySecondaryData.STRING_TYPE); - string.setDefaultValue(block.get("default")); + string.setDefaultValue(deFault); string.setDescription(block.get("help")); mobyDataType = string; } else if("list".equals(acdType)){ MobySecondaryData enumeration = new MobySecondaryData(acdName); enumeration.setDataType(MobySecondaryData.STRING_TYPE); - enumeration.setDefaultValue(block.get("default")); + enumeration.setDefaultValue(deFault); enumeration.setDescription(block.get("information")); processACDList(enumeration, block.get("values"), block.get("delimiter"), block.get("codedelimiter")); @@ -880,7 +921,7 @@ else if("integer".equals(acdType)){ MobySecondaryData integer = new MobySecondaryData(acdName); integer.setDataType(MobySecondaryData.INTEGER_TYPE); - integer.setDefaultValue(block.get("default")); + integer.setDefaultValue(deFault); integer.setDescription(block.get("information")); integer.setMinValue(block.get("minimum")); integer.setMaxValue(block.get("maximum")); @@ -889,7 +930,7 @@ else if("float".equals(acdType)){ MobySecondaryData floating = new MobySecondaryData(acdName); floating.setDataType(MobySecondaryData.FLOAT_TYPE); - floating.setDefaultValue(block.get("default")); + floating.setDefaultValue(deFault); floating.setDescription(block.get("information")); floating.setMinValue(block.get("minimum")); floating.setMaxValue(block.get("maximum")); @@ -897,6 +938,7 @@ } else{ System.err.println("Skipping secondary parameter that is not a primitive in MOBY:" + acdType); + continue; } } //end if(additional) // else it's a required parameter @@ -910,10 +952,26 @@ else{ mobyDataType = new MobyPrimaryDataSimple(acdName); } + + // There are instances where the ACD data type is generic, such as + // "infile", "outfile", "string", and "datafile" + // We will not handle the case of "list" data type, because this was enumerated anyway. + if((acdType.equals("infile") || + acdType.equals("outfile") || + acdType.equals("string") || + acdType.equals("datafile")) && + block.containsKey("knowntype")){ + // In such cases, keep track of the basic type (e.g. string, so when we build + // the command line we know how to represent the data) + acdBasicTypes.put(acdName, acdType); + acdType = block.get("knowntype"); + } acdTypes.put(acdName, acdType); } - mobyDataTypes.add(mobyDataType); + if(mobyDataType != null){ + mobyDataTypes.add(mobyDataType); + } } return mobyDataTypes; From gordonp at dev.open-bio.org Wed Apr 18 11:55:18 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 18 Apr 2007 11:55:18 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704181555.l3IFtI06012232@dev.open-bio.org> gordonp Wed Apr 18 11:55:18 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util In directory dev.open-bio.org:/tmp/cvs-serv12197/src/main/ca/ucalgary/seahawk/util Modified Files: MobyUtils.java Log Message: Added binary data support, and create GlobalKeyword only if data is not also a sequence moby-live/Java/src/main/ca/ucalgary/seahawk/util MobyUtils.java,1.5,1.6 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/MobyUtils.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/util/MobyUtils.java 2007/02/08 16:59:58 1.5 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/MobyUtils.java 2007/04/18 15:55:18 1.6 @@ -2,17 +2,21 @@ import ca.ucalgary.seahawk.gui.MobyContentGUI; import ca.ucalgary.seahawk.gui.MobyServicesGUI; +import ca.ucalgary.seahawk.services.MobyClient; import org.biomoby.shared.data.*; import org.biomoby.shared.MobyDataType; import org.biomoby.shared.MobyNamespace; +import java.io.ByteArrayOutputStream; +import java.io.InputStream; +import java.net.URL; import java.util.Vector; import javax.swing.JLabel; /** * Contains utility methods for Moby Object creation from unstructured data, and for - * creating the Seahawk GUI. + * creating the Seahawk GUI. */ public class MobyUtils{ @@ -21,6 +25,41 @@ private static MobyContentGUI mobyContentGUI = null; private static MobyServicesGUI mobyServicesGUI = null; + /** + * The purpose of this method is to create a MOBY document to encapsulate + * a binary data object stored at the given URL. If the data does + * not represent a single binary MOBY object, the method returns null. + * If the provided client or URL is null, null will be returned too. + */ + public static MobyContentInstance convertURLtoMobyBinaryData(MobyClient client, URL url)throws Exception{ + if(url == null || client == null){ + return null; + } + + ByteArrayOutputStream bytes = new ByteArrayOutputStream(); + InputStream is = url.openStream(); + + // Slurp up the file as bytes + byte[] buffer = new byte[4096]; + for(int bytesRead = is.read(buffer); bytesRead != -1; bytesRead = is.read(buffer)){ + bytes.write(buffer, 0, bytesRead); + } + + // Find MOBY Objects in it + MobyDataObject[] foundObjects = client.getMobyObjects(bytes.toByteArray(), + MobyDataType.getDataType(MobyDataBytes.BASE64_DATATYPE)); + // 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]); + 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){ if(data == null){ return new MobyDataInstance[0]; @@ -39,14 +78,6 @@ strObject.setPrimaryNamespace(new MobyNamespace("seahawk")); objects.add(strObject); - // If it's a single word, give keyword options - if(data.trim().matches("^[A-Za-z0-9_-]{3,}$")){ - objects.add(new MobyDataComposite("Global_Keyword", - "dummy_name", - "seahawk", - data.trim())); - } - // See if it's sequence MobyDataComposite mdc = createMobySequence(data, "user-selection"); if(mdc != null){ @@ -63,6 +94,16 @@ mdc.setName(objectName); objects.add(mdc); } + // If it's a single word, give keyword options + else{ + if(data.trim().matches("^[A-Za-z0-9_-]{3,35}$")){ + objects.add(new MobyDataComposite("Global_Keyword", + "dummy_name", + "seahawk", + data.trim())); + } + } + return (MobyDataInstance[]) objects.toArray(new MobyDataInstance[objects.size()]); } From gordonp at dev.open-bio.org Wed Apr 18 11:57:01 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 18 Apr 2007 11:57:01 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704181557.l3IFv1YP012275@dev.open-bio.org> gordonp Wed Apr 18 11:57: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-serv12240/src/main/ca/ucalgary/seahawk/gui Modified Files: MobyContentGUI.java Log Message: Fixed possible string out of bounds exception for tab labels moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyContentGUI.java,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.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/gui/MobyContentGUI.java 2007/04/03 02:34:08 1.6 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java 2007/04/18 15:57:00 1.7 @@ -667,6 +667,9 @@ } else{ int allowableLen = MAX_TAB_NAME_LENGTH-shortName.length(); + if(allowableLen > path.length()){ + allowableLen = path.length(); + } shortName = shortName+"..."+path.substring(path.length()-allowableLen); } } From gordonp at dev.open-bio.org Wed Apr 18 11:58:08 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 18 Apr 2007 11:58:08 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704181558.l3IFw81M012339@dev.open-bio.org> gordonp Wed Apr 18 11:58:08 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services In directory dev.open-bio.org:/tmp/cvs-serv12304/src/main/ca/ucalgary/seahawk/services Modified Files: MobyComplexBuilder.java Log Message: Fixed binary data replaceAll equivalent moby-live/Java/src/main/ca/ucalgary/seahawk/services MobyComplexBuilder.java,1.5,1.6 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyComplexBuilder.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/services/MobyComplexBuilder.java 2007/04/08 17:26:24 1.5 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyComplexBuilder.java 2007/04/18 15:58:08 1.6 @@ -206,22 +206,21 @@ for(int j = 0; j <= matcher.groupCount(); j++){ // A replaceAll() for binary data if(data != null){ - (new Exception("Binary replaceAll()")).printStackTrace(); int srcPos = 0; - for(int varIndex = result.indexOf("\\$"+j, srcPos); + for(int varIndex = result.indexOf("$"+j, srcPos); varIndex != -1; - varIndex = result.indexOf("\\$"+j, srcPos)){ - int varValueLength = matcher.end(j)-matcher.start(j)+1; - - byte[] newResultBytes = new byte[resultBytes.length+varValueLength]; - if(varIndex > 0){ + varIndex = result.indexOf("$"+j, srcPos)){ + int varValueLength = matcher.end(j)-matcher.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); - int remaining = result.length()-varIndex-2; + int remaining = result.length()-varIndex-varLen; if(remaining > 0){ - System.arraycopy(resultBytes, varIndex+2, newResultBytes, varIndex+varValueLength, - result.length()-varIndex-2); + System.arraycopy(resultBytes, varIndex+varLen, newResultBytes, varIndex+varValueLength, + result.length()-varIndex-varLen); } srcPos += varIndex + varValueLength + 1; resultBytes = newResultBytes; From gordonp at dev.open-bio.org Wed Apr 18 11:59:01 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 18 Apr 2007 11:59:01 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704181559.l3IFx0nI012382@dev.open-bio.org> gordonp Wed Apr 18 11:59:00 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-serv12347/src/main/ca/ucalgary/seahawk/gui/test Modified Files: SeahawkTestCase.java Log Message: Test service category update moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test SeahawkTestCase.java,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test/SeahawkTestCase.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/gui/test/SeahawkTestCase.java 2007/04/04 01:29:20 1.6 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test/SeahawkTestCase.java 2007/04/18 15:59:00 1.7 @@ -699,7 +699,7 @@ public void testRunServiceSecondariesAndSCUFL() throws Exception{ try{ - findService(TEST_DNA_SEQ, "Bioinformatics", "..."); + findService(TEST_DNA_SEQ, "Analysis", "..."); } catch(Exception e){ e.printStackTrace(); fail("Error while a finding service ending with \"...\" " + From gordonp at dev.open-bio.org Wed Apr 18 12:01:00 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 18 Apr 2007 12:01:00 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704181601.l3IG10xq012427@dev.open-bio.org> gordonp Wed Apr 18 12:01:00 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services In directory dev.open-bio.org:/tmp/cvs-serv12392/src/main/ca/ucalgary/seahawk/services Modified Files: MobyClient.java Log Message: Made less verbose, fixed binary data search pass-through for non-binary data moby-live/Java/src/main/ca/ucalgary/seahawk/services MobyClient.java,1.10,1.11 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.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/services/MobyClient.java 2007/04/08 17:26:24 1.10 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java 2007/04/18 16:01:00 1.11 @@ -554,10 +554,14 @@ public MobyDataInstance getMobyObject(Map resultParts, MobyPrimaryData dataTemplate) throws Exception, MobyServiceException{ Vector results = new Vector(); + + // System.err.println("Data has " + resultParts.size() + " parts"); // The output parameter *potentially* has multiple parts - // (e.g. multiple .png file from EMBOSS's "banana" program) + // (e.g. multiple .png files from EMBOSS's "banana" program) // hence the nested for loops (part iteration, followed by created-object iteration) for(String resultPartName: resultParts.keySet()){ + + //System.err.println("About to check part "+ resultPartName); for(MobyDataObject resultPart: getMobyObjects(resultParts.get(resultPartName), dataTemplate.getDataType())){ // Maintain the name for the object in the collection, as banana.1.png, banana.2.png, etc. // is useful information for the end-user for making sense of them together! (left to right) @@ -608,10 +612,17 @@ } else if(results.size() > 1){ if(dataTemplate instanceof MobyPrimaryDataSimple){ - System.err.println("The data map provided " + - "was a collection, but the request was to return a simple. " + + // In this case, eliminate any higher-up objects that + // have the exact same contents as the same members who are their + // subtypes, as these are superfluous. + + System.err.println("Multiple Moby objects were found in the text data, " + + "but the request was to return a simple. " + "Only the first value in the collection has been returned."); - // TODO: should we instead return the one deepest in the heirarchy (or with the most members)? + for(MobyDataObject result: results){ + System.err.println("Found object: " + result.getDataType().getName()); + } + // TODO: should we instead return the one deepest in the hierarchy (or with the most members)? return results.elementAt(0); } else{ @@ -647,8 +658,11 @@ 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))){ - return getMobyObjects(new String(rawData)); + //System.err.println("Data type does not inerit from Base64, continuing with string-based search..."); + return getMobyObjects(new String(rawData), targetDataType); } + //System.err.println("Data type " + targetDataType.getName() + " inherits from " + MobyDataBytes.BASE64_DATATYPE + + // ", continuing with byte-based search..."); String rawDataAsString = null; @@ -656,18 +670,22 @@ for(Pattern pattern: regexMap.keySet()){ MobyComplexBuilder rule = regexMap.get(pattern); + //System.err.print("Checking" + rule.getDataType().getName()+":"); + //for(MobyDataType parent: rule.getDataType().getLineage()){System.err.print(" " + parent.getName());} + //System.err.println(""); if(rule.getDataType().inheritsFrom(targetDataType)){ + //System.err.println("Checking rule that generates data type " + rule.getDataType().getName()); // Only build the string representation of the byte array if we // found a rule that applies (since it's a somewhat expensive operation // to do the conversion) if(rawDataAsString == null){ rawDataAsString = bytesToString(rawData); - System.err.println("Start of data is " + rawDataAsString.substring(0, 4)); + //System.err.println("Start of data is " + rawDataAsString.substring(0, 4)); } Matcher matcher = pattern.matcher(rawDataAsString); while(matcher.find()){ - System.err.println("Found match for binary data"); + //System.err.println("Found match for binary data"); try{ MobyDataObject mobyObj = rule.apply(matcher, rawData); if(mobyObj != null){ From gordonp at dev.open-bio.org Wed Apr 18 12:02:09 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 18 Apr 2007 12:02:09 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704181602.l3IG29t5012489@dev.open-bio.org> gordonp Wed Apr 18 12:02:09 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util In directory dev.open-bio.org:/tmp/cvs-serv12458/src/main/ca/ucalgary/seahawk/util Added Files: HTMLUtils.java Log Message: New file for data reformtting utils of Seahawk HTML display moby-live/Java/src/main/ca/ucalgary/seahawk/util HTMLUtils.java,NONE,1.1 From gordonp at dev.open-bio.org Wed Apr 18 12:04:06 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 18 Apr 2007 12:04:06 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704181604.l3IG46D9012553@dev.open-bio.org> gordonp Wed Apr 18 12:04:06 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv12518/src/main/ca/ucalgary/seahawk/gui Modified Files: MobyContentPane.java Log Message: Added better binary data support, and only add to history if load successful moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyContentPane.java,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.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/gui/MobyContentPane.java 2007/04/03 02:34:08 1.6 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java 2007/04/18 16:04:06 1.7 @@ -209,17 +209,6 @@ return; } - if(addToHistory){ - // Are we truncating the history? (i.e. loading a new doc in the middle of the history) - if(historyIndex != history.size()-1){ - history.setSize(historyIndex+1); - } - history.add(url); - - historyIndex = history.size()-1; - contentGUI.updateHistory(this); - } - try { // 1000 is initial, unimportant guess as to resulting HTML size StringBuffer resultBuffer = new StringBuffer(1000); @@ -238,17 +227,25 @@ // Tell the stylesheet the URL of the moby data (it will create xpointers to it) contentGUI.getTransformer().setParameter(XSL_DOC_SOURCE_PARAM, url.toString()); // Do the actual transformation - StringWriter stringWriter = new StringWriter(1000); + String htmlContents = "[Seahawk Internal Error]"; try{ + StringWriter stringWriter = new StringWriter(1000); contentGUI.getTransformer().transform(new StreamSource(url.openStream()), new StreamResult(stringWriter)); + htmlContents = stringWriter.toString(); + htmlContents = HTMLUtils.encapsulateBinaryData(url, htmlContents); } catch(TransformerException te){ status.setText("Sorry! Could not transform the MOBY data into presentation form"); logger.error("Sorry! Could not transform the MOBY data into presentation form: " + te); return; } - String htmlContents = stringWriter.toString(); + catch(Exception e){ + 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"); + } // Looks like tab-formatted text (at least 3 tabs)? if(htmlContents.indexOf('\t') != -1){ htmlContents = htmlContents.replaceAll(">(([^<]*\t){3,}[^<]+)", ">
$1
"); @@ -295,6 +292,27 @@ } 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{ + MobyContentInstance mobyContents = + MobyUtils.convertURLtoMobyBinaryData(servicesGUI.getMobyClient(), url); + if(mobyContents != null){ + File mobyRepresentation = File.createTempFile("seahawkBase64BinData", ".xml"); + mobyRepresentation.deleteOnExit(); + FileWriter fw = new FileWriter(mobyRepresentation); + MobyDataUtils.toXMLDocument(fw, mobyContents); + fw.close(); + // Recursive call with new URL, should be displayed using the MOBY XSLT + gotoURL(mobyRepresentation.toURI().toURL(), addToHistory); + return; + } + } catch(Exception e){ + e.printStackTrace(); + editorPane.setText("Failure in loading MOBYfied binary data:\n" + e); + 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); } else{ @@ -311,6 +329,17 @@ ioe.printStackTrace(); } + if(addToHistory){ + // Are we truncating the history? (i.e. loading a new doc in the middle of the history) + if(historyIndex != history.size()-1){ + history.setSize(historyIndex+1); + } + history.add(url); + + historyIndex = history.size()-1; + contentGUI.updateHistory(this); + } + // This page has had a title associated with it before...reuse it! if(historyTabLabels.containsKey(url)){ tabbedPane.setTitleAt(tabbedPane.indexOfComponent(this), historyTabLabels.get(url).toString()); From gordonp at dev.open-bio.org Wed Apr 18 12:06:34 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 18 Apr 2007 12:06:34 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704181606.l3IG6YnG012616@dev.open-bio.org> gordonp Wed Apr 18 12:06:33 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/test In directory dev.open-bio.org:/tmp/cvs-serv12581/src/main/ca/ucalgary/services/test Modified Files: ACDServiceTestCase.java Log Message: Added check of binary data holder to ensure no corruption of the data occurs moby-live/Java/src/main/ca/ucalgary/services/test ACDServiceTestCase.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/test/ACDServiceTestCase.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/services/test/ACDServiceTestCase.java 2007/04/12 00:57:32 1.2 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/test/ACDServiceTestCase.java 2007/04/18 16:06:33 1.3 @@ -24,7 +24,7 @@ private final static String ACDTEST_MOBY_XML = "ca/ucalgary/services/test/mobyDNASeq.xml"; private final static String ACDTEST_BINARY_DATA1 = "ca/ucalgary/services/test/mobyTest1.png"; private final static String ACDTEST_BINARY_DATA2 = "ca/ucalgary/services/test/mobyTest2.png"; - private final static String MOBY_PNG_DATATYPE = "b64_Encoded_PNG"; + private final static String MOBY_PNG_DATATYPE = "PNGFormatImage"; public ACDServiceTestCase(String name){ super(name); @@ -74,6 +74,7 @@ } assertNotNull("The binary test data resource " + u1.toString() + " could not be loaded", binaryDataParts.get(u1.toString())); + try{ binaryDataParts.put(u2.toString(), getURLData(u2)); } catch(Exception e){ @@ -82,6 +83,17 @@ } assertNotNull("The binary test data resource " + u2.toString() + " could not be loaded", binaryDataParts.get(u2.toString())); + // Check that the byte holder class works okay + MobyDataBytes byteObject = null; + try{ + byteObject = new MobyDataBytes("foo", binaryDataParts.get(u2.toString())); + } catch(Exception e){ + e.printStackTrace(); + fail("Could not build a MobyDataBytes object from a byte array: "+ e); + } + assertTrue("The MobyDataBytes object does not return the same byte array " + + "as given in its constructor (data corruption occured)", + Arrays.equals(byteObject.getBytes(), binaryDataParts.get(u2.toString()))); MobyDataObjectSet pngCollectionTemplate = new MobyDataObjectSet("test", new MobyDataObject[]{new MobyDataComposite(MOBY_PNG_DATATYPE)}); From gordonp at dev.open-bio.org Wed Apr 18 12:07:41 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 18 Apr 2007 12:07:41 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704181607.l3IG7fLp012680@dev.open-bio.org> gordonp Wed Apr 18 12:07:41 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services In directory dev.open-bio.org:/tmp/cvs-serv12645/src/main/ca/ucalgary/seahawk/services Modified Files: TextClient.java Log Message: Made less verbose moby-live/Java/src/main/ca/ucalgary/seahawk/services TextClient.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/TextClient.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/services/TextClient.java 2007/04/12 00:59:42 1.2 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/TextClient.java 2007/04/18 16:07:41 1.3 @@ -214,7 +214,7 @@ } if(stringWriter.getBuffer().length() > 0){ - System.err.println("Result of transformation: " + stringWriter.toString()); + //System.err.println("Result of transformation: " + stringWriter.toString()); return stringWriter.toString(); } } From gordonp at dev.open-bio.org Wed Apr 18 12:08:15 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 18 Apr 2007 12:08:15 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704181608.l3IG8FQq012723@dev.open-bio.org> gordonp Wed Apr 18 12:08:15 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv12688/src/main/ca/ucalgary/seahawk/gui Modified Files: MobyServicesGUI.java Log Message: Expose MobyClient for use by other components moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyServicesGUI.java,1.8,1.9 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyServicesGUI.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/MobyServicesGUI.java 2007/04/03 02:34:08 1.8 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyServicesGUI.java 2007/04/18 16:08:15 1.9 @@ -73,6 +73,10 @@ return mobyClient.getMobyCentralImpl(); } + public MobyClient getMobyClient(){ + return mobyClient; + } + public void setClipboard(MobyContentClipboard clip){ clipboard = clip; } From gordonp at dev.open-bio.org Wed Apr 18 12:33:45 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 18 Apr 2007 12:33:45 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704181633.l3IGXjHV012804@dev.open-bio.org> gordonp Wed Apr 18 12:33:45 EDT 2007 Update of /home/repository/moby/moby-live/Java/docs In directory dev.open-bio.org:/tmp/cvs-serv12769/docs Modified Files: ChangeLog Log Message: Noted addition of binary data handling in Seahawk & ACDServlet moby-live/Java/docs ChangeLog,1.76,1.77 =================================================================== RCS file: /home/repository/moby/moby-live/Java/docs/ChangeLog,v retrieving revision 1.76 retrieving revision 1.77 diff -u -r1.76 -r1.77 --- /home/repository/moby/moby-live/Java/docs/ChangeLog 2007/04/03 02:42:23 1.76 +++ /home/repository/moby/moby-live/Java/docs/ChangeLog 2007/04/18 16:33:45 1.77 @@ -1,3 +1,7 @@ +2007-04-18 Paul Gordon + + * Added support for binary data file loading, and Web image display in Seahawk & ACDServlet + 2007-04-02 Paul Gordon * Added asynchronous service call support to MobyRequest, Seahawk, based on client code originally provided by Eddie Kawas. From gss at dev.open-bio.org Wed Apr 25 12:18:01 2007 From: gss at dev.open-bio.org (Gary Schiltz) Date: Wed, 25 Apr 2007 12:18:01 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704251618.l3PGI1mT027733@dev.open-bio.org> gss Wed Apr 25 12:18:01 EDT 2007 Update of /home/repository/moby/server-shared In directory dev.open-bio.org:/tmp/cvs-serv27699/server-shared Log Message: Directory /home/repository/moby/server-shared added to the repository server-shared - New directory rcsdiff: /home/repository/moby/server-shared/RCS/-,v: No such file or directory rcsdiff: /home/repository/moby/server-shared/RCS/New,v: No such file or directory rcsdiff: /home/repository/moby/server-shared/RCS/directory,v: No such file or directory From kawas at dev.open-bio.org Wed Apr 25 13:30:08 2007 From: kawas at dev.open-bio.org (Eddie Kawas) Date: Wed, 25 Apr 2007 13:30:08 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704251730.l3PHU8CN027861@dev.open-bio.org> kawas Wed Apr 25 13:30:08 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/support/registry-servlets In directory dev.open-bio.org:/tmp/cvs-serv27826/Java/src/support/registry-servlets Modified Files: moby.jsp Log Message: service tester html should only be shown if the server hosting the registry servlets enables testing ... moby-live/Java/src/support/registry-servlets moby.jsp,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/support/registry-servlets/moby.jsp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/support/registry-servlets/moby.jsp 2006/11/16 22:00:05 1.1 +++ /home/repository/moby/moby-live/Java/src/support/registry-servlets/moby.jsp 2007/04/25 17:30:08 1.2 @@ -1,79 +1,153 @@ -<%@ page info="Moby Central Servlets" %> +<%@ page info="Moby Central Servlets"%> - + Moby Servlets

BioMOBY Registry Servlets

-


-Update SignatureURLs For your BioMoby Services - Form that aids in the updating of SignatureURLs. This form
-returns valid RDF upon successfully updating your signatureURL.s

-

Client LSID Resolver - Resolve LSIDs to metadata

-
-

To use this servlet, pass the parameter lsid, that is a valid LSID.
- As an example invocation, click here.

-
-

RDFGenerator - Retrieve the RDF representation for your BioMoby Service.

-
-

This servlet takes in the following parameters:

-
    -
  • name - the name of your service
  • -
  • auth - the service providers authority URI
  • -
  • url - an optional mobycentral registry endpoint to use when generating your RDF
  • -
  • uri - an optional mobycentral registry namespace to use when generating your RDF
  • -
-As an example invocation, click here.
-

RDF Agent Test - Invoke the RDF agent on the remote location that houses your RDF.

-
-

This servlets takes as parameter, url, the url to test the agent with.

-

As an example, click here.

-

For a form based page, click here.

-
-

CallableServiceServlet -Use this to determine whether or not a particular service(s) is reachable.

-
-

This servlet takes in the following parameters:

-
    -
  • service - the name of your service <optional>
  • -
  • authority - the service providers authority URI <optional>
  • -
  • getStats - Whether or not to show some statistics <optional> - set parameter to true to see stats
  • -
-

As an example, click here to see a report for all services.
- In addition, to see a report for services by the authority bioinfo.icapture.ubc.ca, click here.
-
-To see a list of unreachable services sorted by service provider, click here.
-To see some stats regarding the percent of alive services, click here.
-Finally, to see whether the service, getGoTerm, by the authority bioinfo.icapture.ubc.ca is alive, click here.
+


+Update SignatureURLs For your +BioMoby Services - Form that aids in the updating of SignatureURLs. This +form
+returns valid RDF upon successfully updating your signatureURL.s

+

Client LSID Resolver - Resolve +LSIDs to metadata

+
+

To use this servlet, pass the parameter lsid, +that is a valid LSID.
+As an example invocation, click here.

+
+

RDFGenerator - Retrieve the RDF +representation for your BioMoby Service.

+
+

This servlet takes in the following parameters:

+
    +
  • name - the name of your service
  • +
  • auth - the service providers + authority URI
  • +
  • url - an optional mobycentral + registry endpoint to use when generating your RDF
  • +
  • uri - an optional mobycentral + registry namespace to use when generating your RDF
  • +
+As an example invocation, click here.
+

RDF Agent Test - Invoke the RDF +agent on the remote location that houses your RDF.

+
+

This servlets takes as parameter, url, +the url to test the agent with.

+

As an example, click here.

+

For a form based page, click +here.

+
+<% + boolean validate = false; + String valString = System.getProperty("DO_SERVICE_VALIDATION"); + if (valString != null && valString.trim().length() != 0) { + validate = Boolean.parseBoolean(valString); + } + if (validate) { +%> +

CallableServiceServlet - Use this +to determine whether or not a particular service(s) is reachable.

+
+

This servlet takes in the following parameters:

+
    +
  • service - the name of your service + <optional>
  • +
  • authority - the service providers + authority URI <optional>
  • +
  • getStats - Whether or not to show + some statistics <optional> - set parameter to true to see + stats
  • +
+

As an example, click here to see a report for all services.
+In addition, to see a report for services by the authority +bioinfo.icapture.ubc.ca, click here.
+
To see a list of unreachable services sorted by service provider, click here.
+To see some stats regarding the percent of alive services, click here.
+Finally, to see whether the service, getGoTerm, by the authority +bioinfo.icapture.ubc.ca is alive, click here.

-

LSID Resolver Client - Using AJAX, retrieve metadata that describes Moby Ontologies..

-
-

As an example, click here.

-
-

LSID Resolver Client 2 - Resolve LSIDs to data and or metadata..

-
-

As an example, click here.

-
-

The Resources 'Scripts' - Servlets that return the RDF representations of the BioMOBY ontologies.

-
-

For example,

-
    -
  1. Object Ontology
  2. -
  3. Namespace Ontology
  4. -
  5. Service Type Ontology
  6. -
  7. Service Instance Ontology
  8. -
-
-

The Types 'Scripts' - Servlets that perform data dumps for the ontologies in a structured manner.

-
-

For example,

-
    -
  1. Object Ontology
  2. -
  3. Namespace Ontology
  4. -
  5. Service Type Ontology
  6. -
+<% +} +%> +

LSID +Resolver Client - Using AJAX, retrieve metadata that describes Moby +Ontologies..

+
+

As an example, click here.

+
+

LSID +Resolver Client 2 - Resolve LSIDs to data and or metadata..

+
+

As an example, click here.

+
+

The +Resources 'Scripts' - Servlets that return the RDF representations of +the BioMOBY ontologies.

+
+

For example,

+
    +
  1. Object + Ontology
  2. +
  3. Namespace + Ontology
  4. +
  5. Service + Type Ontology
  6. +
  7. Service + Instance Ontology
  8. +
+
+

The +Types 'Scripts' - Servlets that perform data dumps for the ontologies +in a structured manner.

+
+

For example,

+
    +
  1. Object + Ontology
  2. +
  3. Namespace + Ontology
  4. +
  5. Service + Type Ontology
  6. +
From kawas at dev.open-bio.org Wed Apr 25 13:31:38 2007 From: kawas at dev.open-bio.org (Eddie Kawas) Date: Wed, 25 Apr 2007 13:31:38 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704251731.l3PHVcxM027946@dev.open-bio.org> kawas Wed Apr 25 13:31:38 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/support/registry-servlets/config In directory dev.open-bio.org:/tmp/cvs-serv27907/Java/src/support/registry-servlets/config Modified Files: context.xml web.xml Log Message: added a boolean variable to determine whether service testing is enabled or not moby-live/Java/src/support/registry-servlets/config context.xml,1.1,1.2 web.xml,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/support/registry-servlets/config/context.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/support/registry-servlets/config/context.xml 2006/11/16 22:00:32 1.1 +++ /home/repository/moby/moby-live/Java/src/support/registry-servlets/config/context.xml 2007/04/25 17:31:38 1.2 @@ -32,6 +32,10 @@ --> + + -org.biomoby.client.ui.graphical.servlet.utilities.RegistryContextListener + + org.biomoby.client.ui.graphical.servlet.utilities.RegistryContextListener + default *.js From kawas at dev.open-bio.org Wed Apr 25 16:32:28 2007 From: kawas at dev.open-bio.org (Eddie Kawas) Date: Wed, 25 Apr 2007 16:32:28 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704252032.l3PKWSdI028242@dev.open-bio.org> kawas Wed Apr 25 16:32:28 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/utilities In directory dev.open-bio.org:/tmp/cvs-serv28203/Java/src/main/org/biomoby/client/ui/graphical/servlet/utilities Modified Files: ContextLoader.java RegistryContextListener.java Log Message: updated the context loader to read in a boolean regarding whether or not to test services. the listener now uses that variable to determine whether or not we are to test the services in the registry. moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/utilities ContextLoader.java,1.2,1.3 RegistryContextListener.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/utilities/ContextLoader.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/ui/graphical/servlet/utilities/ContextLoader.java 2006/10/16 17:23:16 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/utilities/ContextLoader.java 2007/04/25 20:32:28 1.3 @@ -38,6 +38,8 @@ private String FULL_SERVER_URL = ""; private String CONTEXT_PATH = ""; + + private boolean TESTING_SERVICES = false; /** * Constructor loads variables from InitialContext() @@ -115,6 +117,24 @@ log.error("Failure obtaining and setting LSID_PORT:" + System.getProperty("line.separator") + ex.getLocalizedMessage()); } + + // check if the server wants to validate services ... + try { + Boolean validate = false; + validate = (Boolean) c.lookup("java:comp/env/DO_SERVICE_VALIDATION"); + if (validate != null) { + // set DO_SERVICE_VALIDATION + log.info(validate.booleanValue() ? "Service testing is turned on ..." : "Service testing is turned off ..."); + TESTING_SERVICES = validate.booleanValue(); + System.setProperty("DO_SERVICE_VALIDATION", validate.booleanValue() + ""); + } else { + log.info("Service testing is turned off ..."); + } + + } catch (Exception ex) { + log.warn("Failure obtaining and setting DO_SERVICE_VALIDATION:" + + System.getProperty("line.separator") + ex.getLocalizedMessage()); + } } catch (Exception e) { log @@ -343,4 +363,8 @@ return CONTEXT_PATH; } + public boolean isTESTING_SERVICES() { + return TESTING_SERVICES; + } + } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/utilities/RegistryContextListener.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/ui/graphical/servlet/utilities/RegistryContextListener.java 2006/10/25 19:32:54 1.1 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/utilities/RegistryContextListener.java 2007/04/25 20:32:28 1.2 @@ -45,17 +45,19 @@ // add objects to keep to the context - make sure to remove them on destroy! ServletContext servletContext = servletContextEvent.getServletContext(); - try { - Timer timer = new Timer(); - ServiceTesterRunner runner = new ServiceTesterRunner(); - Calendar calendar = Calendar.getInstance(); - Date time = calendar.getTime(); - log.info("Scheduling an on going task: ServiceTester"); - timer.scheduleAtFixedRate(runner, time, 1000 * 60 * 60); - servletContext.setAttribute("tester", runner); - servletContext.setAttribute("timer", timer); - } catch (Exception e) { - + if (cLoader.isTESTING_SERVICES()) { + try { + Timer timer = new Timer(); + ServiceTesterRunner runner = new ServiceTesterRunner(); + Calendar calendar = Calendar.getInstance(); + Date time = calendar.getTime(); + log.info("Scheduling an on going task: ServiceTester"); + timer.scheduleAtFixedRate(runner, time, 1000 * 60 * 60); + servletContext.setAttribute("tester", runner); + servletContext.setAttribute("timer", timer); + } catch (Exception e) { + + } } } @@ -63,9 +65,10 @@ ServletContext servletContext = servletContextEvent.getServletContext(); // here we 'cleanup' all items we placed for 'global' use Timer timer = (Timer)servletContext.getAttribute ("timer"); - if (timer != null) + if (timer != null) { timer.cancel(); - log.info("cancelling on going task: ServiceTester"); + log.info("cancelling on going task: ServiceTester"); + } servletContext.removeAttribute ("timer"); servletContext.removeAttribute ("tester"); } From gordonp at dev.open-bio.org Thu Apr 26 11:05:28 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 26 Apr 2007 11:05:28 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704261505.l3QF5S76032674@dev.open-bio.org> gordonp Thu Apr 26 11:05:27 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data In directory dev.open-bio.org:/tmp/cvs-serv32639/src/main/org/biomoby/shared/data Modified Files: MobyDataSecondaryInstance.java Log Message: Made instance description carried over from template value used in c-tor moby-live/Java/src/main/org/biomoby/shared/data MobyDataSecondaryInstance.java,1.8,1.9 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataSecondaryInstance.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/MobyDataSecondaryInstance.java 2006/12/14 22:18:18 1.8 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataSecondaryInstance.java 2007/04/26 15:05:27 1.9 @@ -37,6 +37,7 @@ setDefaultValue(type.getDefaultValue()); setMinimumValue(type.getMinimumValue()); setMaximumValue(type.getMaximumValue()); + setDescription(type.getDescription()); } /** From gordonp at dev.open-bio.org Thu Apr 26 11:06:16 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 26 Apr 2007 11:06:16 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704261506.l3QF6Gwf032717@dev.open-bio.org> gordonp Thu Apr 26 11:06: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-serv32682/src/main/org/biomoby/shared/data Modified Files: MobyDataObjectSet.java Log Message: Made the containing vector use a Generics construct (MobyDataObject) for type safety moby-live/Java/src/main/org/biomoby/shared/data MobyDataObjectSet.java,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectSet.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/MobyDataObjectSet.java 2006/12/11 18:59:36 1.6 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectSet.java 2007/04/26 15:06:15 1.7 @@ -29,7 +29,7 @@ */ public class MobyDataObjectSet extends MobyPrimaryDataSet implements MobyDataInstance, Collection{ - Vector bag; + Vector bag; private int xmlMode = MobyDataInstance.CENTRAL_XML_MODE; public MobyDataObjectSet(org.w3c.dom.Element e) throws MobyException{ @@ -57,7 +57,7 @@ */ public MobyDataObjectSet(String name){ super(name); - bag = new Vector(); + bag = new Vector(); } /** @@ -95,8 +95,8 @@ boolean first = true; synchronized (bag) { if (bag.size() > 0){ - for (Enumeration en = bag.elements(); en.hasMoreElements(); ){ - MobyDataType objType = ((MobyPrimaryData) en.nextElement()).getDataType(); + for(MobyDataObject member: bag){ + MobyDataType objType = member.getDataType(); // Unknown datatype, break because we can't assume any common lineage for all elements anymore if(objType == null){ break; @@ -149,8 +149,8 @@ Vector namespaces = new Vector(); boolean first = true; synchronized (bag) { - for (Enumeration en = bag.elements(); en.hasMoreElements(); ){ - MobyNamespace[] nsInstances = ((MobyPrimaryData) en.nextElement()).getNamespaces(); + for (MobyDataObject member: bag){ + MobyNamespace[] nsInstances = member.getNamespaces(); Vector newNames = new Vector(); for(int i = 0; nsInstances != null && i < nsInstances.length; i++){ newNames.add(nsInstances[i]); @@ -180,8 +180,9 @@ *************************************************************************/ public void setNamespaces (MobyNamespace[] values) { synchronized (bag) { - for (Enumeration en = bag.elements(); en.hasMoreElements(); ) - ((MobyPrimaryData) en.nextElement()).setNamespaces (values); + for(MobyDataObject member: bag){ + member.setNamespaces(values); + } } } @@ -190,8 +191,9 @@ *************************************************************************/ public void addNamespace (MobyNamespace value) { synchronized (bag) { - for (Enumeration en = bag.elements(); en.hasMoreElements(); ) - ((MobyPrimaryData) en.nextElement()).addNamespace (value); + for (MobyDataObject member: bag){ + member.addNamespace(value); + } } } @@ -201,8 +203,9 @@ *************************************************************************/ public void removeNamespace (String namespaceName) { synchronized (bag) { - for (Enumeration en = bag.elements(); en.hasMoreElements(); ) - ((MobyPrimaryData) en.nextElement()).removeNamespace (namespaceName); + for (MobyDataObject member: bag){ + member.removeNamespace(namespaceName); + } } } @@ -211,8 +214,9 @@ *************************************************************************/ public void removeNamespace (MobyNamespace value) { synchronized (bag) { - for (Enumeration en = bag.elements(); en.hasMoreElements(); ) - ((MobyPrimaryData) en.nextElement()).removeNamespace (value); + for(MobyDataObject member: bag){ + member.removeNamespace(value); + } } } @@ -409,7 +413,7 @@ /** * @return an iterator over the non-null MobyDataObjects in this collection */ - public Iterator iterator(){ + public Iterator iterator(){ return bag.iterator(); } @@ -511,15 +515,12 @@ public String toXML(){ StringBuffer collectionXml = new StringBuffer(); - Iterator membersIterator = bag.iterator(); if(xmlMode == MobyDataInstance.SERVICE_XML_MODE){ collectionXml.append("\n"); - while(membersIterator.hasNext()){ - - MobyDataObject mdsi = (MobyDataObject) membersIterator.next(); + for(MobyDataObject mdsi: bag){ mdsi.setXmlMode(xmlMode); collectionXml.append(""+mdsi.toXML()+""); @@ -534,9 +535,7 @@ collectionXml.append("\n"); Hashtable printed = new Hashtable(); - while(membersIterator.hasNext()){ - - MobyDataObject mdsi = (MobyDataObject) membersIterator.next(); + for(MobyDataObject mdsi: bag){ // Could the DataType be null? I hope not! String objectClass = mdsi.getDataType().getName(); From gordonp at dev.open-bio.org Thu Apr 26 11:08:03 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 26 Apr 2007 11:08:03 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704261508.l3QF83x4000335@dev.open-bio.org> gordonp Thu Apr 26 11:08:03 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client In directory dev.open-bio.org:/tmp/cvs-serv32767/src/main/org/biomoby/client Modified Files: MobyRequest.java Log Message: Added new setInput() method that takes an array of data instances to populate the request (used by Seahawk for multi-param service calls) moby-live/Java/src/main/org/biomoby/client MobyRequest.java,1.24,1.25 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java 2007/04/03 02:22:56 1.24 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java 2007/04/26 15:08:03 1.25 @@ -192,6 +192,19 @@ } /** + * Takes the data in the array, with their current articleNames, as input for the service + */ + public void setInput(MobyDataInstance[] data) throws MobyException{ + MobyDataJob job = new MobyDataJob(); + for(MobyDataInstance param: data){ + System.err.println("Adding job param " + param.getName()); + job.put(param.getName(), param); + } + inputData = new MobyContentInstance(); + inputData.put(job); + } + + /** * Convenience method to run services that take one argument. If the service * requires the input to have a name, it will be automatically assigned. */ From gordonp at dev.open-bio.org Thu Apr 26 11:11:19 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 26 Apr 2007 11:11:19 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704261511.l3QFBJBa000417@dev.open-bio.org> gordonp Thu Apr 26 11:11:19 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-serv386/src/main/ca/ucalgary/seahawk/resources/images Added Files: attention.gif checkmark.gif Log Message: Small icons used by MobyDataObjectWidget to denote the state of the object instantiation moby-live/Java/src/main/ca/ucalgary/seahawk/resources/images attention.gif,NONE,1.1 checkmark.gif,NONE,1.1 From gordonp at dev.open-bio.org Thu Apr 26 11:15:45 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 26 Apr 2007 11:15:45 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704261515.l3QFFj0g000565@dev.open-bio.org> gordonp Thu Apr 26 11:15:45 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv530/src/main/ca/ucalgary/seahawk/gui Modified Files: FileAndTextTransferHandler.java Log Message: Refactored several aspects of the transfer handler for easier extension moby-live/Java/src/main/ca/ucalgary/seahawk/gui FileAndTextTransferHandler.java,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/FileAndTextTransferHandler.java,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/gui/FileAndTextTransferHandler.java 2007/03/23 20:23:52 1.4 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/FileAndTextTransferHandler.java 2007/04/26 15:15:45 1.5 @@ -1,5 +1,6 @@ package ca.ucalgary.seahawk.gui; +import ca.ucalgary.seahawk.util.HTMLUtils; import org.biomoby.shared.MobyPrefixResolver; import org.biomoby.shared.data.*; import org.biomoby.shared.parser.MobyTags; @@ -21,21 +22,18 @@ * windowing system, so dropped files, URLs and string can be loaded into * tabs. Dragging from Seahawk tabs is not yet supported. */ -class FileAndTextTransferHandler extends TransferHandler { +public class FileAndTextTransferHandler extends TransferHandler { private DataFlavor fileFlavor, stringFlavor; private MobyContentGUI gui; - private JTextArea source; - private boolean shouldRemove; - protected String newline = "\n"; - FileAndTextTransferHandler(MobyContentGUI mcg) { + public FileAndTextTransferHandler(MobyContentGUI mcg) { gui = mcg; fileFlavor = DataFlavor.javaFileListFlavor; stringFlavor = DataFlavor.stringFlavor; } 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; @@ -46,63 +44,27 @@ if (hasFileFlavor(t.getTransferDataFlavors())) { // Load any dragged file as a URL for (File file: (java.util.List) t.getTransferData(DataFlavor.javaFileListFlavor)) { - String fileString = file.toURI().toURL().toString().toLowerCase(); - // Windows Web shortcut? - URL u = null; - if(fileString.lastIndexOf(".url") == fileString.length()-4){ - LineNumberReader in = new LineNumberReader( - new InputStreamReader(file.toURI().toURL().openStream())); - for(String line = in.readLine(); line != null; line = in.readLine()){ - int urlIndex = line.indexOf("URL="); - if(line.indexOf("URL=") == 0){ - try{ - u = new URL(line.substring(4)); - } catch(MalformedURLException murle){ - System.err.println("Could not format " +line); - murle.printStackTrace(); - // Not a URL, but really it should have been. - // oh well, move on to normal file loading... - } - break; // done with this file as a URL, no need to execute other loadPaneFromURL - } - } - } + URL u = HTMLUtils.checkForURLShortcut(file); // Was it a shortcut file after all? if(u != null){ + System.err.println("Dropped item appears to be a URL shortcut..."); gui.loadPaneFromURL(u, true); } // Any other type of file is loaded as-is else{ + System.err.println("Dropped item appears to be a file..."); gui.loadPaneFromURL(file.toURI().toURL(), true); } } return true; } else if (hasTextFlavor(t.getTransferDataFlavors())) { // Make a string out of the text - StringBuffer textBuffer = new StringBuffer(); - Reader reader = DataFlavor.selectBestTextFlavor(t.getTransferDataFlavors()).getReaderForText(t); - //Reader reader = DataFlavor.plainTextFlavor.getReaderForText(t); - char[] buffer = new char[1024]; - for(int charsRead = reader.read(buffer); charsRead != -1; charsRead = reader.read(buffer)){ - textBuffer.append(buffer, 0, charsRead); - } - // Some readers put funny nulls before each char (8->16 bit char encoding goof) - String text = textBuffer.toString().replaceAll("\00", ""); + boolean NOT_JUST_PLAIN_TEXT = false; + String text = convertToString(t, NOT_JUST_PLAIN_TEXT); // Is it an address bar icon dragged from firefox? Strip the surrounding html - String linktext = null; - if(text.indexOf("") == text.length()-11){ - linktext = text.substring(15, text.indexOf("\"",15)); - } - else if(text.indexOf("") == text.length()-4){ //unix - linktext = text.substring(9, text.indexOf("\"",9)); - } - else if(text.indexOf("") != -1){ - int startHref = text.indexOf("")+1); - xmltext = xmltext.replaceAll(">", ">"); - xmltext = xmltext.replaceAll("<", "<"); - xmltext = xmltext.replaceAll("&", "&"); - } - xmltext = xmltext.trim(); // remove leading and trailing spaces - MobyContentInstance content = null; - try{ - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - dbf.setNamespaceAware (true); - DocumentBuilder db = dbf.newDocumentBuilder(); - if(xmltext.indexOf("xmlns:moby") == -1){ - // Ensure that the moby: prefix is declared in the first tag - xmltext = xmltext.replaceFirst("<([A-Za-z0-9_][^> \t\n]*)", "<$1 xmlns:moby=\""+ - MobyPrefixResolver.MOBY_XML_NAMESPACE+"\""); - } - if(xmltext.indexOf("\n" + xmltext; - } - - org.w3c.dom.Element data = db.parse(new ByteArrayInputStream(xmltext.getBytes())).getDocumentElement(); - if(data.getLocalName().equals(MobyTags.MOBY)){ - content = MobyDataUtils.fromXMLDocument(data); - } - else if(data.getLocalName().equals(MobyTags.MOBYCONTENT)){ - content = new MobyContentInstance(data); - } - else if(data.getLocalName().equals(MobyTags.MOBYDATA)){ - content = new MobyContentInstance(); - content.parseDataGroup(data); - } - else{ - // Any other data can be processed by the base object class - content = new MobyContentInstance(MobyDataObject.createInstanceFromDOM(data), "Drag 'n' Drop data"); - } - - if(content != null){ - gui.loadPaneFromObject(content, true); - return true; - } - } catch(Exception e){ - // Not good MOBY XML, oh well, lets fall back on the HTML-based display below... - e.printStackTrace(); - } + MobyContentInstance content = HTMLUtils.checkForMobyXML(text); + if(content != null){ + System.err.println("Dropped item appears to be moby xml..."); + gui.loadPaneFromObject(content, true); + return true; } // Otherwise save the data to a temp file and load it as a URL @@ -206,21 +121,44 @@ gui.loadPaneFromURL(savedFile.toURI().toURL(), true); return true; } + else{ + System.err.println("Cannot drop data into Seahawk, data was neither a file, nor text"); + } } catch (UnsupportedFlavorException ufe) { - System.out.println("importData: unsupported data flavor"); - } catch (IOException ieo) { - System.out.println("importData: I/O exception"); - } + System.out.println("importData: unsupported data flavor:"+ufe); + } catch (IOException ioe) { + ioe.printStackTrace(); + System.out.println("importData: I/O exception: "+ioe); + } catch (Exception e){ + e.printStackTrace(); + System.out.println("importData: General exception: "+e); + } return false; } - public boolean canImport(JComponent c, DataFlavor[] flavors) { + public String convertToString(Transferable t, boolean get_plain_text) throws Exception{ + StringBuffer textBuffer = new StringBuffer(); + Reader reader = get_plain_text ? DataFlavor.plainTextFlavor.getReaderForText(t) : + DataFlavor.selectBestTextFlavor(t.getTransferDataFlavors()).getReaderForText(t); + char[] buffer = new char[4096]; + for(int charsRead = reader.read(buffer); charsRead != -1; charsRead = reader.read(buffer)){ + textBuffer.append(buffer, 0, charsRead); + } + // Some readers put funny nulls before each char (8->16 bit char encoding goof) + return textBuffer.toString().replaceAll("\00", ""); + } + + /** + * Overrides same method in parent class, tells the dropper if we'll accept the data + * before the drop is actually attempted. + */ + public boolean canImport(JComponent comp, DataFlavor[] flavors) { if (hasFileFlavor(flavors)) { return true; } if (hasTextFlavor(flavors)) { return true; } return false; } - private boolean hasFileFlavor(DataFlavor[] flavors) { + protected boolean hasFileFlavor(DataFlavor[] flavors) { for (DataFlavor flavor: flavors) { if (flavor.isFlavorJavaFileListType()) { return true; @@ -229,7 +167,7 @@ return false; } - private boolean hasTextFlavor(DataFlavor[] flavors) { + protected boolean hasTextFlavor(DataFlavor[] flavors) { for (DataFlavor flavor: flavors) { if (flavor.isFlavorTextType()) { return true; From gordonp at dev.open-bio.org Thu Apr 26 11:15:45 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 26 Apr 2007 11:15:45 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704261515.l3QFFjBr000585@dev.open-bio.org> gordonp Thu Apr 26 11:15:45 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util In directory dev.open-bio.org:/tmp/cvs-serv530/src/main/ca/ucalgary/seahawk/util Modified Files: HTMLUtils.java Log Message: Refactored several aspects of the transfer handler for easier extension moby-live/Java/src/main/ca/ucalgary/seahawk/util HTMLUtils.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/HTMLUtils.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/HTMLUtils.java 2007/04/18 16:02:09 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/HTMLUtils.java 2007/04/26 15:15:45 1.2 @@ -1,9 +1,14 @@ package ca.ucalgary.seahawk.util; +import org.biomoby.shared.*; import org.biomoby.shared.data.*; +import org.biomoby.shared.parser.MobyTags; + +import javax.xml.parsers.*; import java.io.*; -import java.net.URL; +import java.net.*; + public class HTMLUtils{ @@ -55,4 +60,142 @@ return html; } + /** + * Extracts a URL string from a given piece of text iof that's all it contains. + * Especially suited for dropped URL's etc. from browsers, as it cleans up the HTML junk + * browsers wrap links in. + */ + public static String checkForHyperlinkText(String text){ + if(text.indexOf("") == text.length()-11){ + return text.substring(15, text.indexOf("\"",15)); + } + else if(text.indexOf("") == text.length()-4){ //unix + return text.substring(9, text.indexOf("\"",9)); + } + else if(text.indexOf("") != -1){ + int startHref = text.indexOf(""+text+""; + } + + StringBuffer result = new StringBuffer(""); + int lineCharCount = 0; + String[] tokens = text.split("[ \t\n]"); + for(String word: tokens){ + while(word.length()+1 > maxLineLength){ //single word is bigger than preset width, hyphenate + int cutPoint = maxLineLength - lineCharCount - 1; + result.append(word.substring(0, cutPoint)+"-
"); + lineCharCount = 0; + word = word.substring(cutPoint); + } + if(lineCharCount != 0 && lineCharCount + word.length() > maxLineLength){ + result.append("
" + word + " "); + lineCharCount = word.length()+1; + continue; + } + result.append(word+" "); + lineCharCount += word.length()+1; + } + result.append(""); + + return result.toString(); + } + + /** + * Given an HTML fragment (e.g. cut'n'pasted from a browser), see if we unescape the + * HTML we get a MOBY XML block (e.g. from the biomoby.org web site examples). + */ + public static MobyContentInstance checkForMobyXML(String text){ + if(//(text.indexOf("moby:") != -1 || text.indexOf("articleName=\"") != -1) && + text.indexOf("namespace=\"") == -1 || + text.indexOf("id=\"") == -1){ + return null; + } + + MobyContentInstance content = null; + String xmltext = text; + // See if the xml needs unescaping (e.g. if preformatted HTML dropped from Firefox or Thunderbird) + int preStart = xmltext.indexOf("")+1); + xmltext = xmltext.replaceAll(">", ">"); + xmltext = xmltext.replaceAll("<", "<"); + xmltext = xmltext.replaceAll("&", "&"); + } + xmltext = xmltext.trim(); // remove leading and trailing spaces + try{ + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + dbf.setNamespaceAware (true); + DocumentBuilder db = dbf.newDocumentBuilder(); + if(xmltext.indexOf("xmlns:moby") == -1){ + // Ensure that the moby: prefix is declared in the first tag + xmltext = xmltext.replaceFirst("<([A-Za-z0-9_][^> \t\n]*)", "<$1 xmlns:moby=\""+ + MobyPrefixResolver.MOBY_XML_NAMESPACE+"\""); + } + if(xmltext.indexOf("\n" + xmltext; + } + + org.w3c.dom.Element data = db.parse(new ByteArrayInputStream(xmltext.getBytes())).getDocumentElement(); + if(data.getLocalName().equals(MobyTags.MOBY)){ + content = MobyDataUtils.fromXMLDocument(data); + } + else if(data.getLocalName().equals(MobyTags.MOBYCONTENT)){ + content = new MobyContentInstance(data); + } + else if(data.getLocalName().equals(MobyTags.MOBYDATA)){ + content = new MobyContentInstance(); + content.parseDataGroup(data); + } + else{ + // Any other data can be processed by the base object class + content = new MobyContentInstance(MobyDataObject.createInstanceFromDOM(data), "Drag 'n' Drop data"); + } + } catch(Exception e){ + e.printStackTrace(); + } + return content; + } } From gordonp at dev.open-bio.org Thu Apr 26 11:19:58 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 26 Apr 2007 11:19:58 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704261519.l3QFJwIh000668@dev.open-bio.org> gordonp Thu Apr 26 11:19: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-serv637/src/main/ca/ucalgary/seahawk/gui Added Files: MobyDataObjectWidget.java MobyObjectReceiver.java MobyObjectTransferHandler.java Log Message: GUI components added in support of direct manipulation of multiple parameters for Moby service input moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyDataObjectWidget.java,NONE,1.1 MobyObjectReceiver.java,NONE,1.1 MobyObjectTransferHandler.java,NONE,1.1 From gordonp at dev.open-bio.org Thu Apr 26 11:22:27 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 26 Apr 2007 11:22:27 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704261522.l3QFMRB1000753@dev.open-bio.org> gordonp Thu Apr 26 11:22: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-serv718/src/main/ca/ucalgary/seahawk/services Modified Files: MobyClient.java Log Message: Small method sig and doc updates moby-live/Java/src/main/ca/ucalgary/seahawk/services MobyClient.java,1.11,1.12 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.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/services/MobyClient.java 2007/04/18 16:01:00 1.11 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java 2007/04/26 15:22:27 1.12 @@ -740,11 +740,11 @@ return new MobyDataObject[0]; } - // Vector of moby objects we construct based on the xpath mappings found + // Vector of moby objects we construct based on the regex mappings found Vector objectVector = new Vector(); Iterator regex_keys = regexMap.keySet().iterator(); - while(regex_keys.hasNext()){ //map still has untraversed xpath entry to test + while(regex_keys.hasNext()){ //map still has untraversed regex entry to test Pattern pattern = (Pattern) regex_keys.next(); Matcher matcher = pattern.matcher(textData); @@ -771,29 +771,44 @@ * Using the URL regular expression mappings that have been set up, * maps a string to moby objects. URL regexs are special because they are * flexible in the order in which query parameters are given. They - * may also have requirements based on the hypertext linked. + * may also have requirements based on the hypertext linked. This method + * does not look at the contents of the URL, but rather the URL itself. */ public MobyDataObject[] getMobyObjects(URL url){ - return getMobyObjects(url, null); + return getMobyObjects(url, null, null); } public MobyDataObject[] getMobyObjects(URL url, String linkText){ + return getMobyObjects(url, linkText, null); + } + + public MobyDataObject[] getMobyObjects(URL url, MobyDataType targetDataType){ + return getMobyObjects(url, null, targetDataType); + } + + public MobyDataObject[] getMobyObjects(URL url, String linkText, MobyDataType targetDataType){ if(urlRegexMap.isEmpty()){ System.out.println("The MOBY Client has not been provided any url regex->moby data mappings!"); return new MobyDataObject[0]; } - // Vector of moby objects we construct based on the xpath mappings found + // Vector of moby objects we construct based on the regex mappings found Vector objectVector = new Vector(); String urlString = url.toString(); Iterator url_regex_keys = urlRegexMap.keySet().iterator(); - while(url_regex_keys.hasNext()){ // map still has untraversed xpath entry to test + while(url_regex_keys.hasNext()){ // map still has untraversed regex entry to test Pattern pattern = (Pattern) url_regex_keys.next(); + MobyComplexBuilder rule = (MobyComplexBuilder) urlRegexMap.get(pattern); + + // If we asked for a particular data type, make sure the rule can produce it before we + // start to go matching it. + if(targetDataType != null && !rule.getDataType().inheritsFrom(targetDataType)){ + continue; + } Matcher matcher = pattern.matcher(urlString); while(matcher.find()){ - MobyComplexBuilder rule = (MobyComplexBuilder) urlRegexMap.get(pattern); try{ MobyDataObject mobyObj = rule.apply(matcher); From gordonp at dev.open-bio.org Thu Apr 26 11:23:59 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 26 Apr 2007 11:23:59 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704261523.l3QFNx94000819@dev.open-bio.org> gordonp Thu Apr 26 11:23:59 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv784/src/main/ca/ucalgary/seahawk/gui Modified Files: MobyContentGUI.java Log Message: Minor fix to allow tab close when 2 tabs and no clipboard showing moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyContentGUI.java,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.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/MobyContentGUI.java 2007/04/18 15:57:00 1.7 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java 2007/04/26 15:23:59 1.8 @@ -846,7 +846,8 @@ } if(tabbedPane.getComponentAt(index) == clipboard && tabbedPane.getTabCount() > 1 || - tabbedPane.getTabCount() > 2){ + tabbedPane.getTabCount() > 2 || + tabbedPane.indexOfComponent(clipboard) == -1 && tabbedPane.getTabCount() >= 2){ item = new JMenuItem(MobyContentGUI.CLOSE_OTHERS_OPTION); item.setActionCommand(MobyContentGUI.CLOSE_OTHERS_OPTION); item.addActionListener(gui); From gordonp at dev.open-bio.org Thu Apr 26 11:25:13 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 26 Apr 2007 11:25:13 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704261525.l3QFPDvh000883@dev.open-bio.org> gordonp Thu Apr 26 11:25:13 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv848/src/main/ca/ucalgary/seahawk/gui Modified Files: MobySecondaryInputGUI.java Log Message: Added proper multi-primary parameter support, and tooltip formatting for secondary parameters moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobySecondaryInputGUI.java,1.5,1.6 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobySecondaryInputGUI.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/MobySecondaryInputGUI.java 2007/04/12 01:03:14 1.5 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobySecondaryInputGUI.java 2007/04/26 15:25:13 1.6 @@ -1,21 +1,22 @@ package ca.ucalgary.seahawk.gui; -import org.biomoby.shared.data.MobyDataSecondaryInstance; -import org.biomoby.shared.MobySecondaryData; +import ca.ucalgary.seahawk.services.MobyClient; +import ca.ucalgary.seahawk.util.HTMLUtils; +import org.biomoby.shared.data.*; +import org.biomoby.shared.*; import java.awt.*; import javax.swing.*; import javax.swing.text.JTextComponent; import java.awt.event.*; -import java.util.Map; -import java.util.HashMap; -import java.util.Iterator; +import java.util.*; /** * A class that generates a GUI to fill in (instantiate or change) the values of Secondary Input to MOBY services. */ public class MobySecondaryInputGUI extends JDialog implements ActionListener, Runnable { + public final static int MAX_TOOLTIP_WIDTH = 40; public final static int INT_CHOICE_MAX = 100; public final static int DEFAULT_TEXT_SIZE = 12; public final static String UNBOUNDED_INT_RANGE_DESC = "[integer]"; @@ -23,6 +24,7 @@ public final static String TITLE = "Secondary Inputs for MOBY Service"; public final static String OK_BUTTON_NAME = "MSIGexecuteButton"; + private MobyPrimaryData[] inputsPrimary = null; private MobyDataSecondaryInstance[] inputs = null; private JButton cancelButton; private String cancelMessage = "Cancel"; @@ -34,35 +36,38 @@ private ActionListener listener; private int handlerCode = 0; // callback event ID provided by caller to c-tor private boolean showingNew = false; + private MobyClient mobyClient; private static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(MobySecondaryInputGUI.class); - public MobySecondaryInputGUI(ActionListener al, Frame owner, boolean modal){ - this(al, owner, modal, 0); + public MobySecondaryInputGUI(ActionListener al, Frame owner, boolean modal, MobyClient client){ + this(al, owner, modal, 0, client); } /** * @param al the object to receive the "all done" callback * @param actionCommandID the id to give back as the event ID during callback */ - public MobySecondaryInputGUI(ActionListener al, Frame owner, boolean modal, int actionCommandID){ + public MobySecondaryInputGUI(ActionListener al, Frame owner, boolean modal, int actionCommandID, MobyClient client){ super(owner, modal); setup(); listener = al; handlerCode = actionCommandID; + mobyClient = client; setVisible(false); showingNew = false; setName(TITLE); } - public MobySecondaryInputGUI(ActionListener al){ - this(al, 0); + public MobySecondaryInputGUI(ActionListener al, MobyClient client){ + this(al, 0, client); } - public MobySecondaryInputGUI(ActionListener al, int actionCommandID){ + public MobySecondaryInputGUI(ActionListener al, int actionCommandID, MobyClient client){ super(); setup(); listener = al; + mobyClient = client; handlerCode = actionCommandID; setVisible(false); } @@ -121,19 +126,24 @@ } public void fillIn(MobyDataSecondaryInstance[] secondaryInputs, boolean showGUI){ - if(secondaryInputs == null){ + fillIn(null, secondaryInputs, showGUI); + } + + public void fillIn(MobyPrimaryData[] primaryInputs, MobyDataSecondaryInstance[] secondaryInputs, boolean showGUI){ + // If more than 1 primary input parameter, need to disable + // submission until these fields are filled in too. + if(!setupPrimaryInput(primaryInputs) && secondaryInputs == null){ run(); //should do callback return; } inputs = secondaryInputs; - java.util.Arrays.sort(inputs); // Create a thread here to prevent possible AWT-EventQueue deadlock // when widgets are added and the thread of caller of the method was // the AWT-EventQueue. - WidgetCreatorThread widgetMaker = new WidgetCreatorThread(showGUI); + WidgetCreatorThread widgetMaker = new WidgetCreatorThread(showGUI, true); if(!showGUI){ // Call synchronous to ensure data is present before returning widgetMaker.run(); @@ -145,11 +155,31 @@ } + /** + * Is there more than one primary parameter? Do we need to populate it? + * @return true if we can submit the job as is, otherwise false (data still needs to be filled in) + */ + protected boolean setupPrimaryInput(MobyPrimaryData[] primaryInputs){ + confirmButton.setEnabled(true); //unless otherwise noted, we can submit + if(primaryInputs != null){ + inputsPrimary = primaryInputs; + for(MobyPrimaryData primary: inputsPrimary){ + if(!(primary instanceof MobyDataInstance)){ + // a primary parameter has not yet been instantiated + confirmButton.setEnabled(false); + } + } + } + return confirmButton.isEnabled(); + } + class WidgetCreatorThread extends Thread{ private boolean showGUI; + private boolean showSinglePrimaryInput; - public WidgetCreatorThread(boolean b){ - showGUI = b; + public WidgetCreatorThread(boolean gui, boolean single){ + showGUI = gui; + showSinglePrimaryInput = single; } public void run(){ @@ -159,10 +189,24 @@ setVisible(true); } - // Add a widget for each input value - for(int i = 0; i < inputs.length; i++){ - optionsPanel.add(makeWidget(inputs[i])); + if(!confirmButton.isEnabled() || showSinglePrimaryInput){ + //java.util.Arrays.sort(inputsPrimary); + for(MobyPrimaryData input: inputsPrimary){ + optionsPanel.add(makeWidget(input)); + } + + // Visually separate the primary and secondary inputs + optionsPanel.add(new JSeparator()); + } + + // Sort the parameters alphabetically + Arrays.sort(inputs); // MobyDataSecondaryInstance implements Comparable + + // Add a widget for each secondary param + for(MobyDataSecondaryInstance input: inputs){ + optionsPanel.add(makeWidget(input)); } + // Make the window the preferred size of its widget contents if(showGUI){ pack(); @@ -182,6 +226,22 @@ return ret; } + public Component makeWidget(MobyPrimaryData data){ + boolean DATA_EDITABLE = true; + MobyDataObjectWidget primaryDataWidget = null; + // Choose c-tor based on if param is instantiated or not + if(data instanceof MobyDataInstance){ + primaryDataWidget = new MobyDataObjectWidget(data.getName(), mobyClient, (MobyDataInstance) data, DATA_EDITABLE); + } + else{ + primaryDataWidget = new MobyDataObjectWidget(data.getName(), mobyClient, data); + } + // We want to get informed of updates to the data, as this + // may change whether the dialog should be submittable or not + primaryDataWidget.addActionListener(this); + return primaryDataWidget; + } + public Component makeWidget(MobyDataSecondaryInstance msdi){ String dataType = msdi.getDataType(); @@ -410,7 +470,7 @@ if(desc == null || desc.length() == 0){ desc = "Sorry, no description of this input is available from the service provider"; } - label.setToolTipText(desc); + label.setToolTipText(HTMLUtils.htmlifyToolTipText(desc, MAX_TOOLTIP_WIDTH)); return label; } @@ -441,6 +501,25 @@ else if(source == cancelButton){ dispose(); } + // Primary input data update + else if(source instanceof MobyDataObjectWidget){ + MobyPrimaryData newData = ((MobyDataObjectWidget) source).getData(); + String newDataName = ((MobyDataObjectWidget) source).getName(); + boolean enableSubmit = true; + + // Copy the new data value to the original array + for(int i = 0; i < inputsPrimary.length; i++){ + if(inputsPrimary[i].getName().equals(newDataName)){ + newData.setName(newDataName); + inputsPrimary[i] = newData; + } + // Is there still some uninstantiated data? + if(enableSubmit && !(inputsPrimary[i] instanceof MobyDataInstance)){ + enableSubmit = false; + } + } + confirmButton.setEnabled(enableSubmit); + } else{ logger.warn("Unrecognized event source (" + source + ") in " + getClass()); } From gordonp at dev.open-bio.org Thu Apr 26 11:26:25 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 26 Apr 2007 11:26:25 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704261526.l3QFQPXh000947@dev.open-bio.org> gordonp Thu Apr 26 11:26:24 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv912/src/main/ca/ucalgary/seahawk/gui Modified Files: MobyServicesGUI.java Log Message: Added support for multiple primary input parameters to a service, and fixed up tooltip formatting moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyServicesGUI.java,1.9,1.10 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyServicesGUI.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/MobyServicesGUI.java 2007/04/18 16:08:15 1.9 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyServicesGUI.java 2007/04/26 15:26:24 1.10 @@ -1,6 +1,7 @@ package ca.ucalgary.seahawk.gui; import ca.ucalgary.seahawk.services.MobyClient; +import ca.ucalgary.seahawk.util.HTMLUtils; import javax.swing.*; import org.w3c.dom.*; import org.biomoby.shared.*; @@ -13,6 +14,7 @@ import java.awt.*; import java.io.*; import java.text.Collator; +import java.net.URL; import java.util.*; import javax.swing.event.PopupMenuListener; import javax.swing.event.PopupMenuEvent; @@ -47,6 +49,7 @@ MobyDataServiceAssocInstance[] ms; MobyDataSecondaryInstance[] secondaryInputInstances = null; + MobyPrimaryData[] primaryInput = null; int maxDataDesc = 22; private HashMap service2submenu; //tracks nested submenus to root submenus of choices popup private HashMap submenu2msIndex; @@ -174,23 +177,50 @@ } public void setupServiceSecondaryData(MobyRequestEventHandler handler){ + MobyDataInstance[] castInputs = new MobyDataInstance[primaryInput.length]; + System.err.println("Submitting job with " + primaryInput.length + " parameters"); + for(int i = 0; i < primaryInput.length; i++){ + if(!(primaryInput[i] instanceof MobyDataInstance)){ + logger.warn("Warning: setupServiceSecondaryData was called before the primary input" + + " for the service was instantiated, ignoring the call. Object found was" + + " of class "+primaryInput[i].getClass().getName()); + return; + } + castInputs[i] = (MobyDataInstance) primaryInput[i]; + } + + try{ + mobyRequest.setInput(castInputs); + } catch(MobyException me){ + me.printStackTrace(); + logger.warn("Error while trying to set service input: " + me); + } mobyRequest.setSecondaryInput(secondaryInputInstances); executeService(handler); } protected void setupService(MobyService mobyService, MobyDataInstance mdi, int handlerHashCode, boolean useDefaultSecondaries){ - mobyRequest.setDebugMode(System.getProperty("moby.debug") != null); - mobyRequest.setService(mobyService); - // We only implement simple input for now (i.e. only one input argument) - try{ - mobyRequest.setInput(mdi, ""); - } - catch(MobyException me){ - logger.error("Failure in MOBY input, was not acceptable:" + me); + if(!(mdi instanceof MobyPrimaryData)){ + logger.error("Failure in MOBY input, was not primary data as expected, but rather "+mdi.getClass().getName()); return; } + + mobyRequest.setDebugMode(System.getProperty("moby.debug") != null); + mobyRequest.setService(mobyService); + MobyPrimaryData[] primaryInputTemplate = mobyService.getPrimaryInputs(); + primaryInput = new MobyPrimaryData[primaryInputTemplate.length]; + System.arraycopy(primaryInputTemplate, 0, primaryInput, 0, primaryInput.length); if(!hasSecondaryInput(mobyService)){ + try{ + // Implement simple input (i.e. only one input argument) + mobyRequest.setInput(mdi, ""); + } + catch(MobyException me){ + logger.error("Failure in MOBY input, was not acceptable:" + me); + return; + } + // No need for further info, just launch the request removePopupOptions(); executeService(getHandlerByHashCode(handlerHashCode)); @@ -198,14 +228,55 @@ else{ // We need more info from the user to launch this service //logger.warn("Need to get secondary parameters: " + secondaryInputTemplate.getClass()); - MobyData[] secondaryInputTemplate = mobyService.getSecondaryInputs(); - getSecondaryInput((MobySecondaryData[]) secondaryInputTemplate, handlerHashCode, useDefaultSecondaries); + MobyService metaDataMobyService = MobyService.getService(mobyService.getName(), mobyService.getAuthority()); + + // We need to figure out where the provided data instance goes into the parameter list for the service + Vector paramMatch = new Vector(); + int paramMatchDefault = 0; + MobyDataType providedDataType = ((MobyPrimaryData) mdi).getDataType(); + for(MobyPrimaryData input: primaryInput){ + if(providedDataType.inheritsFrom(input.getDataType())){ + paramMatch.add(input.getName()); + } + } + if(paramMatch.size() == 0){ + logger.error("Failure in MOBY input, could not match the input (" +providedDataType.getName() + + ") to any service param for service "+mobyService.getName()); + return; + } + + String targetParamName = paramMatch.elementAt(0); + // Need to choose among multiple parameters + if(paramMatch.size() > 1){ + targetParamName = (String) JOptionPane.showInputDialog(null, + "Choose the service parameter the chosen " + + "object represents", + "Service Parameter Choice", + JOptionPane.QUESTION_MESSAGE, + null, + paramMatch.toArray(), + paramMatch.elementAt(paramMatchDefault)); + } + // Finds the matching param and set it + for(int i = 0; i < primaryInput.length; i++){ + if(targetParamName.equals(primaryInput[i].getName())){ + mdi.setName(targetParamName); + primaryInput[i] = (MobyPrimaryData) mdi; + } + } + + // We need to create the secondary parameters too, and launch the dialog to fill in the + // uninstantiated data. + getSecondaryInput(metaDataMobyService, handlerHashCode, useDefaultSecondaries); } } + // True if there are secondaries, or more than one primary input + // (which also needs the dialog for user data instantiation) private boolean hasSecondaryInput(MobyService mobyService){ MobyData[] secondaryInputTemplate = mobyService.getSecondaryInputs(); - return secondaryInputTemplate != null && secondaryInputTemplate.length != 0; + return secondaryInputTemplate != null && secondaryInputTemplate.length != 0 || + mobyService.getPrimaryInputs().length > 1; } /** @@ -233,11 +304,14 @@ * Launches a dialog that the user can configure secondary parameters in, * or tries to fill in and use all defaults if valid and useDefaults is specified. */ - protected void getSecondaryInput(MobySecondaryData[] secondaryInputTemplate, int handlerHashCode, boolean useDefaults){ + protected void getSecondaryInput(MobyService mobyService, int handlerHashCode, boolean useDefaults){ + MobySecondaryData[] secondaryInputTemplate = mobyService.getSecondaryInputs(); if(secondaryGUI == null){ - secondaryGUI = new MobySecondaryInputGUI(this, handlerHashCode); + secondaryGUI = new MobySecondaryInputGUI(this, handlerHashCode, mobyClient); } + // Create the param array that will be modified in the secondary dialog and used + // after the callback to run the service. secondaryInputInstances = new MobyDataSecondaryInstance[secondaryInputTemplate.length]; for(int i = 0; i < secondaryInputInstances.length; i++){ @@ -249,7 +323,8 @@ return; } // The GUI will perform a callback when the user is done the input - secondaryGUI.fillIn(secondaryInputInstances); + boolean SHOW_DIALOG = true; + secondaryGUI.fillIn(primaryInput, secondaryInputInstances, SHOW_DIALOG); } /** @@ -943,19 +1018,12 @@ String serviceDesc = service.getDescription(); String serviceAuthority = service.getAuthority(); if(serviceDesc != null && serviceDesc.length() > 0){ - if(serviceDesc.length() > MAX_SERVICE_DESC_LEN){ - serviceDesc = htmlifyToolTipText(serviceDesc); + if(serviceAuthority != null && serviceAuthority.length() > 0){ + serviceDesc += " [" + serviceAuthority + "]"; } + serviceDesc = HTMLUtils.htmlifyToolTipText(serviceDesc, MAX_SERVICE_DESC_LEN); sdesc = serviceDesc; } - if(serviceAuthority != null && serviceAuthority.length() > 0){ - if(sdesc == null){ - sdesc = serviceAuthority; - } - else{ - sdesc += " [" + serviceAuthority + "]"; - } - } if(sdesc != null){ mobyItem.setToolTipText(sdesc); } @@ -987,10 +1055,7 @@ } String menuToolTip = commonAncestorDesc + type.getDescription(); - if(menuToolTip.length() > MAX_SERVICE_DESC_LEN){ - // Cut down really long ancestry descs to the last part (most precise) - menuToolTip = htmlifyToolTipText(menuToolTip); - } + menuToolTip = HTMLUtils.htmlifyToolTipText(menuToolTip, MAX_SERVICE_DESC_LEN); menu.setToolTipText(menuToolTip); parentMenu.add(menu); @@ -1017,46 +1082,6 @@ } } - /** - * By turning the tool tip text into HTML, we can make it multiline - */ - protected String htmlifyToolTipText(String text){ - int maxLine = MAX_SERVICE_DESC_LEN; - StringBuffer result = null; - - while(true){ - result = new StringBuffer(""); - StringTokenizer st = new StringTokenizer(text, " \t\n"); - int lineCharCount = 0; - - if(st.hasMoreTokens()){ - result.append(st.nextToken()); - lineCharCount = result.length()-6; - } - while(st.hasMoreTokens()){ - String word = st.nextToken(); - if(lineCharCount != 0 && lineCharCount + word.length() >= maxLine){ - result.append("
" + word); - lineCharCount = word.length(); - continue; - } - result.append(" " + word); - lineCharCount += word.length()+1; - - if(lineCharCount > maxLine){ //single word is bigger than preset width, redo layout - maxLine = lineCharCount; - break; - } - } - result.append(""); - if(!st.hasMoreTokens()){ //used up all the text, didn't break previous loop abnormally - break; - } - } //end layout block - - return result.toString(); - } - public JMenu addNameDivSubMenu(JMenu parentMenu, MobyService[] services){ if(services == null || services.length == 0){ return null; @@ -1097,10 +1122,7 @@ desc = type.getComment(); } String menuToolTip = commonAncestorDesc + desc; - if(menuToolTip.length() > MAX_SERVICE_DESC_LEN){ - // Cut down really long ancestry descs to the last part (most precise) - menuToolTip = htmlifyToolTipText(menuToolTip); - } + menuToolTip = HTMLUtils.htmlifyToolTipText(menuToolTip, MAX_SERVICE_DESC_LEN); menu.setToolTipText(menuToolTip); parentMenu.add(menu); @@ -1230,9 +1252,7 @@ assignMenuDataIndex(submenu); } desc = "Input data: " + desc; - if(desc.length() > MAX_SERVICE_DESC_LEN){ - desc = htmlifyToolTipText(desc); - } + desc = HTMLUtils.htmlifyToolTipText(desc, MAX_SERVICE_DESC_LEN); submenu.setToolTipText(desc); submenu.setName(SERVICE_SUBMENU_NAME); return submenu; From gordonp at dev.open-bio.org Thu Apr 26 11:30:01 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 26 Apr 2007 11:30:01 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704261530.l3QFU1sE001011@dev.open-bio.org> gordonp Thu Apr 26 11:30:01 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources In directory dev.open-bio.org:/tmp/cvs-serv976/src/main/ca/ucalgary/seahawk/resources Modified Files: mobyBuilderRules.xml Log Message: Added binary object rules for images and ABI trace files, plus DNASequence moby-live/Java/src/main/ca/ucalgary/seahawk/resources mobyBuilderRules.xml,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/mobyBuilderRules.xml,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/mobyBuilderRules.xml 2007/04/03 02:37:43 1.3 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/mobyBuilderRules.xml 2007/04/26 15:30:01 1.4 @@ -4,6 +4,77 @@ http://www.bioxml.info/dtd/tigrxml.dtd http://www.bioxml.info/dtd/Bioseq.dtd + + + (\N+(?:\x20|\r|\t|\n)?)+ + + + unknown + + $2 + string-length('$2') + + + + + \AABIF.*\z + + unknown + + + $0 + + + + + + \A.PNG\r\n\x1A\n.*\z + + $0 + + + + + \AGIF8.*\z + + $0 + + + + + + \A......(?:JFIF|Exif).*\z + + $0 + + + + + ((?:http|ftp|file):// + ([^/\x20\r\t\n]+)? # host name (non-whitespace, non-slash), maybe + \S*?) # rest of the URL until + ([,\.\)\(]\s|\z) # trailing punctuation and whitespace, or just EOD + + + $1 + + + $1 + + + + + (\S+@ # user name (non-whitespace) + [^/\x20\r\t\n]+ # host name (non-whitespace, non-slash chars) + \. # literal dot + [A-Za-z]{2,4}) # top level domain (2 to 4 letters) + (?:\W|\z) # must be followed by non-word char, or EOD + + + $1 + $1 + + (?:GI|gi)[|:](\d+) @@ -23,7 +94,7 @@ - (?:DOI|doi):?\s*(10\.\d+/[^%"\# \t\r\n]+) + (?:DOI|doi):?\s*(10\.\d+/[^%"\#\x20\t\r\n]+) $1 @@ -31,7 +102,7 @@ - (?:\s|\A|/)(10\.\d+/[A-Za-z]+[^%"\# \t\r\n]+) + (?:\s|\A|/)(10\.\d+/[A-Za-z]+[^%"\#\x20\t\r\n]+) $1 @@ -122,4 +193,4 @@ $1 - \ No newline at end of file + From gordonp at dev.open-bio.org Thu Apr 26 11:31:00 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 26 Apr 2007 11:31:00 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704261531.l3QFV0KD001075@dev.open-bio.org> gordonp Thu Apr 26 11:31:00 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources In directory dev.open-bio.org:/tmp/cvs-serv1040/src/main/ca/ucalgary/seahawk/resources Modified Files: startup.html Log Message: Updated to show that we can handle images files, and other binary file types moby-live/Java/src/main/ca/ucalgary/seahawk/resources startup.html,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/startup.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/startup.html 2007/03/27 14:01:36 1.2 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/startup.html 2007/04/26 15:31:00 1.3 @@ -7,7 +7,7 @@ Seahawk Quick Start:
    -
  1. Drag a desktop file (text, RTF or HTML), a Web link, a URL, or a part of an open Web page from your browser onto this window. It will open in a new tab.
  2. +
  3. Drag a desktop file (text, RTF, HTML, image, ABI trace file, etc.), a Web link, a URL, or a part of an open Web page from your browser onto this window. It will open in a new tab.
  4. Highlight the part of document you want to explore further (e.g. a DNA sequence or a database ID).
  5. Click the highlighted data and wait for analysis services options to pop up.
From gordonp at dev.open-bio.org Fri Apr 27 09:44:21 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 27 Apr 2007 09:44:21 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704271344.l3RDiLLf003307@dev.open-bio.org> gordonp Fri Apr 27 09:44:21 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared In directory dev.open-bio.org:/tmp/cvs-serv3272/src/main/org/biomoby/shared Modified Files: MobyPrimaryDataSimple.java Log Message: Worked around namespace setting quirks, replace blank ones if they the only one moby-live/Java/src/main/org/biomoby/shared MobyPrimaryDataSimple.java,1.10,1.11 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyPrimaryDataSimple.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyPrimaryDataSimple.java 2006/11/11 23:04:34 1.10 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyPrimaryDataSimple.java 2007/04/27 13:44:21 1.11 @@ -134,8 +134,14 @@ *************************************************************************/ public void addNamespace (MobyNamespace value) { synchronized (namespaces) { - if (! namespaces.contains (value)) + if (! namespaces.contains (value)){ + // GET RID OF ANY BLANK NAMESPACE IF WE'VE GOT A REAL ONE + if(namespaces.size() == 1 && + namespaces.elementAt(0).getName().length() == 0){ + namespaces.remove(0); + } namespaces.addElement (value); + } } } From gordonp at dev.open-bio.org Fri Apr 27 09:45:29 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 27 Apr 2007 09:45:29 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704271345.l3RDjTBk003373@dev.open-bio.org> gordonp Fri Apr 27 09:45:29 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data In directory dev.open-bio.org:/tmp/cvs-serv3338/src/main/org/biomoby/shared/data Modified Files: MobyDataObject.java Log Message: Workaround for namespace setting quirks of MobyPrimaryDataSimple moby-live/Java/src/main/org/biomoby/shared/data MobyDataObject.java,1.14,1.15 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObject.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/MobyDataObject.java 2007/03/12 17:03:24 1.14 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObject.java 2007/04/27 13:45:29 1.15 @@ -519,7 +519,8 @@ */ public void setPrimaryNamespace(MobyNamespace ns){ MobyNamespace[] nss = getNamespaces(); - if(nss == null || nss.length == 0){ + // special case, if no namespace already, simply add this one + if(nss == null || nss.length == 0 || nss[0].getName().length() == 0){ addNamespace(ns); return; } @@ -532,6 +533,7 @@ // Swap'em nss[i] = nss[0]; nss[0] = ns; + setNamespaces(null); setNamespaces(nss); } //It's in slot 0 as it should be @@ -543,6 +545,7 @@ // Prepend the namespace to the array newnss[0] = ns; System.arraycopy(nss, 0, newnss, 1, nss.length); + setNamespaces(null); setNamespaces(newnss); } From dag at dev.open-bio.org Mon Apr 23 18:39:11 2007 From: dag at dev.open-bio.org (Chris Dagdigian) Date: Mon, 23 Apr 2007 22:39:11 -0000 Subject: [MOBY-guts] biomoby commit Message-ID: <200704232239.l3NMd9T5023791@dev.open-bio.org> dag Mon Apr 23 18:39:08 EDT 2007 Update of /home/repository/moby/s-moby/ontologies In directory dev.open-bio.org:/home/dag/s-moby/ontologies Modified Files: PO.tar.gz moby.tar.gz sswap.tar.gz Log Message: Added files supplied by Teri Gomez @ NCGR in file s-moby_ncgr_20070413.tar -Chris Dagdigian s-moby/ontologies PO.tar.gz,1.1,1.2 moby.tar.gz,1.6,1.7 sswap.tar.gz,1.2,1.3 =================================================================== RCS file: /home/repository/moby/s-moby/ontologies/PO.tar.gz,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 Binary files /home/repository/moby/s-moby/ontologies/PO.tar.gz 2006/11/06 17:46:43 1.1 and /home/repository/moby/s-moby/ontologies/PO.tar.gz 2007/04/23 22:39:08 1.2 differ rcsdiff: /home/repository/moby/s-moby/ontologies/PO.tar.gz: diff failed =================================================================== RCS file: /home/repository/moby/s-moby/ontologies/moby.tar.gz,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 Binary files /home/repository/moby/s-moby/ontologies/moby.tar.gz 2006/12/20 01:30:12 1.6 and /home/repository/moby/s-moby/ontologies/moby.tar.gz 2007/04/23 22:39:08 1.7 differ rcsdiff: /home/repository/moby/s-moby/ontologies/moby.tar.gz: diff failed =================================================================== RCS file: /home/repository/moby/s-moby/ontologies/sswap.tar.gz,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 Binary files /home/repository/moby/s-moby/ontologies/sswap.tar.gz 2006/12/20 01:31:46 1.2 and /home/repository/moby/s-moby/ontologies/sswap.tar.gz 2007/04/23 22:39:08 1.3 differ rcsdiff: /home/repository/moby/s-moby/ontologies/sswap.tar.gz: diff failed From dag at dev.open-bio.org Mon Apr 23 18:39:16 2007 From: dag at dev.open-bio.org (Chris Dagdigian) Date: Mon, 23 Apr 2007 22:39:16 -0000 Subject: [MOBY-guts] biomoby commit Message-ID: <200704232239.l3NMdDhP023818@dev.open-bio.org> dag Mon Apr 23 18:39:13 EDT 2007 Update of /home/repository/moby/s-moby/ontologies/build In directory dev.open-bio.org:/home/dag/s-moby/ontologies/build Modified Files: build.xml Log Message: Added files supplied by Teri Gomez @ NCGR in file s-moby_ncgr_20070413.tar -Chris Dagdigian s-moby/ontologies/build build.xml,1.3,1.4 =================================================================== RCS file: /home/repository/moby/s-moby/ontologies/build/build.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/s-moby/ontologies/build/build.xml 2006/06/01 18:12:31 1.3 +++ /home/repository/moby/s-moby/ontologies/build/build.xml 2007/04/23 22:39:13 1.4 @@ -9,14 +9,9 @@ - - - - - - + dag Mon Apr 23 18:39:13 EDT 2007 Update of /home/repository/moby/s-moby/ontologies/sswap In directory dev.open-bio.org:/home/dag/s-moby/ontologies/sswap Added Files: SSWAP owlImports Log Message: Added files supplied by Teri Gomez @ NCGR in file s-moby_ncgr_20070413.tar -Chris Dagdigian s-moby/ontologies/sswap SSWAP,NONE,1.1 owlImports,NONE,1.1 From dag at dev.open-bio.org Mon Apr 23 18:39:24 2007 From: dag at dev.open-bio.org (Chris Dagdigian) Date: Mon, 23 Apr 2007 22:39:24 -0000 Subject: [MOBY-guts] biomoby commit Message-ID: <200704232239.l3NMdDSf023838@dev.open-bio.org> dag Mon Apr 23 18:39:13 EDT 2007 Update of /home/repository/moby/s-moby/ontologies/src/java/org/semanticmoby/ontologies/util In directory dev.open-bio.org:/home/dag/s-moby/ontologies/src/java/org/semanticmoby/ontologies/util Modified Files: OBOFileIndividualCreator.java Log Message: Added files supplied by Teri Gomez @ NCGR in file s-moby_ncgr_20070413.tar -Chris Dagdigian s-moby/ontologies/src/java/org/semanticmoby/ontologies/util OBOFileIndividualCreator.java,1.6,1.7 =================================================================== RCS file: /home/repository/moby/s-moby/ontologies/src/java/org/semanticmoby/ontologies/util/OBOFileIndividualCreator.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 From dag at dev.open-bio.org Mon Apr 23 18:39:25 2007 From: dag at dev.open-bio.org (Chris Dagdigian) Date: Mon, 23 Apr 2007 22:39:25 -0000 Subject: [MOBY-guts] biomoby commit Message-ID: <200704232239.l3NMdEpA023870@dev.open-bio.org> dag Mon Apr 23 18:39:13 EDT 2007 Update of /home/repository/moby/s-moby/ontologies/sswap/owldoc In directory dev.open-bio.org:/home/dag/s-moby/ontologies/sswap/owldoc Added Files: sswap.html Log Message: Added files supplied by Teri Gomez @ NCGR in file s-moby_ncgr_20070413.tar -Chris Dagdigian s-moby/ontologies/sswap/owldoc sswap.html,NONE,1.1 From deandres at dev.open-bio.org Mon Apr 2 07:43:46 2007 From: deandres at dev.open-bio.org (Enrique de Andres Saiz) Date: Mon, 2 Apr 2007 03:43:46 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704020743.l327hkg1004097@dev.open-bio.org> deandres Mon Apr 2 03:43:46 EDT 2007 Update of /home/repository/moby/moby-live/Perl/MOBY/Async In directory dev.open-bio.org:/tmp/cvs-serv4062 Modified Files: Service.pm Log Message: Catched INT andt TERM signals for destroying resource moby-live/Perl/MOBY/Async Service.pm,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Async/Service.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Perl/MOBY/Async/Service.pm 2007/03/15 09:50:50 1.4 +++ /home/repository/moby/moby-live/Perl/MOBY/Async/Service.pm 2007/04/02 07:43:45 1.5 @@ -151,20 +151,16 @@ sub execute { my ($self, %args) = @_; - print "Creating WS-Resource...\n\n" unless ($self->{silent}); - my $start = time; my ($EPR, @queryIDs) = $self->submit(%args); - print XML::LibXML->new->parse_string($EPR->XML)->getDocumentElement()->toString."\n\n" unless ($self->{silent}); - my $pollingTime; my ($i, $j) = (0, 1); my @status; while ( $pollingTime = &_getPollingTime($i, $j, $start, @status) ) { ($i, $j) = ($j, $i+$j); - print "Next polling in $pollingTime seconds...\n\n" unless ($self->{silent}); + print "(next polling in $pollingTime seconds)\n\n" unless ($self->{silent}); sleep $pollingTime; @status = $self->poll($EPR, @queryIDs); @@ -177,13 +173,11 @@ } } - print "Retrieving results and destroying WS-Resource...\n\n" unless ($self->{silent}); - my @responses = $self->result($EPR, @queryIDs); $self->destroy($EPR); my $response = &_composeResponse(@responses); - print "Finished.\n" unless ($self->{silent}); + print "Finished.\n\n" unless ($self->{silent}); return $response; } @@ -191,6 +185,8 @@ sub submit { my ($self, %args) = @_; + print "Creating WS-Resource...\n\n" unless ($self->{silent}); + # Compose the moby message (part of this block is copied from MOBY::Client::Service) die "ERROR: expected listref for XMLinputlist" unless ( ref( $args{XMLinputlist} ) eq 'ARRAY' ); my @inputs = @{ $args{XMLinputlist} }; @@ -269,6 +265,19 @@ $EPR->Address($address); $EPR->ReferenceParameters(''.$identifier.''); + print XML::LibXML->new->parse_string($EPR->XML)->getDocumentElement()->toString."\n\n" unless ($self->{silent}); + + $SIG{TERM} = sub { + $self->destroy($EPR); + print "Finished.\n\n" unless ($self->{silent}); + exit; + }; + $SIG{INT} = sub { + $self->destroy($EPR); + print "Finished.\n\n" unless ($self->{silent}); + exit; + }; + # Return Endpoint Reference and the queryIDs return ($EPR, @queryIDs); } @@ -281,15 +290,13 @@ my $start = time; my ($EPR, @queryIDs) = $self->enumerated_submit(%args); - print XML::LibXML->new->parse_string($EPR->XML)->getDocumentElement()->toString."\n\n" unless ($self->{silent}); - my $pollingTime; my ($i, $j) = (0, 1); my @status; while ( $pollingTime = &_getPollingTime($i, $j, $start, @status) ) { ($i, $j) = ($j, $i+$j); - print "Next polling in $pollingTime seconds...\n\n" unless ($self->{silent}); + print "(next polling in $pollingTime seconds)\n\n" unless ($self->{silent}); sleep $pollingTime; @status = $self->poll($EPR, @queryIDs); @@ -302,13 +309,11 @@ } } - print "Retrieving results and destroying WS-Resource...\n\n" unless ($self->{silent}); - my @responses = $self->result($EPR, @queryIDs); $self->destroy($EPR); my $response = &_composeResponse(@responses); - print "Finished.\n" unless ($self->{silent}); + print "Finished.\n\n" unless ($self->{silent}); return $response; } @@ -316,6 +321,8 @@ sub enumerated_submit { my ($self, %args) = @_; + print "Creating WS-Resource...\n\n" unless ($self->{silent}); + # Compose the moby message (part of this block is copied from MOBY::Client::Service) die "ERROR: expected Input to be a HASH ref" unless ( ref( $args{Input} ) eq 'HASH' ); my %inputs = %{$args{Input}}; @@ -393,6 +400,19 @@ $EPR->Address($address); $EPR->ReferenceParameters(''.$identifier.''); + print XML::LibXML->new->parse_string($EPR->XML)->getDocumentElement()->toString."\n\n" unless ($self->{silent}); + + $SIG{TERM} = sub { + $self->destroy($EPR); + print "Finished.\n\n" unless ($self->{silent}); + exit; + }; + $SIG{INT} = sub { + $self->destroy($EPR); + print "Finished.\n\n" unless ($self->{silent}); + exit; + }; + # Return Endpoint Reference and the queryIDs return ($EPR, @queryIDs); } @@ -400,6 +420,8 @@ sub poll { my ($self, $EPR, @queryIDs) = @_; + print "Polling...\n\n" unless ($self->{silent}); + my $searchTerm = ""; foreach my $queryID (@queryIDs) { $searchTerm .= ""; @@ -434,6 +456,8 @@ sub result { my ($self, $EPR, @queryIDs) = @_; + print "Retrieving results...\n\n" unless ($self->{silent}); + my $searchTerm = ""; foreach my $queryID (@queryIDs) { $searchTerm .= ""; @@ -467,6 +491,8 @@ sub destroy { my ($self, $EPR) = @_; + print "Destroying WS-Resource...\n\n" unless ($self->{silent}); + my $ans = WSRF::Lite -> uri($WSRF::Constants::WSRL) -> on_action( sub {sprintf '%s/%s', @_} ) From deandres at dev.open-bio.org Mon Apr 2 09:16:22 2007 From: deandres at dev.open-bio.org (Enrique de Andres Saiz) Date: Mon, 2 Apr 2007 05:16:22 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704020916.l329GMtp004787@dev.open-bio.org> deandres Mon Apr 2 05:16:22 EDT 2007 Update of /home/repository/moby/moby-live/Perl/MOBY/Async In directory dev.open-bio.org:/tmp/cvs-serv4752 Modified Files: Service.pm Log Message: Deleted a duplicated message into enumerated_execute moby-live/Perl/MOBY/Async Service.pm,1.5,1.6 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Async/Service.pm,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Perl/MOBY/Async/Service.pm 2007/04/02 07:43:45 1.5 +++ /home/repository/moby/moby-live/Perl/MOBY/Async/Service.pm 2007/04/02 09:16:21 1.6 @@ -285,8 +285,6 @@ sub enumerated_execute { my ($self, %args) = @_; - print "Creating WS-Resource...\n\n" unless ($self->{silent}); - my $start = time; my ($EPR, @queryIDs) = $self->enumerated_submit(%args); From deandres at dev.open-bio.org Mon Apr 2 12:13:32 2007 From: deandres at dev.open-bio.org (Enrique de Andres Saiz) Date: Mon, 2 Apr 2007 08:13:32 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704021213.l32CDW1E005063@dev.open-bio.org> deandres Mon Apr 2 08:13:32 EDT 2007 Update of /home/repository/moby/moby-live/Perl/MOBY/Async In directory dev.open-bio.org:/tmp/cvs-serv5016 Modified Files: LSAE.pm Service.pm SimpleServer.pm WSRF.pm Log Message: Modified pod title moby-live/Perl/MOBY/Async LSAE.pm,1.2,1.3 Service.pm,1.6,1.7 SimpleServer.pm,1.2,1.3 WSRF.pm,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Async/LSAE.pm,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Perl/MOBY/Async/LSAE.pm 2007/02/07 19:43:49 1.2 +++ /home/repository/moby/moby-live/Perl/MOBY/Async/LSAE.pm 2007/04/02 12:13:32 1.3 @@ -2,7 +2,7 @@ =head1 NAME -MOBY::Async::LSAE +MOBY::Async::LSAE - utilities to work with LSAE analysis event blocks =head1 AUTHORS =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Async/Service.pm,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Perl/MOBY/Async/Service.pm 2007/04/02 09:16:21 1.6 +++ /home/repository/moby/moby-live/Perl/MOBY/Async/Service.pm 2007/04/02 12:13:32 1.7 @@ -2,7 +2,7 @@ =head1 NAME -MOBY::Async::Service +MOBY::Async::Service - an object for communicating with Asynchronous MOBY Services =head1 AUTHORS =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Async/SimpleServer.pm,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Perl/MOBY/Async/SimpleServer.pm 2007/03/13 15:50:58 1.2 +++ /home/repository/moby/moby-live/Perl/MOBY/Async/SimpleServer.pm 2007/04/02 12:13:32 1.3 @@ -2,7 +2,7 @@ =head1 NAME -MOBY::Async::SimpleServer +MOBY::Async::SimpleServer - a base class for simple Asynchronous MOBY Services =head1 AUTHORS =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Async/WSRF.pm,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Perl/MOBY/Async/WSRF.pm 2006/12/04 08:27:52 1.1 +++ /home/repository/moby/moby-live/Perl/MOBY/Async/WSRF.pm 2007/04/02 12:13:32 1.2 @@ -2,7 +2,7 @@ =head1 NAME -MOBY::Async::WSRF +MOBY::Async::WSRF - utilities to work with WSRF in MOBY =head1 AUTHORS From gordonp at dev.open-bio.org Tue Apr 3 02:18:46 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 2 Apr 2007 22:18:46 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704030218.l332IknY006474@dev.open-bio.org> gordonp Mon Apr 2 22:18:46 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util In directory dev.open-bio.org:/tmp/cvs-serv6443/src/main/ca/ucalgary/seahawk/util Added Files: CloseTabIcon.java CombinedIcon.java NullIcon.java Log Message: Icon support for Seahawk tabs augmented to include close icon moby-live/Java/src/main/ca/ucalgary/seahawk/util CloseTabIcon.java,NONE,1.1 CombinedIcon.java,NONE,1.1 NullIcon.java,NONE,1.1 From gordonp at dev.open-bio.org Tue Apr 3 02:20:50 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 2 Apr 2007 22:20:50 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704030220.l332KonZ006555@dev.open-bio.org> gordonp Mon Apr 2 22:20:50 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-serv6524/src/main/ca/ucalgary/seahawk/resources/images Added Files: tabclose.gif tabclose_d.gif Log Message: Icon support for Seahawk tabs augmented to include close icon moby-live/Java/src/main/ca/ucalgary/seahawk/resources/images tabclose.gif,NONE,1.1 tabclose_d.gif,NONE,1.1 From gordonp at dev.open-bio.org Tue Apr 3 02:22:57 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 2 Apr 2007 22:22:57 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704030222.l332Mvde006640@dev.open-bio.org> gordonp Mon Apr 2 22:22:56 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client In directory dev.open-bio.org:/tmp/cvs-serv6605/src/main/org/biomoby/client Modified Files: MobyRequest.java Log Message: Added support for asynchronous service calls moby-live/Java/src/main/org/biomoby/client MobyRequest.java,1.23,1.24 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java 2007/03/30 21:17:27 1.23 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java 2007/04/03 02:22:56 1.24 @@ -121,6 +121,7 @@ debugPS.println("Syntax error encountered while compiling XPath " + "statements for internal use (code bug?): " + te); } + setDebugMode(System.getProperty("moby.debug") != null); } /** @@ -317,17 +318,17 @@ } } - // Parse and merge the new data into the existing contents - InputStream resultStream = AsyncClient.getResultStream(epr, newDataAvailable); - Element mobyDOM = asyncSoapTextToMobyDOM(resultStream); - MobyContentInstance newResults = MobyDataUtils.fromXMLDocument(mobyDOM); - // The merge - for(String jobid: newResults.keySet()){ - finalContents.put(jobid, newResults.get(jobid)); - } - - // Inform the handler that some data has been added to the response (for incremental display?) if(newDataAvailable.size() > 0 && handler != null){ + // Parse and merge the new data into the existing contents + InputStream resultStream = AsyncClient.getResultStream(epr, newDataAvailable); + Element mobyDOM = asyncSoapTextToMobyDOM(resultStream); + MobyContentInstance newResults = MobyDataUtils.fromXMLDocument(mobyDOM); + // The merge + for(String jobid: newResults.keySet()){ + finalContents.put(jobid, newResults.get(jobid)); + } + + // Inform the handler that some data has been added to the response (for incremental display?) MobyRequestEvent mre = new MobyRequestEvent(finalContents, this, null, requestId); StringWriter xmlWriter = new StringWriter(); MobyDataUtils.toXMLDocument(xmlWriter, finalContents); From gordonp at dev.open-bio.org Tue Apr 3 02:27:33 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 2 Apr 2007 22:27:33 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704030227.l332RXsx006685@dev.open-bio.org> gordonp Mon Apr 2 22:27: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-serv6650/src/main/org/biomoby/shared/data Modified Files: MobyDataDateTime.java Log Message: Belatedly made DateTime inherit directly from Object, since it's a primitive (it wasn't a couple of years ago when I first committed this class) moby-live/Java/src/main/org/biomoby/shared/data MobyDataDateTime.java,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataDateTime.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/MobyDataDateTime.java 2006/07/07 04:12:40 1.6 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataDateTime.java 2007/04/03 02:27:33 1.7 @@ -10,20 +10,23 @@ import java.util.TimeZone; /** - * A class representing a MOBY DateTime. - * DateTime is not a primitive in MOBY, but this is a useful utility - * class parses and outputs dates and times in proper ISO 8601 format + * A class representing a MOBY DateTime, which is a primitive in MOBY. + * This is a useful utility + * class that parses and outputs dates and times in proper ISO 8601 format * as required by the MOBY object description. * * For a description of ISO 8601 as used on the Web, see * http://www.w3.org/TR/NOTE-datetime * * Because getObject() will return a mutable GregorianCalendar, you can use - * its methods to modify the underlying date of this MOBY object. + * its methods to modify the underlying date of this MOBY object. Since it + * is a Gregorian calendar, if you + * are representing dates before September 14th, 1752, I guarantee nothing. * + * @author Paul Gordon */ -public class MobyDataDateTime extends MobyDataString{ +public class MobyDataDateTime extends MobyDataObject{ private GregorianCalendar value; @@ -285,7 +288,7 @@ } public Object clone(){ - MobyDataString copy = new MobyDataDateTime(getName(), getValue()); + MobyDataDateTime copy = new MobyDataDateTime(getName(), getValue()); copy.setDataType(getDataType()); copy.setId(getId()); copy.setNamespaces(getNamespaces()); From gordonp at dev.open-bio.org Tue Apr 3 02:29:54 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 2 Apr 2007 22:29:54 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704030229.l332TsUC006753@dev.open-bio.org> gordonp Mon Apr 2 22:29:54 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services In directory dev.open-bio.org:/tmp/cvs-serv6718/src/main/ca/ucalgary/seahawk/services Modified Files: MobyClient.java Log Message: Flanking whitespace processing for rules, plus disabled isAlive() check until we can do it more efficiently moby-live/Java/src/main/ca/ucalgary/seahawk/services MobyClient.java,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.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/MobyClient.java 2007/03/21 16:23:43 1.7 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java 2007/04/03 02:29:54 1.8 @@ -54,6 +54,7 @@ public static final String WHITESPACE_ATTR = "whitespace"; public static final String WHITESPACE_ATTR_STRIP_VAL = "strip"; 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 ENCODING_ATTR = "encoding"; public static final String ENCODING_ATTR_BASE64_VAL = "Base64"; @@ -395,10 +396,12 @@ } else if(!memberWhitespaceSetting.equals(WHITESPACE_ATTR_KEEP_VAL) && !memberWhitespaceSetting.equals(WHITESPACE_ATTR_NORMALIZE_VAL) && + !memberWhitespaceSetting.equals(WHITESPACE_ATTR_STRIP_FLANKING_VAL) && !memberWhitespaceSetting.equals(WHITESPACE_ATTR_STRIP_VAL)){ System.err.println("Object member " + memberNameKey + " has an unrecognized value for the " + WHITESPACE_ATTR + - " attribute, overriding with default of " + WHITESPACE_ATTR_KEEP_VAL); + " attribute (" + memberWhitespaceSetting + + "), overriding with default of " + WHITESPACE_ATTR_KEEP_VAL); memberWhitespaceSetting = WHITESPACE_ATTR_KEEP_VAL; } String memberEncodingSetting = memTag.getAttribute(ENCODING_ATTR); @@ -890,16 +893,20 @@ for(int i = 0; i < mdos.length; i++){ MobyService templateServices = new MobyService(""); templateServices.addInput(mdos[i]); + // Normally category is "moby", which excludes async services. + // Turn it into a wildcard instead by making the template category blank + templateServices.setCategory(""); MobyService[] mService = c.findService(templateServices); Vector filteredServices = new Vector(); // Let's make sure all of the services have their service type properly instantiated // for ontology checks later on for(int j = 0; j < mService.length; j++){ - MobyService service = MobyService.getService(mService[j].getName(), mService[j].getAuthority()); - if(service != null){ - mService[j] = service; - } + // Paul: commenting out is temporary until we can fetch the services more quickly + //MobyService service = MobyService.getService(mService[j].getName(), mService[j].getAuthority()); + //if(service != null){ + //mService[j] = service; + //} mService[j].setServiceType(MobyServiceType.getServiceType(mService[j].getServiceType().getName())); if(serviceLevel != MobyService.UNCHECKED){ @@ -911,7 +918,8 @@ } } - if(serviceLevel != MobyService.UNCHECKED){ + // Paul: false is temporary until we can fetch the services more quickly (and check isAlive) + if(false && serviceLevel != MobyService.UNCHECKED){ mService = (MobyService []) filteredServices.toArray(new MobyService[filteredServices.size()]); } From gordonp at dev.open-bio.org Tue Apr 3 02:30:36 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 2 Apr 2007 22:30:36 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704030230.l332UapC006796@dev.open-bio.org> gordonp Mon Apr 2 22:30:36 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services In directory dev.open-bio.org:/tmp/cvs-serv6761/src/main/ca/ucalgary/seahawk/services Modified Files: MobyComplexBuilder.java Log Message: Flanking whitespace processing for rules, start of implicit iteration code for HAS rules moby-live/Java/src/main/ca/ucalgary/seahawk/services MobyComplexBuilder.java,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyComplexBuilder.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/MobyComplexBuilder.java 2007/03/12 14:38:38 1.3 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyComplexBuilder.java 2007/04/03 02:30:36 1.4 @@ -148,10 +148,19 @@ for(int i = 0; i < children.length; i++){ String memberName = children[i].getName(); String[] resultSpec = (String[]) memberRules.get(memberName); + MobyRelationship memberRelationship = mobyDataType.getChild(memberName); String result = resultSpec[0]; byte[] resultBytes = result.getBytes(); String whitespaceMode = resultSpec[1]; String encodingMode = resultSpec[2]; + + // 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){ + + } + // else is iHASA, scalar context boolean nonBasic = result.length() != 2 || result.indexOf("$") != 0; MobyPrefixResolver.MobyNodeList nodeList = new MobyPrefixResolver.MobyNodeList(); @@ -192,6 +201,9 @@ else if(whitespaceMode.equals(MobyClient.WHITESPACE_ATTR_STRIP_VAL)){ varValue = varValue.replaceAll("\\s+",""); } + else if(whitespaceMode.equals(MobyClient.WHITESPACE_ATTR_STRIP_FLANKING_VAL)){ + varValue = varValue.trim(); // removes leading and trailing whitespace + } result = result.replaceAll("\\$"+j, varValue); // Binary data and XPath are incompatible, since many bytes are not allowed in XML @@ -201,12 +213,12 @@ } if(encodingMode.equals(MobyClient.ENCODING_ATTR_BASE64_VAL)){ - (new Exception("Base 64 encoding")).printStackTrace(); + //(new Exception("Base 64 encoding")).printStackTrace(); result = org.apache.axis.encoding.Base64.encode(data == null ? result.getBytes() : resultBytes); } else{ - System.err.println("NO BASE64 (" + MobyClient.ENCODING_ATTR_BASE64_VAL + - ") ENCODING for " +memberName+": " + encodingMode); + //System.err.println("NO BASE64 (" + MobyClient.ENCODING_ATTR_BASE64_VAL + + // ") ENCODING for " +memberName+": " + encodingMode); } // If the value contains anything other than $#, treat it as a XPath expression From gordonp at dev.open-bio.org Tue Apr 3 02:31:29 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 2 Apr 2007 22:31:29 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704030231.l332VTnH006841@dev.open-bio.org> gordonp Mon Apr 2 22:31:29 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-serv6806/src/main/ca/ucalgary/seahawk/resources/images Modified Files: document.gif Log Message: Made background transparent moby-live/Java/src/main/ca/ucalgary/seahawk/resources/images document.gif,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/images/document.gif,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 Binary files /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/images/document.gif 2006/10/25 02:33:22 1.1 and /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/images/document.gif 2007/04/03 02:31:29 1.2 differ rcsdiff: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/images/document.gif: diff failed From gordonp at dev.open-bio.org Tue Apr 3 02:32:15 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 2 Apr 2007 22:32:15 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704030232.l332WFu2006884@dev.open-bio.org> gordonp Mon Apr 2 22:32:14 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-serv6849/src/main/ca/ucalgary/seahawk/gui/test Modified Files: SeahawkTestCase.java Log Message: Refactoring, plus addition of asynchronous service test case moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test SeahawkTestCase.java,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test/SeahawkTestCase.java,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/gui/test/SeahawkTestCase.java 2007/02/08 16:59:58 1.4 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test/SeahawkTestCase.java 2007/04/03 02:32:14 1.5 @@ -37,6 +37,7 @@ private final static String TEST_MOBY_XML = "ca/ucalgary/seahawk/gui/test/allDataTypes.xml"; private final static String TEST_EXTERNAL_URL = "http://www.google.com/"; private final static String TEST_DNA_SEQ = "AAGCTTGGCCAACGTAAATCTTTCGGCGGCA"; + private final static String TEST_AA_SEQ = "MPGGFILAIDEGTTSARAIIYNQDLEVLGIGQYDFPQHYPSP"; private JFCTestHelper helper = null; @@ -156,7 +157,7 @@ dnaDataType, clipSet.getDataType()); // add an object of another type (AminoAcidSequence) - MobyDataObject mobyObject3 = MobyUtils.createMobySequence("MPGGFILAIDEGTTSARAIIY", "baz"); + MobyDataObject mobyObject3 = MobyUtils.createMobySequence(TEST_AA_SEQ, "baz"); clipSet = contentGUI.addToClipboard(mobyObject3); assertNotNull("The clipboard is null, but should be initialized, with two objects", clipSet); assertTrue("The clipboard contains the wrong number (" + clipSet.size() + ") of items, expected 3", @@ -569,9 +570,9 @@ public void testCloseOtherTabs(){ } - public void testRunServices() throws Exception{ + public void findService(String sequenceData, String targetMenuText, String targetServiceLabelText) throws Exception{ // load a dna sequence in a tab - MobyDataObject mobyObject = MobyUtils.createMobySequence(TEST_DNA_SEQ, "foo"); + MobyDataObject mobyObject = MobyUtils.createMobySequence(sequenceData, "foo"); contentGUI.loadPaneFromObject(new MobyContentInstance(mobyObject, "hyperlink-test"), true); //true = load in new tab // give the JVM time to paint the new data @@ -584,8 +585,9 @@ String text = pane.getDocument().getText(0, pane.getDocument().getLength()); // Find the position of the first XPointer link (should be a reference // to the file version of the DNASequence we created above) - int hyperlinkModelIndex = text.indexOf("DNASequence"); - assertFalse("Could not find a MOBY link in the DNASequence representation", hyperlinkModelIndex == -1); + String dataType = mobyObject.getDataType().getName(); + int hyperlinkModelIndex = text.indexOf(dataType); + assertFalse("Could not find a MOBY link in the "+dataType+" representation", hyperlinkModelIndex == -1); try{ Rectangle linkPos = pane.modelToView(hyperlinkModelIndex+4); @@ -601,7 +603,8 @@ } Robot robot = new Robot(); - robot.mouseMove(screenPos.x, screenPos.y); + robot.mouseMove(screenPos.x, screenPos.y+10); + sleep(1000); robot.mousePress(InputEvent.BUTTON1_MASK); robot.mouseRelease(InputEvent.BUTTON1_MASK); sleep(2000); @@ -614,7 +617,7 @@ openPopup instanceof JPopupMenu); // Move the mouse a bit to the right to bring up the submenu - robot.mouseMove(screenPos.x+10, screenPos.y); + robot.mouseMove(screenPos.x+10, screenPos.y+8); // Find a submenu with services Component serviceTypeChoices = getSubComponentByName((JPopupMenu) openPopup, @@ -631,7 +634,7 @@ JMenuItem serviceTypeChosen = ((JMenu) serviceTypeChoices).getItem(1); for(int i = 2; - serviceTypeChosen.getText().indexOf("Analysis") == -1 && + serviceTypeChosen.getText().indexOf(targetMenuText) == -1 && i <= ((JMenu) serviceTypeChoices).getItemCount(); i++){ if(i == ((JMenu) serviceTypeChoices).getItemCount()){ @@ -649,64 +652,55 @@ sleep(1000); serviceTypeChoices = serviceTypeChosen; - Vector servicePathChosen = findMenuItem((JMenu) serviceTypeChosen, "..."); + Vector servicePathChosen = findMenuItem((JMenu) serviceTypeChosen, targetServiceLabelText); if(servicePathChosen == null || servicePathChosen.size() == 0){ - System.err.println("WARNING: Skipping test of secondary param services, none were found ending in '...'"); - return; + throw new Exception("Cannot find a target service, "+ + "none were found ending in '"+targetServiceLabelText+"'"); } - else{ - // Make sure it's visible - showMenuItem((JMenu) serviceTypeChosen, servicePathChosen, robot); - Point serviceMenuItemLoc = servicePathChosen.lastElement().getLocationOnScreen(); //so move the mouse there too - // and click the service button - robot.mouseMove(serviceMenuItemLoc.x+2, serviceMenuItemLoc.y+2); - robot.keyPress(KeyEvent.VK_SHIFT); - robot.mousePress(InputEvent.BUTTON1_MASK); - robot.mouseRelease(InputEvent.BUTTON1_MASK); - robot.keyRelease(KeyEvent.VK_SHIFT); - //serviceChosen.doClick(300); - sleep(2000); - JDialog secondaryParamsDialog = null; + // Make sure it's visible + showMenuItem((JMenu) serviceTypeChosen, servicePathChosen, robot); + Point serviceMenuItemLoc = servicePathChosen.lastElement().getLocationOnScreen(); //so move the mouse there too + // and click the service button + robot.mouseMove(serviceMenuItemLoc.x+2, serviceMenuItemLoc.y+2); + robot.keyPress(KeyEvent.VK_SHIFT); + robot.mousePress(InputEvent.BUTTON1_MASK); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + robot.keyRelease(KeyEvent.VK_SHIFT); + //serviceChosen.doClick(300); + sleep(2000); + } - DialogFinder dfinder = new DialogFinder(".*"); - List showingDialogs = dfinder.findAll(); - for(int i = 0; i < showingDialogs.size(); i++){ - JDialog dialog = (JDialog) showingDialogs.get(i); - if(MobySecondaryInputGUI.TITLE.equals(dialog.getTitle())){ - secondaryParamsDialog = dialog; - break; - } - } + public void testRunAsynchronousService() throws Exception{ + try{ + findService(TEST_AA_SEQ, "Bioinformatics", "(async)"); + } catch(Exception e){ + e.printStackTrace(); + fail("Error while finding a service ending with \"(async)\" " + + "(asynchronous execution) under \"Bioinformatics\" in the popup"); + } - assertNotNull("Requesting a service with secondary parameters did not launch " + - "a secondary parameter input component (was null)", - secondaryParamsDialog); - assertTrue("Secondary parameter input component was not a JDialog as expected (was a " + - secondaryParamsDialog.getClass().getName(), - secondaryParamsDialog instanceof JDialog); - Component okButton = getSubComponentByName(secondaryParamsDialog.getContentPane(), - MobySecondaryInputGUI.OK_BUTTON_NAME); - assertNotNull("Could not find the OK button in the secondary input GUI dialog", okButton); - Point okLoc = okButton.getLocationOnScreen(); //so move the mouse there too - // and click the OK button - robot.mouseMove(okLoc.x+2, okLoc.y+2); - robot.mousePress(InputEvent.BUTTON1_MASK); - robot.mouseRelease(InputEvent.BUTTON1_MASK); - sleep(2000); + fillInSecondariesAndExecute(); - showingDialogs = dfinder.findAll(); - for(int i = 0; i < showingDialogs.size(); i++){ - JDialog dialog = (JDialog) showingDialogs.get(i); - if(dialog.isVisible()){ - assertFalse("The secondary parameter window did not disappear when enter was pressed (" + - "either the approval button does not have the default focus, or " + - " there is an internal problem with the dialog validation)", - MobySecondaryInputGUI.TITLE.equals(dialog.getTitle())); - } + // Wait until the job is finished to proceed to the next test + while(contentGUI.getCurrentURL() == null){ + sleep(1000); + if(contentGUI.isShowingFailure()){ + break; } - } - + sleep(2000); //just to ensure HTML rendering finishes + } + + public void testRunServiceSecondariesAndSCUFL() throws Exception{ + try{ + findService(TEST_DNA_SEQ, "Bioinformatics", "..."); + } catch(Exception e){ + e.printStackTrace(); + fail("Error while a finding service ending with \"...\" " + + "(secondary input) under \"Analysis\" in the popup"); + } + fillInSecondariesAndExecute(); + // Wait until the job is finished to proceed to the next test while(contentGUI.getCurrentURL() == null){ sleep(1000); @@ -724,6 +718,49 @@ assertTrue("The SCUFL saved data file was empty", testFile.length() != 0); } + public void fillInSecondariesAndExecute() throws Exception{ + Robot robot = new Robot(); + JDialog secondaryParamsDialog = null; + + DialogFinder dfinder = new DialogFinder(".*"); + List showingDialogs = dfinder.findAll(); + for(int i = 0; i < showingDialogs.size(); i++){ + JDialog dialog = (JDialog) showingDialogs.get(i); + if(MobySecondaryInputGUI.TITLE.equals(dialog.getTitle())){ + secondaryParamsDialog = dialog; + break; + } + } + + assertNotNull("Requesting a service with secondary parameters did not launch " + + "a secondary parameter input component (was null)", + secondaryParamsDialog); + assertTrue("Secondary parameter input component was not a JDialog as expected (was a " + + secondaryParamsDialog.getClass().getName(), + secondaryParamsDialog instanceof JDialog); + Component okButton = getSubComponentByName(secondaryParamsDialog.getContentPane(), + MobySecondaryInputGUI.OK_BUTTON_NAME); + assertNotNull("Could not find the OK button in the secondary input GUI dialog", okButton); + Point okLoc = okButton.getLocationOnScreen(); //so move the mouse there too + // and click the OK button + robot.mouseMove(okLoc.x+2, okLoc.y+2); + robot.mousePress(InputEvent.BUTTON1_MASK); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + sleep(2000); + + showingDialogs = dfinder.findAll(); + for(int i = 0; i < showingDialogs.size(); i++){ + JDialog dialog = (JDialog) showingDialogs.get(i); + if(dialog.isVisible()){ + assertFalse("The secondary parameter window did not disappear when enter was pressed (" + + "either the approval button does not have the default focus, or " + + "there is an internal problem with the dialog validation)", + MobySecondaryInputGUI.TITLE.equals(dialog.getTitle())); + } + } + + } + // Load a document, then highlight a salient section that can be turned into Web Service choices // via MobyServicesGUI. public void testHighlightOptions() throws Exception{ @@ -853,17 +890,18 @@ public static Test suite() { TestSuite suite = new TestSuite(); - suite.addTest(new SeahawkTestCase("testMain")); //done - suite.addTest(new SeahawkTestCase("testHelpTab")); //done - suite.addTest(new SeahawkTestCase("testHelpButton")); //done - suite.addTest(new SeahawkTestCase("testClipboardTab")); //done - suite.addTest(new SeahawkTestCase("testOpenButton")); //done - suite.addTest(new SeahawkTestCase("testSave")); //done - suite.addTest(new SeahawkTestCase("testPrint")); //done - suite.addTest(new SeahawkTestCase("testNavigationButtons")); //done - suite.addTest(new SeahawkTestCase("testRunServices")); //done - suite.addTest(new SeahawkTestCase("testHighlightOptions"));//done - suite.addTest(new SeahawkTestCase("testExternalBrowser"));//done + suite.addTest(new SeahawkTestCase("testMain")); //done + suite.addTest(new SeahawkTestCase("testHelpTab")); //done + suite.addTest(new SeahawkTestCase("testHelpButton")); //done + suite.addTest(new SeahawkTestCase("testClipboardTab")); //done + suite.addTest(new SeahawkTestCase("testOpenButton")); //done + suite.addTest(new SeahawkTestCase("testSave")); //done + suite.addTest(new SeahawkTestCase("testPrint")); //done + suite.addTest(new SeahawkTestCase("testNavigationButtons")); //done + suite.addTest(new SeahawkTestCase("testRunAsynchronousService")); //done + suite.addTest(new SeahawkTestCase("testRunServiceSecondariesAndSCUFL")); //done + suite.addTest(new SeahawkTestCase("testHighlightOptions"));//done + suite.addTest(new SeahawkTestCase("testExternalBrowser"));//doney return suite; } @@ -906,15 +944,19 @@ } public boolean findMenuItem(JMenu menu, String pattern, Vector result){ - JMenuItem serviceChosen = menu.getItem(0); - for(int i = 1; - serviceChosen.getText().indexOf(pattern) == -1 && i <= menu.getItemCount(); + JMenuItem serviceChosen = null; + for(int i = 0; + i <= menu.getItemCount(); i++){ if(i == menu.getItemCount()){ return false; } + + serviceChosen = menu.getItem(i); + if(serviceChosen.getText().indexOf(pattern) != -1){ + break; + } else{ - serviceChosen = menu.getItem(i); // Nested menu if(serviceChosen instanceof JMenu){ if(findMenuItem((JMenu) serviceChosen, pattern, result)){ From gordonp at dev.open-bio.org Tue Apr 3 02:33:57 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 2 Apr 2007 22:33:57 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704030233.l332XvsP006948@dev.open-bio.org> gordonp Mon Apr 2 22:33:57 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv6913/src/main/ca/ucalgary/seahawk/gui Modified Files: MobySecondaryInputGUI.java Log Message: Added paste functionality miscellanea, and better tab interaction (close icon, ctrl-T for new) moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobySecondaryInputGUI.java,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobySecondaryInputGUI.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/MobySecondaryInputGUI.java 2007/03/27 14:02:53 1.3 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobySecondaryInputGUI.java 2007/04/03 02:33:57 1.4 @@ -33,6 +33,7 @@ private Map data2widget; private ActionListener listener; private int handlerCode = 0; // callback event ID provided by caller to c-tor + private boolean showingNew = false; private static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(MobySecondaryInputGUI.class); @@ -50,6 +51,7 @@ listener = al; handlerCode = actionCommandID; setVisible(false); + showingNew = false; setName(TITLE); } @@ -166,11 +168,20 @@ pack(); toFront(); requestFocus(); + showingNew = true; confirmButton.requestFocusInWindow(); } } } + public boolean isNewShowing(){ + boolean ret = showingNew; + if(ret){ + showingNew = false; + } + return ret; + } + public Component makeWidget(MobyDataSecondaryInstance msdi){ String dataType = msdi.getDataType(); From gordonp at dev.open-bio.org Tue Apr 3 02:34:09 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 2 Apr 2007 22:34:09 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704030234.l332Y90U007007@dev.open-bio.org> gordonp Mon Apr 2 22:34:08 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv6956/src/main/ca/ucalgary/seahawk/gui Modified Files: MobyContentClipboard.java MobyContentGUI.java MobyContentPane.java MobyServicesGUI.java SplashWindow.java Log Message: Added paste functionality miscellanea, and better tab interaction (close icon, ctrl-T for new) moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyContentClipboard.java,1.2,1.3 MobyContentGUI.java,1.5,1.6 MobyContentPane.java,1.5,1.6 MobyServicesGUI.java,1.7,1.8 SplashWindow.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentClipboard.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/MobyContentClipboard.java 2007/02/08 16:59:57 1.2 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentClipboard.java 2007/04/03 02:34:08 1.3 @@ -89,6 +89,10 @@ sGUI.setClipboard(this); } + // By overriding this with a blank method body, we avoid adding a close icon to the tab + public void stateChanged(javax.swing.event.ChangeEvent ce){ + } + /** Sets up temporary files, icons, etc. */ public void init(){ int index = tabbedPane.indexOfComponent(this); =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.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/MobyContentGUI.java 2007/03/21 16:24:42 1.5 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java 2007/04/03 02:34:08 1.6 @@ -10,6 +10,7 @@ import java.util.TreeMap; import javax.swing.*; +import javax.swing.event.*; import javax.xml.transform.stream.*; import javax.xml.transform.*; @@ -28,7 +29,7 @@ * @author Paul Gordon (gordonp at ucalgary.ca) */ -public class MobyContentGUI extends JFrame implements ActionListener, ComponentListener, MobyRequestEventHandler, MouseListener{ +public class MobyContentGUI extends JFrame implements ActionListener, ComponentListener, KeyListener, MobyRequestEventHandler, MouseListener{ // Variables used to coordinate component finding with the unit test cases public final static String BACK_BUTTON_NAME = "MCGbackButton"; @@ -50,6 +51,8 @@ public final static String DEFAULT_STARTUP_PAGE_RESOURCE = "ca/ucalgary/seahawk/resources/startup.html"; public final static String DEFAULT_XSLT_CONVERTER_URL = "ca/ucalgary/seahawk/resources/moby2HTML.xsl"; public final static int MAX_TAB_NAME_LENGTH = 25; + public final static String CLIPBOARD_TAB_TOOLTIP = "Right-click for clipboard options"; + public final static String TAB_TOOLTIP = "Right-click for tab options, or Ctrl-T for new tab"; public final static String CLOSE_TAB_OPTION = "Close This Tab"; public final static String CLOSE_OTHERS_OPTION = "Close Other Tabs"; public final static String FILE_OPEN_OPTION = "Open File"; @@ -176,6 +179,8 @@ // See OptionsTabbedPaneUI class definiton at the end of this file (overrides right-click behaviour) tabbedPane.setUI(new OptionsTabbedPaneUI(this)); tabbedPane.setSize(getContentSize()); + tabbedPane.setToolTipText("Hit to display a new tab"); + tabbedPane.addKeyListener(this); clipboard = new MobyContentClipboard(this, servicesGUI, @@ -185,6 +190,18 @@ } + public boolean allTabsVisible(){ + if(tabbedPane.getTabLayoutPolicy() == JTabbedPane.WRAP_TAB_LAYOUT){ + return true; + } + for(int i = 0; i < tabbedPane.getTabCount(); i++){ + if(tabbedPane.getBoundsAt(i) == null){ + return false; //bounds null if not showing on screen + } + } + return true; + } + public JPanel getToolbar(){ return statusPanel; } @@ -205,6 +222,24 @@ } /** + * 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 + * paste events. + */ + public void keyPressed(KeyEvent e){ + // Ctrl-T for new tab, like regular Web browsers + if(e.getKeyCode() == KeyEvent.VK_T && e.isControlDown()){ + MobyContentPane tab = createTab("New Tab"); + tabbedPane.setSelectedComponent(tab); + tab.getDisplay().setText("Use the file/globe icon at the bottom of this window to load data," + + "or drag'n'drop/paste data from your desktop or Web browser."); + } + } + + public void keyReleased(KeyEvent e){} + public void keyTyped(KeyEvent e){} + + /** * This method sets the layout, basic GUI elements, * initializes conditions, and so on so it'll be ready to go when gotoURL is called * to load a MOBY document for the first time. @@ -245,6 +280,10 @@ setVisible(true); tabbedPane.add(clipboard); + int clipboardIndex = tabbedPane.indexOfComponent(clipboard); + if(clipboardIndex != -1){ + tabbedPane.setToolTipTextAt(clipboardIndex, CLIPBOARD_TAB_TOOLTIP); + } clipboard.setPreferredSize(getContentSize()); clipboard.init(); setup = true; @@ -271,6 +310,10 @@ setVisible(true); tab.setPreferredSize(getContentSize()); tabbedPane.addTab(title, tab); + int tabIndex = tabbedPane.indexOfComponent(tab); + if(tabIndex != -1){ + tabbedPane.setToolTipTextAt(tabIndex, TAB_TOOLTIP); + } return tab; } @@ -792,7 +835,7 @@ item.addActionListener(gui); tabOptions.add(item); } - else{ + else if(tabbedPane.getTabCount() > 1){ item = new JMenuItem(MobyContentGUI.CLOSE_TAB_OPTION); item.setActionCommand(MobyContentGUI.CLOSE_TAB_OPTION); item.addActionListener(gui); @@ -861,16 +904,19 @@ new Thread(){ public void run(){org.biomoby.shared.MobyDataType.getDataType("Object");} }.start(); - // And the service definitions new Thread(){ - public void run(){org.biomoby.shared.MobyService.getService("","");} + 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(); MobyContentGUI gui = ca.ucalgary.seahawk.util.MobyUtils.getMobyContentGUI(new JLabel()); gui.setDefaultCloseOperation(defaultCloseOperation); gui.setVisible(true); - if(argv.length != 0){ + if(argv.length != 0 && argv[0] != null && argv[0].length() != 0){ try{ gui.loadPaneFromURL(new URL(argv[0]), true); } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.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/MobyContentPane.java 2007/03/23 20:22:52 1.5 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java 2007/04/03 02:34:08 1.6 @@ -19,9 +19,7 @@ import org.apache.xpath.*; import org.apache.xpath.objects.*; -import ca.ucalgary.seahawk.util.DynamicJPopupMenu; -import ca.ucalgary.seahawk.util.PrintableJEditorPane; -import ca.ucalgary.seahawk.util.MobyUtils; +import ca.ucalgary.seahawk.util.*; import javax.swing.*; import javax.swing.event.*; @@ -41,15 +39,17 @@ * Also provides link handling (including service options popup) and drag 'n' drop capabilities. */ -public class MobyContentPane extends JPanel implements Printable, CaretListener, HyperlinkListener, MouseListener, MobyRequestEventHandler, KeyListener{ +public class MobyContentPane extends JPanel implements Printable, CaretListener, HyperlinkListener, MouseListener, MobyRequestEventHandler, KeyListener, ChangeListener{ public static final String MOBY_SERVICE_POPUP_NAME = "seahawkServicePopup"; public static final String WAITING_TAB_ICON_RESOURCE = "ca/ucalgary/seahawk/resources/images/hourglass.gif"; public static final String FAILED_TAB_ICON_RESOURCE = "ca/ucalgary/seahawk/resources/images/failed.gif"; public static final String LOADED_TAB_ICON_RESOURCE = "ca/ucalgary/seahawk/resources/images/document.gif"; + private static final int TAB_ICON_SPACER = 2; private static ImageIcon hourglassIcon; private static ImageIcon failedIcon; private static ImageIcon loadedIcon; + private static ImageIcon closeIcon; /** The name of the param in the stylesheet that will hold the Moby doc URL for XPointer usage */ public final static String XSL_DOC_SOURCE_PARAM = "sourceURL"; @@ -83,6 +83,8 @@ addKeyListener(this); setTransferHandler(new FileAndTextTransferHandler(cGUI)); + tabbedPane.addChangeListener(this); + // The following is a non-user editable pane for showing HTML editorPane = new PrintableJEditorPane(); editorPane.addKeyListener(this); @@ -131,6 +133,35 @@ } } + public void stateChanged(ChangeEvent ce){ + int tabIndex = tabbedPane.indexOfComponent(this); + Icon currentIcon = tabIndex < 0 ? null : tabbedPane.getIconAt(tabIndex); + if(tabIndex == tabbedPane.getSelectedIndex() && + tabbedPane.getTabCount() > 1){ + try{ + if(currentIcon == null){ + tabbedPane.setIconAt(tabIndex, new CloseTabIcon()); + return; + } + // If there's a real (non-close-tab) single icon, add the close tab icon + if(!(currentIcon instanceof CloseTabIcon)){ + try{tabbedPane.setIconAt(tabIndex, new CloseTabIcon(currentIcon, TAB_ICON_SPACER));} + catch(Exception e){e.printStackTrace();} + tabbedPane.setDisabledIconAt(tabIndex, currentIcon); + } + } + catch(Exception e){ + e.printStackTrace(); + } + + } else{ + if(currentIcon != null && currentIcon instanceof CloseTabIcon){ + tabbedPane.setIconAt(tabIndex, ((CloseTabIcon) currentIcon).getSecondIcon()); + tabbedPane.setDisabledIconAt(tabIndex, ((CloseTabIcon) currentIcon).getSecondIcon()); + } + } + } + public void setPreferredSize(Dimension dims){ super.setPreferredSize(dims); scrollPane.setPreferredSize(dims); @@ -370,8 +401,19 @@ } public void failed(String msg){ - tabbedPane.setIconAt(tabbedPane.indexOfComponent(this), failedIcon); - tabbedPane.setTitleAt(tabbedPane.indexOfComponent(this), msg); + int tabIndex = tabbedPane.indexOfComponent(this); + if(tabIndex > -1){ + try{tabbedPane.setIconAt(tabIndex, + new CloseTabIcon(failedIcon, TAB_ICON_SPACER));} + catch(Exception e){e.printStackTrace(); + tabbedPane.setIconAt(tabIndex, failedIcon);} + } + else{ + tabbedPane.setIconAt(tabIndex, failedIcon); + } + tabbedPane.setDisabledIconAt(tabIndex, failedIcon); + + tabbedPane.setTitleAt(tabIndex, msg); // Add the ability to back track from the error to the previous document if(historyIndex != -1){ historyIndex++; @@ -382,8 +424,18 @@ } public void succeeded(String msg){ - tabbedPane.setIconAt(tabbedPane.indexOfComponent(this), loadedIcon); - tabbedPane.setTitleAt(tabbedPane.indexOfComponent(this), msg); + int tabIndex = tabbedPane.indexOfComponent(this); + if(tabIndex > -1 && tabbedPane.getTabCount() > 1){ + try{tabbedPane.setIconAt(tabIndex, + new CloseTabIcon(loadedIcon, TAB_ICON_SPACER));} + catch(Exception e){e.printStackTrace(); + tabbedPane.setIconAt(tabIndex, loadedIcon);} + } + else{ + tabbedPane.setIconAt(tabIndex, loadedIcon); + } + tabbedPane.setDisabledIconAt(tabIndex, loadedIcon); + tabbedPane.setTitleAt(tabIndex, msg); // Store the latest title for the URL loaded, in case we revisit historyTabLabels.put(history.elementAt(historyIndex), msg); hasFailed = false; @@ -685,7 +737,17 @@ // Set the icon for the tab to an hourglass if(tabbedPane != null){ - tabbedPane.setIconAt(tabbedPane.indexOfComponent(this), hourglassIcon); + int tabIndex = tabbedPane.indexOfComponent(this); + if(tabIndex > -1){ + try{tabbedPane.setIconAt(tabIndex, + new CloseTabIcon(hourglassIcon, TAB_ICON_SPACER));} + catch(Exception e){e.printStackTrace(); + tabbedPane.setIconAt(tabIndex, hourglassIcon);} + } + else{ + tabbedPane.setIconAt(tabIndex, hourglassIcon); + } + tabbedPane.setDisabledIconAt(tabIndex, hourglassIcon); } } @@ -885,6 +947,15 @@ * like Control-v to paste. */ public void mouseEntered(MouseEvent e){ + // There is one situation where we *don't* want to take the focus, when + // the secondary parameter dialog has just been displayed. We get a mouseEntered + // callback when the popup menu used to select the service disappears, + // and the secondary parameter dialog gets hidden behind the main window where + // the user can't see it! + if(servicesGUI.isSecondaryParamDialogNew()){ + return; + } + if(!requestFocusInWindow()){ requestFocus(); } @@ -1072,17 +1143,22 @@ } /** - * Implemented to provide paste functonality (control-v or the paste button on a Sun keyboard), + * 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 * paste events. */ public void keyPressed(KeyEvent e){ - System.err.println("Key pressed " + e.getKeyChar()); if(e.getKeyCode() == KeyEvent.VK_PASTE || e.getKeyCode() == KeyEvent.VK_V && e.isControlDown()){ - System.err.println("Paste (pressed)!"); paste(); } + // Ctrl-T for new tab, like regular Web browsers + if(e.getKeyCode() == KeyEvent.VK_T && e.isControlDown()){ + MobyContentPane tab = contentGUI.createTab("New Tab"); + tabbedPane.setSelectedComponent(tab); + tab.getDisplay().setText("Use the file/globe icon at the bottom of this window to load data," + + "or drag'n'drop/paste data from your desktop or Web browser."); + } } public void keyReleased(KeyEvent e){} =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyServicesGUI.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/MobyServicesGUI.java 2007/02/08 16:59:57 1.7 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyServicesGUI.java 2007/04/03 02:34:08 1.8 @@ -218,6 +218,13 @@ public void popupMenuWillBecomeVisible(PopupMenuEvent e){ } + public boolean isSecondaryParamDialogNew(){ + if(secondaryGUI == null){ + return false; + } + return secondaryGUI.isNewShowing(); + } + /** * Launches a dialog that the user can configure secondary parameters in, * or tries to fill in and use all defaults if valid and useDefaults is specified. @@ -925,7 +932,7 @@ // Visual indicate secondary input usage in the service with an ellipsis at the end of the name JMenuItem mobyItem = new JMenuItem("Run " + service.getName() + - (hasSecondaryInput(service) ? "..." : "")); + (hasSecondaryInput(service) ? "..." : "")+(service.isAsynchronous() ? "(async)":"")); mobyItem.setActionCommand("MOBY:"+dataIndex+":"+serviceIndex+(handler == null ? "" : ":"+handler.hashCode())); mobyItem.addActionListener(this); String sdesc = "No description provided"; =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/SplashWindow.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/SplashWindow.java 2006/10/25 13:54:50 1.2 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/SplashWindow.java 2007/04/03 02:34:08 1.3 @@ -251,6 +251,7 @@ // Show the window. instance.setVisible(true); + instance.toFront(); // Note: To make sure the user gets a chance to see the // splash window we wait until its paint method has been From gordonp at dev.open-bio.org Tue Apr 3 02:37:43 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 2 Apr 2007 22:37:43 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704030237.l332bh6A007091@dev.open-bio.org> gordonp Mon Apr 2 22:37:43 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources In directory dev.open-bio.org:/tmp/cvs-serv7056/src/main/ca/ucalgary/seahawk/resources Modified Files: mobyBuilderRules.xml Log Message: Added PMID and DOI parsing rules moby-live/Java/src/main/ca/ucalgary/seahawk/resources mobyBuilderRules.xml,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/mobyBuilderRules.xml,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/mobyBuilderRules.xml 2006/12/14 19:38:34 1.2 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/mobyBuilderRules.xml 2007/04/03 02:37:43 1.3 @@ -4,6 +4,39 @@ http://www.bioxml.info/dtd/tigrxml.dtd http://www.bioxml.info/dtd/Bioseq.dtd + + + (?:GI|gi)[|:](\d+) + substring-before(substring-after(self::tigr:TU//tigr:ACCESSION/@DBXREF, 'gi|'), '|') + + $1 + + + + + + (?:PMID|pmid):?\s*(\d{5,}) + + $1 + + + + + + (?:DOI|doi):?\s*(10\.\d+/[^%"\# \t\r\n]+) + + $1 + + + + + + (?:\s|\A|/)(10\.\d+/[A-Za-z]+[^%"\# \t\r\n]+) + + $1 + + + \s*(LOCUS\s+(\S+)(?:.*|\n)+?\n//(?:\n|$)) @@ -28,15 +61,6 @@ - - - (?:GI|gi)[|:](\d+) - substring-before(substring-after(self::tigr:TU//tigr:ACCESSION/@DBXREF, 'gi|'), '|') - - $1 - - - From gordonp at dev.open-bio.org Tue Apr 3 02:39:52 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 2 Apr 2007 22:39:52 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704030239.l332dqgd007178@dev.open-bio.org> gordonp Mon Apr 2 22:39:51 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/test In directory dev.open-bio.org:/tmp/cvs-serv7142/src/main/org/biomoby/client/test Modified Files: AsyncClientTestCase.java Added Files: TestAASeq.xml Removed Files: TestFASTACollection.xml Log Message: Updated test case service to run, and made a hard timeout too moby-live/Java/src/main/org/biomoby/client/test TestAASeq.xml,NONE,1.1 AsyncClientTestCase.java,1.1,1.2 TestFASTACollection.xml,1.1,NONE =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/test/AsyncClientTestCase.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/test/AsyncClientTestCase.java 2007/03/30 21:17:27 1.1 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/test/AsyncClientTestCase.java 2007/04/03 02:39:51 1.2 @@ -18,10 +18,11 @@ import java.util.Set; public class AsyncClientTestCase extends TestCase{ - private final static String TEST_INPUT_RESOURCE = "org/biomoby/client/test/TestFASTACollection.xml"; - private final static String TEST_SERVICE_NAME = "runClustalwFast"; - private final static String TEST_SERVICE_AUTHORITY = "inb.bsc.es"; + private final static String TEST_INPUT_RESOURCE = "org/biomoby/client/test/TestAASeq.xml"; + private final static String TEST_SERVICE_NAME = "runFunCUT"; + private final static String TEST_SERVICE_AUTHORITY = "cnio.es"; private final static int POLLING_WAITTIME_MS = 5000; // ms between checks to see if the job is done + private final static int MAX_WAITTIME_MS = 600000; // allow 10 minutes for the service to run /** * @param name Test case name. @@ -92,12 +93,17 @@ assertNotNull("Could not load the test data (" + dataURL + ")", data); for(MobyDataJob job: data.values()){ + String jobKeys = ""; + for(String key: job.keySet()){ + jobKeys += key + " "; + } + for(MobyPrimaryData input: inputs){ if(!job.containsKey(input.getName())){ System.err.println("Test Input Data: " + job); fail("The service requires an input ("+input.getName() + ") that was not provided in the test input data (" + - dataURL + ")"); + dataURL + "). The provided input: "+jobKeys); } if(!(job.get(input.getName()) instanceof MobyPrimaryData)){ System.err.println("Test Input Data: " + job); @@ -128,18 +134,28 @@ fail("Exception while sending request to service: " + e); } + long startTime = System.currentTimeMillis(); // Essentially cloning, so removing ids doesn't change the // MobyContentInstance "data" (which we will use again later on) Set queryIDs = new HashSet(data.keySet()); try { - // Should add some timeout here... while(!queryIDs.isEmpty()){ + if(System.currentTimeMillis()-startTime > MAX_WAITTIME_MS){ + destroyEPR(epr); + fail("The service ("+serviceName + + ") took longer than the maximum allowed time to execute ("+ + MAX_WAITTIME_MS+"ms)"); + } + Thread.sleep(POLLING_WAITTIME_MS); AnalysisEvent[] events = AsyncClient.poll(epr, queryIDs); for(AnalysisEvent event: events){ - if(event != null && event.isCompleted()){ - queryIDs.remove(event.getQueryId()); + if(event != null){ + System.err.println("Event: " + event); + if(event.isCompleted()){ + queryIDs.remove(event.getQueryId()); + } } } } rcsdiff: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/test/RCS/TestFASTACollection.xml,v: No such file or directory From gordonp at dev.open-bio.org Tue Apr 3 02:42:23 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 2 Apr 2007 22:42:23 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704030242.l332gN3J007221@dev.open-bio.org> gordonp Mon Apr 2 22:42:23 EDT 2007 Update of /home/repository/moby/moby-live/Java/docs In directory dev.open-bio.org:/tmp/cvs-serv7186/docs Modified Files: ChangeLog Log Message: Async client support + Seahawk UI updates noted moby-live/Java/docs ChangeLog,1.75,1.76 =================================================================== RCS file: /home/repository/moby/moby-live/Java/docs/ChangeLog,v retrieving revision 1.75 retrieving revision 1.76 diff -u -r1.75 -r1.76 --- /home/repository/moby/moby-live/Java/docs/ChangeLog 2006/11/21 13:04:15 1.75 +++ /home/repository/moby/moby-live/Java/docs/ChangeLog 2007/04/03 02:42:23 1.76 @@ -1,3 +1,9 @@ +2007-04-02 Paul Gordon + + * Added asynchronous service call support to MobyRequest, Seahawk, based on client code originally provided by Eddie Kawas. + + * UI updates to Seahawk for tab management and drag 'n' drop/paste functionality + 2006-11-21 Martin Senger * Added 'Released-Date' tag to joMby jar files From gordonp at dev.open-bio.org Wed Apr 4 01:29:20 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Tue, 3 Apr 2007 21:29:20 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704040129.l341TKVK009378@dev.open-bio.org> gordonp Tue Apr 3 21:29:20 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-serv9342/src/main/ca/ucalgary/seahawk/gui/test Modified Files: SeahawkTestCase.java Log Message: Mouse movement tweaks for more robust popup usage, check if async service also has secondary params moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test SeahawkTestCase.java,1.5,1.6 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test/SeahawkTestCase.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/test/SeahawkTestCase.java 2007/04/03 02:32:14 1.5 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test/SeahawkTestCase.java 2007/04/04 01:29:20 1.6 @@ -570,7 +570,8 @@ public void testCloseOtherTabs(){ } - public void findService(String sequenceData, String targetMenuText, String targetServiceLabelText) throws Exception{ + // returns the text label of the service menu item invoked + public String findService(String sequenceData, String targetMenuText, String targetServiceLabelText) throws Exception{ // load a dna sequence in a tab MobyDataObject mobyObject = MobyUtils.createMobySequence(sequenceData, "foo"); contentGUI.loadPaneFromObject(new MobyContentInstance(mobyObject, "hyperlink-test"), true); //true = load in new tab @@ -617,7 +618,7 @@ openPopup instanceof JPopupMenu); // Move the mouse a bit to the right to bring up the submenu - robot.mouseMove(screenPos.x+10, screenPos.y+8); + robot.mouseMove(screenPos.x+10, screenPos.y+10); // Find a submenu with services Component serviceTypeChoices = getSubComponentByName((JPopupMenu) openPopup, @@ -668,18 +669,23 @@ robot.keyRelease(KeyEvent.VK_SHIFT); //serviceChosen.doClick(300); sleep(2000); + + return servicePathChosen.elementAt(servicePathChosen.size()-1).getText(); } public void testRunAsynchronousService() throws Exception{ + String serviceLabel = null; try{ - findService(TEST_AA_SEQ, "Bioinformatics", "(async)"); + serviceLabel = findService(TEST_AA_SEQ, "Bioinformatics", "(async)"); } catch(Exception e){ e.printStackTrace(); fail("Error while finding a service ending with \"(async)\" " + "(asynchronous execution) under \"Bioinformatics\" in the popup"); } - fillInSecondariesAndExecute(); + if(serviceLabel.indexOf("...") != 0){ + fillInSecondariesAndExecute(); + } // Wait until the job is finished to proceed to the next test while(contentGUI.getCurrentURL() == null){ @@ -811,6 +817,7 @@ robot.mouseMove(screenEndPos.x, screenEndPos.y); robot.mouseRelease(InputEvent.BUTTON1_MASK); sleep(1000); + robot.mouseMove(screenEndPos.x+2, screenEndPos.y+2); robot.mousePress(InputEvent.BUTTON1_MASK); robot.mouseRelease(InputEvent.BUTTON1_MASK); sleep(2000); From gordonp at dev.open-bio.org Wed Apr 4 01:31:38 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Tue, 3 Apr 2007 21:31:38 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704040131.l341Vc0F009446@dev.open-bio.org> gordonp Tue Apr 3 21:31:38 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services In directory dev.open-bio.org:/tmp/cvs-serv9410/src/main/ca/ucalgary/seahawk/services Modified Files: MobyClient.java Log Message: Temporarily adding a call to Eddie's ValidateService applet as a substitute for isAlive metadata check (much, much faster) moby-live/Java/src/main/ca/ucalgary/seahawk/services MobyClient.java,1.8,1.9 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.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/MobyClient.java 2007/04/03 02:29:54 1.8 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java 2007/04/04 01:31:38 1.9 @@ -22,7 +22,7 @@ import javax.xml.parsers.*; -import java.io.File; +import java.io.*; import java.net.URL; import java.net.MalformedURLException; import java.util.*; @@ -60,9 +60,11 @@ public static final String ENCODING_ATTR_BASE64_VAL = "Base64"; public static final String ENCODING_ATTR_NONE_VAL = "none"; public static final String SINGLE_RETURNED_VALUE_KEY = "_no_acd_param_should_have_this_name"; + public static final String IS_ALIVE_SERVICE_URL = "http://mobycentral.icapture.ubc.ca:8090/authority/ValidateService"; private NamespaceContextImpl nsContext; private CentralImpl c; + private Map isDeadMap; private HashMap xpathMap; private HashMap urlRegexMap; private Map regexMap; @@ -905,9 +907,10 @@ // Paul: commenting out is temporary until we can fetch the services more quickly //MobyService service = MobyService.getService(mService[j].getName(), mService[j].getAuthority()); //if(service != null){ - //mService[j] = service; + // mService[j] = service; //} + mService[j].setStatus(MobyService.ALIVE, isServiceAlive(mService[j])); mService[j].setServiceType(MobyServiceType.getServiceType(mService[j].getServiceType().getName())); if(serviceLevel != MobyService.UNCHECKED){ int serviceStatus = mService[j].getStatus(); @@ -919,7 +922,7 @@ } // Paul: false is temporary until we can fetch the services more quickly (and check isAlive) - if(false && serviceLevel != MobyService.UNCHECKED){ + if(serviceLevel != MobyService.UNCHECKED){ mService = (MobyService []) filteredServices.toArray(new MobyService[filteredServices.size()]); } @@ -1160,5 +1163,55 @@ } return false; } + + /** + * @return true unless we can contact ValidateService, and it tells us the service is dead + */ + private boolean isServiceAlive(MobyService service){ + // first time method is called + if(isDeadMap == null){ + isDeadMap = new HashMap(); // keys are authority:serviceName + try{ + URL u = new URL(IS_ALIVE_SERVICE_URL); + LineNumberReader reader = new LineNumberReader(new InputStreamReader(u.openStream())); + String currentAuthority = null; + for(String line = reader.readLine(); + line != null; + line = reader.readLine()){ + // authority declarations look like " host.domain.tld" + if(line.indexOf(" ") == 0){ + currentAuthority = line.trim(); + } + else if(line.indexOf("\t") == 0){ + String[] fields = line.trim().split(","); + if(fields.length != 2){ + System.err.println("Unrecognized line (not 2 comma delimited fields) " + + "from ValidateService: " + line.trim()); + } + else if(fields[1].equals("true")){ + // service is okay, don't add to dead map + } + else if(fields[1].equals("false")){ + isDeadMap.put(currentAuthority+":"+fields[0], "dead"); + } + else{ + System.err.println("Unrecognized line (second field not 'true' or 'false') " + + "from ValidateService: " + line.trim()); + } + } + } + + } catch(Exception e){ + e.printStackTrace(); + // will not attempt to retrieve map again, as it's not null anymore + return true; + } + } + + if(isDeadMap.containsKey(service.getAuthority()+":"+service.getName())){ + return false; // dead for sure + } + return true; // be optimistic by default, assume it's alive + } } From senger at dev.open-bio.org Thu Apr 5 14:24:58 2007 From: senger at dev.open-bio.org (Martin Senger) Date: Thu, 5 Apr 2007 10:24:58 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704051424.l35EOw1F015561@dev.open-bio.org> senger Thu Apr 5 10:24:57 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard In directory dev.open-bio.org:/tmp/cvs-serv15542 Modified Files: ServiceCallerModel.java Log Message: moby-live/Java/src/main/org/biomoby/service/dashboard ServiceCallerModel.java,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/ServiceCallerModel.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/service/dashboard/ServiceCallerModel.java 2006/02/20 05:51:10 1.3 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/ServiceCallerModel.java 2007/04/05 14:24:57 1.4 @@ -134,7 +134,7 @@ MobyService selService = (MobyService)propertyChannel.get (DP_SC_SERVICE); if (selService == null) throw new MobyException ("No service given."); - MobyService clonedService = new MobyService (selService.getName()); + MobyService clonedService = new MobyService (selService.getName(), selService.getAuthority()); clonedService.setURL (selService.getURL()); setService (clonedService); From gordonp at dev.open-bio.org Sun Apr 8 17:26:25 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Sun, 8 Apr 2007 13:26:25 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704081726.l38HQPRY021059@dev.open-bio.org> gordonp Sun Apr 8 13:26:25 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services In directory dev.open-bio.org:/tmp/cvs-serv21020/src/main/ca/ucalgary/seahawk/services Modified Files: MobyClient.java MobyComplexBuilder.java Log Message: Refactored rule evaluation code for reuse, and added support for assigning an article name to created objects moby-live/Java/src/main/ca/ucalgary/seahawk/services MobyClient.java,1.9,1.10 MobyComplexBuilder.java,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.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/MobyClient.java 2007/04/04 01:31:38 1.9 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java 2007/04/08 17:26:24 1.10 @@ -41,6 +41,7 @@ public static final String RULE_SET_TAG = "object"; public static final String PREFIX_TAG = "prefix"; public static final String PREFIX_ATTR = "value"; + public static final String ARTICLENAME_RULE_TAG = "articlename"; public static final String NAMESPACE_RULE_TAG = "namespace"; public static final String NAMESPACE_VALUE_TAG = "ns"; public static final String NAMESPACE_VALUE_ATTR = "value"; @@ -195,9 +196,10 @@ Vector regexStrings = new Vector(); Vector urlRegexStrings = new Vector(); Vector xpathStrings = new Vector(); - Map namespaceMap = new HashMap(); - Map memberMap = new HashMap(); + Map namespaceMap = new HashMap(); + Map memberMap = new HashMap(); String dataTypeString = null; + String articleNameString = null; NodeList ruleMembers = ruleSet.getChildNodes(); for(int j = 0; j < ruleMembers.getLength(); j++){ @@ -221,6 +223,15 @@ else if(isNamespaceRule(ruleMember)){ addNamespaceMapping(ruleMember, namespaceMap); } + else if(isArticleNameRule(ruleMember)){ + if(articleNameString != null && articleNameString.length() != 0){ + System.err.println("Skipping unexpected article name definition node, " + + "a valid article name rule has already been " + + "created for this ruleset"); + continue; + } + articleNameString = ruleMember.getTextContent(); + } else if(isDataTypeRule(ruleMember)){ if(dataTypeString != null && dataTypeString.length() != 0){ System.err.println("Skipping unexpected datatype definition node, " + @@ -257,13 +268,13 @@ } for(int j = 0; j < xpathStrings.size(); j++){ - addXPathMapping((String) xpathStrings.elementAt(j), namespaceMap); + addXPathMapping((String) xpathStrings.elementAt(j), namespaceMap, articleNameString); } for(int j = 0; j < regexStrings.size(); j++){ - addRegexMapping((String) regexStrings.elementAt(j), namespaceMap); + addRegexMapping((String) regexStrings.elementAt(j), namespaceMap, articleNameString); } for(int j = 0; j < urlRegexStrings.size(); j++){ - addURLRegexMapping((String) urlRegexStrings.elementAt(j), namespaceMap); + addURLRegexMapping((String) urlRegexStrings.elementAt(j), namespaceMap, articleNameString); } } // Build complex object @@ -274,13 +285,13 @@ } for(int j = 0; j < xpathStrings.size(); j++){ - addXPathMapping((String) xpathStrings.elementAt(j), namespaceMap, dataTypeString, memberMap); + 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); + addRegexMapping((String) regexStrings.elementAt(j), namespaceMap, dataTypeString, memberMap, articleNameString); } for(int j = 0; j < urlRegexStrings.size(); j++){ - addURLRegexMapping((String) urlRegexStrings.elementAt(j), namespaceMap, dataTypeString, memberMap); + addURLRegexMapping((String) urlRegexStrings.elementAt(j), namespaceMap, dataTypeString, memberMap, articleNameString); } } @@ -307,6 +318,10 @@ return e != null && DATATYPE_RULE_TAG.equals(e.getLocalName()); } + public boolean isArticleNameRule(Element e){ + return e != null && ARTICLENAME_RULE_TAG.equals(e.getLocalName()); + } + public boolean isMemberRule(Element e){ return e != null && MEMBER_RULE_TAG.equals(e.getLocalName()); } @@ -379,7 +394,7 @@ return str; } - protected void addMemberMapping(Element memTag, Map membersMap) throws Exception{ + protected void addMemberMapping(Element memTag, Map membersMap) throws Exception{ if(!isMemberRule(memTag)){ throw new Exception("Element provided to addMemberMapping (" + (memTag == null ? null : memTag.getLocalName()) + @@ -432,7 +447,7 @@ memberEncodingSetting}); } - protected void addNamespaceMapping(Element nsTag, Map namespaceStrings) throws Exception{ + protected void addNamespaceMapping(Element nsTag, Map namespaceStrings) throws Exception{ if(!isNamespaceRule(nsTag)){ throw new Exception("Element provided to createNamespaceMapping (" + (nsTag == null ? null : nsTag.getLocalName()) + @@ -945,20 +960,24 @@ } public void addRegexMapping(String regexp, String[] mobyObj){ //mobyObj<--mobyNamespaces + addRegexMapping(regexp, mobyObj, null); + } + + public void addRegexMapping(String regexp, String[] mobyObj, String articleName){ //mobyObj<--mobyNamespaces if(mobyObj == null){ System.err.println("Ignoring empty namespace-only regex rule mappings"); return; } - Map nsRules = new HashMap(); + Map nsRules = new HashMap(); // Default the rule to taking the whole matched expression ($0) for(int i = 0; i < mobyObj.length; i++){ nsRules.put(mobyObj[i], "$0"); } - addRegexMapping(regexp, nsRules); + addRegexMapping(regexp, nsRules, articleName); } - public void addURLRegexMapping(String url_regexp, String[] mobyObj){ //mobyObj<--mobyNamespaces + public void addURLRegexMapping(String url_regexp, String[] mobyObj, String articleName){ //mobyObj<--mobyNamespaces if(mobyObj == null){ System.err.println("Ignoring empty namespace-only url regex rule mappings"); return; @@ -969,7 +988,7 @@ for(int i = 0; i < mobyObj.length; i++){ url_nsRules.put(mobyObj[i], "$1"); } - addURLRegexMapping(url_regexp, url_nsRules); + addURLRegexMapping(url_regexp, url_nsRules, articleName); } /** @@ -999,25 +1018,30 @@ return url_regex_flexible; } - protected void addRegexMapping(String regexp, Map nsRules){ //nsRules = Map + protected void addRegexMapping(String regexp, Map nsRules, String articleName){ //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); + addRegexMapping(regexp, nsRules, (String) null, (Map) null, articleName); } - protected void addURLRegexMapping(String url_regexp, Map url_nsRules){ //nsRules = Map + protected void addURLRegexMapping(String url_regexp, Map url_nsRules, String articleName){ //nsRules = Map if(url_nsRules == null || url_nsRules.size() == 0){ System.err.println("Ignoring empty namespace-only url regex rule mappings"); return; } - addURLRegexMapping(url_regexp, url_nsRules, (String) null, (Map) null); + addURLRegexMapping(url_regexp, url_nsRules, (String) null, (Map) null, articleName); + } + + public void addRegexMapping(String regexp, Map nsRules, + String mobyDataType, Map membersMap){ + addRegexMapping(regexp, nsRules, mobyDataType, membersMap, null); } - public void addRegexMapping(String regexp, Map nsRules, String mobyDataType, Map membersMap){ //mobyObj<--mobyNamespaces + public void addRegexMapping(String regexp, Map nsRules, String mobyDataType, Map membersMap, String articleName){ try{ // Pattern.DOTALL to allow ".*" to span multiple lines, also allow comments (# to EOL) and whitespace // for better readability in the rules file. @@ -1027,14 +1051,16 @@ if(mobyDataType == null || mobyDataType.length() == 0){ regexMap.put(pattern, new MobyComplexBuilder("Object", membersMap, - nsRules)); + nsRules, + articleName)); return; } // Complex Object regexMap.put(pattern, new MobyComplexBuilder(mobyDataType, membersMap, - nsRules)); + nsRules, + articleName)); }catch(Exception e){ System.err.println("Could not create regular expression statement from '" + regexp + "': " + e); @@ -1043,7 +1069,7 @@ } public void addURLRegexMapping(String url_regexp, Map url_nsRules, - String mobyDataType, Map membersMap){ //mobyObj<--mobyNamespaces + String mobyDataType, Map membersMap, String articleName){ //mobyObj<--mobyNamespaces //System.out.println("url regex addMapping: " + url_regexp); try{ Pattern pattern = Pattern.compile(processURLRegExp(url_regexp)); @@ -1052,14 +1078,16 @@ if(mobyDataType == null || mobyDataType.length() == 0){ urlRegexMap.put(pattern, new MobyComplexBuilder("Object", membersMap, - url_nsRules)); + url_nsRules, + articleName)); return; } // Complex Object urlRegexMap.put(pattern, new MobyComplexBuilder(mobyDataType, membersMap, - url_nsRules)); + url_nsRules, + articleName)); }catch(Exception e){ System.err.println("Could not create URL regular expression statement from '" + url_regexp + "': " + e); @@ -1078,14 +1106,15 @@ for(int i = 0; i < mobyObj.length; i++){ nsRules.put(mobyObj[i], "."); } - addXPathMapping(xpath, nsRules); + addXPathMapping(xpath, nsRules, null); } - public void addXPathMapping(String xpath_exp, Map nsRules){ //mobyObj<--mobyNamespaces - addXPathMapping(xpath_exp, nsRules, (String) null, (Map) null); + public void addXPathMapping(String xpath_exp, Map nsRules, String articleName){ //mobyObj<--mobyNamespaces + addXPathMapping(xpath_exp, nsRules, (String) null, (Map) null, articleName); } - public void addXPathMapping(String xpath_exp, Map nsRules, String mobyDataType, Map membersMap){ //mobyObj<--mobyNamespaces + public void addXPathMapping(String xpath_exp, Map nsRules, String mobyDataType, + Map membersMap, String articleName){ //mobyObj<--mobyNamespaces //System.out.println("xpath addMapping: " + xpath_exp); try{ XPath xpath = new XPath(xpath_exp, @@ -1097,14 +1126,16 @@ if(mobyDataType == null || mobyDataType.length() == 0){ xpathMap.put(xpath, new MobyComplexBuilder("Object", membersMap, - nsRules)); + nsRules, + articleName)); return; } // Complex Object xpathMap.put(xpath, new MobyComplexBuilder(mobyDataType, membersMap, - nsRules)); + nsRules, + articleName)); }catch(Exception e){ logger.warn("Could not create XPath select statement from '" + =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyComplexBuilder.java,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/services/MobyComplexBuilder.java 2007/04/03 02:30:36 1.4 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyComplexBuilder.java 2007/04/08 17:26:24 1.5 @@ -19,12 +19,13 @@ */ public class MobyComplexBuilder{ - + public static final String ANON_ARTICLE = "_seahawk_data"; private static XPathFactory xPathFactory; private static DocumentBuilder docBuilder; - private Map namespaceRules; - private Map memberRules; + private Map namespaceRules; // ns, template + private Map memberRules; // member name, [template, whitespace rule, encoding rule] + private String articleNameRule; private MobyDataType mobyDataType; private MobyNamespace[] mobyNS; private MobyRelationship[] children; @@ -40,13 +41,18 @@ } } - public MobyComplexBuilder(String dataType, Map members, Map nameSpaces) throws Exception{ + public MobyComplexBuilder(String dataType, Map members, Map nameSpaces) throws Exception{ + this(dataType, members, nameSpaces, ANON_ARTICLE); + } + + public MobyComplexBuilder(String dataType, Map members, Map nameSpaces, String articleName) throws Exception{ mobyDataType = MobyDataType.getDataType(dataType); // Not an existing Ontology data type if(mobyDataType == null){ mobyDataType = new MobyDataType(dataType); } + articleNameRule = articleName; memberRules = members; if(mobyDataType != null && mobyDataType.getName() != null && @@ -115,15 +121,26 @@ mobyObj = new MobyDataComposite(mobyDataType); } + // Set article name, if available + if(articleNameRule != null && articleNameRule.length() > 0){ + mobyObj.setName(evaluateRule(matcher, + articleNameRule, + MobyClient.WHITESPACE_ATTR_STRIP_FLANKING_VAL, + null, + data)); + } + // Set namespaces if available if(namespaceRules != null && namespaceRules.size() > 0){ boolean haveID = false; for(int i = 0; mobyNS != null && i < mobyNS.length; i++){ - String result = (String) namespaceRules.get(mobyNS[i].getName()); - // Replace any $0, $1, etc. in the replacement string with the values found in the matcher - for(int j = 0; j <= matcher.groupCount(); j++){ - result = result.replaceAll("\\$"+j, matcher.group(j)); - } + String resultSpec = namespaceRules.get(mobyNS[i].getName()); + String result = evaluateRule(matcher, + resultSpec, + MobyClient.WHITESPACE_ATTR_STRIP_FLANKING_VAL, + null, + data); + // A non-blank value was the result of the evaluation if(result.length() > 0){ if(!haveID){ @@ -141,19 +158,14 @@ } } - Document doc = docBuilder.newDocument(); // 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 = (String[]) memberRules.get(memberName); + String[] resultSpec = memberRules.get(memberName); + MobyRelationship memberRelationship = mobyDataType.getChild(memberName); - String result = resultSpec[0]; - byte[] resultBytes = result.getBytes(); - String whitespaceMode = resultSpec[1]; - String encodingMode = resultSpec[2]; - // 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... @@ -161,88 +173,109 @@ } // else is iHASA, scalar context - - boolean nonBasic = result.length() != 2 || result.indexOf("$") != 0; - MobyPrefixResolver.MobyNodeList nodeList = new MobyPrefixResolver.MobyNodeList(); - // Replace any $0, $1, etc. in the replacement string with the values found in the matcher - // 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++){ - // A replaceAll() for binary data - if(data != null){ - (new Exception("Binary replaceAll()")).printStackTrace(); - 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)+1; - - byte[] newResultBytes = new byte[resultBytes.length+varValueLength]; - if(varIndex > 0){ - System.arraycopy(resultBytes, 0, newResultBytes, 0, varIndex); - } - System.arraycopy(data, matcher.start(j), newResultBytes, varIndex, varValueLength); - int remaining = result.length()-varIndex-2; - if(remaining > 0){ - System.arraycopy(resultBytes, varIndex+2, newResultBytes, varIndex+varValueLength, - result.length()-varIndex-2); - } - srcPos += varIndex + varValueLength + 1; - resultBytes = newResultBytes; - } - } - // $# substitution in a string, considerably simpler! - else{ - String varValue = matcher.group(j); - if(whitespaceMode.equals(MobyClient.WHITESPACE_ATTR_NORMALIZE_VAL)){ - varValue = varValue.replaceAll("\\s+"," "); - } - else if(whitespaceMode.equals(MobyClient.WHITESPACE_ATTR_STRIP_VAL)){ - varValue = varValue.replaceAll("\\s+",""); - } - else if(whitespaceMode.equals(MobyClient.WHITESPACE_ATTR_STRIP_FLANKING_VAL)){ - varValue = varValue.trim(); // removes leading and trailing whitespace - } - result = result.replaceAll("\\$"+j, 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 - nodeList.add(doc.createTextNode(result)); - } - } - - if(encodingMode.equals(MobyClient.ENCODING_ATTR_BASE64_VAL)){ - //(new Exception("Base 64 encoding")).printStackTrace(); - result = org.apache.axis.encoding.Base64.encode(data == null ? result.getBytes() : resultBytes); - } else{ - //System.err.println("NO BASE64 (" + MobyClient.ENCODING_ATTR_BASE64_VAL + - // ") ENCODING for " +memberName+": " + encodingMode); - } + String result = evaluateRule(matcher, resultSpec[0], resultSpec[1], resultSpec[2], data); - // If the value contains anything other than $#, treat it as a XPath expression - // to be evaluated on a text node containing the result value - if(nonBasic && data == null){ - XPath xpath = xPathFactory.newXPath(); - try{ - result = xpath.evaluate(result, nodeList); - }catch(Exception e){ - e.printStackTrace(); - throw new MobyException("Could not evaluate result of XPath expression for object member " + - memberName + " (" + result + "): " + e); - } + ((MobyDataComposite) mobyObj).put(memberName, + MobyDataObject.createInstanceFromString(children[i].getDataTypeName(), result)); } - - ((MobyDataComposite) mobyObj).put(memberName, - MobyDataObject.createInstanceFromString(children[i].getDataTypeName(), result)); } } } - return mobyObj; } + // takes a rule and evaluates $# variables and XPath expressions + private String evaluateRule(Matcher matcher, String result, String whitespaceMode, String encodingMode, byte[] data) + throws MobyException{ + byte[] resultBytes = result.getBytes(); + boolean nonBasic = result.length() != 2 || result.indexOf("$") != 0; + + MobyPrefixResolver.MobyNodeList nodeList = new MobyPrefixResolver.MobyNodeList(); + + Document doc = null; + // Only get a DOM instance (for text node creation) if we're going to evaluate an XPath in the end + if(nonBasic){ + doc = docBuilder.newDocument(); + } + + // Replace any $0, $1, etc. in the replacement string with the values found in the matcher + // 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++){ + // A replaceAll() for binary data + if(data != null){ + (new Exception("Binary replaceAll()")).printStackTrace(); + 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)+1; + + byte[] newResultBytes = new byte[resultBytes.length+varValueLength]; + if(varIndex > 0){ + System.arraycopy(resultBytes, 0, newResultBytes, 0, varIndex); + } + System.arraycopy(data, matcher.start(j), newResultBytes, varIndex, varValueLength); + int remaining = result.length()-varIndex-2; + if(remaining > 0){ + System.arraycopy(resultBytes, varIndex+2, newResultBytes, varIndex+varValueLength, + result.length()-varIndex-2); + } + srcPos += varIndex + varValueLength + 1; + resultBytes = newResultBytes; + } + } + // $# substitution in a string, considerably simpler! + else{ + String varValue = matcher.group(j); + if(whitespaceMode == null){ + // do nothing + } + else if(whitespaceMode.equals(MobyClient.WHITESPACE_ATTR_NORMALIZE_VAL)){ + varValue = varValue.replaceAll("\\s+"," "); + } + else if(whitespaceMode.equals(MobyClient.WHITESPACE_ATTR_STRIP_VAL)){ + varValue = varValue.replaceAll("\\s+",""); + } + else if(whitespaceMode.equals(MobyClient.WHITESPACE_ATTR_STRIP_FLANKING_VAL)){ + varValue = varValue.trim(); // removes leading and trailing whitespace + } + result = result.replaceAll("\\$"+j, 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 + if(nonBasic){ + nodeList.add(doc.createTextNode(result)); + } + } + } + + if(encodingMode != null && encodingMode.equals(MobyClient.ENCODING_ATTR_BASE64_VAL)){ + //(new Exception("Base 64 encoding")).printStackTrace(); + result = org.apache.axis.encoding.Base64.encode(data == null ? result.getBytes() : resultBytes); + } + else{ + //System.err.println("NO BASE64 (" + MobyClient.ENCODING_ATTR_BASE64_VAL + + // ") ENCODING for " +memberName+": " + encodingMode); + } + + // If the value contains anything other than $#, treat it as a XPath expression + // to be evaluated on a text node containing the result value + if(nonBasic && data == null){ + XPath xpath = xPathFactory.newXPath(); + try{ + result = xpath.evaluate(result, nodeList); + }catch(Exception e){ + e.printStackTrace(); + throw new MobyException("Could not evaluate result of XPath expression " + + "('" + result + "'): " + e); + } + } + return result; + } + public MobyDataObject applyXPath(Object result, NamespaceContext nsContext) throws MobyException, XPathExpressionException{ XPath xpath = xPathFactory.newXPath(); xpath.setNamespaceContext(nsContext); @@ -260,7 +293,7 @@ if(namespaceRules != null && namespaceRules.size() > 0){ boolean haveID = false; for(int i = 0; mobyNS != null && i < mobyNS.length; i++){ - String expr = (String) namespaceRules.get(mobyNS[i].getName()); + String expr = namespaceRules.get(mobyNS[i].getName()); String value = xpath.evaluate(expr, result); // A non-blank value was the result of the evaluation @@ -285,7 +318,7 @@ if(children != null){ for(int i = 0; i < children.length; i++){ String memberName = children[i].getName(); - String expr = ((String[]) memberRules.get(memberName))[0]; + String expr = memberRules.get(memberName)[0]; String value = xpath.evaluate(expr, result); ((MobyDataComposite) mobyObj).put(memberName, From gordonp at dev.open-bio.org Sun Apr 8 17:29:29 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Sun, 8 Apr 2007 13:29:29 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704081729.l38HTTec021123@dev.open-bio.org> gordonp Sun Apr 8 13:29:29 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data In directory dev.open-bio.org:/tmp/cvs-serv21088/src/main/org/biomoby/shared/data Modified Files: MobyDataComposite.java Log Message: Made member data type enforcement more consistent, now you can't manually add field of the wrong type either (with the put() method) moby-live/Java/src/main/org/biomoby/shared/data MobyDataComposite.java,1.12,1.13 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataComposite.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataComposite.java 2007/03/12 17:02:30 1.12 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataComposite.java 2007/04/08 17:29:29 1.13 @@ -54,12 +54,16 @@ // will be a problem for member association (i.e. it's an anonymous variable) String fieldName = getName(child); if(fieldName == null || fieldName.length() == 0){ - throw new IllegalArgumentException("The subelement with index " + i + - " does not have an article " + - "name, which is required"); + throw new MobyException("The subelement with index " + i + + " does not have an article " + + "name, which is required"); } - - put(fieldName, (MobyDataObject) createInstanceFromDOM(child)); + MobyDataObject childObject = (MobyDataObject) createInstanceFromDOM(child); + if(childObject == null){ + throw new MobyException("The object member '" + fieldName + "' for object '"+ getName() + + " could not be properly parsed into a MOBY object"); + } + put(fieldName, childObject); } } } @@ -251,8 +255,7 @@ // Print out the sorted fields' XML for(int i = 0; i < fieldNames.length; i++){ - //MobyDataObject mdsi = members.get(fieldNames[i]); //Java1.5 - MobyDataObject mdsi = (MobyDataObject) members.get(fieldNames[i]); + MobyDataObject mdsi = members.get(fieldNames[i]); // ensure the articleName is set correctly for the requirements of this object if(!fieldNames[i].toString().equals(mdsi.getName())){ mdsi.setName(fieldNames[i].toString()); @@ -378,11 +381,28 @@ * e.g. creating a GenericSequence involves putting a 'length' member (MobyDataInt), * then putting a 'sequence' member (MobyDataString). * + * This method will throw an IllegalArgumentException if the value does not inherit from the type defined by Moby Central + * * NOTE: if the field already exists and is defined with the HAS relationship in the DataType ontology, * the previous value is NOT overwritten, rather the MobyDataObject is switched into a MobyDataObjectVector. * Replace mode will be used unless the data type and relationship are properly defined. */ public MobyDataObject put(String fieldName, MobyDataObject value){ + if(value == null){ + return null; + } + + MobyRelationship relationship = getDataType().getChild(fieldName); + MobyDataType childDataType = MobyDataType.getDataType(relationship.getDataTypeName()); + if(!value.getDataType().inheritsFrom(childDataType)){ + // Incompatible types + throw new IllegalArgumentException("The object member '" + fieldName + "' for object '"+ getName() + + "' does not inherit from the required data type " + + "(found data type " + value.getDataType().getName()+ + ", but require subclass of " + + childDataType.getName() +")"); + } + // If the field already exists, see if the HAS (1-to-many) relationship exists if(members.containsKey(fieldName)){ MobyDataObject existingMember = members.get(fieldName); @@ -393,12 +413,11 @@ return existingMember; } - // Use replace mode if the data type or relatioship is unavailable + // Use replace mode if the data type or relationship is unavailable MobyDataType dt = getDataType(); if(dt == null){ return members.put(fieldName, value); } - MobyRelationship relationship = getDataType().getChild(fieldName); if(relationship == null){ return members.put(fieldName, value); } From gordonp at dev.open-bio.org Thu Apr 12 00:40:23 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 11 Apr 2007 20:40:23 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704120040.l3C0eN4W030342@dev.open-bio.org> gordonp Wed Apr 11 20:40:23 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/test In directory dev.open-bio.org:/tmp/cvs-serv30306/src/main/org/biomoby/service/test Modified Files: TestServletContext.java Log Message: Minor change to conform to j2EE spec, empty enumeration for parameter names rather than null moby-live/Java/src/main/org/biomoby/service/test TestServletContext.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/test/TestServletContext.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/service/test/TestServletContext.java 2006/12/06 16:07:10 1.1 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/test/TestServletContext.java 2007/04/12 00:40:22 1.2 @@ -30,7 +30,7 @@ public java.util.Enumeration getAttributeNames(){return null;} public ServletContext getContext(String uripath){return null;} public String getInitParameter(String name){return null;} - public java.util.Enumeration getInitParameterNames(){return null;} + public java.util.Enumeration getInitParameterNames(){return (new Vector()).elements();} public int getMajorVersion(){return 0;} public String getMimeType(String file){return null;} public int getMinorVersion(){return 0;} From gordonp at dev.open-bio.org Thu Apr 12 00:51:45 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 11 Apr 2007 20:51:45 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704120051.l3C0pj3w030408@dev.open-bio.org> gordonp Wed Apr 11 20:51:45 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/service In directory dev.open-bio.org:/tmp/cvs-serv30372/src/main/org/biomoby/service Modified Files: MobyServlet.java Log Message: Made servlet parameter fethcing more robust by always checking servlet config AND context for a non-null value moby-live/Java/src/main/org/biomoby/service MobyServlet.java,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/MobyServlet.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/service/MobyServlet.java 2007/03/12 16:57:30 1.6 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/MobyServlet.java 2007/04/12 00:51:45 1.7 @@ -625,8 +625,8 @@ MobyDataType.getDataType("Object"); // Not sure we actually need MobyRequest yet... - if(getInitParameter(MOBY_CENTRAL_URL_PARAM) != null){ - mobyRequest = new MobyRequest(new CentralCachedCallsImpl(getInitParameter(MOBY_CENTRAL_URL_PARAM))); + if(getCoCInitParameter(MOBY_CENTRAL_URL_PARAM) != null){ + mobyRequest = new MobyRequest(new CentralCachedCallsImpl(getCoCInitParameter(MOBY_CENTRAL_URL_PARAM))); } else{ mobyRequest = new MobyRequest(new CentralCachedCallsImpl()); @@ -640,6 +640,22 @@ isInitialized = true; } + protected String getCoCInitParameter(String paramName){ + javax.servlet.ServletConfig config = getServletConfig(); + if(config != null){ + if(config.getInitParameter(paramName) != null){ + return config.getInitParameter(paramName); + } + } + javax.servlet.ServletContext context = getServletContext(); + if(context != null){ + if(context.getInitParameter(paramName) != null){ + return context.getInitParameter(paramName); + } + } + return getInitParameter(paramName); + } + public synchronized MobyService createServiceFromConfig(HttpServletRequest request) throws Exception{ MobyService service = new MobyService(getServiceName()); @@ -671,8 +687,8 @@ // Inputs and outputs and service type must be defined String[] ins = ann.in(); - if(config != null && config.getInitParameter(MOBY_INPUT_PARAM) != null){ - ins = config.getInitParameter(MOBY_INPUT_PARAM).split(","); + if(getCoCInitParameter(MOBY_INPUT_PARAM) != null){ + ins = getCoCInitParameter(MOBY_INPUT_PARAM).split(","); } if(ins == null){ throw new Exception("Could not find required " + MOBY_INPUT_PARAM + @@ -684,8 +700,8 @@ } String[] outs = ann.out(); - if(config != null && config.getInitParameter(MOBY_OUTPUT_PARAM) != null){ - outs = config.getInitParameter(MOBY_OUTPUT_PARAM).split(","); + if(getCoCInitParameter(MOBY_OUTPUT_PARAM) != null){ + outs = getCoCInitParameter(MOBY_OUTPUT_PARAM).split(","); } if(outs == null){ throw new Exception("Could not find required " + MOBY_OUTPUT_PARAM + @@ -698,8 +714,8 @@ } String[] secondaries = ann.secondaryParams(); - if(config != null && config.getInitParameter(MOBY_SECONDARYINPUT_PARAM) != null){ - secondaries = config.getInitParameter(MOBY_SECONDARYINPUT_PARAM).split(","); + if(getCoCInitParameter(MOBY_SECONDARYINPUT_PARAM) != null){ + secondaries = getCoCInitParameter(MOBY_SECONDARYINPUT_PARAM).split(","); } if(secondaries != null && secondaries.length > 0){ for(String secondary: secondaries){ @@ -713,8 +729,8 @@ // A description and provider URI must be available too String param = ann.type(); // Did we override the service type in the web.xml? - if(config != null && config.getInitParameter(MOBY_SERVICETYPE_PARAM) != null){ - param = config.getInitParameter(MOBY_SERVICETYPE_PARAM); + if(getCoCInitParameter(MOBY_SERVICETYPE_PARAM) != null){ + param = getCoCInitParameter(MOBY_SERVICETYPE_PARAM); } if(param == null){ throw new Exception("Could not find required " + MOBY_SERVICETYPE_PARAM + @@ -733,9 +749,9 @@ String[] desc = ann.description(); // Did we override the service type in the web.xml? - if(config != null && config.getInitParameter(MOBY_SERVICETYPE_PARAM) != null){ + if(getCoCInitParameter(MOBY_SERVICETYPE_PARAM) != null){ desc = new String[1]; - desc[0] = config.getInitParameter(MOBY_SERVICETYPE_PARAM); + desc[0] = getCoCInitParameter(MOBY_SERVICETYPE_PARAM); } if(desc == null){ throw new Exception("Could not find required " + MOBY_SERVICE_DESC_PARAM + @@ -753,8 +769,8 @@ param = ann.provider(); // Did we override the provider info in web.xml? - if(config != null && config.getInitParameter(MOBY_PROVIDER_URI_PARAM) != null){ - param = config.getInitParameter(MOBY_PROVIDER_URI_PARAM); + if(getCoCInitParameter(MOBY_PROVIDER_URI_PARAM) != null){ + param = getCoCInitParameter(MOBY_PROVIDER_URI_PARAM); } if(param == null){ throw new Exception("Could not find required " + MOBY_PROVIDER_URI_PARAM + @@ -774,8 +790,8 @@ param = ann.author(); // Did we override the contact info in web.xml? - if(config != null && config.getInitParameter(MOBY_CONTACT_PARAM) != null){ - param = config.getInitParameter(MOBY_CONTACT_PARAM); + if(getCoCInitParameter(MOBY_CONTACT_PARAM) != null){ + param = getCoCInitParameter(MOBY_CONTACT_PARAM); } if(param == null){ throw new Exception("Could not find required " + MOBY_CONTACT_PARAM + @@ -803,7 +819,7 @@ service.setSignatureURL(endPointURL+"?"+MODE_HTTP_PARAM+"="+RDF_MODE); // Other fields (authoritative and contact info) are highly recommended, but optional if(config != null){ - param = config.getInitParameter(MOBY_AUTHORITATIVE_PARAM); + param = getCoCInitParameter(MOBY_AUTHORITATIVE_PARAM); if(param != null){ if("YES".equals(param.toUpperCase()) || "Y".equals(param.toUpperCase()) || "1".equals(param)){ service.setAuthoritative(true); @@ -833,11 +849,10 @@ mobyService ann = this.getClass().getAnnotation(mobyService.class); - javax.servlet.ServletConfig config = getServletConfig(); String param = null; // Did we override the service type in the web.xml? - if(config != null && config.getInitParameter(MOBY_SERVICENAME_PARAM) != null){ - param = config.getInitParameter(MOBY_SERVICENAME_PARAM); + if(getCoCInitParameter(MOBY_SERVICENAME_PARAM) != null){ + param = getCoCInitParameter(MOBY_SERVICENAME_PARAM); if(param != null && param.length() != 0){ return param; } From gordonp at dev.open-bio.org Thu Apr 12 00:53:31 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 11 Apr 2007 20:53:31 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704120053.l3C0rV11030452@dev.open-bio.org> gordonp Wed Apr 11 20:53:31 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/test In directory dev.open-bio.org:/tmp/cvs-serv30416/src/main/org/biomoby/service/test Modified Files: ServletTester.java Log Message: Added ability to load sample data as resource, specify alternative web.xml location, and stricter on testing URL to avoid localhost references moby-live/Java/src/main/org/biomoby/service/test ServletTester.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/test/ServletTester.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/service/test/ServletTester.java 2007/03/12 16:57:30 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/test/ServletTester.java 2007/04/12 00:53:31 1.3 @@ -21,6 +21,23 @@ import java.io.*; public class ServletTester{ + private String alternateWebXML; + + /** + * Runs a test on the service described in WEB-INF/web.xml + */ + public ServletTester(){ + this(null); + } + + /** + * Mainly for JUnit tests, specify a web.xml file to be used for configuring the test run, + * rather than using the default WEB-INF/web.xml in the class path. + */ + public ServletTester(String altWebXML){ + alternateWebXML = altWebXML; + } + public static void main(String[] args) throws Exception{ if(args.length != 2 && args.length != 3 || @@ -29,19 +46,23 @@ " "); throw new Exception("Incorrect command arguments"); } - if(args[0].indexOf("http://localhost") == 0){ + if(args[0].indexOf("http://localhost") == 0 || args[0].indexOf("http://127.0.0.1/") == 0){ System.err.println("The servlet URL must be fully qualified " + - "(\"localhost\" is not acceptable)"); + "(\"localhost\" or \"127.0.0.1\" are not acceptable)"); throw new Exception("Servlet URL not fully qualified"); } ServletTester tester = new ServletTester(); + tester.runService(args); + } + public void runService(String[] args) throws Exception{ // Open the web.xml file to determine the service name and inputs/outputs. - java.net.URL webXmlURL = tester.getClass().getClassLoader().getResource("WEB-INF/web.xml"); + String webXMLPath = alternateWebXML != null ? alternateWebXML : "WEB-INF/web.xml"; + java.net.URL webXmlURL = getClass().getClassLoader().getResource(webXMLPath); if(webXmlURL == null){ - System.err.println("Could not find \"WEB-INF/web.xml\", aborting!"); - throw new Exception("No WEB-INF/web.xml in the code archive"); + System.err.println("Could not find \""+webXMLPath+"\", aborting!"); + throw new Exception("No \""+ webXMLPath+"\" in the resource path"); } String centralURL = null; @@ -108,12 +129,29 @@ try{ dataIn = (new URL(args[1])).openStream(); } catch(Exception e){ - e.printStackTrace(); + //e.printStackTrace(); } } + // Last ditch, try as a resource if(dataIn == null){ - System.err.println("Could not read example data file \"" + args[1] + "\", aborting!"); - throw new Exception("Example data file was unreadable: " + args[1]); + ClassLoader cl = getClass().getClassLoader(); + if(cl == null){ + cl = ClassLoader.getSystemClassLoader(); + } + System.err.println("Trying to load as resource with " + cl); + URL resourceURL = null; + if(cl != null){ + resourceURL = cl.getResource(args[1]); + } + if(resourceURL == null){ + System.err.println("Could not find the example data named \"" + args[1] + "\", aborting!"); + throw new Exception("Example data was not found: " + args[1]); + } + try{ + dataIn = resourceURL.openStream(); + } catch(Exception e){ + e.printStackTrace(); + } } // Create the data and service instances. From gordonp at dev.open-bio.org Thu Apr 12 00:54:16 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 11 Apr 2007 20:54:16 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704120054.l3C0sGEw030496@dev.open-bio.org> gordonp Wed Apr 11 20:54:16 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/test In directory dev.open-bio.org:/tmp/cvs-serv30460/src/main/org/biomoby/service/test Modified Files: MobyServletTestCase.java Log Message: Several changes to improve extensibility of tests by subclasses moby-live/Java/src/main/org/biomoby/service/test MobyServletTestCase.java,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/test/MobyServletTestCase.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/service/test/MobyServletTestCase.java 2007/03/12 16:57:30 1.3 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/test/MobyServletTestCase.java 2007/04/12 00:54:16 1.4 @@ -21,8 +21,10 @@ public class MobyServletTestCase extends TestCase{ private final static String TEST_MOBY_XML = "org/biomoby/service/test/mobyAASeq.xml"; + private final static String SERVLET_TEST_WEBXML = "org/biomoby/service/test/web.xml"; private final static String SERVLET_TEST_URL = "http://moby.ucalgary.ca:8089/MobyServlet"; private final static String TEST_MAIN_CLASS_NAME = "org.biomoby.service.test.ConvertAAtoFASTA_AA"; + /** * @param name Test case name. */ @@ -94,11 +96,35 @@ } public void testRDF(){ - TestServletConfig config = new TestServletConfig("ConvertAAtoFASTA_AA", new TestServletContext()); - //config.addInitParameter(); - MobyServlet servlet = new ConvertAAtoFASTA_AA(); + String webXMLPath = "WEB-INF/web.xml"; + java.net.URL webXmlURL = getClass().getClassLoader().getResource(webXMLPath); + assertNotNull("No \""+ webXMLPath+"\" in the resource path", webXmlURL); + TestServletConfig servletConfig = null; try{ - servlet.init(config); + servletConfig = new TestServletConfig(new TestServletContext(), webXmlURL); + } catch(Exception e){ + e.printStackTrace(); + fail("Could not create servlet configuration from " + webXmlURL + ": " + e); + } + + MobyServlet servlet = null; + try{ + // This line can throw many different exception if you didn't get the class right! + Class servletClass = MobyServlet.class.getClassLoader().loadClass(servletConfig.getServletClassName()); + if(servletClass == null){ + throw new ClassNotFoundException("The servlet Class to run (" + + servletConfig.getServletClassName() + + ") was not found, please ensure the web.xml is up-to-date."); + } + servlet = (MobyServlet) servletClass.newInstance(); + } catch(Exception e){ + e.printStackTrace(); + fail("The servlet Class was not specified properly in " + webXmlURL + + " (the servlet-class tag was not useable): " + e); + } + + try{ + servlet.init(servletConfig); } catch(Exception e){ e.printStackTrace(); @@ -106,9 +132,8 @@ } TestHttpServletRequest request = new TestHttpServletRequest(); - request.addHeader("SOAPAction", "MobyServlet"); request.setParameter(MobyServlet.MODE_HTTP_PARAM, MobyServlet.RDF_MODE); - request.setRequestURL("http://moby.ucalgary.ca:8089/ConvertAAtoFASTA_AA"); + request.setRequestURL("http://hostname.domain.tld:8089/UnImportantServiceName"); TestHttpServletResponse response = new TestHttpServletResponse(); StringBufferServletOutputStream out = new StringBufferServletOutputStream(); @@ -237,7 +262,17 @@ public void testServletTester(){ try{ - ServletTester.main(new String[]{getExampleServlet(), getExampleURL().toString()}); + // Use the specific, basic servlet test, with the defined web.xml + // because we want to be able to do this test regardless of the + // class environment we find ourselves in (i.e. a WEB-INF/web.xml + // that is for a more specialized service such as ACDService) + ServletTester tester = new ServletTester(SERVLET_TEST_WEBXML); + + // A useful side effect of an object instance is that it + // can use the classloader that loaded it to find resources + // (there is no class instance get a classloader from in static methods) + tester.runService(new String[]{SERVLET_TEST_URL, TEST_MOBY_XML}); + } catch(Exception e){ e.printStackTrace(); fail("Could not run servlet tester successfully: " + e); From gordonp at dev.open-bio.org Thu Apr 12 00:56:04 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 11 Apr 2007 20:56:04 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704120056.l3C0u4hV030602@dev.open-bio.org> gordonp Wed Apr 11 20:56:03 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/test In directory dev.open-bio.org:/tmp/cvs-serv30570/src/main/org/biomoby/service/test Added Files: web.xml Log Message: web.xml for base MobyServlet, added here so it can be loaded explicitly by the ServletTester when the normal web.xml is describing another more specialized service moby-live/Java/src/main/org/biomoby/service/test web.xml,NONE,1.1 From gordonp at dev.open-bio.org Thu Apr 12 00:57:32 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 11 Apr 2007 20:57:32 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704120057.l3C0vW7l030668@dev.open-bio.org> gordonp Wed Apr 11 20:57:32 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/test In directory dev.open-bio.org:/tmp/cvs-serv30632/src/main/ca/ucalgary/services/test Modified Files: ACDServiceTestCase.java Log Message: Now correctly tests the command-line servlet tester class moby-live/Java/src/main/ca/ucalgary/services/test ACDServiceTestCase.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/test/ACDServiceTestCase.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/services/test/ACDServiceTestCase.java 2007/03/12 14:33:38 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/test/ACDServiceTestCase.java 2007/04/12 00:57:32 1.2 @@ -9,6 +9,7 @@ import ca.ucalgary.seahawk.services.MobyClient; import org.biomoby.service.test.MobyServletTestCase; +import org.biomoby.service.test.ServletTester; import org.biomoby.shared.MobyDataType; import org.biomoby.shared.data.*; @@ -25,9 +26,6 @@ private final static String ACDTEST_BINARY_DATA2 = "ca/ucalgary/services/test/mobyTest2.png"; private final static String MOBY_PNG_DATATYPE = "b64_Encoded_PNG"; - // Sync with acdweb.xml's example EMBOSS service - //private final static String ACDSERVLET_TEST_URL = "http://moby.ucalgary.ca:8089/transeq"; - public ACDServiceTestCase(String name){ super(name); } @@ -45,10 +43,6 @@ return ACDTEST_CLASS_NAME; } -// protected String getExampleServlet(){ -// return ACDSERVLET_TEST_URL; -// } - /** * Loads a binary file, then tests it against a regex, creates a MOBY object, and * then the new object is compared to the original file data (they should be @@ -154,7 +148,7 @@ suite.addTest(new ACDServiceTestCase("testMain")); suite.addTest(new ACDServiceTestCase("testBinaryRegex")); suite.addTest(new MobyServletTestCase("testSecondaryParams")); - //suite.addTest(new MobyServletTestCase("testServletTester")); + suite.addTest(new MobyServletTestCase("testServletTester")); return suite; } From gordonp at dev.open-bio.org Thu Apr 12 00:59:42 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 11 Apr 2007 20:59:42 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704120059.l3C0xgQE030712@dev.open-bio.org> gordonp Wed Apr 11 20:59:42 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services In directory dev.open-bio.org:/tmp/cvs-serv30676/src/main/ca/ucalgary/seahawk/services Modified Files: TextClient.java Log Message: Translated spaces to hyphens in target types because XSLT doesn't allow spaces in mode names moby-live/Java/src/main/ca/ucalgary/seahawk/services TextClient.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/TextClient.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/services/TextClient.java 2007/03/12 14:30:56 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/TextClient.java 2007/04/12 00:59:42 1.2 @@ -116,6 +116,8 @@ if(textType == null){ return false; } + // Spaces are not allowed in mode names + textType = textType.replace(' ', '-'); // Search for templates matching the given type or one of its parent types, // and see if they create the given text type (indicated by the template's mode attribute) @@ -156,6 +158,8 @@ if(targetTextType == null || mobyData == null || !(mobyData instanceof MobyPrimaryData)){ return null; } + // Spaces are not allowed in mode names + targetTextType = targetTextType.replace(' ', '-'); Vector candidateTypes = new Vector(); for(MobyDataType type = ((MobyPrimaryData) mobyData).getDataType(); From gordonp at dev.open-bio.org Thu Apr 12 01:02:29 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 11 Apr 2007 21:02:29 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704120102.l3C12T3P030758@dev.open-bio.org> gordonp Wed Apr 11 21:02:29 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services In directory dev.open-bio.org:/tmp/cvs-serv30722/src/main/ca/ucalgary/services Modified Files: ACDService.java Log Message: Made servlet param fetching more robust, allow advanced parameters in ACD files to be optionally published, service name now carried from MobyServlet.getServiceName() moby-live/Java/src/main/ca/ucalgary/services ACDService.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/ACDService.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/services/ACDService.java 2007/03/12 14:32:02 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/ACDService.java 2007/04/12 01:02:29 1.2 @@ -27,6 +27,7 @@ // Used for web.xml configuration public final static String EMBOSS_ROOT_PARAM = "embossRoot"; public final static String EMBOSS_PARAMS_PARAM = "embossParams"; + public final static String EMBOSS_ADV_PARAMS_PARAM = "embossUseAdvancedParams"; public final static String EMBOSS_OUTPUT_PARAM = "embossOutput"; public final static String ACD_FILE_PARAM = "acdFile"; public final static String ACD_RULES_LOCATION_PARAM = "regexRulesLoc"; @@ -43,6 +44,7 @@ private MobyClient mobyClient; // For converting MOBY data to plain-text representation private TextClient textClient; + private MobyDataType binaryDataType; // Keep track of what MOBY input parameters are to be converted to what ACD types private Map acdTypes; @@ -111,7 +113,7 @@ MobyServiceException.INTERNAL_PROCESSING_ERROR, request.getID(), "The requested output parameter in the servlet configuration (" + - outputName + "could not be created from the program's results data, please " + + outputName + ") could not be created from the program's results data, please " + " ask the service provider to correct the output transformation rules"); } result.put(outputName, mdi); @@ -134,30 +136,48 @@ Map tempFiles = new HashMap(); // Primary input - String stdin = ""; + byte[] stdin = null; for(MobyPrimaryData mobyInputTemplate: inputs){ // Retrieve the input with the same name as the service template specifies String paramName = mobyInputTemplate.getName(); MobyDataInstance inputData = request.get(paramName); - String inputTextData = textClient.getText(inputData, acdTypes.get(mobyInputTemplate.getName())); + byte[] inputDataBytes = null; + + // Transform the moby data to text, unless it's binary data, which will be passed as decoded bytes + // Now, for binary data, we have to ignore any fields other than the Base64 encoded one. Sorry! + String tempFileSuffix = ".txt"; + if(mobyInputTemplate.getDataType().inheritsFrom(binaryDataType)){ + inputDataBytes = org.apache.axis.encoding.Base64.decode(MobyDataBytes.ENCODED_MEMBER_NAME); + tempFileSuffix = ".bin"; + } + else{ + String inputTextData = textClient.getText(inputData, acdTypes.get(mobyInputTemplate.getName())); + if(inputTextData == null){ + throw new NullPointerException("The TextClient returned null after transforming the " + + "input parameter " + mobyInputTemplate.getName() + + " to text type " + acdTypes.get(mobyInputTemplate.getName())); + } + inputDataBytes = inputTextData.getBytes(); + } // Create the required command-line flag for the parameter if(inputs.length == 1){ // If only one input, we can pass it via stdin command.add("-"+paramName); command.add("stdin"); - stdin = inputTextData; + stdin = inputDataBytes; } else{ // Otherwise we need to create temporary files to store the data - File tempFile = File.createTempFile("ACDService."+programBinaryFile.getName()+".input."+paramName, ".txt"); + File tempFile = File.createTempFile("ACDService."+programBinaryFile.getName()+".input."+paramName, + tempFileSuffix); command.add("-"+paramName); command.add(tempFile.toString()); tempFiles.put(paramName, tempFile); // Write the data to the file - FileWriter fileWriter = new FileWriter(tempFile); - fileWriter.write(inputTextData); - fileWriter.close(); + FileOutputStream fileOS = new FileOutputStream(tempFile); + fileOS.write(inputDataBytes); + fileOS.close(); } } @@ -179,7 +199,7 @@ // Primary output for(MobyPrimaryData mobyOutputTemplate: outputs){ - // Retrieve the input with the same name as the service template specifies + // Retrieve the output with the same name as the service template specifies String paramName = mobyOutputTemplate.getName(); // Create the required command-line flag for the parameter @@ -190,7 +210,12 @@ } else{ // Otherwise we need to create temporary files to store the data - File tempFile = File.createTempFile("ACDService."+programBinaryFile.getName()+".output."+paramName, ".txt"); + String tempFileSuffix = ".txt"; + if(mobyOutputTemplate.getDataType().inheritsFrom(binaryDataType)){ + tempFileSuffix = ".bin"; + } + File tempFile = File.createTempFile("ACDService."+programBinaryFile.getName()+".output."+paramName, + tempFileSuffix); command.add("-"+paramName); command.add(tempFile.toString()); tempFiles.put(paramName, tempFile); @@ -271,7 +296,7 @@ /** * @return the standard output of the command */ - private String runProgram(MobyDataJob request, String[] command, File workingDir, final String input) throws Exception{ + private String runProgram(MobyDataJob request, String[] command, File workingDir, final byte[] input) throws Exception{ // TODO: ensure $embossRootDirName/lib is in the LD_LIBRARY_PATH, // what is the equivalent in Windows? Process process = runtime.exec(command, @@ -302,10 +327,18 @@ new Thread(){ public void run(){ try{ - for(String line: input.split("\n")){ - // Feed in the data one line at a time - stdin.write((line+"\n").getBytes()); - stdin.flush(); + final int SENDING_BLOCK_SIZE = 1024; + for(int i = 0; i < input.length; i += SENDING_BLOCK_SIZE){ + // Last chunk + if(i + SENDING_BLOCK_SIZE > input.length){ + stdin.write(input, i, input.length-i); + break; + } + // Feed the data to the command-line process in chunks + else{ + stdin.write(input, i, SENDING_BLOCK_SIZE); + stdin.flush(); + } } stdin.flush(); stdin.close(); @@ -366,17 +399,13 @@ throws java.lang.Exception{ MobyService service = super.createServiceFromConfig(request); - javax.servlet.ServletConfig config = getServletConfig(); - - if(config == null){ - throw new Exception("There is no servlet configuration available"); + if(getCoCInitParameter(EMBOSS_ROOT_PARAM) != null){ + embossRootDirName = getCoCInitParameter(EMBOSS_ROOT_PARAM); } - - if(config.getInitParameter(EMBOSS_ROOT_PARAM) == null){ + else{ throw new Exception("No parameter called " + EMBOSS_ROOT_PARAM + " was found in the servlet configuration"); } - embossRootDirName = config.getInitParameter(EMBOSS_ROOT_PARAM); if(embossRootDirName.length() == 0){ throw new Exception("Parameter " + EMBOSS_ROOT_PARAM + " was blank in the servlet configuration"); @@ -393,7 +422,8 @@ ") exists, but is not a directory, as expected"); } // See if it's really the emboss root (has bin dir) - String embossBinDirName = embossRootDirName+File.separator+"bin"; + String slash = File.separator; + String embossBinDirName = embossRootDirName+slash+"bin"; File embossBinDir = new File(embossBinDirName); if(!embossBinDir.exists()){ throw new Exception("The EMBOSS binaries directory inferred from " + @@ -405,8 +435,23 @@ "the servlet configuration (" + embossBinDirName + ") exists, but is not a directory, as expected"); } - String programName = config.getServletName(); - + + String programName = null; + if(getServletConfig() != null){ + programName = getServletConfig().getServletName(); + } + if(programName == null && getServletContext() != null){ + programName = getServletContext().getServletContextName(); + } + if(programName == null || programName.length() == 0){ + throw new Exception("Could not determine the program name, no servlet " + + "name or servlet context name is available"); + } + if(programName.length() == 0){ + throw new Exception("The program name is blank, based on the available " + + "servlet and servlet context names"); + } + // See that the emboss root and program work together programBinaryFile = new File(embossBinDir, programName); if(!programBinaryFile.exists()){ @@ -420,13 +465,12 @@ ") exists, but is not a file, as expected"); } - String slash = File.separator; // The default location EMBOSS uses is the default we'll use... String acdFileName = embossRootDir.getPath()+slash+"share"+slash+"EMBOSS"+slash+ "acd"+slash+programName+".acd"; // Unless overriden in the config... - if(config.getInitParameter(ACD_FILE_PARAM) != null){ - acdFileName = config.getInitParameter(ACD_FILE_PARAM); + if(getCoCInitParameter(ACD_FILE_PARAM) != null){ + acdFileName = getCoCInitParameter(ACD_FILE_PARAM); if(acdFileName.length() == 0){ throw new Exception("Parameter " + ACD_FILE_PARAM + " was blank in the servlet configuration"); @@ -444,8 +488,8 @@ acdRootDirName = acdFile.getParent(); URL regexRulesURL = null; - if(config.getInitParameter(ACD_RULES_LOCATION_PARAM) != null){ - String rulesLocationName = config.getInitParameter(ACD_RULES_LOCATION_PARAM); + if(getCoCInitParameter(ACD_RULES_LOCATION_PARAM) != null){ + String rulesLocationName = getCoCInitParameter(ACD_RULES_LOCATION_PARAM); if(rulesLocationName.length() == 0){ throw new Exception("Parameter " + ACD_RULES_LOCATION_PARAM + " was blank in the servlet configuration (please " + @@ -489,8 +533,8 @@ } URL xsltRulesURL = null; - if(config.getInitParameter(MOBY_RULES_LOCATION_PARAM) != null){ - String rulesLocationName = config.getInitParameter(MOBY_RULES_LOCATION_PARAM); + if(getCoCInitParameter(MOBY_RULES_LOCATION_PARAM) != null){ + String rulesLocationName = getCoCInitParameter(MOBY_RULES_LOCATION_PARAM); if(rulesLocationName.length() == 0){ throw new Exception("Parameter " + MOBY_RULES_LOCATION_PARAM + " was blank in the servlet configuration (please " + @@ -543,19 +587,21 @@ textClient = new TextClient(); textClient.addMappingsFromURL(xsltRulesURL); + boolean useAdvancedParams = Boolean.parseBoolean(getCoCInitParameter(EMBOSS_ADV_PARAMS_PARAM)); + // All the parameters have been specified correctly, now check the ACD file // and create the MOBYService signature from it. try{ - configureServiceFromACDFile(service, acdFile); + configureServiceFromACDFile(service, acdFile, useAdvancedParams); } catch(Exception e){ log("While parsing the ACD file (" + acdFileName + ")", e); throw new Exception("While parsing the ACD file (" + acdFileName + "): " + e); } - // Override params? - if(config.getInitParameter(EMBOSS_PARAMS_PARAM) != null){ - for(String param: config.getInitParameter(EMBOSS_PARAMS_PARAM).split(",")){ + // Override params? (will also add non-existing params if you really want) + if(getCoCInitParameter(EMBOSS_PARAMS_PARAM) != null){ + for(String param: getCoCInitParameter(EMBOSS_PARAMS_PARAM).split(",")){ String[] specs = param.split(":"); if(specs.length != 2){ log("While parsing the " + EMBOSS_PARAMS_PARAM + " specs, item \""+ @@ -573,8 +619,8 @@ // A parameter telling us what hard-coded output file name patterns // are used in the ACD program (i.e. ones we can't specify ourselves on the command line, // so we need to know them in order to hand them back to the user). - if(config.getInitParameter(EMBOSS_OUTPUT_PARAM) != null){ - String[] specs = config.getInitParameter(EMBOSS_OUTPUT_PARAM).split(":"); + if(getCoCInitParameter(EMBOSS_OUTPUT_PARAM) != null){ + String[] specs = getCoCInitParameter(EMBOSS_OUTPUT_PARAM).split(":"); if(specs.length != 2){ throw new Exception("While parsing the " + EMBOSS_OUTPUT_PARAM + " specs, "+ "the value did not have the expected \"name:regex\" format"); @@ -599,19 +645,24 @@ } } + binaryDataType = MobyDataType.getDataType(MobyDataBytes.BASE64_DATATYPE); + return service; } /** * Parses the ACD file and sets the MOBY signature parameters appropriately. */ - public void configureServiceFromACDFile(MobyService service, File acdFile) throws Exception{ + public void configureServiceFromACDFile(MobyService service, File acdFile, boolean useAdvancedParams) + throws Exception{ ACDFile parsedACDData = new ACDFile(acdFile); configureServiceFromACDApplication(service, parsedACDData.getApplicationSection()); configureServiceFromACDInput(service, parsedACDData.getInputSection()); configureServiceFromACDParams(service, parsedACDData.getAdditionalParamsSection()); - configureServiceFromACDParams(service, parsedACDData.getAdvancedParamsSection()); + if(useAdvancedParams){ + configureServiceFromACDParams(service, parsedACDData.getAdvancedParamsSection()); + } configureServiceFromACDOutput(service, parsedACDData.getOutputSection()); } @@ -632,8 +683,8 @@ "but got \"" + entries.get(ACDFile.BLOCK_TYPE_KEY) + "\""); } - // Get the service name and description - service.setName(entries.get(ACDFile.BLOCK_NAME_KEY)); + // service.setName(entries.get(ACDFile.BLOCK_NAME_KEY)); + // Get the service description if(entries.containsKey("documentation")){ service.setDescription(entries.get("documentation")); } @@ -660,9 +711,13 @@ // Make sure it maps to a MOBY Input if(!paramUsed.containsKey(acdInputName)){ + String declInputNames = ""; + for(String inputName: paramUsed.keySet()){ + declInputNames = inputName+" "; + } throw new Exception("A required ACD input parameter ("+acdInputName+ ") does not have a matching declaration in the " + - "servlet configuration"); + "servlet configuration ( "+declInputNames+")"); } MobyPrimaryData mobyPrimaryInput = paramUsed.get(acdInputName); From gordonp at dev.open-bio.org Thu Apr 12 01:03:15 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 11 Apr 2007 21:03:15 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704120103.l3C13FqL030802@dev.open-bio.org> gordonp Wed Apr 11 21:03:14 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv30766/src/main/ca/ucalgary/seahawk/gui Modified Files: MobySecondaryInputGUI.java Log Message: Fixed boolean param parsing moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobySecondaryInputGUI.java,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobySecondaryInputGUI.java,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/gui/MobySecondaryInputGUI.java 2007/04/03 02:33:57 1.4 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobySecondaryInputGUI.java 2007/04/12 01:03:14 1.5 @@ -246,8 +246,10 @@ widget.add(makeJLabel(msdi)); JCheckBox checkbox = new JCheckBox(); checkbox.setSelected(defaultValue.toLowerCase().equals("true") || + defaultValue.toLowerCase().equals("yes") || defaultValue.equals("1") || - defaultValue.equals("T")); + defaultValue.equals("T") || + defaultValue.equals("Y")); data2widget.put(msdi, checkbox); widget.add(checkbox); @@ -463,10 +465,13 @@ newValue = ((JTextComponent) widget).getText(); msdi.setValue(newValue.toString()); } + else if(widget instanceof JCheckBox){ + msdi.setValue(""+((JCheckBox) widget).isSelected()); + } else{ logger.error("IllegalArgumentException: GUI Component for " + msdi.getName() + " was neither a JComboBox nor a " + - "JTextComponent as expected"); + "JTextComponent nor a JCheckBox as expected"); throw new IllegalArgumentException(); } } From mwilkinson at dev.open-bio.org Thu Apr 12 18:22:16 2007 From: mwilkinson at dev.open-bio.org (Mark Wilkinson) Date: Thu, 12 Apr 2007 14:22:16 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704121822.l3CIMGHW032668@dev.open-bio.org> mwilkinson Thu Apr 12 14:22:16 EDT 2007 Update of /home/repository/moby/moby-live/Docs In directory dev.open-bio.org:/tmp/cvs-serv32642 Added Files: BioMoby 1_0 version 11.pdf Removed Files: BioMoby 1_0 version 6.pdf BioMoby 1_0 version 7.pdf Log Message: final version of the manuscript moby-live/Docs BioMoby 1_0 version 11.pdf,NONE,1.1 BioMoby 1_0 version 6.pdf,1.1,NONE BioMoby 1_0 version 7.pdf,1.1,NONE rcsdiff: /home/repository/moby/moby-live/Docs/RCS/BioMoby,v: No such file or directory rcsdiff: /home/repository/moby/moby-live/Docs/RCS/1_0,v: No such file or directory rcsdiff: /home/repository/moby/moby-live/Docs/RCS/version,v: No such file or directory rcsdiff: /home/repository/moby/moby-live/Docs/RCS/BioMoby,v: No such file or directory rcsdiff: /home/repository/moby/moby-live/Docs/RCS/1_0,v: No such file or directory rcsdiff: /home/repository/moby/moby-live/Docs/RCS/version,v: No such file or directory rcsdiff: /home/repository/moby/moby-live/Docs/RCS/6.pdf,v: No such file or directory rcsdiff: /home/repository/moby/moby-live/Docs/RCS/BioMoby,v: No such file or directory rcsdiff: /home/repository/moby/moby-live/Docs/RCS/1_0,v: No such file or directory rcsdiff: /home/repository/moby/moby-live/Docs/RCS/version,v: No such file or directory rcsdiff: /home/repository/moby/moby-live/Docs/RCS/7.pdf,v: No such file or directory From gordonp at dev.open-bio.org Fri Apr 13 01:55:36 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 12 Apr 2007 21:55:36 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704130155.l3D1ta62000908@dev.open-bio.org> gordonp Thu Apr 12 21:55:36 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data In directory dev.open-bio.org:/tmp/cvs-serv872/src/main/org/biomoby/shared/data Modified Files: MobyDataBytes.java Log Message: Fixed contenmt member typo, made more verbose error messaging moby-live/Java/src/main/org/biomoby/shared/data MobyDataBytes.java,1.5,1.6 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataBytes.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/MobyDataBytes.java 2007/03/12 17:01:29 1.5 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataBytes.java 2007/04/13 01:55:36 1.6 @@ -23,7 +23,7 @@ public class MobyDataBytes extends MobyDataComposite{ public static final String BASE64_DATATYPE = "text-base64"; - public static final String ENCODED_MEMBER_NAME = "contents"; + public static final String ENCODED_MEMBER_NAME = "content"; /** How much is read from a input stream (e.g. file) at once */ public static final int BYTE_READ_SIZE = 4096; @@ -52,6 +52,13 @@ populateMembersFromDOM(element); MobyDataObject contents = get(ENCODED_MEMBER_NAME); + if(contents == null){ + throw new MobyException("The encoded binary member (" + ENCODED_MEMBER_NAME + + ") of the given element (" + + element.getLocalName()+ + ") was missing, but must exist to be a proper " + + BASE64_DATATYPE + " object"); + } if(!(contents instanceof MobyDataString)){ throw new MobyException("The encoded binary member (" + ENCODED_MEMBER_NAME + ") of the given element (" + From gordonp at dev.open-bio.org Fri Apr 13 01:56:12 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 12 Apr 2007 21:56:12 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704130156.l3D1uCqs000952@dev.open-bio.org> gordonp Thu Apr 12 21:56:12 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data In directory dev.open-bio.org:/tmp/cvs-serv916/src/main/org/biomoby/shared/data Modified Files: MobyDataComposite.java Log Message: More data type error checking moby-live/Java/src/main/org/biomoby/shared/data MobyDataComposite.java,1.13,1.14 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataComposite.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataComposite.java 2007/04/08 17:29:29 1.13 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataComposite.java 2007/04/13 01:56:12 1.14 @@ -393,10 +393,22 @@ } MobyRelationship relationship = getDataType().getChild(fieldName); + if(relationship == null){ + relationship = MobyDataType.getDataType(getDataType().getName()).getChild(fieldName); + if(relationship == null){ + String memberNames = ""; + for(MobyRelationship rel: getDataType().getChildren()){ + memberNames += " "+rel.getName(); + } + throw new IllegalArgumentException("The member '" + fieldName + "' for object '"+ getName() + + "' does not exist in the Moby ontology definition for "+ + getDataType().getName() + ", valid member names are:" + memberNames); + } + } MobyDataType childDataType = MobyDataType.getDataType(relationship.getDataTypeName()); if(!value.getDataType().inheritsFrom(childDataType)){ // Incompatible types - throw new IllegalArgumentException("The object member '" + fieldName + "' for object '"+ getName() + + throw new IllegalArgumentException("The member '" + fieldName + "' for object '"+ getName() + "' does not inherit from the required data type " + "(found data type " + value.getDataType().getName()+ ", but require subclass of " + From gordonp at dev.open-bio.org Wed Apr 18 15:28:07 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 18 Apr 2007 11:28:07 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704181528.l3IFS7xQ012123@dev.open-bio.org> gordonp Wed Apr 18 11:28:07 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/resources In directory dev.open-bio.org:/tmp/cvs-serv12088/src/main/ca/ucalgary/services/resources Modified Files: mobyRules.xsl Log Message: Added rules for ABI traces, and DNA sequence-to-plain string moby-live/Java/src/main/ca/ucalgary/services/resources mobyRules.xsl,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/resources/mobyRules.xsl,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/mobyRules.xsl 2007/03/12 14:33:38 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/resources/mobyRules.xsl 2007/04/18 15:28:07 1.2 @@ -52,11 +52,14 @@ because XSLT does not handle variables in the mode attribute. Therefore for each target text data type included in this stylesheet, you must include an if condition here. See http://www.dpawson.co.uk/xsl/sect2/nono.html#d1905e383 - --> + --> + + + @@ -68,6 +71,11 @@ + + + + + + + + + + + + + From gordonp at dev.open-bio.org Wed Apr 18 15:53:59 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 18 Apr 2007 11:53:59 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704181553.l3IFrxH3012189@dev.open-bio.org> gordonp Wed Apr 18 11:53:58 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services In directory dev.open-bio.org:/tmp/cvs-serv12154/src/main/ca/ucalgary/services Modified Files: ACDService.java Log Message: Added support for binary data passthrough, better ACD parameter handling, and change from stdin to temp files for input due to EMBOSS inconsistency of implementing acceptance of stdin moby-live/Java/src/main/ca/ucalgary/services ACDService.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/ACDService.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/services/ACDService.java 2007/04/12 01:02:29 1.2 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/ACDService.java 2007/04/18 15:53:58 1.3 @@ -48,6 +48,7 @@ // Keep track of what MOBY input parameters are to be converted to what ACD types private Map acdTypes; + private Map acdBasicTypes; //holds e.g. string, when acdType for same key is "nucleotide sequence" // For launching command-line programs private Runtime runtime; Vector fixedSecondaryData; @@ -57,6 +58,7 @@ public void init(){ super.init(); acdTypes = new HashMap(); + acdBasicTypes = new HashMap(); runtime = Runtime.getRuntime(); fixedSecondaryData = new Vector(); } @@ -146,8 +148,9 @@ // Transform the moby data to text, unless it's binary data, which will be passed as decoded bytes // Now, for binary data, we have to ignore any fields other than the Base64 encoded one. Sorry! String tempFileSuffix = ".txt"; - if(mobyInputTemplate.getDataType().inheritsFrom(binaryDataType)){ - inputDataBytes = org.apache.axis.encoding.Base64.decode(MobyDataBytes.ENCODED_MEMBER_NAME); + if(inputData instanceof MobyDataBytes){ + //System.err.println("Passing binary data to service"); + inputDataBytes = ((MobyDataBytes) inputData).getBytes(); tempFileSuffix = ".bin"; } else{ @@ -161,11 +164,15 @@ } // Create the required command-line flag for the parameter - if(inputs.length == 1){ + + // Is it a primary param whose value must be passed in directly, as opposed to in a file? + String basicType = acdBasicTypes.get(paramName); + if(basicType != null && + (basicType.equals("string") || basicType.equals("integer") || + basicType.equals("float") || basicType.equals("boolean"))){ // If only one input, we can pass it via stdin command.add("-"+paramName); - command.add("stdin"); - stdin = inputDataBytes; + command.add(new String(inputDataBytes)); } else{ // Otherwise we need to create temporary files to store the data @@ -183,7 +190,10 @@ // User-selected Secondary input for(MobyDataSecondaryInstance mobySecondary: request.getSecondaryData()){ - // Make that no funny business is going on with shell escape characters. + // ASSUMPTION: Don't need to make sure that no funny business is + // going on with shell escape characters in the secondary names and + // values (potential security problem), because we call the string + // array form of Runtime.exec() later, which does not invoke a shell. command.add("-"+mobySecondary.getName()); command.add(mobySecondary.getObject().toString()); } @@ -204,7 +214,7 @@ // Create the required command-line flag for the parameter if(outputs.length == 1){ - // If only one input, we can pass it via stdin + // If only one output, we can grab it via stdout command.add("-"+paramName); command.add("stdout"); } @@ -299,13 +309,18 @@ private String runProgram(MobyDataJob request, String[] command, File workingDir, final byte[] input) throws Exception{ // TODO: ensure $embossRootDirName/lib is in the LD_LIBRARY_PATH, // what is the equivalent in Windows? - Process process = runtime.exec(command, - new String[]{"EMBOSS="+embossRootDirName, - "EMBOSS_ACDROOT="+acdRootDirName}, - workingDir); + //for(String cmdpart: command){ + // System.err.print(cmdpart+" "); + //} + //System.err.println(""); + final Process process = runtime.exec(command, + new String[]{"EMBOSS="+embossRootDirName, + "EMBOSS_ACDROOT="+acdRootDirName}, + workingDir); final OutputStream stdin = process.getOutputStream(); final InputStream stderr = process.getErrorStream(); final InputStream stdout = process.getInputStream(); + final StringBuffer output = new StringBuffer(); // Echo the program's stderr new Thread(){ @@ -323,51 +338,71 @@ } }.start(); - // Write the data to the command's stdin, one line at a time + // Write the data to the command's stdin, in one fell swoop new Thread(){ public void run(){ try{ - final int SENDING_BLOCK_SIZE = 1024; - for(int i = 0; i < input.length; i += SENDING_BLOCK_SIZE){ - // Last chunk - if(i + SENDING_BLOCK_SIZE > input.length){ - stdin.write(input, i, input.length-i); - break; - } - // Feed the data to the command-line process in chunks - else{ - stdin.write(input, i, SENDING_BLOCK_SIZE); - stdin.flush(); - } - } + stdin.write(input); stdin.flush(); stdin.close(); } catch(Exception e){ - System.err.println("Caught exception while sending data to the command: "+e); + // Okay, so sometimes Java sits there waiting to write data + // even after the write call (due to buffering?), then throws + // an Exception because the stream was closed in the main thread + // below. How do we distinguish between genuine write issues and this? + // By checking if the job is finished already and exited normally and produced data. + // If so, don't bother reporting the error, otherwise report it + // because the program may be missing data! + try{ + Thread.sleep(1000);} + catch(Exception te){ + System.err.println("Warning: grace period for stdin close " + + "not met, thread was interrupted: " + te); + } + //grace period between stream close and process end + boolean completed = true; + int eVal = 0; + try{ + eVal = process.exitValue(); + } catch(IllegalThreadStateException itse){ + completed = false; + } + // 3 conditions, from more most severe to least + if(!completed){ + System.err.println("Caught exception while sending data to the command" + + "(while process is still running): "+e); + } + else if(eVal != 0){ + System.err.println("Caught exception while sending data to the command" + + "(and the process had a non-zero return value): "+e); + } + else if(output.length() == 0){ + System.err.println("Caught exception while sending data to the command " + + "(and the process output is blank): "+e); + // Not *necessarily* a real error + // (grace time may be exceeded), but maybe, + // so print it anyway + e.printStackTrace(); + } + else{ + return; //all okay, we only got here becuase of the java superfluous buffering issue + } e.printStackTrace(); } } }.start(); - final StringBuffer output = new StringBuffer(); - // Read the program's output (in a thread, to avoid deadlocks) - new Thread(){ - public void run(){ - try{ - byte[] data = new byte[1024]; - for(int c = stdout.read(data, 0, data.length); c != -1; c = stdout.read(data, 0, 1024)){ - output.append(new String(data, 0, c)); - } - } - catch(Exception e){ - System.err.println("Caught exception while receiving data from the command-line program: "+e); - e.printStackTrace(); - } + try{ + byte[] data = new byte[1024]; + for(int c = stdout.read(data, 0, data.length); c != -1; c = stdout.read(data, 0, 1024)){ + output.append(new String(data, 0, c)); + } + } + catch(Exception e){ + throw new Exception("Caught exception while receiving data from the command-line program: "+e); + } - } - }.start(); - int exitVal = process.waitFor(); if(exitVal != 0){ addException(new MobyServiceException(MobyServiceException.WARNING, @@ -658,7 +693,11 @@ ACDFile parsedACDData = new ACDFile(acdFile); configureServiceFromACDApplication(service, parsedACDData.getApplicationSection()); - configureServiceFromACDInput(service, parsedACDData.getInputSection()); + List> combinedInput = new ArrayList>(parsedACDData.getInputSection()); + combinedInput.addAll(parsedACDData.getRequiredParamsSection()); + configureServiceFromACDInput(service, combinedInput); + //configureServiceFromACDInput(service, parsedACDData.getInputSection()); + //configureServiceFromACDInput(service, parsedACDData.getRequiredParamsSection()); configureServiceFromACDParams(service, parsedACDData.getAdditionalParamsSection()); if(useAdvancedParams){ configureServiceFromACDParams(service, parsedACDData.getAdvancedParamsSection()); @@ -699,10 +738,10 @@ protected void configureServiceFromACDInput(MobyService service, List> spec) throws Exception{ MobyPrimaryData[] mobyInputTypes = service.getPrimaryInputs(); - Map paramUsed = new HashMap(); + Map paramUnused = new HashMap(); for(MobyPrimaryData mobyPrimaryInput: mobyInputTypes){ - paramUsed.put(mobyPrimaryInput.getName(), mobyPrimaryInput); + paramUnused.put(mobyPrimaryInput.getName(), mobyPrimaryInput); } for(MobyData acdInput: specToMoby(spec)){ @@ -710,9 +749,9 @@ String acdInputName = acdInput.getName(); // Make sure it maps to a MOBY Input - if(!paramUsed.containsKey(acdInputName)){ + if(!paramUnused.containsKey(acdInputName)){ String declInputNames = ""; - for(String inputName: paramUsed.keySet()){ + for(String inputName: paramUnused.keySet()){ declInputNames = inputName+" "; } throw new Exception("A required ACD input parameter ("+acdInputName+ @@ -720,25 +759,26 @@ "servlet configuration ( "+declInputNames+")"); } - MobyPrimaryData mobyPrimaryInput = paramUsed.get(acdInputName); + MobyPrimaryData mobyPrimaryInput = paramUnused.get(acdInputName); if(!textClient.canProduceTextTypeFromMoby(acdTypes.get(acdInputName), mobyPrimaryInput)){ throw new Exception("No XSLT rules exist that can produce the requested " + "text type '" + acdTypes.get(acdInputName) + - "' from the given MOBY object type (" + + "' (acd input parameter " + acdInputName + + ") from the given MOBY object type (" + mobyPrimaryInput.getDataType().getName()+")"); } // If it exists, make sure it's of the right type if(acdInput instanceof MobyPrimaryDataSimple && - paramUsed.get(acdInputName) instanceof MobyPrimaryDataSet){ + paramUnused.get(acdInputName) instanceof MobyPrimaryDataSet){ throw new Exception("The MOBY input parameter \""+acdInputName+ "\" is a Collection, but the ACD input parameter is " + "a simple (expected a declaration like \""+acdInputName+":"+ ""+ - paramUsed.get(acdInputName).getDataType().getName()+ + paramUnused.get(acdInputName).getDataType().getName()+ "\")"); } - paramUsed.remove(acdInputName); + paramUnused.remove(acdInputName); } // Secondary params read from the ACD spec always get included else if(acdInput instanceof MobySecondaryData){ @@ -751,9 +791,9 @@ } } - if(!paramUsed.isEmpty()){ + if(!paramUnused.isEmpty()){ String unmappedParams = ""; - for(String param: paramUsed.keySet()){ + for(String param: paramUnused.keySet()){ unmappedParams += " "+param; } throw new Exception("There are superfluous MOBY input parameters specified that do " + @@ -852,26 +892,27 @@ // Secondary Parameter types String additional = block.get("additional"); String deFault = block.get("default"); - if(additional != null && additional.toUpperCase().equals("Y") || - deFault != null && deFault.toUpperCase().equals("N")){ + //System.err.println("param: " + acdName + "/" + acdType +" " + additional +" ("+deFault+")"); + if((additional != null && additional.toUpperCase().equals("Y")) || + deFault != null){ if("boolean".equals(acdType) || "toggle".equals(acdType)){ MobySecondaryData bool = new MobySecondaryData(acdName); bool.setDataType(MobySecondaryData.BOOLEAN_TYPE); - bool.setDefaultValue(block.get("default")); + bool.setDefaultValue(deFault); bool.setDescription(block.get("help")); mobyDataType = bool; } else if("string".equals(acdType) || "range".equals(acdType)){ MobySecondaryData string = new MobySecondaryData(acdName); string.setDataType(MobySecondaryData.STRING_TYPE); - string.setDefaultValue(block.get("default")); + string.setDefaultValue(deFault); string.setDescription(block.get("help")); mobyDataType = string; } else if("list".equals(acdType)){ MobySecondaryData enumeration = new MobySecondaryData(acdName); enumeration.setDataType(MobySecondaryData.STRING_TYPE); - enumeration.setDefaultValue(block.get("default")); + enumeration.setDefaultValue(deFault); enumeration.setDescription(block.get("information")); processACDList(enumeration, block.get("values"), block.get("delimiter"), block.get("codedelimiter")); @@ -880,7 +921,7 @@ else if("integer".equals(acdType)){ MobySecondaryData integer = new MobySecondaryData(acdName); integer.setDataType(MobySecondaryData.INTEGER_TYPE); - integer.setDefaultValue(block.get("default")); + integer.setDefaultValue(deFault); integer.setDescription(block.get("information")); integer.setMinValue(block.get("minimum")); integer.setMaxValue(block.get("maximum")); @@ -889,7 +930,7 @@ else if("float".equals(acdType)){ MobySecondaryData floating = new MobySecondaryData(acdName); floating.setDataType(MobySecondaryData.FLOAT_TYPE); - floating.setDefaultValue(block.get("default")); + floating.setDefaultValue(deFault); floating.setDescription(block.get("information")); floating.setMinValue(block.get("minimum")); floating.setMaxValue(block.get("maximum")); @@ -897,6 +938,7 @@ } else{ System.err.println("Skipping secondary parameter that is not a primitive in MOBY:" + acdType); + continue; } } //end if(additional) // else it's a required parameter @@ -910,10 +952,26 @@ else{ mobyDataType = new MobyPrimaryDataSimple(acdName); } + + // There are instances where the ACD data type is generic, such as + // "infile", "outfile", "string", and "datafile" + // We will not handle the case of "list" data type, because this was enumerated anyway. + if((acdType.equals("infile") || + acdType.equals("outfile") || + acdType.equals("string") || + acdType.equals("datafile")) && + block.containsKey("knowntype")){ + // In such cases, keep track of the basic type (e.g. string, so when we build + // the command line we know how to represent the data) + acdBasicTypes.put(acdName, acdType); + acdType = block.get("knowntype"); + } acdTypes.put(acdName, acdType); } - mobyDataTypes.add(mobyDataType); + if(mobyDataType != null){ + mobyDataTypes.add(mobyDataType); + } } return mobyDataTypes; From gordonp at dev.open-bio.org Wed Apr 18 15:55:18 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 18 Apr 2007 11:55:18 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704181555.l3IFtI06012232@dev.open-bio.org> gordonp Wed Apr 18 11:55:18 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util In directory dev.open-bio.org:/tmp/cvs-serv12197/src/main/ca/ucalgary/seahawk/util Modified Files: MobyUtils.java Log Message: Added binary data support, and create GlobalKeyword only if data is not also a sequence moby-live/Java/src/main/ca/ucalgary/seahawk/util MobyUtils.java,1.5,1.6 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/MobyUtils.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/util/MobyUtils.java 2007/02/08 16:59:58 1.5 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/MobyUtils.java 2007/04/18 15:55:18 1.6 @@ -2,17 +2,21 @@ import ca.ucalgary.seahawk.gui.MobyContentGUI; import ca.ucalgary.seahawk.gui.MobyServicesGUI; +import ca.ucalgary.seahawk.services.MobyClient; import org.biomoby.shared.data.*; import org.biomoby.shared.MobyDataType; import org.biomoby.shared.MobyNamespace; +import java.io.ByteArrayOutputStream; +import java.io.InputStream; +import java.net.URL; import java.util.Vector; import javax.swing.JLabel; /** * Contains utility methods for Moby Object creation from unstructured data, and for - * creating the Seahawk GUI. + * creating the Seahawk GUI. */ public class MobyUtils{ @@ -21,6 +25,41 @@ private static MobyContentGUI mobyContentGUI = null; private static MobyServicesGUI mobyServicesGUI = null; + /** + * The purpose of this method is to create a MOBY document to encapsulate + * a binary data object stored at the given URL. If the data does + * not represent a single binary MOBY object, the method returns null. + * If the provided client or URL is null, null will be returned too. + */ + public static MobyContentInstance convertURLtoMobyBinaryData(MobyClient client, URL url)throws Exception{ + if(url == null || client == null){ + return null; + } + + ByteArrayOutputStream bytes = new ByteArrayOutputStream(); + InputStream is = url.openStream(); + + // Slurp up the file as bytes + byte[] buffer = new byte[4096]; + for(int bytesRead = is.read(buffer); bytesRead != -1; bytesRead = is.read(buffer)){ + bytes.write(buffer, 0, bytesRead); + } + + // Find MOBY Objects in it + MobyDataObject[] foundObjects = client.getMobyObjects(bytes.toByteArray(), + MobyDataType.getDataType(MobyDataBytes.BASE64_DATATYPE)); + // 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]); + 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){ if(data == null){ return new MobyDataInstance[0]; @@ -39,14 +78,6 @@ strObject.setPrimaryNamespace(new MobyNamespace("seahawk")); objects.add(strObject); - // If it's a single word, give keyword options - if(data.trim().matches("^[A-Za-z0-9_-]{3,}$")){ - objects.add(new MobyDataComposite("Global_Keyword", - "dummy_name", - "seahawk", - data.trim())); - } - // See if it's sequence MobyDataComposite mdc = createMobySequence(data, "user-selection"); if(mdc != null){ @@ -63,6 +94,16 @@ mdc.setName(objectName); objects.add(mdc); } + // If it's a single word, give keyword options + else{ + if(data.trim().matches("^[A-Za-z0-9_-]{3,35}$")){ + objects.add(new MobyDataComposite("Global_Keyword", + "dummy_name", + "seahawk", + data.trim())); + } + } + return (MobyDataInstance[]) objects.toArray(new MobyDataInstance[objects.size()]); } From gordonp at dev.open-bio.org Wed Apr 18 15:57:01 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 18 Apr 2007 11:57:01 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704181557.l3IFv1YP012275@dev.open-bio.org> gordonp Wed Apr 18 11:57: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-serv12240/src/main/ca/ucalgary/seahawk/gui Modified Files: MobyContentGUI.java Log Message: Fixed possible string out of bounds exception for tab labels moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyContentGUI.java,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.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/gui/MobyContentGUI.java 2007/04/03 02:34:08 1.6 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java 2007/04/18 15:57:00 1.7 @@ -667,6 +667,9 @@ } else{ int allowableLen = MAX_TAB_NAME_LENGTH-shortName.length(); + if(allowableLen > path.length()){ + allowableLen = path.length(); + } shortName = shortName+"..."+path.substring(path.length()-allowableLen); } } From gordonp at dev.open-bio.org Wed Apr 18 15:58:08 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 18 Apr 2007 11:58:08 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704181558.l3IFw81M012339@dev.open-bio.org> gordonp Wed Apr 18 11:58:08 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services In directory dev.open-bio.org:/tmp/cvs-serv12304/src/main/ca/ucalgary/seahawk/services Modified Files: MobyComplexBuilder.java Log Message: Fixed binary data replaceAll equivalent moby-live/Java/src/main/ca/ucalgary/seahawk/services MobyComplexBuilder.java,1.5,1.6 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyComplexBuilder.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/services/MobyComplexBuilder.java 2007/04/08 17:26:24 1.5 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyComplexBuilder.java 2007/04/18 15:58:08 1.6 @@ -206,22 +206,21 @@ for(int j = 0; j <= matcher.groupCount(); j++){ // A replaceAll() for binary data if(data != null){ - (new Exception("Binary replaceAll()")).printStackTrace(); int srcPos = 0; - for(int varIndex = result.indexOf("\\$"+j, srcPos); + for(int varIndex = result.indexOf("$"+j, srcPos); varIndex != -1; - varIndex = result.indexOf("\\$"+j, srcPos)){ - int varValueLength = matcher.end(j)-matcher.start(j)+1; - - byte[] newResultBytes = new byte[resultBytes.length+varValueLength]; - if(varIndex > 0){ + varIndex = result.indexOf("$"+j, srcPos)){ + int varValueLength = matcher.end(j)-matcher.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); - int remaining = result.length()-varIndex-2; + int remaining = result.length()-varIndex-varLen; if(remaining > 0){ - System.arraycopy(resultBytes, varIndex+2, newResultBytes, varIndex+varValueLength, - result.length()-varIndex-2); + System.arraycopy(resultBytes, varIndex+varLen, newResultBytes, varIndex+varValueLength, + result.length()-varIndex-varLen); } srcPos += varIndex + varValueLength + 1; resultBytes = newResultBytes; From gordonp at dev.open-bio.org Wed Apr 18 15:59:01 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 18 Apr 2007 11:59:01 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704181559.l3IFx0nI012382@dev.open-bio.org> gordonp Wed Apr 18 11:59:00 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-serv12347/src/main/ca/ucalgary/seahawk/gui/test Modified Files: SeahawkTestCase.java Log Message: Test service category update moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test SeahawkTestCase.java,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test/SeahawkTestCase.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/gui/test/SeahawkTestCase.java 2007/04/04 01:29:20 1.6 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test/SeahawkTestCase.java 2007/04/18 15:59:00 1.7 @@ -699,7 +699,7 @@ public void testRunServiceSecondariesAndSCUFL() throws Exception{ try{ - findService(TEST_DNA_SEQ, "Bioinformatics", "..."); + findService(TEST_DNA_SEQ, "Analysis", "..."); } catch(Exception e){ e.printStackTrace(); fail("Error while a finding service ending with \"...\" " + From gordonp at dev.open-bio.org Wed Apr 18 16:01:00 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 18 Apr 2007 12:01:00 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704181601.l3IG10xq012427@dev.open-bio.org> gordonp Wed Apr 18 12:01:00 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services In directory dev.open-bio.org:/tmp/cvs-serv12392/src/main/ca/ucalgary/seahawk/services Modified Files: MobyClient.java Log Message: Made less verbose, fixed binary data search pass-through for non-binary data moby-live/Java/src/main/ca/ucalgary/seahawk/services MobyClient.java,1.10,1.11 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.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/services/MobyClient.java 2007/04/08 17:26:24 1.10 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java 2007/04/18 16:01:00 1.11 @@ -554,10 +554,14 @@ public MobyDataInstance getMobyObject(Map resultParts, MobyPrimaryData dataTemplate) throws Exception, MobyServiceException{ Vector results = new Vector(); + + // System.err.println("Data has " + resultParts.size() + " parts"); // The output parameter *potentially* has multiple parts - // (e.g. multiple .png file from EMBOSS's "banana" program) + // (e.g. multiple .png files from EMBOSS's "banana" program) // hence the nested for loops (part iteration, followed by created-object iteration) for(String resultPartName: resultParts.keySet()){ + + //System.err.println("About to check part "+ resultPartName); for(MobyDataObject resultPart: getMobyObjects(resultParts.get(resultPartName), dataTemplate.getDataType())){ // Maintain the name for the object in the collection, as banana.1.png, banana.2.png, etc. // is useful information for the end-user for making sense of them together! (left to right) @@ -608,10 +612,17 @@ } else if(results.size() > 1){ if(dataTemplate instanceof MobyPrimaryDataSimple){ - System.err.println("The data map provided " + - "was a collection, but the request was to return a simple. " + + // In this case, eliminate any higher-up objects that + // have the exact same contents as the same members who are their + // subtypes, as these are superfluous. + + System.err.println("Multiple Moby objects were found in the text data, " + + "but the request was to return a simple. " + "Only the first value in the collection has been returned."); - // TODO: should we instead return the one deepest in the heirarchy (or with the most members)? + for(MobyDataObject result: results){ + System.err.println("Found object: " + result.getDataType().getName()); + } + // TODO: should we instead return the one deepest in the hierarchy (or with the most members)? return results.elementAt(0); } else{ @@ -647,8 +658,11 @@ 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))){ - return getMobyObjects(new String(rawData)); + //System.err.println("Data type does not inerit from Base64, continuing with string-based search..."); + return getMobyObjects(new String(rawData), targetDataType); } + //System.err.println("Data type " + targetDataType.getName() + " inherits from " + MobyDataBytes.BASE64_DATATYPE + + // ", continuing with byte-based search..."); String rawDataAsString = null; @@ -656,18 +670,22 @@ for(Pattern pattern: regexMap.keySet()){ MobyComplexBuilder rule = regexMap.get(pattern); + //System.err.print("Checking" + rule.getDataType().getName()+":"); + //for(MobyDataType parent: rule.getDataType().getLineage()){System.err.print(" " + parent.getName());} + //System.err.println(""); if(rule.getDataType().inheritsFrom(targetDataType)){ + //System.err.println("Checking rule that generates data type " + rule.getDataType().getName()); // Only build the string representation of the byte array if we // found a rule that applies (since it's a somewhat expensive operation // to do the conversion) if(rawDataAsString == null){ rawDataAsString = bytesToString(rawData); - System.err.println("Start of data is " + rawDataAsString.substring(0, 4)); + //System.err.println("Start of data is " + rawDataAsString.substring(0, 4)); } Matcher matcher = pattern.matcher(rawDataAsString); while(matcher.find()){ - System.err.println("Found match for binary data"); + //System.err.println("Found match for binary data"); try{ MobyDataObject mobyObj = rule.apply(matcher, rawData); if(mobyObj != null){ From gordonp at dev.open-bio.org Wed Apr 18 16:02:09 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 18 Apr 2007 12:02:09 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704181602.l3IG29t5012489@dev.open-bio.org> gordonp Wed Apr 18 12:02:09 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util In directory dev.open-bio.org:/tmp/cvs-serv12458/src/main/ca/ucalgary/seahawk/util Added Files: HTMLUtils.java Log Message: New file for data reformtting utils of Seahawk HTML display moby-live/Java/src/main/ca/ucalgary/seahawk/util HTMLUtils.java,NONE,1.1 From gordonp at dev.open-bio.org Wed Apr 18 16:04:06 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 18 Apr 2007 12:04:06 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704181604.l3IG46D9012553@dev.open-bio.org> gordonp Wed Apr 18 12:04:06 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv12518/src/main/ca/ucalgary/seahawk/gui Modified Files: MobyContentPane.java Log Message: Added better binary data support, and only add to history if load successful moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyContentPane.java,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.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/gui/MobyContentPane.java 2007/04/03 02:34:08 1.6 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java 2007/04/18 16:04:06 1.7 @@ -209,17 +209,6 @@ return; } - if(addToHistory){ - // Are we truncating the history? (i.e. loading a new doc in the middle of the history) - if(historyIndex != history.size()-1){ - history.setSize(historyIndex+1); - } - history.add(url); - - historyIndex = history.size()-1; - contentGUI.updateHistory(this); - } - try { // 1000 is initial, unimportant guess as to resulting HTML size StringBuffer resultBuffer = new StringBuffer(1000); @@ -238,17 +227,25 @@ // Tell the stylesheet the URL of the moby data (it will create xpointers to it) contentGUI.getTransformer().setParameter(XSL_DOC_SOURCE_PARAM, url.toString()); // Do the actual transformation - StringWriter stringWriter = new StringWriter(1000); + String htmlContents = "[Seahawk Internal Error]"; try{ + StringWriter stringWriter = new StringWriter(1000); contentGUI.getTransformer().transform(new StreamSource(url.openStream()), new StreamResult(stringWriter)); + htmlContents = stringWriter.toString(); + htmlContents = HTMLUtils.encapsulateBinaryData(url, htmlContents); } catch(TransformerException te){ status.setText("Sorry! Could not transform the MOBY data into presentation form"); logger.error("Sorry! Could not transform the MOBY data into presentation form: " + te); return; } - String htmlContents = stringWriter.toString(); + catch(Exception e){ + 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"); + } // Looks like tab-formatted text (at least 3 tabs)? if(htmlContents.indexOf('\t') != -1){ htmlContents = htmlContents.replaceAll(">(([^<]*\t){3,}[^<]+)", ">
$1
"); @@ -295,6 +292,27 @@ } 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{ + MobyContentInstance mobyContents = + MobyUtils.convertURLtoMobyBinaryData(servicesGUI.getMobyClient(), url); + if(mobyContents != null){ + File mobyRepresentation = File.createTempFile("seahawkBase64BinData", ".xml"); + mobyRepresentation.deleteOnExit(); + FileWriter fw = new FileWriter(mobyRepresentation); + MobyDataUtils.toXMLDocument(fw, mobyContents); + fw.close(); + // Recursive call with new URL, should be displayed using the MOBY XSLT + gotoURL(mobyRepresentation.toURI().toURL(), addToHistory); + return; + } + } catch(Exception e){ + e.printStackTrace(); + editorPane.setText("Failure in loading MOBYfied binary data:\n" + e); + 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); } else{ @@ -311,6 +329,17 @@ ioe.printStackTrace(); } + if(addToHistory){ + // Are we truncating the history? (i.e. loading a new doc in the middle of the history) + if(historyIndex != history.size()-1){ + history.setSize(historyIndex+1); + } + history.add(url); + + historyIndex = history.size()-1; + contentGUI.updateHistory(this); + } + // This page has had a title associated with it before...reuse it! if(historyTabLabels.containsKey(url)){ tabbedPane.setTitleAt(tabbedPane.indexOfComponent(this), historyTabLabels.get(url).toString()); From gordonp at dev.open-bio.org Wed Apr 18 16:06:34 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 18 Apr 2007 12:06:34 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704181606.l3IG6YnG012616@dev.open-bio.org> gordonp Wed Apr 18 12:06:33 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/test In directory dev.open-bio.org:/tmp/cvs-serv12581/src/main/ca/ucalgary/services/test Modified Files: ACDServiceTestCase.java Log Message: Added check of binary data holder to ensure no corruption of the data occurs moby-live/Java/src/main/ca/ucalgary/services/test ACDServiceTestCase.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/test/ACDServiceTestCase.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/services/test/ACDServiceTestCase.java 2007/04/12 00:57:32 1.2 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/test/ACDServiceTestCase.java 2007/04/18 16:06:33 1.3 @@ -24,7 +24,7 @@ private final static String ACDTEST_MOBY_XML = "ca/ucalgary/services/test/mobyDNASeq.xml"; private final static String ACDTEST_BINARY_DATA1 = "ca/ucalgary/services/test/mobyTest1.png"; private final static String ACDTEST_BINARY_DATA2 = "ca/ucalgary/services/test/mobyTest2.png"; - private final static String MOBY_PNG_DATATYPE = "b64_Encoded_PNG"; + private final static String MOBY_PNG_DATATYPE = "PNGFormatImage"; public ACDServiceTestCase(String name){ super(name); @@ -74,6 +74,7 @@ } assertNotNull("The binary test data resource " + u1.toString() + " could not be loaded", binaryDataParts.get(u1.toString())); + try{ binaryDataParts.put(u2.toString(), getURLData(u2)); } catch(Exception e){ @@ -82,6 +83,17 @@ } assertNotNull("The binary test data resource " + u2.toString() + " could not be loaded", binaryDataParts.get(u2.toString())); + // Check that the byte holder class works okay + MobyDataBytes byteObject = null; + try{ + byteObject = new MobyDataBytes("foo", binaryDataParts.get(u2.toString())); + } catch(Exception e){ + e.printStackTrace(); + fail("Could not build a MobyDataBytes object from a byte array: "+ e); + } + assertTrue("The MobyDataBytes object does not return the same byte array " + + "as given in its constructor (data corruption occured)", + Arrays.equals(byteObject.getBytes(), binaryDataParts.get(u2.toString()))); MobyDataObjectSet pngCollectionTemplate = new MobyDataObjectSet("test", new MobyDataObject[]{new MobyDataComposite(MOBY_PNG_DATATYPE)}); From gordonp at dev.open-bio.org Wed Apr 18 16:07:41 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 18 Apr 2007 12:07:41 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704181607.l3IG7fLp012680@dev.open-bio.org> gordonp Wed Apr 18 12:07:41 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services In directory dev.open-bio.org:/tmp/cvs-serv12645/src/main/ca/ucalgary/seahawk/services Modified Files: TextClient.java Log Message: Made less verbose moby-live/Java/src/main/ca/ucalgary/seahawk/services TextClient.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/TextClient.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/services/TextClient.java 2007/04/12 00:59:42 1.2 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/TextClient.java 2007/04/18 16:07:41 1.3 @@ -214,7 +214,7 @@ } if(stringWriter.getBuffer().length() > 0){ - System.err.println("Result of transformation: " + stringWriter.toString()); + //System.err.println("Result of transformation: " + stringWriter.toString()); return stringWriter.toString(); } } From gordonp at dev.open-bio.org Wed Apr 18 16:08:15 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 18 Apr 2007 12:08:15 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704181608.l3IG8FQq012723@dev.open-bio.org> gordonp Wed Apr 18 12:08:15 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv12688/src/main/ca/ucalgary/seahawk/gui Modified Files: MobyServicesGUI.java Log Message: Expose MobyClient for use by other components moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyServicesGUI.java,1.8,1.9 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyServicesGUI.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/MobyServicesGUI.java 2007/04/03 02:34:08 1.8 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyServicesGUI.java 2007/04/18 16:08:15 1.9 @@ -73,6 +73,10 @@ return mobyClient.getMobyCentralImpl(); } + public MobyClient getMobyClient(){ + return mobyClient; + } + public void setClipboard(MobyContentClipboard clip){ clipboard = clip; } From gordonp at dev.open-bio.org Wed Apr 18 16:33:45 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 18 Apr 2007 12:33:45 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704181633.l3IGXjHV012804@dev.open-bio.org> gordonp Wed Apr 18 12:33:45 EDT 2007 Update of /home/repository/moby/moby-live/Java/docs In directory dev.open-bio.org:/tmp/cvs-serv12769/docs Modified Files: ChangeLog Log Message: Noted addition of binary data handling in Seahawk & ACDServlet moby-live/Java/docs ChangeLog,1.76,1.77 =================================================================== RCS file: /home/repository/moby/moby-live/Java/docs/ChangeLog,v retrieving revision 1.76 retrieving revision 1.77 diff -u -r1.76 -r1.77 --- /home/repository/moby/moby-live/Java/docs/ChangeLog 2007/04/03 02:42:23 1.76 +++ /home/repository/moby/moby-live/Java/docs/ChangeLog 2007/04/18 16:33:45 1.77 @@ -1,3 +1,7 @@ +2007-04-18 Paul Gordon + + * Added support for binary data file loading, and Web image display in Seahawk & ACDServlet + 2007-04-02 Paul Gordon * Added asynchronous service call support to MobyRequest, Seahawk, based on client code originally provided by Eddie Kawas. From gss at dev.open-bio.org Wed Apr 25 16:18:01 2007 From: gss at dev.open-bio.org (Gary Schiltz) Date: Wed, 25 Apr 2007 12:18:01 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704251618.l3PGI1mT027733@dev.open-bio.org> gss Wed Apr 25 12:18:01 EDT 2007 Update of /home/repository/moby/server-shared In directory dev.open-bio.org:/tmp/cvs-serv27699/server-shared Log Message: Directory /home/repository/moby/server-shared added to the repository server-shared - New directory rcsdiff: /home/repository/moby/server-shared/RCS/-,v: No such file or directory rcsdiff: /home/repository/moby/server-shared/RCS/New,v: No such file or directory rcsdiff: /home/repository/moby/server-shared/RCS/directory,v: No such file or directory From kawas at dev.open-bio.org Wed Apr 25 17:30:08 2007 From: kawas at dev.open-bio.org (Eddie Kawas) Date: Wed, 25 Apr 2007 13:30:08 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704251730.l3PHU8CN027861@dev.open-bio.org> kawas Wed Apr 25 13:30:08 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/support/registry-servlets In directory dev.open-bio.org:/tmp/cvs-serv27826/Java/src/support/registry-servlets Modified Files: moby.jsp Log Message: service tester html should only be shown if the server hosting the registry servlets enables testing ... moby-live/Java/src/support/registry-servlets moby.jsp,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/support/registry-servlets/moby.jsp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/support/registry-servlets/moby.jsp 2006/11/16 22:00:05 1.1 +++ /home/repository/moby/moby-live/Java/src/support/registry-servlets/moby.jsp 2007/04/25 17:30:08 1.2 @@ -1,79 +1,153 @@ -<%@ page info="Moby Central Servlets" %> +<%@ page info="Moby Central Servlets"%> - + Moby Servlets

BioMOBY Registry Servlets

-


-Update SignatureURLs For your BioMoby Services - Form that aids in the updating of SignatureURLs. This form
-returns valid RDF upon successfully updating your signatureURL.s

-

Client LSID Resolver - Resolve LSIDs to metadata

-
-

To use this servlet, pass the parameter lsid, that is a valid LSID.
- As an example invocation, click here.

-
-

RDFGenerator - Retrieve the RDF representation for your BioMoby Service.

-
-

This servlet takes in the following parameters:

-
    -
  • name - the name of your service
  • -
  • auth - the service providers authority URI
  • -
  • url - an optional mobycentral registry endpoint to use when generating your RDF
  • -
  • uri - an optional mobycentral registry namespace to use when generating your RDF
  • -
-As an example invocation, click here.
-

RDF Agent Test - Invoke the RDF agent on the remote location that houses your RDF.

-
-

This servlets takes as parameter, url, the url to test the agent with.

-

As an example, click here.

-

For a form based page, click here.

-
-

CallableServiceServlet -Use this to determine whether or not a particular service(s) is reachable.

-
-

This servlet takes in the following parameters:

-
    -
  • service - the name of your service <optional>
  • -
  • authority - the service providers authority URI <optional>
  • -
  • getStats - Whether or not to show some statistics <optional> - set parameter to true to see stats
  • -
-

As an example, click here to see a report for all services.
- In addition, to see a report for services by the authority bioinfo.icapture.ubc.ca, click here.
-
-To see a list of unreachable services sorted by service provider, click here.
-To see some stats regarding the percent of alive services, click here.
-Finally, to see whether the service, getGoTerm, by the authority bioinfo.icapture.ubc.ca is alive, click here.
+


+Update SignatureURLs For your +BioMoby Services - Form that aids in the updating of SignatureURLs. This +form
+returns valid RDF upon successfully updating your signatureURL.s

+

Client LSID Resolver - Resolve +LSIDs to metadata

+
+

To use this servlet, pass the parameter lsid, +that is a valid LSID.
+As an example invocation, click here.

+
+

RDFGenerator - Retrieve the RDF +representation for your BioMoby Service.

+
+

This servlet takes in the following parameters:

+
    +
  • name - the name of your service
  • +
  • auth - the service providers + authority URI
  • +
  • url - an optional mobycentral + registry endpoint to use when generating your RDF
  • +
  • uri - an optional mobycentral + registry namespace to use when generating your RDF
  • +
+As an example invocation, click here.
+

RDF Agent Test - Invoke the RDF +agent on the remote location that houses your RDF.

+
+

This servlets takes as parameter, url, +the url to test the agent with.

+

As an example, click here.

+

For a form based page, click +here.

+
+<% + boolean validate = false; + String valString = System.getProperty("DO_SERVICE_VALIDATION"); + if (valString != null && valString.trim().length() != 0) { + validate = Boolean.parseBoolean(valString); + } + if (validate) { +%> +

CallableServiceServlet - Use this +to determine whether or not a particular service(s) is reachable.

+
+

This servlet takes in the following parameters:

+
    +
  • service - the name of your service + <optional>
  • +
  • authority - the service providers + authority URI <optional>
  • +
  • getStats - Whether or not to show + some statistics <optional> - set parameter to true to see + stats
  • +
+

As an example, click here to see a report for all services.
+In addition, to see a report for services by the authority +bioinfo.icapture.ubc.ca, click here.
+
To see a list of unreachable services sorted by service provider, click here.
+To see some stats regarding the percent of alive services, click here.
+Finally, to see whether the service, getGoTerm, by the authority +bioinfo.icapture.ubc.ca is alive, click here.

-

LSID Resolver Client - Using AJAX, retrieve metadata that describes Moby Ontologies..

-
-

As an example, click here.

-
-

LSID Resolver Client 2 - Resolve LSIDs to data and or metadata..

-
-

As an example, click here.

-
-

The Resources 'Scripts' - Servlets that return the RDF representations of the BioMOBY ontologies.

-
-

For example,

-
    -
  1. Object Ontology
  2. -
  3. Namespace Ontology
  4. -
  5. Service Type Ontology
  6. -
  7. Service Instance Ontology
  8. -
-
-

The Types 'Scripts' - Servlets that perform data dumps for the ontologies in a structured manner.

-
-

For example,

-
    -
  1. Object Ontology
  2. -
  3. Namespace Ontology
  4. -
  5. Service Type Ontology
  6. -
+<% +} +%> +

LSID +Resolver Client - Using AJAX, retrieve metadata that describes Moby +Ontologies..

+
+

As an example, click here.

+
+

LSID +Resolver Client 2 - Resolve LSIDs to data and or metadata..

+
+

As an example, click here.

+
+

The +Resources 'Scripts' - Servlets that return the RDF representations of +the BioMOBY ontologies.

+
+

For example,

+
    +
  1. Object + Ontology
  2. +
  3. Namespace + Ontology
  4. +
  5. Service + Type Ontology
  6. +
  7. Service + Instance Ontology
  8. +
+
+

The +Types 'Scripts' - Servlets that perform data dumps for the ontologies +in a structured manner.

+
+

For example,

+
    +
  1. Object + Ontology
  2. +
  3. Namespace + Ontology
  4. +
  5. Service + Type Ontology
  6. +
From kawas at dev.open-bio.org Wed Apr 25 17:31:38 2007 From: kawas at dev.open-bio.org (Eddie Kawas) Date: Wed, 25 Apr 2007 13:31:38 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704251731.l3PHVcxM027946@dev.open-bio.org> kawas Wed Apr 25 13:31:38 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/support/registry-servlets/config In directory dev.open-bio.org:/tmp/cvs-serv27907/Java/src/support/registry-servlets/config Modified Files: context.xml web.xml Log Message: added a boolean variable to determine whether service testing is enabled or not moby-live/Java/src/support/registry-servlets/config context.xml,1.1,1.2 web.xml,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/support/registry-servlets/config/context.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/support/registry-servlets/config/context.xml 2006/11/16 22:00:32 1.1 +++ /home/repository/moby/moby-live/Java/src/support/registry-servlets/config/context.xml 2007/04/25 17:31:38 1.2 @@ -32,6 +32,10 @@ --> + + -org.biomoby.client.ui.graphical.servlet.utilities.RegistryContextListener + + org.biomoby.client.ui.graphical.servlet.utilities.RegistryContextListener + default *.js From kawas at dev.open-bio.org Wed Apr 25 20:32:28 2007 From: kawas at dev.open-bio.org (Eddie Kawas) Date: Wed, 25 Apr 2007 16:32:28 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704252032.l3PKWSdI028242@dev.open-bio.org> kawas Wed Apr 25 16:32:28 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/utilities In directory dev.open-bio.org:/tmp/cvs-serv28203/Java/src/main/org/biomoby/client/ui/graphical/servlet/utilities Modified Files: ContextLoader.java RegistryContextListener.java Log Message: updated the context loader to read in a boolean regarding whether or not to test services. the listener now uses that variable to determine whether or not we are to test the services in the registry. moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/utilities ContextLoader.java,1.2,1.3 RegistryContextListener.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/utilities/ContextLoader.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/ui/graphical/servlet/utilities/ContextLoader.java 2006/10/16 17:23:16 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/utilities/ContextLoader.java 2007/04/25 20:32:28 1.3 @@ -38,6 +38,8 @@ private String FULL_SERVER_URL = ""; private String CONTEXT_PATH = ""; + + private boolean TESTING_SERVICES = false; /** * Constructor loads variables from InitialContext() @@ -115,6 +117,24 @@ log.error("Failure obtaining and setting LSID_PORT:" + System.getProperty("line.separator") + ex.getLocalizedMessage()); } + + // check if the server wants to validate services ... + try { + Boolean validate = false; + validate = (Boolean) c.lookup("java:comp/env/DO_SERVICE_VALIDATION"); + if (validate != null) { + // set DO_SERVICE_VALIDATION + log.info(validate.booleanValue() ? "Service testing is turned on ..." : "Service testing is turned off ..."); + TESTING_SERVICES = validate.booleanValue(); + System.setProperty("DO_SERVICE_VALIDATION", validate.booleanValue() + ""); + } else { + log.info("Service testing is turned off ..."); + } + + } catch (Exception ex) { + log.warn("Failure obtaining and setting DO_SERVICE_VALIDATION:" + + System.getProperty("line.separator") + ex.getLocalizedMessage()); + } } catch (Exception e) { log @@ -343,4 +363,8 @@ return CONTEXT_PATH; } + public boolean isTESTING_SERVICES() { + return TESTING_SERVICES; + } + } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/utilities/RegistryContextListener.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/ui/graphical/servlet/utilities/RegistryContextListener.java 2006/10/25 19:32:54 1.1 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/utilities/RegistryContextListener.java 2007/04/25 20:32:28 1.2 @@ -45,17 +45,19 @@ // add objects to keep to the context - make sure to remove them on destroy! ServletContext servletContext = servletContextEvent.getServletContext(); - try { - Timer timer = new Timer(); - ServiceTesterRunner runner = new ServiceTesterRunner(); - Calendar calendar = Calendar.getInstance(); - Date time = calendar.getTime(); - log.info("Scheduling an on going task: ServiceTester"); - timer.scheduleAtFixedRate(runner, time, 1000 * 60 * 60); - servletContext.setAttribute("tester", runner); - servletContext.setAttribute("timer", timer); - } catch (Exception e) { - + if (cLoader.isTESTING_SERVICES()) { + try { + Timer timer = new Timer(); + ServiceTesterRunner runner = new ServiceTesterRunner(); + Calendar calendar = Calendar.getInstance(); + Date time = calendar.getTime(); + log.info("Scheduling an on going task: ServiceTester"); + timer.scheduleAtFixedRate(runner, time, 1000 * 60 * 60); + servletContext.setAttribute("tester", runner); + servletContext.setAttribute("timer", timer); + } catch (Exception e) { + + } } } @@ -63,9 +65,10 @@ ServletContext servletContext = servletContextEvent.getServletContext(); // here we 'cleanup' all items we placed for 'global' use Timer timer = (Timer)servletContext.getAttribute ("timer"); - if (timer != null) + if (timer != null) { timer.cancel(); - log.info("cancelling on going task: ServiceTester"); + log.info("cancelling on going task: ServiceTester"); + } servletContext.removeAttribute ("timer"); servletContext.removeAttribute ("tester"); } From gordonp at dev.open-bio.org Thu Apr 26 15:05:28 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 26 Apr 2007 11:05:28 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704261505.l3QF5S76032674@dev.open-bio.org> gordonp Thu Apr 26 11:05:27 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data In directory dev.open-bio.org:/tmp/cvs-serv32639/src/main/org/biomoby/shared/data Modified Files: MobyDataSecondaryInstance.java Log Message: Made instance description carried over from template value used in c-tor moby-live/Java/src/main/org/biomoby/shared/data MobyDataSecondaryInstance.java,1.8,1.9 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataSecondaryInstance.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/MobyDataSecondaryInstance.java 2006/12/14 22:18:18 1.8 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataSecondaryInstance.java 2007/04/26 15:05:27 1.9 @@ -37,6 +37,7 @@ setDefaultValue(type.getDefaultValue()); setMinimumValue(type.getMinimumValue()); setMaximumValue(type.getMaximumValue()); + setDescription(type.getDescription()); } /** From gordonp at dev.open-bio.org Thu Apr 26 15:06:16 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 26 Apr 2007 11:06:16 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704261506.l3QF6Gwf032717@dev.open-bio.org> gordonp Thu Apr 26 11:06: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-serv32682/src/main/org/biomoby/shared/data Modified Files: MobyDataObjectSet.java Log Message: Made the containing vector use a Generics construct (MobyDataObject) for type safety moby-live/Java/src/main/org/biomoby/shared/data MobyDataObjectSet.java,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectSet.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/MobyDataObjectSet.java 2006/12/11 18:59:36 1.6 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectSet.java 2007/04/26 15:06:15 1.7 @@ -29,7 +29,7 @@ */ public class MobyDataObjectSet extends MobyPrimaryDataSet implements MobyDataInstance, Collection{ - Vector bag; + Vector bag; private int xmlMode = MobyDataInstance.CENTRAL_XML_MODE; public MobyDataObjectSet(org.w3c.dom.Element e) throws MobyException{ @@ -57,7 +57,7 @@ */ public MobyDataObjectSet(String name){ super(name); - bag = new Vector(); + bag = new Vector(); } /** @@ -95,8 +95,8 @@ boolean first = true; synchronized (bag) { if (bag.size() > 0){ - for (Enumeration en = bag.elements(); en.hasMoreElements(); ){ - MobyDataType objType = ((MobyPrimaryData) en.nextElement()).getDataType(); + for(MobyDataObject member: bag){ + MobyDataType objType = member.getDataType(); // Unknown datatype, break because we can't assume any common lineage for all elements anymore if(objType == null){ break; @@ -149,8 +149,8 @@ Vector namespaces = new Vector(); boolean first = true; synchronized (bag) { - for (Enumeration en = bag.elements(); en.hasMoreElements(); ){ - MobyNamespace[] nsInstances = ((MobyPrimaryData) en.nextElement()).getNamespaces(); + for (MobyDataObject member: bag){ + MobyNamespace[] nsInstances = member.getNamespaces(); Vector newNames = new Vector(); for(int i = 0; nsInstances != null && i < nsInstances.length; i++){ newNames.add(nsInstances[i]); @@ -180,8 +180,9 @@ *************************************************************************/ public void setNamespaces (MobyNamespace[] values) { synchronized (bag) { - for (Enumeration en = bag.elements(); en.hasMoreElements(); ) - ((MobyPrimaryData) en.nextElement()).setNamespaces (values); + for(MobyDataObject member: bag){ + member.setNamespaces(values); + } } } @@ -190,8 +191,9 @@ *************************************************************************/ public void addNamespace (MobyNamespace value) { synchronized (bag) { - for (Enumeration en = bag.elements(); en.hasMoreElements(); ) - ((MobyPrimaryData) en.nextElement()).addNamespace (value); + for (MobyDataObject member: bag){ + member.addNamespace(value); + } } } @@ -201,8 +203,9 @@ *************************************************************************/ public void removeNamespace (String namespaceName) { synchronized (bag) { - for (Enumeration en = bag.elements(); en.hasMoreElements(); ) - ((MobyPrimaryData) en.nextElement()).removeNamespace (namespaceName); + for (MobyDataObject member: bag){ + member.removeNamespace(namespaceName); + } } } @@ -211,8 +214,9 @@ *************************************************************************/ public void removeNamespace (MobyNamespace value) { synchronized (bag) { - for (Enumeration en = bag.elements(); en.hasMoreElements(); ) - ((MobyPrimaryData) en.nextElement()).removeNamespace (value); + for(MobyDataObject member: bag){ + member.removeNamespace(value); + } } } @@ -409,7 +413,7 @@ /** * @return an iterator over the non-null MobyDataObjects in this collection */ - public Iterator iterator(){ + public Iterator iterator(){ return bag.iterator(); } @@ -511,15 +515,12 @@ public String toXML(){ StringBuffer collectionXml = new StringBuffer(); - Iterator membersIterator = bag.iterator(); if(xmlMode == MobyDataInstance.SERVICE_XML_MODE){ collectionXml.append("\n"); - while(membersIterator.hasNext()){ - - MobyDataObject mdsi = (MobyDataObject) membersIterator.next(); + for(MobyDataObject mdsi: bag){ mdsi.setXmlMode(xmlMode); collectionXml.append(""+mdsi.toXML()+""); @@ -534,9 +535,7 @@ collectionXml.append("\n"); Hashtable printed = new Hashtable(); - while(membersIterator.hasNext()){ - - MobyDataObject mdsi = (MobyDataObject) membersIterator.next(); + for(MobyDataObject mdsi: bag){ // Could the DataType be null? I hope not! String objectClass = mdsi.getDataType().getName(); From gordonp at dev.open-bio.org Thu Apr 26 15:08:03 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 26 Apr 2007 11:08:03 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704261508.l3QF83x4000335@dev.open-bio.org> gordonp Thu Apr 26 11:08:03 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client In directory dev.open-bio.org:/tmp/cvs-serv32767/src/main/org/biomoby/client Modified Files: MobyRequest.java Log Message: Added new setInput() method that takes an array of data instances to populate the request (used by Seahawk for multi-param service calls) moby-live/Java/src/main/org/biomoby/client MobyRequest.java,1.24,1.25 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java 2007/04/03 02:22:56 1.24 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java 2007/04/26 15:08:03 1.25 @@ -192,6 +192,19 @@ } /** + * Takes the data in the array, with their current articleNames, as input for the service + */ + public void setInput(MobyDataInstance[] data) throws MobyException{ + MobyDataJob job = new MobyDataJob(); + for(MobyDataInstance param: data){ + System.err.println("Adding job param " + param.getName()); + job.put(param.getName(), param); + } + inputData = new MobyContentInstance(); + inputData.put(job); + } + + /** * Convenience method to run services that take one argument. If the service * requires the input to have a name, it will be automatically assigned. */ From gordonp at dev.open-bio.org Thu Apr 26 15:11:19 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 26 Apr 2007 11:11:19 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704261511.l3QFBJBa000417@dev.open-bio.org> gordonp Thu Apr 26 11:11:19 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-serv386/src/main/ca/ucalgary/seahawk/resources/images Added Files: attention.gif checkmark.gif Log Message: Small icons used by MobyDataObjectWidget to denote the state of the object instantiation moby-live/Java/src/main/ca/ucalgary/seahawk/resources/images attention.gif,NONE,1.1 checkmark.gif,NONE,1.1 From gordonp at dev.open-bio.org Thu Apr 26 15:15:45 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 26 Apr 2007 11:15:45 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704261515.l3QFFj0g000565@dev.open-bio.org> gordonp Thu Apr 26 11:15:45 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv530/src/main/ca/ucalgary/seahawk/gui Modified Files: FileAndTextTransferHandler.java Log Message: Refactored several aspects of the transfer handler for easier extension moby-live/Java/src/main/ca/ucalgary/seahawk/gui FileAndTextTransferHandler.java,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/FileAndTextTransferHandler.java,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/gui/FileAndTextTransferHandler.java 2007/03/23 20:23:52 1.4 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/FileAndTextTransferHandler.java 2007/04/26 15:15:45 1.5 @@ -1,5 +1,6 @@ package ca.ucalgary.seahawk.gui; +import ca.ucalgary.seahawk.util.HTMLUtils; import org.biomoby.shared.MobyPrefixResolver; import org.biomoby.shared.data.*; import org.biomoby.shared.parser.MobyTags; @@ -21,21 +22,18 @@ * windowing system, so dropped files, URLs and string can be loaded into * tabs. Dragging from Seahawk tabs is not yet supported. */ -class FileAndTextTransferHandler extends TransferHandler { +public class FileAndTextTransferHandler extends TransferHandler { private DataFlavor fileFlavor, stringFlavor; private MobyContentGUI gui; - private JTextArea source; - private boolean shouldRemove; - protected String newline = "\n"; - FileAndTextTransferHandler(MobyContentGUI mcg) { + public FileAndTextTransferHandler(MobyContentGUI mcg) { gui = mcg; fileFlavor = DataFlavor.javaFileListFlavor; stringFlavor = DataFlavor.stringFlavor; } 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; @@ -46,63 +44,27 @@ if (hasFileFlavor(t.getTransferDataFlavors())) { // Load any dragged file as a URL for (File file: (java.util.List) t.getTransferData(DataFlavor.javaFileListFlavor)) { - String fileString = file.toURI().toURL().toString().toLowerCase(); - // Windows Web shortcut? - URL u = null; - if(fileString.lastIndexOf(".url") == fileString.length()-4){ - LineNumberReader in = new LineNumberReader( - new InputStreamReader(file.toURI().toURL().openStream())); - for(String line = in.readLine(); line != null; line = in.readLine()){ - int urlIndex = line.indexOf("URL="); - if(line.indexOf("URL=") == 0){ - try{ - u = new URL(line.substring(4)); - } catch(MalformedURLException murle){ - System.err.println("Could not format " +line); - murle.printStackTrace(); - // Not a URL, but really it should have been. - // oh well, move on to normal file loading... - } - break; // done with this file as a URL, no need to execute other loadPaneFromURL - } - } - } + URL u = HTMLUtils.checkForURLShortcut(file); // Was it a shortcut file after all? if(u != null){ + System.err.println("Dropped item appears to be a URL shortcut..."); gui.loadPaneFromURL(u, true); } // Any other type of file is loaded as-is else{ + System.err.println("Dropped item appears to be a file..."); gui.loadPaneFromURL(file.toURI().toURL(), true); } } return true; } else if (hasTextFlavor(t.getTransferDataFlavors())) { // Make a string out of the text - StringBuffer textBuffer = new StringBuffer(); - Reader reader = DataFlavor.selectBestTextFlavor(t.getTransferDataFlavors()).getReaderForText(t); - //Reader reader = DataFlavor.plainTextFlavor.getReaderForText(t); - char[] buffer = new char[1024]; - for(int charsRead = reader.read(buffer); charsRead != -1; charsRead = reader.read(buffer)){ - textBuffer.append(buffer, 0, charsRead); - } - // Some readers put funny nulls before each char (8->16 bit char encoding goof) - String text = textBuffer.toString().replaceAll("\00", ""); + boolean NOT_JUST_PLAIN_TEXT = false; + String text = convertToString(t, NOT_JUST_PLAIN_TEXT); // Is it an address bar icon dragged from firefox? Strip the surrounding html - String linktext = null; - if(text.indexOf("") == text.length()-11){ - linktext = text.substring(15, text.indexOf("\"",15)); - } - else if(text.indexOf("") == text.length()-4){ //unix - linktext = text.substring(9, text.indexOf("\"",9)); - } - else if(text.indexOf("") != -1){ - int startHref = text.indexOf("")+1); - xmltext = xmltext.replaceAll(">", ">"); - xmltext = xmltext.replaceAll("<", "<"); - xmltext = xmltext.replaceAll("&", "&"); - } - xmltext = xmltext.trim(); // remove leading and trailing spaces - MobyContentInstance content = null; - try{ - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - dbf.setNamespaceAware (true); - DocumentBuilder db = dbf.newDocumentBuilder(); - if(xmltext.indexOf("xmlns:moby") == -1){ - // Ensure that the moby: prefix is declared in the first tag - xmltext = xmltext.replaceFirst("<([A-Za-z0-9_][^> \t\n]*)", "<$1 xmlns:moby=\""+ - MobyPrefixResolver.MOBY_XML_NAMESPACE+"\""); - } - if(xmltext.indexOf("\n" + xmltext; - } - - org.w3c.dom.Element data = db.parse(new ByteArrayInputStream(xmltext.getBytes())).getDocumentElement(); - if(data.getLocalName().equals(MobyTags.MOBY)){ - content = MobyDataUtils.fromXMLDocument(data); - } - else if(data.getLocalName().equals(MobyTags.MOBYCONTENT)){ - content = new MobyContentInstance(data); - } - else if(data.getLocalName().equals(MobyTags.MOBYDATA)){ - content = new MobyContentInstance(); - content.parseDataGroup(data); - } - else{ - // Any other data can be processed by the base object class - content = new MobyContentInstance(MobyDataObject.createInstanceFromDOM(data), "Drag 'n' Drop data"); - } - - if(content != null){ - gui.loadPaneFromObject(content, true); - return true; - } - } catch(Exception e){ - // Not good MOBY XML, oh well, lets fall back on the HTML-based display below... - e.printStackTrace(); - } + MobyContentInstance content = HTMLUtils.checkForMobyXML(text); + if(content != null){ + System.err.println("Dropped item appears to be moby xml..."); + gui.loadPaneFromObject(content, true); + return true; } // Otherwise save the data to a temp file and load it as a URL @@ -206,21 +121,44 @@ gui.loadPaneFromURL(savedFile.toURI().toURL(), true); return true; } + else{ + System.err.println("Cannot drop data into Seahawk, data was neither a file, nor text"); + } } catch (UnsupportedFlavorException ufe) { - System.out.println("importData: unsupported data flavor"); - } catch (IOException ieo) { - System.out.println("importData: I/O exception"); - } + System.out.println("importData: unsupported data flavor:"+ufe); + } catch (IOException ioe) { + ioe.printStackTrace(); + System.out.println("importData: I/O exception: "+ioe); + } catch (Exception e){ + e.printStackTrace(); + System.out.println("importData: General exception: "+e); + } return false; } - public boolean canImport(JComponent c, DataFlavor[] flavors) { + public String convertToString(Transferable t, boolean get_plain_text) throws Exception{ + StringBuffer textBuffer = new StringBuffer(); + Reader reader = get_plain_text ? DataFlavor.plainTextFlavor.getReaderForText(t) : + DataFlavor.selectBestTextFlavor(t.getTransferDataFlavors()).getReaderForText(t); + char[] buffer = new char[4096]; + for(int charsRead = reader.read(buffer); charsRead != -1; charsRead = reader.read(buffer)){ + textBuffer.append(buffer, 0, charsRead); + } + // Some readers put funny nulls before each char (8->16 bit char encoding goof) + return textBuffer.toString().replaceAll("\00", ""); + } + + /** + * Overrides same method in parent class, tells the dropper if we'll accept the data + * before the drop is actually attempted. + */ + public boolean canImport(JComponent comp, DataFlavor[] flavors) { if (hasFileFlavor(flavors)) { return true; } if (hasTextFlavor(flavors)) { return true; } return false; } - private boolean hasFileFlavor(DataFlavor[] flavors) { + protected boolean hasFileFlavor(DataFlavor[] flavors) { for (DataFlavor flavor: flavors) { if (flavor.isFlavorJavaFileListType()) { return true; @@ -229,7 +167,7 @@ return false; } - private boolean hasTextFlavor(DataFlavor[] flavors) { + protected boolean hasTextFlavor(DataFlavor[] flavors) { for (DataFlavor flavor: flavors) { if (flavor.isFlavorTextType()) { return true; From gordonp at dev.open-bio.org Thu Apr 26 15:15:45 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 26 Apr 2007 11:15:45 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704261515.l3QFFjBr000585@dev.open-bio.org> gordonp Thu Apr 26 11:15:45 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util In directory dev.open-bio.org:/tmp/cvs-serv530/src/main/ca/ucalgary/seahawk/util Modified Files: HTMLUtils.java Log Message: Refactored several aspects of the transfer handler for easier extension moby-live/Java/src/main/ca/ucalgary/seahawk/util HTMLUtils.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/HTMLUtils.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/HTMLUtils.java 2007/04/18 16:02:09 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/HTMLUtils.java 2007/04/26 15:15:45 1.2 @@ -1,9 +1,14 @@ package ca.ucalgary.seahawk.util; +import org.biomoby.shared.*; import org.biomoby.shared.data.*; +import org.biomoby.shared.parser.MobyTags; + +import javax.xml.parsers.*; import java.io.*; -import java.net.URL; +import java.net.*; + public class HTMLUtils{ @@ -55,4 +60,142 @@ return html; } + /** + * Extracts a URL string from a given piece of text iof that's all it contains. + * Especially suited for dropped URL's etc. from browsers, as it cleans up the HTML junk + * browsers wrap links in. + */ + public static String checkForHyperlinkText(String text){ + if(text.indexOf("") == text.length()-11){ + return text.substring(15, text.indexOf("\"",15)); + } + else if(text.indexOf("") == text.length()-4){ //unix + return text.substring(9, text.indexOf("\"",9)); + } + else if(text.indexOf("") != -1){ + int startHref = text.indexOf(""+text+""; + } + + StringBuffer result = new StringBuffer(""); + int lineCharCount = 0; + String[] tokens = text.split("[ \t\n]"); + for(String word: tokens){ + while(word.length()+1 > maxLineLength){ //single word is bigger than preset width, hyphenate + int cutPoint = maxLineLength - lineCharCount - 1; + result.append(word.substring(0, cutPoint)+"-
"); + lineCharCount = 0; + word = word.substring(cutPoint); + } + if(lineCharCount != 0 && lineCharCount + word.length() > maxLineLength){ + result.append("
" + word + " "); + lineCharCount = word.length()+1; + continue; + } + result.append(word+" "); + lineCharCount += word.length()+1; + } + result.append(""); + + return result.toString(); + } + + /** + * Given an HTML fragment (e.g. cut'n'pasted from a browser), see if we unescape the + * HTML we get a MOBY XML block (e.g. from the biomoby.org web site examples). + */ + public static MobyContentInstance checkForMobyXML(String text){ + if(//(text.indexOf("moby:") != -1 || text.indexOf("articleName=\"") != -1) && + text.indexOf("namespace=\"") == -1 || + text.indexOf("id=\"") == -1){ + return null; + } + + MobyContentInstance content = null; + String xmltext = text; + // See if the xml needs unescaping (e.g. if preformatted HTML dropped from Firefox or Thunderbird) + int preStart = xmltext.indexOf("")+1); + xmltext = xmltext.replaceAll(">", ">"); + xmltext = xmltext.replaceAll("<", "<"); + xmltext = xmltext.replaceAll("&", "&"); + } + xmltext = xmltext.trim(); // remove leading and trailing spaces + try{ + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + dbf.setNamespaceAware (true); + DocumentBuilder db = dbf.newDocumentBuilder(); + if(xmltext.indexOf("xmlns:moby") == -1){ + // Ensure that the moby: prefix is declared in the first tag + xmltext = xmltext.replaceFirst("<([A-Za-z0-9_][^> \t\n]*)", "<$1 xmlns:moby=\""+ + MobyPrefixResolver.MOBY_XML_NAMESPACE+"\""); + } + if(xmltext.indexOf("\n" + xmltext; + } + + org.w3c.dom.Element data = db.parse(new ByteArrayInputStream(xmltext.getBytes())).getDocumentElement(); + if(data.getLocalName().equals(MobyTags.MOBY)){ + content = MobyDataUtils.fromXMLDocument(data); + } + else if(data.getLocalName().equals(MobyTags.MOBYCONTENT)){ + content = new MobyContentInstance(data); + } + else if(data.getLocalName().equals(MobyTags.MOBYDATA)){ + content = new MobyContentInstance(); + content.parseDataGroup(data); + } + else{ + // Any other data can be processed by the base object class + content = new MobyContentInstance(MobyDataObject.createInstanceFromDOM(data), "Drag 'n' Drop data"); + } + } catch(Exception e){ + e.printStackTrace(); + } + return content; + } } From gordonp at dev.open-bio.org Thu Apr 26 15:19:58 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 26 Apr 2007 11:19:58 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704261519.l3QFJwIh000668@dev.open-bio.org> gordonp Thu Apr 26 11:19: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-serv637/src/main/ca/ucalgary/seahawk/gui Added Files: MobyDataObjectWidget.java MobyObjectReceiver.java MobyObjectTransferHandler.java Log Message: GUI components added in support of direct manipulation of multiple parameters for Moby service input moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyDataObjectWidget.java,NONE,1.1 MobyObjectReceiver.java,NONE,1.1 MobyObjectTransferHandler.java,NONE,1.1 From gordonp at dev.open-bio.org Thu Apr 26 15:22:27 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 26 Apr 2007 11:22:27 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704261522.l3QFMRB1000753@dev.open-bio.org> gordonp Thu Apr 26 11:22: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-serv718/src/main/ca/ucalgary/seahawk/services Modified Files: MobyClient.java Log Message: Small method sig and doc updates moby-live/Java/src/main/ca/ucalgary/seahawk/services MobyClient.java,1.11,1.12 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.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/services/MobyClient.java 2007/04/18 16:01:00 1.11 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java 2007/04/26 15:22:27 1.12 @@ -740,11 +740,11 @@ return new MobyDataObject[0]; } - // Vector of moby objects we construct based on the xpath mappings found + // Vector of moby objects we construct based on the regex mappings found Vector objectVector = new Vector(); Iterator regex_keys = regexMap.keySet().iterator(); - while(regex_keys.hasNext()){ //map still has untraversed xpath entry to test + while(regex_keys.hasNext()){ //map still has untraversed regex entry to test Pattern pattern = (Pattern) regex_keys.next(); Matcher matcher = pattern.matcher(textData); @@ -771,29 +771,44 @@ * Using the URL regular expression mappings that have been set up, * maps a string to moby objects. URL regexs are special because they are * flexible in the order in which query parameters are given. They - * may also have requirements based on the hypertext linked. + * may also have requirements based on the hypertext linked. This method + * does not look at the contents of the URL, but rather the URL itself. */ public MobyDataObject[] getMobyObjects(URL url){ - return getMobyObjects(url, null); + return getMobyObjects(url, null, null); } public MobyDataObject[] getMobyObjects(URL url, String linkText){ + return getMobyObjects(url, linkText, null); + } + + public MobyDataObject[] getMobyObjects(URL url, MobyDataType targetDataType){ + return getMobyObjects(url, null, targetDataType); + } + + public MobyDataObject[] getMobyObjects(URL url, String linkText, MobyDataType targetDataType){ if(urlRegexMap.isEmpty()){ System.out.println("The MOBY Client has not been provided any url regex->moby data mappings!"); return new MobyDataObject[0]; } - // Vector of moby objects we construct based on the xpath mappings found + // Vector of moby objects we construct based on the regex mappings found Vector objectVector = new Vector(); String urlString = url.toString(); Iterator url_regex_keys = urlRegexMap.keySet().iterator(); - while(url_regex_keys.hasNext()){ // map still has untraversed xpath entry to test + while(url_regex_keys.hasNext()){ // map still has untraversed regex entry to test Pattern pattern = (Pattern) url_regex_keys.next(); + MobyComplexBuilder rule = (MobyComplexBuilder) urlRegexMap.get(pattern); + + // If we asked for a particular data type, make sure the rule can produce it before we + // start to go matching it. + if(targetDataType != null && !rule.getDataType().inheritsFrom(targetDataType)){ + continue; + } Matcher matcher = pattern.matcher(urlString); while(matcher.find()){ - MobyComplexBuilder rule = (MobyComplexBuilder) urlRegexMap.get(pattern); try{ MobyDataObject mobyObj = rule.apply(matcher); From gordonp at dev.open-bio.org Thu Apr 26 15:23:59 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 26 Apr 2007 11:23:59 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704261523.l3QFNx94000819@dev.open-bio.org> gordonp Thu Apr 26 11:23:59 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv784/src/main/ca/ucalgary/seahawk/gui Modified Files: MobyContentGUI.java Log Message: Minor fix to allow tab close when 2 tabs and no clipboard showing moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyContentGUI.java,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.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/MobyContentGUI.java 2007/04/18 15:57:00 1.7 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java 2007/04/26 15:23:59 1.8 @@ -846,7 +846,8 @@ } if(tabbedPane.getComponentAt(index) == clipboard && tabbedPane.getTabCount() > 1 || - tabbedPane.getTabCount() > 2){ + tabbedPane.getTabCount() > 2 || + tabbedPane.indexOfComponent(clipboard) == -1 && tabbedPane.getTabCount() >= 2){ item = new JMenuItem(MobyContentGUI.CLOSE_OTHERS_OPTION); item.setActionCommand(MobyContentGUI.CLOSE_OTHERS_OPTION); item.addActionListener(gui); From gordonp at dev.open-bio.org Thu Apr 26 15:25:13 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 26 Apr 2007 11:25:13 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704261525.l3QFPDvh000883@dev.open-bio.org> gordonp Thu Apr 26 11:25:13 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv848/src/main/ca/ucalgary/seahawk/gui Modified Files: MobySecondaryInputGUI.java Log Message: Added proper multi-primary parameter support, and tooltip formatting for secondary parameters moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobySecondaryInputGUI.java,1.5,1.6 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobySecondaryInputGUI.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/MobySecondaryInputGUI.java 2007/04/12 01:03:14 1.5 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobySecondaryInputGUI.java 2007/04/26 15:25:13 1.6 @@ -1,21 +1,22 @@ package ca.ucalgary.seahawk.gui; -import org.biomoby.shared.data.MobyDataSecondaryInstance; -import org.biomoby.shared.MobySecondaryData; +import ca.ucalgary.seahawk.services.MobyClient; +import ca.ucalgary.seahawk.util.HTMLUtils; +import org.biomoby.shared.data.*; +import org.biomoby.shared.*; import java.awt.*; import javax.swing.*; import javax.swing.text.JTextComponent; import java.awt.event.*; -import java.util.Map; -import java.util.HashMap; -import java.util.Iterator; +import java.util.*; /** * A class that generates a GUI to fill in (instantiate or change) the values of Secondary Input to MOBY services. */ public class MobySecondaryInputGUI extends JDialog implements ActionListener, Runnable { + public final static int MAX_TOOLTIP_WIDTH = 40; public final static int INT_CHOICE_MAX = 100; public final static int DEFAULT_TEXT_SIZE = 12; public final static String UNBOUNDED_INT_RANGE_DESC = "[integer]"; @@ -23,6 +24,7 @@ public final static String TITLE = "Secondary Inputs for MOBY Service"; public final static String OK_BUTTON_NAME = "MSIGexecuteButton"; + private MobyPrimaryData[] inputsPrimary = null; private MobyDataSecondaryInstance[] inputs = null; private JButton cancelButton; private String cancelMessage = "Cancel"; @@ -34,35 +36,38 @@ private ActionListener listener; private int handlerCode = 0; // callback event ID provided by caller to c-tor private boolean showingNew = false; + private MobyClient mobyClient; private static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(MobySecondaryInputGUI.class); - public MobySecondaryInputGUI(ActionListener al, Frame owner, boolean modal){ - this(al, owner, modal, 0); + public MobySecondaryInputGUI(ActionListener al, Frame owner, boolean modal, MobyClient client){ + this(al, owner, modal, 0, client); } /** * @param al the object to receive the "all done" callback * @param actionCommandID the id to give back as the event ID during callback */ - public MobySecondaryInputGUI(ActionListener al, Frame owner, boolean modal, int actionCommandID){ + public MobySecondaryInputGUI(ActionListener al, Frame owner, boolean modal, int actionCommandID, MobyClient client){ super(owner, modal); setup(); listener = al; handlerCode = actionCommandID; + mobyClient = client; setVisible(false); showingNew = false; setName(TITLE); } - public MobySecondaryInputGUI(ActionListener al){ - this(al, 0); + public MobySecondaryInputGUI(ActionListener al, MobyClient client){ + this(al, 0, client); } - public MobySecondaryInputGUI(ActionListener al, int actionCommandID){ + public MobySecondaryInputGUI(ActionListener al, int actionCommandID, MobyClient client){ super(); setup(); listener = al; + mobyClient = client; handlerCode = actionCommandID; setVisible(false); } @@ -121,19 +126,24 @@ } public void fillIn(MobyDataSecondaryInstance[] secondaryInputs, boolean showGUI){ - if(secondaryInputs == null){ + fillIn(null, secondaryInputs, showGUI); + } + + public void fillIn(MobyPrimaryData[] primaryInputs, MobyDataSecondaryInstance[] secondaryInputs, boolean showGUI){ + // If more than 1 primary input parameter, need to disable + // submission until these fields are filled in too. + if(!setupPrimaryInput(primaryInputs) && secondaryInputs == null){ run(); //should do callback return; } inputs = secondaryInputs; - java.util.Arrays.sort(inputs); // Create a thread here to prevent possible AWT-EventQueue deadlock // when widgets are added and the thread of caller of the method was // the AWT-EventQueue. - WidgetCreatorThread widgetMaker = new WidgetCreatorThread(showGUI); + WidgetCreatorThread widgetMaker = new WidgetCreatorThread(showGUI, true); if(!showGUI){ // Call synchronous to ensure data is present before returning widgetMaker.run(); @@ -145,11 +155,31 @@ } + /** + * Is there more than one primary parameter? Do we need to populate it? + * @return true if we can submit the job as is, otherwise false (data still needs to be filled in) + */ + protected boolean setupPrimaryInput(MobyPrimaryData[] primaryInputs){ + confirmButton.setEnabled(true); //unless otherwise noted, we can submit + if(primaryInputs != null){ + inputsPrimary = primaryInputs; + for(MobyPrimaryData primary: inputsPrimary){ + if(!(primary instanceof MobyDataInstance)){ + // a primary parameter has not yet been instantiated + confirmButton.setEnabled(false); + } + } + } + return confirmButton.isEnabled(); + } + class WidgetCreatorThread extends Thread{ private boolean showGUI; + private boolean showSinglePrimaryInput; - public WidgetCreatorThread(boolean b){ - showGUI = b; + public WidgetCreatorThread(boolean gui, boolean single){ + showGUI = gui; + showSinglePrimaryInput = single; } public void run(){ @@ -159,10 +189,24 @@ setVisible(true); } - // Add a widget for each input value - for(int i = 0; i < inputs.length; i++){ - optionsPanel.add(makeWidget(inputs[i])); + if(!confirmButton.isEnabled() || showSinglePrimaryInput){ + //java.util.Arrays.sort(inputsPrimary); + for(MobyPrimaryData input: inputsPrimary){ + optionsPanel.add(makeWidget(input)); + } + + // Visually separate the primary and secondary inputs + optionsPanel.add(new JSeparator()); + } + + // Sort the parameters alphabetically + Arrays.sort(inputs); // MobyDataSecondaryInstance implements Comparable + + // Add a widget for each secondary param + for(MobyDataSecondaryInstance input: inputs){ + optionsPanel.add(makeWidget(input)); } + // Make the window the preferred size of its widget contents if(showGUI){ pack(); @@ -182,6 +226,22 @@ return ret; } + public Component makeWidget(MobyPrimaryData data){ + boolean DATA_EDITABLE = true; + MobyDataObjectWidget primaryDataWidget = null; + // Choose c-tor based on if param is instantiated or not + if(data instanceof MobyDataInstance){ + primaryDataWidget = new MobyDataObjectWidget(data.getName(), mobyClient, (MobyDataInstance) data, DATA_EDITABLE); + } + else{ + primaryDataWidget = new MobyDataObjectWidget(data.getName(), mobyClient, data); + } + // We want to get informed of updates to the data, as this + // may change whether the dialog should be submittable or not + primaryDataWidget.addActionListener(this); + return primaryDataWidget; + } + public Component makeWidget(MobyDataSecondaryInstance msdi){ String dataType = msdi.getDataType(); @@ -410,7 +470,7 @@ if(desc == null || desc.length() == 0){ desc = "Sorry, no description of this input is available from the service provider"; } - label.setToolTipText(desc); + label.setToolTipText(HTMLUtils.htmlifyToolTipText(desc, MAX_TOOLTIP_WIDTH)); return label; } @@ -441,6 +501,25 @@ else if(source == cancelButton){ dispose(); } + // Primary input data update + else if(source instanceof MobyDataObjectWidget){ + MobyPrimaryData newData = ((MobyDataObjectWidget) source).getData(); + String newDataName = ((MobyDataObjectWidget) source).getName(); + boolean enableSubmit = true; + + // Copy the new data value to the original array + for(int i = 0; i < inputsPrimary.length; i++){ + if(inputsPrimary[i].getName().equals(newDataName)){ + newData.setName(newDataName); + inputsPrimary[i] = newData; + } + // Is there still some uninstantiated data? + if(enableSubmit && !(inputsPrimary[i] instanceof MobyDataInstance)){ + enableSubmit = false; + } + } + confirmButton.setEnabled(enableSubmit); + } else{ logger.warn("Unrecognized event source (" + source + ") in " + getClass()); } From gordonp at dev.open-bio.org Thu Apr 26 15:26:25 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 26 Apr 2007 11:26:25 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704261526.l3QFQPXh000947@dev.open-bio.org> gordonp Thu Apr 26 11:26:24 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv912/src/main/ca/ucalgary/seahawk/gui Modified Files: MobyServicesGUI.java Log Message: Added support for multiple primary input parameters to a service, and fixed up tooltip formatting moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyServicesGUI.java,1.9,1.10 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyServicesGUI.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/MobyServicesGUI.java 2007/04/18 16:08:15 1.9 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyServicesGUI.java 2007/04/26 15:26:24 1.10 @@ -1,6 +1,7 @@ package ca.ucalgary.seahawk.gui; import ca.ucalgary.seahawk.services.MobyClient; +import ca.ucalgary.seahawk.util.HTMLUtils; import javax.swing.*; import org.w3c.dom.*; import org.biomoby.shared.*; @@ -13,6 +14,7 @@ import java.awt.*; import java.io.*; import java.text.Collator; +import java.net.URL; import java.util.*; import javax.swing.event.PopupMenuListener; import javax.swing.event.PopupMenuEvent; @@ -47,6 +49,7 @@ MobyDataServiceAssocInstance[] ms; MobyDataSecondaryInstance[] secondaryInputInstances = null; + MobyPrimaryData[] primaryInput = null; int maxDataDesc = 22; private HashMap service2submenu; //tracks nested submenus to root submenus of choices popup private HashMap submenu2msIndex; @@ -174,23 +177,50 @@ } public void setupServiceSecondaryData(MobyRequestEventHandler handler){ + MobyDataInstance[] castInputs = new MobyDataInstance[primaryInput.length]; + System.err.println("Submitting job with " + primaryInput.length + " parameters"); + for(int i = 0; i < primaryInput.length; i++){ + if(!(primaryInput[i] instanceof MobyDataInstance)){ + logger.warn("Warning: setupServiceSecondaryData was called before the primary input" + + " for the service was instantiated, ignoring the call. Object found was" + + " of class "+primaryInput[i].getClass().getName()); + return; + } + castInputs[i] = (MobyDataInstance) primaryInput[i]; + } + + try{ + mobyRequest.setInput(castInputs); + } catch(MobyException me){ + me.printStackTrace(); + logger.warn("Error while trying to set service input: " + me); + } mobyRequest.setSecondaryInput(secondaryInputInstances); executeService(handler); } protected void setupService(MobyService mobyService, MobyDataInstance mdi, int handlerHashCode, boolean useDefaultSecondaries){ - mobyRequest.setDebugMode(System.getProperty("moby.debug") != null); - mobyRequest.setService(mobyService); - // We only implement simple input for now (i.e. only one input argument) - try{ - mobyRequest.setInput(mdi, ""); - } - catch(MobyException me){ - logger.error("Failure in MOBY input, was not acceptable:" + me); + if(!(mdi instanceof MobyPrimaryData)){ + logger.error("Failure in MOBY input, was not primary data as expected, but rather "+mdi.getClass().getName()); return; } + + mobyRequest.setDebugMode(System.getProperty("moby.debug") != null); + mobyRequest.setService(mobyService); + MobyPrimaryData[] primaryInputTemplate = mobyService.getPrimaryInputs(); + primaryInput = new MobyPrimaryData[primaryInputTemplate.length]; + System.arraycopy(primaryInputTemplate, 0, primaryInput, 0, primaryInput.length); if(!hasSecondaryInput(mobyService)){ + try{ + // Implement simple input (i.e. only one input argument) + mobyRequest.setInput(mdi, ""); + } + catch(MobyException me){ + logger.error("Failure in MOBY input, was not acceptable:" + me); + return; + } + // No need for further info, just launch the request removePopupOptions(); executeService(getHandlerByHashCode(handlerHashCode)); @@ -198,14 +228,55 @@ else{ // We need more info from the user to launch this service //logger.warn("Need to get secondary parameters: " + secondaryInputTemplate.getClass()); - MobyData[] secondaryInputTemplate = mobyService.getSecondaryInputs(); - getSecondaryInput((MobySecondaryData[]) secondaryInputTemplate, handlerHashCode, useDefaultSecondaries); + MobyService metaDataMobyService = MobyService.getService(mobyService.getName(), mobyService.getAuthority()); + + // We need to figure out where the provided data instance goes into the parameter list for the service + Vector paramMatch = new Vector(); + int paramMatchDefault = 0; + MobyDataType providedDataType = ((MobyPrimaryData) mdi).getDataType(); + for(MobyPrimaryData input: primaryInput){ + if(providedDataType.inheritsFrom(input.getDataType())){ + paramMatch.add(input.getName()); + } + } + if(paramMatch.size() == 0){ + logger.error("Failure in MOBY input, could not match the input (" +providedDataType.getName() + + ") to any service param for service "+mobyService.getName()); + return; + } + + String targetParamName = paramMatch.elementAt(0); + // Need to choose among multiple parameters + if(paramMatch.size() > 1){ + targetParamName = (String) JOptionPane.showInputDialog(null, + "Choose the service parameter the chosen " + + "object represents", + "Service Parameter Choice", + JOptionPane.QUESTION_MESSAGE, + null, + paramMatch.toArray(), + paramMatch.elementAt(paramMatchDefault)); + } + // Finds the matching param and set it + for(int i = 0; i < primaryInput.length; i++){ + if(targetParamName.equals(primaryInput[i].getName())){ + mdi.setName(targetParamName); + primaryInput[i] = (MobyPrimaryData) mdi; + } + } + + // We need to create the secondary parameters too, and launch the dialog to fill in the + // uninstantiated data. + getSecondaryInput(metaDataMobyService, handlerHashCode, useDefaultSecondaries); } } + // True if there are secondaries, or more than one primary input + // (which also needs the dialog for user data instantiation) private boolean hasSecondaryInput(MobyService mobyService){ MobyData[] secondaryInputTemplate = mobyService.getSecondaryInputs(); - return secondaryInputTemplate != null && secondaryInputTemplate.length != 0; + return secondaryInputTemplate != null && secondaryInputTemplate.length != 0 || + mobyService.getPrimaryInputs().length > 1; } /** @@ -233,11 +304,14 @@ * Launches a dialog that the user can configure secondary parameters in, * or tries to fill in and use all defaults if valid and useDefaults is specified. */ - protected void getSecondaryInput(MobySecondaryData[] secondaryInputTemplate, int handlerHashCode, boolean useDefaults){ + protected void getSecondaryInput(MobyService mobyService, int handlerHashCode, boolean useDefaults){ + MobySecondaryData[] secondaryInputTemplate = mobyService.getSecondaryInputs(); if(secondaryGUI == null){ - secondaryGUI = new MobySecondaryInputGUI(this, handlerHashCode); + secondaryGUI = new MobySecondaryInputGUI(this, handlerHashCode, mobyClient); } + // Create the param array that will be modified in the secondary dialog and used + // after the callback to run the service. secondaryInputInstances = new MobyDataSecondaryInstance[secondaryInputTemplate.length]; for(int i = 0; i < secondaryInputInstances.length; i++){ @@ -249,7 +323,8 @@ return; } // The GUI will perform a callback when the user is done the input - secondaryGUI.fillIn(secondaryInputInstances); + boolean SHOW_DIALOG = true; + secondaryGUI.fillIn(primaryInput, secondaryInputInstances, SHOW_DIALOG); } /** @@ -943,19 +1018,12 @@ String serviceDesc = service.getDescription(); String serviceAuthority = service.getAuthority(); if(serviceDesc != null && serviceDesc.length() > 0){ - if(serviceDesc.length() > MAX_SERVICE_DESC_LEN){ - serviceDesc = htmlifyToolTipText(serviceDesc); + if(serviceAuthority != null && serviceAuthority.length() > 0){ + serviceDesc += " [" + serviceAuthority + "]"; } + serviceDesc = HTMLUtils.htmlifyToolTipText(serviceDesc, MAX_SERVICE_DESC_LEN); sdesc = serviceDesc; } - if(serviceAuthority != null && serviceAuthority.length() > 0){ - if(sdesc == null){ - sdesc = serviceAuthority; - } - else{ - sdesc += " [" + serviceAuthority + "]"; - } - } if(sdesc != null){ mobyItem.setToolTipText(sdesc); } @@ -987,10 +1055,7 @@ } String menuToolTip = commonAncestorDesc + type.getDescription(); - if(menuToolTip.length() > MAX_SERVICE_DESC_LEN){ - // Cut down really long ancestry descs to the last part (most precise) - menuToolTip = htmlifyToolTipText(menuToolTip); - } + menuToolTip = HTMLUtils.htmlifyToolTipText(menuToolTip, MAX_SERVICE_DESC_LEN); menu.setToolTipText(menuToolTip); parentMenu.add(menu); @@ -1017,46 +1082,6 @@ } } - /** - * By turning the tool tip text into HTML, we can make it multiline - */ - protected String htmlifyToolTipText(String text){ - int maxLine = MAX_SERVICE_DESC_LEN; - StringBuffer result = null; - - while(true){ - result = new StringBuffer(""); - StringTokenizer st = new StringTokenizer(text, " \t\n"); - int lineCharCount = 0; - - if(st.hasMoreTokens()){ - result.append(st.nextToken()); - lineCharCount = result.length()-6; - } - while(st.hasMoreTokens()){ - String word = st.nextToken(); - if(lineCharCount != 0 && lineCharCount + word.length() >= maxLine){ - result.append("
" + word); - lineCharCount = word.length(); - continue; - } - result.append(" " + word); - lineCharCount += word.length()+1; - - if(lineCharCount > maxLine){ //single word is bigger than preset width, redo layout - maxLine = lineCharCount; - break; - } - } - result.append(""); - if(!st.hasMoreTokens()){ //used up all the text, didn't break previous loop abnormally - break; - } - } //end layout block - - return result.toString(); - } - public JMenu addNameDivSubMenu(JMenu parentMenu, MobyService[] services){ if(services == null || services.length == 0){ return null; @@ -1097,10 +1122,7 @@ desc = type.getComment(); } String menuToolTip = commonAncestorDesc + desc; - if(menuToolTip.length() > MAX_SERVICE_DESC_LEN){ - // Cut down really long ancestry descs to the last part (most precise) - menuToolTip = htmlifyToolTipText(menuToolTip); - } + menuToolTip = HTMLUtils.htmlifyToolTipText(menuToolTip, MAX_SERVICE_DESC_LEN); menu.setToolTipText(menuToolTip); parentMenu.add(menu); @@ -1230,9 +1252,7 @@ assignMenuDataIndex(submenu); } desc = "Input data: " + desc; - if(desc.length() > MAX_SERVICE_DESC_LEN){ - desc = htmlifyToolTipText(desc); - } + desc = HTMLUtils.htmlifyToolTipText(desc, MAX_SERVICE_DESC_LEN); submenu.setToolTipText(desc); submenu.setName(SERVICE_SUBMENU_NAME); return submenu; From gordonp at dev.open-bio.org Thu Apr 26 15:30:01 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 26 Apr 2007 11:30:01 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704261530.l3QFU1sE001011@dev.open-bio.org> gordonp Thu Apr 26 11:30:01 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources In directory dev.open-bio.org:/tmp/cvs-serv976/src/main/ca/ucalgary/seahawk/resources Modified Files: mobyBuilderRules.xml Log Message: Added binary object rules for images and ABI trace files, plus DNASequence moby-live/Java/src/main/ca/ucalgary/seahawk/resources mobyBuilderRules.xml,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/mobyBuilderRules.xml,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/mobyBuilderRules.xml 2007/04/03 02:37:43 1.3 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/mobyBuilderRules.xml 2007/04/26 15:30:01 1.4 @@ -4,6 +4,77 @@ http://www.bioxml.info/dtd/tigrxml.dtd http://www.bioxml.info/dtd/Bioseq.dtd + + + (\N+(?:\x20|\r|\t|\n)?)+ + + + unknown + + $2 + string-length('$2') + + + + + \AABIF.*\z + + unknown + + + $0 + + + + + + \A.PNG\r\n\x1A\n.*\z + + $0 + + + + + \AGIF8.*\z + + $0 + + + + + + \A......(?:JFIF|Exif).*\z + + $0 + + + + + ((?:http|ftp|file):// + ([^/\x20\r\t\n]+)? # host name (non-whitespace, non-slash), maybe + \S*?) # rest of the URL until + ([,\.\)\(]\s|\z) # trailing punctuation and whitespace, or just EOD + + + $1 + + + $1 + + + + + (\S+@ # user name (non-whitespace) + [^/\x20\r\t\n]+ # host name (non-whitespace, non-slash chars) + \. # literal dot + [A-Za-z]{2,4}) # top level domain (2 to 4 letters) + (?:\W|\z) # must be followed by non-word char, or EOD + + + $1 + $1 + + (?:GI|gi)[|:](\d+) @@ -23,7 +94,7 @@ - (?:DOI|doi):?\s*(10\.\d+/[^%"\# \t\r\n]+) + (?:DOI|doi):?\s*(10\.\d+/[^%"\#\x20\t\r\n]+) $1 @@ -31,7 +102,7 @@ - (?:\s|\A|/)(10\.\d+/[A-Za-z]+[^%"\# \t\r\n]+) + (?:\s|\A|/)(10\.\d+/[A-Za-z]+[^%"\#\x20\t\r\n]+) $1 @@ -122,4 +193,4 @@ $1 - \ No newline at end of file + From gordonp at dev.open-bio.org Thu Apr 26 15:31:00 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 26 Apr 2007 11:31:00 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704261531.l3QFV0KD001075@dev.open-bio.org> gordonp Thu Apr 26 11:31:00 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources In directory dev.open-bio.org:/tmp/cvs-serv1040/src/main/ca/ucalgary/seahawk/resources Modified Files: startup.html Log Message: Updated to show that we can handle images files, and other binary file types moby-live/Java/src/main/ca/ucalgary/seahawk/resources startup.html,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/startup.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/startup.html 2007/03/27 14:01:36 1.2 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/startup.html 2007/04/26 15:31:00 1.3 @@ -7,7 +7,7 @@ Seahawk Quick Start:
    -
  1. Drag a desktop file (text, RTF or HTML), a Web link, a URL, or a part of an open Web page from your browser onto this window. It will open in a new tab.
  2. +
  3. Drag a desktop file (text, RTF, HTML, image, ABI trace file, etc.), a Web link, a URL, or a part of an open Web page from your browser onto this window. It will open in a new tab.
  4. Highlight the part of document you want to explore further (e.g. a DNA sequence or a database ID).
  5. Click the highlighted data and wait for analysis services options to pop up.
From gordonp at dev.open-bio.org Fri Apr 27 13:44:21 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 27 Apr 2007 09:44:21 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704271344.l3RDiLLf003307@dev.open-bio.org> gordonp Fri Apr 27 09:44:21 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared In directory dev.open-bio.org:/tmp/cvs-serv3272/src/main/org/biomoby/shared Modified Files: MobyPrimaryDataSimple.java Log Message: Worked around namespace setting quirks, replace blank ones if they the only one moby-live/Java/src/main/org/biomoby/shared MobyPrimaryDataSimple.java,1.10,1.11 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyPrimaryDataSimple.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyPrimaryDataSimple.java 2006/11/11 23:04:34 1.10 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyPrimaryDataSimple.java 2007/04/27 13:44:21 1.11 @@ -134,8 +134,14 @@ *************************************************************************/ public void addNamespace (MobyNamespace value) { synchronized (namespaces) { - if (! namespaces.contains (value)) + if (! namespaces.contains (value)){ + // GET RID OF ANY BLANK NAMESPACE IF WE'VE GOT A REAL ONE + if(namespaces.size() == 1 && + namespaces.elementAt(0).getName().length() == 0){ + namespaces.remove(0); + } namespaces.addElement (value); + } } } From gordonp at dev.open-bio.org Fri Apr 27 13:45:29 2007 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 27 Apr 2007 09:45:29 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200704271345.l3RDjTBk003373@dev.open-bio.org> gordonp Fri Apr 27 09:45:29 EDT 2007 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data In directory dev.open-bio.org:/tmp/cvs-serv3338/src/main/org/biomoby/shared/data Modified Files: MobyDataObject.java Log Message: Workaround for namespace setting quirks of MobyPrimaryDataSimple moby-live/Java/src/main/org/biomoby/shared/data MobyDataObject.java,1.14,1.15 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObject.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/MobyDataObject.java 2007/03/12 17:03:24 1.14 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObject.java 2007/04/27 13:45:29 1.15 @@ -519,7 +519,8 @@ */ public void setPrimaryNamespace(MobyNamespace ns){ MobyNamespace[] nss = getNamespaces(); - if(nss == null || nss.length == 0){ + // special case, if no namespace already, simply add this one + if(nss == null || nss.length == 0 || nss[0].getName().length() == 0){ addNamespace(ns); return; } @@ -532,6 +533,7 @@ // Swap'em nss[i] = nss[0]; nss[0] = ns; + setNamespaces(null); setNamespaces(nss); } //It's in slot 0 as it should be @@ -543,6 +545,7 @@ // Prepend the namespace to the array newnss[0] = ns; System.arraycopy(nss, 0, newnss, 1, nss.length); + setNamespaces(null); setNamespaces(newnss); } From dag at dev.open-bio.org Mon Apr 23 22:39:11 2007 From: dag at dev.open-bio.org (Chris Dagdigian) Date: Mon, 23 Apr 2007 22:39:11 -0000 Subject: [MOBY-guts] biomoby commit Message-ID: <200704232239.l3NMd9T5023791@dev.open-bio.org> dag Mon Apr 23 18:39:08 EDT 2007 Update of /home/repository/moby/s-moby/ontologies In directory dev.open-bio.org:/home/dag/s-moby/ontologies Modified Files: PO.tar.gz moby.tar.gz sswap.tar.gz Log Message: Added files supplied by Teri Gomez @ NCGR in file s-moby_ncgr_20070413.tar -Chris Dagdigian s-moby/ontologies PO.tar.gz,1.1,1.2 moby.tar.gz,1.6,1.7 sswap.tar.gz,1.2,1.3 =================================================================== RCS file: /home/repository/moby/s-moby/ontologies/PO.tar.gz,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 Binary files /home/repository/moby/s-moby/ontologies/PO.tar.gz 2006/11/06 17:46:43 1.1 and /home/repository/moby/s-moby/ontologies/PO.tar.gz 2007/04/23 22:39:08 1.2 differ rcsdiff: /home/repository/moby/s-moby/ontologies/PO.tar.gz: diff failed =================================================================== RCS file: /home/repository/moby/s-moby/ontologies/moby.tar.gz,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 Binary files /home/repository/moby/s-moby/ontologies/moby.tar.gz 2006/12/20 01:30:12 1.6 and /home/repository/moby/s-moby/ontologies/moby.tar.gz 2007/04/23 22:39:08 1.7 differ rcsdiff: /home/repository/moby/s-moby/ontologies/moby.tar.gz: diff failed =================================================================== RCS file: /home/repository/moby/s-moby/ontologies/sswap.tar.gz,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 Binary files /home/repository/moby/s-moby/ontologies/sswap.tar.gz 2006/12/20 01:31:46 1.2 and /home/repository/moby/s-moby/ontologies/sswap.tar.gz 2007/04/23 22:39:08 1.3 differ rcsdiff: /home/repository/moby/s-moby/ontologies/sswap.tar.gz: diff failed From dag at dev.open-bio.org Mon Apr 23 22:39:16 2007 From: dag at dev.open-bio.org (Chris Dagdigian) Date: Mon, 23 Apr 2007 22:39:16 -0000 Subject: [MOBY-guts] biomoby commit Message-ID: <200704232239.l3NMdDhP023818@dev.open-bio.org> dag Mon Apr 23 18:39:13 EDT 2007 Update of /home/repository/moby/s-moby/ontologies/build In directory dev.open-bio.org:/home/dag/s-moby/ontologies/build Modified Files: build.xml Log Message: Added files supplied by Teri Gomez @ NCGR in file s-moby_ncgr_20070413.tar -Chris Dagdigian s-moby/ontologies/build build.xml,1.3,1.4 =================================================================== RCS file: /home/repository/moby/s-moby/ontologies/build/build.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/s-moby/ontologies/build/build.xml 2006/06/01 18:12:31 1.3 +++ /home/repository/moby/s-moby/ontologies/build/build.xml 2007/04/23 22:39:13 1.4 @@ -9,14 +9,9 @@ - - - - - - + dag Mon Apr 23 18:39:13 EDT 2007 Update of /home/repository/moby/s-moby/ontologies/sswap In directory dev.open-bio.org:/home/dag/s-moby/ontologies/sswap Added Files: SSWAP owlImports Log Message: Added files supplied by Teri Gomez @ NCGR in file s-moby_ncgr_20070413.tar -Chris Dagdigian s-moby/ontologies/sswap SSWAP,NONE,1.1 owlImports,NONE,1.1 From dag at dev.open-bio.org Mon Apr 23 22:39:24 2007 From: dag at dev.open-bio.org (Chris Dagdigian) Date: Mon, 23 Apr 2007 22:39:24 -0000 Subject: [MOBY-guts] biomoby commit Message-ID: <200704232239.l3NMdDSf023838@dev.open-bio.org> dag Mon Apr 23 18:39:13 EDT 2007 Update of /home/repository/moby/s-moby/ontologies/src/java/org/semanticmoby/ontologies/util In directory dev.open-bio.org:/home/dag/s-moby/ontologies/src/java/org/semanticmoby/ontologies/util Modified Files: OBOFileIndividualCreator.java Log Message: Added files supplied by Teri Gomez @ NCGR in file s-moby_ncgr_20070413.tar -Chris Dagdigian s-moby/ontologies/src/java/org/semanticmoby/ontologies/util OBOFileIndividualCreator.java,1.6,1.7 =================================================================== RCS file: /home/repository/moby/s-moby/ontologies/src/java/org/semanticmoby/ontologies/util/OBOFileIndividualCreator.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 From dag at dev.open-bio.org Mon Apr 23 22:39:25 2007 From: dag at dev.open-bio.org (Chris Dagdigian) Date: Mon, 23 Apr 2007 22:39:25 -0000 Subject: [MOBY-guts] biomoby commit Message-ID: <200704232239.l3NMdEpA023870@dev.open-bio.org> dag Mon Apr 23 18:39:13 EDT 2007 Update of /home/repository/moby/s-moby/ontologies/sswap/owldoc In directory dev.open-bio.org:/home/dag/s-moby/ontologies/sswap/owldoc Added Files: sswap.html Log Message: Added files supplied by Teri Gomez @ NCGR in file s-moby_ncgr_20070413.tar -Chris Dagdigian s-moby/ontologies/sswap/owldoc sswap.html,NONE,1.1