Fixed R code add

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/statistical-algorithms-importer@160640 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2017-12-18 12:01:19 +00:00
parent 3b6ade4f1c
commit 170cf1eb2a
6 changed files with 37 additions and 26 deletions

View File

@ -56,12 +56,15 @@ public class StatAlgoImporterController {
private StatAlgoImporterMonitor monitor; private StatAlgoImporterMonitor monitor;
private enum InputRequestType { private enum InputRequestType {
Save, MainCodeSet, BinaryCodeSet, SoftwareCreate; Save, NewMainCodeSet, MainCodeSet, BinaryCodeSet, SoftwareCreate;
} }
private InputRequestType inputRequestType; private InputRequestType inputRequestType;
private NewCodeEvent newCodeEvent;
private ItemDescription mainCodeItemDescription; private ItemDescription mainCodeItemDescription;
private ItemDescription binaryCodeItemDescription; private ItemDescription binaryCodeItemDescription;
public StatAlgoImporterController() { public StatAlgoImporterController() {
eventBus = new SimpleEventBus(); eventBus = new SimpleEventBus();
@ -321,10 +324,10 @@ public class StatAlgoImporterController {
UtilsGXT3.alert("Attention", event.getError()); UtilsGXT3.alert("Attention", event.getError());
return; return;
} else { } else {
if(inputRequestType==null){ if (inputRequestType == null) {
return; return;
} }
switch (inputRequestType) { switch (inputRequestType) {
case Save: case Save:
pm.saveProject(event.getInputData(), monitor); pm.saveProject(event.getInputData(), monitor);
@ -332,6 +335,9 @@ public class StatAlgoImporterController {
case SoftwareCreate: case SoftwareCreate:
pm.softwareCreate(event.getInputData(), monitor); pm.softwareCreate(event.getInputData(), monitor);
break; break;
case NewMainCodeSet:
pm.setNewCode(event.getInputData(),newCodeEvent, monitor);
break;
case MainCodeSet: case MainCodeSet:
pm.setMainCode(event.getInputData(), mainCodeItemDescription); pm.setMainCode(event.getInputData(), mainCodeItemDescription);
break; break;
@ -359,9 +365,9 @@ public class StatAlgoImporterController {
final ConfirmMessageBox mb = new ConfirmMessageBox("Attention", final ConfirmMessageBox mb = new ConfirmMessageBox("Attention",
"The creation of new software will overwrite the possible previous version, moreover" "The creation of new software will overwrite the possible previous version, moreover"
+ " the compiled software will be notified to the Infrastructure Administrators" + " the compiled software will be notified to the Infrastructure Administrators"
+ " and will be published in the suggested VREs. The source code will not be shared." + " and will be published in the suggested VREs. The source code will not be shared."
+ " Do you confirm the submission?"); + " Do you confirm the submission?");
mb.addDialogHideHandler(new DialogHideHandler() { mb.addDialogHideHandler(new DialogHideHandler() {
@Override @Override
@ -386,8 +392,6 @@ public class StatAlgoImporterController {
mb.show(); mb.show();
} }
private void softwareRepackage() { private void softwareRepackage() {
pm.softwareRepackage(); pm.softwareRepackage();
@ -438,10 +442,16 @@ public class StatAlgoImporterController {
private void doSetNewMainCodeEvent(NewCodeEvent event) { private void doSetNewMainCodeEvent(NewCodeEvent event) {
monitor = new StatAlgoImporterMonitor(); monitor = new StatAlgoImporterMonitor();
pm.setNewCode(event, monitor); newCodeEvent = event;
inputRequestType = InputRequestType.NewMainCodeSet;
InputRequestEvent inputRequestEvent = new InputRequestEvent();
eventBus.fireEvent(inputRequestEvent);
Log.debug("ProjectNewMainCodeSetRequest: " + inputRequestEvent);
} }
private void doDeleteItemCommand(DeleteItemEvent event) { private void doDeleteItemCommand(DeleteItemEvent event) {
ItemDescription itemDescription = event.getItemDescription(); ItemDescription itemDescription = event.getItemDescription();
if (itemDescription != null && itemDescription.getId() != null) { if (itemDescription != null && itemDescription.getId() != null) {

View File

@ -55,7 +55,7 @@ public class NewCodeEvent extends GwtEvent<NewCodeEvent.NewCodeEventHandler> {
source.fireEvent(saveNewMainCodeEvent); source.fireEvent(saveNewMainCodeEvent);
} }
public CodeContentType getCodeType() { public CodeContentType getCodeContentType() {
return codeContentType; return codeContentType;
} }
@ -72,6 +72,4 @@ public class NewCodeEvent extends GwtEvent<NewCodeEvent.NewCodeEventHandler> {
return "NewCodeEvent [codeContentType=" + codeContentType + ", file=" + file + ", code=" + code + "]"; return "NewCodeEvent [codeContentType=" + codeContentType + ", file=" + file + ", code=" + code + "]";
} }
} }

View File

@ -529,8 +529,8 @@ public class ProjectManager {
} }
public void setNewCode(NewCodeEvent newCodeEvent, final StatAlgoImporterMonitor monitor) { public void setNewCode(InputData inputData, NewCodeEvent newCodeEvent, final StatAlgoImporterMonitor monitor) {
StatAlgoImporterServiceAsync.INSTANCE.setNewCode(newCodeEvent.getFile(), newCodeEvent.getCode(), StatAlgoImporterServiceAsync.INSTANCE.setNewCode(inputData, newCodeEvent.getFile(), newCodeEvent.getCode(),
new AsyncCallback<Project>() { new AsyncCallback<Project>() {
@Override @Override

View File

@ -36,7 +36,8 @@ public interface StatAlgoImporterService extends RemoteService {
* Retrieve SAI descriptort * Retrieve SAI descriptort
* *
* @return SAI descriptort * @return SAI descriptort
* @throws StatAlgoImporterServiceException Exception * @throws StatAlgoImporterServiceException
* Exception
*/ */
public SAIDescriptor getSAIDescripor() throws StatAlgoImporterServiceException; public SAIDescriptor getSAIDescripor() throws StatAlgoImporterServiceException;
@ -53,13 +54,14 @@ public interface StatAlgoImporterService extends RemoteService {
// Code // Code
public ArrayList<CodeData> getCode() throws StatAlgoImporterServiceException; public ArrayList<CodeData> getCode() throws StatAlgoImporterServiceException;
public Project createProjectOnWorkspace(ProjectCreateSession projectCreateSession) throws StatAlgoImporterServiceException; public Project createProjectOnWorkspace(ProjectCreateSession projectCreateSession)
throws StatAlgoImporterServiceException;
// //
public Project setMainCode(ItemDescription itemDescription) throws StatAlgoImporterServiceException; public Project setMainCode(ItemDescription itemDescription) throws StatAlgoImporterServiceException;
public Project setBinaryCode(ItemDescription itemDescription) throws StatAlgoImporterServiceException; public Project setBinaryCode(ItemDescription itemDescription) throws StatAlgoImporterServiceException;
public void addResourceToProject(ItemDescription itemDescription) throws StatAlgoImporterServiceException; public void addResourceToProject(ItemDescription itemDescription) throws StatAlgoImporterServiceException;
public Project deleteResourceOnProject(ItemDescription itemDescription) throws StatAlgoImporterServiceException; public Project deleteResourceOnProject(ItemDescription itemDescription) throws StatAlgoImporterServiceException;
@ -76,15 +78,15 @@ public interface StatAlgoImporterService extends RemoteService {
public Project restoreUISession(String value) throws StatAlgoImporterServiceException; public Project restoreUISession(String value) throws StatAlgoImporterServiceException;
public Project setNewCode(ItemDescription itemDescription, String code) throws StatAlgoImporterServiceException; public Project setNewCode(InputData inputData, ItemDescription itemDescription, String code)
throws StatAlgoImporterServiceException;
public String publishSoftware() throws StatAlgoImporterServiceException; public String publishSoftware() throws StatAlgoImporterServiceException;
public String getDeployOperationStatus(String operationId) throws StatAlgoImporterServiceException; public String getDeployOperationStatus(String operationId) throws StatAlgoImporterServiceException;
public String getDeployOperationLogs(String operationId) throws StatAlgoImporterServiceException; public String getDeployOperationLogs(String operationId) throws StatAlgoImporterServiceException;
public void repackageSoftware() throws StatAlgoImporterServiceException; public void repackageSoftware() throws StatAlgoImporterServiceException;
} }

View File

@ -52,7 +52,7 @@ public interface StatAlgoImporterServiceAsync {
void saveCode(String code, AsyncCallback<Void> asyncCallback); void saveCode(String code, AsyncCallback<Void> asyncCallback);
void setNewCode(ItemDescription itemDescription, String code, AsyncCallback<Project> asyncCallback); void setNewCode(InputData inputData, ItemDescription itemDescription, String code, AsyncCallback<Project> asyncCallback);
void createSoftware(InputData inputData, AsyncCallback<Project> callback); void createSoftware(InputData inputData, AsyncCallback<Project> callback);

View File

@ -593,11 +593,11 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
} }
@Override @Override
public Project setNewCode(ItemDescription fileDescription, String code) throws StatAlgoImporterServiceException { public Project setNewCode(InputData inputData,ItemDescription fileDescription, String code) throws StatAlgoImporterServiceException {
try { try {
HttpServletRequest httpRequest = this.getThreadLocalRequest(); HttpServletRequest httpRequest = this.getThreadLocalRequest();
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest); ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
logger.debug("saveNewCode(): itemDescription" + fileDescription + ", code:" + code); logger.debug("setNewCode(): "+inputData+", " + fileDescription + ", " + code);
Project project = SessionUtil.getProjectSession(httpRequest, serviceCredentials); Project project = SessionUtil.getProjectSession(httpRequest, serviceCredentials);
if (project != null && project.getProjectFolder() != null if (project != null && project.getProjectFolder() != null
&& project.getProjectFolder().getFolder() != null) { && project.getProjectFolder().getFolder() != null) {
@ -609,9 +609,9 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
code, project.getProjectFolder().getFolder().getId()); code, project.getProjectFolder().getFolder().getId());
MainCode mainCode = new MainCode(mainCodeItemDescription); MainCode mainCode = new MainCode(mainCodeItemDescription);
project.setMainCode(mainCode); project.setMainCode(mainCode);
InputData inputData=project.getInputData();
if(inputData!=null){ if(inputData!=null){
inputData.setListInputOutputVariables(null); inputData.setListInputOutputVariables(null);
project.setInputData(inputData);
} }
project.setProjectTarget(null); project.setProjectTarget(null);
WPS4RParser wps4Parser = new WPS4RParser(project, serviceCredentials); WPS4RParser wps4Parser = new WPS4RParser(project, serviceCredentials);
@ -625,6 +625,7 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
ItemDescription binaryCodeItemDescription = codeSave.saveNew(serviceCredentials, ItemDescription binaryCodeItemDescription = codeSave.saveNew(serviceCredentials,
fileDescription, code, project.getProjectFolder().getFolder().getId()); fileDescription, code, project.getProjectFolder().getFolder().getId());
projectSupportBashEdit.setBinaryItem(binaryCodeItemDescription); projectSupportBashEdit.setBinaryItem(binaryCodeItemDescription);
project.setInputData(inputData);
project.setProjectTarget(null); project.setProjectTarget(null);
} else { } else {
throw new StatAlgoImporterServiceException("Error in project support!"); throw new StatAlgoImporterServiceException("Error in project support!");