Search in sources :

Example 1 with IndexElement

use of org.obeonetwork.dsl.database.IndexElement 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);
}
Also used : IndexElementPropertiesEditionPart(org.obeonetwork.dsl.database.parts.IndexElementPropertiesEditionPart) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) Column(org.obeonetwork.dsl.database.Column) Viewer(org.eclipse.jface.viewers.Viewer) EObject(org.eclipse.emf.ecore.EObject) EObjectFlatComboSettings(org.eclipse.emf.eef.runtime.ui.widgets.eobjflatcombo.EObjectFlatComboSettings) IndexElement(org.obeonetwork.dsl.database.IndexElement)

Example 2 with IndexElement

use of org.obeonetwork.dsl.database.IndexElement 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 IndexElement

use of org.obeonetwork.dsl.database.IndexElement in project InformationSystem by ObeoNetwork.

the class EntityToMLD method getUniqueIndexComments.

private String getUniqueIndexComments(Index index) {
    String comments = "Index d'unicité pour ";
    for (int i = 0; i < index.getElements().size(); i++) {
        if (i > 0) {
            comments += ", ";
        }
        IndexElement elt = index.getElements().get(i);
        comments += elt.getColumn().getName();
    }
    return comments;
}
Also used : Constraint(org.obeonetwork.dsl.database.Constraint) IndexElement(org.obeonetwork.dsl.database.IndexElement)

Example 4 with IndexElement

use of org.obeonetwork.dsl.database.IndexElement 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)

Example 5 with IndexElement

use of org.obeonetwork.dsl.database.IndexElement in project InformationSystem by ObeoNetwork.

the class DefaultDataBaseBuilder method buildIndex.

protected void buildIndex(DatabaseMetaData metaData, Table table, ResultSet rs, Map<Object, Object> indices) throws SQLException {
    int indexType = rs.getInt(7);
    String indexName = rs.getString(6);
    if (indexType != 0) {
        Index index = (Index) indices.get(indexName);
        if (index == null) {
            index = CreationUtils.createIndex(table, indexName);
            String indexQualifier = rs.getString(5);
            index.setQualifier(indexQualifier);
            index.setUnique(!(rs.getBoolean(4)));
            indices.put(indexName, index);
        }
        String indexColumnName = rs.getString(9);
        Column indexColumn = queries.getColumn(table, indexColumnName);
        if (indexColumn != null) {
            IndexElement element = CreationUtils.createIndexElement(index);
            element.setColumn(indexColumn);
            String order = rs.getString(10);
            Boolean inAscendingOrder = isInAscendingOrder(metaData, order, table, index, indexColumnName);
            if (inAscendingOrder == null) {
                element.setAsc(true);
            } else {
                element.setAsc(inAscendingOrder);
            }
        } else {
            System.err.println("indexColumn not found -> table=" + table.getName() + "indexName=" + indexName + " indexColumnName=" + indexColumnName + " indexColumn=" + indexColumn + " qualifier=" + rs.getString(5));
        }
    }
}
Also used : Column(org.obeonetwork.dsl.database.Column) Index(org.obeonetwork.dsl.database.Index) IndexElement(org.obeonetwork.dsl.database.IndexElement)

Aggregations

IndexElement (org.obeonetwork.dsl.database.IndexElement)14 Index (org.obeonetwork.dsl.database.Index)7 Column (org.obeonetwork.dsl.database.Column)4 EObject (org.eclipse.emf.ecore.EObject)3 Constraint (org.obeonetwork.dsl.database.Constraint)3 ForeignKey (org.obeonetwork.dsl.database.ForeignKey)3 Table (org.obeonetwork.dsl.database.Table)3 ArrayList (java.util.ArrayList)2 Viewer (org.eclipse.jface.viewers.Viewer)2 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)2 Attribute (org.obeonetwork.dsl.environment.Attribute)2 Reference (org.obeonetwork.dsl.environment.Reference)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 EReference (org.eclipse.emf.ecore.EReference)1 EObjectPropertiesEditionContext (org.eclipse.emf.eef.runtime.context.impl.EObjectPropertiesEditionContext)1