@Override
public UpdateContainer doIt(Workspace workspace) throws CommandException {
Worksheet wk = workspace.getWorksheet(worksheetId);
WebService service = null;
DataSource source = null;
if (!wk.containService()) {
logger.info("The worksheet does not have a service object.");
// return new UpdateContainer(new ErrorUpdate(
// "Error occured while publishing the model. The worksheet does not have a service object."));
} else
service = wk.getMetadataContainer().getService();
AlignmentManager mgr = AlignmentManager.Instance();
String alignmentId = mgr.constructAlignmentId(workspace.getId(), worksheetId);
Alignment al = mgr.getAlignment(alignmentId);
if (al == null) {
logger.error("The alignment model is null.");
if (service == null)
return new UpdateContainer(new ErrorUpdate(
"Error occured while publishing the source. The alignment model is null."));
}
DirectedWeightedMultigraph<Node, LabeledLink> tree = null;
if (al != null)
tree = al.getSteinerTree();
if (tree == null) {
logger.error("The alignment tree is null.");
if (service == null)
return new UpdateContainer(new ErrorUpdate(
"Error occured while publishing the source. The alignment tree is null."));
}
if (service != null) service.updateModel(tree);
else {
source = new DataSource(wk.getTitle(), tree);
MetadataContainer metaData = wk.getMetadataContainer();
if (metaData == null) {
metaData = new MetadataContainer();
wk.setMetadataContainer(metaData);
}
metaData.setSource(source);
logger.info("Source added to the Worksheet.");
}
try {
if (service != null) {
WebServicePublisher servicePublisher = new WebServicePublisher(service);
servicePublisher.publish(Repository.Instance().LANG, true);
logger.info("Service model has successfully been published to repository: " + service.getId());
return new UpdateContainer(new InfoUpdate(
"Service model has successfully been published to repository: " + service.getId()));
} else { //if (source != null) {
DataSourcePublisher sourcePublisher = new DataSourcePublisher(source, workspace.getFactory(), wk.getMetadataContainer().getSourceInformation());
sourcePublisher.publish(Repository.Instance().LANG, true);
logger.info("Source model has successfully been published to repository: " + source.getId());
return new UpdateContainer(new InfoUpdate(