diff --git a/plugins/org.teiid.designer.dqp.ui/src/org/teiid/designer/runtime/ui/actions/DeployVdbAction.java b/plugins/org.teiid.designer.dqp.ui/src/org/teiid/designer/runtime/ui/actions/DeployVdbAction.java index 6b9191de33..bfcac88540 100644 --- a/plugins/org.teiid.designer.dqp.ui/src/org/teiid/designer/runtime/ui/actions/DeployVdbAction.java +++ b/plugins/org.teiid.designer.dqp.ui/src/org/teiid/designer/runtime/ui/actions/DeployVdbAction.java @@ -41,6 +41,7 @@ import org.teiid.designer.runtime.ui.vdb.DeployVdbDialog; import org.teiid.designer.runtime.ui.vdb.VdbAgeChecker; import org.teiid.designer.runtime.ui.vdb.VdbDeployer; +import org.teiid.designer.runtime.ui.vdb.VdbErrorChecker; import org.teiid.designer.runtime.ui.vdb.VdbRequiresSaveChecker; import org.teiid.designer.ui.actions.ISelectionAction; import org.teiid.designer.ui.actions.SortableSelectionAction; @@ -145,6 +146,10 @@ public void run() { for (IFile nextVDB : this.selectedVDBs) { boolean doDeploy = VdbRequiresSaveChecker.insureOpenVdbSaved(nextVDB); + + if( doDeploy) { + doDeploy = !VdbErrorChecker.hasErrors(nextVDB, true); + } if( doDeploy ) { doDeploy = VdbAgeChecker.doDeploy(nextVDB, teiidServer.getServerVersion()); diff --git a/plugins/org.teiid.designer.dqp.ui/src/org/teiid/designer/runtime/ui/actions/ExecuteVDBAction.java b/plugins/org.teiid.designer.dqp.ui/src/org/teiid/designer/runtime/ui/actions/ExecuteVDBAction.java index a37c076c06..9ad46aafa8 100644 --- a/plugins/org.teiid.designer.dqp.ui/src/org/teiid/designer/runtime/ui/actions/ExecuteVDBAction.java +++ b/plugins/org.teiid.designer.dqp.ui/src/org/teiid/designer/runtime/ui/actions/ExecuteVDBAction.java @@ -25,6 +25,7 @@ import org.teiid.designer.runtime.ui.vdb.ExecuteVdbDialog; import org.teiid.designer.runtime.ui.vdb.ExecuteVdbWorker; import org.teiid.designer.runtime.ui.vdb.VdbConstants; +import org.teiid.designer.runtime.ui.vdb.VdbErrorChecker; import org.teiid.designer.ui.actions.SortableSelectionAction; import org.teiid.designer.ui.common.actions.ModelActionConstants; import org.teiid.designer.ui.common.eventsupport.SelectionUtilities; @@ -103,14 +104,6 @@ public void run() { IFile vdb = selectedVDB; try { - if (!isVdbSyncd(vdb)) { - Shell shell = UiUtil.getWorkbenchShellOnlyIfUiThread(); - String title = UTIL.getString("VdbNotSyncdDialog.title"); //$NON-NLS-1$ - String msg = UTIL.getString("VdbNotSyncdDialog.msg"); //$NON-NLS-1$ - if (!MessageDialog.openQuestion(shell, title, msg)) - return; - } - if (vdb == null) { ExecuteVdbDialog dialog = new ExecuteVdbDialog(worker.getShell(), null); @@ -119,6 +112,18 @@ public void run() { if (dialog.getReturnCode() == Window.OK) { vdb = dialog.getSelectedVdb(); } + } + + if (!isVdbSyncd(vdb)) { + Shell shell = UiUtil.getWorkbenchShellOnlyIfUiThread(); + String title = UTIL.getString("VdbNotSyncdDialog.title"); //$NON-NLS-1$ + String msg = UTIL.getString("VdbNotSyncdDialog.msg"); //$NON-NLS-1$ + if (!MessageDialog.openQuestion(shell, title, msg)) + return; + } + + if( VdbErrorChecker.hasErrors(vdb, false)) { + return; } if (vdb != null) { diff --git a/plugins/org.teiid.designer.dqp.ui/src/org/teiid/designer/runtime/ui/i18n.properties b/plugins/org.teiid.designer.dqp.ui/src/org/teiid/designer/runtime/ui/i18n.properties index c140c87795..e15bd47eb6 100644 --- a/plugins/org.teiid.designer.dqp.ui/src/org/teiid/designer/runtime/ui/i18n.properties +++ b/plugins/org.teiid.designer.dqp.ui/src/org/teiid/designer/runtime/ui/i18n.properties @@ -639,6 +639,11 @@ VdbAgeChecker.oldVdb.message=The {0} VDB was created to target an 8.x Teiid runt VdbAgeChecker.invalidVdbVersionForServer.title=Deploy VDB Warning VdbAgeChecker.invalidVdbVersionForServer.message=The target Teiid server version {0} does not support the non-integer VDB version ({1}) and will not fully deploy. \ \n\nDo you wish to deploy the VDB {2} anyway? + +VdbErrorChecker.vdbHasErrors.title=VDB has errors +VdbErrorChecker.vdbHasErrorsOnDeploy.message=The {0} VDB has errors in one or more models and cannot be deployed.\n\nFix errors and synchronize this VDB then redeploy. +VdbErrorChecker.vdbHasErrors.message=The {0} VDB has errors in one or more models and cannot be deployed.\n\nFix errors and synchronize this VDB. + ######################################### # CreateDataSourceWizard diff --git a/plugins/org.teiid.designer.dqp.ui/src/org/teiid/designer/runtime/ui/vdb/ExecuteVdbAction.java b/plugins/org.teiid.designer.dqp.ui/src/org/teiid/designer/runtime/ui/vdb/ExecuteVdbAction.java index 4eaa168742..ea47b53d3c 100644 --- a/plugins/org.teiid.designer.dqp.ui/src/org/teiid/designer/runtime/ui/vdb/ExecuteVdbAction.java +++ b/plugins/org.teiid.designer.dqp.ui/src/org/teiid/designer/runtime/ui/vdb/ExecuteVdbAction.java @@ -76,14 +76,16 @@ public void run() { return; try { - if (!isVdbSyncd(vdb)) { + if (!isVdbSyncd(vdb) ) { Shell shell = UiUtil.getWorkbenchShellOnlyIfUiThread(); String title = UTIL.getString("VdbNotSyncdDialog.title"); //$NON-NLS-1$ String msg = UTIL.getString("VdbNotSyncdDialog.msg"); //$NON-NLS-1$ if (!MessageDialog.openQuestion(shell, title, msg)) return; } - + if( !VdbErrorChecker.hasErrors(vdb, false)) { + return; + } worker.run(vdb); } catch (Exception ex) { ErrorHandler.toExceptionDialog(ex); diff --git a/plugins/org.teiid.designer.dqp.ui/src/org/teiid/designer/runtime/ui/vdb/VdbErrorChecker.java b/plugins/org.teiid.designer.dqp.ui/src/org/teiid/designer/runtime/ui/vdb/VdbErrorChecker.java new file mode 100644 index 0000000000..2226c3fcf3 --- /dev/null +++ b/plugins/org.teiid.designer.dqp.ui/src/org/teiid/designer/runtime/ui/vdb/VdbErrorChecker.java @@ -0,0 +1,68 @@ +/* + * JBoss, Home of Professional Open Source. + * + * See the LEGAL.txt file distributed with this work for information regarding copyright ownership and licensing. + * + * See the AUTHORS.txt file distributed with this work for a full listing of individual contributors. + */ +package org.teiid.designer.runtime.ui.vdb; + +import org.eclipse.core.resources.IFile; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.ui.IWorkbenchWindow; +import org.teiid.core.designer.util.CoreArgCheck; +import org.teiid.core.designer.util.FileUtils; +import org.teiid.designer.core.validation.Severity; +import org.teiid.designer.runtime.ui.DqpUiConstants; +import org.teiid.designer.ui.UiPlugin; +import org.teiid.designer.vdb.VdbUtil; +import org.teiid.designer.vdb.manifest.ModelElement; +import org.teiid.designer.vdb.manifest.ProblemElement; +import org.teiid.designer.vdb.manifest.VdbElement; + +public class VdbErrorChecker { + + public static boolean hasErrors(IFile vdbFile, boolean deployOnly) { + CoreArgCheck.isNotNull(vdbFile, "vdbFile"); //$NON-NLS-1$ + + + try { + VdbElement vdbElement = VdbUtil.getVdbManifest(vdbFile); + for( ModelElement model : vdbElement.getModels() ) { + + if( hasProblems(model)) { + + final IWorkbenchWindow window = UiPlugin.getDefault().getCurrentWorkbenchWindow(); + + String vdbName = FileUtils.getNameWithoutExtension(vdbFile); + if( deployOnly ) { + MessageDialog.openError(window.getShell(), + DqpUiConstants.UTIL.getString("VdbErrorChecker.vdbHasErrors.title"), //$NON-NLS-1$ + DqpUiConstants.UTIL.getString("VdbErrorChecker.vdbHasErrorsOnDeploy.message", vdbName)); //$NON-NLS-1$ + } else { + MessageDialog.openError(window.getShell(), + DqpUiConstants.UTIL.getString("VdbErrorChecker.vdbHasErrors.title"), //$NON-NLS-1$ + DqpUiConstants.UTIL.getString("VdbErrorChecker.vdbHasErrors.message", vdbName)); //$NON-NLS-1$ + } + + return true; + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return false; + } + + private static boolean hasProblems(ModelElement model) { + for( ProblemElement problem : model.getProblems()) { + if( problem.getSeverity().name().equals(Severity.get(Severity.ERROR).getName())) { + return true; + } + } + + return false; + } +} diff --git a/plugins/org.teiid.designer.dqp.ui/src/org/teiid/designer/runtime/ui/vdb/VdbRequiresSaveChecker.java b/plugins/org.teiid.designer.dqp.ui/src/org/teiid/designer/runtime/ui/vdb/VdbRequiresSaveChecker.java index c6a6717f77..554493b82d 100644 --- a/plugins/org.teiid.designer.dqp.ui/src/org/teiid/designer/runtime/ui/vdb/VdbRequiresSaveChecker.java +++ b/plugins/org.teiid.designer.dqp.ui/src/org/teiid/designer/runtime/ui/vdb/VdbRequiresSaveChecker.java @@ -1,3 +1,10 @@ +/* + * JBoss, Home of Professional Open Source. + * + * See the LEGAL.txt file distributed with this work for information regarding copyright ownership and licensing. + * + * See the AUTHORS.txt file distributed with this work for a full listing of individual contributors. + */ package org.teiid.designer.runtime.ui.vdb; import java.lang.reflect.InvocationTargetException;