Skip to content
Snippets Groups Projects
Commit 4ab19f5c authored by Johannes Mey's avatar Johannes Mey
Browse files

removed unused modules

parent 58491c98
No related branches found
No related tags found
No related merge requests found
Showing
with 0 additions and 781 deletions
/*******************************************************************************
* Copyright (c) 2010-2015, Benedek Izso, Gabor Szarnyas, Istvan Rath and Daniel Varro
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Benedek Izso - initial API and implementation
* Gabor Szarnyas - initial API and implementation
*******************************************************************************/
package hu.bme.mit.trainbenchmark.benchmark.drools.matches;
import static hu.bme.mit.trainbenchmark.constants.QueryConstants.VAR_ROUTE;
import static hu.bme.mit.trainbenchmark.constants.QueryConstants.VAR_SEMAPHORE;
import static hu.bme.mit.trainbenchmark.constants.QueryConstants.VAR_SW;
import static hu.bme.mit.trainbenchmark.constants.QueryConstants.VAR_SWP;
import org.kie.api.runtime.rule.Row;
import hu.bme.mit.trainbenchmark.benchmark.emf.matches.EmfSwitchSetMatch;
import hu.bme.mit.trainbenchmark.railway.Route;
import hu.bme.mit.trainbenchmark.railway.Semaphore;
import hu.bme.mit.trainbenchmark.railway.Switch;
import hu.bme.mit.trainbenchmark.railway.SwitchPosition;
public class DroolsSwitchSetMatch extends EmfSwitchSetMatch {
public DroolsSwitchSetMatch(final Row match) {
super((Semaphore) match.get(VAR_SEMAPHORE), (Route) match.get(VAR_ROUTE), (SwitchPosition) match.get(VAR_SWP), (Switch) match
.get(VAR_SW));
}
}
package hu.bme.mit.trainbenchmark.benchmark.drools.operations;
import hu.bme.mit.trainbenchmark.benchmark.drools.driver.DroolsDriver;
import hu.bme.mit.trainbenchmark.benchmark.drools.matches.DroolsConnectedSegmentsMatch;
import hu.bme.mit.trainbenchmark.benchmark.drools.matches.DroolsPosLengthMatch;
import hu.bme.mit.trainbenchmark.benchmark.drools.matches.DroolsRouteSensorMatch;
import hu.bme.mit.trainbenchmark.benchmark.drools.matches.DroolsSemaphoreNeighborMatch;
import hu.bme.mit.trainbenchmark.benchmark.drools.matches.DroolsSwitchMonitoredMatch;
import hu.bme.mit.trainbenchmark.benchmark.drools.matches.DroolsSwitchSetMatch;
import hu.bme.mit.trainbenchmark.benchmark.drools.queries.DroolsQuery;
import hu.bme.mit.trainbenchmark.benchmark.emf.matches.EmfConnectedSegmentsInjectMatch;
import hu.bme.mit.trainbenchmark.benchmark.emf.matches.EmfMatch;
import hu.bme.mit.trainbenchmark.benchmark.emf.matches.EmfPosLengthInjectMatch;
import hu.bme.mit.trainbenchmark.benchmark.emf.matches.EmfRouteSensorInjectMatch;
import hu.bme.mit.trainbenchmark.benchmark.emf.matches.EmfSemaphoreNeighborInjectMatch;
import hu.bme.mit.trainbenchmark.benchmark.emf.matches.EmfSwitchMonitoredInjectMatch;
import hu.bme.mit.trainbenchmark.benchmark.emf.matches.EmfSwitchSetInjectMatch;
import hu.bme.mit.trainbenchmark.benchmark.emf.transformation.EmfTransformation;
import hu.bme.mit.trainbenchmark.benchmark.emf.transformation.inject.EmfTransformationInjectConnectedSegments;
import hu.bme.mit.trainbenchmark.benchmark.emf.transformation.inject.EmfTransformationInjectPosLength;
import hu.bme.mit.trainbenchmark.benchmark.emf.transformation.inject.EmfTransformationInjectRouteSensor;
import hu.bme.mit.trainbenchmark.benchmark.emf.transformation.inject.EmfTransformationInjectSemaphoreNeighbor;
import hu.bme.mit.trainbenchmark.benchmark.emf.transformation.inject.EmfTransformationInjectSwitchMonitored;
import hu.bme.mit.trainbenchmark.benchmark.emf.transformation.inject.EmfTransformationInjectSwitchSet;
import hu.bme.mit.trainbenchmark.benchmark.emf.transformation.query.EmfApiQuery;
import hu.bme.mit.trainbenchmark.benchmark.emf.transformation.query.EmfApiQueryConnectedSegmentsInject;
import hu.bme.mit.trainbenchmark.benchmark.emf.transformation.query.EmfApiQueryPosLengthInject;
import hu.bme.mit.trainbenchmark.benchmark.emf.transformation.query.EmfApiQueryRouteSensorInject;
import hu.bme.mit.trainbenchmark.benchmark.emf.transformation.query.EmfApiQuerySemaphoreNeighborInject;
import hu.bme.mit.trainbenchmark.benchmark.emf.transformation.query.EmfApiQuerySwitchMonitoredInject;
import hu.bme.mit.trainbenchmark.benchmark.emf.transformation.query.EmfApiQuerySwitchSetInject;
import hu.bme.mit.trainbenchmark.benchmark.emf.transformation.repair.EmfTransformationRepairConnectedSegments;
import hu.bme.mit.trainbenchmark.benchmark.emf.transformation.repair.EmfTransformationRepairPosLength;
import hu.bme.mit.trainbenchmark.benchmark.emf.transformation.repair.EmfTransformationRepairRouteSensor;
import hu.bme.mit.trainbenchmark.benchmark.emf.transformation.repair.EmfTransformationRepairSemaphoreNeighbor;
import hu.bme.mit.trainbenchmark.benchmark.emf.transformation.repair.EmfTransformationRepairSwitchMonitored;
import hu.bme.mit.trainbenchmark.benchmark.emf.transformation.repair.EmfTransformationRepairSwitchSet;
import hu.bme.mit.trainbenchmark.benchmark.operations.ModelOperation;
import hu.bme.mit.trainbenchmark.benchmark.operations.ModelOperationFactory;
import hu.bme.mit.trainbenchmark.constants.RailwayOperation;
import hu.bme.mit.trainbenchmark.constants.RailwayQuery;
public class DroolsModelOperationFactory extends ModelOperationFactory<EmfMatch, DroolsDriver> {
@Override
public ModelOperation<? extends EmfMatch, DroolsDriver> createOperation(final RailwayOperation operationEnum, final String workspaceDir,
final DroolsDriver driver) throws Exception {
switch (operationEnum) {
// ConnectedSegments
case CONNECTEDSEGMENTS: {
final DroolsQuery<DroolsConnectedSegmentsMatch> query = DroolsQuery.create(driver, workspaceDir, RailwayQuery.CONNECTEDSEGMENTS);
final ModelOperation<DroolsConnectedSegmentsMatch, DroolsDriver> operation = ModelOperation.of(query);
return operation;
}
case CONNECTEDSEGMENTS_INJECT: {
final EmfApiQuery<EmfConnectedSegmentsInjectMatch, DroolsDriver> query = new EmfApiQueryConnectedSegmentsInject<>(driver);
final EmfTransformation<EmfConnectedSegmentsInjectMatch, DroolsDriver> transformation = new EmfTransformationInjectConnectedSegments<>(driver);
final ModelOperation<EmfConnectedSegmentsInjectMatch, DroolsDriver> operation = ModelOperation.of(query, transformation);
return operation;
}
case CONNECTEDSEGMENTS_REPAIR: {
final DroolsQuery<DroolsConnectedSegmentsMatch> query = DroolsQuery.create(driver, workspaceDir, RailwayQuery.CONNECTEDSEGMENTS);
final EmfTransformationRepairConnectedSegments<DroolsDriver, DroolsConnectedSegmentsMatch> transformation = new EmfTransformationRepairConnectedSegments<>(
driver);
final ModelOperation<DroolsConnectedSegmentsMatch, DroolsDriver> operation = ModelOperation.of(query, transformation);
return operation;
}
// PosLength
case POSLENGTH: {
final DroolsQuery<DroolsPosLengthMatch> query = DroolsQuery.create(driver, workspaceDir, RailwayQuery.POSLENGTH);
final ModelOperation<DroolsPosLengthMatch, DroolsDriver> operation = ModelOperation.of(query);
return operation;
}
case POSLENGTH_INJECT: {
final EmfApiQuery<EmfPosLengthInjectMatch, DroolsDriver> query = new EmfApiQueryPosLengthInject<>(driver);
final EmfTransformation<EmfPosLengthInjectMatch, DroolsDriver> transformation = new EmfTransformationInjectPosLength<>(driver);
final ModelOperation<EmfPosLengthInjectMatch, DroolsDriver> operation = ModelOperation.of(query, transformation);
return operation;
}
case POSLENGTH_REPAIR: {
final DroolsQuery<DroolsPosLengthMatch> query = DroolsQuery.create(driver, workspaceDir, RailwayQuery.POSLENGTH);
final EmfTransformation<DroolsPosLengthMatch, DroolsDriver> transformation = new EmfTransformationRepairPosLength<>(driver);
final ModelOperation<DroolsPosLengthMatch, DroolsDriver> operation = ModelOperation.of(query, transformation);
return operation;
}
// RouteSensor
case ROUTESENSOR: {
final DroolsQuery<DroolsRouteSensorMatch> query = DroolsQuery.create(driver, workspaceDir, RailwayQuery.ROUTESENSOR);
final ModelOperation<DroolsRouteSensorMatch, DroolsDriver> operation = ModelOperation.of(query);
return operation;
}
case ROUTESENSOR_INJECT: {
final EmfApiQuery<EmfRouteSensorInjectMatch, DroolsDriver> query = new EmfApiQueryRouteSensorInject<>(driver);
final EmfTransformation<EmfRouteSensorInjectMatch, DroolsDriver> transformation = new EmfTransformationInjectRouteSensor<>(driver);
final ModelOperation<EmfRouteSensorInjectMatch, DroolsDriver> operation = ModelOperation.of(query, transformation);
return operation;
}
case ROUTESENSOR_REPAIR: {
final DroolsQuery<DroolsRouteSensorMatch> query = DroolsQuery.create(driver, workspaceDir, RailwayQuery.ROUTESENSOR);
final EmfTransformationRepairRouteSensor<DroolsDriver, DroolsRouteSensorMatch> transformation = new EmfTransformationRepairRouteSensor<>(driver);
final ModelOperation<DroolsRouteSensorMatch, DroolsDriver> operation = ModelOperation.of(query, transformation);
return operation;
}
// SemaphoreNeighbor
case SEMAPHORENEIGHBOR: {
final DroolsQuery<DroolsSemaphoreNeighborMatch> query = DroolsQuery.create(driver, workspaceDir, RailwayQuery.SEMAPHORENEIGHBOR);
final ModelOperation<DroolsSemaphoreNeighborMatch, DroolsDriver> operation = ModelOperation.of(query);
return operation;
}
case SEMAPHORENEIGHBOR_INJECT: {
final EmfApiQuery<EmfSemaphoreNeighborInjectMatch, DroolsDriver> query = new EmfApiQuerySemaphoreNeighborInject<>(driver);
final EmfTransformation<EmfSemaphoreNeighborInjectMatch, DroolsDriver> transformation = new EmfTransformationInjectSemaphoreNeighbor<>(driver);
final ModelOperation<EmfSemaphoreNeighborInjectMatch, DroolsDriver> operation = ModelOperation.of(query, transformation);
return operation;
}
case SEMAPHORENEIGHBOR_REPAIR: {
final DroolsQuery<DroolsSemaphoreNeighborMatch> query = DroolsQuery.create(driver, workspaceDir, RailwayQuery.SEMAPHORENEIGHBOR);
final EmfTransformationRepairSemaphoreNeighbor<DroolsDriver, DroolsSemaphoreNeighborMatch> transformation = new EmfTransformationRepairSemaphoreNeighbor<>(
driver);
final ModelOperation<DroolsSemaphoreNeighborMatch, DroolsDriver> operation = ModelOperation.of(query, transformation);
return operation;
}
// SwitchMonitored
case SWITCHMONITORED: {
final DroolsQuery<DroolsSwitchMonitoredMatch> query = DroolsQuery.create(driver, workspaceDir, RailwayQuery.SWITCHMONITORED);
final ModelOperation<DroolsSwitchMonitoredMatch, DroolsDriver> operation = ModelOperation.of(query);
return operation;
}
case SWITCHMONITORED_INJECT: {
final EmfApiQuery<EmfSwitchMonitoredInjectMatch, DroolsDriver> query = new EmfApiQuerySwitchMonitoredInject<>(driver);
final EmfTransformation<EmfSwitchMonitoredInjectMatch, DroolsDriver> transformation = new EmfTransformationInjectSwitchMonitored<>(driver);
final ModelOperation<EmfSwitchMonitoredInjectMatch, DroolsDriver> operation = ModelOperation.of(query, transformation);
return operation;
}
case SWITCHMONITORED_REPAIR: {
final DroolsQuery<DroolsSwitchMonitoredMatch> query = DroolsQuery.create(driver, workspaceDir, RailwayQuery.SWITCHMONITORED);
final EmfTransformationRepairSwitchMonitored<DroolsDriver, DroolsSwitchMonitoredMatch> transformation = new EmfTransformationRepairSwitchMonitored<>(
driver);
final ModelOperation<DroolsSwitchMonitoredMatch, DroolsDriver> operation = ModelOperation.of(query, transformation);
return operation;
}
// SwitchSet
case SWITCHSET: {
final DroolsQuery<DroolsSwitchSetMatch> query = DroolsQuery.create(driver, workspaceDir, RailwayQuery.SWITCHSET);
final ModelOperation<DroolsSwitchSetMatch, DroolsDriver> operation = ModelOperation.of(query);
return operation;
}
case SWITCHSET_INJECT: {
final EmfApiQuery<EmfSwitchSetInjectMatch, DroolsDriver> query = new EmfApiQuerySwitchSetInject<>(driver);
final EmfTransformation<EmfSwitchSetInjectMatch, DroolsDriver> transformation = new EmfTransformationInjectSwitchSet<>(driver);
final ModelOperation<EmfSwitchSetInjectMatch, DroolsDriver> operation = ModelOperation.of(query, transformation);
return operation;
}
case SWITCHSET_REPAIR: {
final DroolsQuery<DroolsSwitchSetMatch> query = DroolsQuery.create(driver, workspaceDir, RailwayQuery.SWITCHSET);
final EmfTransformation<DroolsSwitchSetMatch, DroolsDriver> transformation = new EmfTransformationRepairSwitchSet<>(driver);
final ModelOperation<DroolsSwitchSetMatch, DroolsDriver> operation = ModelOperation.of(query, transformation);
return operation;
}
default:
break;
}
throw new UnsupportedOperationException("Operation " + operationEnum + " not supported.");
}
}
/*******************************************************************************
* Copyright (c) 2010-2015, Benedek Izso, Gabor Szarnyas, Istvan Rath and Daniel Varro
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Benedek Izso - initial API and implementation
* Gabor Szarnyas - initial API and implementation
*******************************************************************************/
package hu.bme.mit.trainbenchmark.benchmark.drools.queries;
import java.io.IOException;
import java.util.Collection;
import org.kie.api.io.ResourceType;
import org.kie.api.runtime.rule.LiveQuery;
import org.kie.internal.builder.KnowledgeBuilder;
import org.kie.internal.builder.KnowledgeBuilderFactory;
import org.kie.internal.io.ResourceFactory;
import hu.bme.mit.trainbenchmark.benchmark.drools.driver.DroolsDriver;
import hu.bme.mit.trainbenchmark.benchmark.emf.matches.EmfMatch;
import hu.bme.mit.trainbenchmark.benchmark.operations.ModelQuery;
import hu.bme.mit.trainbenchmark.constants.RailwayQuery;
public class DroolsQuery<TMatch extends EmfMatch> extends ModelQuery<TMatch, DroolsDriver> {
protected Collection<TMatch> matches;
protected DroolsResultListener listener;
protected LiveQuery liveQuery;
protected DroolsQuery(final DroolsDriver driver, final String workspaceDir, final RailwayQuery query)
throws IOException {
super(query, driver);
final String queryFile = query + ".drl";
final KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource(queryFile, DroolsQuery.class), ResourceType.DRL);
}
public static <TMatch extends EmfMatch> DroolsQuery<TMatch> create(final DroolsDriver driver,
final String workspaceDir, final RailwayQuery query) throws IOException {
return new DroolsQuery<TMatch>(driver, workspaceDir, query);
}
@SuppressWarnings("unchecked")
@Override
public Collection<TMatch> evaluate() throws IOException {
if (liveQuery == null) {
listener = new DroolsResultListener(query);
liveQuery = driver.getKsession().openLiveQuery(query.toString(), new Object[] {}, listener);
} else {
driver.getKsession().fireAllRules();
}
matches = (Collection<TMatch>) listener.getMatches();
return matches;
}
@Override
public void close() {
if (liveQuery != null) {
liveQuery.close();
}
}
}
/*******************************************************************************
* Copyright (c) 2010-2015, Benedek Izso, Gabor Szarnyas, Istvan Rath and Daniel Varro
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Benedek Izso - initial API and implementation
* Gabor Szarnyas - initial API and implementation
*******************************************************************************/
package hu.bme.mit.trainbenchmark.benchmark.drools.queries;
import java.util.HashSet;
import java.util.Set;
import org.kie.api.runtime.rule.Row;
import org.kie.api.runtime.rule.ViewChangedEventListener;
import hu.bme.mit.trainbenchmark.benchmark.drools.matches.DroolsConnectedSegmentsMatch;
import hu.bme.mit.trainbenchmark.benchmark.drools.matches.DroolsPosLengthMatch;
import hu.bme.mit.trainbenchmark.benchmark.drools.matches.DroolsRouteSensorMatch;
import hu.bme.mit.trainbenchmark.benchmark.drools.matches.DroolsSemaphoreNeighborMatch;
import hu.bme.mit.trainbenchmark.benchmark.drools.matches.DroolsSwitchMonitoredMatch;
import hu.bme.mit.trainbenchmark.benchmark.drools.matches.DroolsSwitchSetMatch;
import hu.bme.mit.trainbenchmark.benchmark.emf.matches.EmfMatch;
import hu.bme.mit.trainbenchmark.constants.RailwayQuery;
public class DroolsResultListener implements ViewChangedEventListener {
protected RailwayQuery query;
protected final Set<EmfMatch> matches = new HashSet<>();
public DroolsResultListener(final RailwayQuery query) {
this.query = query;
}
@Override
public void rowInserted(final Row row) {
matches.add(createMatch(query, row));
}
@Override
public void rowDeleted(final Row row) {
matches.remove(createMatch(query, row));
}
@Override
public void rowUpdated(final Row row) {
matches.add(createMatch(query, row));
}
public Set<EmfMatch> getMatches() {
return matches;
}
private EmfMatch createMatch(final RailwayQuery query, final Row row) {
switch (query) {
case CONNECTEDSEGMENTS:
return new DroolsConnectedSegmentsMatch(row);
case POSLENGTH:
return new DroolsPosLengthMatch(row);
case ROUTESENSOR:
return new DroolsRouteSensorMatch(row);
case SEMAPHORENEIGHBOR:
return new DroolsSemaphoreNeighborMatch(row);
case SWITCHMONITORED:
return new DroolsSwitchMonitoredMatch(row);
case SWITCHSET:
return new DroolsSwitchSetMatch(row);
default:
throw new UnsupportedOperationException("Query not supported: " + query);
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<kmodule xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://jboss.org/kie/6.0.0/kmodule">
<kbase name="TrainBenchmarkKB" packages="hu.bme.mit.trainbenchmark.benchmark.drools.queries">
<ksession name="TrainBenchmarkKieSession"/>
</kbase>
</kmodule>
\ No newline at end of file
package hu.bme.mit.trainbenchmark.railway
query "ConnectedSegments"
segment1 : Segment( )
segment2 : Segment( this memberOf segment1.connectsTo )
segment3 : Segment( this memberOf segment2.connectsTo )
segment4 : Segment( this memberOf segment3.connectsTo )
segment5 : Segment( this memberOf segment4.connectsTo )
segment6 : Segment( this memberOf segment5.connectsTo )
sensor : Sensor(
this memberOf segment1.monitoredBy,
this memberOf segment2.monitoredBy,
this memberOf segment3.monitoredBy,
this memberOf segment4.monitoredBy,
this memberOf segment5.monitoredBy,
this memberOf segment6.monitoredBy
)
end
package hu.bme.mit.trainbenchmark.railway
query "PosLength"
segment : Segment( length <= 0 )
end
package hu.bme.mit.trainbenchmark.railway
query "RouteSensor"
route : Route()
swP : SwitchPosition( ) from route.follows
sw : Switch( this == swP.target )
sensor : Sensor( ) from sw.monitoredBy
not Sensor( this == sensor, this memberOf route.requires )
end
package hu.bme.mit.trainbenchmark.railway
query "SemaphoreNeighbor"
route1 : Route( )
sensor1 : Sensor( ) from route1.requires
te1 : TrackElement( ) from sensor1.monitors
te2 : TrackElement( ) from te1.connectsTo
sensor2 : Sensor( ) from te2.monitoredBy
semaphore : Semaphore( this == route1.exit )
route2 : Route( requires contains sensor2, this != route1 )
not Route( entry == semaphore, requires contains sensor2 )
end
package hu.bme.mit.trainbenchmark.railway
query "SwitchMonitored"
sw : Switch( monitoredBy.isEmpty() )
end
package hu.bme.mit.trainbenchmark.railway
query "SwitchSet"
route : Route( active, $follows : follows )
semaphore : Semaphore( this == route.entry )
swP : SwitchPosition( this memberOf $follows )
sw: Switch( this == swP.target, currentPosition.value != swP.position.value )
end
/*******************************************************************************
* Copyright (c) 2010-2015, Benedek Izso, Gabor Szarnyas, Istvan Rath and Daniel Varro
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Benedek Izso - initial API and implementation
* Gabor Szarnyas - initial API and implementation
*******************************************************************************/
package hu.bme.mit.trainbenchmark.benchmark.drools.test;
import hu.bme.mit.trainbenchmark.benchmark.config.BenchmarkConfigBase;
import hu.bme.mit.trainbenchmark.benchmark.drools.DroolsBenchmarkScenario;
import hu.bme.mit.trainbenchmark.benchmark.drools.config.DroolsBenchmarkConfig;
import hu.bme.mit.trainbenchmark.benchmark.drools.config.DroolsBenchmarkConfigBuilder;
import hu.bme.mit.trainbenchmark.benchmark.runcomponents.BenchmarkResult;
import hu.bme.mit.trainbenchmark.benchmark.test.TrainBenchmarkTest;
public class DroolsTest extends TrainBenchmarkTest {
@Override
protected BenchmarkResult runTest(final BenchmarkConfigBase bcb) throws Exception {
final DroolsBenchmarkConfig bc = new DroolsBenchmarkConfigBuilder().setConfigBase(bcb).createConfig();
final DroolsBenchmarkScenario scenario = new DroolsBenchmarkScenario(bc);
final BenchmarkResult result = scenario.performBenchmark();
return result;
}
}
/target
/target
plugins { id "com.github.johnrengelman.shadow" version "1.2.3" }
shadowJar {
classifier = 'fat'
manifest { attributes 'Main-Class': 'hu.bme.mit.trainbenchmark.benchmark.eclipseocl.EclipseOclBenchmarkMain' }
}
dependencies {
compile project(':trainbenchmark-tool-emf')
compile group: 'org.eclipse.ocl', name: 'org.eclipse.ocl', version:'3.3.0.v20140120-1508'
compile group: 'org.eclipse.ocl', name: 'org.eclipse.ocl.ecore', version:'3.3.0.v20130520-1222'
compile group: 'org.eclipse.ocl', name: 'org.eclipse.ocl.common', version:'1.2.0.v20140610-0641'
compile group: 'lpg.runtime', name: 'java', version:'2.0.17-v201004271640'
}
/*******************************************************************************
* Copyright (c) 2010-2015, Benedek Izso, Gabor Szarnyas, Istvan Rath and Daniel Varro
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Benedek Izso - initial API and implementation
* Gabor Szarnyas - initial API and implementation
*******************************************************************************/
package hu.bme.mit.trainbenchmark.benchmark.eclipseocl;
import hu.bme.mit.trainbenchmark.benchmark.config.BenchmarkConfig;
import hu.bme.mit.trainbenchmark.benchmark.eclipseocl.config.EclipseOclBenchmarkConfig;
public class EclipseOclBenchmarkMain {
public static void main(final String[] args) throws Exception {
final EclipseOclBenchmarkConfig bc = BenchmarkConfig.fromFile(args[0], EclipseOclBenchmarkConfig.class);
final EclipseOclBenchmarkScenario scenario = new EclipseOclBenchmarkScenario(bc);
scenario.performBenchmark();
}
}
package hu.bme.mit.trainbenchmark.benchmark.eclipseocl;
import hu.bme.mit.trainbenchmark.benchmark.eclipseocl.config.EclipseOclBenchmarkConfig;
import hu.bme.mit.trainbenchmark.benchmark.eclipseocl.operations.EclipseOclModelOperationFactory;
import hu.bme.mit.trainbenchmark.benchmark.emf.comparators.EmfMatchComparator;
import hu.bme.mit.trainbenchmark.benchmark.emf.driver.EmfDriver;
import hu.bme.mit.trainbenchmark.benchmark.emf.driver.EmfDriverFactory;
import hu.bme.mit.trainbenchmark.benchmark.emf.matches.EmfMatch;
import hu.bme.mit.trainbenchmark.benchmark.phases.BenchmarkScenario;
public class EclipseOclBenchmarkScenario extends BenchmarkScenario<EmfMatch, EmfDriver, EclipseOclBenchmarkConfig> {
public EclipseOclBenchmarkScenario(final EclipseOclBenchmarkConfig bc) throws Exception {
super(new EmfDriverFactory(), new EclipseOclModelOperationFactory(), new EmfMatchComparator(), bc);
}
}
/*******************************************************************************
* Copyright (c) 2010-2015, Benedek Izso, Gabor Szarnyas, Istvan Rath and Daniel Varro
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Benedek Izso - initial API and implementation
* Gabor Szarnyas - initial API and implementation
*******************************************************************************/
package hu.bme.mit.trainbenchmark.benchmark.eclipseocl.config;
import hu.bme.mit.trainbenchmark.benchmark.config.BenchmarkConfig;
import hu.bme.mit.trainbenchmark.benchmark.config.BenchmarkConfigBase;
public class EclipseOclBenchmarkConfig extends BenchmarkConfig {
protected EclipseOclBenchmarkConfig(final BenchmarkConfigBase configBase) {
super(configBase);
}
@Override
public String getToolName() {
return "Eclipse OCL";
}
@Override
public String getProjectName() {
return "eclipseocl";
}
}
package hu.bme.mit.trainbenchmark.benchmark.eclipseocl.config;
import hu.bme.mit.trainbenchmark.benchmark.config.BenchmarkConfigBuilder;
public class EclipseOclBenchmarkConfigBuilder
extends BenchmarkConfigBuilder<EclipseOclBenchmarkConfig, EclipseOclBenchmarkConfigBuilder> {
@Override
public EclipseOclBenchmarkConfig createConfig() {
checkNotNulls();
return new EclipseOclBenchmarkConfig(configBase);
}
}
package hu.bme.mit.trainbenchmark.benchmark.eclipseocl.operations;
import hu.bme.mit.trainbenchmark.benchmark.eclipseocl.queries.EclipseOclQuery;
import hu.bme.mit.trainbenchmark.benchmark.eclipseocl.queries.EclipseOclQueryConnectedSegments;
import hu.bme.mit.trainbenchmark.benchmark.eclipseocl.queries.EclipseOclQueryPosLength;
import hu.bme.mit.trainbenchmark.benchmark.eclipseocl.queries.EclipseOclQueryRouteSensor;
import hu.bme.mit.trainbenchmark.benchmark.eclipseocl.queries.EclipseOclQuerySemaphoreNeighbor;
import hu.bme.mit.trainbenchmark.benchmark.eclipseocl.queries.EclipseOclQuerySwitchMonitored;
import hu.bme.mit.trainbenchmark.benchmark.eclipseocl.queries.EclipseOclQuerySwitchSet;
import hu.bme.mit.trainbenchmark.benchmark.emf.driver.EmfDriver;
import hu.bme.mit.trainbenchmark.benchmark.emf.matches.EmfConnectedSegmentsInjectMatch;
import hu.bme.mit.trainbenchmark.benchmark.emf.matches.EmfConnectedSegmentsMatch;
import hu.bme.mit.trainbenchmark.benchmark.emf.matches.EmfMatch;
import hu.bme.mit.trainbenchmark.benchmark.emf.matches.EmfPosLengthInjectMatch;
import hu.bme.mit.trainbenchmark.benchmark.emf.matches.EmfPosLengthMatch;
import hu.bme.mit.trainbenchmark.benchmark.emf.matches.EmfRouteSensorInjectMatch;
import hu.bme.mit.trainbenchmark.benchmark.emf.matches.EmfRouteSensorMatch;
import hu.bme.mit.trainbenchmark.benchmark.emf.matches.EmfSemaphoreNeighborInjectMatch;
import hu.bme.mit.trainbenchmark.benchmark.emf.matches.EmfSemaphoreNeighborMatch;
import hu.bme.mit.trainbenchmark.benchmark.emf.matches.EmfSwitchMonitoredInjectMatch;
import hu.bme.mit.trainbenchmark.benchmark.emf.matches.EmfSwitchMonitoredMatch;
import hu.bme.mit.trainbenchmark.benchmark.emf.matches.EmfSwitchSetInjectMatch;
import hu.bme.mit.trainbenchmark.benchmark.emf.matches.EmfSwitchSetMatch;
import hu.bme.mit.trainbenchmark.benchmark.emf.transformation.EmfTransformation;
import hu.bme.mit.trainbenchmark.benchmark.emf.transformation.inject.EmfTransformationInjectConnectedSegments;
import hu.bme.mit.trainbenchmark.benchmark.emf.transformation.inject.EmfTransformationInjectPosLength;
import hu.bme.mit.trainbenchmark.benchmark.emf.transformation.inject.EmfTransformationInjectRouteSensor;
import hu.bme.mit.trainbenchmark.benchmark.emf.transformation.inject.EmfTransformationInjectSemaphoreNeighbor;
import hu.bme.mit.trainbenchmark.benchmark.emf.transformation.inject.EmfTransformationInjectSwitchMonitored;
import hu.bme.mit.trainbenchmark.benchmark.emf.transformation.inject.EmfTransformationInjectSwitchSet;
import hu.bme.mit.trainbenchmark.benchmark.emf.transformation.query.EmfApiQuery;
import hu.bme.mit.trainbenchmark.benchmark.emf.transformation.query.EmfApiQueryConnectedSegmentsInject;
import hu.bme.mit.trainbenchmark.benchmark.emf.transformation.query.EmfApiQueryPosLengthInject;
import hu.bme.mit.trainbenchmark.benchmark.emf.transformation.query.EmfApiQueryRouteSensorInject;
import hu.bme.mit.trainbenchmark.benchmark.emf.transformation.query.EmfApiQuerySemaphoreNeighborInject;
import hu.bme.mit.trainbenchmark.benchmark.emf.transformation.query.EmfApiQuerySwitchMonitoredInject;
import hu.bme.mit.trainbenchmark.benchmark.emf.transformation.query.EmfApiQuerySwitchSetInject;
import hu.bme.mit.trainbenchmark.benchmark.emf.transformation.repair.EmfTransformationRepairConnectedSegments;
import hu.bme.mit.trainbenchmark.benchmark.emf.transformation.repair.EmfTransformationRepairPosLength;
import hu.bme.mit.trainbenchmark.benchmark.emf.transformation.repair.EmfTransformationRepairRouteSensor;
import hu.bme.mit.trainbenchmark.benchmark.emf.transformation.repair.EmfTransformationRepairSemaphoreNeighbor;
import hu.bme.mit.trainbenchmark.benchmark.emf.transformation.repair.EmfTransformationRepairSwitchMonitored;
import hu.bme.mit.trainbenchmark.benchmark.emf.transformation.repair.EmfTransformationRepairSwitchSet;
import hu.bme.mit.trainbenchmark.benchmark.operations.ModelOperation;
import hu.bme.mit.trainbenchmark.benchmark.operations.ModelOperationFactory;
import hu.bme.mit.trainbenchmark.constants.RailwayOperation;
public class EclipseOclModelOperationFactory extends ModelOperationFactory<EmfMatch, EmfDriver> {
@Override
public ModelOperation<? extends EmfMatch, EmfDriver> createOperation(final RailwayOperation operationEnum, final String workspaceDir,
final EmfDriver driver) throws Exception {
switch (operationEnum) {
// ConnectedSegments
case CONNECTEDSEGMENTS: {
final EclipseOclQueryConnectedSegments query = new EclipseOclQueryConnectedSegments(driver, workspaceDir);
final ModelOperation<EmfConnectedSegmentsMatch, EmfDriver> operation = ModelOperation.of(query);
return operation;
}
case CONNECTEDSEGMENTS_INJECT: {
final EmfApiQuery<EmfConnectedSegmentsInjectMatch, EmfDriver> query = new EmfApiQueryConnectedSegmentsInject<>(driver);
final EmfTransformation<EmfConnectedSegmentsInjectMatch, EmfDriver> transformation = new EmfTransformationInjectConnectedSegments<>(driver);
final ModelOperation<EmfConnectedSegmentsInjectMatch, EmfDriver> operation = ModelOperation.of(query, transformation);
return operation;
}
case CONNECTEDSEGMENTS_REPAIR: {
final EclipseOclQuery<EmfConnectedSegmentsMatch> query = new EclipseOclQueryConnectedSegments(driver, workspaceDir);
final EmfTransformation<EmfConnectedSegmentsMatch, EmfDriver> transformation = new EmfTransformationRepairConnectedSegments<>(driver);
final ModelOperation<EmfConnectedSegmentsMatch, EmfDriver> operation = ModelOperation.of(query, transformation);
return operation;
}
// PosLength
case POSLENGTH: {
final EclipseOclQuery<EmfPosLengthMatch> query = new EclipseOclQueryPosLength(driver, workspaceDir);
final ModelOperation<EmfPosLengthMatch, EmfDriver> operation = ModelOperation.of(query);
return operation;
}
case POSLENGTH_INJECT: {
final EmfApiQuery<EmfPosLengthInjectMatch, EmfDriver> query = new EmfApiQueryPosLengthInject<>(driver);
final EmfTransformation<EmfPosLengthInjectMatch, EmfDriver> transformation = new EmfTransformationInjectPosLength<>(driver);
final ModelOperation<EmfPosLengthInjectMatch, EmfDriver> operation = ModelOperation.of(query, transformation);
return operation;
}
case POSLENGTH_REPAIR: {
final EclipseOclQuery<EmfPosLengthMatch> query = new EclipseOclQueryPosLength(driver, workspaceDir);
final EmfTransformation<EmfPosLengthMatch, EmfDriver> transformation = new EmfTransformationRepairPosLength<>(driver);
final ModelOperation<EmfPosLengthMatch, EmfDriver> operation = ModelOperation.of(query, transformation);
return operation;
}
// RouteSensor
case ROUTESENSOR: {
final EclipseOclQuery<EmfRouteSensorMatch> query = new EclipseOclQueryRouteSensor(driver, workspaceDir);
final ModelOperation<EmfRouteSensorMatch, EmfDriver> operation = ModelOperation.of(query);
return operation;
}
case ROUTESENSOR_INJECT: {
final EmfApiQuery<EmfRouteSensorInjectMatch, EmfDriver> query = new EmfApiQueryRouteSensorInject<>(driver);
final EmfTransformation<EmfRouteSensorInjectMatch, EmfDriver> transformation = new EmfTransformationInjectRouteSensor<>(driver);
final ModelOperation<EmfRouteSensorInjectMatch, EmfDriver> operation = ModelOperation.of(query, transformation);
return operation;
}
case ROUTESENSOR_REPAIR: {
final EclipseOclQuery<EmfRouteSensorMatch> query = new EclipseOclQueryRouteSensor(driver, workspaceDir);
final EmfTransformation<EmfRouteSensorMatch, EmfDriver> transformation = new EmfTransformationRepairRouteSensor<>(driver);
final ModelOperation<EmfRouteSensorMatch, EmfDriver> operation = ModelOperation.of(query, transformation);
return operation;
}
// SemaphoreNeighbor
case SEMAPHORENEIGHBOR: {
final EclipseOclQuery<EmfSemaphoreNeighborMatch> query = new EclipseOclQuerySemaphoreNeighbor(driver, workspaceDir);
final ModelOperation<EmfSemaphoreNeighborMatch, EmfDriver> operation = ModelOperation.of(query);
return operation;
}
case SEMAPHORENEIGHBOR_INJECT: {
final EmfApiQuery<EmfSemaphoreNeighborInjectMatch, EmfDriver> query = new EmfApiQuerySemaphoreNeighborInject<>(driver);
final EmfTransformation<EmfSemaphoreNeighborInjectMatch, EmfDriver> transformation = new EmfTransformationInjectSemaphoreNeighbor<>(driver);
final ModelOperation<EmfSemaphoreNeighborInjectMatch, EmfDriver> operation = ModelOperation.of(query, transformation);
return operation;
}
case SEMAPHORENEIGHBOR_REPAIR: {
final EclipseOclQuery<EmfSemaphoreNeighborMatch> query = new EclipseOclQuerySemaphoreNeighbor(driver, workspaceDir);
final EmfTransformation<EmfSemaphoreNeighborMatch, EmfDriver> transformation = new EmfTransformationRepairSemaphoreNeighbor<>(driver);
final ModelOperation<EmfSemaphoreNeighborMatch, EmfDriver> operation = ModelOperation.of(query, transformation);
return operation;
}
// SwitchMonitored
case SWITCHMONITORED: {
final EclipseOclQuery<EmfSwitchMonitoredMatch> query = new EclipseOclQuerySwitchMonitored(driver, workspaceDir);
final ModelOperation<EmfSwitchMonitoredMatch, EmfDriver> operation = ModelOperation.of(query);
return operation;
}
case SWITCHMONITORED_INJECT: {
final EmfApiQuery<EmfSwitchMonitoredInjectMatch, EmfDriver> query = new EmfApiQuerySwitchMonitoredInject<>(driver);
final EmfTransformation<EmfSwitchMonitoredInjectMatch, EmfDriver> transformation = new EmfTransformationInjectSwitchMonitored<>(driver);
final ModelOperation<EmfSwitchMonitoredInjectMatch, EmfDriver> operation = ModelOperation.of(query, transformation);
return operation;
}
case SWITCHMONITORED_REPAIR: {
final EclipseOclQuery<EmfSwitchMonitoredMatch> query = new EclipseOclQuerySwitchMonitored(driver, workspaceDir);
final EmfTransformation<EmfSwitchMonitoredMatch, EmfDriver> transformation = new EmfTransformationRepairSwitchMonitored<>(driver);
final ModelOperation<EmfSwitchMonitoredMatch, EmfDriver> operation = ModelOperation.of(query, transformation);
return operation;
}
// SwitchSet
case SWITCHSET: {
final EclipseOclQuery<EmfSwitchSetMatch> query = new EclipseOclQuerySwitchSet(driver, workspaceDir);
final ModelOperation<EmfSwitchSetMatch, EmfDriver> operation = ModelOperation.of(query);
return operation;
}
case SWITCHSET_INJECT: {
final EmfApiQuery<EmfSwitchSetInjectMatch, EmfDriver> query = new EmfApiQuerySwitchSetInject<>(driver);
final EmfTransformation<EmfSwitchSetInjectMatch, EmfDriver> transformation = new EmfTransformationInjectSwitchSet<>(driver);
final ModelOperation<EmfSwitchSetInjectMatch, EmfDriver> operation = ModelOperation.of(query, transformation);
return operation;
}
case SWITCHSET_REPAIR: {
final EclipseOclQuery<EmfSwitchSetMatch> query = new EclipseOclQuerySwitchSet(driver, workspaceDir);
final EmfTransformation<EmfSwitchSetMatch, EmfDriver> transformation = new EmfTransformationRepairSwitchSet<>(driver);
final ModelOperation<EmfSwitchSetMatch, EmfDriver> operation = ModelOperation.of(query, transformation);
return operation;
}
default:
break;
}
throw new UnsupportedOperationException("Operation " + operationEnum + " not supported.");
}
}
/*******************************************************************************
* Copyright (c) 2010-2015, Benedek Izso, Gabor Szarnyas, Istvan Rath and Daniel Varro
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Benedek Izso - initial API and implementation
* Gabor Szarnyas - initial API and implementation
*******************************************************************************/
package hu.bme.mit.trainbenchmark.benchmark.eclipseocl.queries;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
import org.apache.commons.io.FileUtils;
import org.eclipse.ocl.ParserException;
import org.eclipse.ocl.ecore.OCL;
import org.eclipse.ocl.ecore.OCL.Helper;
import org.eclipse.ocl.ecore.OCL.Query;
import org.eclipse.ocl.ecore.OCLExpression;
import hu.bme.mit.trainbenchmark.benchmark.emf.driver.EmfDriver;
import hu.bme.mit.trainbenchmark.benchmark.emf.matches.EmfMatch;
import hu.bme.mit.trainbenchmark.benchmark.operations.ModelQuery;
import hu.bme.mit.trainbenchmark.constants.RailwayQuery;
import hu.bme.mit.trainbenchmark.railway.RailwayContainer;
import hu.bme.mit.trainbenchmark.railway.RailwayPackage;
public abstract class EclipseOclQuery<TMatch extends EmfMatch> extends ModelQuery<TMatch, EmfDriver> {
protected Collection<TMatch> matches;
protected OCL ocl;
protected Query queryEvaluator;
protected RailwayContainer container;
public EclipseOclQuery(final EmfDriver driver, final String workspaceDir, final RailwayQuery query) throws IOException, ParserException {
super(query, driver);
final String oclQueryDefinition = FileUtils
.readFileToString(new File(workspaceDir + "/trainbenchmark-tool-eclipseocl/src/main/resources/queries/" + query + ".ocl"));
ocl = OCL.newInstance();
final Helper helper = ocl.createOCLHelper();
helper.setContext(RailwayPackage.eINSTANCE.getRailwayContainer());
final OCLExpression expression = helper.createQuery(oclQueryDefinition);
queryEvaluator = ocl.createQuery(expression);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment