Fixes to test cases
[jabaws.git] / webservices / compbio / ws / client / Jws2Client.java
index 1673e18..eda6533 100644 (file)
@@ -38,20 +38,19 @@ import java.net.MalformedURLException;
 import java.net.URL;\r
 import java.util.Arrays;\r
 import java.util.List;\r
-import java.util.Set;\r
 import java.util.logging.Level;\r
 import java.util.logging.Logger;\r
 \r
 import javax.xml.ws.Service;\r
 import javax.xml.ws.WebServiceException;\r
 \r
-import compbio.data.msa.Annotation;\r
 import compbio.data.msa.JABAService;\r
 import compbio.data.msa.Metadata;\r
 import compbio.data.msa.MsaWS;\r
+import compbio.data.msa.SequenceAnnotation;\r
 import compbio.data.sequence.Alignment;\r
 import compbio.data.sequence.FastaSequence;\r
-import compbio.data.sequence.Score;\r
+import compbio.data.sequence.ScoreManager;\r
 import compbio.data.sequence.SequenceUtil;\r
 import compbio.data.sequence.UnknownFileFormatException;\r
 import compbio.metadata.JobSubmissionException;\r
@@ -159,17 +158,17 @@ public class Jws2Client {
                                // std.out will not be\r
                                outStream = System.out;\r
                        }\r
-                       if (service == Services.AAConWS) {\r
-                               Set<Score> result = analize(inputFile, ((Annotation<T>) msaws),\r
-                                               preset, customOptions);\r
+                       if (service.getServiceType() == SequenceAnnotation.class) {\r
+                               ScoreManager result = analize(inputFile,\r
+                                               ((SequenceAnnotation<T>) msaws), preset, customOptions);\r
+\r
                                IOHelper.writeOut(outStream, result);\r
                        } else {\r
                                alignment = align(inputFile, (MsaWS<T>) msaws, preset,\r
                                                customOptions);\r
                                IOHelper.writeOut(outStream, alignment);\r
                        }\r
-\r
-                       // stream is closed in the method no need to close it here\r
+                       outStream.close();\r
                }\r
 \r
                boolean listParameters = CmdHelper.listParameters(cmd);\r
@@ -202,13 +201,14 @@ public class Jws2Client {
         * @return Set<Score> the conservation scores\r
         * @throws UnknownFileFormatException\r
         */\r
-       <T> Set<Score> analize(File file, Annotation<T> wsproxy, Preset<T> preset,\r
-                       List<Option<T>> customOptions) {\r
+       <T> ScoreManager analize(File file, SequenceAnnotation<T> wsproxy,\r
+                       Preset<T> preset, List<Option<T>> customOptions) {\r
 \r
                List<FastaSequence> fastalist = null;\r
-               Set<Score> scores = null;\r
+               ScoreManager scores = null;\r
                try {\r
                        fastalist = SequenceUtil.openInputStream(file.getAbsolutePath());\r
+                       assert !fastalist.isEmpty() : "Input is empty!";\r
 \r
                        String jobId = null;\r
                        if (customOptions != null && preset != null) {\r
@@ -220,9 +220,11 @@ public class Jws2Client {
                        } else if (preset != null) {\r
                                jobId = wsproxy.presetAnalize(fastalist, preset);\r
                        } else {\r
+                               System.out.println("\n\ncalling analise.........");\r
                                jobId = wsproxy.analize(fastalist);\r
                        }\r
-                       Thread.sleep(1000);\r
+                       Thread.sleep(2000);\r
+\r
                        scores = wsproxy.getAnnotation(jobId);\r
 \r
                } catch (IOException e) {\r
@@ -287,8 +289,13 @@ public class Jws2Client {
                                serv = service.getService(url, V2_QUALIFIED_SERVICE_NAME);\r
                        }\r
                }\r
+               if (serv == null) {\r
+                       System.err.println("Could not connect to " + url\r
+                                       + " the server is down?");\r
+                       // FIXME\r
+               }\r
                JABAService serviceIF = service.getInterface(serv);\r
-               log.log(Level.FINE, "Connected successfully!");\r
+               log.log(Level.INFO, "Connected successfully!");\r
 \r
                return serviceIF;\r
        }\r
@@ -426,7 +433,7 @@ public class Jws2Client {
 \r
        /**\r
         * Starts command line client, if no parameter are supported print help. Two\r
-        * parameters are required for successfull call the JWS2 host name and a\r
+        * parameters are required for successful call the JWS2 host name and a\r
         * service name.\r
         * \r
         * @param args\r