Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
Showing
6 changed files
with
102 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
plugins/org.teiid.designer.dqp.ui/src/org/teiid/designer/runtime/ui/vdb/VdbErrorChecker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...g.teiid.designer.dqp.ui/src/org/teiid/designer/runtime/ui/vdb/VdbRequiresSaveChecker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters