Skip to content

Commit

Permalink
TEIIDDES-2524 added additional support for CREATE VIRTUAL PROCEDURE to
Browse files Browse the repository at this point in the history
ddl export
  • Loading branch information
blafond committed Oct 19, 2015
1 parent cf863df commit fce55a0
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 8 deletions.
Expand Up @@ -598,4 +598,10 @@ public boolean supportsMyNamespace( Object modelObject ) throws Exception {
return ModelExtensionUtils.isSupportedNamespace(modelResource, getNamespacePrefix());
}

@Override
public boolean supportsProperty(Object modelObject, String propId)
throws Exception {
return getPropertyDefinition(modelObject, propId) != null;
}

}
Expand Up @@ -378,7 +378,7 @@ class CheckboxTreeLabelProvider extends LabelProvider {
private final Image PROCEDURE_IMG = UiPlugin.getDefault().getImage(UiConstants.Images.PROCEDURE_ICON);
private final Image INDEX_IMG = UiPlugin.getDefault().getImage(UiConstants.Images.INDEX_ICON);
private final Image VIEW_TABLE_IMG = UiPlugin.getDefault().getImage(UiConstants.Images.VIRTUAL_TABLE_ICON);

private final Image VIRTUAL_PROCEDURE_IMG = UiPlugin.getDefault().getImage(UiConstants.Images.VIRTUAL_PROCEDURE_ICON);

@Override
public Image getImage( final Object node ) {
Expand All @@ -397,6 +397,9 @@ public Image getImage( final Object node ) {
}
return VIEW_IMG;
} else if(type==RelationalConstants.TYPES.PROCEDURE) {
if( importer.modelType() == ModelType.VIRTUAL_LITERAL) {
return VIRTUAL_PROCEDURE_IMG;
}
return PROCEDURE_IMG;
} else if(type==RelationalConstants.TYPES.INDEX) {
return INDEX_IMG;
Expand Down
Expand Up @@ -209,6 +209,7 @@ public void importDdl(String ddl, IProgressMonitor monitor, int totalWork, Prope
importManager.setRelationalModel(model);

RelationalModel targetRelationalModel = importManager.getObjectFactory().createRelationalModel(model);
targetRelationalModel.setModelType(importManager.getModelType().getValue());

importManager.setProgressMonitor(monitor);

Expand Down
Expand Up @@ -304,12 +304,12 @@ public EObject createObject( RelationalReference relationalRef, ModelResource mo
modelResource.getEmfResource().getContents().add(newEObject);
} break;
case TYPES.PROCEDURE: {
if (relationalRef instanceof RelationalViewProcedure) {
newEObject = VIEW_MODEL_FACTORY.buildObject(relationalRef, modelResource, new NullProgressMonitor());
} else {
newEObject = createProcedure(relationalRef, modelResource);
modelResource.getEmfResource().getContents().add(newEObject);
}
if( relationalRef instanceof RelationalViewProcedure ) {
newEObject = VIEW_MODEL_FACTORY.buildObject(relationalRef, modelResource, new NullProgressMonitor());
} else {
newEObject = createProcedure(relationalRef, modelResource);
modelResource.getEmfResource().getContents().add(newEObject);
}
} break;

case TYPES.INDEX: {
Expand Down Expand Up @@ -1211,7 +1211,9 @@ private void setPropertyValue(ModelObjectExtensionAssistant assistant, EObject e
}

try {
assistant.setPropertyValue(eObject, namespacedId, propValue);
if( assistant.supportsProperty(eObject, propId) ) {
assistant.setPropertyValue(eObject, namespacedId, propValue);
}
} catch (Exception ex) {
RelationalPlugin.Util.log(IStatus.ERROR,ex,
NLS.bind(Messages.emfModelGenerator_errorSettingPropertyValue, namespacedId));
Expand Down
Expand Up @@ -558,6 +558,37 @@ protected RelationalProcedure createProcedure( AstNode procedureNode, Relational

return procedure;
}

/**
* Create a RelationalProcedure
* @param procedureNode the AstNode for the procedure
* @param model the RelationalModel
* @return the RelationalProcedure
*
* @throws Exception
*/
protected RelationalProcedure createViewProcedure( AstNode procedureNode, RelationalModel model) throws Exception {
RelationalProcedure procedure = getFactory().createViewProcedure();
Info info = createInfo(procedureNode, model);
if (info.getSchema() == null)
model.addChild(procedure);
else {
info.getSchema().getProcedures().add(procedure);
procedure.setParent(info.getSchema());
}

initialize(procedure, procedureNode, info.getName());
// TODO: determine how to handle Procedure StatementOption
// TODO: determine how to handle Procedure Statement

if (procedureNode.getProperty(StandardDdlLexicon.DATATYPE_NAME) != null) {
RelationalProcedureResultSet result = getFactory().createProcedureResultSet();
procedure.setResultSet(result);
initialize(result, procedureNode);
}

return procedure;
}

/**
* Perform the import
Expand Down
Expand Up @@ -18,6 +18,7 @@
import java.util.List;
import java.util.Map;
import java.util.Properties;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceVisitor;
Expand Down Expand Up @@ -712,6 +713,17 @@ public boolean supportsMedOperation( String proposedOperationName,
public boolean supportsMyNamespace( Object modelObject ) throws Exception {
return false;
}

/**
* {@inheritDoc}
*
*/
@Override
public boolean supportsProperty(Object modelObject, String propId)
throws Exception {
// TODO Auto-generated method stub
return false;
}

}

Expand Down
Expand Up @@ -170,4 +170,7 @@ public abstract void setPropertyValue( Object modelObject,
public void applyMedIfNecessary(IResource model) throws Exception {
// Do nothing by default
}

public abstract boolean supportsProperty(Object modelObject,
String propId ) throws Exception;
}
Expand Up @@ -270,4 +270,11 @@ public boolean supportsMedOperation(String proposedOperationName,
CoreArgCheck.isNotEmpty(proposedOperationName, "proposedOperationName is empty"); //$NON-NLS-1$
return ExtensionConstants.MedOperations.SHOW_IN_REGISTRY.equals(proposedOperationName); // only show in registry
}


@Override
public boolean supportsProperty(Object modelObject, String propId)
throws Exception {
return getPropertyDefinition(modelObject, propId) != null;
}
}

0 comments on commit fce55a0

Please sign in to comment.