use of com.twinsoft.convertigo.beans.variables.RequestableVariable in project convertigo by convertigo.
the class TreeDropAdapter method pasteMobileComponent.
private boolean pasteMobileComponent(DatabaseObject parent, DatabaseObject databaseObject, Element element) throws EngineException {
// MOBILE COMPONENTS
if (parent instanceof com.twinsoft.convertigo.beans.mobile.components.MobileComponent) {
if (parent.priority == databaseObject.priority) {
return true;
}
// Case dbo is a Sequence
if (databaseObject instanceof Sequence) {
Sequence sequence = (Sequence) databaseObject;
// Add child components to fill the form
if (parent instanceof com.twinsoft.convertigo.beans.mobile.components.UIForm) {
com.twinsoft.convertigo.beans.mobile.components.UIForm uiForm = GenericUtils.cast(parent);
try {
String projectName = ((Element) element.getElementsByTagName("project").item(0)).getAttribute("name");
// add an onSubmit event with a callSequence
com.twinsoft.convertigo.beans.mobile.components.UIControlEvent event = new com.twinsoft.convertigo.beans.mobile.components.UIControlEvent();
event.setEventName(com.twinsoft.convertigo.beans.mobile.components.UIControlEvent.AttrEvent.onSubmit.name());
event.bNew = true;
event.hasChanged = true;
DatabaseObject call = com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.createBean(com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.getComponentByName("CallSequenceAction"));
if (call != null && call instanceof com.twinsoft.convertigo.beans.mobile.components.UIDynamicAction) {
com.twinsoft.convertigo.beans.mobile.components.UIDynamicAction dynAction = GenericUtils.cast(call);
com.twinsoft.convertigo.beans.mobile.components.dynamic.IonBean ionBean = dynAction.getIonBean();
if (ionBean != null && ionBean.hasProperty("requestable")) {
ionBean.setPropertyValue("requestable", new com.twinsoft.convertigo.beans.mobile.components.MobileSmartSourceType(projectName + "." + sequence.getName()));
}
}
call.bNew = true;
call.hasChanged = true;
event.add(call);
// add a list of item with label & input for each variable
DatabaseObject dboList = com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.createBean(com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.getComponentByName("List"));
for (RequestableVariable variable : sequence.getVariables()) {
DatabaseObject dboItem = com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.createBean(com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.getComponentByName("ListItem"));
dboList.add(dboItem);
DatabaseObject dboLabel = com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.createBean(com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.getComponentByName("Label"));
dboItem.add(dboLabel);
com.twinsoft.convertigo.beans.mobile.components.UIText uiText = new com.twinsoft.convertigo.beans.mobile.components.UIText();
uiText.bNew = true;
uiText.hasChanged = true;
uiText.setTextSmartType(new com.twinsoft.convertigo.beans.mobile.components.MobileSmartSourceType(variable.getName() + ":"));
dboLabel.add(uiText);
DatabaseObject dboInput = com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.createBean(com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.getComponentByName("Input"));
if (dboInput != null && dboInput instanceof com.twinsoft.convertigo.beans.mobile.components.UIDynamicElement) {
com.twinsoft.convertigo.beans.mobile.components.UIDynamicElement dynElem = GenericUtils.cast(dboInput);
com.twinsoft.convertigo.beans.mobile.components.dynamic.IonBean ionBean = dynElem.getIonBean();
if (ionBean != null && ionBean.hasProperty("FormControlName")) {
ionBean.setPropertyValue("FormControlName", new com.twinsoft.convertigo.beans.mobile.components.MobileSmartSourceType(variable.getName()));
}
dboItem.add(dboInput);
}
}
// add a buttonset with a submit and a reset button
DatabaseObject dboBtnSet = com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.createBean(com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.getComponentByName("ButtonSet"));
DatabaseObject dboSubmit = com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.createBean(com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.getComponentByName("SubmitButton"));
dboBtnSet.add(dboSubmit);
com.twinsoft.convertigo.beans.mobile.components.UIText sText = new com.twinsoft.convertigo.beans.mobile.components.UIText();
sText.bNew = true;
sText.hasChanged = true;
sText.setTextSmartType(new com.twinsoft.convertigo.beans.mobile.components.MobileSmartSourceType("Submit"));
dboSubmit.add(sText);
DatabaseObject dboReset = com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.createBean(com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.getComponentByName("ResetButton"));
dboBtnSet.add(dboReset);
com.twinsoft.convertigo.beans.mobile.components.UIText rText = new com.twinsoft.convertigo.beans.mobile.components.UIText();
rText.bNew = true;
rText.hasChanged = true;
rText.setTextSmartType(new com.twinsoft.convertigo.beans.mobile.components.MobileSmartSourceType("Reset"));
dboReset.add(rText);
uiForm.add(event);
uiForm.add(dboList);
uiForm.add(dboBtnSet);
} catch (Exception e) {
throw new EngineException("Unable to create filled Form from requestable", e);
}
return true;
}
// Add a CallSequenceAction
if (parent instanceof com.twinsoft.convertigo.beans.mobile.components.UIPageEvent || parent instanceof com.twinsoft.convertigo.beans.mobile.components.UIAppEvent || parent instanceof com.twinsoft.convertigo.beans.mobile.components.UIActionEvent || parent instanceof com.twinsoft.convertigo.beans.mobile.components.UIControlEvent || parent instanceof com.twinsoft.convertigo.beans.mobile.components.IAction || parent instanceof com.twinsoft.convertigo.beans.mobile.components.UIActionStack) {
com.twinsoft.convertigo.beans.mobile.components.UIComponent uiComponent = GenericUtils.cast(parent);
String projectName = ((Element) element.getElementsByTagName("project").item(0)).getAttribute("name");
DatabaseObject call = com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.createBean(com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.getComponentByName("CallSequenceAction"));
if (call != null && call instanceof com.twinsoft.convertigo.beans.mobile.components.UIDynamicAction) {
com.twinsoft.convertigo.beans.mobile.components.UIDynamicAction dynAction = GenericUtils.cast(call);
com.twinsoft.convertigo.beans.mobile.components.dynamic.IonBean ionBean = dynAction.getIonBean();
if (ionBean != null && ionBean.hasProperty("requestable")) {
ionBean.setPropertyValue("requestable", new com.twinsoft.convertigo.beans.mobile.components.MobileSmartSourceType(projectName + "." + sequence.getName()));
call.bNew = true;
call.hasChanged = true;
uiComponent.add(call);
uiComponent.hasChanged = true;
}
}
return true;
}
} else // Case dbo is a SharedAction
if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIActionStack) {
com.twinsoft.convertigo.beans.mobile.components.UIActionStack stack = GenericUtils.cast(databaseObject);
// Add an InvokeAction
if (parent instanceof com.twinsoft.convertigo.beans.mobile.components.UIPageEvent || parent instanceof com.twinsoft.convertigo.beans.mobile.components.UIAppEvent || parent instanceof com.twinsoft.convertigo.beans.mobile.components.UIActionEvent || parent instanceof com.twinsoft.convertigo.beans.mobile.components.UIControlEvent || parent instanceof com.twinsoft.convertigo.beans.mobile.components.IAction || parent instanceof com.twinsoft.convertigo.beans.mobile.components.UIActionStack) {
com.twinsoft.convertigo.beans.mobile.components.UIComponent uiComponent = GenericUtils.cast(parent);
String projectName = ((Element) element.getElementsByTagName("project").item(0)).getAttribute("name");
String mobileAppName = ((Element) element.getElementsByTagName("mobileapplication").item(0)).getAttribute("name");
String applicationName = ((Element) element.getElementsByTagName("application").item(0)).getAttribute("name");
DatabaseObject invokeAction = com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.createBean(com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.getComponentByName("InvokeAction"));
com.twinsoft.convertigo.beans.mobile.components.UIDynamicInvoke invoke = GenericUtils.cast(invokeAction);
if (invoke != null) {
invoke.setSharedActionQName(projectName + "." + mobileAppName + "." + applicationName + "." + stack.getName());
invoke.bNew = true;
invoke.hasChanged = true;
uiComponent.add(invoke);
uiComponent.hasChanged = true;
}
return true;
}
} else // Case dbo is a SharedComponent
if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UISharedComponent) {
com.twinsoft.convertigo.beans.mobile.components.UISharedComponent usc = GenericUtils.cast(databaseObject);
// Add a UseShared component
if (parent instanceof com.twinsoft.convertigo.beans.mobile.components.PageComponent || parent instanceof com.twinsoft.convertigo.beans.mobile.components.UISharedComponent || parent instanceof com.twinsoft.convertigo.beans.mobile.components.UIElement && !(parent instanceof com.twinsoft.convertigo.beans.mobile.components.UIUseShared)) {
com.twinsoft.convertigo.beans.mobile.components.MobileComponent mc = GenericUtils.cast(parent);
String projectName = ((Element) element.getElementsByTagName("project").item(0)).getAttribute("name");
String mobileAppName = ((Element) element.getElementsByTagName("mobileapplication").item(0)).getAttribute("name");
String applicationName = ((Element) element.getElementsByTagName("application").item(0)).getAttribute("name");
com.twinsoft.convertigo.beans.mobile.components.UIUseShared use = new com.twinsoft.convertigo.beans.mobile.components.UIUseShared();
if (use != null) {
use.setSharedComponentQName(projectName + "." + mobileAppName + "." + applicationName + "." + usc.getName());
use.bNew = true;
use.hasChanged = true;
mc.add(use);
mc.hasChanged = true;
}
return true;
}
}
}
return false;
}
use of com.twinsoft.convertigo.beans.variables.RequestableVariable in project convertigo by convertigo.
the class CouchVariablesDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
try {
PropertyDescriptor[] availablesParameters = null;
List<RequestableVariable> dboVariables = null;
if (props != null) {
availablesParameters = props;
} else {
availablesParameters = CachedIntrospector.getBeanInfo(couchDbTransaction).getPropertyDescriptors();
}
if (couchDbTransaction != null) {
dboVariables = couchDbTransaction.getVariablesList();
}
couchVariablesComposite = new CouchVariablesComposite(parent, SWT.V_SCROLL, dboVariables);
couchVariablesComposite.setBackground(parent.getBackground());
couchVariablesComposite.setPropertyDescriptor(couchDbTransaction, availablesParameters, couchDbTransaction.getParent());
GridData couchVarData = new GridData(GridData.FILL_BOTH);
couchVarData.horizontalSpan = 2;
couchVariablesComposite.setLayoutData(couchVarData);
if (couchVariablesComposite.getSelectedParameters().size() == 0) {
setReturnCode(-1);
}
} catch (IntrospectionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return couchVariablesComposite;
}
use of com.twinsoft.convertigo.beans.variables.RequestableVariable in project convertigo by convertigo.
the class TransactionTreeObject method detectVariables.
/**
* SQL TRANSACTION *
*/
private void detectVariables(String queries, String oldQueries, List<RequestableVariable> listVariables) {
if (queries != null && !queries.equals("")) {
// We create an another List which permit to compare and update variables
Set<String> newSQLQueriesVariablesNames = getSetVariableNames(queries);
Set<String> oldSQLQueriesVariablesNames = getSetVariableNames(oldQueries);
// Modify variables definition if needed
if (listVariables != null && !oldSQLQueriesVariablesNames.equals(newSQLQueriesVariablesNames)) {
for (RequestableVariable variable : listVariables) {
String variableName = variable.getName();
if (oldSQLQueriesVariablesNames.contains(variableName) && !newSQLQueriesVariablesNames.contains(variableName)) {
try {
MessageBox messageBox = new MessageBox(viewer.getControl().getShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
messageBox.setMessage("Do you really want to delete the variable \"" + variableName + "\"?");
messageBox.setText("Delete \"" + variableName + "\"?");
if (messageBox.open() == SWT.YES) {
variable.delete();
}
} catch (EngineException e) {
ConvertigoPlugin.logException(e, "Error when deleting the variable \"" + variableName + "\"");
}
}
}
}
}
}
use of com.twinsoft.convertigo.beans.variables.RequestableVariable in project convertigo by convertigo.
the class SapJcoConnector method executeJCoSearch.
public static Document executeJCoSearch(SapJcoConnector connector, String pattern) throws EngineException {
SapJcoTransaction transaction = (SapJcoTransaction) connector.newTransaction();
transaction.setBapiName("RFC_FUNCTION_SEARCH");
transaction.context = connector.context;
transaction.setParent(connector);
RequestableVariable variable = new RequestableVariable();
variable.setName("FUNCNAME");
variable.setValueOrNull(pattern);
transaction.addVariable(variable);
return connector.getSapJCoProvider().executeJCoFunction(transaction, true);
}
use of com.twinsoft.convertigo.beans.variables.RequestableVariable in project convertigo by convertigo.
the class SqlConnector method createSqlTransaction.
public static SqlTransaction createSqlTransaction(SqlConnector sqlConnector, String callableName, String specific_name) throws EngineException, ClassNotFoundException, SQLException {
SqlTransaction sqlTransaction = null;
if (sqlConnector != null && !callableName.isEmpty()) {
// get a connection
sqlConnector.open();
// Create transaction
sqlTransaction = sqlConnector.newTransaction();
sqlTransaction.setName("Call_" + StringUtils.normalize(callableName));
sqlTransaction.hasChanged = true;
sqlTransaction.bNew = true;
// Build sqlQuery and retrieve parameters
boolean isFunction = false;
String sqlQuery = "CALL " + callableName + "(";
Connection connection = sqlConnector.connection;
List<Map<String, Object>> parameterList = getProcedureParameters(connection, callableName);
for (Map<String, Object> parameterMap : parameterList) {
String proc_specific_name = (String) parameterMap.get("SPECIFIC_NAME");
if (specific_name.equals(proc_specific_name)) {
String param_name = (String) parameterMap.get("COLUMN_NAME");
int param_mode = (Integer) parameterMap.get("COLUMN_TYPE");
// int param_type = (Integer) parameterMap.get("DATA_TYPE");
switch(param_mode) {
case DatabaseMetaData.procedureColumnReturn:
case DatabaseMetaData.procedureColumnResult:
isFunction = true;
break;
case DatabaseMetaData.procedureColumnIn:
case DatabaseMetaData.procedureColumnInOut:
// update query and create input variable
if (param_name != null && !param_name.isEmpty()) {
RequestableVariable variable = new RequestableVariable();
variable.setName(StringUtils.normalize(param_name));
variable.hasChanged = true;
variable.bNew = true;
sqlQuery += sqlQuery.endsWith("(") ? "" : ",";
sqlQuery += "{" + variable.getName() + "}";
sqlTransaction.addVariable(variable);
} else {
sqlQuery += sqlQuery.endsWith("(") ? "?" : ",?";
}
break;
case DatabaseMetaData.procedureColumnOut:
sqlQuery += sqlQuery.endsWith("(") ? "?" : ",?";
break;
case DatabaseMetaData.procedureColumnUnknown:
default:
break;
}
}
}
sqlQuery += ")";
if (isFunction) {
sqlQuery = "? = " + sqlQuery;
}
sqlQuery = "{" + sqlQuery + "}";
sqlTransaction.setSqlQuery(sqlQuery);
// close connection
sqlConnector.close();
}
return sqlTransaction;
}
Aggregations