-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TEIIDDES-2683 Added excel.mxd to Designer's list of built-in MEDs
- Loading branch information
Showing
4 changed files
with
189 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
plugins/org.teiid.designer.metamodels.relational/excel.mxd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<modelExtension xmlns:p="http://www.jboss.org/teiiddesigner/ext/2012" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" metamodelUri="http://www.metamatrix.com/metamodels/Relational" namespacePrefix="excel" namespaceUri="http://www.teiid.org/translator/excel/2014" version="1" xsi:schemaLocation="http://www.jboss.org/teiiddesigner/ext/2012 http://www.jboss.org/teiiddesigner/ext/2012/modelExtension.xsd" xmlns="http://www.jboss.org/teiiddesigner/ext/2012"> | ||
<p:modelType>PHYSICAL</p:modelType> | ||
<p:extendedMetaclass name="org.teiid.designer.metamodels.relational.impl.ColumnImpl"> | ||
<p:property advanced="false" index="true" masked="false" name="CELL_NUMBER" required="true" type="integer"> | ||
<p:description locale="en_US">The column cell number</p:description> | ||
<p:display locale="en_US">Cell Number</p:display> | ||
</p:property> | ||
</p:extendedMetaclass> | ||
<p:extendedMetaclass name="org.teiid.designer.metamodels.relational.impl.BaseTableImpl"> | ||
<p:property advanced="false" index="true" masked="false" name="FILE" required="true" type="string"> | ||
<p:description locale="en_US">The Excel full file name and path</p:description> | ||
<p:display locale="en_US">File</p:display> | ||
</p:property> | ||
<p:property advanced="false" index="true" masked="false" name="FIRST_DATA_ROW_NUMBER" required="false" type="integer"> | ||
<p:description locale="en_US">First data row number</p:description> | ||
<p:display locale="en_US">First Data Row</p:display> | ||
</p:property> | ||
</p:extendedMetaclass> | ||
</modelExtension> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
.../src/org/teiid/designer/metamodels/relational/extension/ExcelModelExtensionAssistant.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
package org.teiid.designer.metamodels.relational.extension; | ||
|
||
import org.eclipse.core.resources.IResource; | ||
import org.eclipse.emf.ecore.EObject; | ||
import org.teiid.core.designer.util.CoreArgCheck; | ||
import org.teiid.designer.core.ModelerCore; | ||
import org.teiid.designer.core.extension.EmfModelObjectExtensionAssistant; | ||
import org.teiid.designer.core.workspace.ModelResource; | ||
import org.teiid.designer.core.workspace.ModelUtil; | ||
import org.teiid.designer.extension.ExtensionConstants; | ||
import org.teiid.designer.extension.ExtensionPlugin; | ||
import org.teiid.designer.extension.properties.ModelExtensionPropertyDefinition; | ||
import org.teiid.designer.extension.registry.ModelExtensionRegistry; | ||
import org.teiid.designer.metamodels.core.ModelType; | ||
import org.teiid.designer.metamodels.relational.Column; | ||
import org.teiid.designer.metamodels.relational.Procedure; | ||
import org.teiid.designer.metamodels.relational.RelationalPackage; | ||
import org.teiid.designer.metamodels.relational.RelationalPlugin; | ||
import org.teiid.designer.metamodels.relational.Table; | ||
|
||
public class ExcelModelExtensionAssistant extends EmfModelObjectExtensionAssistant implements ExcelModelExtensionConstants { | ||
|
||
/** | ||
* Saves the relational MED to a model if necessary. | ||
* @param model the model being checked (can be <code>null</code>) | ||
* @throws Exception if there is an error applying MED | ||
*/ | ||
public void applyMedIfNecessary(final IResource model) throws Exception { | ||
if (model != null) { | ||
final ModelResource modelResource = ModelerCore.getModelWorkspace().findModelResource(model); | ||
|
||
if (modelResource != null && !modelResource.isReadOnly()) { | ||
if ((ModelType.VIRTUAL_LITERAL == modelResource.getModelType()) | ||
&& RelationalPackage.eNS_URI.equals(modelResource.getPrimaryMetamodelUri()) && !supportsMyNamespace(model)) { | ||
saveModelExtensionDefinition(model); | ||
} | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
* | ||
* @see org.teiid.designer.core.extension.EmfModelObjectExtensionAssistant#getPropertyDefinition(java.lang.Object, java.lang.String) | ||
*/ | ||
@Override | ||
protected ModelExtensionPropertyDefinition getPropertyDefinition(final Object modelObject, | ||
final String propId) throws Exception { | ||
CoreArgCheck.isInstanceOf(EObject.class, modelObject); | ||
|
||
// make sure there is a property definition first | ||
final ModelExtensionPropertyDefinition propDefn = super.getPropertyDefinition(modelObject, propId); | ||
|
||
if (propDefn != null) { | ||
// must be procedure in a virtual model | ||
if (ModelUtil.isPhysical(modelObject)) { | ||
if( PropertyIds.CELL_NUMBER.equals(propId) && | ||
modelObject instanceof Column ) { | ||
return propDefn; | ||
} else if( (PropertyIds.FILE.equals(propId) || | ||
PropertyIds.FIRST_DATA_ROW_NUMBER.equals(propId)) && | ||
modelObject instanceof Table) { | ||
return propDefn; | ||
} | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public static ExcelModelExtensionAssistant getExcelAssistant() { | ||
final ModelExtensionRegistry registry = ExtensionPlugin.getInstance().getRegistry(); | ||
final String prefix = NAMESPACE_PROVIDER.getNamespacePrefix(); | ||
return (ExcelModelExtensionAssistant)registry.getModelExtensionAssistant(prefix); | ||
} | ||
|
||
|
||
public static boolean setExcelProperty(EObject eObj, String id, String value) { | ||
final ExcelModelExtensionAssistant assistant = getExcelAssistant(); | ||
if( assistant != null ) { | ||
try { | ||
assistant.setPropertyValue(eObj, id, value); | ||
} catch (Exception e) { | ||
RelationalPlugin.Util.log(e); | ||
return false; | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
|
||
public static String getExcelProperty(EObject eObj, String key) { | ||
String result = null; | ||
final ExcelModelExtensionAssistant assistant = getExcelAssistant(); | ||
if( assistant != null ) { | ||
try { | ||
result = assistant.getPropertyValue(eObj, key); | ||
} catch (Exception e) { | ||
RelationalPlugin.Util.log(e); | ||
} | ||
} | ||
|
||
return result; | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
.../src/org/teiid/designer/metamodels/relational/extension/ExcelModelExtensionConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package org.teiid.designer.metamodels.relational.extension; | ||
|
||
import org.teiid.designer.extension.properties.ModelExtensionPropertyDefinition; | ||
import org.teiid.designer.extension.properties.NamespaceProvider; | ||
|
||
public interface ExcelModelExtensionConstants{ | ||
String MED_PROBLEM_MARKER_ID = "org.teiid.designer.extension.ui.medMarker"; //$NON-NLS-1$ | ||
|
||
/** | ||
* | ||
*/ | ||
NamespaceProvider NAMESPACE_PROVIDER = new NamespaceProvider() { | ||
|
||
/** | ||
* {@inheritDoc} | ||
* | ||
* @see org.teiid.designer.extension.properties.NamespaceProvider#getNamespacePrefix() | ||
*/ | ||
@Override | ||
public String getNamespacePrefix() { | ||
return "excel"; //$NON-NLS-1$ | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
* | ||
* @see org.teiid.designer.extension.properties.NamespaceProvider#getNamespaceUri() | ||
*/ | ||
@Override | ||
public String getNamespaceUri() { | ||
return "http://www.jboss.org/teiiddesigner/ext/rest/2012"; //$NON-NLS-1$ | ||
} | ||
}; | ||
|
||
/** | ||
* The fully qualified extension property definition identifiers. | ||
*/ | ||
interface PropertyIds { | ||
|
||
/** | ||
* The property definition identifer for the excel table cell number. Applies to column | ||
*/ | ||
String CELL_NUMBER = ModelExtensionPropertyDefinition.Utils.getPropertyId(NAMESPACE_PROVIDER, "CELL_NUMBER"); //$NON-NLS-1$ | ||
|
||
/** | ||
* The property definition identifer for the excel table cell number. | ||
*/ | ||
String FILE = ModelExtensionPropertyDefinition.Utils.getPropertyId(NAMESPACE_PROVIDER, "FILE"); //$NON-NLS-1$ | ||
|
||
/** | ||
* The property definition identifer for the excel table cell number. | ||
*/ | ||
String FIRST_DATA_ROW_NUMBER = ModelExtensionPropertyDefinition.Utils.getPropertyId(NAMESPACE_PROVIDER, "FIRST_DATA_ROW_NUMBER"); //$NON-NLS-1$ | ||
|
||
} | ||
|
||
} |