SetQuery setQuery = (SetQuery)command; if (setQuery.getLimit() != null) { handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0013"), true, true, true); //$NON-NLS-1$ return; handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0001"), true, true, true); //$NON-NLS-1$ return; this.updateInfo.partitionInfo = partitions; if (partitions.isEmpty()) { handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0018"), false, true, false); //$NON-NLS-1$ this.updateInfo.updateType = ui.updateType; internalValidate(query, viewSymbols); internalValidate(command, viewSymbols); if (this.updateInfo.deleteType != UpdateType.INHERENT) { this.deleteReport.getItems().clear();
private void setUpdateFlags(GroupSymbol groupSymbol) throws QueryMetadataException, TeiidComponentException { UpdateMapping info = updateInfo.updatableGroups.get(groupSymbol.getName()); if (info == null) { return; // not projected } if (!metadata.groupSupports(groupSymbol.getMetadataID(), SupportConstants.Group.UPDATE)) { report.handleValidationWarning(QueryPlugin.Util.getString("ERR.015.012.0003", groupSymbol)); //$NON-NLS-1$ return; } info.insertAllowed = true; for (ElementSymbol es : ResolverUtil.resolveElementsInGroup(info.group, metadata)) { if (!info.updatableViewSymbols.values().contains(es) && !validateInsertElement(es)) { info.insertAllowed = false; } } info.updateAllowed = true; }
UpdateValidator validator = new UpdateValidator(qmi, determineType(insertPlan), determineType(updatePlan), determineType(deletePlan)); validator.validate(result, elements); UpdateInfo info = validator.getUpdateInfo(); if (logValidation && qmi.groupSupports(virtualGroup.getMetadataID(), SupportConstants.Group.UPDATE)) { if (info.isInherentInsert() && validator.getInsertReport().hasItems()) { LogManager.logDetail(LogConstants.CTX_QUERY_RESOLVER, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31173, validator.getInsertReport().getFailureMessage(), SQLConstants.Reserved.INSERT, qmi.getFullName(virtualGroup.getMetadataID()))); if (info.isInherentUpdate() && validator.getUpdateReport().hasItems()) { LogManager.logDetail(LogConstants.CTX_QUERY_RESOLVER, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31173, validator.getUpdateReport().getFailureMessage(), SQLConstants.Reserved.UPDATE, qmi.getFullName(virtualGroup.getMetadataID()))); if (info.isInherentDelete() && validator.getDeleteReport().hasItems()) { LogManager.logDetail(LogConstants.CTX_QUERY_RESOLVER, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31173, validator.getDeleteReport().getFailureMessage(), SQLConstants.Reserved.DELETE, qmi.getFullName(virtualGroup.getMetadataID())));
private UpdateValidator helpTest(String sql, TransformationMetadata md, boolean failInsert, boolean failUpdate, boolean failDelete) { try { String vGroup = "gx"; Command command = createView(sql, md, vGroup); UpdateValidator uv = new UpdateValidator(md, UpdateType.INHERENT, UpdateType.INHERENT, UpdateType.INHERENT); GroupSymbol gs = new GroupSymbol(vGroup); ResolverUtil.resolveGroup(gs, md); uv.validate(command, ResolverUtil.resolveElementsInGroup(gs, md)); UpdateInfo info = uv.getUpdateInfo(); assertEquals(uv.getReport().getFailureMessage(), failInsert, info.getInsertValidationError() != null); assertEquals(uv.getReport().getFailureMessage(), failUpdate, info.getUpdateValidationError() != null); assertEquals(uv.getReport().getFailureMessage(), failDelete, info.getDeleteValidationError() != null); return uv; } catch (TeiidException e) { throw new RuntimeException(e); } }
private void internalValidate(Command command, List<ElementSymbol> viewSymbols) throws QueryMetadataException, TeiidComponentException { if (!(command instanceof Query)) { handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0001"), true, true, true); //$NON-NLS-1$ return; handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0001"), true, true, true); //$NON-NLS-1$ return; handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0006"), true, true, true); //$NON-NLS-1$ return; handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0013"), true, true, true); //$NON-NLS-1$ return; handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0008"), true, true, true); //$NON-NLS-1$ return; setUpdateFlags(groupSymbol); if (updateInfo.isSimple) { if (!allGroups.isEmpty()) { setUpdateFlags(allGroups.iterator().next()); handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0015"), false, true, false); //$NON-NLS-1$ handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0005"), true, false, false); //$NON-NLS-1$ this.updateInfo.deleteTarget = this.updateInfo.updatableGroups.values().iterator().next(); } else { handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0014"), false, false, true); //$NON-NLS-1$
UpdateValidator validator = new UpdateValidator(qmi, determineType(insertPlan), determineType(updatePlan), determineType(deletePlan)); validator.validate(result, elements); UpdateInfo info = validator.getUpdateInfo(); if (logValidation && qmi.groupSupports(virtualGroup.getMetadataID(), SupportConstants.Group.UPDATE)) { if (info.isInherentInsert() && validator.getInsertReport().hasItems()) { LogManager.logDetail(LogConstants.CTX_QUERY_RESOLVER, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31173, validator.getInsertReport().getFailureMessage(), SQLConstants.Reserved.INSERT, qmi.getFullName(virtualGroup.getMetadataID()))); if (info.isInherentUpdate() && validator.getUpdateReport().hasItems()) { LogManager.logDetail(LogConstants.CTX_QUERY_RESOLVER, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31173, validator.getUpdateReport().getFailureMessage(), SQLConstants.Reserved.UPDATE, qmi.getFullName(virtualGroup.getMetadataID()))); if (info.isInherentDelete() && validator.getDeleteReport().hasItems()) { LogManager.logDetail(LogConstants.CTX_QUERY_RESOLVER, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31173, validator.getDeleteReport().getFailureMessage(), SQLConstants.Reserved.DELETE, qmi.getFullName(virtualGroup.getMetadataID())));
private void internalValidate(Command command, List<ElementSymbol> viewSymbols) throws QueryMetadataException, TeiidComponentException { if (!(command instanceof Query)) { handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0001"), true, true, true); //$NON-NLS-1$ return; handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0001"), true, true, true); //$NON-NLS-1$ return; handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0006"), true, true, true); //$NON-NLS-1$ return; handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0013"), true, true, true); //$NON-NLS-1$ return; handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0008"), true, true, true); //$NON-NLS-1$ return; setUpdateFlags(groupSymbol); if (updateInfo.isSimple) { if (!allGroups.isEmpty()) { setUpdateFlags(allGroups.iterator().next()); handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0015"), false, true, false); //$NON-NLS-1$ handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0005"), true, false, false); //$NON-NLS-1$ this.updateInfo.deleteTarget = this.updateInfo.updatableGroups.values().iterator().next(); } else { handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0014"), false, false, true); //$NON-NLS-1$
UpdateValidator validator = new UpdateValidator(qmi, determineType(insertPlan), determineType(updatePlan), determineType(deletePlan)); validator.validate(result, elements); UpdateInfo info = validator.getUpdateInfo(); if (logValidation && qmi.groupSupports(virtualGroup.getMetadataID(), SupportConstants.Group.UPDATE)) { if (info.isInherentInsert() && validator.getInsertReport().hasItems()) { LogManager.logDetail(LogConstants.CTX_QUERY_RESOLVER, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31173, validator.getInsertReport().getFailureMessage(), SQLConstants.Reserved.INSERT, qmi.getFullName(virtualGroup.getMetadataID()))); if (info.isInherentUpdate() && validator.getUpdateReport().hasItems()) { LogManager.logDetail(LogConstants.CTX_QUERY_RESOLVER, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31173, validator.getUpdateReport().getFailureMessage(), SQLConstants.Reserved.UPDATE, qmi.getFullName(virtualGroup.getMetadataID()))); if (info.isInherentDelete() && validator.getDeleteReport().hasItems()) { LogManager.logDetail(LogConstants.CTX_QUERY_RESOLVER, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31173, validator.getDeleteReport().getFailureMessage(), SQLConstants.Reserved.DELETE, qmi.getFullName(virtualGroup.getMetadataID())));
SetQuery setQuery = (SetQuery)command; if (setQuery.getLimit() != null) { handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0013"), true, true, true); //$NON-NLS-1$ return; handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0001"), true, true, true); //$NON-NLS-1$ return; this.updateInfo.partitionInfo = partitions; if (partitions.isEmpty()) { handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0018"), false, true, false); //$NON-NLS-1$ this.updateInfo.updateType = ui.updateType; internalValidate(query, viewSymbols); internalValidate(command, viewSymbols); if (this.updateInfo.deleteType != UpdateType.INHERENT) { this.deleteReport.getItems().clear();
private void internalValidate(Command command, List<ElementSymbol> viewSymbols) throws QueryMetadataException, TeiidComponentException { if (!(command instanceof Query)) { handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0001"), true, true, true); //$NON-NLS-1$ return; handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0001"), true, true, true); //$NON-NLS-1$ return; handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0006"), true, true, true); //$NON-NLS-1$ return; handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0013"), true, true, true); //$NON-NLS-1$ return; handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0008"), true, true, true); //$NON-NLS-1$ return; setUpdateFlags(groupSymbol); if (updateInfo.isSimple) { if (!allGroups.isEmpty()) { setUpdateFlags(allGroups.iterator().next()); handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0015"), false, true, false); //$NON-NLS-1$ handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0005"), true, false, false); //$NON-NLS-1$ this.updateInfo.deleteTarget = this.updateInfo.updatableGroups.values().iterator().next(); } else { handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0014"), false, false, true); //$NON-NLS-1$
private void setUpdateFlags(GroupSymbol groupSymbol) throws QueryMetadataException, TeiidComponentException { UpdateMapping info = updateInfo.updatableGroups.get(groupSymbol.getName()); if (info == null) { return; // not projected } if (!metadata.groupSupports(groupSymbol.getMetadataID(), SupportConstants.Group.UPDATE)) { report.handleValidationWarning(QueryPlugin.Util.getString("ERR.015.012.0003", groupSymbol)); //$NON-NLS-1$ return; } info.insertAllowed = true; for (ElementSymbol es : ResolverUtil.resolveElementsInGroup(info.group, metadata)) { if (!info.updatableViewSymbols.values().contains(es) && !validateInsertElement(es)) { info.insertAllowed = false; } } info.updateAllowed = true; }
SetQuery setQuery = (SetQuery)command; if (setQuery.getLimit() != null) { handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0013"), true, true, true); //$NON-NLS-1$ return; handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0001"), true, true, true); //$NON-NLS-1$ return; this.updateInfo.partitionInfo = partitions; if (partitions.isEmpty()) { handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0018"), false, true, false); //$NON-NLS-1$ this.updateInfo.updateType = ui.updateType; internalValidate(query, viewSymbols); internalValidate(command, viewSymbols); if (this.updateInfo.deleteType != UpdateType.INHERENT) { this.deleteReport.getItems().clear();
private void setUpdateFlags(GroupSymbol groupSymbol) throws QueryMetadataException, TeiidComponentException { UpdateMapping info = updateInfo.updatableGroups.get(groupSymbol.getName()); if (info == null) { return; // not projected } if (!metadata.groupSupports(groupSymbol.getMetadataID(), SupportConstants.Group.UPDATE)) { report.handleValidationWarning(QueryPlugin.Util.getString("ERR.015.012.0003", groupSymbol)); //$NON-NLS-1$ return; } info.insertAllowed = true; for (ElementSymbol es : ResolverUtil.resolveElementsInGroup(info.group, metadata)) { if (!info.updatableViewSymbols.values().contains(es) && !validateInsertElement(es)) { info.insertAllowed = false; } } info.updateAllowed = true; }