ref 8819: Extend The Algorithms Importer to Manage Many Processes as Black Boxes

https://support.d4science.org/issues/8819

Updated the support for Processes as Black Boxes

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/statistical-algorithms-importer@150440 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2017-06-19 17:18:14 +00:00
parent 0792103e86
commit 7a61bafdcf
3 changed files with 87 additions and 18 deletions

View File

@ -56,10 +56,12 @@ public class StatAlgoImporterController {
private StatAlgoImporterMonitor monitor; private StatAlgoImporterMonitor monitor;
private enum InputRequestType { private enum InputRequestType {
Save, SoftwareCreate; Save, MainCodeSet, BinaryCodeSet, SoftwareCreate;
} }
private InputRequestType inputRequestType; private InputRequestType inputRequestType;
private ItemDescription mainCodeItemDescription;
private ItemDescription binaryCodeItemDescription;
public StatAlgoImporterController() { public StatAlgoImporterController() {
eventBus = new SimpleEventBus(); eventBus = new SimpleEventBus();
@ -352,6 +354,12 @@ public class StatAlgoImporterController {
case SoftwareCreate: case SoftwareCreate:
pm.softwareCreate(event.getInputData(), monitor); pm.softwareCreate(event.getInputData(), monitor);
break; break;
case MainCodeSet:
pm.setMainCode(event.getInputData(), mainCodeItemDescription);
break;
case BinaryCodeSet:
pm.setBinaryCode(event.getInputData(), binaryCodeItemDescription);
break;
default: default:
break; break;
@ -427,17 +435,26 @@ public class StatAlgoImporterController {
} }
private void doMainCodeSetCommand(MainCodeSetEvent event) { private void doMainCodeSetCommand(MainCodeSetEvent event) {
ItemDescription itemDescription = event.getItemDescription(); ItemDescription mainCodeItemDesc = event.getItemDescription();
if (itemDescription != null && itemDescription.getId() != null) { if (mainCodeItemDesc != null && mainCodeItemDesc.getId() != null) {
pm.setMainCode(itemDescription); mainCodeItemDescription=mainCodeItemDesc;
inputRequestType = InputRequestType.MainCodeSet;
InputRequestEvent inputRequestEvent = new InputRequestEvent();
eventBus.fireEvent(inputRequestEvent);
Log.debug("ProjectMainCodeSetRequest: " + inputRequestEvent);
} }
} }
private void doBinaryCodeSetCommand(BinaryCodeSetEvent event) { private void doBinaryCodeSetCommand(BinaryCodeSetEvent event) {
ItemDescription itemDescription = event.getItemDescription(); ItemDescription binaryCodeItemDesc = event.getItemDescription();
if (itemDescription != null && itemDescription.getId() != null) { if (binaryCodeItemDesc != null && binaryCodeItemDesc.getId() != null) {
pm.setBinaryCode(itemDescription); binaryCodeItemDescription=binaryCodeItemDesc;
inputRequestType = InputRequestType.BinaryCodeSet;
InputRequestEvent inputRequestEvent = new InputRequestEvent();
eventBus.fireEvent(inputRequestEvent);
Log.debug("ProjectBinaryCodeSetRequest: " + inputRequestEvent);
} }
} }

View File

@ -433,7 +433,7 @@ public class ProjectManager {
} }
public void setMainCode(final ItemDescription itemDescription) { public void setMainCode(final InputData inputData, final ItemDescription itemDescription) {
if (project != null) { if (project != null) {
if (project.getMainCode() != null && project.getMainCode().getItemDescription() != null) { if (project.getMainCode() != null && project.getMainCode().getItemDescription() != null) {
final ConfirmMessageBox mb = new ConfirmMessageBox("Attention", final ConfirmMessageBox mb = new ConfirmMessageBox("Attention",
@ -444,11 +444,14 @@ public class ProjectManager {
public void onDialogHide(DialogHideEvent event) { public void onDialogHide(DialogHideEvent event) {
switch (event.getHideButton()) { switch (event.getHideButton()) {
case NO: case NO:
mb.hide();
break; break;
case YES: case YES:
setMainCodeOnServer(itemDescription); mb.hide();
saveInputDataForMainSet(inputData,itemDescription);
break; break;
default: default:
break; break;
} }
@ -457,14 +460,40 @@ public class ProjectManager {
mb.setWidth(300); mb.setWidth(300);
mb.show(); mb.show();
} else { } else {
setMainCodeOnServer(itemDescription); saveInputDataForMainSet(inputData, itemDescription);
} }
} else { } else {
} }
} }
private void saveInputDataForMainSet(final InputData inputData, final ItemDescription itemDescription){
StatAlgoImporterServiceAsync.INSTANCE.saveProject(inputData, new AsyncCallback<Void>() {
@Override
public void onSuccess(Void result) {
setMainCodeOnServer(itemDescription);
/*
UtilsGXT3.info("Save", "Project saved!");
fireProjectStatusExplorerRefreshEvent();*/
}
@Override
public void onFailure(Throwable caught) {
if (caught instanceof StatAlgoImporterSessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(SessionExpiredType.EXPIREDONSERVER));
} else {
Log.error("Error on save project: " + caught.getLocalizedMessage());
UtilsGXT3.alert("Error", caught.getLocalizedMessage());
}
caught.printStackTrace();
}
});
}
private void setMainCodeOnServer(final ItemDescription itemDescription) { private void setMainCodeOnServer(final ItemDescription itemDescription) {
@ -519,11 +548,11 @@ public class ProjectManager {
}); });
} }
public void setBinaryCode(final ItemDescription itemDescription) { public void setBinaryCode(final InputData inputData,final ItemDescription itemDescription) {
if (project != null) { if (project != null) {
if (project.getProjectConfig() != null && project.getProjectConfig().getProjectSupport() != null if (project.getProjectConfig() != null && project.getProjectConfig().getProjectSupport() != null
&& project.getProjectConfig().getProjectSupport() instanceof ProjectSupportBlackBox) { && project.getProjectConfig().getProjectSupport() instanceof ProjectSupportBlackBox) {
setBinaryCodeOnServer(itemDescription); saveInputDataForBinarySet(inputData,itemDescription);
} }
} else { } else {
@ -531,6 +560,29 @@ public class ProjectManager {
} }
} }
private void saveInputDataForBinarySet(final InputData inputData, final ItemDescription itemDescription){
StatAlgoImporterServiceAsync.INSTANCE.saveProject(inputData, new AsyncCallback<Void>() {
@Override
public void onSuccess(Void result) {
setBinaryCodeOnServer(itemDescription);
}
@Override
public void onFailure(Throwable caught) {
if (caught instanceof StatAlgoImporterSessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(SessionExpiredType.EXPIREDONSERVER));
} else {
Log.error("Error on save project: " + caught.getLocalizedMessage());
UtilsGXT3.alert("Error", caught.getLocalizedMessage());
}
caught.printStackTrace();
}
});
}
private void setBinaryCodeOnServer(final ItemDescription itemDescription) { private void setBinaryCodeOnServer(final ItemDescription itemDescription) {

View File

@ -43,7 +43,7 @@ public class InputVariablePanel extends ContentPanel {
} }
protected void init() { private void init() {
setId("InputVariablePanel"); setId("InputVariablePanel");
setHeaderVisible(true); setHeaderVisible(true);
setAnimCollapse(false); setAnimCollapse(false);
@ -55,7 +55,7 @@ public class InputVariablePanel extends ContentPanel {
} }
protected void bindToEvents() { private void bindToEvents() {
eventBus.addHandler(ProjectStatusEvent.TYPE, eventBus.addHandler(ProjectStatusEvent.TYPE,
new ProjectStatusEvent.ProjectStatusEventHandler() { new ProjectStatusEvent.ProjectStatusEventHandler() {
@ -94,17 +94,17 @@ public class InputVariablePanel extends ContentPanel {
Log.debug("InputVariablePanel bind to Event do!"); Log.debug("InputVariablePanel bind to Event do!");
} }
protected void addNewSelectedRowsVariable( private void addNewSelectedRowsVariable(
InputOutputVariables selectedRowsVariable) { InputOutputVariables selectedRowsVariable) {
inputVariableTabPanel.addSelectedRowsVariable(selectedRowsVariable); inputVariableTabPanel.addSelectedRowsVariable(selectedRowsVariable);
} }
protected void manageInputRequestEvents(InputRequestEvent event) { private void manageInputRequestEvents(InputRequestEvent event) {
inputVariableTabPanel.requestInput(); inputVariableTabPanel.requestInput();
} }
protected void manageProjectStatusEvents(ProjectStatusEvent event) { private void manageProjectStatusEvents(ProjectStatusEvent event) {
Log.debug("InputVariablePanel recieved event ProjectStatus: " Log.debug("InputVariablePanel recieved event ProjectStatus: "
+ event.toString()); + event.toString());
switch (event.getProjectStatusEventType()) { switch (event.getProjectStatusEventType()) {