List of usage examples for java.util Stack peek
public synchronized E peek()
From source file:org.jumpmind.metl.core.runtime.component.XmlFormatter.java
private void addModelAttributeXml(Stack<DocElement> parentStack, String attributeId, Object modelAttrValue, Document generatedXml, String entityId) { DocElement templateDocElement = entityAttributeDtls.get(attributeId); String value = modelAttrValue == null ? null : modelAttrValue.toString(); Element newElement = null;//from ww w . java 2 s . c o m Element templateParentElement = null; String templateParentXPath = null; Attribute newAttribute = null; Map<Element, Namespace> generatedDocNamespaces = null; Map<Element, Namespace> templateNamespaces = null; Stack<Element> parentsToAdd = new Stack<Element>(); DocElement entityDocElement = entityAttributeDtls.get(entityId); generatedDocNamespaces = removeNamespaces(generatedXml); templateNamespaces = removeNamespaces(templateDoc); // we can be passed elements in the model that don't reside in the // template. If so, just ignore the field and do nothing if (templateDocElement != null) { // at this point, our stack should always currently have the entity // for this attribute as the top level of the stack // set up our new element or attribute to add if (templateDocElement.xmlElement != null) { // we have to add an element newElement = templateDocElement.xmlElement.clone(); newElement.removeContent(); removeAllAttributes(newElement); if (StringUtils.isEmpty(value)) { if (nullHandling.equalsIgnoreCase(NULL_HANDLING_XML_NIL)) { newElement.setAttribute("nil", "true", getXmlNamespace()); } } else { newElement.setText(value); } } else { // we have to add an attribute newAttribute = templateDocElement.xmlAttribute.clone(); if (value != null) { newAttribute.setValue(value); } } // in this case the attribute is one lower than the entity and // should simply be attached to the entity if (templateDocElement.level - 1 == parentStack.peek().level) { if (newElement != null) { applyAttributeXPath(generatedXml, templateDocElement.xpath, value); } else { parentStack.peek().xmlElement.setAttribute(newAttribute); } } else { // the attribute doesn't hang directly off the entity // we must find its parent in the existing doc or fill static // content as appropriate // first get the parent element for this model attribute, and // gets its xpath XPathExpression<Element> expression = XPathFactory.instance().compile(templateDocElement.xpath, Filters.element()); List<Element> matches = expression.evaluate(templateDoc.getRootElement()); if (matches.size() != 0) { templateParentElement = matches.get(0).getParentElement(); } else { // throw an exception, we should always find the element in // the template } // now look for parent elements in the generated xml until we // find one // or we hit the entity itself boolean parentFound = false; do { templateParentXPath = XPathHelper.getRelativePath(entityDocElement.xmlElement, templateParentElement); expression = XPathFactory.instance().compile(templateParentXPath, Filters.element()); matches = expression.evaluate(parentStack.peek().xmlElement); if (matches.size() == 0) { Element elementToAdd = templateParentElement.clone(); elementToAdd.removeContent(); removeAllAttributes(elementToAdd); parentsToAdd.push(elementToAdd); templateParentElement = templateParentElement.getParentElement(); } else { parentFound = true; } } while (parentFound == false); // add every parent we couldn't find up to the entity level Element elementToAddTo = matches.get(0); while (!parentsToAdd.isEmpty()) { elementToAddTo.addContent(0, parentsToAdd.peek()); elementToAddTo = parentsToAdd.pop(); } // add our model attribute to the latest level if (newElement != null) { applyAttributeXPath(generatedXml, templateDocElement.xpath, value); } else { elementToAddTo.setAttribute(newAttribute); } } } restoreNamespaces(templateDoc, templateNamespaces); restoreNamespaces(generatedXml, generatedDocNamespaces); }
From source file:org.apache.tajo.engine.planner.LogicalPlanner.java
public LogicalNode postHook(PlanContext context, Stack<Expr> stack, Expr expr, LogicalNode current) throws PlanningException { // Some generated logical nodes (e.g., implicit aggregation) without exprs will pass NULL as a expr parameter. // We should skip them. if (expr != null) { // A relation list including a single ScanNode will return a ScanNode instance that already passed postHook. // So, it skips the already-visited ScanNode instance. if (expr.getType() == OpType.RelationList && current.getType() == NodeType.SCAN) { return current; }// ww w . j ava 2 s .c om } QueryBlock queryBlock = context.queryBlock; queryBlock.updateLatestNode(current); // if this node is the topmost if (stack.size() == 0) { queryBlock.setRoot(current); } if (!stack.empty()) { queryBlock.updateCurrentNode(stack.peek()); } return current; }
From source file:org.apache.hadoop.hbase.filter.ParseFilter.java
/** * Parses the filterString and constructs a filter using it * <p>/*w w w.ja v a2 s . c om*/ * @param filterStringAsByteArray filter string given by the user * @return filter object we constructed */ public Filter parseFilterString(byte[] filterStringAsByteArray) throws CharacterCodingException { // stack for the operators and parenthesis Stack<ByteBuffer> operatorStack = new Stack<ByteBuffer>(); // stack for the filter objects Stack<Filter> filterStack = new Stack<Filter>(); Filter filter = null; for (int i = 0; i < filterStringAsByteArray.length; i++) { if (filterStringAsByteArray[i] == ParseConstants.LPAREN) { // LPAREN found operatorStack.push(ParseConstants.LPAREN_BUFFER); } else if (filterStringAsByteArray[i] == ParseConstants.WHITESPACE || filterStringAsByteArray[i] == ParseConstants.TAB) { // WHITESPACE or TAB found continue; } else if (checkForOr(filterStringAsByteArray, i)) { // OR found i += ParseConstants.OR_ARRAY.length - 1; reduce(operatorStack, filterStack, ParseConstants.OR_BUFFER); operatorStack.push(ParseConstants.OR_BUFFER); } else if (checkForAnd(filterStringAsByteArray, i)) { // AND found i += ParseConstants.AND_ARRAY.length - 1; reduce(operatorStack, filterStack, ParseConstants.AND_BUFFER); operatorStack.push(ParseConstants.AND_BUFFER); } else if (checkForSkip(filterStringAsByteArray, i)) { // SKIP found i += ParseConstants.SKIP_ARRAY.length - 1; reduce(operatorStack, filterStack, ParseConstants.SKIP_BUFFER); operatorStack.push(ParseConstants.SKIP_BUFFER); } else if (checkForWhile(filterStringAsByteArray, i)) { // WHILE found i += ParseConstants.WHILE_ARRAY.length - 1; reduce(operatorStack, filterStack, ParseConstants.WHILE_BUFFER); operatorStack.push(ParseConstants.WHILE_BUFFER); } else if (filterStringAsByteArray[i] == ParseConstants.RPAREN) { // RPAREN found if (operatorStack.empty()) { throw new IllegalArgumentException("Mismatched parenthesis"); } ByteBuffer argumentOnTopOfStack = operatorStack.peek(); while (!(argumentOnTopOfStack.equals(ParseConstants.LPAREN_BUFFER))) { filterStack.push(popArguments(operatorStack, filterStack)); if (operatorStack.empty()) { throw new IllegalArgumentException("Mismatched parenthesis"); } argumentOnTopOfStack = operatorStack.pop(); } } else { // SimpleFilterExpression found byte[] filterSimpleExpression = extractFilterSimpleExpression(filterStringAsByteArray, i); i += (filterSimpleExpression.length - 1); filter = parseSimpleFilterExpression(filterSimpleExpression); filterStack.push(filter); } } // Finished parsing filterString while (!operatorStack.empty()) { filterStack.push(popArguments(operatorStack, filterStack)); } filter = filterStack.pop(); if (!filterStack.empty()) { throw new IllegalArgumentException("Incorrect Filter String"); } return filter; }
From source file:com.sqewd.open.dal.core.persistence.db.EntityHelper.java
@SuppressWarnings({ "unchecked", "rawtypes" }) public static void setColumnValue(final ResultSet rs, final StructAttributeReflect attr, final AbstractEntity entity, final AbstractJoinGraph gr, final Stack<KeyValuePair<Class<?>>> path) throws Exception { KeyValuePair<String> alias = gr.getAliasFor(path, attr.Column, 0); String tabprefix = alias.getKey(); if (EnumPrimitives.isPrimitiveType(attr.Field.getType())) { EnumPrimitives prim = EnumPrimitives.type(attr.Field.getType()); switch (prim) { case ECharacter: String sv = rs.getString(tabprefix + "." + attr.Column); if (!rs.wasNull()) { PropertyUtils.setSimpleProperty(entity, attr.Field.getName(), sv.charAt(0)); }/* w w w . j a va 2s .c o m*/ break; case EShort: short shv = rs.getShort(tabprefix + "." + attr.Column); if (!rs.wasNull()) { PropertyUtils.setSimpleProperty(entity, attr.Field.getName(), shv); } break; case EInteger: int iv = rs.getInt(tabprefix + "." + attr.Column); if (!rs.wasNull()) { PropertyUtils.setSimpleProperty(entity, attr.Field.getName(), iv); } break; case ELong: long lv = rs.getLong(tabprefix + "." + attr.Column); if (!rs.wasNull()) { PropertyUtils.setSimpleProperty(entity, attr.Field.getName(), lv); } break; case EFloat: float fv = rs.getFloat(tabprefix + "." + attr.Column); if (!rs.wasNull()) { PropertyUtils.setSimpleProperty(entity, attr.Field.getName(), fv); } break; case EDouble: double dv = rs.getDouble(tabprefix + "." + attr.Column); if (!rs.wasNull()) { PropertyUtils.setSimpleProperty(entity, attr.Field.getName(), dv); } break; default: throw new Exception("Unsupported Data type [" + prim.name() + "]"); } } else if (attr.Convertor != null) { String value = rs.getString(tabprefix + "." + attr.Column); if (!rs.wasNull()) { attr.Convertor.load(entity, attr.Column, value); } } else if (attr.Field.getType().equals(String.class)) { String value = rs.getString(tabprefix + "." + attr.Column); if (!rs.wasNull()) { PropertyUtils.setSimpleProperty(entity, attr.Field.getName(), value); } } else if (attr.Field.getType().equals(Date.class)) { long value = rs.getLong(tabprefix + "." + attr.Column); if (!rs.wasNull()) { Date dt = new Date(value); PropertyUtils.setSimpleProperty(entity, attr.Field.getName(), dt); } } else if (attr.Field.getType().isEnum()) { String value = rs.getString(tabprefix + "." + attr.Column); if (!rs.wasNull()) { Class ecls = attr.Field.getType(); Object evalue = Enum.valueOf(ecls, value); PropertyUtils.setSimpleProperty(entity, attr.Field.getName(), evalue); } } else if (attr.Reference != null) { Class<?> rt = Class.forName(attr.Reference.Class); Object obj = rt.newInstance(); if (!(obj instanceof AbstractEntity)) throw new Exception("Unsupported Entity type [" + rt.getCanonicalName() + "]"); AbstractEntity rentity = (AbstractEntity) obj; if (path.size() > 0) { path.peek().setKey(attr.Column); } KeyValuePair<Class<?>> cls = new KeyValuePair<Class<?>>(); cls.setValue(rentity.getClass()); path.push(cls); setEntity(rentity, rs, gr, path); PropertyUtils.setSimpleProperty(entity, attr.Field.getName(), rentity); path.pop(); } }
From source file:com.projity.pm.graphic.model.transform.NodeCacheTransformer.java
public void transfrom(List list) { model.clear();// w ww. jav a 2 s . com if (list == null) return; boolean preserveHierarchy = transformer.isPreserveHierarchy(); if (!transformer.isShowSummary()) { preserveHierarchy = false; removeSummaries(list); } Map<GraphicNode, List<GraphicNode>> assignmentsMap = null; if (!transformer.isShowAssignments()) removeAssignments(list); if (!transformer.isShowEmptyLines()) removeVoids(list); if (transformer.isShowEmptyLines() && !transformer.isShowEndEmptyLines()) removeEndVoids(list); NodeTransformer composition = transformer.getTransformer(); NodeFilter hiddenFilter = transformer.getHiddenFilter(); if (hiddenFilter instanceof BaseFilter && !((BaseFilter) hiddenFilter).isActive()) hiddenFilter = null; //to avoid useless filtering in case of BaseFilter NodeFilter userFilter = (transformer.isNoneFilter()) ? null : transformer.getUserFilter(); boolean filtering = hiddenFilter != null || userFilter != null; NodeSorter sorter1 = transformer.getHiddenSorter(); NodeSorter sorter2 = transformer.getUserSorter(); boolean sorting = !(sorter1 == null && transformer.isNoneSorter()); NodeGrouper grouper = transformer.getUserGrouper(); boolean grouping = !transformer.isNoneGrouper(); if (!filtering && !sorting && !grouping) return; if (transformer.isShowAssignments() && preserveHierarchy && !transformer.isTreatAssignmentsAsTasks()) assignmentsMap = extractAssignments(list); List localList = null; Stack parents = null; boolean alreadyExcluded; if (preserveHierarchy) { localList = new ArrayList(); parents = new Stack(); } else localList = list; GraphicNode gnode, previous = null; Object current; for (Iterator i = list.iterator(); i.hasNext();) { gnode = (GraphicNode) i.next(); gnode.setFiltered(false); if (!gnode.isVoid()) { current = (composition == null) ? gnode.getNode() : composition.evaluate(gnode.getNode()); alreadyExcluded = false; if (hiddenFilter != null) { if (!hiddenFilter.evaluate(current)) { if (!gnode.isSummary() || !preserveHierarchy) { i.remove(); continue; } if (gnode.isSummary() && preserveHierarchy) gnode.setFiltered(true); alreadyExcluded = true; } } if (userFilter != null && !alreadyExcluded) { if (!userFilter.evaluate(current)) { if (!gnode.isSummary() || !preserveHierarchy) { i.remove(); continue; } if (gnode.isSummary() && preserveHierarchy) gnode.setFiltered(true); } } } if (preserveHierarchy) { //contruct a temporary tree for sorting and grouping // if (parents==null||previous==null){ // System.out.println("null"); // } if (gnode.getLevel() == 1) { localList.add(gnode); parents.clear(); } else { if (previous.getLevel() < gnode.getLevel()) { parents.push(previous); } else if (previous.getLevel() >= gnode.getLevel()) { while (parents.size() >= gnode.getLevel()) parents.pop(); } ((GraphicNode) parents.peek()).getChildren().add(gnode); } previous = gnode; } } //remove parents without children if (preserveHierarchy) { list.clear(); if (transformer.isShowEmptySummaries()) { if ("TaskUsage".equals(viewName)) filterBadBranches(localList); } else filterEmptySummaries(localList, false); } if (sorting) { if (sorter1 != null) sorter1.sortList(localList, new GraphicNodeComparator(sorter1, composition), preserveHierarchy); if (!transformer.isNoneSorter()) sorter2.sortList(localList, new GraphicNodeComparator(sorter2, composition), preserveHierarchy); } if (grouping) { List groups = grouper.getGroups(); levelOffset = groups.size(); List groupedList = new LinkedList(); groupList(localList, groupedList, groups.listIterator(), null, composition, preserveHierarchy); localList.clear(); localList.addAll(groupedList); } if (preserveHierarchy) { //converts tmp tree to list treeToList(localList, list); } if (assignmentsMap != null) recoverAssignments(list, assignmentsMap); // if (transformer.isShowEmptyLines()) // placeVoidNodes(list); }
From source file:org.vedantatree.expressionoasis.Compiler.java
/** * It restructures the given list of Expression Tokens in 'Reverse Polish * Notation'./*from w w w .j a va 2 s . com*/ * * @param expressionTokensList list of Expression Tokens * @return the stack of restructured Expression Tokens in 'RPN' * @throws ExpressionEngineException if Expression Tokens are invalid */ private Stack<ExpressionToken> restructureTokensInRPN(List<ExpressionToken> expressionTokensList) throws ExpressionEngineException { // stack to collect operators Stack<ExpressionToken> operatorStack = new Stack<ExpressionToken>(); // stack to collect restructured expression tokens Stack<ExpressionToken> rpnStack = new Stack<ExpressionToken>(); /* * Pseudo code * Iterate over tokens * If current token is a operator * check the tokens on operator stack till it get emptied * if top token is an operator and its precedence is >= current token precedence * remove from opstack and add to rpnstack * add current token to operator stack * If current token is bracket * If current token is left bracket * add it to operator stack * If current token is right bracket * pop the tokens from operator stack till we get the left bracket * and add these to rpn stack * if we found left bracket * create bracket pair and add to rpn stack * Otherwise * push the token to rpn stack * If operator stack is not empty * empty it from top and push all tokens to rpn stack * * RPN is ready!! */ ExpressionToken lastToken = null; for (Iterator<ExpressionToken> iter = expressionTokensList.iterator(); iter.hasNext();) { ExpressionToken currentToken = (ExpressionToken) iter.next(); // Put the operator/function on operator stack, // and shift higher precedence operator to RPN stack from top if (grammar.isOperator(currentToken)) { // fix for bug#1 @ googlecode // handle unary operators, if unary operators are in the beginning of expression if (operatorStack.isEmpty() && rpnStack.isEmpty()) { operatorStack.push(new UnaryToken(currentToken)); } // or if unary operator are after left bracket else if (grammar.isOperator(lastToken) || grammar.isLeftBracket(lastToken)) { operatorStack.push(new UnaryToken(currentToken)); } else { LOGGER.debug("currentTokenPP[" + currentToken + "]"); int currentTokenPrecedence = grammar.getPrecedenceOrder(currentToken, isUnary(currentToken)); // Remove high precedence operator from opStack and add to RPN stack while (!operatorStack.isEmpty()) { ExpressionToken peekToken = (ExpressionToken) operatorStack.peek(); // if the topmost token on stack is an operator // and its precedence is greater than precedence of current token // pop it from operator stack and add to RPN stack if (grammar.isOperator(peekToken) && currentTokenPrecedence <= grammar .getPrecedenceOrder(peekToken, isUnary(peekToken))) { operatorStack.pop(); rpnStack.push(peekToken); } else { break; } } operatorStack.push(currentToken); } } // Work for brackets else if (grammar.isBracket(currentToken)) { if (grammar.isLeftBracket(currentToken)) { // Push the bracket onto the opStack operatorStack.push(currentToken); } // Else pop the elements from opStack until left // bracket ffror this right bracket is found. // throw an error if no left bracket is found else { boolean leftBracketFound = false; while (!operatorStack.isEmpty()) { ExpressionToken peekOperator = (ExpressionToken) operatorStack.peek(); leftBracketFound = grammar.isLeftBracket(peekOperator); operatorStack.pop(); // TODO: collect more cases of unary and simple token and add more examples if (leftBracketFound) { // Putting the bracket pair on rpnStack // to handle the array [] - binary, and function () - unary cases String value = peekOperator.getValue() + grammar.getOppositeBracket(peekOperator.getValue()); ExpressionToken bracketToken = grammar.isUnary(value) ? new UnaryToken(value, peekOperator.getIndex()) : new ExpressionToken(value, peekOperator.getIndex()); rpnStack.push(bracketToken); break; } rpnStack.push(peekOperator); } if (!leftBracketFound) { throw new ExpressionEngineException("Left bracket is missing for \"" + currentToken.getValue() + "\" at " + currentToken.getIndex()); } } } // Work for operands else { rpnStack.push(currentToken); } lastToken = currentToken; } // push rest of the tokens to RPN stack while (!operatorStack.isEmpty()) { ExpressionToken element = (ExpressionToken) operatorStack.peek(); // No enclosing bracket if any left bracket is found // Throw the error in this case. if (grammar.isLeftBracket(element.getValue())) { throw new ExpressionEngineException( "Right bracket is missing for \"" + element.getValue() + "\" at " + element.getIndex()); } operatorStack.pop(); rpnStack.push(element); } return rpnStack; }
From source file:org.ganges.expressionengine.Compiler.java
/** * It restructures the given list of Expression Tokens in 'Reverse Polish * Notation'.//from w ww .j a v a 2 s .c o m * * @param expressionTokensList list of Expression Tokens * @return the stack of restructured Expression Tokens in 'RPN' * @throws ExpressionEngineException if Expression Tokens are invalid */ protected Stack<ExpressionToken> restructureTokensInRPN(List<ExpressionToken> expressionTokensList) throws ExpressionEngineException { // stack to collect operators Stack<ExpressionToken> operatorStack = new Stack<ExpressionToken>(); // stack to collect restructured expression tokens Stack<ExpressionToken> rpnStack = new Stack<ExpressionToken>(); /*Pseudo code * Iterate over tokens * If current token is a operator * check the tokens on operator stack till it get emptied * if top token is an operator and its precedence is >= current token precedence * remove from opstack and add to rpnstack * add current token to operator stack * If current token is bracket * If current token is left bracket * add it to operator stack * If current token is right bracket * pop the tokens from operator stack till we get the left bracket * and add these to rpn stack * if we found left bracket * create bracket pair and add to rpn stack * Otherwise * push the token to rpn stack * If operator stack is not empty * empty it from top and push all tokens to rpn stack * * RPN is ready!! */ ExpressionToken lastToken = null; for (Iterator<ExpressionToken> iter = expressionTokensList.iterator(); iter.hasNext();) { ExpressionToken currentToken = (ExpressionToken) iter.next(); // Put the operator/function on operator stack, // and shift higher precedence operator to RPN stack from top if (grammar.isOperator(currentToken)) { // fix for bug#1 @ googlecode // handle unary operators, if unary operators are in the beginning of expression if (operatorStack.isEmpty() && rpnStack.isEmpty()) { operatorStack.push(new UnaryToken(currentToken)); } // or if unary operator are after left bracket else if (grammar.isOperator(lastToken) || grammar.isLeftBracket(lastToken)) { operatorStack.push(new UnaryToken(currentToken)); } else { LOGGER.debug("currentTokenPP[" + currentToken + "]"); int currentTokenPrecedence = grammar.getPrecedenceOrder(currentToken, isUnary(currentToken)); // Remove high precedence operator from opStack and add to RPN stack while (!operatorStack.isEmpty()) { ExpressionToken peekToken = (ExpressionToken) operatorStack.peek(); // if the topmost token on stack is an operator // and its precedence is greater than precedence of current token // pop it from operator stack and add to RPN stack if (grammar.isOperator(peekToken) && currentTokenPrecedence <= grammar .getPrecedenceOrder(peekToken, isUnary(peekToken))) { operatorStack.pop(); rpnStack.push(peekToken); } else { break; } } operatorStack.push(currentToken); } } // Work for brackets else if (grammar.isBracket(currentToken)) { if (grammar.isLeftBracket(currentToken)) { // Push the bracket onto the opStack operatorStack.push(currentToken); } // Else pop the elements from opStack until left // bracket ffror this right bracket is found. // throw an error if no left bracket is found else { boolean leftBracketFound = false; while (!operatorStack.isEmpty()) { ExpressionToken peekOperator = (ExpressionToken) operatorStack.peek(); leftBracketFound = grammar.isLeftBracket(peekOperator); operatorStack.pop(); // TODO: collect more cases of unary and simple token and add more examples if (leftBracketFound) { // Putting the bracket pair on rpnStack // to handle the array [] - binary, and function () - unary cases String value = peekOperator.getValue() + grammar.getOppositeBracket(peekOperator.getValue()); ExpressionToken bracketToken = grammar.isUnary(value) ? new UnaryToken(value, peekOperator.getIndex()) : new ExpressionToken(value, peekOperator.getIndex()); rpnStack.push(bracketToken); break; } rpnStack.push(peekOperator); } if (!leftBracketFound) { throw new ExpressionEngineException("Left bracket is missing for \"" + currentToken.getValue() + "\" at " + currentToken.getIndex()); } } } // Work for operands else { rpnStack.push(currentToken); } lastToken = currentToken; } // push rest of the tokens to RPN stack while (!operatorStack.isEmpty()) { ExpressionToken element = (ExpressionToken) operatorStack.peek(); // No enclosing bracket if any left bracket is found // Throw the error in this case. if (grammar.isLeftBracket(element.getValue())) { throw new ExpressionEngineException( "Right bracket is missing for \"" + element.getValue() + "\" at " + element.getIndex()); } operatorStack.pop(); rpnStack.push(element); } return rpnStack; }
From source file:com.bluexml.xforms.generator.forms.renderable.common.association.selection.RenderableSEdit.java
@Override public Rendered render(String path, Stack<Renderable> parents, Stack<Rendered> renderedParents, boolean isInIMultRepeater) { RenderedInput rendered = new RenderedInput(); ModelElementSubmission submission = new ModelElementSubmission("", "", true, false); submission.setAlwaysActive(false); // #1222 if (bean.getCreateEditFormType().equals(FormTypeRendered.formForm)) { String listForms = StringUtils.join(bean.getCreateEditForms(), ','); // #1510 if (listForms == null) { // listForms = bean.getCreateEditDefaultFormName() + "/" // + MsgId.INT_ACT_SUFFIX_GET_FORM_CLASS; // #1637 listForms = MsgId.INT_ACT_PARAM_ANY_DATATYPE + "=" + bean.getCreateEditDefaultFormName() + "&" + MsgId.INT_ACT_PARAM_ANY_HINT + "=" + MsgId.INT_ACT_SUFFIX_GET_FORM_CLASS; }//from ww w . j a v a 2s. c o m // String action = MsgId.INT_URI_SCHEME_WRITER.getText() + MsgId.INT_ACT_CODE_EDIT_FORM // + "/" + bean.getName() + "/" + listForms; // #1637 String action = MsgId.INT_URI_SCHEME_WRITER.getText() + MsgId.INT_ACT_CODE_EDIT_FORM + "?" + MsgId.INT_ACT_PARAM_ANY_ASSOC + "=" + bean.getName() + "&" + listForms; submission.setAction(action); } else { // String action = MsgId.INT_URI_SCHEME_WRITER.getText() + MsgId.INT_ACT_CODE_EDIT_CLASS // + "/" + bean.getName() + "/" // + ModelTools.getCompleteName(bean.getDestinationClass()); // #1637 String action = MsgId.INT_URI_SCHEME_WRITER.getText() + MsgId.INT_ACT_CODE_EDIT_CLASS + "?" + MsgId.INT_ACT_PARAM_ANY_ASSOC + "=" + bean.getName() + "&" + MsgId.INT_ACT_PARAM_ANY_DATATYPE + "=" + ModelTools.getCompleteName(bean.getDestinationClass()); submission.setAction(action); } if (getFormGenerator().isInReadOnlyMode() == false) { // #1238 Element trigger = XFormsGenerator.createElementWithLabel("trigger", XFormsGenerator.NAMESPACE_XFORMS, MsgPool.getMsg(MsgId.CAPTION_BUTTON_EDIT)); Element action = XFormsGenerator.createElement("action", XFormsGenerator.NAMESPACE_XFORMS); action.setAttribute("event", "DOMActivate", XFormsGenerator.NAMESPACE_EVENTS); // setvalue.setAttribute("ref", "instance('minstance')/editedid"); // String rootPath = getRootPath(renderedParents); // String instancePathToSIDEID; // if (StringUtils.trimToNull(rootPath) != null) { // we are in a nxn widget // instancePathToSIDEID = "instance('minstance')/" + rootPath ; // } else { // we are in a nx1 widget // instancePathToSIDEID = "instance('minstance')/" + path; // } // setvalue.setAttribute("value", instancePathToSIDEID + MsgId.INT_INSTANCE_SIDEID); Renderable parent = parents.peek(); ModelElementBindSimple bindEdit; if (parent instanceof RenderableSMultipleDisplay) { RenderableSMultiple grandpa = (RenderableSMultiple) parents.get(parents.size() - 2); ModelElementBindHolder bindRepeater = grandpa.getBindRepeater(); bindEdit = bindRepeater.getSubBind(2); } else { // we're in a Nx1 widget bindEdit = ((RenderableSSingle) parent).getSelectedBindEdit(); } Element setvalueEdit = XFormsGenerator.createElement("setvalue", XFormsGenerator.NAMESPACE_XFORMS); bindEdit.addLinkedElement(setvalueEdit); setvalueEdit.setAttribute("value", "../" + MsgId.INT_INSTANCE_SIDEID); action.addContent(setvalueEdit); Element send = XFormsGenerator.createElement("send", XFormsGenerator.NAMESPACE_XFORMS); submission.addLinkedElement(send); action.addContent(send); trigger.addContent(action); rendered.setXformsElement(trigger); } rendered.addModelElement(submission); return rendered; }
From source file:org.apache.tajo.plan.LogicalPlanner.java
public LogicalNode postHook(PlanContext context, Stack<Expr> stack, Expr expr, LogicalNode current) throws TajoException { // Some generated logical nodes (e.g., implicit aggregation) without exprs will pass NULL as a expr parameter. // We should skip them. if (expr != null) { // A relation list including a single ScanNode will return a ScanNode instance that already passed postHook. // So, it skips the already-visited ScanNode instance. if (expr.getType() == OpType.RelationList && current.getType() == NodeType.SCAN) { return current; }//from w ww .j av a 2 s.c o m } QueryBlock queryBlock = context.queryBlock; queryBlock.updateLatestNode(current); // if this node is the topmost if (stack.size() == 0) { queryBlock.setRoot(current); } if (!stack.empty()) { queryBlock.updateCurrentNode(stack.peek()); } return current; }
From source file:org.apache.tajo.plan.rewrite.rules.FilterPushDownRule.java
@Override public LogicalNode visitJoin(FilterPushDownContext context, LogicalPlan plan, LogicalPlan.QueryBlock block, JoinNode joinNode, Stack<LogicalNode> stack) throws TajoException { Set<EvalNode> onPredicates = new HashSet<>(); if (joinNode.hasJoinQual()) { onPredicates.addAll(new HashSet<>( Arrays.asList(AlgebraicUtil.toConjunctiveNormalFormArray(joinNode.getJoinQual())))); }/*from w w w. j ava 2 s. c o m*/ // clear join qual joinNode.clearJoinQual(); // we assume all the quals in pushingDownFilters as where predicates Set<EvalNode> nonPushableQuals = extractNonPushableJoinQuals(plan, block, joinNode, onPredicates, context.pushingDownFilters); // add every predicate and remove non-pushable ones context.pushingDownFilters.addAll(onPredicates); context.pushingDownFilters.removeAll(nonPushableQuals); LogicalNode left = joinNode.getLeftChild(); LogicalNode right = joinNode.getRightChild(); List<EvalNode> notMatched = new ArrayList<>(); // Join's input schema = right child output columns + left child output columns Map<EvalNode, EvalNode> transformedMap = findCanPushdownAndTransform(context, block, joinNode, left, notMatched, null, 0); context.setFiltersTobePushed(transformedMap.keySet()); visit(context, plan, block, left, stack); context.setToOrigin(transformedMap); context.addFiltersTobePushed(notMatched); notMatched.clear(); transformedMap = findCanPushdownAndTransform(context, block, joinNode, right, notMatched, null, left.getOutSchema().size()); context.setFiltersTobePushed(transformedMap.keySet()); visit(context, plan, block, right, stack); context.setToOrigin(transformedMap); context.addFiltersTobePushed(notMatched); notMatched.clear(); context.pushingDownFilters.addAll(nonPushableQuals); List<EvalNode> matched = new ArrayList<>(); // If the query involves a subquery, the stack can be empty. // In this case, this join is the top most one within a query block. boolean isTopMostJoin = stack.isEmpty() ? true : stack.peek().getType() != NodeType.JOIN; for (EvalNode evalNode : context.pushingDownFilters) { // TODO: currently, non-equi theta join is not supported yet. if (LogicalPlanner.isEvaluatableJoinQual(block, evalNode, joinNode, onPredicates.contains(evalNode), isTopMostJoin)) { matched.add(evalNode); } } EvalNode qual = null; if (matched.size() > 1) { // merged into one eval tree qual = AlgebraicUtil.createSingletonExprFromCNF(matched.toArray(new EvalNode[matched.size()])); } else if (matched.size() == 1) { // if the number of matched expr is one qual = matched.get(0); } if (qual != null) { joinNode.setJoinQual(qual); if (joinNode.getJoinType() == JoinType.CROSS) { joinNode.setJoinType(JoinType.INNER); } } context.pushingDownFilters.removeAll(matched); // The selection node for non-equi theta join conditions should be created here // to process those conditions as early as possible. // This should be removed after TAJO-742. if (context.pushingDownFilters.size() > 0) { List<EvalNode> nonEquiThetaJoinQuals = extractNonEquiThetaJoinQuals(context.pushingDownFilters, block, joinNode); if (nonEquiThetaJoinQuals.size() > 0) { SelectionNode selectionNode = createSelectionParentForNonEquiThetaJoinQuals(plan, block, stack, joinNode, nonEquiThetaJoinQuals); context.pushingDownFilters.removeAll(nonEquiThetaJoinQuals); return selectionNode; } } return joinNode; }