diff options
10 files changed, 52 insertions, 33 deletions
diff --git a/builds/org.eclipse.emf.edapt.declaration.doc/src/org/eclipse/emf/edapt/declaration/doc/OperationExtractor.java b/builds/org.eclipse.emf.edapt.declaration.doc/src/org/eclipse/emf/edapt/declaration/doc/OperationExtractor.java index 6c802fd..674161f 100644 --- a/builds/org.eclipse.emf.edapt.declaration.doc/src/org/eclipse/emf/edapt/declaration/doc/OperationExtractor.java +++ b/builds/org.eclipse.emf.edapt.declaration.doc/src/org/eclipse/emf/edapt/declaration/doc/OperationExtractor.java @@ -20,30 +20,25 @@ public class OperationExtractor { public static void main(String[] args) throws IOException {
DeclarationPackage.eINSTANCE.getConstraint();
- Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("*",
- new XMIResourceFactoryImpl());
+ Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl());
OperationRegistry.getInstance().registerLibrary(BaseLibrary.class);
- for (Library rootLibrary : OperationRegistry.getInstance()
- .getRootLibraries()) {
-
+ for (Library rootLibrary : OperationRegistry.getInstance().getRootLibraries()) {
+
for (Library library : rootLibrary.getLibraries()) {
- ECollections.sort(library.getOperations(),
- new Comparator<Operation>() {
- public int compare(Operation o1, Operation o2) {
- return o1.getLabel().compareTo(o2.getLabel());
- }
- });
+ ECollections.sort(library.getOperations(), new Comparator<Operation>() {
+ public int compare(Operation o1, Operation o2) {
+ return o1.getLabel().compareTo(o2.getLabel());
+ }
+ });
}
}
ResourceSet resourceSet = new ResourceSetImpl();
- Resource resource = resourceSet.createResource(URI
- .createFileURI("model/library.declaration"));
- resource.getContents().addAll(
- OperationRegistry.getInstance().getRootLibraries());
+ Resource resource = resourceSet.createResource(URI.createFileURI("model/library.declaration"));
+ resource.getContents().addAll(OperationRegistry.getInstance().getRootLibraries());
- ResourceUtils.saveResourceSet(resourceSet);
+ ResourceUtils.saveResourceSet(resourceSet, null);
}
}
diff --git a/plugins/org.eclipse.emf.edapt.common/src/org/eclipse/emf/edapt/internal/common/ResourceUtils.java b/plugins/org.eclipse.emf.edapt.common/src/org/eclipse/emf/edapt/internal/common/ResourceUtils.java index cee701a..600ca3c 100644 --- a/plugins/org.eclipse.emf.edapt.common/src/org/eclipse/emf/edapt/internal/common/ResourceUtils.java +++ b/plugins/org.eclipse.emf.edapt.common/src/org/eclipse/emf/edapt/internal/common/ResourceUtils.java @@ -112,7 +112,7 @@ public final class ResourceUtils { */ public static ResourceSet loadResourceSet(List<URI> modelURIs, List<EPackage> ePackages, IResourceSetFactory resourceSetFactory) - throws IOException { + throws IOException { final ResourceSet resourceSet = resourceSetFactory.createResourceSet(); @@ -191,9 +191,11 @@ public final class ResourceUtils { } /** Save model based on {@link ResourceSet}. */ - public static void saveResourceSet(ResourceSet resourceSet) + public static void saveResourceSet(ResourceSet resourceSet, Map<String, Object> options) throws IOException { - final Map<String, Object> options = new HashMap<String, Object>(); + if (options == null) { + options = new HashMap<String, Object>(); + } options.put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.FALSE); for (final Resource resource : resourceSet.getResources()) { if (resource.getURI() == null diff --git a/plugins/org.eclipse.emf.edapt.history.cdo/src/org/eclipse/emf/edapt/cdo/migration/execution/CDOPersistency.java b/plugins/org.eclipse.emf.edapt.history.cdo/src/org/eclipse/emf/edapt/cdo/migration/execution/CDOPersistency.java index f2470ad..3eae2c0 100644 --- a/plugins/org.eclipse.emf.edapt.history.cdo/src/org/eclipse/emf/edapt/cdo/migration/execution/CDOPersistency.java +++ b/plugins/org.eclipse.emf.edapt.history.cdo/src/org/eclipse/emf/edapt/cdo/migration/execution/CDOPersistency.java @@ -49,7 +49,7 @@ public class CDOPersistency extends Persistency { final StrategyBackwardConverter bConverter = new StrategyBackwardConverter( extent, list); final ResourceSet resourceSet = bConverter.convert(model); - ResourceUtils.saveResourceSet(resourceSet); + ResourceUtils.saveResourceSet(resourceSet, null); } public static Model loadModel(List<URI> modelURIs, Metamodel metamodel, diff --git a/plugins/org.eclipse.emf.edapt.history/src/org/eclipse/emf/edapt/history/reconstruction/EcoreForwardReconstructor.java b/plugins/org.eclipse.emf.edapt.history/src/org/eclipse/emf/edapt/history/reconstruction/EcoreForwardReconstructor.java index e1e40a2..bbbf914 100644 --- a/plugins/org.eclipse.emf.edapt.history/src/org/eclipse/emf/edapt/history/reconstruction/EcoreForwardReconstructor.java +++ b/plugins/org.eclipse.emf.edapt.history/src/org/eclipse/emf/edapt/history/reconstruction/EcoreForwardReconstructor.java @@ -85,8 +85,8 @@ public class EcoreForwardReconstructor extends ForwardReconstructorBase { /** Save all metamodel resources. */ public void save() { try { - ResourceUtils.saveResourceSet(resourceSet); - } catch (final IOException e) { + ResourceUtils.saveResourceSet(resourceSet, null); + } catch (IOException e) { LoggingUtils.logError(HistoryPlugin.getPlugin(), e); } diff --git a/plugins/org.eclipse.emf.edapt.history/src/org/eclipse/emf/edapt/migration/execution/Migrator.java b/plugins/org.eclipse.emf.edapt.history/src/org/eclipse/emf/edapt/migration/execution/Migrator.java index 67c2f4b..515abe3 100644 --- a/plugins/org.eclipse.emf.edapt.history/src/org/eclipse/emf/edapt/migration/execution/Migrator.java +++ b/plugins/org.eclipse.emf.edapt.history/src/org/eclipse/emf/edapt/migration/execution/Migrator.java @@ -164,13 +164,34 @@ public class Migrator { */ public void migrateAndSave(List<URI> modelURIs, Release sourceRelease, Release targetRelease, IProgressMonitor monitor) - throws MigrationException { + throws MigrationException { + this.migrateAndSave(modelURIs, sourceRelease, targetRelease, monitor, null); + } + + /** + * Migrate a model based on a set of {@link URI}. + * + * @param modelURIs + * @param sourceRelease + * Release to which the model conforms + * @param targetRelease + * Release to which the model should be migrated (use null for + * the newest release) + * @param monitor + * Progress monitor + * @param options + * Options to pass to the ResourceSet when saving + * @since 1.1 + */ + public void migrateAndSave(List<URI> modelURIs, Release sourceRelease, + Release targetRelease, IProgressMonitor monitor, Map<String, Object> options) + throws MigrationException { final Model model = migrate(modelURIs, sourceRelease, targetRelease, monitor); if (model == null) { throw new MigrationException("Model is up-to-date", null); //$NON-NLS-1$ } try { - Persistency.saveModel(model); + Persistency.saveModel(model, options); } catch (final IOException e) { throw new MigrationException("Model could not be saved", e); //$NON-NLS-1$ } @@ -223,7 +244,7 @@ public class Migrator { */ private Model migrate(List<URI> modelURIs, Release sourceRelease, Release targetRelease, IProgressMonitor monitor) - throws MigrationException { + throws MigrationException { try { if (targetRelease == null) { targetRelease = getLatestRelease(); diff --git a/plugins/org.eclipse.emf.edapt.migration/src/org/eclipse/emf/edapt/internal/migration/internal/BackupUtils.java b/plugins/org.eclipse.emf.edapt.migration/src/org/eclipse/emf/edapt/internal/migration/internal/BackupUtils.java index be8b830..68feefb 100644 --- a/plugins/org.eclipse.emf.edapt.migration/src/org/eclipse/emf/edapt/internal/migration/internal/BackupUtils.java +++ b/plugins/org.eclipse.emf.edapt.migration/src/org/eclipse/emf/edapt/internal/migration/internal/BackupUtils.java @@ -107,7 +107,7 @@ public final class BackupUtils { targetURIs.add(targetURI); } } - ResourceUtils.saveResourceSet(model); + ResourceUtils.saveResourceSet(model, null); return targetURIs; } diff --git a/plugins/org.eclipse.emf.edapt.migration/src/org/eclipse/emf/edapt/internal/migration/internal/Persistency.java b/plugins/org.eclipse.emf.edapt.migration/src/org/eclipse/emf/edapt/internal/migration/internal/Persistency.java index b3c5963..d3a53e1 100644 --- a/plugins/org.eclipse.emf.edapt.migration/src/org/eclipse/emf/edapt/internal/migration/internal/Persistency.java +++ b/plugins/org.eclipse.emf.edapt.migration/src/org/eclipse/emf/edapt/internal/migration/internal/Persistency.java @@ -14,6 +14,7 @@ package org.eclipse.emf.edapt.internal.migration.internal; import java.io.IOException; import java.util.Collections; import java.util.List; +import java.util.Map; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.EObject; @@ -81,7 +82,7 @@ public class Persistency { resource.getContents().addAll(metamodelResource.getRootPackages()); } - ResourceUtils.saveResourceSet(resourceSet); + ResourceUtils.saveResourceSet(resourceSet, null); } /** Load model based on {@link URI} for model and metamodel. */ @@ -118,9 +119,9 @@ public class Persistency { } /** Save model based on {@link URI}. */ - public static void saveModel(Model model) throws IOException { + public static void saveModel(Model model, Map<String, Object> options) throws IOException { final BackwardConverter bConverter = new BackwardConverter(); final ResourceSet resourceSet = bConverter.convert(model); - ResourceUtils.saveResourceSet(resourceSet); + ResourceUtils.saveResourceSet(resourceSet, options); } } diff --git a/tests/org.eclipse.emf.edapt.tests/src/org/eclipse/emf/edapt/tests/history/LifecycleTestBase.java b/tests/org.eclipse.emf.edapt.tests/src/org/eclipse/emf/edapt/tests/history/LifecycleTestBase.java index dbfeb56..2c89104 100644 --- a/tests/org.eclipse.emf.edapt.tests/src/org/eclipse/emf/edapt/tests/history/LifecycleTestBase.java +++ b/tests/org.eclipse.emf.edapt.tests/src/org/eclipse/emf/edapt/tests/history/LifecycleTestBase.java @@ -158,7 +158,7 @@ public abstract class LifecycleTestBase extends MigrationTestBase { .addReconstructor(new HistoryInterpreter(listener, mapping)); reconstructor.reconstruct(history.getLastRelease(), false); - ResourceUtils.saveResourceSet(domain.getResourceSet()); + ResourceUtils.saveResourceSet(domain.getResourceSet(), null); Assert.assertTrue(new IntegrityChecker(listener.getHistory()).check()); } diff --git a/tests/org.eclipse.emf.edapt.tests/src/org/eclipse/emf/edapt/tests/migration/ConverterTest.java b/tests/org.eclipse.emf.edapt.tests/src/org/eclipse/emf/edapt/tests/migration/ConverterTest.java index d0ae234..5a14d9a 100644 --- a/tests/org.eclipse.emf.edapt.tests/src/org/eclipse/emf/edapt/tests/migration/ConverterTest.java +++ b/tests/org.eclipse.emf.edapt.tests/src/org/eclipse/emf/edapt/tests/migration/ConverterTest.java @@ -85,7 +85,7 @@ public class ConverterTest extends TestCase { resource.setUri(mapper.map(resource.getUri())); } - Persistency.saveModel(model); + Persistency.saveModel(model, null); final Resource model1 = ResourceUtils .loadResourceSet(model1URI, metamodel.getEPackages()) diff --git a/tests/org.eclipse.emf.edapt.tests/src/org/eclipse/emf/edapt/tests/util/SplitContainment.java b/tests/org.eclipse.emf.edapt.tests/src/org/eclipse/emf/edapt/tests/util/SplitContainment.java index 8c2ecbf..11de310 100644 --- a/tests/org.eclipse.emf.edapt.tests/src/org/eclipse/emf/edapt/tests/util/SplitContainment.java +++ b/tests/org.eclipse.emf.edapt.tests/src/org/eclipse/emf/edapt/tests/util/SplitContainment.java @@ -75,8 +75,8 @@ public class SplitContainment { final Resource resource = resourceSet.createResource(uri); resource.getContents().add(element); } - - ResourceUtils.saveResourceSet(resourceSet); + + ResourceUtils.saveResourceSet(resourceSet, null); } /** |