Skip to content

Commit

Permalink
TEIIDDES-2974, TEIIDDES-2970
Browse files Browse the repository at this point in the history
 * removed setting of NIS on generated mat. table/columns
 * auto-setting MAT_XXX extension properties on Mat. View during source
model creation
  • Loading branch information
blafond committed Nov 2, 2016
1 parent c00a396 commit bd49295
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.teiid.designer.metamodels.relational.UniqueConstraint;
import org.teiid.designer.metamodels.relational.UniqueKey;
import org.teiid.designer.metamodels.relational.extension.InfinispanCacheModelExtensionConstants;
import org.teiid.designer.metamodels.relational.extension.RelationalModelExtensionConstants;
import org.teiid.designer.transformation.TransformationPlugin;
import org.teiid.designer.transformation.reverseeng.ReverseEngConstants;

Expand Down Expand Up @@ -159,6 +160,21 @@ public MultiStatus execute() {
getExtensionAssistant().setPropertyValue(
stagingTable, InfinispanCacheModelExtensionConstants.PropertyIds.PRIMARY_TABLE, modelName + StringConstants.DOT + selectedViewOrTable.getName());

/*
"teiid_rel:MATVIEW_AFTER_LOAD_SCRIPT" 'execute {jdgsourcemodelname}.native(''swap cache names'');'
"teiid_rel:MATVIEW_BEFORE_LOAD_SCRIPT" 'execute {jdgsourcemodelname}.native(''truncate cache'');',
"teiid_rel:MATERIALIZED_STAGE_TABLE" '{jdgsourcemodelname}.{stagingTable}')
where {jdgsourcemodelname} as the new JDG Source Model that is created.
*/
String afterLoadScriptStr = "execute " + sourceModelName + ".native(\'\'swap cache names\'\');";
String beforeLoadScriptStr = "execute " + sourceModelName + ".native(\'\'truncate cache\'\');";
String stageTableStr = sourceModelName + "." + stagingTable.getName();

ModelObjectExtensionAssistant assistant = getRelationalExtensionAssistant();
assistant.setPropertyValue(selectedViewOrTable, RelationalModelExtensionConstants.PropertyIds.MATVIEW_AFTER_LOAD_SCRIPT, afterLoadScriptStr);
assistant.setPropertyValue(selectedViewOrTable, RelationalModelExtensionConstants.PropertyIds.MATVIEW_BEFORE_LOAD_SCRIPT, beforeLoadScriptStr);
assistant.setPropertyValue(selectedViewOrTable, RelationalModelExtensionConstants.PropertyIds.MATERIALIZED_STAGE_TABLE, stageTableStr);

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

Expand Down Expand Up @@ -243,7 +259,7 @@ private void addValue(final Object owner, final Object value, EList feature) {
}

protected void copyTableValues(final Table orig, final Table copy) {
copy.setNameInSource( orig.getNameInSource() );
//copy.setNameInSource( orig.getNameInSource() ); // Materialized Tables do not represent DB schema or tables so DO NOT SET
copy.setCardinality(orig.getCardinality() );
copy.setSystem(orig.isSystem() );
// Defect 16941 - the supportsUpdate flag should always be true for a materialization table
Expand All @@ -264,7 +280,7 @@ private void copyColValues(final Column orig, final Column copy) {
copy.setMaximumValue(orig.getMaximumValue() );
copy.setMinimumValue(orig.getMinimumValue() );
copy.setName(orig.getName() );
copy.setNameInSource(orig.getNameInSource() );
// copy.setNameInSource(orig.getNameInSource() ); // Materialized Tables do not represent DB schema or tables so DO NOT SET
copy.setNativeType(orig.getNativeType() );
copy.setNullable(orig.getNullable() );
copy.setPrecision(orig.getPrecision() );
Expand Down Expand Up @@ -523,4 +539,9 @@ private ModelObjectExtensionAssistant getExtensionAssistant() {
final ModelExtensionRegistry registry = ExtensionPlugin.getInstance().getRegistry();
return (ModelObjectExtensionAssistant)registry.getModelExtensionAssistant(INFINISPAN_EXT_ASSISTANT_NS);
}

private ModelObjectExtensionAssistant getRelationalExtensionAssistant() {
final ModelExtensionRegistry registry = ExtensionPlugin.getInstance().getRegistry();
return (ModelObjectExtensionAssistant)registry.getModelExtensionAssistant(RELATIONAL_EXT_ASSISTANT_NS);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public interface ReverseEngConstants {

String INFINISPAN_EXT_ASSISTANT_NS = "infinispan"; //$NON-NLS-1$

String RELATIONAL_EXT_ASSISTANT_NS = "relational"; //$NON-NLS-1$

public enum Mode {
MATERIALIZE,
POJO
Expand Down

0 comments on commit bd49295

Please sign in to comment.