Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
h4uges committed Sep 28, 2023
2 parents 53202ce + 22fd6ac commit eabbad5
Show file tree
Hide file tree
Showing 30 changed files with 293 additions and 282 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
release:
types: [created]
schedule:
- cron: '0 3 * * *' # run nightly at 3:00 am
- cron: '5 3 * * *' # run nightly at 3:05 am
workflow_call:

jobs:
Expand All @@ -18,7 +18,7 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Cache
uses: actions/cache@v3
with:
Expand Down
53 changes: 2 additions & 51 deletions .github/workflows/validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout DSLs
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: dsls
repository: vitruv-tools/Vitruv-DSLs
Expand Down Expand Up @@ -72,7 +72,7 @@ jobs:
name: dsls
path: dsls
- name: Checkout Case Studies
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: casestudies
repository: vitruv-tools/Vitruv-CaseStudies
Expand Down Expand Up @@ -110,52 +110,3 @@ jobs:
-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.NoOpLog
env:
MAVEN_OPTS: -Djansi.force=true

validate_tool_adapters:
needs: [validate_framework]
name: Tool Adapters
runs-on: ubuntu-latest
steps:
- name: Download Framework Artifact
uses: actions/download-artifact@v3
with:
name: framework
path: framework
- name: Checkout Tool Adapters
uses: actions/checkout@v3
with:
path: tool_adapters
repository: vitruv-tools/Vitruv-Tool-Adapters
ref: main
fetch-depth: 0
- name: Checkout Matching Tool Adapters Branch
run: |
cd tool_adapters
git checkout -B ${{ github.head_ref }} origin/${{ github.head_ref }} || true
- name: Cache
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml', '**/MANIFEST.MF') }}
restore-keys: ${{ runner.os }}-m2
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17
- name: Build and Verify Tools Adapters
uses: coactions/setup-xvfb@v1
with:
working-directory: ./tool_adapters
run: >
./mvnw -B -U package -Dmaven.test.skip=true
-Dvitruv.framework.url=file:///${{ github.workspace }}/framework
-Dstyle.color=always
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
-Dorg.slf4j.simpleLogger.log.org.eclipse.tycho.core.resolver.DefaultTychoResolver=warn
-Dorg.slf4j.simpleLogger.log.org.eclipse.tycho.osgi.configuration.MavenContextConfigurator=warn
-Dorg.slf4j.simpleLogger.log.org.eclipse.sisu.equinox.launching.internal.DefaultEquinoxLauncher=warn
-Dorg.slf4j.simpleLogger.log.org.eclipse.xtext.maven.XtextGenerateMojo=warn
-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.NoOpLog
env:
MAVEN_OPTS: -Djansi.force=true
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
# Vitruv V-SUM
# Vitruv
[![GitHub Action CI](https://github.com/vitruv-tools/Vitruv/actions/workflows/ci.yml/badge.svg)](https://github.com/vitruv-tools/Vitruv/actions/workflows/ci.yml)
[![Latest Release](https://img.shields.io/github/release/vitruv-tools/Vitruv.svg)](https://github.com/vitruv-tools/Vitruv/releases/latest)
[![Issues](https://img.shields.io/github/issues/vitruv-tools/Vitruv.svg)](https://github.com/vitruv-tools/Vitruv/issues)
[![License](https://img.shields.io/github/license/vitruv-tools/Vitruv.svg)](https://raw.githubusercontent.com/vitruv-tools/Vitruv/main/LICENSE)

[Vitruvius](https://vitruv.tools) is a framework for view-based software development. It assumes different models to be used for describing a software system,
which are automatically kept consistent by the framework and its applications. For general information on Vitruvius, see our [GitHub Organisation](https://github.com/vitruv-tools) and our [Wiki](https://github.com/vitruv-tools/.github/wiki).
[Vitruvius](https://vitruv.tools) is a framework for view-based (software) development.
It assumes different models to be used for describing a system, which are automatically kept consistent by the framework executing (semi-)automated rules that preserve consistency.
These models are modified only via views, which are projections from the underlying models.
For general information on Vitruvius, see our [GitHub Organisation](https://github.com/vitruv-tools) and our [Wiki](https://github.com/vitruv-tools/.github/wiki).

This project contains the central definition of a V-SUM (Virtual Single Underlying Model) containing development artifacts to be kept consistent and to be accessed and modified via views.
This project contains the central Vitruvius framework, providing the definition of a V-SUM (Virtual Single Underlying Model) containing development artifacts to be kept consistent and to be accessed and modified via views.
In the implementation, a V-SUM is called `VirtualModel`, which is instantiated with a set of `ChangePropagationSpecifications` (no matter whether they are developed with the [Vitruv-DSLs](https://github.com/vitruv-tools/Vitruv-DSLs) or just as an implementation of the interface defined in the [Vitruv-Change](https://github.com/vitruv-tools/Vitruv-Change) repository).
The `VirtualModel` then provides functionality to derive and modify views and to propagate the changes in these views back to the `VirtualModel`, which then executes the `ChangePropagationSpecifications` to preserve consistency.

## Installation

Vitruvius can be installed in Eclipse via the [nightly update site](https://vitruv.tools/updatesite/nightly). A wiki page provides [detailed instructions for using or extending Vitruvius](https://github.com/vitruv-tools/.github/wiki/Getting-Started).
Vitruvius can be installed in Eclipse via the [nightly update site](https://vitruv.tools/updatesite/nightly). A wiki page provides [detailed instructions for using or extending Vitruvius or parts of it](https://github.com/vitruv-tools/.github/wiki/Getting-Started).

## Project Development
## Framework-internal Dependencies

Vitruvius is realized as Eclipse plug-ins and depends on the following Eclipse tools:
- Eclipse Modeling Framework (EMF) _as the modelling environment_
- Xtend _for code_
This project depends on the following other projects from the Vitruvius framework:
- [Vitruv-Change](https://github.com/vitruv-tools/Vitruv-Change)
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import tools.vitruv.framework.views.ViewSelector

import static com.google.common.base.Preconditions.checkArgument

abstract package class AbstractViewType<S extends ViewSelector> implements ViewCreatingViewType<S> {
abstract package class AbstractViewType<S extends ViewSelector, Id> implements ViewCreatingViewType<S, Id> {
@Accessors(PUBLIC_GETTER)
val String name

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import org.eclipse.emf.ecore.resource.Resource
import org.eclipse.emf.ecore.resource.ResourceSet
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl
import org.eclipse.xtend.lib.annotations.Accessors
import tools.vitruv.change.atomic.hid.HierarchicalId
import tools.vitruv.change.atomic.uuid.Uuid
import tools.vitruv.change.composite.description.PropagatedChange
import tools.vitruv.change.composite.description.VitruviusChange
import tools.vitruv.change.composite.propagation.ChangePropagationListener
Expand All @@ -25,7 +27,7 @@ package class BasicView implements ModifiableView, ChangePropagationListener {
@Accessors(PUBLIC_GETTER, PROTECTED_SETTER)
var ViewSelection selection
@Accessors(PUBLIC_GETTER, PROTECTED_SETTER)
var ViewCreatingViewType<? extends ViewSelector> viewType
var ViewCreatingViewType<? extends ViewSelector, HierarchicalId> viewType
@Accessors(PUBLIC_GETTER, PROTECTED_SETTER)
var ChangeableViewSource viewSource
@Accessors(PROTECTED_GETTER)
Expand All @@ -35,7 +37,7 @@ package class BasicView implements ModifiableView, ChangePropagationListener {
boolean viewChanged
boolean closed

protected new(ViewCreatingViewType<? extends ViewSelector> viewType, ChangeableViewSource viewSource,
protected new(ViewCreatingViewType<? extends ViewSelector, HierarchicalId> viewType, ChangeableViewSource viewSource,
ViewSelection selection) {
checkArgument(viewType !== null, "view type must not be null")
checkArgument(viewSource !== null, "view selection must not be null")
Expand Down Expand Up @@ -88,7 +90,7 @@ package class BasicView implements ModifiableView, ChangePropagationListener {
modelChanged = true
}

override startedChangePropagation(VitruviusChange changeToPropagate) {
override startedChangePropagation(VitruviusChange<Uuid> changeToPropagate) {
// do nothing
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import org.eclipse.emf.ecore.resource.Resource
import org.eclipse.emf.ecore.resource.ResourceSet
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl
import org.eclipse.xtend.lib.annotations.Delegate
import tools.vitruv.change.atomic.hid.HierarchicalId
import tools.vitruv.change.composite.description.VitruviusChange
import tools.vitruv.change.composite.description.VitruviusChangeFactory
import tools.vitruv.framework.views.CommittableView
import tools.vitruv.framework.views.View
import tools.vitruv.change.changederivation.StateBasedChangeResolutionStrategy

import static com.google.common.base.Preconditions.checkArgument
import static com.google.common.base.Preconditions.checkState

Expand Down Expand Up @@ -75,7 +75,7 @@ class ChangeDerivingView implements ModifiableView, CommittableView {
view.close
}

private def VitruviusChange generateChange(Resource newState, Resource referenceState) {
private def VitruviusChange<HierarchicalId> generateChange(Resource newState, Resource referenceState) {
if (referenceState === null) {
return changeResolutionStrategy.getChangeSequenceForCreated(newState)
} else if (newState === null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package tools.vitruv.framework.views.impl

import java.util.List
import org.eclipse.xtend.lib.annotations.Delegate
import tools.vitruv.change.atomic.EChange
import tools.vitruv.change.atomic.EChangeIdManager
import tools.vitruv.change.atomic.id.IdResolver
import tools.vitruv.change.composite.description.VitruviusChangeResolver
import tools.vitruv.change.composite.recording.ChangeRecorder
import tools.vitruv.framework.views.CommittableView
import tools.vitruv.framework.views.View
Expand All @@ -13,9 +10,6 @@ import tools.vitruv.change.changederivation.StateBasedChangeResolutionStrategy
import static com.google.common.base.Preconditions.checkArgument
import static com.google.common.base.Preconditions.checkState

import static extension tools.vitruv.change.atomic.resolve.EChangeIdResolverAndApplicator.applyBackward
import static extension tools.vitruv.change.atomic.resolve.EChangeIdResolverAndApplicator.applyForward

/**
* A {@link View} that records changes to its resources and allows to propagate them
* back to the underlying models using the {@link #commitChanges} method.
Expand Down Expand Up @@ -43,21 +37,13 @@ class ChangeRecordingView implements ModifiableView, CommittableView {
changeRecorder.addToRecording(view.viewResourceSet)
changeRecorder.beginRecording()
}
def private void assignIds(List<EChange> changes) {
val idResolver = IdResolver.create(view.viewResourceSet)
val idManager = new EChangeIdManager(idResolver)
changes.toList.reverseView.forEach[applyBackward]
changes.forEach[
idManager.setOrGenerateIds(it)
it.applyForward(idResolver)
]
}

override commitChanges() {
view.checkNotClosed()
val recordedChange = changeRecorder.endRecording()
assignIds(recordedChange.EChanges)
view.viewType.commitViewChanges(this, recordedChange)
val changeResolver = VitruviusChangeResolver.forHierarchicalIds(view.viewResourceSet)
val unresolvedChanges = changeResolver.assignIds(recordedChange)
view.viewType.commitViewChanges(this, unresolvedChanges)
view.viewChanged = false
changeRecorder.beginRecording()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@
import java.util.function.Function;
import java.util.stream.Stream;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;

import edu.kit.ipd.sdq.commons.util.org.eclipse.emf.ecore.resource.ResourceCopier;
import tools.vitruv.change.atomic.EChangeUuidManager;
import tools.vitruv.change.atomic.id.IdResolver;
import tools.vitruv.change.atomic.hid.HierarchicalId;
import tools.vitruv.change.atomic.uuid.Uuid;
import tools.vitruv.change.atomic.uuid.UuidResolver;
import tools.vitruv.change.changederivation.DeltaBasedResourceUtil;
import tools.vitruv.change.composite.description.VitruviusChange;
import tools.vitruv.change.composite.description.VitruviusChangeResolver;
import tools.vitruv.framework.views.ChangeableViewSource;
import tools.vitruv.framework.views.View;
import tools.vitruv.framework.views.ViewSelection;
Expand All @@ -30,14 +32,14 @@
* selection mechanism and providing a one-to-one (identity) mapping of elements
* within the {@link ViewSource} to a created {@link View}.
*/
public class IdentityMappingViewType extends AbstractViewType<DirectViewElementSelector> {
public class IdentityMappingViewType extends AbstractViewType<DirectViewElementSelector<HierarchicalId>, HierarchicalId> {
public IdentityMappingViewType(String name) {
super(name);
}

@Override
public DirectViewElementSelector createSelector(ChangeableViewSource viewSource) {
return new DirectViewElementSelector(this, viewSource,
public DirectViewElementSelector<HierarchicalId> createSelector(ChangeableViewSource viewSource) {
return new DirectViewElementSelector<>(this, viewSource,
viewSource.getViewSourceModels().stream().map(resource -> {
if (!resource.getContents().isEmpty() && ResourceCopier.requiresFullCopy(resource)) {
// Some resources (like UML) can only be copied as a whole, so no option to select
Expand All @@ -49,7 +51,7 @@ public DirectViewElementSelector createSelector(ChangeableViewSource viewSource)
}

@Override
public ModifiableView createView(DirectViewElementSelector selector) {
public ModifiableView createView(DirectViewElementSelector<HierarchicalId> selector) {
checkArgument(selector.getViewType() == this, "cannot create view with selector for different view type");
return new BasicView(selector.getViewType(), selector.getViewSource(), selector.getSelection());
}
Expand All @@ -64,16 +66,18 @@ public void updateView(ModifiableView view) {
}

@Override
public void commitViewChanges(ModifiableView view, VitruviusChange viewChange) {
public void commitViewChanges(ModifiableView view, VitruviusChange<HierarchicalId> viewChange) {
ResourceSet viewSourceCopyResourceSet = DeltaBasedResourceUtil.withDeltaFactory(new ResourceSetImpl());
IdResolver viewSourceCopyIdResolver = IdResolver.create(viewSourceCopyResourceSet);
VitruviusChangeResolver<HierarchicalId> idChangeResolver = VitruviusChangeResolver.forHierarchicalIds(viewSourceCopyResourceSet);

UuidResolver viewSourceCopyUuidResolver = UuidResolver.create(viewSourceCopyResourceSet);
VitruviusChangeResolver<Uuid> uuidChangeResolver = VitruviusChangeResolver.forUuids(viewSourceCopyUuidResolver);
Map<Resource, Resource> mapping = createViewResources(view, viewSourceCopyResourceSet);
view.getViewSource().getUuidResolver().resolveResources(mapping, viewSourceCopyUuidResolver);

VitruviusChange resolvedChange = viewChange.unresolve().resolveAndApply(viewSourceCopyIdResolver);
EChangeUuidManager.setOrGenerateIds(resolvedChange.getEChanges(), viewSourceCopyUuidResolver);
view.getViewSource().propagateChange(resolvedChange.unresolve());
VitruviusChange<EObject> resolvedChange = idChangeResolver.resolveAndApply(viewChange);
VitruviusChange<Uuid> unresolvedChanges = uuidChangeResolver.assignIds(resolvedChange);
view.getViewSource().propagateChange(unresolvedChanges);
}

private Map<Resource, Resource> createViewResources(ModifiableView view, ResourceSet viewResourceSet) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
* A specific view type that is able to create and update views. This is not its
* public interface but only for internal usage by views and their selectors.
*
* @param <S> the type of view selector this view type uses
* @param <S> the type of view selector this view type uses.
* @param <Id> the type of Id the changes to commit must have.
*/
public interface ViewCreatingViewType<S extends ViewSelector> extends ViewType<S> {
public interface ViewCreatingViewType<S extends ViewSelector, Id> extends ViewType<S> {
/**
* Creates a view for the given {@link ViewSelector}. The selector must have
* been created by calling the {@link #createSelector} method of the same
Expand All @@ -35,11 +36,10 @@ public interface ViewCreatingViewType<S extends ViewSelector> extends ViewType<S
* underlying {@link ChangeableViewSource}. Since view elements do not
* necessarily correspond to elements of the underlying view source, the view
* type is responsible for transforming the given {@link VitruviusChange} such
* that the underlying view source can process it. The given changes must use
* hierarchical IDs and may be unresolved.
* that the underlying view source can process it.
*
* @param view is the modified view.
* @param viewChange are the changes performed to the view.
*/
void commitViewChanges(ModifiableView view, VitruviusChange viewChange);
void commitViewChanges(ModifiableView view, VitruviusChange<Id> viewChange);
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ import static com.google.common.base.Preconditions.checkState
* and view elements (such as selecting types but providing instances in the view),
* but a selection is performed on the view elements themselves.
*/
class DirectViewElementSelector implements ViewSelector {
class DirectViewElementSelector<Id> implements ViewSelector {
@Delegate
val ModifiableViewSelection viewSelection

@Accessors(PUBLIC_GETTER)
val ChangeableViewSource viewSource

@Accessors(PUBLIC_GETTER)
val ViewCreatingViewType<DirectViewElementSelector> viewType
val ViewCreatingViewType<DirectViewElementSelector<Id>, Id> viewType

/**
* Creates a new selector based on the given collection of selectable elements
Expand All @@ -43,7 +43,7 @@ class DirectViewElementSelector implements ViewSelector {
* @param selectableElements - the elements to select from to be used by the
* {@link ViewType} when creating a view
*/
new(ViewCreatingViewType<DirectViewElementSelector> viewType, ChangeableViewSource viewSource,
new(ViewCreatingViewType<DirectViewElementSelector<Id>, Id> viewType, ChangeableViewSource viewSource,
Collection<EObject> selectableElements) {
checkArgument(selectableElements !== null, "selectable elements must not be null")
checkArgument(viewType !== null, "view type must not be null")
Expand Down
Loading

0 comments on commit eabbad5

Please sign in to comment.