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@150987 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2017-07-10 17:51:25 +00:00
parent 25f7b58415
commit 942471cd66
13 changed files with 607 additions and 516 deletions

View File

@ -49,7 +49,7 @@ public class StatAlgoImporterController {
private SimpleEventBus eventBus;
private UserInfo userInfo;
@SuppressWarnings("unused")
private BorderLayoutContainer mainPanel;
private ProjectManager pm;
@ -72,18 +72,17 @@ public class StatAlgoImporterController {
callHello();
checkSession();
pm = new ProjectManager(eventBus);
//pm.startProjectManager();
// pm.startProjectManager();
bindToEvents();
}
private void checkSession() {
// if you do not need to something when the session expire
//CheckSession.getInstance().startPolling();
// CheckSession.getInstance().startPolling();
}
private void sessionExpiredShow() {
//CheckSession.showLogoutDialog();
// CheckSession.showLogoutDialog();
}
/**
@ -98,31 +97,27 @@ public class StatAlgoImporterController {
}
private void callHello() {
StatAlgoImporterServiceAsync.INSTANCE
.hello(new AsyncCallback<UserInfo>() {
StatAlgoImporterServiceAsync.INSTANCE.hello(new AsyncCallback<UserInfo>() {
@Override
public void onFailure(Throwable caught) {
Log.info("No valid user found: " + caught.getMessage());
if (caught instanceof StatAlgoImporterSessionExpiredException) {
UtilsGXT3.alert("Error", "Expired Session");
sessionExpiredShowDelayed();
} else {
UtilsGXT3.alert(
"Error",
"No user found: "
+ caught.getLocalizedMessage());
}
}
@Override
public void onFailure(Throwable caught) {
Log.info("No valid user found: " + caught.getMessage());
if (caught instanceof StatAlgoImporterSessionExpiredException) {
UtilsGXT3.alert("Error", "Expired Session");
sessionExpiredShowDelayed();
} else {
UtilsGXT3.alert("Error", "No user found: " + caught.getLocalizedMessage());
}
}
@Override
public void onSuccess(UserInfo result) {
userInfo = result;
Log.info("Hello: " + userInfo.getUsername());
@Override
public void onSuccess(UserInfo result) {
userInfo = result;
Log.info("Hello: " + userInfo.getUsername());
}
}
});
});
}
@ -146,10 +141,8 @@ public class StatAlgoImporterController {
Log.debug("Locale avaible:" + locale);
}
String currentLocaleCookie = Cookies.getCookie(LocaleInfo
.getLocaleCookieName());
Log.debug(Constants.STATISTICAL_ALGORITHMS_IMPORTER_COOKIE + ":"
+ currentLocaleCookie);
String currentLocaleCookie = Cookies.getCookie(LocaleInfo.getLocaleCookieName());
Log.debug(Constants.STATISTICAL_ALGORITHMS_IMPORTER_COOKIE + ":" + currentLocaleCookie);
LocaleInfo currentLocaleInfo = LocaleInfo.getCurrentLocale();
Log.debug("Current Locale:" + currentLocaleInfo.getLocaleName());
@ -161,13 +154,11 @@ public class StatAlgoImporterController {
long nowLong = now.getTime();
nowLong = nowLong + (1000 * 60 * 60 * 24 * 21);
now.setTime(nowLong);
String cookieLang = Cookies
.getCookie(Constants.STATISTICAL_ALGORITHMS_IMPORTER_COOKIE);
String cookieLang = Cookies.getCookie(Constants.STATISTICAL_ALGORITHMS_IMPORTER_COOKIE);
if (cookieLang != null) {
Cookies.removeCookie(Constants.STATISTICAL_ALGORITHMS_IMPORTER_COOKIE);
}
Cookies.setCookie(Constants.STATISTICAL_ALGORITHMS_IMPORTER_COOKIE,
localeName, now);
Cookies.setCookie(Constants.STATISTICAL_ALGORITHMS_IMPORTER_COOKIE, localeName, now);
com.google.gwt.user.client.Window.Location.reload();
}
@ -182,21 +173,17 @@ public class StatAlgoImporterController {
}
// Bind Controller to events on bus
private void bindToEvents() {
eventBus.addHandler(SessionExpiredEvent.TYPE,
new SessionExpiredEvent.SessionExpiredEventHandler() {
eventBus.addHandler(SessionExpiredEvent.TYPE, new SessionExpiredEvent.SessionExpiredEventHandler() {
@Override
public void onSessionExpired(SessionExpiredEvent event) {
Log.debug("Catch Event SessionExpiredEvent");
doSessionExpiredCommand(event);
@Override
public void onSessionExpired(SessionExpiredEvent event) {
Log.debug("Catch Event SessionExpiredEvent");
doSessionExpiredCommand(event);
}
});
}
});
eventBus.addHandler(StatAlgoImporterRibbonEvent.TYPE,
new StatAlgoImporterRibbonEvent.StatRunnerRibbonEventHandler() {
@ -209,74 +196,61 @@ public class StatAlgoImporterController {
}
});
eventBus.addHandler(MainCodeSetEvent.TYPE,
new MainCodeSetEvent.MainCodeSetEventHandler() {
eventBus.addHandler(MainCodeSetEvent.TYPE, new MainCodeSetEvent.MainCodeSetEventHandler() {
@Override
public void onMainCodeSet(MainCodeSetEvent event) {
Log.debug("Catch MainCodeSetEvent");
doMainCodeSetCommand(event);
@Override
public void onMainCodeSet(MainCodeSetEvent event) {
Log.debug("Catch MainCodeSetEvent");
doMainCodeSetCommand(event);
}
}
});
});
eventBus.addHandler(BinaryCodeSetEvent.TYPE,
new BinaryCodeSetEvent.BinaryCodeSetEventHandler() {
eventBus.addHandler(BinaryCodeSetEvent.TYPE, new BinaryCodeSetEvent.BinaryCodeSetEventHandler() {
@Override
public void onBinaryCodeSet(BinaryCodeSetEvent event) {
Log.debug("Catch BinaryCodeSetEvent");
doBinaryCodeSetCommand(event);
@Override
public void onBinaryCodeSet(BinaryCodeSetEvent event) {
Log.debug("Catch BinaryCodeSetEvent");
doBinaryCodeSetCommand(event);
}
}
});
});
eventBus.addHandler(DeleteItemEvent.TYPE,
new DeleteItemEvent.DeleteItemEventHandler() {
eventBus.addHandler(DeleteItemEvent.TYPE, new DeleteItemEvent.DeleteItemEventHandler() {
@Override
public void onDelete(DeleteItemEvent event) {
Log.debug("Catch DeleteItemEvent");
doDeleteItemCommand(event);
@Override
public void onDelete(DeleteItemEvent event) {
Log.debug("Catch DeleteItemEvent");
doDeleteItemCommand(event);
}
}
});
});
eventBus.addHandler(InputReadyEvent.TYPE,
new InputReadyEvent.InputReadyEventHandler() {
eventBus.addHandler(InputReadyEvent.TYPE, new InputReadyEvent.InputReadyEventHandler() {
@Override
public void onInputReady(InputReadyEvent event) {
Log.debug("Catch InputReadyEvent");
doInputReadyCommand(event);
@Override
public void onInputReady(InputReadyEvent event) {
Log.debug("Catch InputReadyEvent");
doInputReadyCommand(event);
}
});
}
});
eventBus.addHandler(NewCodeEvent.TYPE,
new NewCodeEvent.NewCodeEventHandler() {
eventBus.addHandler(NewCodeEvent.TYPE, new NewCodeEvent.NewCodeEventHandler() {
@Override
public void onSet(NewCodeEvent event) {
Log.debug("Catch SaveNewMainCodeEvent");
doSetNewMainCodeEvent(event);
@Override
public void onSet(NewCodeEvent event) {
Log.debug("Catch SaveNewMainCodeEvent");
doSetNewMainCodeEvent(event);
}
}
});
});
}
private void doMenuCommand(StatAlgoImporterRibbonEvent event) {
StatAlgoImporterRibbonType eventType = event.getStatRunnerRibbonType();
@ -300,7 +274,7 @@ public class StatAlgoImporterController {
break;
case RESOURCE_GITHUB:
showGitHubWizard();
break;
break;
case SOFTWARE_CREATE:
softwareCreateRequest();
break;
@ -322,21 +296,17 @@ public class StatAlgoImporterController {
private void showHelp() {
try {
StatAlgoImporterResources.INSTANCE.wikiLink().getText(
new ResourceCallback<TextResource>() {
public void onError(ResourceException e) {
Log.error("Error retrieving wiki link!: "
+ e.getLocalizedMessage());
UtilsGXT3.alert("Error",
"Error retrieving wiki link!");
}
StatAlgoImporterResources.INSTANCE.wikiLink().getText(new ResourceCallback<TextResource>() {
public void onError(ResourceException e) {
Log.error("Error retrieving wiki link!: " + e.getLocalizedMessage());
UtilsGXT3.alert("Error", "Error retrieving wiki link!");
}
public void onSuccess(TextResource r) {
String s = r.getText();
Window.open(s,
"Statistical Algorithms Importer Wiki", "");
}
});
public void onSuccess(TextResource r) {
String s = r.getText();
Window.open(s, "Statistical Algorithms Importer Wiki", "");
}
});
} catch (ResourceException e) {
Log.error("Error retrieving wiki link!: " + e.getLocalizedMessage());
UtilsGXT3.alert("Error", "Error retrieving wiki link!");
@ -347,6 +317,13 @@ public class StatAlgoImporterController {
}
private void doInputReadyCommand(InputReadyEvent event) {
if (!event.isValidData()) {
if (monitor != null) {
monitor.hide();
return;
}
}
switch (inputRequestType) {
case Save:
pm.saveProject(event.getInputData(), monitor);
@ -377,11 +354,9 @@ public class StatAlgoImporterController {
private void softwareCreateRequest() {
final ConfirmMessageBox mb = new ConfirmMessageBox(
"Warning",
final ConfirmMessageBox mb = new ConfirmMessageBox("Warning",
"The creation of new software will overwrite the possible"
+ " previous version and will require publication again."
+ " Do you want to proceed anyway?");
+ " previous version and will require publication again." + " Do you want to proceed anyway?");
mb.addDialogHideHandler(new DialogHideHandler() {
@Override
@ -410,7 +385,7 @@ public class StatAlgoImporterController {
pm.softwarePublish();
}
private void softwareRepackage() {
pm.softwareRepackage();
@ -426,10 +401,10 @@ public class StatAlgoImporterController {
}
private void showGitHubWizard(){
private void showGitHubWizard() {
pm.addGitHubProject();
}
private void showAddResourceDialog() {
pm.addResource();
}
@ -437,20 +412,20 @@ public class StatAlgoImporterController {
private void doMainCodeSetCommand(MainCodeSetEvent event) {
ItemDescription mainCodeItemDesc = event.getItemDescription();
if (mainCodeItemDesc != null && mainCodeItemDesc.getId() != null) {
mainCodeItemDescription=mainCodeItemDesc;
mainCodeItemDescription = mainCodeItemDesc;
inputRequestType = InputRequestType.MainCodeSet;
InputRequestEvent inputRequestEvent = new InputRequestEvent();
eventBus.fireEvent(inputRequestEvent);
Log.debug("ProjectMainCodeSetRequest: " + inputRequestEvent);
}
}
private void doBinaryCodeSetCommand(BinaryCodeSetEvent event) {
ItemDescription binaryCodeItemDesc = event.getItemDescription();
if (binaryCodeItemDesc != null && binaryCodeItemDesc.getId() != null) {
binaryCodeItemDescription=binaryCodeItemDesc;
binaryCodeItemDescription = binaryCodeItemDesc;
inputRequestType = InputRequestType.BinaryCodeSet;
InputRequestEvent inputRequestEvent = new InputRequestEvent();
eventBus.fireEvent(inputRequestEvent);
@ -458,7 +433,6 @@ public class StatAlgoImporterController {
}
}
private void doSetNewMainCodeEvent(NewCodeEvent event) {
monitor = new StatAlgoImporterMonitor();
@ -489,8 +463,7 @@ public class StatAlgoImporterController {
@SuppressWarnings("unused")
private void asyncCodeLoadingFailed(Throwable reason) {
Log.error("Async code loading failed", reason);
eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
eventBus.fireEvent(new SessionExpiredEvent(SessionExpiredType.EXPIREDONSERVER));
}

View File

@ -36,17 +36,14 @@ public class CodeParser {
String[] varDescription = parameter.split("<-");
String checkDataTypeValue = varDescription[1].trim();
if (checkDataTypeValue.endsWith(";"))
checkDataTypeValue = checkDataTypeValue.substring(0,
checkDataTypeValue.length() - 1);
checkDataTypeValue = checkDataTypeValue.substring(0, checkDataTypeValue.length() - 1);
String defaultValue = varDescription[1].trim();
if (defaultValue.endsWith(";"))
defaultValue = defaultValue.substring(0,
defaultValue.length() - 1);
defaultValue = defaultValue.substring(0, defaultValue.length() - 1);
if (defaultValue.startsWith("\""))
defaultValue = defaultValue.substring(1);
if (defaultValue.endsWith("\""))
defaultValue = defaultValue.substring(0,
defaultValue.length() - 1);
defaultValue = defaultValue.substring(0, defaultValue.length() - 1);
String[] def = defaultValue.split("\"");
if (def.length > 2) {
defaultValue = def[0];
@ -55,31 +52,25 @@ public class CodeParser {
}
}
if (ioType.compareTo(IOType.OUTPUT) == 0) {
selectedRowsVariables = new InputOutputVariables(
varDescription[0].trim(), varDescription[0].trim(),
selectedRowsVariables = new InputOutputVariables(varDescription[0].trim(), varDescription[0].trim(),
defaultValue, DataType.FILE, ioType, parameter);
} else {
selectedRowsVariables = new InputOutputVariables(
varDescription[0].trim(), varDescription[0].trim(),
defaultValue, checkDataType(checkDataTypeValue),
ioType, parameter);
selectedRowsVariables = new InputOutputVariables(varDescription[0].trim(), varDescription[0].trim(),
defaultValue, checkDataType(checkDataTypeValue), ioType, parameter);
}
} else {
if (parameter.contains("=")) {
String[] varDescription = parameter.split("=");
String checkDataTypeValue = varDescription[1].trim();
if (checkDataTypeValue.endsWith(";"))
checkDataTypeValue = checkDataTypeValue.substring(0,
checkDataTypeValue.length() - 1);
checkDataTypeValue = checkDataTypeValue.substring(0, checkDataTypeValue.length() - 1);
String defaultValue = varDescription[1].trim();
if (defaultValue.endsWith(";"))
defaultValue = defaultValue.substring(0,
defaultValue.length() - 1);
defaultValue = defaultValue.substring(0, defaultValue.length() - 1);
if (defaultValue.startsWith("\""))
defaultValue = defaultValue.substring(1);
if (defaultValue.endsWith("\""))
defaultValue = defaultValue.substring(0,
defaultValue.length() - 1);
defaultValue = defaultValue.substring(0, defaultValue.length() - 1);
String[] def = defaultValue.split("\"");
if (def.length > 2) {
defaultValue = def[0];
@ -89,14 +80,11 @@ public class CodeParser {
}
if (ioType.compareTo(IOType.OUTPUT) == 0) {
selectedRowsVariables = new InputOutputVariables(
varDescription[0].trim(), varDescription[0].trim(),
selectedRowsVariables = new InputOutputVariables(varDescription[0].trim(), varDescription[0].trim(),
defaultValue, DataType.FILE, ioType, parameter);
} else {
selectedRowsVariables = new InputOutputVariables(
varDescription[0].trim(), varDescription[0].trim(),
defaultValue, checkDataType(checkDataTypeValue),
ioType, parameter);
selectedRowsVariables = new InputOutputVariables(varDescription[0].trim(), varDescription[0].trim(),
defaultValue, checkDataType(checkDataTypeValue), ioType, parameter);
}
} else {
@ -104,6 +92,13 @@ public class CodeParser {
}
}
/*if (selectedRowsVariables != null) {
if (selectedRowsVariables.getName() != null && !selectedRowsVariables.getName().isEmpty()
&& selectedRowsVariables.getName().length() > 32) {
String nameLimited = selectedRowsVariables.getName().substring(0, 33);
selectedRowsVariables.setName(nameLimited);
}
}*/
Log.debug("CodeParser: " + selectedRowsVariables);
return selectedRowsVariables;
}

View File

@ -15,23 +15,23 @@ import com.google.gwt.event.shared.HasHandlers;
*
*
*/
public class InputReadyEvent extends
GwtEvent<InputReadyEvent.InputReadyEventHandler> {
public class InputReadyEvent extends GwtEvent<InputReadyEvent.InputReadyEventHandler> {
public static Type<InputReadyEventHandler> TYPE = new Type<InputReadyEventHandler>();
private InputData inputData;
private boolean validData;
public interface InputReadyEventHandler extends EventHandler {
void onInputReady(InputReadyEvent event);
}
public interface HasInputReadyEventHandler extends HasHandlers {
public HandlerRegistration addInputReadyEventHandler(
InputReadyEventHandler handler);
public HandlerRegistration addInputReadyEventHandler(InputReadyEventHandler handler);
}
public InputReadyEvent(InputData inputData) {
public InputReadyEvent(InputData inputData, boolean validData) {
this.inputData = inputData;
this.validData = validData;
}
@Override
@ -48,8 +48,7 @@ public class InputReadyEvent extends
return TYPE;
}
public static void fire(HasHandlers source,
InputReadyEvent inputSaveReadyEvent) {
public static void fire(HasHandlers source, InputReadyEvent inputSaveReadyEvent) {
source.fireEvent(inputSaveReadyEvent);
}
@ -57,10 +56,13 @@ public class InputReadyEvent extends
return inputData;
}
@Override
public String toString() {
return "InputReadyEvent [inputData=" + inputData + "]";
public boolean isValidData() {
return validData;
}
@Override
public String toString() {
return "InputReadyEvent [inputData=" + inputData + ", validData=" + validData + "]";
}
}

View File

@ -1,6 +1,7 @@
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.tools.input;
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.InputReadyEvent;
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.utils.UtilsGXT3;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.InputOutputVariables;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.InputData;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project;
@ -27,8 +28,7 @@ public class InputVariableTabPanel extends TabPanel {
private InterpreterInfoPanel interpreterInfoPanel;
private ProjectInfoPanel projectInfoPanel;
public InputVariableTabPanel(EventBus eventBus,
InputVariablePanel toolBoxPanel) {
public InputVariableTabPanel(EventBus eventBus, InputVariablePanel toolBoxPanel) {
super();
Log.debug("Create InpuntVariableTabPanel");
this.eventBus = eventBus;
@ -83,13 +83,12 @@ public class InputVariableTabPanel extends TabPanel {
interpreterInfoPanel.update(project);
forceLayout();
} catch (Throwable e) {
Log.error("Error in InputVariableTabPanel: "
+ e.getLocalizedMessage());
Log.error("Error in InputVariableTabPanel: " + e.getLocalizedMessage());
e.printStackTrace();
}
}
public void setBinaryCode(Project project) {
try {
globalVariablesPanel.update(project);
@ -98,13 +97,11 @@ public class InputVariableTabPanel extends TabPanel {
interpreterInfoPanel.update(project);
forceLayout();
} catch (Throwable e) {
Log.error("Error in InputVariableTabPanel: "
+ e.getLocalizedMessage());
Log.error("Error in InputVariableTabPanel: " + e.getLocalizedMessage());
e.printStackTrace();
}
}
public void updateTabs(Project project) {
try {
@ -114,37 +111,39 @@ public class InputVariableTabPanel extends TabPanel {
projectInfoPanel.update(project);
forceLayout();
} catch (Throwable e) {
Log.error("Error in InputVariableTabPanel: "
+ e.getLocalizedMessage());
Log.error("Error in InputVariableTabPanel: " + e.getLocalizedMessage());
e.printStackTrace();
}
}
public void requestInput() {
InputData inputData = new InputData();
boolean valid=true;
if (globalVariablesPanel != null) {
inputData.setListGlobalVariables(globalVariablesPanel
.getGlobalVariables());
inputData.setListGlobalVariables(globalVariablesPanel.getGlobalVariables());
}
if (inputOutputVariablesPanel != null) {
inputData.setListInputOutputVariables(inputOutputVariablesPanel
.getInputOutputVariables());
inputData.setListInputOutputVariables(inputOutputVariablesPanel.getInputOutputVariables());
}
if (interpreterInfoPanel != null) {
inputData.setInterpreterInfo(interpreterInfoPanel
.getInterpreterInfo());
inputData.setInterpreterInfo(interpreterInfoPanel.getInterpreterInfo());
}
if (projectInfoPanel != null) {
inputData.setProjectInfo(projectInfoPanel
.getProjectInfo());
}
InputReadyEvent inputReadyEvent = new InputReadyEvent(
inputData);
try {
if (projectInfoPanel != null) {
inputData.setProjectInfo(projectInfoPanel.getProjectInfo());
}
} catch (Exception e) {
Log.error("Attention invalid project info: " + e.getLocalizedMessage());
UtilsGXT3.alert("Attention", e.getLocalizedMessage());
valid=false;
}
InputReadyEvent inputReadyEvent = new InputReadyEvent(inputData,valid);
eventBus.fireEvent(inputReadyEvent);
Log.debug("Fired InputReadyEvent");
@ -152,8 +151,7 @@ public class InputVariableTabPanel extends TabPanel {
// Add
private void addInputOutputVariablesPanel(Project project) {
TabItemConfig inputOutputPanelItemConf = new TabItemConfig(
msgs.inputOutputVariables(), false);
TabItemConfig inputOutputPanelItemConf = new TabItemConfig(msgs.inputOutputVariables(), false);
inputOutputVariablesPanel = new InputOutputVariablesPanel(project, eventBus);
inputOutputVariablesPanel.setHeaderVisible(false);
@ -162,38 +160,32 @@ public class InputVariableTabPanel extends TabPanel {
}
private void addGlobalVariablesPanel(Project project) {
TabItemConfig globalVariablePanelItemConf = new TabItemConfig(
msgs.globalVariables(), false);
TabItemConfig globalVariablePanelItemConf = new TabItemConfig(msgs.globalVariables(), false);
globalVariablesPanel = new GlobalVariablesPanel(project,
eventBus);
globalVariablesPanel = new GlobalVariablesPanel(project, eventBus);
globalVariablesPanel.setHeaderVisible(false);
add(globalVariablesPanel, globalVariablePanelItemConf);
}
private void addInterpreterInfoPanel(Project project) {
TabItemConfig interpreterInfoPanelItemConf = new TabItemConfig(
msgs.interpreterInfo(), false);
TabItemConfig interpreterInfoPanelItemConf = new TabItemConfig(msgs.interpreterInfo(), false);
interpreterInfoPanel = new InterpreterInfoPanel(project, eventBus);
interpreterInfoPanel.setHeaderVisible(false);
add(interpreterInfoPanel, interpreterInfoPanelItemConf);
}
private void addProjectInfoPanel(Project project) {
TabItemConfig projectInfoPanelItemConf = new TabItemConfig(
msgs.projectInfo(), false);
TabItemConfig projectInfoPanelItemConf = new TabItemConfig(msgs.projectInfo(), false);
projectInfoPanel = new ProjectInfoPanel(project, eventBus);
projectInfoPanel.setHeaderVisible(false);
add(projectInfoPanel, projectInfoPanelItemConf);
}
public void addSelectedRowsVariable(
InputOutputVariables inputOutputVariable) {
public void addSelectedRowsVariable(InputOutputVariables inputOutputVariable) {
setActiveWidget(inputOutputVariablesPanel);
inputOutputVariablesPanel.addNewInputOutputVariables(inputOutputVariable);

View File

@ -15,6 +15,7 @@ import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
import com.sencha.gxt.widget.core.client.form.FieldLabel;
import com.sencha.gxt.widget.core.client.form.TextField;
import com.sencha.gxt.widget.core.client.form.validator.MaxLengthValidator;
import com.sencha.gxt.widget.core.client.form.validator.RegExValidator;
/**
@ -31,19 +32,12 @@ public class ProjectInfoPanel extends ContentPanel {
private TextField algorithmName;
private TextField algorithmDescription;
private TextField algorithmCategory;
//private ListStore<RequestedVRE> storeRequestedVRE;
//private Grid<RequestedVRE> gridRequestedVRE;
//private GridRowEditing<RequestedVRE> gridRequestedVREEditing;
//private TextButton btnAdd;
//private boolean addStatus;
//private int seq = 0;
public ProjectInfoPanel(Project project, EventBus eventBus) {
super();
Log.debug("ProjectInfoPanel");
this.eventBus = eventBus;
// msgs = GWT.create(ServiceCategoryMessages.class);
try {
init();
create(project);
@ -65,8 +59,8 @@ public class ProjectInfoPanel extends ContentPanel {
//
algorithmName = new TextField();
algorithmName.setAllowBlank(false);
algorithmName.addValidator(new RegExValidator("^[a-zA-Z0-9_]*$",
"Attention only characters a-z,A-Z,0-9 are allowed"));
algorithmName.addValidator(
new RegExValidator("^[a-zA-Z0-9_]*$", "Attention only characters a-z,A-Z,0-9 are allowed"));
algorithmName.setEmptyText("Enter name...");
algorithmName.addChangeHandler(new ChangeHandler() {
@ -84,224 +78,34 @@ public class ProjectInfoPanel extends ContentPanel {
algorithmDescription = new TextField();
algorithmDescription.setAllowBlank(false);
algorithmDescription.setEmptyText("Enter description...");
algorithmDescription.addValidator(new RegExValidator("^[^\"]*$",
"Attention character \" is not allowed"));
FieldLabel descriptionLabel = new FieldLabel(algorithmDescription,
"Description");
algorithmDescription.addValidator(new RegExValidator("^[^\"]*$", "Attention character \" is not allowed"));
FieldLabel descriptionLabel = new FieldLabel(algorithmDescription, "Description");
descriptionLabel.setLabelWidth(LABAEL_WIDTH);
//
algorithmCategory = new TextField();
algorithmCategory.setAllowBlank(false);
algorithmCategory.setEmptyText("Enter description...");
algorithmCategory.addValidator(new RegExValidator("^[^\"]*$",
"Attention character \" is not allowed"));
algorithmCategory.addValidator(new RegExValidator("^[^\"]*$", "Attention character \" is not allowed"));
algorithmCategory.addValidator(new MaxLengthValidator(32));
FieldLabel categoryLabel = new FieldLabel(algorithmCategory, "Category");
categoryLabel.setLabelWidth(LABAEL_WIDTH);
// Grid
/*
RequestedVREProperties props = GWT.create(RequestedVREProperties.class);
ColumnConfig<RequestedVRE, String> nameColumn = new ColumnConfig<RequestedVRE, String>(
props.name(), 100, "Name");
// nameColumn.setMenuDisabled(true);
ColumnConfig<RequestedVRE, String> descriptionColumn = new ColumnConfig<RequestedVRE, String>(
props.description(), 100, "Description");
// descriptionColumn.setMenuDisabled(true);
ArrayList<ColumnConfig<RequestedVRE, ?>> l = new ArrayList<ColumnConfig<RequestedVRE, ?>>();
l.add(nameColumn);
l.add(descriptionColumn);
ColumnModel<RequestedVRE> columns = new ColumnModel<RequestedVRE>(l);
storeRequestedVRE = new ListStore<RequestedVRE>(props.id());*/
if (project != null && project.getInputData() != null
&& project.getInputData().getProjectInfo() != null) {
if (project != null && project.getInputData() != null && project.getInputData().getProjectInfo() != null) {
if (project.getInputData().getProjectInfo().getAlgorithmName() != null) {
algorithmName.setValue(project.getInputData().getProjectInfo()
.getAlgorithmName());
algorithmName.setValue(project.getInputData().getProjectInfo().getAlgorithmName());
}
if (project.getInputData().getProjectInfo()
.getAlgorithmDescription() != null) {
algorithmDescription.setValue(project.getInputData()
.getProjectInfo().getAlgorithmDescription());
if (project.getInputData().getProjectInfo().getAlgorithmDescription() != null) {
algorithmDescription.setValue(project.getInputData().getProjectInfo().getAlgorithmDescription());
}
if (project.getInputData().getProjectInfo()
.getAlgorithmCategory() != null) {
algorithmCategory.setValue(project.getInputData()
.getProjectInfo().getAlgorithmCategory());
if (project.getInputData().getProjectInfo().getAlgorithmCategory() != null) {
algorithmCategory.setValue(project.getInputData().getProjectInfo().getAlgorithmCategory());
}
/*if (project.getInputData().getProjectInfo().getListRequestedVRE() != null) {
storeRequestedVRE.addAll(project.getInputData()
.getProjectInfo().getListRequestedVRE());
seq = project.getInputData().getProjectInfo()
.getListRequestedVRE().size();
}*/
}
/*
final GridSelectionModel<RequestedVRE> sm = new GridSelectionModel<RequestedVRE>();
sm.setSelectionMode(SelectionMode.SINGLE);
gridRequestedVRE = new Grid<RequestedVRE>(storeRequestedVRE, columns);
gridRequestedVRE.setSelectionModel(sm);
gridRequestedVRE.getView().setStripeRows(true);
gridRequestedVRE.getView().setColumnLines(true);
gridRequestedVRE.getView().setAutoExpandColumn(nameColumn);
gridRequestedVRE.getView().setAutoFill(true);
gridRequestedVRE.setBorders(false);
gridRequestedVRE.setColumnReordering(false);
// DND
GridDragSource<RequestedVRE> ds = new GridDragSource<RequestedVRE>(
gridRequestedVRE);
ds.addDragStartHandler(new DndDragStartEvent.DndDragStartHandler() {
@Override
public void onDragStart(DndDragStartEvent event) {
@SuppressWarnings("unchecked")
ArrayList<RequestedVRE> draggingSelection = (ArrayList<RequestedVRE>) event
.getData();
Log.debug("Start Drag: " + draggingSelection);
}
});
GridDropTarget<RequestedVRE> dt = new GridDropTarget<RequestedVRE>(
gridRequestedVRE);
dt.setFeedback(Feedback.BOTH);
dt.setAllowSelfAsSource(true);
// EDITING //
TextField nameColumnEditing = new TextField();
nameColumnEditing.addValidator(new RegExValidator("^[^\"]*$",
"Attention character \" is not allowed"));
TextField descriptionColumnEditing = new TextField();
descriptionColumnEditing.addValidator(new RegExValidator("^[^\"]*$",
"Attention character \" is not allowed"));
gridRequestedVREEditing = new GridRowEditing<RequestedVRE>(
gridRequestedVRE);
gridRequestedVREEditing.addEditor(nameColumn, nameColumnEditing);
gridRequestedVREEditing.addEditor(descriptionColumn,
descriptionColumnEditing);
btnAdd = new TextButton("Add");
btnAdd.setIcon(StatAlgoImporterResources.INSTANCE.add16());
btnAdd.setScale(ButtonScale.SMALL);
btnAdd.setIconAlign(IconAlign.LEFT);
btnAdd.setToolTip("Add VRE");
btnAdd.addSelectHandler(new SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
addRequestedVRE(event);
}
});
TextButton btnDelete = new TextButton("Delete");
btnDelete.addSelectHandler(new SelectEvent.SelectHandler() {
public void onSelect(SelectEvent event) {
GridCell cell = gridRequestedVREEditing.getActiveCell();
int rowIndex = cell.getRow();
gridRequestedVREEditing.cancelEditing();
storeRequestedVRE.remove(rowIndex);
storeRequestedVRE.commitChanges();
gridRequestedVREEditing.getCancelButton().setVisible(true);
btnAdd.setEnabled(true);
if (addStatus) {
addStatus = false;
}
List<RequestedVRE> listSelected = storeRequestedVRE.getAll();
List<RequestedVRE> listNewSelected = new ArrayList<RequestedVRE>();
for (int i = 0; i < listSelected.size(); i++) {
RequestedVRE var = listSelected.get(i);
var.setId(i);
listNewSelected.add(var);
}
storeRequestedVRE.clear();
storeRequestedVRE.addAll(listNewSelected);
storeRequestedVRE.commitChanges();
seq = listNewSelected.size();
Log.debug("Current Seq: " + seq);
}
});
ButtonBar buttonBar = gridRequestedVREEditing.getButtonBar();
buttonBar.add(btnDelete);
gridRequestedVREEditing
.addBeforeStartEditHandler(new BeforeStartEditHandler<RequestedVRE>() {
@Override
public void onBeforeStartEdit(
BeforeStartEditEvent<RequestedVRE> event) {
editingBeforeStart(event);
}
});
gridRequestedVREEditing
.addCancelEditHandler(new CancelEditHandler<RequestedVRE>() {
@Override
public void onCancelEdit(CancelEditEvent<RequestedVRE> event) {
storeRequestedVRE.rejectChanges();
btnAdd.setEnabled(true);
}
});
gridRequestedVREEditing
.addCompleteEditHandler(new CompleteEditHandler<RequestedVRE>() {
@Override
public void onCompleteEdit(
CompleteEditEvent<RequestedVRE> event) {
try {
if (addStatus) {
addStatus = false;
}
storeRequestedVRE.commitChanges();
gridRequestedVREEditing.getCancelButton()
.setVisible(true);
btnAdd.setEnabled(true);
} catch (Throwable e) {
Log.error("Error: " + e.getLocalizedMessage());
e.printStackTrace();
}
}
});
*/
// /
//ToolBar toolBar = new ToolBar();
//toolBar.add(btnAdd, new BoxLayoutData(new Margins(0)));
//FieldLabel requestedVRELabel = new FieldLabel(toolBar, "Requested VREs");
//requestedVRELabel.setLabelWidth(LABAEL_WIDTH);
VerticalLayoutContainer vlc = new VerticalLayoutContainer();
vlc.setAdjustForScroll(false);
vlc.setScrollMode(ScrollMode.NONE);
@ -309,95 +113,57 @@ public class ProjectInfoPanel extends ContentPanel {
vlc.add(nameLabel, new VerticalLayoutData(1, -1, new Margins(0)));
vlc.add(descriptionLabel, new VerticalLayoutData(1, -1, new Margins(0)));
vlc.add(categoryLabel, new VerticalLayoutData(1, -1, new Margins(0)));
//vlc.add(requestedVRELabel,
// new VerticalLayoutData(1, -1, new Margins(0)));
//vlc.add(toolBar, new VerticalLayoutData(1, -1, new Margins(0)));
//vlc.add(gridRequestedVRE, new VerticalLayoutData(1, 1, new Margins(0)));
add(vlc, new MarginData(new Margins(0)));
}
public void update(Project project) {
Log.debug("Update Project Info: " + project);
if (project != null && project.getInputData() != null
&& project.getInputData().getProjectInfo() != null) {
if (project != null && project.getInputData() != null && project.getInputData().getProjectInfo() != null) {
if (project.getInputData().getProjectInfo().getAlgorithmName() != null) {
algorithmName.setValue(project.getInputData().getProjectInfo()
.getAlgorithmName());
algorithmName.setValue(project.getInputData().getProjectInfo().getAlgorithmName());
} else {
algorithmName.clear();
}
if (project.getInputData().getProjectInfo()
.getAlgorithmDescription() != null) {
algorithmDescription.setValue(project.getInputData()
.getProjectInfo().getAlgorithmDescription());
if (project.getInputData().getProjectInfo().getAlgorithmDescription() != null) {
algorithmDescription.setValue(project.getInputData().getProjectInfo().getAlgorithmDescription());
} else {
algorithmDescription.clear();
}
if (project.getInputData().getProjectInfo().getAlgorithmCategory() != null) {
algorithmCategory.setValue(project.getInputData()
.getProjectInfo().getAlgorithmCategory());
algorithmCategory.setValue(project.getInputData().getProjectInfo().getAlgorithmCategory());
} else {
algorithmCategory.clear();
}
/*
if (project.getInputData().getProjectInfo().getListRequestedVRE() != null) {
storeRequestedVRE.clear();
storeRequestedVRE.addAll(project.getInputData()
.getProjectInfo().getListRequestedVRE());
storeRequestedVRE.commitChanges();
seq = project.getInputData().getProjectInfo()
.getListRequestedVRE().size();
} else {
storeRequestedVRE.clear();
storeRequestedVRE.commitChanges();
seq = 0;
}*/
} else {
algorithmName.clear();
algorithmDescription.clear();
algorithmCategory.clear();
//storeRequestedVRE.clear();
//storeRequestedVRE.commitChanges();
//seq = 0;
}
}
/*
private void editingBeforeStart(BeforeStartEditEvent<RequestedVRE> event) {
// TODO Auto-generated method stub
}
private void addRequestedVRE(SelectEvent event) {
try {
seq++;
RequestedVRE newRequestedVRE = new RequestedVRE(seq, "", "");
Log.debug("New RequestedVRE: " + newRequestedVRE);
gridRequestedVREEditing.cancelEditing();
addStatus = true;
gridRequestedVREEditing.getCancelButton().setVisible(false);
storeRequestedVRE.add(newRequestedVRE);
int row = storeRequestedVRE.indexOf(newRequestedVRE);
gridRequestedVREEditing.startEditing(new GridCell(row, 0));
} catch (Throwable e) {
e.printStackTrace();
public ProjectInfo getProjectInfo() throws Exception {
if(!algorithmName.validate()){
throw new Exception("Invalid algorithm name");
}
}*/
public ProjectInfo getProjectInfo() {
if(!algorithmDescription.validate()){
throw new Exception("Invalid algorithm description");
}
if(!algorithmCategory.validate()){
throw new Exception("Invalid algorithm category");
}
String name = algorithmName.getCurrentValue();
String description = algorithmDescription.getCurrentValue();
String category = algorithmCategory.getCurrentValue();
//ArrayList<RequestedVRE> listRequestedVRE = new ArrayList<>(
// gridRequestedVRE.getStore().getAll());
return new ProjectInfo(name, description, category);
}

View File

@ -13,6 +13,7 @@ import org.gcube.portlets.user.statisticalalgorithmsimporter.client.rpc.StatAlgo
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.annotation.WPS4RParser;
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.file.CodeReader;
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.generator.ProjectBuilder;
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.generator.ProjectDeploy;
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.is.BuildSAIDescriptor;
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.social.AlgorithmNotification;
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.social.Recipient;
@ -704,9 +705,8 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
project = projectBuilder.buildDeploy();
SessionUtil.setProjectSession(httpRequest, serviceCredentials, project);
ProjectArchiver.archive(project, serviceCredentials);
AlgorithmNotification notify = new AlgorithmNotification(this.getThreadLocalRequest(),
serviceCredentials, project, recipients);
notify.run();
ProjectDeploy projectDeploy=new ProjectDeploy(httpRequest, serviceCredentials, project, recipients);
projectDeploy.deploy();
} else {
throw new StatAlgoImporterServiceException(
"The software was not created correctly try to recreate it!");

View File

@ -1,6 +1,10 @@
package org.gcube.portlets.user.statisticalalgorithmsimporter.server.generator;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
@ -8,10 +12,13 @@ import java.nio.file.StandardOpenOption;
import java.util.ArrayList;
import java.util.List;
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.storage.FilesStorage;
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.util.ServiceCredentials;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterServiceException;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.info.InfoData;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.InterpreterPackageInfo;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.workspace.ItemDescription;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -137,7 +144,7 @@ public class InfoGenerator {
if (project.getInputData().getInterpreterInfo().getVersion() != null) {
infos.add("Interpreter Version: " + project.getInputData().getInterpreterInfo().getVersion());
} else {
infos.add("Interpreter Version: Any");
infos.add("Interpreter Version: ");
}
infos.add("");
if (project.getInputData().getInterpreterInfo().getInterpreterPackagesInfo() != null
@ -146,7 +153,6 @@ public class InfoGenerator {
for (InterpreterPackageInfo info : project.getInputData().getInterpreterInfo()
.getInterpreterPackagesInfo()) {
infos.add("Package Name: " + info.getName());
infos.add("Package Details: " + info.getDetails());
}
}
@ -156,4 +162,65 @@ public class InfoGenerator {
return infos;
}
public InfoData readInfo() throws StatAlgoImporterServiceException {
ItemDescription infoItem = project.getProjectTarget().getProjectCompile().getIntegrationInfo();
FilesStorage filesStorage = new FilesStorage();
InputStream inputStream = filesStorage.retrieveItemOnWorkspace(serviceCredentials.getUserName(),
infoItem.getId());
Reader inputReader = new InputStreamReader(inputStream);
BufferedReader br = new BufferedReader(inputReader);
String thisLine = null;
InfoData infoData = new InfoData();
try {
while ((thisLine = br.readLine()) != null) {
if (!thisLine.isEmpty()) {
if (thisLine.startsWith("Username: ")) {
infoData.setUsername(thisLine.substring(10));
} else {
if (thisLine.startsWith("Full Name: ")) {
infoData.setFullname(thisLine.substring(11));
} else {
if (thisLine.startsWith("Email: ")) {
infoData.setEmail(thisLine.substring(7));
} else {
if (thisLine.startsWith("Language: ")) {
infoData.setLanguage(thisLine.substring(10));
} else {
if (thisLine.startsWith("Algorithm Name: ")) {
infoData.setAlgorithmName(thisLine.substring(16));
} else {
if (thisLine.startsWith("Class Name: ")) {
infoData.setClassName(thisLine.substring(12));
} else {
if (thisLine.startsWith("Algorithm Description: ")) {
infoData.setAlgorithmDescription(thisLine.substring(23));
} else {
if (thisLine.startsWith("Algorithm Category: ")) {
infoData.setAlgorithmCategory(thisLine.substring(20));
} else {
if (thisLine.startsWith("Interpreter Version: ")) {
infoData.setInterpreterVersion(thisLine.substring(21));
} else {
}
}
}
}
}
}
}
}
}
} else {
}
}
} catch (IOException e) {
logger.error("Error reading info.txt file: " + e.getLocalizedMessage(), e);
}
return infoData;
}
}

View File

@ -0,0 +1,53 @@
package org.gcube.portlets.user.statisticalalgorithmsimporter.server.generator;
import java.util.ArrayList;
import javax.servlet.http.HttpServletRequest;
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.social.AlgorithmNotification;
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.social.Recipient;
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.util.ServiceCredentials;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterServiceException;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.info.InfoData;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class ProjectDeploy {
private static Logger logger = LoggerFactory.getLogger(ProjectDeploy.class);
private ServiceCredentials serviceCredentials;
private Project project;
private ArrayList<Recipient> recipients;
private HttpServletRequest httpServletRequest;
public ProjectDeploy(HttpServletRequest httpServletRequest,
ServiceCredentials serviceCredentials, Project project,
ArrayList<Recipient> recipients) {
this.serviceCredentials = serviceCredentials;
this.project = project;
this.recipients = recipients;
this.httpServletRequest = httpServletRequest;
}
public void deploy() throws StatAlgoImporterServiceException{
InfoGenerator infoGenerator=new InfoGenerator(project, serviceCredentials);
InfoData infoData=infoGenerator.readInfo();
logger.debug("Send notify");
sendNotify(infoData);
}
private void sendNotify(InfoData infoData){
AlgorithmNotification notify = new AlgorithmNotification(httpServletRequest,
serviceCredentials, project, recipients, infoData);
notify.run();
}
}

View File

@ -2,9 +2,13 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.server.is;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.gcube.common.resources.gcore.GCoreEndpoint;
import org.gcube.common.resources.gcore.GCoreEndpoint.Profile.Endpoint;
import org.gcube.common.resources.gcore.GenericResource;
import org.gcube.common.resources.gcore.ScopeGroup;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.Constants;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterServiceException;
@ -40,12 +44,12 @@ public class InformationSystemUtils {
.setResult("$resource");
DiscoveryClient<GenericResource> client = ICFactory.clientFor(GenericResource.class);
List<GenericResource> accountingResources = client.submit(query);
logger.debug("Resources: " + accountingResources);
List<GenericResource> saiProfileResources = client.submit(query);
logger.debug("Resources: " + saiProfileResources);
SAIDescriptorJAXB saiDescriptorJaxB = null;
for (GenericResource genericResource : accountingResources) {
for (GenericResource genericResource : saiProfileResources) {
if (genericResource.scopes() != null) {
ScopeGroup<String> scopes = genericResource.scopes();
Iterator<String> iterator = scopes.iterator();
@ -62,11 +66,12 @@ public class InformationSystemUtils {
JAXBParser<SAIDescriptorJAXB> parser = new JAXBParser<SAIDescriptorJAXB>(
SAIDescriptorJAXB.class);
logger.debug("Body: " + genericResource.profile().bodyAsString());
saiDescriptorJaxB = (SAIDescriptorJAXB) parser.parse(genericResource.profile().bodyAsString());
saiDescriptorJaxB = (SAIDescriptorJAXB) parser
.parse(genericResource.profile().bodyAsString());
logger.debug("Enable: " + saiDescriptorJaxB);
} catch (Throwable e) {
String error = "Error in discovery SAI profile generic resource on IS in scope " + scope + ". "
+ "Resource parsing failed!";
String error = "Error in discovery SAI profile generic resource on IS in scope " + scope
+ ". " + "Resource parsing failed!";
logger.error(error);
logger.error(
"Error {resource=" + genericResource + ", error=" + e.getLocalizedMessage() + "}");
@ -87,7 +92,81 @@ public class InformationSystemUtils {
} catch (Throwable e) {
String error = "Error in discovery SAI profile generic resource on IS in scope : " + scope;
logger.error(error);
logger.error("Error: " + e.getLocalizedMessage(),e);
logger.error("Error: " + e.getLocalizedMessage(), e);
throw new StatAlgoImporterServiceException(error, e);
}
}
public static String retrieveDataMinerPoolManager(String scope) throws StatAlgoImporterServiceException {
try {
logger.debug("Retrieve dataminer-pool-manager");
if (scope == null || scope.length() == 0)
return null;
ScopeProvider.instance.set(scope);
logger.debug("Retrieve DataMiner Pool Manager resource in scope: " + scope);
SimpleQuery query = ICFactory.queryFor(GCoreEndpoint.class);
query.addCondition("$resource/Profile/SecondaryType/text() eq '" + Constants.POOL_MANAGER_CATEGORY + "'")
.addCondition("$resource/Profile/Name/text() eq '" + Constants.POOL_MANAGER_NAME + "'")
.setResult("$resource");
DiscoveryClient<GCoreEndpoint> client = ICFactory.clientFor(GCoreEndpoint.class);
List<GCoreEndpoint> dataMinerPoolManagerResources = client.submit(query);
logger.debug("Resources: " + dataMinerPoolManagerResources);
String poolManagerURI=null;
for (GCoreEndpoint gCoreEndpoint : dataMinerPoolManagerResources) {
if (gCoreEndpoint.scopes() != null) {
ScopeGroup<String> scopes = gCoreEndpoint.scopes();
Iterator<String> iterator = scopes.iterator();
String scopeFound = null;
boolean found = false;
while (iterator.hasNext() && !found) {
scopeFound = iterator.next();
if (scopeFound.compareTo(scope) == 0) {
found = true;
}
}
if (found) {
try {
logger.debug(
"DataMiner PoolManager Endpoints map: " + gCoreEndpoint.profile().endpointMap());
Map<String, Endpoint> endpointMap = gCoreEndpoint.profile().endpointMap();
Endpoint dataMinerEndpoint = endpointMap.get("REST-API");
logger.debug("DataMiner PoolManager Endpoint: " + dataMinerEndpoint);
if (dataMinerEndpoint != null && dataMinerEndpoint.uri() != null) {
poolManagerURI=dataMinerEndpoint.uri().toString();
}
} catch (Throwable e) {
String error = "Error in discovery DataMiner PoolManager gCubeEndpoint resource on IS in scope: "
+ scope;
logger.error(error);
logger.error(
"Error {resource=" + gCoreEndpoint + ", error=" + e.getLocalizedMessage() + "}");
e.printStackTrace();
throw new StatAlgoImporterServiceException(error, e);
}
break;
}
}
}
logger.debug("DataMiner PoolManager URI: " + poolManagerURI);
return poolManagerURI;
} catch (StatAlgoImporterServiceException e) {
throw e;
} catch (Throwable e) {
String error = "Error in discovery DataMiner PoolManager gCubeEndpoint resource on IS in scope : " + scope;
logger.error(error);
logger.error("Error: " + e.getLocalizedMessage(), e);
throw new StatAlgoImporterServiceException(error, e);
}
}

View File

@ -0,0 +1,35 @@
package org.gcube.portlets.user.statisticalalgorithmsimporter.server.poolmanager;
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.is.InformationSystemUtils;
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.util.ServiceCredentials;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterServiceException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class PoolManager {
private static Logger logger = LoggerFactory.getLogger(PoolManager.class);
private ServiceCredentials serviceCredentials;
public PoolManager(ServiceCredentials serviceCredentials) {
this.serviceCredentials=serviceCredentials;
}
public void deployAlgorithm() throws StatAlgoImporterServiceException{
retrievePoolManagerURI();
}
private String retrievePoolManagerURI() throws StatAlgoImporterServiceException {
String poolManagerURI=InformationSystemUtils.retrieveDataMinerPoolManager(serviceCredentials.getScope());
logger.debug("PoolManagerURI: "+poolManagerURI);
return poolManagerURI;
}
}

View File

@ -17,6 +17,7 @@ import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNot
import org.gcube.portal.notifications.bean.GenericItemBean;
import org.gcube.portal.notifications.thread.MessageNotificationsThread;
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.util.ServiceCredentials;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.info.InfoData;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -29,23 +30,20 @@ import org.slf4j.LoggerFactory;
*
*/
public class AlgorithmNotification extends Thread {
private static Logger logger = LoggerFactory
.getLogger(AlgorithmNotification.class);
private static Logger logger = LoggerFactory.getLogger(AlgorithmNotification.class);
private HttpServletRequest httpServletRequest;
private ServiceCredentials serviceCredentials;
// private NotificationType notificationType;
private Project project;
private ArrayList<Recipient> recipients;
private InfoData infoData;
public AlgorithmNotification(HttpServletRequest httpServletRequest,
ServiceCredentials serviceCredentials, Project project,
ArrayList<Recipient> recipients) {
public AlgorithmNotification(HttpServletRequest httpServletRequest, ServiceCredentials serviceCredentials,
Project project, ArrayList<Recipient> recipients, InfoData infoData) {
this.serviceCredentials = serviceCredentials;
this.project = project;
this.recipients = recipients;
this.httpServletRequest = httpServletRequest;
// this.notificationType = NotificationType.SAI_ALGORITHM_PUBLICATION;
this.infoData = infoData;
}
@ -55,52 +53,45 @@ public class AlgorithmNotification extends Thread {
private void algorithmPublicationEmail() {
try {
Workspace workspace = HomeLibrary
.getUserWorkspace(serviceCredentials.getUserName());
Workspace workspace = HomeLibrary.getUserWorkspace(serviceCredentials.getUserName());
List<String> recipientIds = retrieveListAddressee();
List<GenericItemBean> recipients = retrieveRecipients();
String subject = "[SAI] New software publication requested";
String body = "The user: "
+ serviceCredentials.getFullName()
+ "\nin VRE: "
+ serviceCredentials.getScope()
+ "\n\nhas requested to publish the algorithm: "
+ project.getInputData().getProjectInfo()
.getAlgorithmName()
+ "\nwith the following jar: "
+ project.getProjectTarget().getProjectDeploy()
.getCodeJar().getPublicLink();
String body = "Username: " + serviceCredentials.getUserName() + "\nFull Name: "
+ serviceCredentials.getFullName() + "\nEmail: " + serviceCredentials.getEmail() + "\n\nin VRE: "
+ serviceCredentials.getScope() + "\n\nhas requested to publish the algorithm: " + "\nLanguage: "
+ infoData.getLanguage() + "\nAlgorithm Name: " + infoData.getAlgorithmName() + "\nClass Name: "
+ infoData.getClassName() + "\nAlgorithm Description: " + infoData.getAlgorithmDescription()
+ "\nAlgorithm Category: " + infoData.getAlgorithmCategory() + "\n\nInterpreter Version: "
+ infoData.getInterpreterVersion() + "\n\nwith the following jar: "
+ project.getProjectTarget().getProjectDeploy().getCodeJar().getPublicLink() + "\n\nInstaller: "
+ "\n./addAlgorithm.sh " + infoData.getAlgorithmName() + " " + infoData.getAlgorithmCategory() + " "
+ infoData.getClassName() + " " + serviceCredentials.getScope() + " transducerers N "
+ project.getProjectTarget().getProjectDeploy().getCodeJar().getPublicLink() + " \""
+ infoData.getAlgorithmDescription() + "\"";
String messageId;
messageId = workspace.getWorkspaceMessageManager()
.sendMessageToPortalLogins(subject, body,
new ArrayList<String>(), recipientIds);
messageId = workspace.getWorkspaceMessageManager().sendMessageToPortalLogins(subject, body,
new ArrayList<String>(), recipientIds);
logger.debug("Sending message notification to: "
+ recipientIds.toString());
logger.debug("Sending message notification to: " + recipientIds.toString());
SocialNetworkingSite site = new SocialNetworkingSite(
httpServletRequest);
SocialNetworkingUser user = new SocialNetworkingUser(
serviceCredentials.getUserName(),
serviceCredentials.getEmail(),
serviceCredentials.getFullName(),
SocialNetworkingSite site = new SocialNetworkingSite(httpServletRequest);
SocialNetworkingUser user = new SocialNetworkingUser(serviceCredentials.getUserName(),
serviceCredentials.getEmail(), serviceCredentials.getFullName(),
serviceCredentials.getUserAvatarURL());
NotificationsManager nm = new ApplicationNotificationsManager(site,
serviceCredentials.getScope(), user);
NotificationsManager nm = new ApplicationNotificationsManager(site, serviceCredentials.getScope(), user);
Thread thread = new Thread(new MessageNotificationsThread(
recipients, messageId, subject, body, nm));
Thread thread = new Thread(new MessageNotificationsThread(recipients, messageId, subject, body, nm));
thread.start();
} catch (InternalErrorException | WorkspaceFolderNotFoundException
| HomeNotFoundException e) {
logger.error("AlgorithmPublicationEmail(): "
+ e.getLocalizedMessage());
} catch (InternalErrorException | WorkspaceFolderNotFoundException | HomeNotFoundException e) {
logger.error("AlgorithmPublicationEmail(): " + e.getLocalizedMessage());
e.printStackTrace();
}
@ -110,9 +101,8 @@ public class AlgorithmNotification extends Thread {
private List<GenericItemBean> retrieveRecipients() {
List<GenericItemBean> genericItemBeanRecipients = new ArrayList<GenericItemBean>();
for (Recipient recipient : recipients) {
genericItemBeanRecipients.add(new GenericItemBean(recipient
.getUser(), recipient.getUser(), recipient.getName() + " "
+ recipient.getSurname(), ""));
genericItemBeanRecipients.add(new GenericItemBean(recipient.getUser(), recipient.getUser(),
recipient.getName() + " " + recipient.getSurname(), ""));
}
return genericItemBeanRecipients;

View File

@ -34,6 +34,9 @@ public class Constants {
// IS Resource
public static final String SAI_NAME = "SAIProfile";
public static final String SAI_CATEGORY = "SAI";
public static final String POOL_MANAGER_NAME = "dataminer-pool-manager";
public static final String POOL_MANAGER_CATEGORY = "DataAnalysis";
// Main Generator
public static final String PRE_INSTALLED = "Pre-Installed";

View File

@ -0,0 +1,136 @@
package org.gcube.portlets.user.statisticalalgorithmsimporter.shared.info;
import java.io.Serializable;
import java.util.ArrayList;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.InterpreterPackageInfo;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class InfoData implements Serializable {
private static final long serialVersionUID = 6804461443058040026L;
private String username;
private String fullname;
private String email;
private String language;
private String algorithmName;
private String className;
private String algorithmDescription;
private String algorithmCategory;
private String interpreterVersion;
private ArrayList<InterpreterPackageInfo> packagesInfo;
public InfoData() {
}
public InfoData(String username, String fullname, String email, String language, String algorithmName,
String className, String algorithmDescription, String algorithmCategory, String interpreterVersion,
ArrayList<InterpreterPackageInfo> packagesInfo) {
super();
this.username = username;
this.fullname = fullname;
this.email = email;
this.language = language;
this.algorithmName = algorithmName;
this.className = className;
this.algorithmDescription = algorithmDescription;
this.algorithmCategory = algorithmCategory;
this.interpreterVersion = interpreterVersion;
this.packagesInfo = packagesInfo;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getFullname() {
return fullname;
}
public void setFullname(String fullname) {
this.fullname = fullname;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getLanguage() {
return language;
}
public void setLanguage(String language) {
this.language = language;
}
public String getAlgorithmName() {
return algorithmName;
}
public void setAlgorithmName(String algorithmName) {
this.algorithmName = algorithmName;
}
public String getClassName() {
return className;
}
public void setClassName(String className) {
this.className = className;
}
public String getAlgorithmDescription() {
return algorithmDescription;
}
public void setAlgorithmDescription(String algorithmDescription) {
this.algorithmDescription = algorithmDescription;
}
public String getAlgorithmCategory() {
return algorithmCategory;
}
public void setAlgorithmCategory(String algorithmCategory) {
this.algorithmCategory = algorithmCategory;
}
public String getInterpreterVersion() {
return interpreterVersion;
}
public void setInterpreterVersion(String interpreterVersion) {
this.interpreterVersion = interpreterVersion;
}
public ArrayList<InterpreterPackageInfo> getPackagesInfo() {
return packagesInfo;
}
public void setPackagesInfo(ArrayList<InterpreterPackageInfo> packagesInfo) {
this.packagesInfo = packagesInfo;
}
@Override
public String toString() {
return "InfoData [username=" + username + ", fullname=" + fullname + ", email=" + email + ", language="
+ language + ", algorithmName=" + algorithmName + ", className=" + className + ", algorithmDescription="
+ algorithmDescription + ", algorithmCategory=" + algorithmCategory + ", interpreterVersion="
+ interpreterVersion + ", packagesInfo=" + packagesInfo + "]";
}
}