Commit bc9ef8c3 authored by Faezeh KHORRAM's avatar Faezeh KHORRAM 💬
Browse files

remove files

parent 6965c42b
......@@ -18,9 +18,7 @@ Require-Bundle: fr.inria.diverse.k3.al.annotationprocessor.plugin;bundle-version
org.eclipse.gemoc.executionframework.behavioralinterface;bundle-version="1.0.0",
org.imt.tdl.testResult;bundle-version="1.0.0",
org.imt.tdl.rt.ui;bundle-version="1.0.0",
org.imt.tdl.eventManager,
org.imt.tdl.executionEngine,
org.imt.tdl.oclInterpreter
org.imt.tdl.configuration;bundle-version="1.0.0"
Bundle-ClassPath: .
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Export-Package: org.imt.k3tdl.k3dsa
package org.imt.k3tdl.k3dsa
import fr.inria.diverse.k3.al.annotationprocessor.Aspect
import fr.inria.diverse.k3.al.annotationprocessor.InitializeModel
import fr.inria.diverse.k3.al.annotationprocessor.Main
import fr.inria.diverse.k3.al.annotationprocessor.Step
......@@ -16,13 +14,11 @@ import org.etsi.mts.tdl.TestDescription
import org.imt.tdl.executionEngine.EngineFactory
import org.imt.tdl.testResult.TDLTestCaseResult
import org.imt.tdl.testResult.TDLTestPackageResult
import org.imt.tdl.testResult.ui.TDLTestResultsView
import org.imt.tdl.testResult.TestResultUtil
import static extension org.imt.k3tdl.k3dsa.BehaviourDescriptionAspect.*
import static extension org.imt.k3tdl.k3dsa.TestConfigurationAspect.*
import static extension org.imt.k3tdl.k3dsa.TestDescriptionAspect.*
import static extension org.imt.k3tdl.k3dsa.PackageAspect.*
import org.imt.tdl.testResult.TestResultUtil
@Aspect(className = Package)
class PackageAspect {
......
package org.imt.k3tdl.k3dsa
import fr.inria.diverse.k3.al.annotationprocessor.Aspect
import fr.inria.diverse.k3.al.annotationprocessor.Step
import fr.inria.diverse.k3.al.annotationprocessor.OverrideAspectMethod
......
......@@ -4,6 +4,7 @@ import fr.inria.diverse.k3.al.annotationprocessor.Aspect
import fr.inria.diverse.k3.al.annotationprocessor.Step
import org.eclipse.emf.common.util.URI
import org.eclipse.emf.ecore.EObject
......@@ -15,7 +16,7 @@ import org.etsi.mts.tdl.GateInstance
import org.etsi.mts.tdl.GateType
import org.etsi.mts.tdl.LiteralValueUse
import org.etsi.mts.tdl.StaticDataUse
import org.imt.tdl.configuration.impl.EngineFactory
import org.imt.tdl.executionEngine.EngineFactory
import static extension org.imt.k3tdl.k3dsa.DataInstanceAspect.*
import static extension org.imt.k3tdl.k3dsa.DataInstanceUseAspect.*
......
......@@ -3,8 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: CustomLaunchConfig
Bundle-SymbolicName: org.imt.tdl.configuration
Bundle-Version: 1.0.0.qualifier
Export-Package: org.imt.tdl.eventManager,
org.imt.tdl.executionEngine,
Export-Package: org.imt.tdl.executionEngine,
org.imt.tdl.oclInterpreter
Require-Bundle: org.eclipse.core.runtime;bundle-version="3.17.100",
org.eclipse.core.resources;bundle-version="3.13.700",
......@@ -32,5 +31,6 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.17.100",
org.eclipse.emf.transaction;bundle-version="1.9.1",
org.eclipse.emf.ecoretools.ale.xtext;bundle-version="1.2.0",
org.eclipse.gemoc.executionframework.behavioralinterface;bundle-version="1.0.0",
org.eclipse.gemoc.executionframework.event.model;bundle-version="4.0.0"
org.eclipse.gemoc.executionframework.event.model;bundle-version="4.0.0",
org.eclipse.gemoc.executionframework.event.manager;bundle-version="4.0.0"
Import-Package: org.eclipse.emf.ecore.provider
package org.imt.tdl.eventManager;
import java.util.HashMap;
import java.util.Map;
public abstract class BehavioralUnitNotification {
private final String behavioralUnit;
private final Map<String, Object> arguments = new HashMap<>();
public BehavioralUnitNotification(String behavioralUnit, Map<String, Object> arguments) {
this.behavioralUnit = behavioralUnit;
this.arguments.putAll(arguments);
}
public String getBehavioralUnit() {
return behavioralUnit;
}
public Map<String, Object> getArguments() {
return arguments;
}
}
package org.imt.tdl.eventManager;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class CompositeCallRequest implements ICallRequest {
private final List<SimpleCallRequest> callRequests;
public CompositeCallRequest(List<SimpleCallRequest> callRequests) {
this.callRequests = Collections.unmodifiableList(new ArrayList<>(callRequests));
}
public List<SimpleCallRequest> getCallRequests() {
return callRequests;
}
@Override
public boolean isRunToCompletion() {
return true;
}
}
package org.imt.tdl.eventManager;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
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.emf.ecoretools.ale.ExtendedClass;
import org.eclipse.emf.ecoretools.ale.Unit;
import org.eclipse.gemoc.dsl.Dsl;
import org.eclipse.gemoc.executionframework.behavioralinterface.behavioralInterface.BehavioralInterface;
import org.eclipse.gemoc.executionframework.behavioralinterface.behavioralInterface.Event;
import org.eclipse.gemoc.executionframework.event.model.event.EventOccurrence;
import org.eclipse.gemoc.xdsmlframework.api.core.IExecutionEngine;
import org.osgi.framework.Bundle;
public class GenericEventManager implements IEventManager{
private final List<EPackage> packages = new ArrayList<>();
private final List<Class<?>> operationalSemantics = new ArrayList<>();
private IExecutionEngine<?> engine;
private final RelationshipManager relationshipManager;
public GenericEventManager(String languageName, Resource executedResource,
IImplementationRelationship implementationRelationships) {
loadLanguage(languageName);
relationshipManager = new RelationshipManager(this);
//implementationRelationships.forEach(r -> relationshipManager.registerImplementationRelationship(r));
}
public void setUp() {
}
private void dispatchEvent(ICallRequest callRequest) {
if (callRequest instanceof StopRequest) {
engine.stop();
} else if (callRequest instanceof CompositeCallRequest) {
((CompositeCallRequest) callRequest).getCallRequests().forEach(cr -> dispatchEvent(cr));
} else if (callRequest instanceof SimpleCallRequest) {
final SimpleCallRequest simpleCallRequest = (SimpleCallRequest) callRequest;
final Method rule = findMethod(simpleCallRequest);
performCall(rule, simpleCallRequest.getArguments());
}
}
private Object performCall(Method toCall, List<Object> args) {
Object result = null;
try {
result = toCall.invoke(null, args.toArray());
} catch (Throwable e1) {
e1.printStackTrace();
}
return result;
}
private void loadLanguage(String languageName) {
final ResourceSet resSet = new ResourceSetImpl();
IConfigurationElement language = Arrays
.asList(Platform.getExtensionRegistry()
.getConfigurationElementsFor("org.eclipse.gemoc.gemoc_language_workbench.sequential.xdsml"))
.stream().filter(l -> l.getAttribute("xdsmlFilePath").endsWith(".dsl")
&& l.getAttribute("name").equals(languageName))
.findFirst().orElse(null);
if (language != null) {
Resource res = resSet.getResource(URI.createURI(language.getAttribute("xdsmlFilePath")), true);
Dsl dsl = (Dsl)res.getContents().get(0);
if (dsl.getEntry("k3") != null) {
//String classes = dsl.getEntry("k3").getValue();
final Bundle bundle = Platform.getBundle(language.getContributor().getName());
final List<Class<?>> classes = dsl.getEntries().stream().filter(e -> e.getKey().equals("k3"))
.findFirst()
.map(os -> Arrays.asList(os.getValue().split(",")).stream().map(cn -> loadClass(cn, bundle))
.filter(c -> c != null).collect(Collectors.toList()))
.orElse(Collections.emptyList()).stream().map(c -> (Class<?>) c).collect(Collectors.toList());
this.operationalSemantics.addAll(classes);
}
}
}
private Class<?> loadClass(String className, Bundle bundle) {
Class<?> result = null;
try {
result = bundle.loadClass(className.replaceAll("\\s", "").trim());
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
return result;
}
private Method findMethod(SimpleCallRequest callRequest) {
final Class<?>[] parameters = (Class[]) callRequest.getArguments().stream().map(o -> o.getClass())
.collect(Collectors.toList()).toArray(new Class[0]);
final String methodName = callRequest.getBehavioralUnit();
final Method method = this.operationalSemantics.stream().filter(c -> methodName.startsWith(c.getName()))
.map(c -> findMethodInClass(c, methodName.substring(c.getName().length() + 1), parameters))
.filter(m -> m != null).findFirst().orElse(null);
return method;
}
private Method findMethodInClass(Class<?> clazz, String name, Class<?>[] parameters) {
return Arrays.stream(clazz.getDeclaredMethods()).map(m -> {
Method result = null;
if (m.getName().equals(name) && m.getParameterCount() == parameters.length) {
final Class<?>[] t = m.getParameterTypes();
result = m;
for (int i = 0; i < t.length; i++) {
Class<?> type = t[i];
if (!type.isAssignableFrom(parameters[i])) {
result = null;
break;
}
}
}
return result;
}).filter(m -> m != null).findFirst().orElse(null);
}
@Override
public IRelationshipManager getRelationshipManager() {
// TODO Auto-generated method stub
return null;
}
@Override
public void processEventOccurrence(EventOccurrence event) {
// TODO Auto-generated method stub
}
@Override
public void processCallRequests() {
// TODO Auto-generated method stub
}
@Override
public void waitForCallRequests() {
// TODO Auto-generated method stub
}
@Override
public Set<BehavioralInterface> getBehavioralInterfaces() {
// TODO Auto-generated method stub
return null;
}
@Override
public Set<Event> getEvents() {
// TODO Auto-generated method stub
return null;
}
@Override
public void emitEventOccurrence(EventOccurrence eventOccurrence) {
// TODO Auto-generated method stub
}
@Override
public void processCallRequest(ICallRequest callRequest) {
// TODO Auto-generated method stub
}
}
package org.imt.tdl.eventManager;
public interface ICallRequest {
boolean isRunToCompletion();
}
package org.imt.tdl.eventManager;
import java.util.Set;
import org.eclipse.gemoc.executionframework.behavioralinterface.behavioralInterface.Event;
import org.eclipse.gemoc.executionframework.behavioralinterface.behavioralInterface.BehavioralInterface;
import org.eclipse.gemoc.executionframework.event.model.event.EventOccurrence;
import org.eclipse.gemoc.xdsmlframework.api.engine_addon.IEngineAddon;
public interface IEventManager extends IEngineAddon {
IRelationshipManager getRelationshipManager();
void processEventOccurrence(EventOccurrence event);
void processCallRequests();
void waitForCallRequests();
//void addListener(IEventManagerListener listener);
//void removeListener(IEventManagerListener listener);
Set<BehavioralInterface> getBehavioralInterfaces();
Set<Event> getEvents();
void emitEventOccurrence(EventOccurrence eventOccurrence);
void processCallRequest(ICallRequest callRequest);
}
\ No newline at end of file
package org.imt.tdl.eventManager;
import java.util.Map;
import org.eclipse.gemoc.executionframework.behavioralinterface.behavioralInterface.BehavioralInterface;
import org.eclipse.gemoc.executionframework.event.model.event.EventOccurrence;
public interface IImplementationRelationship {
Map<String, String> computeEventToMethodMap();
BehavioralInterface getBehavioralInterface();
void processEventOccurrence(EventOccurrence eventOccurrence);
void processCallNotification(BehavioralUnitNotification callNotification);
}
package org.imt.tdl.eventManager;
import java.util.Set;
import org.eclipse.gemoc.executionframework.event.model.event.EventOccurrence;
import org.eclipse.gemoc.executionframework.behavioralinterface.behavioralInterface.Event;
public interface IRelationshipManager {
void registerImplementationRelationship(IImplementationRelationship implementationRelationship);
void unregisterImplementationRelationship(IImplementationRelationship implementationRelationship);
void notifyEventOccurrence(EventOccurrence eventOccurrence);
void notifyCallRequest(ICallRequest callRequest);
void notifyCall(BehavioralUnitNotification callNotification);
Set<Event> getEvents();
}
package org.imt.tdl.eventManager;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.BiConsumer;
import java.util.stream.Collectors;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.gemoc.executionframework.event.model.event.EventOccurrence;
import org.eclipse.gemoc.executionframework.event.model.event.EventOccurrenceType;
import org.eclipse.gemoc.executionframework.behavioralinterface.behavioralInterface.BehavioralInterface;
import org.eclipse.gemoc.executionframework.behavioralinterface.behavioralInterface.Event;
public class RelationshipManager implements IRelationshipManager {
private final IEventManager eventManager;
private final Map<String, BehavioralInterface> uriToBehavioralInterface = new HashMap<>();
private final Set<IImplementationRelationship> implementationRelationships = new HashSet<>();
private final Map<String, List<IImplementationRelationship>> inputImplementationRelationships = new HashMap<>();
public RelationshipManager(IEventManager eventManager) {
this.eventManager = eventManager;
}
public void setExecutedResource(Resource executedResource) {
//inputSubtypingRelationships.values().stream().flatMap(l -> l.stream())
//.forEach(r -> r.setExecutedResource(executedResource));
}
/*
* Called by the event manager when it receives event occurrences and by
* relationships when a detected pattern
*/
@Override
public void notifyEventOccurrence(EventOccurrence eventOccurrence) {
final Event event = eventOccurrence.getEvent();
final BehavioralInterface behavioralInterface = (BehavioralInterface) event.eContainer();
final String uri = behavioralInterface.eResource().getURI().toString();
if (eventOccurrence.getType() == EventOccurrenceType.ACCEPTED) {
inputImplementationRelationships.computeIfAbsent(uri, bi -> new ArrayList<>())
.forEach(r -> r.processEventOccurrence(eventOccurrence));
} else {
eventManager.emitEventOccurrence(eventOccurrence);
}
}
@Override
public void notifyCallRequest(ICallRequest callRequest) {
eventManager.processCallRequest(callRequest);
}
@Override
public void notifyCall(BehavioralUnitNotification callNotification) {
implementationRelationships.forEach(rel -> rel.processCallNotification(callNotification));
}
/*
* Relationship registration stuff
*/
@Override
public void registerImplementationRelationship(IImplementationRelationship implementationRelationship) {
implementationRelationships.add(implementationRelationship);
final String uri = implementationRelationship.getBehavioralInterface().eResource().getURI().toString();
final List<IImplementationRelationship> relationships = inputImplementationRelationships.computeIfAbsent(uri,
k -> new ArrayList<>());
relationships.add(implementationRelationship);
//implementationRelationship.configure(e -> notifyEventOccurrence(e), cr -> notifyCallRequest(cr));
uriToBehavioralInterface.computeIfAbsent(uri, k -> implementationRelationship.getBehavioralInterface());
}
@Override
public void unregisterImplementationRelationship(IImplementationRelationship implementationRelationship) {
final String uri = implementationRelationship.getBehavioralInterface().eResource().getURI().toString();
final List<IImplementationRelationship> relationships = inputImplementationRelationships.get(uri);
if (relationships != null) {
relationships.remove(implementationRelationship);
}
implementationRelationships.remove(implementationRelationship);
}
private Set<BehavioralInterface> getAllBehavioralInterfaces() {
final Set<BehavioralInterface> result = new HashSet<>();
final BiConsumer<String, List<?>> c = (k, v) -> {
if (v != null && !v.isEmpty()) {
result.add(uriToBehavioralInterface.get(k));
}
};
inputImplementationRelationships.forEach(c);
return result;
}
@Override
public Set<Event> getEvents() {
return getAllBehavioralInterfaces().stream().flatMap(i -> i.getEvents().stream()).collect(Collectors.toSet());
}
}
package org.imt.tdl.eventManager;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class SimpleCallRequest implements ICallRequest {
private final String behavioralUnit;
private final List<Object> arguments;
private final boolean runToCompletion;
public SimpleCallRequest(String behavioralUnit, List<Object> arguments, boolean runToCompletion) {
this.behavioralUnit = behavioralUnit;
this.arguments = Collections.unmodifiableList(new ArrayList<>(arguments));
this.runToCompletion = runToCompletion;
}
public String getBehavioralUnit() {
return behavioralUnit;
}
public List<Object> getArguments() {
return arguments;
}
@Override
public boolean isRunToCompletion() {
return runToCompletion;
}
}
package org.imt.tdl.eventManager;
public class StopRequest implements ICallRequest {
@Override
public boolean isRunToCompletion() {
return true;
}
}
package org.imt.tdl.executionEngine;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Optional;
......
package org.imt.tdl.executionEngine;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import java.util.ArrayList;
import java.util.Map;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.gemoc.dsl.Dsl;
import org.eclipse.gemoc.executionframework.engine.commons.EngineContextException;
import org.eclipse.ocl.ParserException;
import org.imt.tdl.eventManager.GenericEventManager;
import org.eclipse.gemoc.executionframework.event.manager.GenericEventManager;
import org.imt.tdl.oclInterpreter.OCLInterpreter;
import org.eclipse.gemoc.dsl.Dsl;
import org.eclipse.gemoc.execution.sequential.javaengine.PlainK3ExecutionEngine;
public class EngineFactory{
......@@ -41,7 +38,6 @@ public class EngineFactory{
}else if(commandType.equals(DSL_SPECIFIC)) {
if (this.eventManager == null) {
//this.eventManager = new GenericEventManager();
this.eventManager.setUp();
}