use of org.obeonetwork.dsl.database.Table in project InformationSystem by ObeoNetwork.
the class DatabaseServices method allSelectableExternalTables.
/**
* Retrieve all non referenced external tables excluding those already displayed on the diagram
* @param context the Table Container
* @param diagram DSemanticDiagram diagram used to check for already displayed tables
* @return List of tables
*/
public List<Table> allSelectableExternalTables(TableContainer context, DSemanticDiagram diagram) {
// Retrieve all non Referenced External Tables
List<Table> allNonReferencedExternalTables = allNonReferencedExternalTables(context);
List<Table> tablesInDiagram = new ArrayList<Table>();
// Retrieve all AbstracteDNode contained in diagram.
List<EObject> allDNodes = EcoreServices.eAllContents(diagram, AbstractDNode.class);
for (EObject node : allDNodes) {
// Retrieve all tables contained in AbstractDNode
if (((AbstractDNode) node).getTarget() instanceof Table) {
tablesInDiagram.add((Table) ((AbstractDNode) node).getTarget());
}
}
// Remove all tables contained in AbstractDNode present in allNonReferencedExternalTables
allNonReferencedExternalTables.removeAll(tablesInDiagram);
return allNonReferencedExternalTables;
}
use of org.obeonetwork.dsl.database.Table in project InformationSystem by ObeoNetwork.
the class DatabaseServices method allReferencedTables.
/**
* Retrieve all referenced Tables.
* @param context the Table Container
* @return list of Tables
*/
public List<Table> allReferencedTables(TableContainer context) {
// Retrieve all tables
List<AbstractTable> abstractTables = context.getTables();
List<Table> tables = new ArrayList<Table>();
List<Table> tablesFKtarget = new ArrayList<Table>();
// Retrieve all tables instance of Table
for (AbstractTable abstractTable : abstractTables) {
if (abstractTable instanceof Table) {
tables.add((Table) abstractTable);
}
}
// Retrieve all foreigns keys for the tables
for (Table table : tables) {
for (ForeignKey fk : table.getForeignKeys()) {
if (!tablesFKtarget.contains(fk.getTarget())) {
// retrieve all table from target of foreigns keys
tablesFKtarget.add(fk.getTarget());
}
}
}
Set<Table> allReferencedTables = new HashSet<Table>();
// Remove duplicates
allReferencedTables.addAll(tablesFKtarget);
return new ArrayList<Table>(allReferencedTables);
}
use of org.obeonetwork.dsl.database.Table in project InformationSystem by ObeoNetwork.
the class DatabaseServices method getForeignKeys.
/**
* Return ForeignKeys from tables.
* @param tableContainer
* @return foreignKeys
*/
public List<ForeignKey> getForeignKeys(TableContainer tableContainer, DSemanticDiagram diagram) {
List<ForeignKey> foreignKeys = new ArrayList<ForeignKey>();
List<AbstractTable> tables = tableContainer.getTables();
for (AbstractTable abstractTable : tables) {
if (abstractTable instanceof Table) {
foreignKeys.addAll(((Table) abstractTable).getForeignKeys());
}
}
// Foreign keys from external tables on diagram
for (DDiagramElement diagramElement : diagram.getDiagramElements()) {
EObject semanticElt = diagramElement.getTarget();
if (semanticElt instanceof Table) {
foreignKeys.addAll(((Table) semanticElt).getForeignKeys());
}
}
return foreignKeys;
}
use of org.obeonetwork.dsl.database.Table in project InformationSystem by ObeoNetwork.
the class DatabaseServices method allTables.
/**
* Retrieve all Tables.
* @param context the Table Container
* @return list of Tables
*/
public List<Table> allTables(TableContainer context) {
EcoreServices ecoreServices = new EcoreServices();
// Retrieve all roots from context
Collection<EObject> allRoots = ecoreServices.allRoots(context);
List<Table> tables = new ArrayList<Table>();
// Retrieve all Tables contained in all roots
for (EObject object : allRoots) {
List<Table> allContainedTables = new ArrayList<Table>();
for (EObject obj : EcoreServices.eAllContents(object, Table.class)) {
allContainedTables.add((Table) obj);
}
tables.addAll(allContainedTables);
}
return tables;
}
use of org.obeonetwork.dsl.database.Table in project InformationSystem by ObeoNetwork.
the class TableConstraintsPropertiesEditionComponent method initPart.
/**
* {@inheritDoc}
*
* @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#initPart(java.lang.Object, int, org.eclipse.emf.ecore.EObject,
* org.eclipse.emf.ecore.resource.ResourceSet)
*/
public void initPart(Object key, int kind, EObject elt, ResourceSet allResource) {
setInitializing(true);
if (editingPart != null && key == partKey) {
editingPart.setContext(elt, allResource);
final Table table = (Table) elt;
final ConstraintsPropertiesEditionPart constraintsPart = (ConstraintsPropertiesEditionPart) editingPart;
// init values
if (isAccessible(DatabaseViewsRepository.Constraints.Properties.constraints_)) {
constraintsSettings = new ReferencesTableSettings(table, DatabasePackage.eINSTANCE.getTable_Constraints());
constraintsPart.initConstraints(constraintsSettings);
}
// init filters
if (isAccessible(DatabaseViewsRepository.Constraints.Properties.constraints_)) {
constraintsPart.addFilterToConstraints(new ViewerFilter() {
/**
* {@inheritDoc}
*
* @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
public boolean select(Viewer viewer, Object parentElement, Object element) {
// $NON-NLS-1$
return (element instanceof String && element.equals("")) || (element instanceof Constraint);
}
});
// Start of user code for additional businessfilters for constraints
// End of user code
}
// init values for referenced views
// init filters for referenced views
}
setInitializing(false);
}
Aggregations