use of org.obeonetwork.dsl.database.spec.ViewSpec in project InformationSystem by ObeoNetwork.
the class DatabaseFactoryImpl method createView.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
public View createView() {
ViewSpec view = new ViewSpec();
view.setTechID(EcoreUtil.generateUUID());
return view;
}
use of org.obeonetwork.dsl.database.spec.ViewSpec in project InformationSystem by ObeoNetwork.
the class DatabaseServices method initializeViewContent.
/**
* Initialize the content of a view.
*
* Tables and Columns are transient and not saved.
* They need to be be computed at the opening of the diagram.
* @param view to initialize.
*/
private void initializeViewContent(View view) {
/* The tables and the columns references are transient.
* Initializing the transient reference is a workaround
* to avoid some diagram refresh problems.
* The initializing need to be done only one time.
*/
ViewSpec viewSpec = (ViewSpec) view;
if (viewSpec.initialized == false) {
// Clear view content
if (viewSpec.getColumns() != null) {
viewSpec.getColumns().clear();
}
if (viewSpec.getTables() != null) {
viewSpec.getTables().clear();
}
// Parse new query and update view content
String query = viewSpec.getQuery();
if (!Strings.isNullOrEmpty(query)) {
ViewContentProvider viewContentProvider = new ViewContentProvider();
viewContentProvider.parseViewQuery(viewSpec.getQuery());
List<ColObject> listOfColumns = viewContentProvider.getColumns();
if (listOfColumns != null) {
for (ColObject column : listOfColumns) {
ViewElement elem = DatabaseFactory.eINSTANCE.createViewElement();
elem.setName(column.getName());
elem.setAlias(column.getAlias());
viewSpec.getColumns().add(elem);
}
}
List<String> listOfTables = viewContentProvider.getTables();
if (listOfTables != null) {
for (String table : listOfTables) {
ViewElement elem = DatabaseFactory.eINSTANCE.createViewElement();
elem.setName(table);
viewSpec.getTables().add(elem);
}
}
}
// The initialization was done update boolean.
viewSpec.initialized = true;
}
}
Aggregations