use of com.twinsoft.convertigo.beans.common.XMLVector in project convertigo by convertigo.
the class SetStepSourceDefinition method getServiceResult.
@Override
protected void getServiceResult(HttpServletRequest request, Document document) throws Exception {
HttpSession session = request.getSession();
CheStudio cheStudio = CallAction.getStudio(session);
Element root = document.getDocumentElement();
if (cheStudio != null) {
SourcePickerViewWrap spv = cheStudio.getSourcePickerView();
if (spv != null) {
// Retrieve the StepSource definition
String qname = request.getParameter("qname");
DatabaseObject dbo = Engine.theApp.databaseObjectsManager.getDatabaseObjectByQName(qname);
StepSourceWrap ssw = (StepSourceWrap) spv.getDragData();
// Update step source definition
if (com.twinsoft.convertigo.engine.admin.services.studio.sourcepicker.CanCreateSource.canCreateSource(dbo, ssw)) {
XMLVector<String> sourceDefinition = new XMLVector<>(2);
sourceDefinition.add(ssw.getPriority());
sourceDefinition.add(ssw.getXpath());
IStepSourceContainer stepSourceContainer = (IStepSourceContainer) dbo;
stepSourceContainer.setSourceDefinition(sourceDefinition);
root.appendChild(new SetPropertyResponse("sourceDefinition").toXml(document, qname));
}
}
}
}
use of com.twinsoft.convertigo.beans.common.XMLVector in project convertigo by convertigo.
the class SourcePickerView method sourceSelected.
public void sourceSelected(StepSourceEvent stepSourceEvent) {
sourcePicker.getTwsDomTree().removeAll();
sourcePicker.getXpathEvaluator().removeAnchor();
sourcePicker.getXpathEvaluator().getXpath().setText("");
DatabaseObject dbo = (DatabaseObject) stepSourceEvent.getSource();
String xpath = stepSourceEvent.getXPath();
String priority = "" + dbo.priority;
XMLVector<String> stepSourceDefinition = new XMLVector<String>();
stepSourceDefinition.add(priority);
stepSourceDefinition.add(xpath);
sourcePicker.setStepSourceDefinition(stepSourceDefinition);
selectedDbo = dbo;
fillHelpContent();
sourcePicker.displayTargetWsdlDom(dbo);
}
use of com.twinsoft.convertigo.beans.common.XMLVector in project convertigo by convertigo.
the class SourcePickerView method showStep.
private void showStep(DatabaseObject dbo, boolean showSource) {
if (selectedDbo == null)
return;
String priority, xpath;
DatabaseObject dboToShow = null;
if (showSource) {
XMLVector<String> sourceDefinition = ((IStepSourceContainer) dbo).getSourceDefinition();
if (!sourceDefinition.isEmpty()) {
Long key = Long.valueOf(sourceDefinition.firstElement());
priority = "" + key;
xpath = sourceDefinition.lastElement();
Step step = dbo instanceof Step ? (Step) dbo : (Step) dbo.getParent();
dboToShow = step.getSequence().loadedSteps.get(key);
if (dboToShow == null) {
ConvertigoPlugin.infoMessageBox("Source is not valid!");
return;
}
} else {
ConvertigoPlugin.infoMessageBox("Source is empty!");
return;
}
} else {
dboToShow = dbo;
priority = "" + dboToShow.priority;
xpath = ".";
}
sourcePicker.getTwsDomTree().removeAll();
sourcePicker.getXpathEvaluator().removeAnchor();
sourcePicker.getXpathEvaluator().getXpath().setText("");
XMLVector<String> stepSourceDefinition = new XMLVector<String>();
stepSourceDefinition.add(priority);
stepSourceDefinition.add(xpath);
sourcePicker.setStepSourceDefinition(stepSourceDefinition);
sourcePicker.displayTargetWsdlDom(dboToShow);
try {
TreeObject treeObject = ConvertigoPlugin.getDefault().getProjectExplorerView().findTreeObjectByUserObject(dboToShow);
ConvertigoPlugin.getDefault().getProjectExplorerView().setSelectedTreeObject(treeObject);
} catch (Throwable t) {
}
}
use of com.twinsoft.convertigo.beans.common.XMLVector in project convertigo by convertigo.
the class TransactionWithVariables method configure.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void configure(Element element) throws Exception {
super.configure(element);
String version = element.getAttribute("version");
if (version == null) {
String s = XMLUtils.prettyPrintDOM(element);
EngineException ee = new EngineException("Unable to find version number for the database object \"" + getName() + "\".\nXML data: " + s);
throw ee;
}
if (VersionUtils.compare(version, "3.1.8") < 0) {
int len = orderedVariables.size();
XMLVector line;
for (int i = 0; i < len; i++) {
line = (XMLVector) orderedVariables.get(i);
if (line.size() > 0) {
// Include in WSDL by default
line.add(Boolean.TRUE);
}
}
hasChanged = true;
Engine.logBeans.warn("[TransactionWithVariables] The object \"" + getName() + "\" has been updated to version 3.1.8");
}
if (VersionUtils.compare(version, "3.2.4") < 0) {
int len = orderedVariables.size();
XMLVector line;
for (int i = 0; i < len; i++) {
line = (XMLVector) orderedVariables.get(i);
if (line.size() > 0) {
// Defaults to non multivalued variable
line.add(3, Boolean.FALSE);
}
}
hasChanged = true;
Engine.logBeans.warn("[TransactionWithVariables] The object \"" + getName() + "\" has been updated to version 3.2.4");
}
if (VersionUtils.compare(version, "4.2.0") < 0) {
int len = orderedVariables.size();
XMLVector line;
for (int i = 0; i < len; i++) {
line = (XMLVector) orderedVariables.get(i);
if (line.size() > 0) {
// Do not set as Personalizable by default
line.add(4, Boolean.FALSE);
// Sets description to variable name by default
line.add(1, line.get(0));
}
}
hasChanged = true;
Engine.logBeans.warn("[TransactionWithVariables] The object \"" + getName() + "\" has been updated to version 4.2.0");
}
if (VersionUtils.compare(version, "4.3.0") < 0) {
int len = orderedVariables.size();
XMLVector line;
for (int i = 0; i < len; i++) {
line = (XMLVector) orderedVariables.get(i);
if (line.size() > 0) {
// Set cached key
line.add(6, Boolean.TRUE);
}
}
hasChanged = true;
Engine.logBeans.warn("[TransactionWithVariables] The object \"" + getName() + "\" has been updated to version 4.3.0");
}
}
use of com.twinsoft.convertigo.beans.common.XMLVector in project convertigo by convertigo.
the class Subfile method execute.
/**
* Applies the extraction rule to the current iJavelin object.
*
* @param javelin the Javelin object.
* @param block the current block to analyze.
* @param blockFactory the block context of the current block.
*
* @return an ExtractionRuleResult object containing the result of
* the query.
*/
public JavelinExtractionRuleResult execute(iJavelin javelin, Block block, BlockFactory blockFactory, org.w3c.dom.Document dom) {
// save the screenZone so that we can restore it after the extraction of tableCUA
XMLRectangle oldScreenZone = getSelectionScreenZone();
XMLVector<XMLVector<Object>> oldColumns = getColumns();
JavelinExtractionRuleResult xrs = new JavelinExtractionRuleResult();
Block downRightBlock, topLeftBlock, blockTmp, newBlock, topActionBlock;
int columnDataLastCharEast, columnDataLastCharWest, dataLastLine;
int subfileMarkerLine;
// attributes of the field of action in the table
int actionLength = 0;
int actionColumn = 0;
// int actionColumnAttributes = 0;
boolean actionColumnExists = false;
Block lastField = null;
boolean screenZoneSet = false;
StringTokenizer st = new StringTokenizer(endString, ",", false);
ArrayList<String> token = new ArrayList<String>(st.countTokens());
// if screen zone has been set, use it...
if (oldScreenZone.x != -1 || oldScreenZone.y != -1 || oldScreenZone.height != -1 || oldScreenZone.width != -1) {
screenZoneSet = true;
}
// for each string
while (st.hasMoreTokens()) {
token.add((String) st.nextToken());
}
try {
// search of the endString among the blocks of the blockFactory
if (token.contains(block.getText().trim()) && JavelinUtils.isSameAttribute(block.attribute, endStringAttribute) && block.line >= subFileDetectionStartLine) {
WindowedBlockManager windowedBlockManager = new WindowedBlockManager(blockFactory);
Engine.logBeans.trace("Searching the end block in a panel.");
if (!windowedBlockManager.searchPanel(block)) {
xrs.hasMatched = false;
xrs.newCurrentBlock = block;
return xrs;
}
// this line of code was not commented. I believe this was to prevent SubFile rule to be run twice. I prefer to set the xrs.newCurrentBlock
// to the correct value. This also corrects the bug that prevented the delete blocks rule to act on the subfile marker as it was marked
// as bFinal to true.
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!
// !! block.bFinal = true; !!
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!
subfileMarkerLine = block.line;
// if endString = "+" -> special case (Non-CUA but we can try to define the subfile)
if (block.getText().equals("+")) {
/**
* CASE "+" in the last row, in the last column
*/
downRightBlock = block;
dataLastLine = downRightBlock.line;
// as '+' is on same line as the alst row of data , add one line to subFileMarkerLine
subfileMarkerLine++;
// do not include marker block in data
downRightBlock = windowedBlockManager.getPreviousBlockInPanel(block);
Engine.logBeans.trace("Down Right Block = " + downRightBlock.getText());
block.line = block.line + 1;
} else // if endString != "+" (most common case)
{
// we look for a block directly above the endString
downRightBlock = windowedBlockManager.getPreviousBlockInPanel(block);
Engine.logBeans.trace("Down Right Block = " + downRightBlock.toString());
while (downRightBlock != null && downRightBlock.line == block.line) {
downRightBlock = windowedBlockManager.getPreviousBlockInPanel(downRightBlock);
Engine.logBeans.trace("New Down Right Block = " + downRightBlock.toString());
}
dataLastLine = downRightBlock.line;
}
// if previous block do not contain any text, we give up creation of the table
if (downRightBlock.length == 0) {
Engine.logBeans.info("Give up subfile creation => Down Right Block length is 0 : " + downRightBlock.toString());
xrs.hasMatched = false;
xrs.newCurrentBlock = block;
return xrs;
}
if ((block.column + block.getText().length()) <= (downRightBlock.column + downRightBlock.getText().length()))
columnDataLastCharEast = downRightBlock.column + downRightBlock.getText().length();
else
columnDataLastCharEast = block.column + block.getText().length();
// we move to west and search for the last block on the line (last row)
blockTmp = downRightBlock;
while (windowedBlockManager.getWestBlock(blockTmp) != null && windowedBlockManager.getWestBlock(blockTmp).line == dataLastLine) {
blockTmp = windowedBlockManager.getWestBlock(blockTmp);
}
Engine.logBeans.trace("last block on the line (west) = " + blockTmp.toString());
columnDataLastCharWest = blockTmp.column;
// we check if action column exists
if (blockTmp.type.equalsIgnoreCase("field")) {
actionColumnExists = true;
actionLength = blockTmp.length;
actionColumn = blockTmp.column;
// actionColumnAttributes = blockTmp.attribute;
} else // maybe action column exists but not on this line
{
List<Block> blockField = windowedBlockManager.getBlocksByType("field");
for (Block blockF : blockField) {
Engine.logBeans.trace("block field found = " + blockF.toString());
if (lastField == null) {
if (blockF.column <= blockTmp.column && blockF.line < blockTmp.line) {
lastField = blockF;
}
} else {
if (blockF.line > lastField.line || blockF.column > lastField.column) {
lastField = blockF;
}
}
}
}
// an action column, it can happen that it doesn't have a title
if (actionColumnExists) {
// if we are in the action column
Engine.logBeans.trace("+++ action column exists +++");
if (columnDataLastCharWest > blockTmp.column) {
columnDataLastCharWest = blockTmp.column;
}
topLeftBlock = null;
} else {
// we are in a data column
Engine.logBeans.trace("Searching title row in data column : " + blockTmp.getText());
while ((windowedBlockManager.getNorthBlock(blockTmp) != null) && (!JavelinUtils.isSameAttribute(windowedBlockManager.getNorthBlock(blockTmp).attribute, titleRowAttribute))) {
blockTmp = windowedBlockManager.getNorthBlock(blockTmp);
Engine.logBeans.trace("Moving to north block : " + blockTmp.getText());
}
// check if the last field is in the data
if (lastField == null || lastField.line < blockTmp.line) {
Engine.logBeans.trace("---actionColumnDoesNotExists");
blockTmp = windowedBlockManager.getNorthBlock(blockTmp);
while (windowedBlockManager.getWestBlock(blockTmp) != null) {
blockTmp = windowedBlockManager.getWestBlock(blockTmp);
Engine.logBeans.trace("Moving to west block : " + blockTmp.getText());
if (columnDataLastCharWest > blockTmp.column) {
columnDataLastCharWest = blockTmp.column;
}
}
topLeftBlock = blockTmp;
Engine.logBeans.trace("Top Left Block = " + (topLeftBlock == null ? "null" : topLeftBlock.getText()));
} else {
Engine.logBeans.trace("+++ action column exists +++");
actionColumnExists = true;
if (columnDataLastCharWest > lastField.column) {
columnDataLastCharWest = lastField.column;
}
blockTmp = lastField;
topLeftBlock = null;
}
}
if (actionColumnExists) {
// we search the bottom of the title rows (but maybe action column doesn't have a title)
while (// while north block of blocktmp not null
(windowedBlockManager.getNorthBlock(blockTmp) != null) && // and north block of blocktmp is not same attribute as titlerow
(!JavelinUtils.isSameAttribute(windowedBlockManager.getNorthBlock(blockTmp).attribute, titleRowAttribute)) && (!JavelinUtils.isSameAttribute(windowedBlockManager.getNorthBlock(blockTmp).attribute, actionLineAttribute))) {
// and north block of blocktmp is not same attribute as actionsline
Engine.logBeans.trace("Wrong title line found (" + blockTmp.line + ") ... keep searching...");
blockTmp = windowedBlockManager.getNorthBlock(blockTmp);
}
// is north block of blocktmp the first title block of first column ?
if (// if north block of blocktmp not null
(windowedBlockManager.getNorthBlock(blockTmp) != null) && // and north block of blocktmp has titlerow attribute
(JavelinUtils.isSameAttribute(windowedBlockManager.getNorthBlock(blockTmp).attribute, titleRowAttribute)) && (goodTitleLine(windowedBlockManager, windowedBlockManager.getNorthBlock(blockTmp)))) {
// and north bolck of blocktmp is on a good title line
// blocktmp is the last top data block of the first column
Engine.logBeans.trace("Top of the action column= " + blockTmp.toString());
topActionBlock = blockTmp;
} else {
// action column is not filled until top, blocktmp is not the last top line of data
// or action column doesn't have a title
Block actiontop = blockTmp;
// Searching a title block
blockTmp = windowedBlockManager.getEastBlock(blockTmp);
blockTmp = windowedBlockManager.getNorthBlock(blockTmp);
// look for a title block of the second column
while (// while north block of blocktmp not null
windowedBlockManager.getNorthBlock(blockTmp) != null && // and north block of blocktmp is the same attribute as titlerow
JavelinUtils.isSameAttribute(windowedBlockManager.getNorthBlock(blockTmp).attribute, titleRowAttribute)) {
Engine.logBeans.trace("Wrong title line found (" + blockTmp.line + ") ... keep searching...");
blockTmp = windowedBlockManager.getNorthBlock(blockTmp);
}
if (blockTmp == null) {
Engine.logBeans.info("Give up subfile creation => Looking for title block : blockTmp is null, no more block to test.");
xrs.hasMatched = false;
xrs.newCurrentBlock = block;
return xrs;
} else {
if (// if blocktmp has same attribute as titlerow
JavelinUtils.isSameAttribute(blockTmp.attribute, titleRowAttribute) && (goodTitleLine(windowedBlockManager, blockTmp))) {
// and blocktmp is on a good title line
Engine.logBeans.trace("Top of the action column= " + actiontop.toString());
topActionBlock = actiontop;
} else {
Engine.logBeans.info("Give up subfile creation => blockTmp is not of title attribute or is not on a good title line : " + blockTmp.toString());
xrs.hasMatched = false;
xrs.newCurrentBlock = block;
return xrs;
}
}
}
// go one column to the east of top action line block, and one block to the north
blockTmp = windowedBlockManager.getEastBlock(topActionBlock);
blockTmp = windowedBlockManager.getNorthBlock(blockTmp);
// block tmp is the first down title block of second column
// or another column if there is no data on the east of top action line block
Block firstTitleBlock = blockTmp;
// go to the first row of the title rows (if many)
while (windowedBlockManager.getNorthBlock(blockTmp) != null && JavelinUtils.isSameAttribute(windowedBlockManager.getNorthBlock(blockTmp).attribute, titleRowAttribute) && blockTmp.line - windowedBlockManager.getNorthBlock(blockTmp).line == 1) blockTmp = windowedBlockManager.getNorthBlock(blockTmp);
// we check if action column has a title
while (// while no more block is on the top
topActionBlock != null && // and the title row is not found
!JavelinUtils.isSameAttribute(topActionBlock.attribute, titleRowAttribute) && // and an action line is not found (we suppose that the title row must be under the actions line)
!JavelinUtils.isSameAttribute(topActionBlock.attribute, actionLineAttribute)) topActionBlock = windowedBlockManager.getNorthBlock(topActionBlock);
if (topActionBlock != null && JavelinUtils.isSameAttribute(topActionBlock.attribute, titleRowAttribute)) {
Engine.logBeans.trace("Action column has a title");
topLeftBlock = topActionBlock;
} else {
// we arrived on the top of the screen or on the actions line
Engine.logBeans.trace("Action column does not have a title");
Engine.logBeans.trace("Value of the first block of the title row : " + blockTmp.toString());
newBlock = new Block();
newBlock.column = actionColumn;
newBlock.length = actionLength;
newBlock.line = firstTitleBlock.line;
newBlock.attribute = titleRowAttribute;
newBlock.setText("A");
newBlock.bRender = false;
Engine.logBeans.trace("Creation of the title block of the action column : " + newBlock.toString());
// maybe firstTitleBlock is not the second column title, look to the west to see if there are other titles
while (windowedBlockManager.getWestBlock(firstTitleBlock) != null) firstTitleBlock = windowedBlockManager.getWestBlock(firstTitleBlock);
// now firstTitleBlock is the second column title, can insert the created block after its preceding block
Engine.logBeans.trace("Insert new title block after : " + windowedBlockManager.getPreviousBlock(firstTitleBlock).toString());
windowedBlockManager.insertBlock(newBlock, windowedBlockManager.getPreviousBlock(firstTitleBlock));
Engine.logBeans.trace("Next of the new Block : " + windowedBlockManager.getNextBlock(newBlock).toString());
// if getNextBlock(newBlock) and newBlock are not on the same line, we've inserted the new block in the wrong place
if (windowedBlockManager.getNextBlock(newBlock).line != newBlock.line) {
Engine.logBeans.trace("The new block and its next block are not on the same line. Trying to insert it on the right place.");
Block newBlockTmp = newBlock;
while (windowedBlockManager.getNextBlock(newBlockTmp).line != newBlock.line) {
newBlockTmp = windowedBlockManager.getNextBlock(newBlockTmp);
}
Engine.logBeans.trace("The previous block of the right place is : " + newBlockTmp.toString());
windowedBlockManager.removeBlock(newBlock);
windowedBlockManager.insertBlock(newBlock, newBlockTmp);
}
topLeftBlock = newBlock;
}
}
// Engine.logBeans.trace("---topLeftBlock.attribute="+ topLeftBlock.attribute);
if (topLeftBlock != null && downRightBlock != null && goodTitleLine(windowedBlockManager, topLeftBlock) && topLeftBlock.line != 0 && JavelinUtils.isSameAttribute(topLeftBlock.attribute, titleRowAttribute)) {
// We search the first row of data, to give to super.execute method
Block topLeftDataRow = topLeftBlock;
while (windowedBlockManager.getNextBlock(topLeftDataRow) != null && windowedBlockManager.getNextBlock(topLeftDataRow).line == topLeftBlock.line) {
topLeftDataRow = windowedBlockManager.getNextBlock(topLeftDataRow);
}
topLeftDataRow = windowedBlockManager.getNextBlock(topLeftDataRow);
// Set line of actions and finding columns of the table
if (actionColumnExists) {
setColumnSelection(0);
int checkAction = extractActionsLine(windowedBlockManager, topLeftBlock);
if (checkAction == 0)
setColumnSelection(-1);
else
setLineActions(checkAction);
} else
setColumnSelection(-1);
columnTitleWest = javelin.getScreenWidth();
columnTitleEast = 0;
setColumns(createTitleColumns(windowedBlockManager, topLeftBlock, downRightBlock.line, columnDataLastCharEast));
Engine.logBeans.trace("##### Columns: " + getColumns());
XMLRectangle mySelectionScreenZone = new XMLRectangle(Math.min(columnDataLastCharWest, columnTitleWest), topLeftBlock.line + 1, (Math.max(columnDataLastCharEast, columnTitleEast) - topLeftBlock.column) + 1, subfileMarkerLine - topLeftBlock.line - 1);
if (screenZoneSet)
setSelectionScreenZone(oldScreenZone);
else
setSelectionScreenZone(mySelectionScreenZone);
// set the offset to 1 this will result in the table to be shifted up one line
if (actionColumnExists)
this.setOffset(2);
else
this.setOffset(1);
// removing the subfile blocks from their panel.
Block panel = windowedBlockManager.getPanel();
if (panel != null) {
Engine.logBeans.trace("SelectionScreenZone: " + getSelectionScreenZone().toString());
for (Block panelChildBlock : new ArrayList<Block>(panel.getOptionalBlockChildren())) {
Engine.logBeans.trace("Trying to remove from Panel: " + panelChildBlock.toString());
if (// data line
getSelectionScreenZone().contains(panelChildBlock.column, panelChildBlock.line, panelChildBlock.length, 1) || (JavelinUtils.isSameAttribute(panelChildBlock.attribute, actionLineAttribute) && panelChildBlock.line < getSelectionScreenZone().y && panelChildBlock.line >= getSelectionScreenZone().y + getLineActions())) {
// action line
panel.removeOptionalChildren(panelChildBlock);
Engine.logBeans.trace("Removed.");
}
}
}
Engine.logBeans.trace("columnDataLastCharWest=" + columnDataLastCharWest + "; topLeftBlock-line=" + topLeftBlock.line + "; downright-col= " + columnDataLastCharEast + "; downright-line= " + downRightBlock.line);
xrs = super.execute(javelin, topLeftDataRow, blockFactory, dom);
table.setOptionalAttribute("subfile", "true");
table.setOptionalAttribute("titleheight", Integer.toString(titleHeight + 1));
setSelectionScreenZone(oldScreenZone);
setColumns(oldColumns);
// block still contains the end of sub file marker .. set the newCurrentBlock to this block
xrs.newCurrentBlock = block;
return xrs;
} else {
Engine.logBeans.info("Give up subfile creation => Down Right Block is null : " + downRightBlock.toString());
Engine.logBeans.info(" OR Top Left Block is null or not of title attribute : " + (topLeftBlock == null ? "null" : topLeftBlock.toString()));
xrs.hasMatched = false;
xrs.newCurrentBlock = block;
return xrs;
}
} else {
xrs.hasMatched = false;
xrs.newCurrentBlock = block;
return xrs;
}
} catch (NullPointerException e) {
Engine.logBeans.error("NullPointerException while executing the Subfile extraction rule", e);
xrs.hasMatched = false;
xrs.newCurrentBlock = blockFactory.getLastBlock();
return xrs;
}
}
Aggregations