use of org.obeonetwork.dsl.database.Sequence in project InformationSystem by ObeoNetwork.
the class AddSequenceItemProvider method getText.
/**
* This returns the label text for the adapted class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
@Override
public String getText(Object object) {
AddSequence addSequence = (AddSequence) object;
Sequence sequence = addSequence.getSequence();
return getString("_UI_AddSequence_type") + " " + sequence.getName();
}
use of org.obeonetwork.dsl.database.Sequence in project InformationSystem by ObeoNetwork.
the class SequenceChangeImpl method setSequence.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setSequence(Sequence newSequence) {
Sequence oldSequence = sequence;
sequence = newSequence;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, DbevolutionPackage.SEQUENCE_CHANGE__SEQUENCE, oldSequence, sequence));
}
use of org.obeonetwork.dsl.database.Sequence in project InformationSystem by ObeoNetwork.
the class SequenceServicesTest method sequenceColumnsTest.
@Test
public void sequenceColumnsTest() {
Sequence sequence = getGSSerieSequence();
assertEquals(1, new SequenceServices().columns(sequence).size());
}
use of org.obeonetwork.dsl.database.Sequence in project InformationSystem by ObeoNetwork.
the class MpdToMldBidiRules method createOrUpdateSequences.
/**
* Create needed new sequences or update existing ones
* @param sourceTableContainer
* @return list of sequences processed so that all other sequences (now useless) could be removed
*/
/**
* @param sourceTableContainer
* @return
*/
private Collection<Sequence> createOrUpdateSequences(TableContainer sourceTableContainer) {
Collection<Sequence> sequences = new ArrayList<Sequence>();
// for each non-composite PK we create a sequence and associate it with the PK column
for (AbstractTable sourceAbstractTable : sourceTableContainer.getTables()) {
if (sourceAbstractTable instanceof Table) {
Table sourceTable = (Table) sourceAbstractTable;
// Get associated table
Table targetTable = getFromOutputTraceabilityMap(sourceTable, DatabasePackage.Literals.TABLE);
if (targetTable != null) {
PrimaryKey pk = targetTable.getPrimaryKey();
// Only for non-composite PK
if (pk != null && pk.getColumns().size() == 1) {
Column targetColumn = pk.getColumns().get(0);
// Retrieve the potentially existing sequence
Sequence existingSequence = targetColumn.getSequence();
String sequenceName = targetTable.getName() + "_SEQ";
if (existingSequence != null) {
// Update name
existingSequence.setName(sequenceName);
// Ensure the sequence is in the right container
if (!targetTable.getOwner().getSequences().contains(existingSequence)) {
targetTable.getOwner().getSequences().add(existingSequence);
}
sequences.add(existingSequence);
} else {
// Create a new sequence
Sequence newSequence = DatabaseFactory.eINSTANCE.createSequence();
newSequence.setName(sequenceName);
newSequence.setIncrement(new BigInteger("1"));
newSequence.setStart(new BigInteger("1"));
newSequence.setComments(String.format(SEQUENCE_INITIAL_COMMENTS, targetTable.getName()));
targetTable.getOwner().getSequences().add(newSequence);
// Retrieve the associated column and associate it with the sequence
targetColumn.setSequence(newSequence);
sequences.add(newSequence);
}
}
}
}
}
if (sourceTableContainer instanceof DataBase) {
DataBase sourceDataBase = (DataBase) sourceTableContainer;
for (Schema sourceSchema : sourceDataBase.getSchemas()) {
sequences.addAll(createOrUpdateSequences(sourceSchema));
}
}
return sequences;
}
use of org.obeonetwork.dsl.database.Sequence in project InformationSystem by ObeoNetwork.
the class ColumnPropertiesEditionComponent 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);
if (editingPart instanceof CompositePropertiesEditionPart) {
((CompositePropertiesEditionPart) editingPart).getSettings().add(typeSettings);
((CompositePropertiesEditionPart) editingPart).getSettings().add(lengthSettings);
((CompositePropertiesEditionPart) editingPart).getSettings().add(precisionSettings);
((CompositePropertiesEditionPart) editingPart).getSettings().add(literalsSettings);
}
final Column column = (Column) elt;
final ColumnPropertiesEditionPart columnPart = (ColumnPropertiesEditionPart) editingPart;
// init values
if (isAccessible(DatabaseViewsRepository.Column.Properties.name))
columnPart.setName(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, column.getName()));
if (isAccessible(DatabaseViewsRepository.Column.Properties.NullablePkAndUnique.nullable)) {
columnPart.setNullable(column.isNullable());
}
if (isAccessible(DatabaseViewsRepository.Column.Properties.NullablePkAndUnique.primaryKey)) {
columnPart.setPrimaryKey(column.isInPrimaryKey());
}
if (isAccessible(DatabaseViewsRepository.Column.Properties.NullablePkAndUnique.unique)) {
columnPart.setUnique(column.isUnique());
}
if (isAccessible(DatabaseViewsRepository.Column.Properties.Sequence.autoincrement)) {
columnPart.setAutoincrement(column.isAutoincrement());
}
if (isAccessible(DatabaseViewsRepository.Column.Properties.Sequence.sequence_)) {
// init part
sequenceSettings = new EObjectFlatComboSettings(column, DatabasePackage.eINSTANCE.getColumn_Sequence());
columnPart.initSequence(sequenceSettings);
// set the button mode
columnPart.setSequenceButtonMode(ButtonsModeEnum.BROWSE);
}
if (isAccessible(DatabaseViewsRepository.Column.Properties.defaultValue))
columnPart.setDefaultValue(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, column.getDefaultValue()));
if (isAccessible(DatabaseViewsRepository.Column.Properties.comments))
columnPart.setComments(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, column.getComments()));
if (typeSettings.getSignificantObject() != null && isAccessible(DatabaseViewsRepository.Column.Properties.type)) {
columnPart.initType(EEFUtils.choiceOfValues(typeSettings.getSignificantObject(), TypesLibraryPackage.eINSTANCE.getTypeInstance_NativeType()), typeSettings.getValue());
}
if (lengthSettings.getValue() != null && isAccessible(DatabaseViewsRepository.Column.Properties.TypeAttributes.length))
columnPart.setLength(EEFConverterUtil.convertToString(EcorePackage.Literals.EINTEGER_OBJECT, lengthSettings.getValue()));
if (precisionSettings.getValue() != null && isAccessible(DatabaseViewsRepository.Column.Properties.TypeAttributes.precision))
columnPart.setPrecision(EEFConverterUtil.convertToString(EcorePackage.Literals.EINTEGER_OBJECT, precisionSettings.getValue()));
if (literalsSettings.getSignificantObject() != null && isAccessible(DatabaseViewsRepository.Column.Properties.literals)) {
columnPart.setLiterals((EList<?>) literalsSettings.getValue());
}
if (isAccessible(DatabaseViewsRepository.Column.Properties.Sequence.sequence_)) {
columnPart.addFilterToSequence(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 Sequence);
}
});
// Start of user code for additional businessfilters for sequence
// End of user code
}
// Start of user code for additional businessfilters for type
// End of user code
// init values for referenced views
// init filters for referenced views
}
setInitializing(false);
}
Aggregations