Search in sources :

Example 1 with DBDiff

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

the class UtilServices method getOrderedChanges.

public List<DBDiff> getOrderedChanges(Comparison comparison) {
    // Collect all changes
    List<DBDiff> changes = new ArrayList<DBDiff>();
    TreeIterator<EObject> it = comparison.eAllContents();
    while (it.hasNext()) {
        EObject next = it.next();
        if (next instanceof DBDiff) {
            changes.add((DBDiff) next);
        }
    }
    orderChanges(changes);
    return changes;
}
Also used : EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) DBDiff(org.obeonetwork.dsl.database.dbevolution.DBDiff)

Example 2 with DBDiff

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

the class DBDiffItemProvider method getText.

/**
 * This returns the label text for the adapted class.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public String getText(Object object) {
    DifferenceKind labelValue = ((DBDiff) object).getKind();
    String label = labelValue == null ? null : labelValue.toString();
    return label == null || label.length() == 0 ? getString("_UI_DBDiff_type") : getString("_UI_DBDiff_type") + " " + label;
}
Also used : DifferenceKind(org.eclipse.emf.compare.DifferenceKind) DBDiff(org.obeonetwork.dsl.database.dbevolution.DBDiff)

Example 3 with DBDiff

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

the class UtilServices method getSubDiffs.

public List<DBDiff> getSubDiffs(Diff diff) {
    List<Diff> subDiffs = getDiffContentService().getSubDiffs(diff);
    List<DBDiff> changes = new ArrayList<DBDiff>();
    for (Diff subDiff : subDiffs) {
        if (subDiff instanceof DBDiff) {
            changes.add((DBDiff) subDiff);
        }
    }
    orderChanges(changes);
    return changes;
}
Also used : Diff(org.eclipse.emf.compare.Diff) DBDiff(org.obeonetwork.dsl.database.dbevolution.DBDiff) ArrayList(java.util.ArrayList) DBDiff(org.obeonetwork.dsl.database.dbevolution.DBDiff)

Example 4 with DBDiff

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

the class DatabasePostProcessor method postComparison.

@Override
public void postComparison(final Comparison comparison, Monitor monitor) {
    // Create DBDiffs
    new DatabaseDiffExtension().visit(comparison);
    // Delete all empty DBDiffs
    final DiffContentService service = new DiffContentService();
    Collection<Diff> toDelete = Collections2.filter(comparison.getDifferences(), new Predicate<Diff>() {

        public boolean apply(Diff input) {
            return input instanceof DBDiff && service.getSubDiffs(input, comparison).isEmpty() && input.getRefinedBy().isEmpty();
        }
    });
    for (Diff diff : toDelete) {
        // It could be optimized doing diff.eContainer().eContents().delete(diff) since no object references it.
        EcoreUtil.delete(diff);
    }
}
Also used : Diff(org.eclipse.emf.compare.Diff) DBDiff(org.obeonetwork.dsl.database.dbevolution.DBDiff) DiffContentService(org.obeonetwork.dsl.database.compare.extensions.services.DiffContentService) DBDiff(org.obeonetwork.dsl.database.dbevolution.DBDiff)

Aggregations

DBDiff (org.obeonetwork.dsl.database.dbevolution.DBDiff)4 ArrayList (java.util.ArrayList)2 Diff (org.eclipse.emf.compare.Diff)2 DifferenceKind (org.eclipse.emf.compare.DifferenceKind)1 EObject (org.eclipse.emf.ecore.EObject)1 DiffContentService (org.obeonetwork.dsl.database.compare.extensions.services.DiffContentService)1