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);
}
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);
}
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;
}
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);
}
}
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));
}
}
}
Aggregations