use of com.twinsoft.convertigo.beans.core.Variable in project convertigo by convertigo.
the class VariableTreeObject2 method handlesBeanNameChanged.
protected void handlesBeanNameChanged(TreeObjectEvent treeObjectEvent) {
DatabaseObjectTreeObject treeObject = (DatabaseObjectTreeObject) treeObjectEvent.getSource();
DatabaseObject databaseObject = (DatabaseObject) treeObject.getObject();
Object oldValue = treeObjectEvent.oldValue;
Object newValue = treeObjectEvent.newValue;
int update = treeObjectEvent.update;
// Updates variables references
if (update != TreeObjectEvent.UPDATE_NONE) {
boolean isLocalProject = false;
boolean isSameValue = false;
boolean shouldUpdate = false;
try {
if (getObject() instanceof Variable) {
Variable variable = (Variable) getObject();
if (databaseObject instanceof RequestableVariable) {
isLocalProject = variable.getProject().equals(databaseObject.getProject());
isSameValue = variable.getName().equals(oldValue);
shouldUpdate = (update == TreeObjectEvent.UPDATE_ALL) || ((update == TreeObjectEvent.UPDATE_LOCAL) && (isLocalProject));
// Verify if parent of databaseObject is a transaction
if (databaseObject.getParent() instanceof Transaction) {
Transaction transaction = (Transaction) databaseObject.getParent();
// Case of rename for Call Transaction
if (variable.getParent() instanceof TransactionStep) {
TransactionStep transactionStep = (TransactionStep) variable.getParent();
if (transactionStep.getSourceTransaction().equals(transaction.getProject() + "." + transaction.getConnector() + "." + transaction.getName())) {
updateNameReference(isSameValue, shouldUpdate, variable, newValue);
}
}
/*
* propagation to testCases of variable renaming in a transaction
*/
if (variable.getParent() instanceof TransactionWithVariables) {
propagateVariableRename(true, true, treeObjectEvent, ((TransactionWithVariables) transaction).getTestCasesList(), transaction.getName());
}
}
// Verify if parent of databaseObject is a sequence
if (databaseObject.getParent() instanceof Sequence) {
Sequence sequence = (Sequence) databaseObject.getParent();
// Case of rename for Call Sequence
if (variable.getParent() instanceof SequenceStep) {
SequenceStep sequenceStep = (SequenceStep) variable.getParent();
if (sequenceStep.getSourceSequence().equals(sequence.getProject() + "." + sequence.getName())) {
updateNameReference(isSameValue, shouldUpdate, variable, newValue);
}
}
/*
* propagation to testCases of variable renaming in a sequence
*/
if (variable.getParent() instanceof Sequence) {
propagateVariableRename(true, true, treeObjectEvent, sequence.getTestCasesList(), sequence.getName());
}
}
}
}
} catch (EngineException e) {
ConvertigoPlugin.logException(e, "Unable to rename the variable references of '" + databaseObject.getName() + "'!");
}
}
}
use of com.twinsoft.convertigo.beans.core.Variable in project convertigo by convertigo.
the class GetTestPlatform method handleIVariableContainer.
private void handleIVariableContainer(Document document, Element e_vars, IVariableContainer vars) {
for (Variable variable : vars.getVariables()) {
Element e_variable = createDatabaseObjectElement(document, variable);
Object val = variable.getValueOrNull();
String strval = val == null ? null : variable.isMultiValued() ? new JSONArray(GenericUtils.<XMLVector<String>>cast(val)).toString() : val.toString();
e_variable.setAttribute("value", strval);
e_variable.setAttribute("isMasked", Visibility.Platform.isMasked(variable.getVisibility()) ? "true" : "false");
e_variable.setAttribute("isMultivalued", "" + variable.isMultiValued());
e_variable.setAttribute("isFileUpload", "" + variable.getIsFileUpload());
e_variable.setAttribute("description", variable.getDescription());
e_variable.setAttribute("required", "" + variable.isRequired());
e_vars.appendChild(e_variable);
}
}
use of com.twinsoft.convertigo.beans.core.Variable in project convertigo by convertigo.
the class OperationImportParametersFromVariablesAction method run.
public void run() {
Display display = Display.getDefault();
Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
Shell shell = getParentShell();
shell.setCursor(waitCursor);
try {
ProjectExplorerView explorerView = getProjectExplorerView();
if (explorerView != null) {
TreeObject treeObject = explorerView.getFirstSelectedTreeObject();
Object databaseObject = treeObject.getObject();
if ((databaseObject != null) && (databaseObject instanceof UrlMappingOperation)) {
UrlMappingOperation operation = (UrlMappingOperation) databaseObject;
String targetRequestable = operation.getTargetRequestable();
if (!targetRequestable.isEmpty()) {
StringTokenizer st = new StringTokenizer(targetRequestable, ".");
int count = st.countTokens();
String projectName = st.nextToken();
String sequenceName = count == 2 ? st.nextToken() : "";
String connectorName = count == 3 ? st.nextToken() : "";
String transactionName = count == 3 ? st.nextToken() : "";
Project project = Engine.theApp.databaseObjectsManager.getProjectByName(projectName);
RequestableObject requestableObject = null;
if (sequenceName.isEmpty()) {
requestableObject = project.getConnectorByName(connectorName).getTransactionByName(transactionName);
} else {
requestableObject = project.getSequenceByName(sequenceName);
}
if (requestableObject != null && requestableObject instanceof IVariableContainer) {
IVariableContainer variableContainer = (IVariableContainer) requestableObject;
for (Variable variable : variableContainer.getVariables()) {
String variableName = variable.getName();
Object variableValue = variable.getValueOrNull();
UrlMappingParameter parameter = null;
try {
parameter = operation.getParameterByName(variableName);
} catch (Exception e) {
}
if (parameter == null) {
if (operation instanceof PostOperation || operation instanceof PutOperation)
parameter = new FormParameter();
else
parameter = 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;
parameter.hasChanged = true;
operation.add(parameter);
operation.hasChanged = true;
}
}
if (operation.hasChanged) {
explorerView.reloadTreeObject(treeObject);
StructuredSelection structuredSelection = new StructuredSelection(treeObject);
ConvertigoPlugin.getDefault().getPropertiesView().selectionChanged((IWorkbenchPart) explorerView, structuredSelection);
}
}
} else {
throw new ConvertigoException("Operation has no target requestable : please select one first.");
}
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to import variables as new parameters in operation!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.beans.core.Variable in project convertigo by convertigo.
the class AbstractCouchDbTransaction method getParameterStringValue.
public String getParameterStringValue(CouchParam param) throws EngineException {
String value = null;
Variable variable = getVariable(param.param());
if (variable != null) {
value = getParameterStringValue(param.param());
}
if (value == null) {
try {
value = (String) getClass().getMethod("getP_" + param.name()).invoke(this);
} catch (Exception e) {
// TODO: handle error
e.printStackTrace();
}
}
return value;
}
use of com.twinsoft.convertigo.beans.core.Variable in project convertigo by convertigo.
the class HttpTransactionVariablesComposite method applyProceed.
public void applyProceed() {
for (Button check : checkboxes) {
DynamicHttpVariable v = (DynamicHttpVariable) check.getData(DynamicHttpVariable.class.getName());
Variable dboVar = httpTransaction.getVariable(v.name());
if (check.getSelection() && dboVar == null) {
try {
RequestableHttpVariable newDboVar = new RequestableHttpVariable();
newDboVar.setName(v.name());
httpTransaction.addVariable(newDboVar);
} catch (EngineException e) {
}
} else if (!check.getSelection() && dboVar != null) {
httpTransaction.removeVariable((RequestableVariable) dboVar);
}
}
for (Iterator<Text> i = customs.iterator(); i.hasNext(); ) {
Text txtName = i.next();
Text txtValue = i.next();
if (txtName.getText().isBlank()) {
continue;
}
DynamicHttpVariable v = (DynamicHttpVariable) txtName.getData(DynamicHttpVariable.class.getName());
try {
RequestableHttpVariable newDboVar = new RequestableHttpVariable();
String name = v.prefix() + txtName.getText();
String normalized = StringUtils.normalize(name);
newDboVar.setName(normalized);
if (!name.equals(normalized)) {
newDboVar.setHttpName(txtName.getText());
}
if (v == DynamicHttpVariable.__POST_) {
newDboVar.setHttpMethod("POST");
}
if (!txtValue.getText().isEmpty()) {
newDboVar.setValueOrNull(txtValue.getText());
}
httpTransaction.addVariable(newDboVar);
} catch (EngineException e) {
}
}
}
Aggregations