Skip to content

Commit

Permalink
TEIIDDES-3102
Browse files Browse the repository at this point in the history
 * Added vdb error check prior to deploy or test VDB
 * warns the user there are errors and request fixing in order to deploy
  • Loading branch information
blafond committed Sep 6, 2017
1 parent 06f997f commit 2e209c6
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 10 deletions.
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand All @@ -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) {
Expand Down
Expand Up @@ -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
Expand Down
Expand Up @@ -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);
Expand Down
@@ -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;
}
}
@@ -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;
Expand Down

0 comments on commit 2e209c6

Please sign in to comment.