Skip to content

Commit

Permalink
TEIIDDES-3133
Browse files Browse the repository at this point in the history
 * injecting translator name during materialized source model creation
 * injecting matview-jdg-source property into model for providers to add
translator overrides or not
 * changed connection info providers to check for property
  • Loading branch information
blafond committed Nov 9, 2017
1 parent a616c43 commit 7a09d0f
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.teiid.designer.datatools.profiles.jbossds.IJBossDsProfileConstants;

public class JDG7ConnectionInfoProvider extends ConnectionInfoHelper implements IConnectionInfoProvider, IJDGProfileConstants.PropertyKeys {
public static final String MATVIEW_JDG_SOURCE = "matview-jdg-source"; //$NON-NLS-1$

@Override
public String getDataSourcePasswordPropertyKey() {
Expand Down Expand Up @@ -95,6 +96,8 @@ public void setConnectionInfo(ModelResource modelResource, IConnectionProfile co
Properties connectionProps = getCommonProfileProperties(connectionProfile);

Properties props = connectionProfile.getBaseProperties();

boolean isMatViewModel = getHelper().getPropertyValue(modelResource, CONNECTION_NAMESPACE + MATVIEW_JDG_SOURCE) != null;

// String result = props.getProperty(IJBossDsProfileConstants.TRANSLATOR_PROP_ID);
// if (null != result) {
Expand Down Expand Up @@ -165,9 +168,19 @@ public void setConnectionInfo(ModelResource modelResource, IConnectionProfile co
if (null != result) {
connectionProps.setProperty(CONNECTION_NAMESPACE + AUTHENTICATION_PASSWORD, result);
}

if( isMatViewModel ) {
// replace the property
connectionProps.setProperty(CONNECTION_NAMESPACE + MATVIEW_JDG_SOURCE, Boolean.TRUE.toString());
}

connectionProps.put(TRANSLATOR_NAMESPACE + TRANSLATOR_NAME_KEY, IJDGProfileConstants.JDG7_TRANSLATOR_NAME); //$NON-NLS-1$

getHelper().setProperties(modelResource, connectionProps);


addMaterializationTranslatorOverrideProperties(modelResource);
if( isMatViewModel ) {
addMaterializationTranslatorOverrideProperties(modelResource);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.teiid.designer.datatools.profiles.jbossds.IJBossDsProfileConstants;

public class JDGConnectionInfoProvider extends ConnectionInfoHelper implements IConnectionInfoProvider, IJDGProfileConstants.PropertyKeys {
public static final String MATVIEW_JDG_SOURCE = "matview-jdg-source"; //$NON-NLS-1$

@Override
public String getDataSourcePasswordPropertyKey() {
Expand Down Expand Up @@ -110,6 +111,8 @@ public void setConnectionInfo(ModelResource modelResource, IConnectionProfile co
Properties connectionProps = getCommonProfileProperties(connectionProfile);

Properties props = connectionProfile.getBaseProperties();

boolean isMatViewModel = getHelper().getPropertyValue(modelResource, CONNECTION_NAMESPACE + MATVIEW_JDG_SOURCE) != null;

String result = props.getProperty(IJBossDsProfileConstants.TRANSLATOR_PROP_ID);
if (null != result) {
Expand Down Expand Up @@ -177,6 +180,10 @@ public void setConnectionInfo(ModelResource modelResource, IConnectionProfile co
getHelper().removeProperties(modelResource, CONNECTION_NAMESPACE);
connectionProps.setProperty(CLASS_NAME, IJDGProfileConstants.REQUIRED_CLASS_NAME);

if( isMatViewModel ) {
// replace the property
connectionProps.setProperty(CONNECTION_NAMESPACE + MATVIEW_JDG_SOURCE, Boolean.TRUE.toString());
}

getHelper().setProperties(modelResource, connectionProps);

Expand All @@ -185,7 +192,9 @@ public void setConnectionInfo(ModelResource modelResource, IConnectionProfile co
setJNDIName(modelResource, result);
}

addMaterializationTranslatorOverrideProperties(modelResource);
if( isMatViewModel ) {
addMaterializationTranslatorOverrideProperties(modelResource);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ EditTOPropertiesAction.translatorOverridesNotAvailable.title=Built-in Translator
EditTOPropertiesAction.translatorOverridesNotAvailable.message=No built-in properties available to override for the translator of type {0}

GenerateDynamicVdbManager.generateDynamicVdbStatus = Generate Dynamic VDB Status
GenerateDynamicVdbManager.warningsOnExport = The VDB was exported but warnings have been issued
GenerateDynamicVdbManager.warningsOnExport = The VDB was exported with the following warnings

########## PreviewDataWorker ##########
PreviewDataWorker.previewUnavailableDialog.title = Preview Unavailable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.io.File;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Properties;

import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
Expand All @@ -32,6 +33,7 @@
import org.teiid.designer.core.workspace.ModelResource;
import org.teiid.designer.core.workspace.ModelUtil;
import org.teiid.designer.core.workspace.ModelWorkspaceException;
import org.teiid.designer.core.workspace.ResourceAnnotationHelper;
import org.teiid.designer.extension.ExtensionPlugin;
import org.teiid.designer.extension.definition.ModelObjectExtensionAssistant;
import org.teiid.designer.extension.registry.ModelExtensionRegistry;
Expand Down Expand Up @@ -63,6 +65,11 @@
public class MaterializedModelManager implements ReverseEngConstants {
private static String RESULT_MSG = TransformationPlugin.Util.getString("MaterializedModelManager.resultStr"); //$NON-NLS-1$
private static String OK_MSG = TransformationPlugin.Util.getString("MaterializedModelManager.success"); //$NON-NLS-1$
public static final String CONNECTION_NAMESPACE = "connection:"; //$NON-NLS-1$
public static final String MATVIEW_JDG_SOURCE = "matview-jdg-source"; //$NON-NLS-1$
public static final String TRANSLATOR_KEY = "translator:name"; //$NON-NLS-1$
public static final String JDG6_TRANSLATOR_NAME = "infinispan-cache-dsl"; //$NON-NLS-1$
public static final String JDG7_TRANSLATOR_NAME = "infinispan-hotrod"; //$NON-NLS-1$

private static IStatus OK_STATUS = new Status(IStatus.OK, TransformationPlugin.PLUGIN_ID,
TransformationPlugin.Util.getString("MaterializedModelManager.allInputsOkStatusMessage")); //$NON-NLS-1$
Expand Down Expand Up @@ -197,6 +204,16 @@ public MultiStatus execute() {
assistant.setPropertyValue(selectedViewOrTable, RelationalModelExtensionConstants.PropertyIds.MATVIEW_BEFORE_LOAD_SCRIPT, beforeLoadScriptStr);
assistant.setPropertyValue(selectedViewOrTable, RelationalModelExtensionConstants.PropertyIds.MATERIALIZED_STAGE_TABLE, stageTableStr);

ResourceAnnotationHelper helper = new ResourceAnnotationHelper();
Properties props = new Properties();
props.put(CONNECTION_NAMESPACE + MATVIEW_JDG_SOURCE, Boolean.TRUE.toString());
if( isJDG7DOT1 ) {
props.put(TRANSLATOR_KEY, JDG7_TRANSLATOR_NAME);
} else {
props.put(TRANSLATOR_KEY, JDG6_TRANSLATOR_NAME);
}
helper.setProperties(newSourceModel, props);

ModelBuildUtil.rebuildImports(targetModelResource.getEmfResource(), true);

newSourceModel.save(new NullProgressMonitor(), false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ VdbResourceChange.syncVdbFailure = Cannot synchronize vdb file from project {0},

XmiVdb.modelNotIncludedMessage = The model {0} is not a relational model and was not included in the generated dynamic VDB
XmiVdb.fileNotIncludedMessage = The file "{0}" was not included in the generated dynamic VDB
XmiVdb.udfPropertyAdded = The vdb contains the udf library named "{0}" hence a property referencing this has been added\n \
to the dynamic VDB. For the dynamic VDB to perform successfully, the udf library must also be\n \
deployed to the Teiid instance.
XmiVdb.udfPropertyAdded = This VDB contains 1 or more UDF jar files. A "lib" property has been added added\n \
to the VDB xml which references these jars.\n\n \
Note that the actual UDF jars must be deployed for this VDB to be active.\n \

0 comments on commit 7a09d0f

Please sign in to comment.