use of com.twinsoft.convertigo.beans.variables.RequestableVariable in project convertigo by convertigo.
the class AbstractCouchDbTransaction method getJsonBody.
public JSONObject getJsonBody(JSONObject jsonDocument) throws JSONException, EngineException {
// add document members from variables
for (RequestableVariable variable : getAllVariables()) {
String variableName = variable.getName();
if (!variableName.startsWith("__") && !variableName.startsWith(CouchParam.prefix)) {
Object value = toJson(getParameterValue(variableName));
addJson(jsonDocument, variableName, value, getParameterDataTypeClass(variableName));
}
}
return jsonDocument;
}
use of com.twinsoft.convertigo.beans.variables.RequestableVariable in project convertigo by convertigo.
the class Migration7_0_0 method handleRequestableVariable.
private static void handleRequestableVariable(List<RequestableVariable> variables) {
for (RequestableVariable variable : variables) {
QName qName = XmlSchemaUtils.getSchemaDataTypeName(variable.getSchemaType());
variable.setXmlTypeAffectation(new XmlQName(qName));
}
}
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 TreeDropAdapter method paste.
private boolean paste(Node node, TreeObject targetTreeObject) throws EngineException {
if (targetTreeObject instanceof DatabaseObjectTreeObject) {
DatabaseObject parent = ((DatabaseObjectTreeObject) targetTreeObject).getObject();
DatabaseObject databaseObject = paste(node, null, true);
Element element = (Element) ((Element) node).getElementsByTagName("dnd").item(0);
// SEQUENCER
if (parent instanceof Sequence || parent instanceof StepWithExpressions) {
if (parent instanceof XMLElementStep)
return false;
if (parent instanceof IThenElseContainer)
return false;
// Add a TransactionStep
if (databaseObject instanceof Transaction) {
String projectName = ((Element) element.getElementsByTagName("project").item(0)).getAttribute("name");
String connectorName = ((Element) element.getElementsByTagName("connector").item(0)).getAttribute("name");
Transaction transaction = (Transaction) databaseObject;
TransactionStep transactionStep = new TransactionStep();
transactionStep.setSourceTransaction(projectName + TransactionStep.SOURCE_SEPARATOR + connectorName + TransactionStep.SOURCE_SEPARATOR + transaction.getName());
transactionStep.bNew = true;
parent.add(transactionStep);
parent.hasChanged = true;
if (transaction instanceof TransactionWithVariables) {
for (Variable variable : ((TransactionWithVariables) transaction).getVariablesList()) {
StepVariable stepVariable = variable.isMultiValued() ? new StepMultiValuedVariable() : new StepVariable();
stepVariable.setName(variable.getName());
stepVariable.setComment(variable.getComment());
stepVariable.setDescription(variable.getDescription());
stepVariable.setRequired(variable.isRequired());
stepVariable.setValueOrNull(variable.getValueOrNull());
stepVariable.setVisibility(variable.getVisibility());
transactionStep.addVariable(stepVariable);
}
}
return true;
} else // Add a SequenceStep
if (databaseObject instanceof Sequence) {
String projectName = ((Element) element.getElementsByTagName("project").item(0)).getAttribute("name");
Sequence seq = (Sequence) databaseObject;
SequenceStep sequenceStep = new SequenceStep();
sequenceStep.setSourceSequence(projectName + SequenceStep.SOURCE_SEPARATOR + seq.getName());
sequenceStep.bNew = true;
parent.add(sequenceStep);
parent.hasChanged = true;
for (Variable variable : seq.getVariablesList()) {
StepVariable stepVariable = variable.isMultiValued() ? new StepMultiValuedVariable() : new StepVariable();
stepVariable.setName(variable.getName());
stepVariable.setComment(variable.getComment());
stepVariable.setDescription(variable.getDescription());
stepVariable.setRequired(variable.isRequired());
stepVariable.setValueOrNull(variable.getValueOrNull());
stepVariable.setVisibility(variable.getVisibility());
sequenceStep.addVariable(stepVariable);
}
return true;
}
} else // URLMAPPER
if (parent instanceof UrlMappingOperation) {
// Set associated requestable, add all parameters for operation
if (databaseObject instanceof RequestableObject) {
String dboQName = "";
if (databaseObject instanceof Sequence) {
dboQName = ((Element) element.getElementsByTagName("project").item(0)).getAttribute("name") + "." + databaseObject.getName();
} else if (databaseObject instanceof Transaction) {
dboQName = ((Element) element.getElementsByTagName("project").item(0)).getAttribute("name") + "." + ((Element) element.getElementsByTagName("connector").item(0)).getAttribute("name") + "." + databaseObject.getName();
}
UrlMappingOperation operation = (UrlMappingOperation) parent;
operation.setTargetRequestable(dboQName);
if (operation.getComment().isEmpty()) {
operation.setComment(databaseObject.getComment());
}
operation.hasChanged = true;
try {
StringTokenizer st = new StringTokenizer(dboQName, ".");
int count = st.countTokens();
Project p = Engine.theApp.databaseObjectsManager.getProjectByName(st.nextToken());
List<RequestableVariable> variables = new ArrayList<RequestableVariable>();
if (count == 2) {
variables = p.getSequenceByName(st.nextToken()).getVariablesList();
} else if (count == 3) {
variables = ((TransactionWithVariables) p.getConnectorByName(st.nextToken()).getTransactionByName(st.nextToken())).getVariablesList();
}
for (RequestableVariable variable : variables) {
String variableName = variable.getName();
Object variableValue = variable.getValueOrNull();
UrlMappingParameter parameter = null;
try {
parameter = operation.getParameterByName(variableName);
} catch (Exception e) {
}
if (parameter == null) {
boolean acceptForm = operation.getMethod().equalsIgnoreCase(HttpMethodType.POST.name()) || operation.getMethod().equalsIgnoreCase(HttpMethodType.PUT.name());
parameter = acceptForm ? new FormParameter() : new QueryParameter();
parameter.setName(variableName);
parameter.setComment(variable.getComment());
parameter.setArray(false);
parameter.setExposed(((RequestableVariable) variable).isWsdl());
parameter.setMultiValued(variable.isMultiValued());
parameter.setRequired(variable.isRequired());
parameter.setValueOrNull(!variable.isMultiValued() ? variableValue : null);
parameter.setMappedVariableName(variableName);
parameter.bNew = true;
operation.add(parameter);
operation.hasChanged = true;
}
}
} catch (Exception e) {
}
return true;
} else // Add a parameter to mapping operation
if (databaseObject instanceof RequestableVariable) {
RequestableVariable variable = (RequestableVariable) databaseObject;
UrlMappingOperation operation = (UrlMappingOperation) parent;
UrlMappingParameter parameter = null;
String variableName = variable.getName();
Object variableValue = variable.getValueOrNull();
try {
parameter = operation.getParameterByName(variableName);
} catch (Exception e) {
}
if (parameter == null) {
boolean acceptForm = operation.getMethod().equalsIgnoreCase(HttpMethodType.POST.name()) || operation.getMethod().equalsIgnoreCase(HttpMethodType.PUT.name());
parameter = acceptForm ? new FormParameter() : new QueryParameter();
parameter.setName(variableName);
parameter.setComment(variable.getComment());
parameter.setArray(false);
parameter.setExposed(((RequestableVariable) variable).isWsdl());
parameter.setMultiValued(variable.isMultiValued());
parameter.setRequired(variable.isRequired());
parameter.setValueOrNull(!variable.isMultiValued() ? variableValue : null);
parameter.setMappedVariableName(variableName);
parameter.bNew = true;
operation.add(parameter);
operation.hasChanged = true;
}
return true;
}
} else // MOBILE COMPONENTS
if (parent instanceof com.twinsoft.convertigo.beans.mobile.components.MobileComponent) {
return pasteMobileComponent(parent, databaseObject, element);
} else // NGX COMPONENTS
if (parent instanceof com.twinsoft.convertigo.beans.ngx.components.MobileComponent) {
return pasteNgxComponent(parent, databaseObject, element);
}
}
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;
}
Aggregations