Some improvement and error fix.
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-analysis/nlphub@165269 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
43a834505d
commit
7286d1d251
|
@ -61,6 +61,7 @@ public class AsyncHttpRequest extends Thread {
|
|||
|
||||
} catch (Exception x) {
|
||||
logger.error(x.getLocalizedMessage());
|
||||
asyncHttpRequestCallback();
|
||||
} finally {
|
||||
try {
|
||||
if (r != null)
|
||||
|
|
|
@ -24,8 +24,9 @@ public class NlpAsyncNerRunner extends AsyncHttpRequest {
|
|||
public final static String WPS_DESCRIBE_PROCESS_URL = Constants.DATAMINER_URL + "/wps/WebProcessingService?request=DescribeProcess&service=WPS&Version=1.0.0";
|
||||
private String identifier, token, httpMethod, annotations, publicLink, language;
|
||||
private Logger logger = Logger.getLogger(NlpAsyncNerRunner.class.getSimpleName());
|
||||
private RunnerCommander commander;
|
||||
|
||||
public NlpAsyncNerRunner(String identifier, String token, String publicLink, String annotations, String language) {
|
||||
public NlpAsyncNerRunner(String identifier, String token, String publicLink, String annotations, String language, RunnerCommander commander) {
|
||||
super();
|
||||
this.identifier = identifier;
|
||||
this.token = token;
|
||||
|
@ -33,6 +34,7 @@ public class NlpAsyncNerRunner extends AsyncHttpRequest {
|
|||
this.annotations = annotations;
|
||||
this.publicLink = publicLink;
|
||||
this.language = language; // not used for the moment...
|
||||
this.commander = commander;
|
||||
ArrayList<NlpParameter> params = buildParameterString();
|
||||
String serviceUrl = WPS_EXECUTE_URL + "&gcube-token=" + token + "&lang=en-US&Identifier=" + identifier;
|
||||
serviceUrl += "&" + setUrl(params);
|
||||
|
@ -138,10 +140,10 @@ public class NlpAsyncNerRunner extends AsyncHttpRequest {
|
|||
logger.info("ID: " + identifier.substring(identifier.lastIndexOf(".") + 1) + " elapsed time: " + elapsedTime);
|
||||
String result = super.getResult();
|
||||
String theLink = "";
|
||||
//System.out.println(result);
|
||||
BufferedReader r = new BufferedReader(
|
||||
new InputStreamReader(new ByteArrayInputStream(result.getBytes(StandardCharsets.UTF_8))));
|
||||
try {
|
||||
BufferedReader r = new BufferedReader(
|
||||
new InputStreamReader(new ByteArrayInputStream(result.getBytes(StandardCharsets.UTF_8))));
|
||||
|
||||
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(r));
|
||||
doc.getDocumentElement().normalize();
|
||||
NodeList nListResult = doc.getElementsByTagName("ogr:Result");
|
||||
|
@ -165,9 +167,9 @@ public class NlpAsyncNerRunner extends AsyncHttpRequest {
|
|||
theLink = res;
|
||||
}
|
||||
}
|
||||
RunnerCommander.updateResultList(identifier.substring(identifier.lastIndexOf(".") + 1) + ":::" + theLink);
|
||||
commander.updateResultList(identifier.substring(identifier.lastIndexOf(".") + 1) + ":::" + theLink);
|
||||
} catch (Exception x) {
|
||||
RunnerCommander.updateResultList(identifier.substring(identifier.lastIndexOf(".") + 1) + ":::" + Constants.ERROR_ID);
|
||||
commander.updateResultList(identifier.substring(identifier.lastIndexOf(".") + 1) + ":::" + Constants.ERROR_ID);
|
||||
logger.error(x.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ public class RunnerCommander extends Thread {
|
|||
private String[] identifiers = null;
|
||||
private String link = "";
|
||||
private String token = "";
|
||||
private static ArrayList<String> outResultList = null;
|
||||
private ArrayList<String> outResultList = null;
|
||||
private long sleepTime = 500l;
|
||||
private long maxWaitingTime = 5l * 60l * 1000l;
|
||||
private Logger logger = Logger.getLogger(RunnerCommander.class.getSimpleName());
|
||||
|
@ -50,7 +50,7 @@ public class RunnerCommander extends Thread {
|
|||
this.sleepTime = sleepTime;
|
||||
}
|
||||
|
||||
public synchronized static void updateResultList(String res) {
|
||||
public synchronized void updateResultList(String res) {
|
||||
outResultList.add(res);
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ public class RunnerCommander extends Thread {
|
|||
|
||||
private void runAlgorithms() {
|
||||
for (String id : identifiers) {
|
||||
NlpAsyncNerRunner n = new NlpAsyncNerRunner(id, token, link, annotationList, null);
|
||||
NlpAsyncNerRunner n = new NlpAsyncNerRunner(id, token, link, annotationList, null, this);
|
||||
n.start();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,14 +101,15 @@
|
|||
<div class="left-side" id="result-text-div"></div>
|
||||
<div class="right-side">
|
||||
<ul class="collapsible" data-collapsible="accordion" id="ner-result-accordion">
|
||||
<li>
|
||||
<div class="collapsible-header">Annotations</div>
|
||||
<div class="collapsible-body" id="result-params-div"></div>
|
||||
</li>
|
||||
<li>
|
||||
<div class="collapsible-header">Algorithms</div>
|
||||
<div class="collapsible-body" id="algorithm-params-div"></div>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<div class="collapsible-header">Annotations</div>
|
||||
<div class="collapsible-body" id="result-params-div"></div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div style="text-align: left;">
|
||||
|
|
|
@ -21,7 +21,18 @@ var checkedAlgs = [];
|
|||
|
||||
$(document).ready(function() {
|
||||
disableExecuteButton();
|
||||
$('.collapsible').collapsible();
|
||||
// $('.collapsible').collapsible();
|
||||
// $('.collapsible').collapsible({
|
||||
// onOpen: function(el) {
|
||||
// console.log(el);
|
||||
// $('.collapsible').collapsible('close', el.prevObject.index());
|
||||
// },
|
||||
// onClose: function(el) {
|
||||
// console.log(el);
|
||||
// $('.collapsible').collapsible('open', el.prevObject.index());
|
||||
// }
|
||||
// });
|
||||
|
||||
$.ajax({
|
||||
url : "https://data.d4science.org/bnp4UDNyb21lSURkQXdDUnlSS0JkVWgzWk1KMUxWVGZHbWJQNStIS0N6Yz0",
|
||||
type : "GET",
|
||||
|
@ -37,6 +48,7 @@ $(document).ready(function() {
|
|||
resizeTable();
|
||||
resizeLogo();
|
||||
enableAjaxFileUpload();
|
||||
collapsibleHandler();
|
||||
|
||||
$("#logo-image").click(function() {
|
||||
backHandler();
|
||||
|
@ -108,7 +120,6 @@ $(document).ready(function() {
|
|||
},
|
||||
onSuccess : function(files, data, xhr) {
|
||||
hideProgress();
|
||||
//console.log('' + data.language);
|
||||
checkLanguage(data.language);
|
||||
selectAnnotationsByLanguage();
|
||||
$("#reset-upload").css("display",
|
||||
|
@ -139,6 +150,25 @@ $(document).ready(function() {
|
|||
});
|
||||
});
|
||||
|
||||
|
||||
collapsibleHandler = function() {
|
||||
// $('.collapsible').collapsible();
|
||||
//$('.collapsible').collapsible({
|
||||
// onOpen: function(el) {
|
||||
// if(el.index() == 0)
|
||||
// $('.collapsible').collapsible('close', 1);
|
||||
// else
|
||||
// $('.collapsible').collapsible('close', 0);
|
||||
// },
|
||||
// onClose: function(el) {
|
||||
// if(el.index() == 0)
|
||||
// $('.collapsible').collapsible('open', 1);
|
||||
// else
|
||||
// $('.collapsible').collapsible('open', 0);
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
enableAjaxFileUpload= function() {
|
||||
$(".ajax-file-upload").attr("enabled", "true");
|
||||
$(".ajax-file-upload").css("background", pageGreen);
|
||||
|
@ -637,7 +667,8 @@ buildAnnotationList = function(list) {
|
|||
* Utility
|
||||
*/
|
||||
showAnnotationsList = function() {
|
||||
$('.collapsible').collapsible('open', 0);
|
||||
$('.collapsible').collapsible();
|
||||
$('.collapsible').collapsible('open', 1);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -721,9 +752,11 @@ enhanceColor = function(color) {
|
|||
* Write the html paragraph <p> containing the text highlighted on annotation value
|
||||
*/
|
||||
rewriteText = function(color) {
|
||||
$("#result-text-div").empty();
|
||||
if(color.startsWith("#"))
|
||||
color = color.substring(1);
|
||||
|
||||
var complemetar = 0xFFFFFF - eval("0x" + color.substring(1));
|
||||
$("#result-text-div").empty();
|
||||
var complemetar = 0xFFFFFF - eval("0x" + color);
|
||||
var complement = complemetar.toString(16);
|
||||
var R = enhanceColor(complement.substring(0,2));
|
||||
var G = enhanceColor(complement.substring(2,4));
|
||||
|
@ -842,10 +875,7 @@ getIndices = function() {
|
|||
*/
|
||||
mergeIndices = function(indices) {
|
||||
var newIndices = [];
|
||||
if (indices.length == 1)
|
||||
newIndices = indices[0];
|
||||
else
|
||||
newIndices = mergeAll(indices);
|
||||
newIndices = mergeAll(indices);
|
||||
return newIndices;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue