Skip to content

Commit

Permalink
Merge pull request #256 from mdrillin/TEIIDDES-1911
Browse files Browse the repository at this point in the history
TEIIDDES-1911 Adds TeiidConnection Importer ability to provide optional import properties
  • Loading branch information
blafond committed Nov 10, 2013
2 parents 9471dd2 + fb1079e commit ce51348
Show file tree
Hide file tree
Showing 10 changed files with 824 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.io.File;
import java.io.InputStream;
import java.util.Collection;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;
Expand All @@ -19,6 +20,7 @@
import org.eclipse.core.runtime.Status;
import org.eclipse.osgi.util.NLS;
import org.teiid.core.designer.util.CoreStringUtil;
import org.teiid.designer.common.xml.XmlUtil;
import org.teiid.designer.runtime.DqpPlugin;
import org.teiid.designer.runtime.PreferenceConstants;
import org.teiid.designer.runtime.spi.ExecutionConfigurationEvent;
Expand Down Expand Up @@ -119,10 +121,11 @@ private ITeiidDataSource getDataSource( String sourceName ) throws Exception {
* @param vdbName name to use for the VDB
* @param sourceName the dataSource to use for the import
* @param translatorName the name of the translator
* @param modelPropertyMap the Map of optional model properties
* @param monitor the progress monitor
* @return status of the deployment
*/
public IStatus deployDynamicVdb(String vdbName, String sourceName, String translatorName, IProgressMonitor monitor) {
public IStatus deployDynamicVdb(String vdbName, String sourceName, String translatorName, Map<String,String> modelPropertyMap, IProgressMonitor monitor) {
// Work remaining for progress monitor
int workRemaining = 100;

Expand Down Expand Up @@ -150,7 +153,7 @@ public IStatus deployDynamicVdb(String vdbName, String sourceName, String transl
sourceJndiName=sourceName;
}
// Get Dynamic VDB string
String dynamicVdbString = createDynamicVdb(vdbName,1,translatorName,importSourceModel,sourceJndiName);
String dynamicVdbString = createDynamicVdb(vdbName,1,translatorName,importSourceModel,sourceJndiName,modelPropertyMap);

// If an import VDB with the supplied name exists, undeploy it first
ITeiidVdb deployedImportVdb;
Expand Down Expand Up @@ -263,9 +266,14 @@ private String getVdbDeploymentName(ITeiidVdb deployedVdb) {
* Create a new, blank deployment for the provided vdbName and version
* @param vdbName name of the VDB
* @param vdbVersion the VDB version
* @param translatorName the translator
* @param datasourceName the dataSource name
* @param datasourceJndeName the dataSource jndi name
* @param modelProps the model properties
* @return the VDB deployment string
*/
private String createDynamicVdb(String vdbName, int vdbVersion, String translatorName, String datasourceName, String datasourceJndiName) {
private String createDynamicVdb(String vdbName, int vdbVersion, String translatorName, String datasourceName, String datasourceJndiName,
Map<String,String> modelProps) {
StringBuffer sb = new StringBuffer();
String deploymentName = vdbName+DYNAMIC_VDB_SUFFIX;
sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"); //$NON-NLS-1$
Expand All @@ -274,6 +282,11 @@ private String createDynamicVdb(String vdbName, int vdbVersion, String translat
sb.append("<property name=\"UseConnectorMetadata\" value=\"true\" />"); //$NON-NLS-1$
sb.append("<property name=\"deployment-name\" value=\""+deploymentName+"\" />"); //$NON-NLS-1$ //$NON-NLS-2$
sb.append("<model name=\""+datasourceName+"\" type=\"PHYSICAL\" visible=\"true\">"); //$NON-NLS-1$ //$NON-NLS-2$
Set<String> propNames = modelProps.keySet();
for(String propName : propNames) {
String propValue = XmlUtil.escapeCharacterData(modelProps.get(propName));
sb.append("<property name=\""+propName+"\" value=\""+propValue+"\" />"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
sb.append("<source name=\""+datasourceName+"\" translator-name=\""+translatorName+"\" connection-jndi-name=\""+datasourceJndiName+"\" />"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
sb.append("</model>"); //$NON-NLS-1$
sb.append("</vdb>"); //$NON-NLS-1$
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ public class Messages extends NLS {
public static String SelectTranslatorPage_dsNameLabel;
public static String SelectTranslatorPage_dsTypeLabel;
public static String SelectTranslatorPage_translatorLabel;
public static String SelectTranslatorPage_SrcModelDefnGroup;
public static String SelectTranslatorPage_SrcDefnGroup;
public static String SelectTranslatorPage_TgtModelDefnGroup;
public static String SelectTranslatorPage_Location;
public static String SelectTranslatorPage_Browse;
public static String SelectTranslatorPage_Name;
Expand Down Expand Up @@ -128,6 +129,23 @@ public class Messages extends NLS {
public static String dataSourceManager_deleteCreateInterruptedMsg;
public static String dataSourceManager_copyOk;
public static String dataSourceManager_copyInterruptedMsg;

public static String ImportPropertiesPanel_groupTitle;
public static String ImportPropertiesPanel_name;
public static String ImportPropertiesPanel_value;
public static String ImportPropertiesPanel_addNewPropertyButton_tooltip;
public static String ImportPropertiesPanel_removePropertyButton_tooltip;

public static String AddGeneralPropertyDialog_title;
public static String AddGeneralPropertyDialog_message;
public static String AddGeneralPropertyDialog_lblName_text;
public static String AddGeneralPropertyDialog_txtName_toolTip;
public static String AddGeneralPropertyDialog_lblValue_text;
public static String AddGeneralPropertyDialog_txtValue_toolTip;
public static String AddGeneralPropertyDialog_customPropertyAlreadyExists;
public static String AddGeneralPropertyDialog_emptyPropertyName;
public static String AddGeneralPropertyDialog_invalidPropertyName;
public static String AddGeneralPropertyDialog_emptyPropertyValue;

static {
NLS.initializeMessages("org.teiid.designer.teiidimporter.ui.messages", Messages.class); //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ interface ImageIds {

String IMPORT_TEIID_METADATA = FOLDER + "importTeiidMetadataWiz.gif"; //$NON-NLS-1$
String RESET_PROPERTY = FOLDER + "restore-default-value.png"; //$NON-NLS-1$
String ADD_PROPERTY = FOLDER + "add_property.png"; //$NON-NLS-1$
String REMOVE_PROPERTY = FOLDER + "remove_property.png"; //$NON-NLS-1$
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ SelectTranslatorPage_title=Select the translator and target model for the import
SelectTranslatorPage_dsNameLabel=DataSource:
SelectTranslatorPage_dsTypeLabel=Driver:
SelectTranslatorPage_translatorLabel=Translator:
SelectTranslatorPage_SrcModelDefnGroup=Target Model Definition
SelectTranslatorPage_SrcDefnGroup=Source Definition
SelectTranslatorPage_TgtModelDefnGroup=Target Model Definition
SelectTranslatorPage_Location=Location:
SelectTranslatorPage_Browse=...
SelectTranslatorPage_Name=Name:
Expand Down Expand Up @@ -119,3 +120,20 @@ dataSourceManager_deleteCreateOk=Delete-Create DataSource succeeded
dataSourceManager_deleteCreateInterruptedMsg=Delete-Create DataSource was interrupted
dataSourceManager_copyOk=Copy DataSource succeeded
dataSourceManager_copyInterruptedMsg=Copy DataSource was interrupted

ImportPropertiesPanel_groupTitle=Optional Source Import Properties
ImportPropertiesPanel_name=Name
ImportPropertiesPanel_value=Value
ImportPropertiesPanel_addNewPropertyButton_tooltip=Add New Property
ImportPropertiesPanel_removePropertyButton_tooltip=Remove Property

AddGeneralPropertyDialog_title = Add New Property
AddGeneralPropertyDialog_message = Enter a unique property name and a value:
AddGeneralPropertyDialog_lblName_text = Name:
AddGeneralPropertyDialog_txtName_toolTip = The unique name of the custom property
AddGeneralPropertyDialog_lblValue_text = Value:
AddGeneralPropertyDialog_txtValue_toolTip = A non-empty value for this custom property
AddGeneralPropertyDialog_customPropertyAlreadyExists = Property "{0}" already exists.
AddGeneralPropertyDialog_emptyPropertyName=Name of property cannot be empty
AddGeneralPropertyDialog_invalidPropertyName=Name must contain only letters, numbers or a '-'
AddGeneralPropertyDialog_emptyPropertyValue=Value or property cannot be empty

0 comments on commit ce51348

Please sign in to comment.