Skip to content

Package: DmrToSegmentsMigrator$PreReplaceProcessor

DmrToSegmentsMigrator$PreReplaceProcessor

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2019 EclipseSource Muenchen GmbH and others.
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License 2.0
6: * which accompanies this distribution, and is available at
7: * https://www.eclipse.org/legal/epl-2.0/
8: *
9: * SPDX-License-Identifier: EPL-2.0
10: *
11: * Contributors:
12: * Lucas Koehler - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emfforms.spi.ide.view.segments;
15:
16: import org.eclipse.emf.common.util.URI;
17: import org.eclipse.emf.ecp.view.spi.model.VDomainModelReference;
18:
19: /**
20: * Service which replaces all legacy domain model references of a view model with equivalent plain DMRs containing the
21: * corresponding segments.
22: *
23: * @author Lucas Koehler
24: * @since 1.22
25: */
26: public interface DmrToSegmentsMigrator {
27:
28:         /**
29:          * Checks whether a view model still contains legacy domain model references that need to be migrated to segments.
30:          *
31:          * @param resourceUri The URI of the view model that should be checked.
32:          * @return true, if the view model requires a migration, false otherwise.
33:          */
34:         boolean needsMigration(URI resourceUri);
35:
36:         /**
37:          * Migrates a view model to use segment based DMRs. This replaces all legacy DMRs from the view model and replaces
38:          * them with segment based DMRs. This is not undoable!
39:          *
40:          * @param resourceUri The URI of the view model that should be migrated.
41:          * @param preReplaceProcessors {@link PreReplaceProcessor} which are executed just before a legacy dmr is replaced
42:          * with the corresponding segment dmr. The processors are always executed in the given order
43:          * @throws DmrToSegmentsMigrationException if the migration fails
44:          */
45:         void performMigration(URI resourceUri, PreReplaceProcessor... preReplaceProcessors)
46:                 throws DmrToSegmentsMigrationException;
47:
48:         /**
49:          * Processor that is executed after segments have been generated for the new segment based dmr but before the legacy
50:          * dmr is replaced in the model. The processor may alter any of the two dmrs or any other part of the containing
51:          * resource.
52:          */
53:         @FunctionalInterface
54:         public interface PreReplaceProcessor {
55:                 /**
56:                  * <p>
57:                  * Processes the legacy dmr, the segment dmr or any related EObject <strong>before</strong> the legacy dmr is
58:                  * replaced with the segment dmr in the model.
59:                  * </p>
60:                  * <p>
61:                  * This may also alter the model including the legacy dmr or the segment dmr.
62:                  *
63:                  * @param legacyDmr The legacy dmr which will be replaced in the model
64:                  * @param segmentDmr The segment based dmr which is already filled with segments based on the legacy dmr
65:                  */
66:                 void process(VDomainModelReference legacyDmr, VDomainModelReference segmentDmr);
67:         }
68: }