use of org.obeonetwork.dsl.database.Column in project InformationSystem by ObeoNetwork.
the class DatabaseServices method createForeignKey.
public ForeignKey createForeignKey(Table source, Table target) {
ForeignKey fk = DatabaseFactory.eINSTANCE.createForeignKey();
source.getForeignKeys().add(fk);
fk.setTarget(target);
// Initialize with columns
if (target.getPrimaryKey() != null) {
for (Column pkColumn : target.getPrimaryKey().getColumns()) {
Column fkColumn = getOrCreateColumn(source, pkColumn);
if (pkColumn != null && fkColumn != null) {
ForeignKeyElement fke = DatabaseFactory.eINSTANCE.createForeignKeyElement();
fke.setPkColumn(pkColumn);
fke.setFkColumn(fkColumn);
fk.getElements().add(fke);
}
}
}
return fk;
}
use of org.obeonetwork.dsl.database.Column in project InformationSystem by ObeoNetwork.
the class IndexElementPropertiesEditionComponent 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 IndexElement indexElement = (IndexElement) elt;
final IndexElementPropertiesEditionPart indexElementPart = (IndexElementPropertiesEditionPart) editingPart;
// init values
if (isAccessible(DatabaseViewsRepository.IndexElement.Properties.column)) {
// init part
columnSettings = new EObjectFlatComboSettings(indexElement, DatabasePackage.eINSTANCE.getIndexElement_Column());
indexElementPart.initColumn(columnSettings);
// set the button mode
indexElementPart.setColumnButtonMode(ButtonsModeEnum.BROWSE);
}
if (isAccessible(DatabaseViewsRepository.IndexElement.Properties.asc)) {
indexElementPart.setAsc(indexElement.isAsc());
}
if (isAccessible(DatabaseViewsRepository.IndexElement.Properties.comments))
indexElementPart.setComments(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, indexElement.getComments()));
// init filters
if (isAccessible(DatabaseViewsRepository.IndexElement.Properties.column)) {
indexElementPart.addFilterToColumn(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 Column);
}
});
// Start of user code for additional businessfilters for column
// End of user code
}
// init values for referenced views
// init filters for referenced views
}
setInitializing(false);
}
use of org.obeonetwork.dsl.database.Column in project InformationSystem by ObeoNetwork.
the class TableTablePropertiesEditionComponent 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 TablePropertiesEditionPart tablePart = (TablePropertiesEditionPart) editingPart;
// init values
if (isAccessible(DatabaseViewsRepository.Table.Properties.name))
tablePart.setName(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, table.getName()));
if (isAccessible(DatabaseViewsRepository.Table.Properties.columns)) {
columnsSettings = new ReferencesTableSettings(table, DatabasePackage.eINSTANCE.getTable_Columns());
tablePart.initColumns(columnsSettings);
}
if (isAccessible(DatabaseViewsRepository.Table.Properties.comments))
tablePart.setComments(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, table.getComments()));
if (isAccessible(DatabaseViewsRepository.Table.Properties.columns)) {
tablePart.addFilterToColumns(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 Column);
}
});
// Start of user code for additional businessfilters for columns
// End of user code
}
// init values for referenced views
// init filters for referenced views
}
setInitializing(false);
}
use of org.obeonetwork.dsl.database.Column in project InformationSystem by ObeoNetwork.
the class AbstractTransformation method removeOldObjects.
private void removeOldObjects() {
// Traverse the whole target resource to remove objects which have not been reused or created by this transformation
Collection<EObject> objectsToKeep = new ArrayList<EObject>();
objectsToKeep.addAll(outputTraceabilityMap.values());
objectsToKeep.addAll(objectsToBeKept);
Collection<EObject> objectsToBeDeleted = new ArrayList<EObject>();
for (Iterator<EObject> it = getResult().getAllContents(); it.hasNext(); ) {
EObject object = it.next();
if (object instanceof Entity || object instanceof Attribute || object instanceof Reference || object instanceof Table || object instanceof Column || object instanceof ForeignKey || object instanceof Index || object instanceof Constraint) {
if (!objectsToKeep.contains(object)) {
objectsToBeDeleted.add(object);
}
}
}
// Remove objects
Session session = SessionManager.INSTANCE.getSession(scaffoldInfo);
for (EObject objectToBeDeleted : objectsToBeDeleted) {
deleteObject(objectToBeDeleted, session);
}
}
use of org.obeonetwork.dsl.database.Column in project InformationSystem by ObeoNetwork.
the class EntityToMLD method createColumn.
private void createColumn(Attribute attribute, Table table) {
// Try to retrieve existing column
Column column = getFromInputTraceabilityMap(attribute, DatabasePackage.Literals.COLUMN);
if (column != null) {
// Ensure the column is in the right table
if (!EcoreUtil.equals(table, column.getOwner())) {
table.getColumns().add(column);
}
} else {
// The column does not already exist, we have to create a new one
column = DatabaseFactory.eINSTANCE.createColumn();
table.getColumns().add(column);
}
// Add to the new traceability map
addToOutputTraceability(attribute, column);
// The following properties are modified even if they were already valued
column.setName(LabelProvider.getColumnNameFromAttribute(attribute));
column.setComments(attribute.getDescription());
column.setDefaultValue(AnnotationHelper.getPhysicalDefault(attribute));
boolean nullable = hasZeroAsLowerMultiplicityBound(attribute);
column.setNullable(nullable);
// Add to PK when needed
if (attribute.isIsIdentifier()) {
column.addToPrimaryKey();
if (column.getComments() == null || column.getComments().length() == 0) {
column.setComments(getPKColumnComment(column));
}
}
if (attribute.getType() instanceof Enumeration) {
handleEnumType(column, (Enumeration) attribute.getType(), table);
} else {
column.setType(resolveType(attribute.getType(), AnnotationHelper.getPhysicalSize(attribute)));
}
}
Aggregations