Skip to content

Commit

Permalink
TEIIDDES-3180
Browse files Browse the repository at this point in the history
 * moved reference check in validator ahead of resolving
 * removed references check in transformation editor validation results
check
  • Loading branch information
blafond committed Jan 17, 2018
1 parent 55c734f commit 8bbdc0d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
Expand Up @@ -2958,10 +2958,9 @@ private void setMessageDisplayForValidSQL() {
boolean targetAndSQLOutNamesOK = statusArray[1];
boolean targetAndSQLOutTypesOK = statusArray[2];
// Check the command for References
int refCount = TransformationSqlHelper.getReferenceCount(currentMappingRoot, cmdType);

// If all checks are OK, the SQL is Fully Reconciled and NO References
if (targetAndSQLOutSizesOK && targetAndSQLOutNamesOK && targetAndSQLOutTypesOK && refCount == 0) {
if (targetAndSQLOutSizesOK && targetAndSQLOutNamesOK && targetAndSQLOutTypesOK) {
getSqlEditorPanelWrapper().setMessage(sqlTypeMsg + SPACE + IS_VALID_AND_RECONCILABLE);
getSqlEditorPanelWrapper().showMessageArea(false);
// If any check is not OK, refine the message further
Expand All @@ -2985,11 +2984,7 @@ private void setMessageDisplayForValidSQL() {
} else if (!targetAndSQLOutTypesOK) {
buff.append("\n" + QUERY_TYPE_MISMATCH_MSG); //$NON-NLS-1$
}
// Add Message if there are references
if (refCount > 0) {
buff.append("\n" + COMMAND_HAS_REFERENCES_MSG); //$NON-NLS-1$
buff.append("\n" + NUMBER_REFERENCES_MSG + refCount); //$NON-NLS-1$
}

getSqlEditorPanelWrapper().setMessage(buff.toString());
getSqlEditorPanelWrapper().showMessageArea(true);
}
Expand Down
Expand Up @@ -22,6 +22,7 @@
import org.eclipse.emf.ecore.EObject;
import org.eclipse.xsd.XSDSimpleTypeDefinition;
import org.teiid.core.designer.util.CoreArgCheck;
import org.teiid.core.designer.util.StringConstants;
import org.teiid.designer.core.ModelerCore;
import org.teiid.designer.core.metadata.runtime.ColumnRecordImpl;
import org.teiid.designer.core.metadata.runtime.TableRecordImpl;
Expand Down Expand Up @@ -2720,7 +2721,18 @@ public static int getReferenceCount( Object transMappingRoot,
// Get the list of References
IReferenceCollectorVisitor referenceCollectorVisitor = getQueryService().getReferenceCollectorVisitor();
List<IReference> refs = referenceCollectorVisitor.findReferences(command);
refCount = refs.size();

boolean allOK = true;
for( IReference ref : refs ) {
if( !ref.toString().equals(StringConstants.QUESTION_MARK) ) {
allOK = false;
break;
}
}
if( !allOK ) {
refCount = refs.size();
}

}

return refCount;
Expand Down
Expand Up @@ -352,6 +352,9 @@ public QueryValidationResult validateSql( final String sql,

if (commandValidationResult.isParsable() && transformType != UNKNOWN_TRNS) {
ICommand command = commandValidationResult.getCommand();

// Validate references before resolving
Collection<IStatus> statusList = validateReferences(command, null);

// resolve command
commandValidationResult = resolveCommand(command, transformType);
Expand Down Expand Up @@ -522,8 +525,6 @@ public SqlTransformationResult validateCommand( final ICommand command, final in
// If no report items - validation is successful
// Check sources (target can't be a source)
statusList = validateSources(command, statusList);
// validate references
statusList = validateReferences(command, statusList);

} else {
statusList = createStatusList(report);
Expand Down

0 comments on commit 8bbdc0d

Please sign in to comment.