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 enum InputRequestType {
Save, SoftwareCreate;
Save, MainCodeSet, BinaryCodeSet, SoftwareCreate;
}
private InputRequestType inputRequestType;
private ItemDescription mainCodeItemDescription;
private ItemDescription binaryCodeItemDescription;
public StatAlgoImporterController() {
eventBus = new SimpleEventBus();
@ -352,6 +354,12 @@ public class StatAlgoImporterController {
case SoftwareCreate:
pm.softwareCreate(event.getInputData(), monitor);
break;
case MainCodeSet:
pm.setMainCode(event.getInputData(), mainCodeItemDescription);
break;
case BinaryCodeSet:
pm.setBinaryCode(event.getInputData(), binaryCodeItemDescription);
break;
default:
break;
@ -427,17 +435,26 @@ public class StatAlgoImporterController {
}
private void doMainCodeSetCommand(MainCodeSetEvent event) {
ItemDescription itemDescription = event.getItemDescription();
if (itemDescription != null && itemDescription.getId() != null) {
pm.setMainCode(itemDescription);
ItemDescription mainCodeItemDesc = event.getItemDescription();
if (mainCodeItemDesc != null && mainCodeItemDesc.getId() != null) {
mainCodeItemDescription=mainCodeItemDesc;
inputRequestType = InputRequestType.MainCodeSet;
InputRequestEvent inputRequestEvent = new InputRequestEvent();
eventBus.fireEvent(inputRequestEvent);
Log.debug("ProjectMainCodeSetRequest: " + inputRequestEvent);
}
}
private void doBinaryCodeSetCommand(BinaryCodeSetEvent event) {
ItemDescription itemDescription = event.getItemDescription();
if (itemDescription != null && itemDescription.getId() != null) {
pm.setBinaryCode(itemDescription);
ItemDescription binaryCodeItemDesc = event.getItemDescription();
if (binaryCodeItemDesc != null && binaryCodeItemDesc.getId() != null) {
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.getMainCode() != null && project.getMainCode().getItemDescription() != null) {
final ConfirmMessageBox mb = new ConfirmMessageBox("Attention",
@ -444,11 +444,14 @@ public class ProjectManager {
public void onDialogHide(DialogHideEvent event) {
switch (event.getHideButton()) {
case NO:
mb.hide();
break;
case YES:
setMainCodeOnServer(itemDescription);
mb.hide();
saveInputDataForMainSet(inputData,itemDescription);
break;
default:
break;
}
@ -457,14 +460,40 @@ public class ProjectManager {
mb.setWidth(300);
mb.show();
} else {
setMainCodeOnServer(itemDescription);
saveInputDataForMainSet(inputData, itemDescription);
}
} 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) {
@ -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.getProjectConfig() != null && project.getProjectConfig().getProjectSupport() != null
&& project.getProjectConfig().getProjectSupport() instanceof ProjectSupportBlackBox) {
setBinaryCodeOnServer(itemDescription);
saveInputDataForBinarySet(inputData,itemDescription);
}
} 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) {

View File

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