X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2Frest%2FRestJobThread.java;h=c8efcda78938399afabf52d42cdda90ddc3278f8;hb=a9177efb4097815d9a8031aa22700c61a7d6260a;hp=5ac1959192b1c883f8daf25bdfa28f33b0e08548;hpb=ad20cd92225f2ee8c251d39b00b90555d382a616;p=jalview.git
diff --git a/src/jalview/ws/rest/RestJobThread.java b/src/jalview/ws/rest/RestJobThread.java
index 5ac1959..c8efcda 100644
--- a/src/jalview/ws/rest/RestJobThread.java
+++ b/src/jalview/ws/rest/RestJobThread.java
@@ -1,29 +1,34 @@
/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
- * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
*
* This file is part of Jalview.
*
* Jalview is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
*
* Jalview is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along with Jalview. If not, see .
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see .
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
*/
package jalview.ws.rest;
-import jalview.bin.Cache;
+import java.util.Locale;
+
+import jalview.bin.Console;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.AlignmentOrder;
import jalview.datamodel.Annotation;
-import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
import jalview.gui.AlignFrame;
@@ -33,6 +38,7 @@ import jalview.gui.WebserviceInfo;
import jalview.io.NewickFile;
import jalview.io.packed.JalviewDataset;
import jalview.io.packed.JalviewDataset.AlignmentSet;
+import jalview.util.MessageManager;
import jalview.ws.AWSThread;
import jalview.ws.AWsJob;
@@ -86,8 +92,8 @@ public class RestJobThread extends AWSThread
{
jobs = new RestJob[1];
jobs[0] = new RestJob(0, this,
- restClient._input.getVisibleAlignment(restClient.service
- .getGapCharacter()),
+ restClient._input.getVisibleAlignment(
+ restClient.service.getGapCharacter()),
restClient._input.getVisibleContigs());
// need a function to get a range on a view/alignment and return both
// annotation, groups and selection subsetted to just that region.
@@ -97,15 +103,14 @@ public class RestJobThread extends AWSThread
{
int[] viscontig = restClient._input.getVisibleContigs();
AlignmentI[] viscontigals = restClient._input
- .getVisibleContigAlignments(restClient.service
- .getGapCharacter());
+ .getVisibleContigAlignments(
+ restClient.service.getGapCharacter());
if (viscontigals != null && viscontigals.length > 0)
{
jobs = new RestJob[viscontigals.length];
for (int j = 0; j < jobs.length; j++)
{
- int[] visc = new int[]
- { viscontig[j * 2], viscontig[j * 2 + 1] };
+ int[] visc = new int[] { viscontig[j * 2], viscontig[j * 2 + 1] };
if (j != 0)
{
jobs[j] = new RestJob(j, this, viscontigals[j], visc);
@@ -170,9 +175,13 @@ public class RestJobThread extends AWSThread
private String getStage(Stage stg)
{
if (stg == Stage.SUBMIT)
+ {
return "submitting ";
+ }
if (stg == Stage.POLL)
+ {
return "checking status of ";
+ }
return (" being confused about ");
}
@@ -226,8 +235,8 @@ public class RestJobThread extends AWSThread
{
if (input.getValue().validFor(rj))
{
- postentity.addPart(input.getKey(), input.getValue()
- .formatForInput(rj));
+ postentity.addPart(input.getKey(),
+ input.getValue().formatForInput(rj));
}
else
{
@@ -259,7 +268,7 @@ public class RestJobThread extends AWSThread
+ "
See Console output for details.";
rj.setAllowedServerExceptions(0);// unrecoverable;
rj.error = true;
- Cache.log.fatal("Unexpected REST Job " + getStage(stg)
+ Console.fatal("Unexpected REST Job " + getStage(stg)
+ "exception for URL " + rj.rsd.postUrl);
throw (he);
} catch (IOException e)
@@ -268,7 +277,7 @@ public class RestJobThread extends AWSThread
+ "Job.
Problematic url was " + request.getURI()
+ "
See Console output for details.";
- Cache.log.warn("IO Exception for REST Job " + getStage(stg)
+ Console.warn("IO Exception for REST Job " + getStage(stg)
+ "exception for URL " + rj.rsd.postUrl);
throw (e);
@@ -277,15 +286,12 @@ public class RestJobThread extends AWSThread
{
case 200:
rj.running = false;
- Cache.log.debug("Processing result set.");
+ Console.debug("Processing result set.");
processResultSet(rj, response, request);
break;
case 202:
rj.statMessage = "
Job submitted successfully. Results available at this URL:\n"
- + ""
- + rj.getJobId()
+ + "" + rj.getJobId()
+ "
";
rj.running = true;
break;
@@ -298,11 +304,9 @@ public class RestJobThread extends AWSThread
{
if (loc.length > 1)
{
- Cache.log
- .warn("Ignoring additional "
- + (loc.length - 1)
- + " location(s) provided in response header ( next one is '"
- + loc[1].getValue() + "' )");
+ Console.warn("Ignoring additional " + (loc.length - 1)
+ + " location(s) provided in response header ( next one is '"
+ + loc[1].getValue() + "' )");
}
rj.setJobId(loc[0].getValue());
rj.setSubmitted(true);
@@ -316,13 +320,13 @@ public class RestJobThread extends AWSThread
rj.setSubjobComplete(true);
rj.error = true;
rj.running = false;
- completeStatus(rj, response, "" + getStage(stg)
- + "failed. Reason below:\n");
+ completeStatus(rj, response,
+ "" + getStage(stg) + "failed. Reason below:\n");
break;
default:
// Some other response. Probably need to pop up the content in a window.
// TODO: deal with all other HTTP response codes from server.
- Cache.log.warn("Unhandled response status when " + getStage(stg)
+ Console.warn("Unhandled response status when " + getStage(stg)
+ "for " + postUrl + ": " + response.getStatusLine());
rj.error = true;
rj.setAllowedServerExceptions(0);
@@ -330,20 +334,13 @@ public class RestJobThread extends AWSThread
rj.setSubmitted(true);
try
{
- completeStatus(
- rj,
- response,
- ""
- + getStage(stg)
- + " resulted in an unexpected server response.
Url concerned was "
- + request.getURI()
- + "
Filtered response content below:
");
+ completeStatus(rj, response, "" + getStage(stg)
+ + " resulted in an unexpected server response.
Url concerned was " + request.getURI()
+ + "
Filtered response content below:
");
} catch (IOException e)
{
- Cache.log.debug("IOException when consuming unhandled response",
- e);
+ Console.debug("IOException when consuming unhandled response", e);
}
;
}
@@ -405,7 +402,7 @@ public class RestJobThread extends AWSThread
*/
String f;
StringBuffer content = new StringBuffer(f = EntityUtils.toString(en));
- f = f.toLowerCase();
+ f = f.toLowerCase(Locale.ROOT);
int body = f.indexOf("
-1)
{
@@ -425,7 +422,7 @@ public class RestJobThread extends AWSThread
public void pollJob(AWsJob job) throws Exception
{
assert (job instanceof RestJob);
- System.err.println("Debug RestJob: Polling Job");
+ jalview.bin.Console.errPrintln("Debug RestJob: Polling Job");
doPoll((RestJob) job);
}
@@ -435,7 +432,7 @@ public class RestJobThread extends AWSThread
assert (job instanceof RestJob);
try
{
- System.err.println("Debug RestJob: Posting Job");
+ jalview.bin.Console.errPrintln("Debug RestJob: Posting Job");
doPost((RestJob) job);
} catch (NoValidInputDataException erex)
{
@@ -449,7 +446,7 @@ public class RestJobThread extends AWSThread
{
job.setSubjobComplete(true);
job.setAllowedServerExceptions(-1);
- Cache.log.error("Exception when trying to start Rest Job.", ex);
+ Console.error("Exception when trying to start Rest Job.", ex);
}
}
@@ -458,7 +455,7 @@ public class RestJobThread extends AWSThread
{
// crazy users will see this message
// TODO: finish this! and remove the message below!
- Cache.log.warn("Rest job result parser is currently INCOMPLETE!");
+ Console.warn("Rest job result parser is currently INCOMPLETE!");
int validres = 0;
for (RestJob rj : (RestJob[]) jobs)
{
@@ -467,31 +464,29 @@ public class RestJobThread extends AWSThread
String ln = null;
try
{
- Cache.log.debug("Parsing data for job " + rj.getJobId());
+ Console.debug("Parsing data for job " + rj.getJobId());
rj.parseResultSet();
if (rj.hasResults())
{
validres++;
}
- Cache.log.debug("Finished parsing data for job " + rj.getJobId());
+ Console.debug("Finished parsing data for job " + rj.getJobId());
} catch (Error ex)
{
- Cache.log.warn("Failed to finish parsing data for job "
- + rj.getJobId());
+ Console.warn(
+ "Failed to finish parsing data for job " + rj.getJobId());
ex.printStackTrace();
} catch (Exception ex)
{
- Cache.log.warn("Failed to finish parsing data for job "
- + rj.getJobId());
+ Console.warn(
+ "Failed to finish parsing data for job " + rj.getJobId());
ex.printStackTrace();
} finally
{
rj.error = true;
rj.statMessage = "Error whilst parsing data for this job.
URL for job response is :"
- + rj.resSet.getUrl()
+ + rj.resSet.getUrl() + "\">" + rj.resSet.getUrl()
+ "
";
}
}
@@ -606,7 +601,7 @@ public class RestJobThread extends AWSThread
// total number of distinct alignment sets generated by job set.
int numAlSets = 0, als = 0;
List destAls = new ArrayList();
- List destColsel = new ArrayList();
+ List destColsel = new ArrayList();
List> trees = new ArrayList>();
do
@@ -712,7 +707,7 @@ public class RestJobThread extends AWSThread
RestJob rj = (RestJob) jobs[nrj];
int contigs[] = input.getVisibleContigs();
AlignmentI destAl = null;
- jalview.datamodel.ColumnSelection destCs = null;
+ jalview.datamodel.HiddenColumns destHCs = null;
// Resolve destAl for this data.
if (als == 0 && rj.isInputContextModified())
{
@@ -728,10 +723,10 @@ public class RestJobThread extends AWSThread
if (!restClient.isAlignmentModified() && merge)
{
destAl = restClient.av.getAlignment();
- destCs = restClient.av.getColumnSelection();
- resultDest
- .add(restClient.isShowResultsInNewView() ? AddDataTo.newView
- : AddDataTo.currentView);
+ destHCs = restClient.av.getAlignment().getHiddenColumns();
+ resultDest.add(restClient.isShowResultsInNewView()
+ ? AddDataTo.newView
+ : AddDataTo.currentView);
destPanels.add(restClient.recoverAlignPanelForView());
}
else
@@ -739,15 +734,15 @@ public class RestJobThread extends AWSThread
newAlignment = true;
// recreate the input alignment data
Object[] idat = input
- .getAlignmentAndColumnSelection(gapCharacter);
+ .getAlignmentAndHiddenColumns(gapCharacter);
destAl = new Alignment((SequenceI[]) idat[0]);
- destCs = (ColumnSelection) idat[1];
+ destHCs = (HiddenColumns) idat[1];
resultDest.add(AddDataTo.newAlignment);
// but do not add to the alignment panel list - since we need to
// create a whole new alignFrame set.
}
destAls.add(destAl);
- destColsel.add(destCs);
+ destColsel.add(destHCs);
}
}
else
@@ -760,13 +755,13 @@ public class RestJobThread extends AWSThread
{
// TODO: decide if multiple multiple alignments returned by
// non-vseparable services are allowed.
- Cache.log
- .warn("dealing with multiple alignment products returned by non-vertically separable service.");
+ Console.warn(
+ "dealing with multiple alignment products returned by non-vertically separable service.");
}
// recover reference to last alignment created for this rest frame
// ready for extension
destAl = destAls.get(als);
- destCs = destColsel.get(als);
+ destHCs = destColsel.get(als);
}
else
{
@@ -795,14 +790,16 @@ public class RestJobThread extends AWSThread
newview = input.getUpdatedView(rseqs, orders, gapCharacter);
}
destAl = new Alignment((SequenceI[]) newview[0]);
- destCs = (ColumnSelection) newview[1];
+ destHCs = (HiddenColumns) newview[1];
newAlignment = true;
// TODO create alignment from result data with propagated
// references.
destAls.add(destAl);
- destColsel.add(destCs);
+ destColsel.add(destHCs);
resultDest.add(AddDataTo.newAlignment);
- throw new Error("Impl. Error! TODO: ");
+ throw new Error(
+ MessageManager.getString("error.implementation_error")
+ + "TODO: ");
}
}
/**
@@ -872,8 +869,8 @@ public class RestJobThread extends AWSThread
}
else
{
- Cache.log
- .warn("Couldn't resolve original sequence for new sequence.");
+ Console.warn(
+ "Couldn't resolve original sequence for new sequence.");
}
}
if (sg.hasSeqrep())
@@ -895,8 +892,8 @@ public class RestJobThread extends AWSThread
{
// adjust boundaries of recovered group w.r.t. new group being
// merged on to original alignment.
- int start = sg.getStartRes() + contigs[ncnt], end = sg
- .getEndRes() + contigs[ncnt];
+ int start = sg.getStartRes() + contigs[ncnt],
+ end = sg.getEndRes() + contigs[ncnt];
if (start < exsg.getStartRes())
{
exsg.setStartRes(start);
@@ -950,8 +947,8 @@ public class RestJobThread extends AWSThread
grass = groupNames.get(alan[nrj][an].groupRef.getName());
if (grass == null)
{
- Cache.log
- .error("Couldn't relocate group referemce for group "
+ Console.error(
+ "Couldn't relocate group referemce for group "
+ alan[nrj][an].groupRef.getName());
}
}
@@ -977,7 +974,8 @@ public class RestJobThread extends AWSThread
visan.sequenceRef = sqass;
visAlAn.add(visan);
}
- if (contigs[ncnt] + alan[nrj][an].annotations.length > visan.annotations.length)
+ if (contigs[ncnt]
+ + alan[nrj][an].annotations.length > visan.annotations.length)
{
// increase width of annotation row
Annotation[] newannv = new Annotation[contigs[ncnt]
@@ -1000,8 +998,8 @@ public class RestJobThread extends AWSThread
{
// TODO: process each newick file, lifting over sequence refs to
// current alignment, if necessary.
- Cache.log
- .error("Tree recovery from restjob not yet implemented.");
+ Console.error(
+ "Tree recovery from restjob not yet implemented.");
}
}
}
@@ -1037,10 +1035,11 @@ public class RestJobThread extends AWSThread
for (AddDataTo action : resultDest)
{
AlignmentI destal;
- ColumnSelection destcs;
- String alTitle = restClient.service.details.Action + " using "
- + restClient.service.details.Name + " on "
- + restClient.viewTitle;
+ HiddenColumns destcs;
+ String alTitle = MessageManager
+ .formatMessage("label.webservice_job_title_on", new String[]
+ { restClient.service.details.Action,
+ restClient.service.details.Name, restClient.viewTitle });
switch (action)
{
case newAlignment:
@@ -1048,8 +1047,8 @@ public class RestJobThread extends AWSThread
destcs = destColsel.get(als);
destaf = new AlignFrame(destal, destcs, AlignFrame.DEFAULT_WIDTH,
AlignFrame.DEFAULT_HEIGHT);
- PaintRefresher.Refresh(destaf, destaf.getViewport()
- .getSequenceSetId());
+ PaintRefresher.Refresh(destaf,
+ destaf.getViewport().getSequenceSetId());
// todo transfer any feature settings and colouring
/*
* destaf.getFeatureRenderer().transferSettings(this.featureSettings);
@@ -1177,8 +1176,8 @@ public class RestJobThread extends AWSThread
{
if (start + width < end)
{
- blocks[c][s] = sequenceIs[s].getSubSequence(start, start
- + width);
+ blocks[c][s] = sequenceIs[s].getSubSequence(start,
+ start + width);
}
else
{
@@ -1259,7 +1258,7 @@ public class RestJobThread extends AWSThread
if (!rj.hasValidInput())
{
// invalid input for this job
- System.err.println("Job " + rj.getJobnum()
+ jalview.bin.Console.errPrintln("Job " + rj.getJobnum()
+ " has invalid input. ( " + rj.getStatus() + ")");
if (rj.hasStatus() && !_warnings.contains(rj.getStatus()))
{