use of org.obeonetwork.dsl.database.Constraint in project InformationSystem by ObeoNetwork.
the class ConstraintPropertiesEditionComponent 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 Constraint constraint = (Constraint) elt;
final ConstraintPropertiesEditionPart constraintPart = (ConstraintPropertiesEditionPart) editingPart;
// init values
if (isAccessible(DatabaseViewsRepository.Constraint.Properties.name))
constraintPart.setName(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, constraint.getName()));
if (isAccessible(DatabaseViewsRepository.Constraint.Properties.expression))
constraintPart.setExpression(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, constraint.getExpression()));
if (isAccessible(DatabaseViewsRepository.Constraint.Properties.comments))
constraintPart.setComments(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, constraint.getComments()));
// init filters
// init values for referenced views
// init filters for referenced views
}
setInitializing(false);
}
use of org.obeonetwork.dsl.database.Constraint in project InformationSystem by ObeoNetwork.
the class TableConstraintsPropertiesEditionComponent 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 Table table = (Table) elt;
final ConstraintsPropertiesEditionPart constraintsPart = (ConstraintsPropertiesEditionPart) editingPart;
// init values
if (isAccessible(DatabaseViewsRepository.Constraints.Properties.constraints_)) {
constraintsSettings = new ReferencesTableSettings(table, DatabasePackage.eINSTANCE.getTable_Constraints());
constraintsPart.initConstraints(constraintsSettings);
}
// init filters
if (isAccessible(DatabaseViewsRepository.Constraints.Properties.constraints_)) {
constraintsPart.addFilterToConstraints(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 Constraint);
}
});
// Start of user code for additional businessfilters for constraints
// End of user code
}
// init values for referenced views
// init filters for referenced views
}
setInitializing(false);
}
use of org.obeonetwork.dsl.database.Constraint 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);
}
}
use of org.obeonetwork.dsl.database.Constraint in project InformationSystem by ObeoNetwork.
the class EntityToMLD method findOrCreateConstraint.
private Constraint findOrCreateConstraint(Table table, String expression) {
for (Constraint constraint : table.getConstraints()) {
if (expression.equals(constraint.getExpression())) {
return constraint;
}
}
// No constraint found, let's create one
Constraint constraint = DatabaseFactory.eINSTANCE.createConstraint();
constraint.setExpression(expression);
table.getConstraints().add(constraint);
return constraint;
}
use of org.obeonetwork.dsl.database.Constraint in project InformationSystem by ObeoNetwork.
the class EntityToMLD method createAdditionalFields.
private void createAdditionalFields(Table table) {
/*
* 1st part : Quick fix for Ministère de l'Education Nationale needs
* a metadata DISABLE_ADDITIONAL_FIELDS_KEY = true can be set on an entity, a namespace or entity root
* if it is set then the additional fields won't be created
*/
if (shouldCreateAdditionalFields(table)) {
/*
* End of 1st part : Quick fix for Ministère de l'Education Nationale needs
*/
// Validity column
String validityColumnName = AdditionalFieldsUtils.getValidityColumnName(table);
Column validityColumn = createValidityColumn(table, validityColumnName);
addToObjectsToBeKept(validityColumn);
// Add constraint on this column
Constraint validityConstraint = findOrCreateConstraint(table, AdditionalFieldsUtils.getValidityColumnConstraint(table));
validityConstraint.setName(getConstraintName(validityConstraint));
validityConstraint.setComments(MessageFormat.format(VALIDITY_CONSTRAINT_COMMENTS, validityColumnName));
addToObjectsToBeKept(validityConstraint);
// Date column
Column dateColumn = createDateColumn(table, AdditionalFieldsUtils.getDateColumnName(table));
addToObjectsToBeKept(dateColumn);
/*
* 2nd part : Quick fix for Ministère de l'Education Nationale needs
*/
}
/*
* End of 2nd part : Quick fix for Ministère de l'Education Nationale needs
*/
}
Aggregations