use of org.obeonetwork.dsl.database.Index in project InformationSystem by ObeoNetwork.
the class DatabaseLabelServices method caseColumn.
@Override
public String caseColumn(Column column) {
String label = caseNamedElement(column);
label += " : ";
String typeLabel = "undefined";
if (column.getType() != null) {
typeLabel = adapterFactoryLabelProvider.getText(column.getType());
}
label += typeLabel;
if (!column.getIndexes().isEmpty() && diagram != null && isIndexLayerActive(diagram.getOwnedDiagramElements().get(0))) {
String indexesLabel = " <";
boolean isFirst = true;
for (Index index : column.getIndexes()) {
EList<Index> indexes = index.getOwner().getIndexes();
int i = indexes.indexOf(index) + 1;
if (isFirst == true) {
indexesLabel += "i" + i;
isFirst = false;
} else {
indexesLabel += ", i" + i;
}
}
indexesLabel += ">";
label += indexesLabel;
}
return label;
}
use of org.obeonetwork.dsl.database.Index in project InformationSystem by ObeoNetwork.
the class IndexPropertiesEditionComponent 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 Index index = (Index) elt;
final IndexPropertiesEditionPart indexPart = (IndexPropertiesEditionPart) editingPart;
// init values
if (isAccessible(DatabaseViewsRepository.Index.Properties.name))
indexPart.setName(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, index.getName()));
if (isAccessible(DatabaseViewsRepository.Index.Properties.qualifier))
indexPart.setQualifier(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, index.getQualifier()));
if (isAccessible(DatabaseViewsRepository.Index.Properties.unique)) {
indexPart.setUnique(index.isUnique());
}
if (isAccessible(DatabaseViewsRepository.Index.Properties.cardinality)) {
indexPart.setCardinality(EEFConverterUtil.convertToString(EcorePackage.Literals.EINT, index.getCardinality()));
}
if (isAccessible(DatabaseViewsRepository.Index.Properties.indexType))
indexPart.setIndexType(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, index.getIndexType()));
if (isAccessible(DatabaseViewsRepository.Index.Properties.comments))
indexPart.setComments(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, index.getComments()));
if (isAccessible(DatabaseViewsRepository.Index.Properties.elements)) {
elementsSettings = new ReferencesTableSettings(index, DatabasePackage.eINSTANCE.getIndex_Elements());
indexPart.initElements(elementsSettings);
}
if (isAccessible(DatabaseViewsRepository.Index.Properties.elements)) {
indexPart.addFilterToElements(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 IndexElement);
}
});
// Start of user code for additional businessfilters for elements
// End of user code
}
// init values for referenced views
// init filters for referenced views
}
setInitializing(false);
}
use of org.obeonetwork.dsl.database.Index 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.Index in project InformationSystem by ObeoNetwork.
the class MpdToMldBidiRules method createTable.
private void createTable(Table sourceTable, TableContainer targetTableContainer) {
Table targetTable = getFromInputTraceabilityMap(sourceTable, DatabasePackage.Literals.TABLE);
if (targetTable != null) {
// Reuse existing table
} else {
// Create a new table
targetTable = DatabaseFactory.eINSTANCE.createTable();
targetTableContainer.getTables().add(targetTable);
}
addToOutputTraceability(sourceTable, targetTable);
targetTable.setName(sourceTable.getName());
targetTable.setComments(sourceTable.getComments());
for (Column column : sourceTable.getColumns()) {
createColumn(column, targetTable);
}
if (sourceTable.getPrimaryKey() != null) {
createPK(sourceTable.getPrimaryKey(), targetTable);
}
for (Index index : sourceTable.getIndexes()) {
createIndex(index, targetTable);
}
for (Constraint constraint : sourceTable.getConstraints()) {
createConstraint(constraint, targetTable);
}
}
use of org.obeonetwork.dsl.database.Index in project InformationSystem by ObeoNetwork.
the class MpdToMldBidiRules method createIndex.
private void createIndex(Index sourceIndex, Table targetTable) {
Index targetIndex = getFromInputTraceabilityMap(sourceIndex, DatabasePackage.Literals.INDEX);
if (targetIndex != null) {
// Ensure it is in the right index
if (!EcoreUtil.equals(targetIndex.getOwner(), targetTable)) {
targetTable.getIndexes().add(targetIndex);
}
} else {
// We have to create a new index
targetIndex = DatabaseFactory.eINSTANCE.createIndex();
targetTable.getIndexes().add(targetIndex);
}
addToOutputTraceability(sourceIndex, targetIndex);
targetIndex.setCardinality(sourceIndex.getCardinality());
targetIndex.setComments(sourceIndex.getComments());
targetIndex.setIndexType(sourceIndex.getIndexType());
targetIndex.setName(sourceIndex.getName());
targetIndex.setQualifier(sourceIndex.getQualifier());
targetIndex.setUnique(sourceIndex.isUnique());
for (IndexElement indexElt : sourceIndex.getElements()) {
createIndexElement(indexElt, targetIndex);
}
}
Aggregations