Search in sources :

Example 1 with Index

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;
}
Also used : Index(org.obeonetwork.dsl.database.Index)

Example 2 with Index

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);
}
Also used : IndexPropertiesEditionPart(org.obeonetwork.dsl.database.parts.IndexPropertiesEditionPart) ReferencesTableSettings(org.eclipse.emf.eef.runtime.ui.widgets.referencestable.ReferencesTableSettings) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) Index(org.obeonetwork.dsl.database.Index) Viewer(org.eclipse.jface.viewers.Viewer) EObject(org.eclipse.emf.ecore.EObject) IndexElement(org.obeonetwork.dsl.database.IndexElement)

Example 3 with Index

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);
    }
}
Also used : Entity(org.obeonetwork.dsl.entity.Entity) Table(org.obeonetwork.dsl.database.Table) Attribute(org.obeonetwork.dsl.environment.Attribute) Constraint(org.obeonetwork.dsl.database.Constraint) Reference(org.obeonetwork.dsl.environment.Reference) ArrayList(java.util.ArrayList) Index(org.obeonetwork.dsl.database.Index) ForeignKey(org.obeonetwork.dsl.database.ForeignKey) Column(org.obeonetwork.dsl.database.Column) EObject(org.eclipse.emf.ecore.EObject) Session(org.eclipse.sirius.business.api.session.Session)

Example 4 with Index

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);
    }
}
Also used : Table(org.obeonetwork.dsl.database.Table) AbstractTable(org.obeonetwork.dsl.database.AbstractTable) Column(org.obeonetwork.dsl.database.Column) Constraint(org.obeonetwork.dsl.database.Constraint) Index(org.obeonetwork.dsl.database.Index)

Example 5 with Index

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);
    }
}
Also used : Index(org.obeonetwork.dsl.database.Index) IndexElement(org.obeonetwork.dsl.database.IndexElement)

Aggregations

Index (org.obeonetwork.dsl.database.Index)20 IndexElement (org.obeonetwork.dsl.database.IndexElement)7 Table (org.obeonetwork.dsl.database.Table)7 EObject (org.eclipse.emf.ecore.EObject)5 Column (org.obeonetwork.dsl.database.Column)4 ArrayList (java.util.ArrayList)3 ForeignKey (org.obeonetwork.dsl.database.ForeignKey)3 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)2 EObjectPropertiesEditionContext (org.eclipse.emf.eef.runtime.context.impl.EObjectPropertiesEditionContext)2 EReferencePropertiesEditionContext (org.eclipse.emf.eef.runtime.context.impl.EReferencePropertiesEditionContext)2 PropertiesEditingPolicy (org.eclipse.emf.eef.runtime.policies.PropertiesEditingPolicy)2 CreateEditingPolicy (org.eclipse.emf.eef.runtime.policies.impl.CreateEditingPolicy)2 PropertiesEditingProvider (org.eclipse.emf.eef.runtime.providers.PropertiesEditingProvider)2 ReferencesTableSettings (org.eclipse.emf.eef.runtime.ui.widgets.referencestable.ReferencesTableSettings)2 Viewer (org.eclipse.jface.viewers.Viewer)2 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)2 AbstractTable (org.obeonetwork.dsl.database.AbstractTable)2 Constraint (org.obeonetwork.dsl.database.Constraint)2 UpdateIndex (org.obeonetwork.dsl.database.dbevolution.UpdateIndex)2 Attribute (org.obeonetwork.dsl.environment.Attribute)2