Skip to content

Commit

Permalink
TEIIDDES-2275
Browse files Browse the repository at this point in the history
 * Relaxed importer to allow no-ddl returned case to create empty model. Works for time-outs and unsupported data sources
 * Removed the browse for Source Model button and associated messages and validation checks.
  • Loading branch information
blafond committed Aug 18, 2014
1 parent 269fa74 commit 53413fa
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,9 @@ void validate( ) {
if(diffReport==null) {
errMessageBuffer.append(DdlImporterUiI18n.DIFFERENCE_PAGE_NO_DIFFERENCE_REPORT_MSG);
} else {
// DifferenceReport has no operations
if(!diffReport.hasOperations()) {
if( importer.noDdlImported() ) { // DifferenceReport has no operations
// do nothing
} else if(!diffReport.hasOperations()) {
errMessageBuffer.append(DdlImporterUiI18n.DIFFERENCE_PAGE_NO_DIFFERENCE_OPERATIONS_MSG);
// DifferenceReport has nothing selected
} else if(!diffReport.hasSelectedOperations()) {
Expand All @@ -340,7 +341,11 @@ void validate( ) {
setMessage(DdlImporterUiI18n.DIFFERENCE_PAGE_IMPORT_COMPLETED_WITH_MESSAGES_MSG);
// Set description to finish
} else {
setMessage(null);
if( importer.noDdlImported() ) {
setMessage(DdlImporterUiI18n.DIFFERENCE_PAGE_NO_DDL_IMPORTED_MSG);
} else {
setMessage(null);
}
setDescription(DdlImporterUiI18n.DIFFERENCE_PAGE_DESCRIPTION);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class DdlImporterUiI18n {
static final String OPT_TO_CREATE_MODEL_ENTITIES_FOR_UNSUPPORTED_DDL_LABEL = i18n("optToCreateModelEntitiesForUnsupportedDdlLabel"); //$NON-NLS-1$
static final String OPT_TO_SET_MODEL_ENTITY_DESCRIPTION_LABEL = i18n("optToSetModelEntityDescriptionLabel"); //$NON-NLS-1$
static final String PAGE_DESCRIPTION = i18n("pageDescription"); //$NON-NLS-1$
static final String DIFFERENCE_PAGE_NO_DDL_IMPORTED_MSG = i18n("differencePage.noDdlImportedMsg"); //$NON-NLS-1$
static final String PAGE_TITLE = i18n("pageTitle"); //$NON-NLS-1$
static final String PATH_MSG_PART = i18n("pathMsgPart"); //$NON-NLS-1$
static final String PROJECT_MSG_PART = i18n("projectMsgPart"); //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,5 @@ differencePage.noDiffReportErrorMsg = No difference report was found
differencePage.noDiffOperationsErrorMsg = No difference operations were found
differencePage.noDiffOperationsSelectedErrorMsg = At least one item must be selected
differencePage.importCompletedWithMessages = The import completed with warnings. See the import messages for more info, then click 'Finish' to complete.
differencePage.seeImportMessagesMsg = See the import messages for more info.
differencePage.seeImportMessagesMsg = See the import messages for more info.
differencePage.noDdlImportedMsg = No DDL imported from your data source. Click Finish to create an empty model
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public class DdlImporter {
private ModelResource model;
private String ddlString;
private IStatus importStatus;
private boolean noDdlImported;

private DdlImporterManager importManager = new DdlImporterManager();

Expand Down Expand Up @@ -128,6 +129,12 @@ void importDdl(FileReader reader, IProgressMonitor monitor, int totalWork ) thro
AstNode rootNode = null;
DdlParsers parsers = new DdlParsers();
ddlString = builder.toString();

if( CoreStringUtil.isEmpty(ddlString) ) {
ddlString = "-- No DDL Returned"; //$NON-NLS-1$
this.noDdlImported = true;
}

try {
if(!CoreStringUtil.isEmpty(specifiedParser)) {
rootNode = parsers.parseUsing(ddlString,specifiedParser);
Expand Down Expand Up @@ -244,6 +251,13 @@ public String getDdlString() {
return ddlString;
}

/**
* @return no DDL imported
*/
public boolean noDdlImported() {
return this.noDdlImported;
}

/**
* @return differenceReport
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,10 @@ public class Messages extends NLS {
public static String SelectTranslatorPage_ModelStatus;
public static String SelectTranslatorPage_SrcModelUndefined;
public static String SelectTranslatorPage_SrcModelSelected;
public static String SelectTranslatorPage_SelectTargetModelTitle;
public static String SelectTranslatorPage_SelectTargetModelMsg;

public static String SelectTranslatorPage_NoOpenProjMsg;
public static String SelectTranslatorPage_SrcLocationNotSpecified;
public static String SelectTranslatorPage_ConnProfileInTargetIncompatible;
public static String SelectTranslatorPage_ModelExistsWithThisNameMsg;
public static String SelectTranslatorPage_ConfirmDeleteTitle;
public static String SelectTranslatorPage_ConfirmDeleteMsg;
public static String SelectTranslatorPage_NoDataSourceNameMsg;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,16 @@ SelectTranslatorPage_Location=Location:
SelectTranslatorPage_Browse=...
SelectTranslatorPage_Name=Name:
SelectTranslatorPage_ModelStatus=Model Status
SelectTranslatorPage_SrcModelUndefined=No Model is selected
SelectTranslatorPage_SrcModelSelected=Model is selected
SelectTranslatorPage_SelectTargetModelTitle=Select Relational Source Model
SelectTranslatorPage_SelectTargetModelMsg=Select a model and click OK
SelectTranslatorPage_SrcModelUndefined=No model name defined
SelectTranslatorPage_SrcModelSelected=Model name defined
SelectTranslatorPage_NoOpenProjMsg=No open projects in workspace
SelectTranslatorPage_SrcLocationNotSpecified=The Model Location must be specified.
SelectTranslatorPage_ModelExistsWithThisNameMsg=A model with the name {0} already exists.
SelectTranslatorPage_ConfirmDeleteTitle=Confirm Delete
SelectTranslatorPage_ConfirmDeleteMsg=Delete the Connection Template: {0} ?
SelectTranslatorPage_NoDataSourceNameMsg=DataSource name is not specified.
SelectTranslatorPage_NoDataSourceDriverMsg=DataSource driver is not specified.
SelectTranslatorPage_NoTranslatorMsg=Translator is not specified.
SelectTranslatorPage_ConnProfileInTargetIncompatible=The target model's connection properties are not compatible with the selected DataSource - cannot update.
SelectTranslatorPage_CreateConnectionProfileCB_Label=Create and apply a Connection Profile.
SelectTranslatorPage_CreateConnectionProfileCB_ToolTip=Create a JBoss DataSource Connection Profile on completion.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@

import java.util.ArrayList;
import java.util.Collection;

import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.dialogs.IDialogConstants;
Expand Down Expand Up @@ -57,12 +57,9 @@
import org.teiid.designer.ui.common.util.WizardUtil;
import org.teiid.designer.ui.common.widget.Dialog;
import org.teiid.designer.ui.common.wizard.AbstractWizardPage;
import org.teiid.designer.ui.explorer.ModelExplorerContentProvider;
import org.teiid.designer.ui.explorer.ModelExplorerLabelProvider;
import org.teiid.designer.ui.viewsupport.ModelIdentifier;
import org.teiid.designer.ui.viewsupport.ModelNameUtil;
import org.teiid.designer.ui.viewsupport.ModelProjectSelectionStatusValidator;
import org.teiid.designer.ui.viewsupport.ModelResourceSelectionValidator;
import org.teiid.designer.ui.viewsupport.ModelWorkspaceViewerFilter;
import org.teiid.designer.ui.viewsupport.ModelingResourceFilter;

Expand Down Expand Up @@ -361,18 +358,7 @@ public void modifyText( ModifyEvent e ) {
}
});

// Browse button for Model selection
browseButton = new Button(sourceGroup, SWT.PUSH);
gridData = new GridData();
browseButton.setLayoutData(gridData);
browseButton.setText(Messages.SelectTranslatorPage_Browse);
browseButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected( SelectionEvent e ) {
handleTargetModelBrowse();
}
});

new Label(sourceGroup, SWT.NONE); // For spacing
new Label(sourceGroup, SWT.NONE); // For spacing

// Info area - shows model selection status
Expand Down Expand Up @@ -414,44 +400,7 @@ void handleTargetModelLocationBrowse() {

validatePage();
}

/**
* Handler for choosing the Target Model
*/
void handleTargetModelBrowse() {
final Object[] selections = WidgetUtil.
showWorkspaceObjectSelectionDialog(Messages.SelectTranslatorPage_SelectTargetModelTitle,
Messages.SelectTranslatorPage_SelectTargetModelMsg,
false,
null,
sourceModelFilter,
new ModelResourceSelectionValidator(false),
new ModelExplorerLabelProvider(),
new ModelExplorerContentProvider() );

// Update importManager with selections
if (selections != null && selections.length == 1 && targetModelFileText != null) {
if( selections[0] instanceof IFile) {
IFile modelFile = (IFile)selections[0];
IPath folderPath = modelFile.getFullPath().removeLastSegments(1);
String modelName = modelFile.getFullPath().lastSegment();
importManager.setTargetModelLocation(folderPath);
importManager.setTargetModelName(modelName);
}
}

// Update UI widgets
if( this.importManager.getTargetModelName() != null ) {
this.targetModelContainerText.setText(this.importManager.getTargetModelLocation().makeRelative().toString());
this.targetModelFileText.setText(this.importManager.getTargetModelName());
} else {
this.targetModelFileText.setText(StringUtilities.EMPTY_STRING);
}

// Validate the page
validatePage();
}


// Handler for ModelText changes
void handleTargetModelTextChanged() {
if( !CoreStringUtil.isEmpty(this.targetModelFileText.getText()) ) {
Expand Down Expand Up @@ -548,8 +497,8 @@ private boolean validateTargetModelSelection() {
}

// Valid target model - now compare it's connection profile vs the selected profile
if( importManager.targetModelExists() && !importManager.isTargetModelConnectionProfileCompatible() ) {
setThisPageComplete(Messages.SelectTranslatorPage_ConnProfileInTargetIncompatible, ERROR);
if( importManager.targetModelExists() ) {
setThisPageComplete(Messages.bind(Messages.SelectTranslatorPage_ModelExistsWithThisNameMsg, fileText), ERROR);
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,12 @@ private boolean validatePage() {
} else {
errorMsg = Messages.ShowDDLPage_vdbDeploymentErrorMsg;
}
setThisPageComplete(errorMsg, ERROR);
setThisPageComplete(errorMsg, WARNING);
return false;
}
String ddlStr = getDDL();
if(ddlStr==null || ddlStr.trim().equals(Messages.TeiidImportManager_getDdlErrorMsg)) {
setThisPageComplete(Messages.TeiidImportManager_getDdlErrorMsg,ERROR);
setThisPageComplete(Messages.TeiidImportManager_getDdlErrorMsg,WARNING);
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ public boolean saveUsingDdlDiffReport(Shell shell) {
// Use the importer to process the difference report, generating the model
if (ddlImporter.getDifferenceReport() == null) return false;

final Exception[] saveException = new Exception[0];
final Exception[] saveException = new Exception[1];
new ProgressMonitorDialog(shell).run(false, false, new IRunnableWithProgress() {

@Override
Expand Down

0 comments on commit 53413fa

Please sign in to comment.