Search in sources :

Example 16 with Comparison

use of org.eclipse.emf.compare.Comparison in project InformationSystem by ObeoNetwork.

the class DiffContentService method isInAddOrDelete.

/**
 * It checks if the given difference is about an added or deleted object.<br>
 * It enables to choose to keep involved differences under an add or delete.
 *
 * @param diff
 * @return
 */
private static boolean isInAddOrDelete(Diff diff) {
    Match match = diff.getMatch();
    Comparison comparison = match.getComparison();
    EObject left = match.getLeft();
    if (left != null) {
        return isInAddOrDelete(comparison, left);
    }
    EObject right = match.getRight();
    if (right != null) {
        return isInAddOrDelete(comparison, right);
    }
    return false;
}
Also used : Comparison(org.eclipse.emf.compare.Comparison) EObject(org.eclipse.emf.ecore.EObject) Match(org.eclipse.emf.compare.Match)

Example 17 with Comparison

use of org.eclipse.emf.compare.Comparison in project InformationSystem by ObeoNetwork.

the class TableChangeBuilder method handleAddChange.

@Override
protected Diff handleAddChange(ReferenceChange change) {
    Comparison comparison = change.getMatch().getComparison();
    TableContainer tableContainer = (TableContainer) change.getMatch().getRight();
    Table table = (Table) change.getValue();
    return createAddTable(comparison, tableContainer, table, change);
}
Also used : AlterTable(org.obeonetwork.dsl.database.dbevolution.AlterTable) RemoveTable(org.obeonetwork.dsl.database.dbevolution.RemoveTable) Table(org.obeonetwork.dsl.database.Table) AddTable(org.obeonetwork.dsl.database.dbevolution.AddTable) Comparison(org.eclipse.emf.compare.Comparison) TableContainer(org.obeonetwork.dsl.database.TableContainer)

Example 18 with Comparison

use of org.eclipse.emf.compare.Comparison in project InformationSystem by ObeoNetwork.

the class AbtractGeneratorTest method assertGen.

protected void assertGen(String testCase, String genFileName) throws Exception {
    Comparison databaseChangeSet = diff(testCase + "/v2.database", testCase + "/v1.database");
    File folder = new File("testFolder");
    AcceleoTextGenerationListener acceleoTextGenerationListener = generate(databaseChangeSet, folder);
    String path = folder.getAbsolutePath() + File.separator + "" + getTimeStamp() + File.separator;
    GeneratedFile generatedFile = new GeneratedFile(path + genFileName, testCase + File.separator + "expected.sql");
    assertSQL(acceleoTextGenerationListener, generatedFile);
}
Also used : Comparison(org.eclipse.emf.compare.Comparison) File(java.io.File)

Example 19 with Comparison

use of org.eclipse.emf.compare.Comparison in project InformationSystem by ObeoNetwork.

the class DatabaseTransformationTest method testDatabaseTransformation.

@SuppressWarnings("unchecked")
@Test
public void testDatabaseTransformation() {
    Comparison expected = (Comparison) this.expectedResourceWrapper.getResource().getContents().get(0);
    Comparison actual = (Comparison) this.actualResourceWrapper.getResource().getContents().get(0);
    try {
        // Comparing Comparisons using EMFCompare does not seem to do well.
        // We thus compare the Comparisons in a rough way manually, errors
        // can be caught in later stages.
        DatabaseTransformationTestSuite.INSTANCE.compareComparisons(expected, actual);
        // Only check for the same number of matches... :-/
        assertEquals(EMFUtils.getAllContentsOfType(ComparePackage.Literals.MATCH, expected).size(), EMFUtils.getAllContentsOfType(ComparePackage.Literals.MATCH, actual).size());
    } catch (AssertionError e) {
        System.out.println("Actual model being used for transformation:");
        try {
            this.actualResourceWrapper.getResource().save(System.out, null);
        } catch (final IOException ex) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        System.out.println("Expected model being used for transformation:");
        try {
            this.expectedResourceWrapper.getResource().save(System.out, null);
        } catch (final IOException ex) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        throw e;
    }
}
Also used : Comparison(org.eclipse.emf.compare.Comparison) IOException(java.io.IOException) Test(org.junit.Test)

Example 20 with Comparison

use of org.eclipse.emf.compare.Comparison in project InformationSystem by ObeoNetwork.

the class DatabaseTransformationTestSuite method transform.

private Comparison transform(Comparison originalComparison) {
    IPostProcessor transformer = new DatabasePostProcessor();
    Comparison comparison = EcoreUtil.copy(originalComparison);
    transformer.postComparison(comparison, null);
    return comparison;
}
Also used : IPostProcessor(org.eclipse.emf.compare.postprocessor.IPostProcessor) Comparison(org.eclipse.emf.compare.Comparison) DatabasePostProcessor(org.obeonetwork.dsl.database.compare.extensions.processor.DatabasePostProcessor)

Aggregations

Comparison (org.eclipse.emf.compare.Comparison)22 Diff (org.eclipse.emf.compare.Diff)7 DefaultComparisonScope (org.eclipse.emf.compare.scope.DefaultComparisonScope)7 IComparisonScope (org.eclipse.emf.compare.scope.IComparisonScope)7 List (java.util.List)6 EList (org.eclipse.emf.common.util.EList)6 EMFCompare (org.eclipse.emf.compare.EMFCompare)6 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)6 EObject (org.eclipse.emf.ecore.EObject)5 File (java.io.File)4 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 Resource (org.eclipse.emf.ecore.resource.Resource)4 TableContainer (org.obeonetwork.dsl.database.TableContainer)4 ReferenceChange (org.eclipse.emf.compare.ReferenceChange)3 BasicMonitor (org.eclipse.emf.common.util.BasicMonitor)2 Match (org.eclipse.emf.compare.Match)2 Test (org.junit.Test)2 DataBase (org.obeonetwork.dsl.database.DataBase)2 URISyntaxException (java.net.URISyntaxException)1