Skip to content

Commit

Permalink
Merge pull request #229 from mdrillin/TEIIDDES-1841
Browse files Browse the repository at this point in the history
TEIIDDES-1841 Improve error message for transformation export
  • Loading branch information
blafond committed Aug 17, 2013
2 parents b595276 + 833daa7 commit 1668a68
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ public class ExportTransformationSqlToTextAction extends SortableSelectionAction
private static final String EXPORT_DEFAULT_FILENAME = "ExportTransformationSqlToTextAction.exportDefaultFile.text"; //$NON-NLS-1$
private static final String EXPORT_DEFAULT_FILEEXT = "ExportTransformationSqlToTextAction.exportDefaultExtension.text"; //$NON-NLS-1$

private static final char DELIMETER = '|';
private static final String DELIMETER = "|"; //$NON-NLS-1$
private static final String SPACE = " "; //$NON-NLS-1$
private static final String LEFT_BRACKET = "[ "; //$NON-NLS-1$
private static final String RIGHT_BRACKET = " ]"; //$NON-NLS-1$

/**
* @since 5.0
Expand Down Expand Up @@ -190,7 +193,11 @@ public String getSqlOutputString( ModelResource modelResource ) throws ModelWork
int initBufferSize = nTransforms * 200;
StringBuffer sb = new StringBuffer(initBufferSize);
String relativeTablePath = null;
Collection invalidQueries = new ArrayList();
boolean hasMissingSelects = false;
boolean hasMissingInserts = false;
boolean hasMissingUpdates = false;
boolean hasMissingDeletes = false;

for (Iterator iter = transformations.iterator(); iter.hasNext();) {
Object obj = iter.next();
String rowString = null;
Expand All @@ -206,7 +213,7 @@ public String getSqlOutputString( ModelResource modelResource ) throws ModelWork
sb.append(rowString);
}
} else {
invalidQueries.add(relativeTablePath);
hasMissingSelects = true;
}

// Now check if updates allowed
Expand All @@ -221,7 +228,7 @@ public String getSqlOutputString( ModelResource modelResource ) throws ModelWork
sb.append(rowString);
}
} else {
invalidQueries.add(relativeTablePath);
hasMissingInserts = true;
}
}
if (TransformationHelper.supportsUpdate((EObject)obj, null)) {
Expand All @@ -233,7 +240,7 @@ public String getSqlOutputString( ModelResource modelResource ) throws ModelWork
sb.append(rowString);
}
} else {
invalidQueries.add(relativeTablePath);
hasMissingUpdates = true;
}
}
if (TransformationHelper.supportsDelete((EObject)obj, null)) {
Expand All @@ -245,16 +252,39 @@ public String getSqlOutputString( ModelResource modelResource ) throws ModelWork
sb.append(rowString);
}
} else {
invalidQueries.add(relativeTablePath);
hasMissingDeletes = true;
}
}
}
}
}

if (!invalidQueries.isEmpty()) {
UiConstants.Util.log(IStatus.ERROR,
UiConstants.Util.getString("ExportTransformationSqlToTextAction.exportQueryProblem", modelResource.getItemName()));//$NON-NLS-1$
// If operations are missing, specify in the error message
if(hasMissingSelects || hasMissingInserts || hasMissingUpdates || hasMissingDeletes) {
int count = 0;
StringBuffer msgBuff = new StringBuffer(UiConstants.Util.getString("ExportTransformationSqlToTextAction.exportQueryProblem", modelResource.getItemName())); //$NON-NLS-1$
msgBuff.append(SPACE+LEFT_BRACKET);
if(hasMissingSelects) {
msgBuff.append(ISQLConstants.SQL_TYPE_SELECT_STRING);
count++;
}
if(hasMissingInserts) {
if(count>0) msgBuff.append(SPACE+DELIMETER+SPACE);
msgBuff.append(ISQLConstants.SQL_TYPE_INSERT_STRING);
count++;
}
if(hasMissingUpdates) {
if(count>0) msgBuff.append(SPACE+DELIMETER+SPACE);
msgBuff.append(ISQLConstants.SQL_TYPE_UPDATE_STRING);
count++;
}
if(hasMissingDeletes) {
if(count>0) msgBuff.append(SPACE+DELIMETER+SPACE);
msgBuff.append(ISQLConstants.SQL_TYPE_DELETE_STRING);
count++;
}
msgBuff.append(RIGHT_BRACKET);
UiConstants.Util.log(IStatus.ERROR,msgBuff.toString());
}

return sb.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ ExportTransformationSqlToTextAction.exportProb=Problem exporting the transformat
ExportTransformationSqlToTextAction.exportSqlDialog.title=Export transformation SQL to a file
ExportTransformationSqlToTextAction.exportDefaultFile.text=ExportedTransformationSQL.txt
ExportTransformationSqlToTextAction.exportDefaultExtension.text=txt
ExportTransformationSqlToTextAction.exportQueryProblem= Problems detected in one or more transformations. {0} Check exported SQL text file for completeness.
ExportTransformationSqlToTextAction.exportQueryProblem= Potential problems detected in the exported SQL for [{0}] - please check the file. One or more missing SQL for these operations:

EditTransformationHelper.dialogTitle=Edit Transformation
EditTransformationHelper.dialogMessage=Select Transformation Target for Model: {0}
Expand Down

0 comments on commit 1668a68

Please sign in to comment.