Skip to content
Snippets Groups Projects
Commit dad2a86e authored by Simon Spinner's avatar Simon Spinner
Browse files

Add DelegateConnectors and CompositeComponent + various fixes.

parent 72b6f490
No related branches found
No related tags found
No related merge requests found
Showing
with 53 additions and 31 deletions
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
......
......@@ -2,9 +2,9 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Prisma Core
Bundle-SymbolicName: tools.descartes.prisma.core
Bundle-Version: 1.0.0.qualifier
Bundle-Version: 0.1.0.qualifier
Bundle-Vendor: Descartes Research Group
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Require-Bundle: org.eclipse.emf.ecore;bundle-version="2.10.2",
edu.kit.ipd.descartes.mm.applicationlevel;bundle-version="1.1.0",
edu.kit.ipd.descartes.mm.deployment;bundle-version="1.1.0",
......
......@@ -68,7 +68,9 @@ public class ApplicationModel {
for (ModelCommand<?,?> currentCommand : commands) {
currentCommand.setContext(context);
}
for (ModelCommand<?,?> currentCommand : commands) {
currentCommand.apply(null);
}
try {
transaction.commit();
successful = true;
......
......@@ -9,44 +9,61 @@ import edu.kit.ipd.descartes.mm.deployment.Deployment;
import edu.kit.ipd.descartes.mm.resourcelandscape.DistributedDataCenter;
import edu.kit.ipd.descartes.mm.usageprofile.UsageProfile;
import tools.descartes.prisma.core.ApplicationModel;
import tools.descartes.prisma.core.commands.repository.RepositoryCommand;
import tools.descartes.prisma.core.commands.system.SystemCommand;
public class CommandContext {
private final ApplicationModel application;
private final CDOTransaction transaction;
private CDOResource repositoryResource = null;
private DistributedDataCenter resourcelandscape = null;
private Repository repository = null;
private System system = null;
private final RepositoryCommand repository;
private final SystemCommand system;
private Deployment deployment = null;
private UsageProfile usageProfile = null;
public CommandContext(ApplicationModel application, CDOTransaction transaction) {
this.application = application;
this.transaction = transaction;
this.transaction = transaction;
this.repository = new RepositoryCommand();
this.repository.setContext(this);
this.system = new SystemCommand();
this.system.setContext(this);
}
public String getApplicationName() {
return application.getApplicationName();
}
public CDOResource getResourceLandscape() {
public CDOResource getResourceLandscapeResource() {
return transaction.getOrCreateResource(application.getResourceLandscapePath());
}
public CDOResource getRepository() {
return transaction.getOrCreateResource(application.getRepositoryPath());
public Repository getRepository() {
return repository.get(null);
}
public CDOResource getRepositoryResource() {
if (repositoryResource == null) {
repositoryResource = transaction.getOrCreateResource(application.getRepositoryPath());
}
return repositoryResource;
}
public CDOResource getSystem() {
public CDOResource getSystemResource() {
return transaction.getOrCreateResource(application.getSystemPath());
}
public CDOResource getDeployment() {
public CDOResource getDeploymentResource() {
return transaction.getOrCreateResource(application.getDeploymentPath());
}
public CDOResource getUsageProfile() {
public CDOResource getUsageProfileResource() {
return transaction.getOrCreateResource(application.getUsageProfilePath());
}
......
......@@ -38,7 +38,7 @@ public abstract class ModelCommand<P extends EObject, E extends EObject> {
protected E find(Collection<?> list) {
for (Object cur : list) {
if (cur.getClass().isAssignableFrom(elementType)) {
if (elementType.isAssignableFrom(cur.getClass())) {
E casted = elementType.cast(cur);
if (matches(casted)) {
return casted;
......
......@@ -25,9 +25,7 @@ public class AssemblyContextCommand extends ModelCommand<ComposedStructure, Asse
@Override
protected AssemblyContext create(ComposedStructure parent) {
RepositoryCommand repo = new RepositoryCommand();
repo.setContext(getContext());
RepositoryComponent encapsulated = component.get(repo.get(null));
RepositoryComponent encapsulated = component.get(getContext().getRepository());
AssemblyContext assembly = RepositoryFactory.eINSTANCE.createAssemblyContext();
assembly.setId("AssemblyContext_" + getId(assemblyContextName));
assembly.setName(assemblyContextName);
......
package tools.descartes.prisma.core.commands.repository;
import edu.kit.ipd.descartes.mm.applicationlevel.repository.Interface;
import edu.kit.ipd.descartes.mm.applicationlevel.repository.InterfaceProvidingEntity;
import edu.kit.ipd.descartes.mm.applicationlevel.repository.InterfaceProvidingRole;
import edu.kit.ipd.descartes.mm.applicationlevel.repository.InterfaceRequiringRole;
import edu.kit.ipd.descartes.mm.applicationlevel.repository.RepositoryComponent;
import edu.kit.ipd.descartes.mm.applicationlevel.repository.RepositoryFactory;
import edu.kit.ipd.descartes.mm.applicationlevel.repository.RepositoryPackage;
import tools.descartes.prisma.core.commands.ModelCommand;
public class InterfaceProvidingRoleCommand extends ModelCommand<RepositoryComponent, InterfaceProvidingRole> {
public class InterfaceProvidingRoleCommand extends ModelCommand<InterfaceProvidingEntity, InterfaceProvidingRole> {
private final String portName;
private final InterfaceCommand interfaceCmd;
......@@ -26,8 +25,8 @@ public class InterfaceProvidingRoleCommand extends ModelCommand<RepositoryCompon
}
@Override
protected InterfaceProvidingRole create(RepositoryComponent parent) {
Interface interf = interfaceCmd.get(parent.getRepository());
protected InterfaceProvidingRole create(InterfaceProvidingEntity parent) {
Interface interf = interfaceCmd.get(getContext().getRepository());
InterfaceProvidingRole providingRole = RepositoryFactory.eINSTANCE.createInterfaceProvidingRole();
providingRole.setName(portName);
providingRole.setInterface(interf);
......
package tools.descartes.prisma.core.commands.repository;
import edu.kit.ipd.descartes.mm.applicationlevel.repository.Interface;
import edu.kit.ipd.descartes.mm.applicationlevel.repository.InterfaceRequiringEntity;
import edu.kit.ipd.descartes.mm.applicationlevel.repository.InterfaceRequiringRole;
import edu.kit.ipd.descartes.mm.applicationlevel.repository.RepositoryComponent;
import edu.kit.ipd.descartes.mm.applicationlevel.repository.RepositoryFactory;
import edu.kit.ipd.descartes.mm.applicationlevel.repository.RepositoryPackage;
import tools.descartes.prisma.core.commands.ModelCommand;
public class InterfaceRequiringRoleCommand extends ModelCommand<RepositoryComponent, InterfaceRequiringRole> {
public class InterfaceRequiringRoleCommand extends ModelCommand<InterfaceRequiringEntity, InterfaceRequiringRole> {
private final String portName;
private final InterfaceCommand interfaceCmd;
......@@ -25,8 +26,8 @@ public class InterfaceRequiringRoleCommand extends ModelCommand<RepositoryCompon
}
@Override
protected InterfaceRequiringRole create(RepositoryComponent parent) {
Interface interf = interfaceCmd.get(parent.getRepository());
protected InterfaceRequiringRole create(InterfaceRequiringEntity parent) {
Interface interf = interfaceCmd.get(getContext().getRepository());
InterfaceRequiringRole requiringRole = RepositoryFactory.eINSTANCE.createInterfaceRequiringRole();
requiringRole.setName(portName);
requiringRole.setInterface(interf);
......
......@@ -18,10 +18,10 @@ public class RepositoryCommand extends ModelCommand<Repository, Repository> {
@Override
public Repository get(Repository parent) {
Repository repo = find(getContext().getRepository().getContents());
Repository repo = find(getContext().getRepositoryResource().getContents());
if (repo == null) {
repo = create(null);
getContext().getRepository().getContents().add(repo);
getContext().getRepositoryResource().getContents().add(repo);
}
return repo;
}
......@@ -31,6 +31,11 @@ public class RepositoryCommand extends ModelCommand<Repository, Repository> {
return this;
}
public RepositoryCommand add(RepositoryComponentCommand<?> component) {
components.add(component);
return this;
}
@Override
public List<ModelCommand<Repository, ?>> getChildCommands() {
List<ModelCommand<Repository,?>> children = new LinkedList<>();
......
......@@ -36,7 +36,7 @@ public abstract class RepositoryComponentCommand<E extends RepositoryComponent>
}
@Override
public boolean matches(RepositoryComponent object) {
public boolean matches(E object) {
return object.getName().equals(componentName);
}
......
......@@ -10,7 +10,7 @@ public class SignatureCommand extends ModelCommand<Interface, Signature> {
private final String signatureName;
private SignatureCommand(String signatureName) {
public SignatureCommand(String signatureName) {
super(RepositoryPackage.Literals.INTERFACE__SIGNATURES, Signature.class);
this.signatureName = signatureName;
}
......
......@@ -20,10 +20,10 @@ public class SystemCommand extends ModelCommand<System, System> {
@Override
public System get(System parent) {
System system = find(getContext().getSystem().getContents());
System system = find(getContext().getSystemResource().getContents());
if (system == null) {
system = create(null);
getContext().getRepository().getContents().add(system);
getContext().getSystemResource().getContents().add(system);
}
return system;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment