// }
// if (true) return null;
if (al == null) {
logger.error("The alignment model is null.");
return new UpdateContainer(new ErrorUpdate(
"Error occured while populating the source. The alignment model is null."));
}
DirectedWeightedMultigraph<Node, LabeledLink> tree = al.getSteinerTree();
if (tree == null) {
logger.error("The alignment tree is null.");
return new UpdateContainer(new ErrorUpdate(
"Error occured while populating the source. The alignment model is null."));
}
DataSource source = new DataSource(wk.getTitle(), tree);
Map<WebService, Map<String, String>> servicesAndMappings =
WebServiceLoader.getInstance().getServicesWithInputContainedInModel(source.getModel(), null);
if (servicesAndMappings == null) {
logger.error("Cannot find any services to be invoked according to this source model.");
return new UpdateContainer(new ErrorUpdate(
"Error occured while populating the source. Cannot find any services to be invoked according to this source model."));
}
// For now, we just use the first service,
// later we can suggest the user a list of available services and user select among them
WebService service = null;
Iterator<WebService> itr = servicesAndMappings.keySet().iterator();
if (itr != null && itr.hasNext()) {
service = itr.next();
}
if (service == null) {
logger.error("Cannot find any services to be invoked according to this source model.");
return new UpdateContainer(new ErrorUpdate(
"Error occured while populating the source. Cannot find any services to be invoked according to this source model."));
}
List<String> requestIds = new ArrayList<String>();
Map<String, String> serviceToSourceAttMapping = servicesAndMappings.get(service);
List<String> requestURLStrings = getUrlStrings(service, source, wk, serviceToSourceAttMapping, requestIds);
if (requestURLStrings == null || requestURLStrings.size() == 0) {
logger.error("Data table does not have any row.");
return new UpdateContainer(new ErrorUpdate("Data table does not have any row."));
}
InvocationManager invocatioManager;
try {
String encoding = wk.getEncoding();
invocatioManager = new InvocationManager(getUrlColumnName(wk), requestIds, requestURLStrings, encoding);
logger.info("Requesting data with includeURL=" + true + ",includeInput=" + true + ",includeOutput=" + true);
Table serviceTable = invocatioManager.getServiceData(false, false, true);
// logger.debug(serviceTable.getPrintInfo());
ServiceTableUtil.populateWorksheet(serviceTable, wk, workspace.getFactory(), selection);
logger.info("The service " + service.getUri() + " has been invoked successfully.");
} catch (MalformedURLException e) {
logger.error("Malformed service request URL.");
return new UpdateContainer(new ErrorUpdate("Malformed service request URL."));
} catch (KarmaException e) {
logger.error(e.getMessage());
return new UpdateContainer(new ErrorUpdate(e.getMessage()));
}
// Create new vWorksheet using the new header order
List<HNodePath> columnPaths = new ArrayList<HNodePath>();
for (HNode node : wk.getHeaders().getSortedHNodes()) {