Skip to content

Commit 345cbee

Browse files
author
Reiner Jung
committed
Merge branch 'cleanup-and-refactoring' into 'main'
Cleanup and refactoring See merge request oceandsl/oceandsl-tools!11
2 parents 2bc19af + 9de2c8f commit 345cbee

File tree

128 files changed

+644
-8082
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+644
-8082
lines changed

analysis/build.gradle

+8
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,11 @@ plugins {
33
id 'java-library'
44
}
55

6+
dependencies {
7+
implementation project(':common')
8+
9+
implementation 'org.eclipse.emf:org.eclipse.emf.ecore:2.23.0'
10+
implementation 'org.eclipse.emf:org.eclipse.emf.ecore.xmi:2.16.0'
11+
12+
implementation 'com.fasterxml.jackson.core:jackson-databind:2.12.0'
13+
}
+44-40
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
***************************************************************************/
16-
package org.oceandsl.architecture.model;
16+
package org.oceandsl.analysis.architecture.model;
1717

1818
import java.io.File;
1919
import java.io.IOException;
@@ -56,12 +56,16 @@
5656
import kieker.model.analysismodel.type.TypePackage;
5757

5858
/**
59+
* Reading and storing model repositories.
60+
*
61+
* Note: This should be merged with the repository class.
62+
*
5963
* @author Reiner Jung
6064
* @since 1.1
6165
*/
62-
public final class ArchitectureModelManagementFactory {
66+
public final class ArchitectureModelManagementUtils {
6367

64-
private static final Logger LOGGER = LoggerFactory.getLogger(ArchitectureModelManagementFactory.class);
68+
private static final Logger LOGGER = LoggerFactory.getLogger(ArchitectureModelManagementUtils.class);
6569

6670
public static final String TYPE_MODEL_NAME = "type-model.xmi";
6771

@@ -75,12 +79,12 @@ public final class ArchitectureModelManagementFactory {
7579

7680
public static final String SOURCES_MODEL_NAME = "sources-model.xmi";
7781

78-
private ArchitectureModelManagementFactory() {
82+
private ArchitectureModelManagementUtils() {
7983
// TODO Auto-generated constructor stub
8084
}
8185

8286
public static ModelRepository createModelRepository(final String experimentName, final boolean mapFile) {
83-
return ArchitectureModelManagementFactory
87+
return ArchitectureModelManagementUtils
8488
.createModelRepository(String.format("%s-%s", experimentName, mapFile ? "map" : "file"));
8589
}
8690

@@ -110,37 +114,37 @@ public static ModelRepository loadModelRepository(final Path path) throws Config
110114
packageRegistry.put(AssemblyPackage.eNS_URI, AssemblyPackage.eINSTANCE);
111115
packageRegistry.put(DeploymentPackage.eNS_URI, DeploymentPackage.eINSTANCE);
112116
packageRegistry.put(ExecutionPackage.eNS_URI, ExecutionPackage.eINSTANCE);
113-
packageRegistry.put(StatisticsPackage.eNS_URI, ArchitectureModelManagementFactory.STATISTICS_MODEL_NAME);
114-
packageRegistry.put(SourcesPackage.eNS_URI, ArchitectureModelManagementFactory.SOURCES_MODEL_NAME);
115-
116-
ArchitectureModelManagementFactory.readModel(resourceSet, repository, TypeModel.class, path,
117-
ArchitectureModelManagementFactory.TYPE_MODEL_NAME);
118-
ArchitectureModelManagementFactory.readModel(resourceSet, repository, AssemblyModel.class, path,
119-
ArchitectureModelManagementFactory.ASSEMBLY_MODEL_NAME);
120-
ArchitectureModelManagementFactory.readModel(resourceSet, repository, DeploymentModel.class, path,
121-
ArchitectureModelManagementFactory.DEPLOYMENT_MODEL_NAME);
122-
ArchitectureModelManagementFactory.readModel(resourceSet, repository, ExecutionModel.class, path,
123-
ArchitectureModelManagementFactory.EXECUTION_MODEL_NAME);
124-
ArchitectureModelManagementFactory.readModel(resourceSet, repository, StatisticsModel.class, path,
125-
ArchitectureModelManagementFactory.STATISTICS_MODEL_NAME);
126-
ArchitectureModelManagementFactory.readModel(resourceSet, repository, SourceModel.class, path,
127-
ArchitectureModelManagementFactory.SOURCES_MODEL_NAME);
117+
packageRegistry.put(StatisticsPackage.eNS_URI, ArchitectureModelManagementUtils.STATISTICS_MODEL_NAME);
118+
packageRegistry.put(SourcesPackage.eNS_URI, ArchitectureModelManagementUtils.SOURCES_MODEL_NAME);
119+
120+
ArchitectureModelManagementUtils.readModel(resourceSet, repository, TypeModel.class, path,
121+
ArchitectureModelManagementUtils.TYPE_MODEL_NAME);
122+
ArchitectureModelManagementUtils.readModel(resourceSet, repository, AssemblyModel.class, path,
123+
ArchitectureModelManagementUtils.ASSEMBLY_MODEL_NAME);
124+
ArchitectureModelManagementUtils.readModel(resourceSet, repository, DeploymentModel.class, path,
125+
ArchitectureModelManagementUtils.DEPLOYMENT_MODEL_NAME);
126+
ArchitectureModelManagementUtils.readModel(resourceSet, repository, ExecutionModel.class, path,
127+
ArchitectureModelManagementUtils.EXECUTION_MODEL_NAME);
128+
ArchitectureModelManagementUtils.readModel(resourceSet, repository, StatisticsModel.class, path,
129+
ArchitectureModelManagementUtils.STATISTICS_MODEL_NAME);
130+
ArchitectureModelManagementUtils.readModel(resourceSet, repository, SourceModel.class, path,
131+
ArchitectureModelManagementUtils.SOURCES_MODEL_NAME);
128132

129133
return repository;
130134
}
131135

132136
private static <T extends EObject> void readModel(final ResourceSet resourceSet, final ModelRepository repository,
133137
final Class<T> type, final Path path, final String filename) throws ConfigurationException {
134-
ArchitectureModelManagementFactory.LOGGER.info("Loading model {}", filename);
135-
final File modelFile = ArchitectureModelManagementFactory.createReadModelFileHandle(path, filename);
138+
ArchitectureModelManagementUtils.LOGGER.info("Loading model {}", filename);
139+
final File modelFile = ArchitectureModelManagementUtils.createReadModelFileHandle(path, filename);
136140
if (modelFile.exists()) {
137141
final Resource resource = resourceSet.getResource(URI.createFileURI(modelFile.getAbsolutePath()), true);
138142
for (final Diagnostic error : resource.getErrors()) {
139-
ArchitectureModelManagementFactory.LOGGER.error("Error loading '{}' of {}:{} {}", filename,
143+
ArchitectureModelManagementUtils.LOGGER.error("Error loading '{}' of {}:{} {}", filename,
140144
error.getLocation(), error.getLine(), error.getMessage());
141145
}
142146
for (final Diagnostic error : resource.getWarnings()) {
143-
ArchitectureModelManagementFactory.LOGGER.error("Warning loading '{}' of {}:{} {}", filename,
147+
ArchitectureModelManagementUtils.LOGGER.error("Warning loading '{}' of {}:{} {}", filename,
144148
error.getLocation(), error.getLine(), error.getMessage());
145149
}
146150
repository.register(type, resource.getContents().get(0));
@@ -149,7 +153,7 @@ private static <T extends EObject> void readModel(final ResourceSet resourceSet,
149153
i.next().eCrossReferences();
150154
}
151155
} else {
152-
ArchitectureModelManagementFactory.LOGGER.error("Error reading model file {}. File does not exist.",
156+
ArchitectureModelManagementUtils.LOGGER.error("Error reading model file {}. File does not exist.",
153157
modelFile.getAbsoluteFile());
154158
throw new ConfigurationException(
155159
String.format("Error reading model file %s. File does not exist.", modelFile.getAbsoluteFile()));
@@ -170,33 +174,33 @@ public static void writeModelRepository(final Path outputDirectory, final ModelR
170174
Files.createDirectory(outputDirectory);
171175
}
172176

173-
ArchitectureModelManagementFactory.writeModel(resourceSet, outputDirectory,
174-
ArchitectureModelManagementFactory.TYPE_MODEL_NAME, repository.getModel(TypeModel.class));
175-
ArchitectureModelManagementFactory.writeModel(resourceSet, outputDirectory,
176-
ArchitectureModelManagementFactory.ASSEMBLY_MODEL_NAME, repository.getModel(AssemblyModel.class));
177-
ArchitectureModelManagementFactory.writeModel(resourceSet, outputDirectory,
178-
ArchitectureModelManagementFactory.DEPLOYMENT_MODEL_NAME, repository.getModel(DeploymentModel.class));
179-
ArchitectureModelManagementFactory.writeModel(resourceSet, outputDirectory,
180-
ArchitectureModelManagementFactory.EXECUTION_MODEL_NAME, repository.getModel(ExecutionModel.class));
181-
ArchitectureModelManagementFactory.writeModel(resourceSet, outputDirectory,
182-
ArchitectureModelManagementFactory.STATISTICS_MODEL_NAME, repository.getModel(StatisticsModel.class));
183-
ArchitectureModelManagementFactory.writeModel(resourceSet, outputDirectory,
184-
ArchitectureModelManagementFactory.SOURCES_MODEL_NAME, repository.getModel(SourceModel.class));
177+
ArchitectureModelManagementUtils.writeModel(resourceSet, outputDirectory,
178+
ArchitectureModelManagementUtils.TYPE_MODEL_NAME, repository.getModel(TypeModel.class));
179+
ArchitectureModelManagementUtils.writeModel(resourceSet, outputDirectory,
180+
ArchitectureModelManagementUtils.ASSEMBLY_MODEL_NAME, repository.getModel(AssemblyModel.class));
181+
ArchitectureModelManagementUtils.writeModel(resourceSet, outputDirectory,
182+
ArchitectureModelManagementUtils.DEPLOYMENT_MODEL_NAME, repository.getModel(DeploymentModel.class));
183+
ArchitectureModelManagementUtils.writeModel(resourceSet, outputDirectory,
184+
ArchitectureModelManagementUtils.EXECUTION_MODEL_NAME, repository.getModel(ExecutionModel.class));
185+
ArchitectureModelManagementUtils.writeModel(resourceSet, outputDirectory,
186+
ArchitectureModelManagementUtils.STATISTICS_MODEL_NAME, repository.getModel(StatisticsModel.class));
187+
ArchitectureModelManagementUtils.writeModel(resourceSet, outputDirectory,
188+
ArchitectureModelManagementUtils.SOURCES_MODEL_NAME, repository.getModel(SourceModel.class));
185189
}
186190

187191
private static <T extends EObject> void writeModel(final ResourceSet resourceSet, final Path outputDirectory,
188192
final String filename, final T model) {
189-
ArchitectureModelManagementFactory.LOGGER.info("Saving model {}", filename);
193+
ArchitectureModelManagementUtils.LOGGER.info("Saving model {}", filename);
190194

191-
final File modelFile = ArchitectureModelManagementFactory.createWriteModelFileHandle(outputDirectory, filename);
195+
final File modelFile = ArchitectureModelManagementUtils.createWriteModelFileHandle(outputDirectory, filename);
192196

193197
final Resource resource = resourceSet.createResource(URI.createURI(modelFile.getAbsolutePath()));
194198
resource.getContents().add(model);
195199

196200
try {
197201
resource.save(Collections.EMPTY_MAP);
198202
} catch (final IOException e) {
199-
ArchitectureModelManagementFactory.LOGGER.error("Cannot write {} model to storage. Cause: {}",
203+
ArchitectureModelManagementUtils.LOGGER.error("Cannot write {} model to storage. Cause: {}",
200204
modelFile.getAbsoluteFile(), e.getLocalizedMessage());
201205
}
202206
}
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
***************************************************************************/
16-
package org.oceandsl.architecture.model.stages.utils;
16+
package org.oceandsl.analysis.architecture.model;
1717

1818
import java.util.List;
1919

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
***************************************************************************/
16-
package org.oceandsl.architecture.model.data.table;
16+
package org.oceandsl.analysis.architecture.model;

analysis/src/main/java/org/oceandsl/analysis/RewriteBeforeAndAfterEventsStage.java analysis/src/main/java/org/oceandsl/analysis/stages/dynamic/RewriteBeforeAndAfterEventsStage.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
***************************************************************************/
16-
package org.oceandsl.analysis;
16+
package org.oceandsl.analysis.stages.dynamic;
1717

1818
import java.io.BufferedReader;
1919
import java.io.File;
+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
***************************************************************************/
16-
package org.oceandsl.architecture.model.stages;
16+
package org.oceandsl.analysis.stages.dynamic;
+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
***************************************************************************/
16-
package org.oceandsl.architecture.model.stages;
16+
package org.oceandsl.analysis.stages.generic;
1717

1818
import teetime.stage.basic.AbstractFilter;
1919

Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
***************************************************************************/
16-
package org.oceandsl.architecture.model.stages.sinks;
16+
package org.oceandsl.analysis.stages.generic;
1717

1818
import java.io.BufferedWriter;
1919
import java.nio.charset.StandardCharsets;
2020
import java.nio.file.Files;
2121
import java.nio.file.Path;
2222

23-
import org.oceandsl.architecture.model.data.table.Table;
23+
import org.oceandsl.analysis.stages.staticdata.data.Table;
2424

2525
import teetime.framework.AbstractConsumerStage;
2626

Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
***************************************************************************/
16-
package org.oceandsl.architecture.model.stages.utils;
16+
package org.oceandsl.analysis.stages.generic;
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
***************************************************************************/
16-
package org.oceandsl.architecture.model.stages;
16+
package org.oceandsl.analysis.stages.model;
1717

1818
import java.util.Map.Entry;
1919
import java.util.function.Function;
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
***************************************************************************/
16-
package org.oceandsl.architecture.model.stages;
16+
package org.oceandsl.analysis.stages.model;
1717

1818
import java.nio.file.Path;
1919

20-
import org.oceandsl.architecture.model.ArchitectureModelManagementFactory;
20+
import org.oceandsl.analysis.architecture.model.ArchitectureModelManagementUtils;
2121

2222
import kieker.analysis.stage.model.ModelRepository;
2323
import teetime.framework.AbstractProducerStage;
@@ -36,7 +36,7 @@ public ModelRepositoryProducerStage(final Path path) {
3636

3737
@Override
3838
protected void execute() throws Exception {
39-
this.outputPort.send(ArchitectureModelManagementFactory.loadModelRepository(this.path));
39+
this.outputPort.send(ArchitectureModelManagementUtils.loadModelRepository(this.path));
4040
this.workCompleted();
4141
}
4242

Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
***************************************************************************/
16-
package org.oceandsl.architecture.model.stages;
16+
package org.oceandsl.analysis.stages.model;
1717

1818
import java.io.File;
1919
import java.io.IOException;
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
***************************************************************************/
16-
package org.oceandsl.architecture.model.stages;
16+
package org.oceandsl.analysis.stages.model;
1717

1818
import java.util.Map.Entry;
1919

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
***************************************************************************/
16-
package org.oceandsl.architecture.model.data.table;
16+
package org.oceandsl.analysis.stages.model.data;
1717

1818
import kieker.model.analysismodel.deployment.DeployedOperation;
1919

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/***************************************************************************
2+
* Copyright (C) 2021 OceanDSL (https://oceandsl.uni-kiel.de)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
***************************************************************************/
16+
package org.oceandsl.analysis.stages.model.data;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/***************************************************************************
2+
* Copyright (C) 2021 OceanDSL (https://oceandsl.uni-kiel.de)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
***************************************************************************/
16+
package org.oceandsl.analysis.stages.model;

tools/create-architecture-model/src/main/java/org/oceandsl/architecture/model/stages/CSVReaderStage.java analysis/src/main/java/org/oceandsl/analysis/stages/staticdata/CSVComponentMapReaderStage.java

+23-6
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,45 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
***************************************************************************/
16-
package org.oceandsl.architecture.model.stages;
16+
package org.oceandsl.analysis.stages.staticdata;
1717

1818
import java.io.BufferedReader;
1919
import java.io.IOException;
2020
import java.nio.file.Files;
2121
import java.nio.file.Path;
2222

23-
import org.oceandsl.architecture.model.data.table.StringValueHandler;
24-
import org.oceandsl.architecture.model.data.table.Table;
23+
import org.oceandsl.analysis.stages.staticdata.data.StringValueHandler;
24+
import org.oceandsl.analysis.stages.staticdata.data.Table;
2525

2626
import teetime.framework.AbstractProducerStage;
2727

2828
/**
29+
* Read a CSV file containing a component map.
30+
*
31+
* Note: Should use a generic CSV reader parent class.
32+
*
2933
* @author Reiner Jung
3034
* @since 1.0
3135
*/
32-
public class CSVReaderStage extends AbstractProducerStage<Table> {
36+
public class CSVComponentMapReaderStage extends AbstractProducerStage<Table> {
3337

3438
private final BufferedReader reader;
39+
private final String seperator;
3540

36-
public CSVReaderStage(final Path path) throws IOException {
41+
/**
42+
* Create reader stage.
43+
*
44+
* @param path
45+
* path to file
46+
* @param separator
47+
* separator character
48+
*
49+
* @throws IOException
50+
* on io exceptions
51+
*/
52+
public CSVComponentMapReaderStage(final Path path, final String separator) throws IOException {
3753
this.reader = Files.newBufferedReader(path);
54+
this.seperator = separator;
3855
}
3956

4057
@Override
@@ -43,7 +60,7 @@ protected void execute() throws Exception {
4360
new StringValueHandler("File"), new StringValueHandler("Function"));
4461
String line;
4562
while ((line = this.reader.readLine()) != null) {
46-
final String[] values = line.split(",");
63+
final String[] values = line.split(this.seperator);
4764
if (values.length == 3) {
4865
resultTable.addRow(values[0].trim(), values[1].trim().toLowerCase(), values[2].trim().toLowerCase());
4966
} else {

0 commit comments

Comments
 (0)