use of com.twinsoft.convertigo.beans.common.XMLVector in project convertigo by convertigo.
the class DatabaseObjectsManager method getCompiledValue.
public Object getCompiledValue(Object propertyObjectValue) throws UndefinedSymbolsException {
if (propertyObjectValue instanceof String) {
return getCompiledValue((String) propertyObjectValue);
} else {
Set<String> undefinedSymbols = null;
if (propertyObjectValue instanceof XMLVector<?>) {
XMLVector<Object> xmlv = GenericUtils.<XMLVector<Object>>cast(propertyObjectValue);
for (int i = 0; i < xmlv.size(); i++) {
Object ob = xmlv.get(i);
Object compiled;
try {
compiled = getCompiledValue(ob);
} catch (UndefinedSymbolsException e) {
compiled = e.incompletValue();
if (undefinedSymbols == null) {
undefinedSymbols = new HashSet<String>();
}
undefinedSymbols.addAll(e.undefinedSymbols());
}
if (ob != compiled) {
// symbol case
if (xmlv == propertyObjectValue) {
propertyObjectValue = xmlv = new XMLVector<Object>(xmlv);
}
xmlv.set(i, compiled);
}
}
} else if (propertyObjectValue instanceof SmartType) {
SmartType smartType = (SmartType) propertyObjectValue;
if (smartType.isUseExpression()) {
String expression = smartType.getExpression();
String compiled;
try {
compiled = getCompiledValue(expression);
} catch (UndefinedSymbolsException e) {
compiled = (String) e.incompletValue();
undefinedSymbols = e.undefinedSymbols();
}
if (compiled != expression) {
propertyObjectValue = smartType = smartType.clone();
smartType.setExpression(compiled);
}
}
}
if (undefinedSymbols != null) {
throw new UndefinedSymbolsException(undefinedSymbols, propertyObjectValue);
}
}
return propertyObjectValue;
}
use of com.twinsoft.convertigo.beans.common.XMLVector in project convertigo by convertigo.
the class VariableGenerateFromXmlAndLinkAction 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 StepVariable))) {
StepVariable stepVariable = (StepVariable) databaseObject;
RequestableStep requestableStep = (RequestableStep) stepVariable.getParent();
if (requestableStep != null) {
DatabaseObjectTreeObject parentDboTreeObject = ((DatabaseObjectTreeObject) treeObject).getParentDatabaseObjectTreeObject().getParentDatabaseObjectTreeObject();
RequestableObject requestableObject = null;
if (requestableStep instanceof SequenceStep) {
requestableObject = ((SequenceStep) requestableStep).getTargetSequence();
} else if (requestableStep instanceof TransactionStep) {
requestableObject = ((TransactionStep) requestableStep).getTargetTransaction();
}
if ((requestableObject != null) && (requestableObject instanceof IVariableContainer)) {
String variableName = stepVariable.getName();
IVariableContainer container = (IVariableContainer) requestableObject;
RequestableVariable variable = (RequestableVariable) container.getVariable(variableName);
// generate dom model
Document document = null;
try {
String description = variable.getDescription();
document = XMLUtils.parseDOMFromString(description);
} catch (Exception e) {
}
if (document != null) {
Element root = document.getDocumentElement();
if (root != null) {
// create step's structure from dom
DatabaseObject parentObject = requestableStep.getParent();
Step step = StepUtils.createStepFromXmlDomModel(parentObject, root);
// add step's structure to parent of requestableStep
if (parentObject instanceof Sequence) {
Sequence parentSequence = (Sequence) parentObject;
parentSequence.addStep(step);
parentSequence.insertAtOrder(step, requestableStep.priority);
} else {
StepWithExpressions parentSwe = (StepWithExpressions) parentObject;
parentSwe.addStep(step);
parentSwe.insertAtOrder(step, requestableStep.priority);
}
// set source definition of variable
XMLVector<String> sourceDefinition = new XMLVector<String>();
sourceDefinition.add(String.valueOf(step.priority));
sourceDefinition.add(".");
stepVariable.setSourceDefinition(sourceDefinition);
stepVariable.hasChanged = true;
// Reload parent dbo in tree
explorerView.reloadTreeObject(parentDboTreeObject);
// Select variable dbo in tree
explorerView.objectSelected(new CompositeEvent(databaseObject));
}
}
}
}
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to generate and link variable!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.beans.common.XMLVector in project convertigo by convertigo.
the class CommandSNA method execute.
public JavelinExtractionRuleResult execute(iJavelin javelin, Block block, BlockFactory blockFactory, org.w3c.dom.Document dom) {
JavelinExtractionRuleResult xrs = new JavelinExtractionRuleResult();
xrs.hasMatched = false;
xrs.newCurrentBlock = block;
String textBlock = block.getText().trim();
int len = block.length;
XMLVector<XMLVector<String>> keywordTable = getKeywordTable();
// test if the current block matches a keyword
for (int i = 0; i < keywordTable.size(); i++) {
XMLVector<String> keyword = keywordTable.get(i);
String textKeyword = keyword.get(0);
String dataKeyword = keyword.get(1);
String replaceTextKeyword = keyword.get(2);
String actionKeyword = keyword.get(3);
if (labelLocation != CommandSNA.LABEL_LOCATION_WEST) {
// key is the first element ex : PF3=EXIT
if (textBlock.startsWith(textKeyword) || (textBlock.toLowerCase().startsWith(textKeyword.toLowerCase()) && !isCaseDependency())) {
if (labelLocation == CommandSNA.LABEL_LOCATION_EAST) {
Engine.logBeans.debug("LabelLocation = east");
// look for the original label if a keyword separator is specified
if (keywordSeparator.length() != 0) {
int keywordLen = textKeyword.length();
boolean separatorFound = false;
String oldLabel = "";
if (textBlock.length() > keywordLen + 1) {
// look for the separator char
for (int j = 0; j < keywordSeparator.length(); j++) {
if (textBlock.charAt(keywordLen) == keywordSeparator.charAt(j)) {
separatorFound = true;
oldLabel = textBlock.substring(keywordLen + 1);
}
}
if (separatorFound) {
// try to parse old label to see if the keyword is the only one of the block
int index = -1;
for (int k = 0; k < keywordTable.size(); k++) {
XMLVector<String> keywordBis = keywordTable.get(k);
String textKeywordBis = keywordBis.get(0);
if (oldLabel.indexOf(textKeywordBis) != -1 && (oldLabel.indexOf(textKeywordBis) < index || index == -1))
index = oldLabel.indexOf(textKeywordBis);
}
if (index != -1) {
// another keyword is found in the label : separate in 2 blocks
Block tmp;
try {
tmp = (Block) block.clone();
} catch (CloneNotSupportedException e) {
Engine.logBeans.error("Exception thrown during block clone", e);
tmp = new Block();
}
block.setText(oldLabel.substring(0, index));
tmp.setText(oldLabel.substring(index));
tmp.column = tmp.column + index + keywordLen + 1;
blockFactory.insertBlock(tmp, block);
} else {
block.setText(oldLabel);
}
}
} else {
// Searching the separator char in the current block
if (textBlock.length() == keywordLen + 1) {
for (int j = 0; j < keywordSeparator.length(); j++) {
if (textBlock.charAt(keywordLen) == keywordSeparator.charAt(j))
// Found the separator char at the end of the current block
separatorFound = true;
}
}
Block eastBlock = blockFactory.getEastBlock(block);
if (eastBlock != null && eastBlock.getText().length() != 0) {
if (separatorFound) {
// east block contains label
oldLabel = eastBlock.getText().trim();
} else {
// Searching the separator char in the east block
String eastBlockText = eastBlock.getText().trim();
for (int j = 0; j < keywordSeparator.length(); j++) {
if (!eastBlockText.equals("") && eastBlockText.charAt(0) == keywordSeparator.charAt(j)) {
// Found the separator char at the beginning of the east block
separatorFound = true;
if (eastBlockText.length() > 1)
oldLabel = eastBlockText.substring(1).trim();
}
}
}
if (separatorFound) {
// try to parse old label to see if the keyword is the only one of the block
int index = -1;
for (int k = 0; k < keywordTable.size(); k++) {
XMLVector<String> keywordBis = keywordTable.get(i);
String textKeywordBis = keywordBis.get(0);
if (oldLabel.indexOf(textKeywordBis) != -1 && oldLabel.indexOf(textKeywordBis) < index)
index = oldLabel.indexOf(textKeywordBis);
}
if (index != -1) {
// another keyword is found in the label :
// remove the first label from this east block and put it in the first block
block.setText(oldLabel.substring(0, index));
eastBlock.setText(oldLabel.substring(index));
}
}
}
}
if (isSeparatorMendatory() && !separatorFound) {
xrs.hasMatched = false;
xrs.newCurrentBlock = block;
return (xrs);
}
}
// if replace text is specified
if (replaceTextKeyword.length() != 0) {
// replace the text with the specified one
// but keep the original size
int originalLen = block.length;
block.setText(replaceTextKeyword);
block.length = originalLen;
}
} else if (labelLocation == CommandSNA.LABEL_LOCATION_NORTH) {
Engine.logBeans.debug("LabelLocation = north");
// if replace text is specified
if (replaceTextKeyword.length() != 0) {
// replace the text with the specified one
// but keep the original size
int originalLen = block.length;
block.setText(replaceTextKeyword);
block.length = originalLen;
} else {
// look for label in north block
Block northBlock = blockFactory.getNorthBlock(block);
if (northBlock != null && northBlock.line == block.line - 1 && northBlock.getText().length() != 0) {
// setText changes the length!
block.setText(northBlock.getText());
block.length = len;
blockFactory.removeBlock(northBlock);
}
}
} else if (labelLocation == CommandSNA.LABEL_LOCATION_SOUTH) {
Engine.logBeans.debug("LabelLocation = south");
// if replace text is specified
if (replaceTextKeyword.length() != 0) {
// replace the text with the specified one
// but keep the original size
int originalLen = block.length;
block.setText(replaceTextKeyword);
block.length = originalLen;
} else {
// look for label in south block
Block southBlock = blockFactory.getSouthBlock(block);
if (southBlock != null && southBlock.line == block.line + 1 && southBlock.getText().length() != 0) {
// setText changes the length!
block.setText(southBlock.getText());
block.length = len;
blockFactory.removeBlock(southBlock);
}
}
}
// set block's type to "keyword"
block.type = "keyword";
// "data" attribute
if (dataKeyword.length() != 0) {
// if data is specified for this keyword, set the "data" attribute
block.setOptionalAttribute("data", dataKeyword);
} else if (block.getOptionalAttribute("data") == null) {
// else, if the attribute doesn't exist, set to ""
block.setOptionalAttribute("data", "");
}
// "action" attribute
if (actionKeyword.length() != 0) {
// if action is specified, set the "action" attribute
block.setOptionalAttribute("action", actionKeyword);
} else if (block.getOptionalAttribute("action") == null) {
// else, if the attribute doesn't exist, set to ""
block.setOptionalAttribute("action", "");
}
// otherwise it keeps the old value
addMashupAttribute(block);
xrs.hasMatched = true;
xrs.newCurrentBlock = block;
return (xrs);
}
} else {
// label is the first element ex : EXIT=PF3
if (textBlock.endsWith(textKeyword) || (textBlock.toLowerCase().endsWith(textKeyword.toLowerCase()) && !isCaseDependency())) {
// set its type to "keyword"
block.type = "keyword";
// set the "data" attribute
if (dataKeyword.length() != 0) {
block.setOptionalAttribute("data", dataKeyword);
} else // otherwise it keeps the old value
if (block.getOptionalAttribute("data") == null)
block.setOptionalAttribute("data", "");
// keep the original size
if (replaceTextKeyword.length() != 0) {
block.setText(replaceTextKeyword);
block.length = len;
} else // else use the text BEFORE the separator character
{
if (textBlock.length() > textKeyword.length() + 1) {
if (keywordSeparator.length() != 0) {
StringTokenizer st = new StringTokenizer(textBlock, keywordSeparator);
block.setText(st.nextToken());
block.length = len;
}
} else {
// Searching the label in the west block
boolean separatorCharFound = false;
int keywordLen = textKeyword.length();
// Searching the separator char in the current block
if (textBlock.length() == keywordLen + 1) {
for (int j = 0; j < keywordSeparator.length(); j++) {
if (textBlock.charAt(0) == keywordSeparator.charAt(j)) {
// Found the separator char at the beginning of the current block
separatorCharFound = true;
}
}
}
Block westBlock = blockFactory.getWestBlock(block);
if (westBlock != null) {
// Searching the separator char in the west block
String westBlockText = westBlock.getText().trim();
for (int j = 0; j < keywordSeparator.length(); j++) {
if (!westBlockText.equals("") && westBlockText.charAt(westBlockText.length() - 1) == keywordSeparator.charAt(j)) {
// Found the separator char at the end of the east block
separatorCharFound = true;
if (westBlockText.length() > 1) {
westBlockText = westBlockText.substring(0, westBlockText.length() - 1).trim();
}
}
}
if (westBlock != null && westBlock.getText().length() != 0 && separatorCharFound) {
// setText changes the length!
block.setText(westBlockText);
block.length = len;
blockFactory.removeBlock(westBlock);
}
}
}
}
// set the "action" attribute
if (actionKeyword.length() != 0) {
block.setOptionalAttribute("action", actionKeyword);
} else // otherwise it keeps the old value
if (block.getOptionalAttribute("action") == null) {
block.setOptionalAttribute("action", "");
}
addMashupAttribute(block);
xrs.hasMatched = true;
xrs.newCurrentBlock = block;
return (xrs);
}
}
}
xrs.hasMatched = false;
xrs.newCurrentBlock = block;
return xrs;
}
use of com.twinsoft.convertigo.beans.common.XMLVector in project convertigo by convertigo.
the class Subfile method createTitleColumns.
private XMLVector<XMLVector<Object>> createTitleColumns(WindowedBlockManager windowedBlockManager, Block block, int bottomScreenZone, int columnDataLastCharEast) {
XMLVector<XMLVector<Object>> columns = new XMLVector<XMLVector<Object>>();
XMLVector<Object> oldCol = null;
Block curBlock;
// int curLine = block.line;
ArrayList<Block> blockToRemove = new ArrayList<Block>();
int bottomLineOfTitle = block.line;
int firstLine = getSelectionScreenZone().y;
int nbUp = 0;
curBlock = block;
Engine.logBeans.trace("Entering createTitleColumns() with " + curBlock.toString());
columnsBlocks = new Vector<Block>();
// For each column of the table
while (curBlock != null) {
if (!canBlockBeSelected(curBlock)) {
curBlock = windowedBlockManager.getNextBlock(curBlock);
continue;
}
Block topBlock = curBlock;
// We go up to the first block of the title rows. (The top block of this column can be higher than the top block of the first column.)
while (windowedBlockManager.getNorthBlock(topBlock) != null && (JavelinUtils.isSameAttribute(windowedBlockManager.getNorthBlock(topBlock).attribute, titleRowAttribute)) && (windowedBlockManager.getNorthBlock(topBlock).line == topBlock.line - 1)) {
topBlock = windowedBlockManager.getNorthBlock(topBlock);
nbUp++;
/* update the titleSize variable representing the size of the title row */
if (nbUp > titleHeight)
titleHeight = nbUp;
}
Engine.logBeans.trace("Top block is " + topBlock);
// Now we append the text of the other blocks of the title rows
String title = "";
Block blockTmp = topBlock;
blockTmp.setText(blockTmp.getText() + " ");
// int maxLine = blockTmp.line;
while ((blockTmp != null) && (JavelinUtils.isSameAttribute(blockTmp.attribute, titleRowAttribute))) {
if (title == "")
title = blockTmp.getText();
else {
title = title + " " + blockTmp.getText();
}
if (!columnsBlocks.contains(blockTmp))
columnsBlocks.add(blockTmp);
columnTitleWest = Math.min(columnTitleWest, block.column);
columnTitleEast = Math.max(columnTitleEast, block.column + block.length);
blockToRemove.add(blockTmp);
if (windowedBlockManager.getSouthBlock(blockTmp) != null && windowedBlockManager.getSouthBlock(blockTmp).line == blockTmp.line + 1)
blockTmp = windowedBlockManager.getSouthBlock(blockTmp);
else
blockTmp = null;
}
// creation of the column vector
XMLVector<Object> col = new XMLVector<Object>();
col.add(new String(title));
col.add(Integer.valueOf(curBlock.column));
col.add(Integer.valueOf(columnDataLastCharEast));
col.add(Integer.valueOf(firstLine - 1));
col.add(Integer.valueOf(0));
columns.add(col);
// Update the endColumn of the previous column
if (oldCol != null) {
oldCol.set(2, Integer.valueOf(curBlock.column - 1));
Engine.logBeans.trace("Updating the endColumn of the previous column to: " + (curBlock.column - 1));
}
// Save the col in order to update the endColumn with the begin column - 1 of the next column
oldCol = col;
Engine.logBeans.trace("Table defining '" + title + "' from column: " + curBlock.column + " to column: " + columnDataLastCharEast);
// We choose the next block
blockTmp = topBlock;
while (blockTmp != null && (windowedBlockManager.getSouthBlock(blockTmp) != null && JavelinUtils.isSameAttribute(blockTmp.attribute, titleRowAttribute) && (windowedBlockManager.getSouthBlock(blockTmp).line == blockTmp.line + 1) && (blockTmp.line != bottomLineOfTitle))) {
if (windowedBlockManager.getEastBlock(blockTmp) != null)
if (curBlock == null || (windowedBlockManager.getEastBlock(blockTmp).column < curBlock.column))
curBlock = windowedBlockManager.getEastBlock(blockTmp);
blockTmp = windowedBlockManager.getSouthBlock(blockTmp);
}
curBlock = windowedBlockManager.getEastBlock(blockTmp);
// We remove title blocks (and the ones above last row of title) now that they are defined
Block blockRem;
Block panel = windowedBlockManager.getPanel();
Engine.logBeans.trace("There are " + blockToRemove.size() + " blocks to remove.");
while (!blockToRemove.isEmpty()) {
blockRem = blockToRemove.get(0);
Engine.logBeans.trace("Remove of title block = " + blockRem.getText());
windowedBlockManager.removeBlock(blockRem);
// the subfile (if exists).
if (panel != null)
panel.removeOptionalChildren(blockRem);
blockToRemove.remove(0);
}
nbUp = 0;
Engine.logBeans.trace("The next block to be analysed is " + curBlock + "\n");
}
return columns;
}
use of com.twinsoft.convertigo.beans.common.XMLVector 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);
}
}
Aggregations