/** * Validate insert/merge entitlements */ protected void validateEntitlements(Insert obj) { List<LanguageObject> insert = new LinkedList<LanguageObject>(); insert.add(obj.getGroup()); insert.addAll(obj.getVariables()); validateEntitlements( insert, DataPolicy.PermissionType.CREATE, Context.INSERT); if (obj.isUpsert()) { validateEntitlements( insert, DataPolicy.PermissionType.UPDATE, Context.MERGE); } }
/** * Validate insert/merge entitlements */ protected void validateEntitlements(Insert obj) { List<LanguageObject> insert = new LinkedList<LanguageObject>(); insert.add(obj.getGroup()); insert.addAll(obj.getVariables()); validateEntitlements( insert, DataPolicy.PermissionType.CREATE, Context.INSERT); if (obj.isUpsert()) { validateEntitlements( insert, DataPolicy.PermissionType.UPDATE, Context.MERGE); } }
/** * Validate insert/merge entitlements */ protected void validateEntitlements(Insert obj) { List<LanguageObject> insert = new LinkedList<LanguageObject>(); insert.add(obj.getGroup()); insert.addAll(obj.getVariables()); validateEntitlements( insert, DataPolicy.PermissionType.CREATE, Context.INSERT); if (obj.isUpsert()) { validateEntitlements( insert, DataPolicy.PermissionType.UPDATE, Context.MERGE); } }
private boolean isUpsertKeyColumn(Insert obj, ElementSymbol insertElem) throws TeiidComponentException, QueryMetadataException { if (!obj.isUpsert()) { return false; } Collection keys = getMetadata().getUniqueKeysInGroup(obj.getGroup().getMetadataID()); //not an actual update, but a modification of existing row return !keys.isEmpty() && getMetadata().getElementIDsInKey(keys.iterator().next()).contains(insertElem.getMetadataID()); }
private boolean isUpsertKeyColumn(Insert obj, ElementSymbol insertElem) throws TeiidComponentException, QueryMetadataException { if (!obj.isUpsert()) { return false; } Collection keys = getMetadata().getUniqueKeysInGroup(obj.getGroup().getMetadataID()); //not an actual update, but a modification of existing row return !keys.isEmpty() && getMetadata().getElementIDsInKey(keys.iterator().next()).contains(insertElem.getMetadataID()); }
private boolean isUpsertKeyColumn(Insert obj, ElementSymbol insertElem) throws TeiidComponentException, QueryMetadataException { if (!obj.isUpsert()) { return false; } Collection keys = getMetadata().getUniqueKeysInGroup(obj.getGroup().getMetadataID()); //not an actual update, but a modification of existing row return !keys.isEmpty() && getMetadata().getElementIDsInKey(keys.iterator().next()).contains(insertElem.getMetadataID()); }
/** * <p> This method updates the <code>Insert</code> object it receives as an * argument by replacing the virtual groups/elements with their physical * counterparts.</p> * @param obj The Insert object to be updated with physical groups/elements */ public void visit(Insert obj) { List physicalElements = new ArrayList(); // get the GroupSymbol on the insert GroupSymbol virtualGroup = obj.getGroup(); obj.setGroup(getMappedGroup(virtualGroup)); // get all virtual columns present on the Insert and replace them with // physical elements if(obj.getVariables() != null) { Iterator elementIter = obj.getVariables().iterator(); while(elementIter.hasNext()) { ElementSymbol virtualElement = (ElementSymbol) elementIter.next(); physicalElements.add(getMappedElement(virtualElement)); } obj.setVariables(physicalElements); } }
/** * <p> This method updates the <code>Insert</code> object it receives as an * argument by replacing the virtual groups/elements with their physical * counterparts.</p> * @param obj The Insert object to be updated with physical groups/elements */ public void visit(Insert obj) { List physicalElements = new ArrayList(); // get the GroupSymbol on the insert GroupSymbol virtualGroup = obj.getGroup(); obj.setGroup(getMappedGroup(virtualGroup)); // get all virtual columns present on the Insert and replace them with // physical elements if(obj.getVariables() != null) { Iterator elementIter = obj.getVariables().iterator(); while(elementIter.hasNext()) { ElementSymbol virtualElement = (ElementSymbol) elementIter.next(); physicalElements.add(getMappedElement(virtualElement)); } obj.setVariables(physicalElements); } }
/** * <p> This method updates the <code>Insert</code> object it receives as an * argument by replacing the virtual groups/elements with their physical * counterparts.</p> * @param obj The Insert object to be updated with physical groups/elements */ public void visit(Insert obj) { List physicalElements = new ArrayList(); // get the GroupSymbol on the insert GroupSymbol virtualGroup = obj.getGroup(); obj.setGroup(getMappedGroup(virtualGroup)); // get all virtual columns present on the Insert and replace them with // physical elements if(obj.getVariables() != null) { Iterator elementIter = obj.getVariables().iterator(); while(elementIter.hasNext()) { ElementSymbol virtualElement = (ElementSymbol) elementIter.next(); physicalElements.add(getMappedElement(virtualElement)); } obj.setVariables(physicalElements); } }
private void resolveVariables(TempMetadataAdapter metadata, Insert insert, Set<GroupSymbol> groups) throws TeiidComponentException, QueryResolverException { try { resolveList(insert.getVariables(), metadata, null, groups); } catch (QueryResolverException e) { throw new QueryResolverException(QueryPlugin.Event.TEIID30126, e, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30126, insert.getGroup(), e.getUnresolvedSymbols())); } }
private void resolveVariables(TempMetadataAdapter metadata, Insert insert, Set<GroupSymbol> groups) throws TeiidComponentException, QueryResolverException { try { resolveList(insert.getVariables(), metadata, null, groups); } catch (QueryResolverException e) { throw new QueryResolverException(QueryPlugin.Event.TEIID30126, e, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30126, insert.getGroup(), e.getUnresolvedSymbols())); } }
private void resolveVariables(TempMetadataAdapter metadata, Insert insert, Set<GroupSymbol> groups) throws TeiidComponentException, QueryResolverException { try { resolveList(insert.getVariables(), metadata, null, groups); } catch (QueryResolverException e) { throw new QueryResolverException(QueryPlugin.Event.TEIID30126, e, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30126, insert.getGroup(), e.getUnresolvedSymbols())); } }
/** * Get the group being updated by the update command * @param command an INSERT, UPDATE, DELETE or SELECT INTO command * @return the group being updated * @since 4.2 */ public static GroupSymbol getUpdatedGroup(Command command) { int type = command.getType(); if (type == Command.TYPE_INSERT) { return ((Insert)command).getGroup(); } else if (type == Command.TYPE_UPDATE) { return ((Update)command).getGroup(); } else if (type == Command.TYPE_DELETE) { return ((Delete)command).getGroup(); } throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30244, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30244, command)); }
/** * Get the group being updated by the update command * @param command an INSERT, UPDATE, DELETE or SELECT INTO command * @return the group being updated * @since 4.2 */ public static GroupSymbol getUpdatedGroup(Command command) { int type = command.getType(); if (type == Command.TYPE_INSERT) { return ((Insert)command).getGroup(); } else if (type == Command.TYPE_UPDATE) { return ((Update)command).getGroup(); } else if (type == Command.TYPE_DELETE) { return ((Delete)command).getGroup(); } throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30244, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30244, command)); }
/** * Get the group being updated by the update command * @param command an INSERT, UPDATE, DELETE or SELECT INTO command * @return the group being updated * @since 4.2 */ public static GroupSymbol getUpdatedGroup(Command command) { int type = command.getType(); if (type == Command.TYPE_INSERT) { return ((Insert)command).getGroup(); } else if (type == Command.TYPE_UPDATE) { return ((Update)command).getGroup(); } else if (type == Command.TYPE_DELETE) { return ((Delete)command).getGroup(); } throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30244, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30244, command)); }
/** * Compare two Insert commands for equality. Will only evaluate to equal if * they are IDENTICAL: group is equal, value is equal and variables are equal. * @param obj Other object * @return True if equal */ public boolean equals(Object obj) { // Quick same object test if(this == obj) { return true; } // Quick fail tests if(!(obj instanceof Insert)) { return false; } Insert other = (Insert) obj; return EquivalenceUtil.areEqual(getGroup(), other.getGroup()) && EquivalenceUtil.areEqual(getValues(), other.getValues()) && EquivalenceUtil.areEqual(getVariables(), other.getVariables()) && sameOptionAndHint(other) && EquivalenceUtil.areEqual(getQueryExpression(), other.getQueryExpression()) && this.upsert == other.upsert; }
/** * Compare two Insert commands for equality. Will only evaluate to equal if * they are IDENTICAL: group is equal, value is equal and variables are equal. * @param obj Other object * @return True if equal */ public boolean equals(Object obj) { // Quick same object test if(this == obj) { return true; } // Quick fail tests if(!(obj instanceof Insert)) { return false; } Insert other = (Insert) obj; return EquivalenceUtil.areEqual(getGroup(), other.getGroup()) && EquivalenceUtil.areEqual(getValues(), other.getValues()) && EquivalenceUtil.areEqual(getVariables(), other.getVariables()) && sameOptionAndHint(other) && EquivalenceUtil.areEqual(getQueryExpression(), other.getQueryExpression()) && this.upsert == other.upsert; }
public void visit(Insert obj) { preVisitVisitor(obj); visitNode(obj.getGroup()); visitNodes(obj.getVariables()); visitNodes(obj.getValues()); if(deep && obj.getQueryExpression()!=null) { visitNode(obj.getQueryExpression()); } visitNode(obj.getOption()); postVisitVisitor(obj); } public void visit(Create obj) {
public void visit(Insert obj) { preVisitVisitor(obj); visitNode(obj.getGroup()); visitNodes(obj.getVariables()); visitNodes(obj.getValues()); if(deep && obj.getQueryExpression()!=null) { visitNode(obj.getQueryExpression()); } visitNode(obj.getOption()); postVisitVisitor(obj); } public void visit(Create obj) {
public void visit(Insert obj) { preVisitVisitor(obj); visitNode(obj.getGroup()); visitNodes(obj.getVariables()); visitNodes(obj.getValues()); if(deep && obj.getQueryExpression()!=null) { visitNode(obj.getQueryExpression()); } visitNode(obj.getOption()); postVisitVisitor(obj); } public void visit(Create obj) {