use of org.obeonetwork.dsl.database.Constraint in project InformationSystem by ObeoNetwork.
the class AddConstraintItemProvider 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) {
AddConstraint addConstraint = (AddConstraint) object;
Constraint constraint = addConstraint.getConstraint();
return getString("_UI_AddConstraint_type") + " " + constraint.getName();
}
use of org.obeonetwork.dsl.database.Constraint in project InformationSystem by ObeoNetwork.
the class ConstraintChangeBuilder method createUpdateConstraint.
protected UpdateConstraint createUpdateConstraint(Match change) {
UpdateConstraint updateConstraint = DbevolutionFactory.eINSTANCE.createUpdateConstraint();
Constraint constraint = (Constraint) change.getRight();
updateConstraint.setConstraint(constraint);
Object leftElement = change.getLeft();
updateConstraint.setNewConstraint((Constraint) leftElement);
fillDBDiff(updateConstraint, change);
return updateConstraint;
}
use of org.obeonetwork.dsl.database.Constraint in project InformationSystem by ObeoNetwork.
the class ConstraintChangeImpl method setConstraint.
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public void setConstraint(Constraint newConstraint) {
Constraint oldConstraint = constraint;
constraint = newConstraint;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, DbevolutionPackage.CONSTRAINT_CHANGE__CONSTRAINT, oldConstraint, constraint));
}
use of org.obeonetwork.dsl.database.Constraint in project InformationSystem by ObeoNetwork.
the class UpdateConstraintImpl method setNewConstraint.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setNewConstraint(Constraint newNewConstraint) {
Constraint oldNewConstraint = newConstraint;
newConstraint = newNewConstraint;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, DbevolutionPackage.UPDATE_CONSTRAINT__NEW_CONSTRAINT, oldNewConstraint, newConstraint));
}
use of org.obeonetwork.dsl.database.Constraint in project InformationSystem by ObeoNetwork.
the class EntityToMLD method handleEnumType.
private void handleEnumType(Column column, Enumeration enumeration, Table table) {
// For an enumeration
// Column has type Texte
TypeInstance typeInstance = TypesLibraryFactory.eINSTANCE.createTypeInstance();
typeInstance.setNativeType(nativeTypesMap.get(ENUM_COLUMN_TYPE));
column.setType(typeInstance);
// Column size is the maximum length of the literals
int maxSize = 0;
List<String> literalValues = new ArrayList<String>();
for (Literal literal : enumeration.getLiterals()) {
String value = literal.getName();
if (value != null) {
literalValues.add("''" + value + "''");
int length = value.length();
if (maxSize < length) {
maxSize = length;
}
}
}
if (maxSize > 0) {
typeInstance.setLength(maxSize);
}
// A check constraint is added with all literals
String expression = MessageFormat.format("{0} in ({1})", column.getName(), Joiner.on(",").join(literalValues));
Constraint validityConstraint = findOrCreateConstraint(table, expression);
validityConstraint.setName("ENUM_CONSTRAINT");
validityConstraint.setComments(MessageFormat.format(ENUM_CONSTRAINTS_COMMENTS, column.getName()));
addToObjectsToBeKept(validityConstraint);
// A default value is added, it is the first literal
if (!enumeration.getLiterals().isEmpty()) {
column.setDefaultValue(enumeration.getLiterals().get(0).getName());
}
}
Aggregations