Skip to content
Snippets Groups Projects
Commit 20280c0b authored by Reiner Jung's avatar Reiner Jung
Browse files

Merge branch 'reiner' into 'main'

Cleanups.

See merge request !74
parents 8db197d2 8cc97073
No related branches found
No related tags found
1 merge request!74Cleanups.
Pipeline #12089 passed
Showing
with 143 additions and 314 deletions
/***************************************************************************
* Copyright (C) 2021 OceanDSL (https://oceandsl.uni-kiel.de)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/
package org.oceandsl.analysis.code;
import kieker.model.analysismodel.execution.EDirection;
/**
* Dataflow analysis record describing a CSV file with 7 columns.
*
* @author Reiner Jung
* @author Yannick Illmann (initial contribution)
*/
public class OperationStorage {
private String sourcePath;
private String sourceModule;
private String sourceSignature;
private String targetPath;
private String targetModule;
private String targetSignature;
private final EDirection direction;
public OperationStorage(final String sourcePath, final String sourceModule, final String sourceSignature,
final String targetPath, final String targetModule, final String targetSignature,
final EDirection direction) {
this.sourcePath = sourcePath;
this.sourceModule = sourceModule;
this.sourceSignature = sourceSignature;
this.targetPath = targetPath;
this.targetModule = targetModule;
this.targetSignature = targetSignature;
this.direction = direction;
}
public String getSourcePath() {
return this.sourcePath;
}
public void setSourcePath(final String sourcePath) {
this.sourcePath = sourcePath;
}
public String getSourceModule() {
return this.sourceModule;
}
public void setSourceModule(final String sourceModule) {
this.sourceModule = sourceModule;
}
public String getSourceSignature() {
return this.sourceSignature;
}
public void setSourceSignature(final String sourceSignature) {
this.sourceSignature = sourceSignature;
}
public String getTargetPath() {
return this.targetPath;
}
public void setTargetPath(final String targetPath) {
this.targetPath = targetPath;
}
public String getTargetModule() {
return this.targetModule;
}
public void setTargetModule(final String targetModule) {
this.targetModule = targetModule;
}
public String getTargetSignature() {
return this.targetSignature;
}
public void setTargetSignature(final String targetSignature) {
this.targetSignature = targetSignature;
}
public EDirection getDirection() {
return this.direction;
}
}
......@@ -27,16 +27,16 @@ import java.util.Map;
import teetime.framework.OutputPort;
import teetime.stage.basic.AbstractFilter;
import org.oceandsl.analysis.code.stages.data.CallerCallee;
import org.oceandsl.analysis.code.stages.data.CallerCalleeEntry;
/**
* This stage receives an {@link CallerCallee} object and checks whether the file path for caller
* This stage receives an {@link CallerCalleeEntry} object and checks whether the file path for caller
* and callee operation are specified. In case they are missing, the stage sets them based on its
* operation to file lookup table. In case the operation is not listed, it collects all operations
* which do not have a file name.
*
* <ul>
* <li>outputPort sends out {@link CallerCallee} objects with all 4 values set.</li>
* <li>outputPort sends out {@link CallerCalleeEntry} objects with all 4 values set.</li>
* <li>missingOperationOutputPort sends out each newly found operation which does not have a
* associated file path.</li>
* </ul>
......@@ -44,7 +44,7 @@ import org.oceandsl.analysis.code.stages.data.CallerCallee;
* @author Reiner Jung
* @since 1.1
*/
public class CallerCalleeFixPathStage extends AbstractFilter<CallerCallee> {
public class CallerCalleeFixPathStage extends AbstractFilter<CallerCalleeEntry> {
private final Map<String, String> operationToFileMap = new HashMap<>();
private final OutputPort<String> missingOperationOutputPort = this.createOutputPort(String.class);
......@@ -65,7 +65,7 @@ public class CallerCalleeFixPathStage extends AbstractFilter<CallerCallee> {
}
@Override
protected void execute(final CallerCallee element) throws Exception {
protected void execute(final CallerCalleeEntry element) throws Exception {
if ("".equals(element.getSourcePath())) {
element.setSourcePath(this.findPath(element.getCaller()));
}
......
......
......@@ -19,7 +19,7 @@ import java.util.Locale;
import teetime.stage.basic.AbstractFilter;
import org.oceandsl.analysis.code.stages.data.CallerCallee;
import org.oceandsl.analysis.code.stages.data.CallerCalleeEntry;
/**
* Make names all lower case when case insensitive is requested.
......@@ -28,7 +28,7 @@ import org.oceandsl.analysis.code.stages.data.CallerCallee;
* @since 1.0
*
*/
public class CallerCalleeMakeLowerCaseStage extends AbstractFilter<CallerCallee> {
public class CallerCalleeMakeLowerCaseStage extends AbstractFilter<CallerCalleeEntry> {
private final boolean caseInsensitive;
......@@ -37,8 +37,8 @@ public class CallerCalleeMakeLowerCaseStage extends AbstractFilter<CallerCallee>
}
@Override
protected void execute(final CallerCallee element) throws Exception {
final CallerCallee result = new CallerCallee(this.convertToLowerCase(element.getSourcePath()),
protected void execute(final CallerCalleeEntry element) throws Exception {
final CallerCalleeEntry result = new CallerCalleeEntry(this.convertToLowerCase(element.getSourcePath()),
this.convertToLowerCase(element.getSourceModule()), this.convertToLowerCase(element.getCaller()),
this.convertToLowerCase(element.getTargetPath()), this.convertToLowerCase(element.getTargetModule()),
this.convertToLowerCase(element.getCallee()));
......
......
......@@ -23,7 +23,7 @@ import java.util.Locale;
import teetime.framework.AbstractProducerStage;
import org.oceandsl.analysis.code.stages.data.Table;
import org.oceandsl.analysis.generic.Table;
/**
* Read a CSV file containing a component map.
......
......
/***************************************************************************
* Copyright (C) 2022 OceanDSL (https://oceandsl.uni-kiel.de)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/
package org.oceandsl.analysis.code.stages;
import java.io.BufferedReader;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import teetime.framework.OutputPort;
import teetime.stage.basic.AbstractFilter;
import org.oceandsl.analysis.code.OperationStorage;
/**
* This stage receives an {@link OperationStorage} object and checks whether the file path for
* source and target entry are specified. In case they are missing, the stage sets them based on its
* entry to file lookup table. In case the entry is not listed, it collects all entries which do not
* have a file name.
*
* <ul>
* <li>outputPort sends out {@link OperationStorage} objects with all values set.</li>
* <li>missingEntryOutputPort sends out each newly found operation which does not have a associated
* file path.</li>
* </ul>
*
* @author Reiner Jung
* @since 1.1
*/
public class OperationStorageFixPathStage extends AbstractFilter<OperationStorage> {
private final Map<String, String> entryToFileMap = new HashMap<>();
private final OutputPort<String> missingEntryOutputPort = this.createOutputPort(String.class);
private final List<String> missingEntryNames = new ArrayList<>();
public OperationStorageFixPathStage(final List<Path> entryMapPaths, final String splitSymbol) throws IOException {
for (final Path functionMapPath : entryMapPaths) {
try (BufferedReader reader = Files.newBufferedReader(functionMapPath)) {
String line = reader.readLine();
while ((line = reader.readLine()) != null) {
final String[] values = line.split(splitSymbol);
if (values.length >= 2) {
this.entryToFileMap.put(values[1].trim(), values[0].trim());
}
}
}
}
}
@Override
protected void execute(final OperationStorage element) throws Exception {
if ("".equals(element.getSourcePath())) {
element.setSourcePath(this.findPath(element.getSourceSignature()));
}
if ("".equals(element.getTargetPath())) {
element.setTargetPath(this.findPath(element.getTargetSignature()));
}
this.outputPort.send(element);
}
private String findPath(final String functionName) {
final String path = this.entryToFileMap.get(functionName);
if (path == null) {
if (!this.missingEntryNames.contains(functionName)) {
this.logger.warn("Missing file entry for operation: {}", functionName);
this.missingEntryNames.add(functionName);
this.missingEntryOutputPort.send(functionName);
}
return "";
} else {
return path;
}
}
public OutputPort<String> getMissingEntryOutputPort() {
return this.missingEntryOutputPort;
}
}
\ No newline at end of file
/***************************************************************************
* Copyright (C) 2021 OceanDSL (https://oceandsl.uni-kiel.de)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/
package org.oceandsl.analysis.code.stages;
import java.util.Locale;
import teetime.stage.basic.AbstractFilter;
import org.oceandsl.analysis.code.OperationStorage;
/**
* Make names all lower case when case insensitive is requested.
*
* @author Reiner Jung
* @since 1.0
*
*/
public class OperationStorageMakeLowerCaseStage extends AbstractFilter<OperationStorage> {
private final boolean caseInsensitive;
public OperationStorageMakeLowerCaseStage(final boolean caseInsensitive) {
this.caseInsensitive = caseInsensitive;
}
@Override
protected void execute(final OperationStorage element) throws Exception {
final OperationStorage result = new OperationStorage(this.convertToLowerCase(element.getSourcePath()),
this.convertToLowerCase(element.getSourceModule()),
this.convertToLowerCase(element.getSourceSignature()), this.convertToLowerCase(element.getTargetPath()),
this.convertToLowerCase(element.getTargetModule()),
this.convertToLowerCase(element.getTargetSignature()), element.getDirection());
this.outputPort.send(result);
}
private String convertToLowerCase(final String string) {
return this.caseInsensitive ? string.toLowerCase(Locale.ROOT) : string;
}
}
......@@ -20,7 +20,7 @@ package org.oceandsl.analysis.code.stages.data;
* @since 1.0
*
*/
public class CallerCallee {
public class CallerCalleeEntry {
private String sourcePath;
private String targetPath;
......@@ -29,7 +29,7 @@ public class CallerCallee {
private final String caller;
private final String callee;
public CallerCallee(final String sourcePath, final String sourceModule, final String caller,
public CallerCalleeEntry(final String sourcePath, final String sourceModule, final String caller,
final String targetPath, final String targetModule, final String callee) {
this.sourcePath = sourcePath;
this.targetPath = targetPath;
......@@ -73,8 +73,8 @@ public class CallerCallee {
@Override
public boolean equals(final Object object) {
if (object instanceof CallerCallee) {
final CallerCallee other = (CallerCallee) object;
if (object instanceof CallerCalleeEntry) {
final CallerCalleeEntry other = (CallerCalleeEntry) object;
return this.checkString(this.sourcePath, other.getSourcePath())
&& this.checkString(this.sourceModule, other.getSourceModule())
&& this.checkString(this.caller, other.getCaller())
......
......
......@@ -13,4 +13,37 @@
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/
package org.oceandsl.analysis.code;
\ No newline at end of file
package org.oceandsl.analysis.code.stages.data;
import lombok.Getter;
public class DataflowEntry {
@Getter
private final String sourcePath;
@Getter
private final String sourceModule;
@Getter
private final String sourceOperation;
@Getter
private final String targetPath;
@Getter
private final String targetModule;
@Getter
private final String targetOperation;
@Getter
private final EDirection direction;
public DataflowEntry(final String sourcePath, final String sourceModule, final String sourceOperation,
final String targetPath, final String targetModule, final String targetOperatio,
final EDirection direction) {
this.sourcePath = sourcePath;
this.sourceModule = sourceModule;
this.sourceOperation = sourceOperation;
this.targetPath = targetPath;
this.targetModule = targetModule;
this.targetOperation = targetOperatio;
this.direction = direction;
}
}
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/
package org.oceandsl.tools.fxca.model;
package org.oceandsl.analysis.code.stages.data;
/**
*
......
......
package org.oceandsl.tools.fxca.stages.calls;
package org.oceandsl.analysis.code.stages.data;
import lombok.Getter;
......
......
package org.oceandsl.tools.fxca.stages.calls;
package org.oceandsl.analysis.code.stages.data;
import lombok.Getter;
......
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/
package org.oceandsl.analysis.code.stages.data;
package org.oceandsl.analysis.generic;
import java.util.ArrayList;
import java.util.List;
......
......
......@@ -27,7 +27,7 @@ import org.csveed.api.CsvClientImpl;
import teetime.framework.AbstractConsumerStage;
import org.oceandsl.analysis.code.stages.data.Table;
import org.oceandsl.analysis.generic.Table;
/**
* Save tables with a specific row type as a csv files based on a path function.
......@@ -79,6 +79,7 @@ public class TableCsvSink<T> extends AbstractConsumerStage<Table<T>> {
try (BufferedWriter outputStream = Files.newBufferedWriter(this.filePathFunction.apply(table.getName()),
StandardCharsets.UTF_8)) {
final CsvClient<T> csvClient = new CsvClientImpl<>(outputStream);
csvClient.setUseHeader(this.header);
if (this.header) {
csvClient.writeHeader(table.getHeader());
}
......
......
/***************************************************************************
* Copyright (C) 2021 OceanDSL (https://oceandsl.uni-kiel.de)
* Copyright (C) 2023 OceanDSL (https://oceandsl.uni-kiel.de)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -13,48 +13,46 @@
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/
package org.oceandsl.analysis.architecture;
package org.oceandsl.analysis.generic.validators;
import kieker.model.analysismodel.deployment.DeployedOperation;
import java.io.File;
import java.nio.file.Paths;
import com.beust.jcommander.IParameterValidator;
import com.beust.jcommander.ParameterException;
import org.oceandsl.analysis.architecture.ArchitectureModelManagementUtils;
/**
* A Single operation call. Data class.
* Check whether the given directory contains a kieker model.
*
* @author Reiner Jung
* @since 1.0
* @since 1.3.0
*
*/
public class OperationCall {
public class PathIsModelDirectoryValidator implements IParameterValidator {
private final DeployedOperation sourceOperation;
private final DeployedOperation targetOperation;
private final String[] modelFiles = { ".project", ArchitectureModelManagementUtils.TYPE_MODEL_NAME,
ArchitectureModelManagementUtils.ASSEMBLY_MODEL_NAME,
ArchitectureModelManagementUtils.DEPLOYMENT_MODEL_NAME,
ArchitectureModelManagementUtils.EXECUTION_MODEL_NAME, ArchitectureModelManagementUtils.SOURCE_MODEL_NAME,
ArchitectureModelManagementUtils.STATISTICS_MODEL_NAME };
public OperationCall(final DeployedOperation sourceOperation, final DeployedOperation targetOperation) {
this.sourceOperation = sourceOperation;
this.targetOperation = targetOperation;
@Override
public void validate(final String name, final String value) throws ParameterException {
final File modelDirectory = Paths.get(value).toFile();
for (final String fileName : this.modelFiles) {
boolean found = false;
for (final File file : modelDirectory.listFiles()) {
if (file.getName().equals(fileName)) {
found = true;
}
public DeployedOperation getSourceOperation() {
return this.sourceOperation;
}
public DeployedOperation getTargetOperation() {
return this.targetOperation;
}
@Override
public boolean equals(final Object object) {
if (object instanceof OperationCall) {
final OperationCall otherCall = (OperationCall) object;
return otherCall.getSourceOperation().equals(this.getSourceOperation())
&& otherCall.getTargetOperation().equals(this.getTargetOperation());
} else {
return false;
if (!found) {
throw new ParameterException(
String.format("Parameter %s: Missing model project file %s from %s", name, fileName, value));
}
}
@Override
public int hashCode() {
return this.sourceOperation.hashCode() ^ this.targetOperation.hashCode();
}
}
......@@ -5,7 +5,7 @@ import java.util.Map;
import teetime.stage.basic.AbstractTransformation;
import org.oceandsl.analysis.code.stages.data.Table;
import org.oceandsl.analysis.generic.Table;
import org.oceandsl.tools.restructuring.restructuremodel.CutOperation;
import org.oceandsl.tools.restructuring.restructuremodel.MoveOperation;
import org.oceandsl.tools.restructuring.restructuremodel.PasteOperation;
......
......
......@@ -27,6 +27,10 @@ import teetime.framework.Configuration;
import teetime.stage.basic.distributor.Distributor;
import teetime.stage.basic.distributor.strategy.CopyByReferenceStrategy;
import org.oceandsl.analysis.code.stages.data.CallerCalleeEntry;
import org.oceandsl.analysis.code.stages.data.DataflowEntry;
import org.oceandsl.analysis.code.stages.data.FileOperationEntry;
import org.oceandsl.analysis.code.stages.data.NotFoundEntry;
import org.oceandsl.analysis.generic.stages.DirectoryProducer;
import org.oceandsl.analysis.generic.stages.DirectoryScannerStage;
import org.oceandsl.analysis.generic.stages.TableCsvSink;
......@@ -36,11 +40,8 @@ import org.oceandsl.tools.fxca.model.FortranParameter;
import org.oceandsl.tools.fxca.model.FortranProject;
import org.oceandsl.tools.fxca.stages.ProcessModuleStructureStage;
import org.oceandsl.tools.fxca.stages.ReadDomStage;
import org.oceandsl.tools.fxca.stages.calls.CallEntry;
import org.oceandsl.tools.fxca.stages.calls.CreateCallTableStage;
import org.oceandsl.tools.fxca.stages.calls.CreateOperationTableStage;
import org.oceandsl.tools.fxca.stages.calls.FileOperationEntry;
import org.oceandsl.tools.fxca.stages.calls.NotFoundEntry;
import org.oceandsl.tools.fxca.stages.calls.ProcessOperationCallStage;
import org.oceandsl.tools.fxca.stages.dataflow.AggregateCommonBlocksStage;
import org.oceandsl.tools.fxca.stages.dataflow.AggregateDataflowStage;
......@@ -50,7 +51,6 @@ import org.oceandsl.tools.fxca.stages.dataflow.CreateCallerCalleeDataflowTableSt
import org.oceandsl.tools.fxca.stages.dataflow.CreateCommonBlockDataflowTableStage;
import org.oceandsl.tools.fxca.stages.dataflow.CreateCommonBlocksTableStage;
import org.oceandsl.tools.fxca.stages.dataflow.DataFlowAnalysisStage;
import org.oceandsl.tools.fxca.stages.dataflow.DataflowEntry;
import org.oceandsl.tools.fxca.stages.dataflow.GlobalDataEntry;
import org.oceandsl.tools.fxca.utils.PatternUriProcessor;
......@@ -109,7 +109,7 @@ public class TeetimeConfiguration extends Configuration {
/** output stages. */
final TableCsvSink<FileOperationEntry> operationTableSink = new TableCsvSink<>(
o -> settings.getOutputDirectoryPath().resolve(TeetimeConfiguration.OPERATION_DEFINITIONS), true);
final TableCsvSink<CallEntry> callTableSink = new TableCsvSink<>(
final TableCsvSink<CallerCalleeEntry> callTableSink = new TableCsvSink<>(
o -> settings.getOutputDirectoryPath().resolve(TeetimeConfiguration.CALL_TABLE), true);
final TableCsvSink<NotFoundEntry> notFoundSink = new TableCsvSink<>(
o -> settings.getOutputDirectoryPath().resolve(TeetimeConfiguration.NOT_FOUND), true);
......
......
......@@ -18,6 +18,8 @@ package org.oceandsl.tools.fxca.model;
import lombok.Getter;
import lombok.Setter;
import org.oceandsl.analysis.code.stages.data.EDirection;
/**
* @author Reiner Jung
* @since 1.3.0
......
......
package org.oceandsl.tools.fxca.stages.calls;
import lombok.Getter;
public class CallEntry {
@Getter
private final String sourcePath;
@Getter
private final String sourceModule;
@Getter
private final String sourceOperation;
@Getter
private final String targetPath;
@Getter
private final String targetModule;
@Getter
private final String targetOperation;
public CallEntry(final String sourcePath, final String sourceModule, final String sourceOperation,
final String targetPath, final String targetModule, final String targetOperation) {
this.sourcePath = sourcePath;
this.sourceModule = sourceModule;
this.sourceOperation = sourceOperation;
this.targetPath = targetPath;
this.targetModule = targetModule;
this.targetOperation = targetOperation;
}
}
......@@ -17,7 +17,8 @@ package org.oceandsl.tools.fxca.stages.calls;
import teetime.stage.basic.AbstractTransformation;
import org.oceandsl.analysis.code.stages.data.Table;
import org.oceandsl.analysis.code.stages.data.CallerCalleeEntry;
import org.oceandsl.analysis.generic.Table;
import org.oceandsl.tools.fxca.model.FortranModule;
import org.oceandsl.tools.fxca.model.FortranOperation;
import org.oceandsl.tools.fxca.model.FortranProject;
......@@ -29,7 +30,7 @@ import org.oceandsl.tools.fxca.utils.Pair;
* @author Reiner Jung
* @since 1.3.0
*/
public class CreateCallTableStage extends AbstractTransformation<FortranProject, Table<CallEntry>> {
public class CreateCallTableStage extends AbstractTransformation<FortranProject, Table<CallerCalleeEntry>> {
private static final String SOURCE_PATH = "caller-path";
private static final String SOURCE_MODULE = "caller-module";
......@@ -40,7 +41,7 @@ public class CreateCallTableStage extends AbstractTransformation<FortranProject,
@Override
protected void execute(final FortranProject project) throws Exception {
final Table<CallEntry> callsTable = new Table<>("calls", CreateCallTableStage.SOURCE_PATH,
final Table<CallerCalleeEntry> callsTable = new Table<>("calls", CreateCallTableStage.SOURCE_PATH,
CreateCallTableStage.SOURCE_MODULE, CreateCallTableStage.SOURCE_OPERATION,
CreateCallTableStage.TARGET_PATH, CreateCallTableStage.TARGET_MODULE,
CreateCallTableStage.TARGET_OPERATION);
......@@ -53,8 +54,8 @@ public class CreateCallTableStage extends AbstractTransformation<FortranProject,
final Operation caller = this.composeOperation(callerPair);
if (calleePair != null) {
final Operation callee = this.composeOperation(calleePair);
callsTable.getRows().add(new CallEntry(caller.path, caller.moduleName, caller.operation, callee.path,
callee.moduleName, callee.operation));
callsTable.getRows().add(new CallerCalleeEntry(caller.path, caller.moduleName, caller.operation,
callee.path, callee.moduleName, callee.operation));
} else {
this.logger.warn("Caller {} {} {} has no callee ", caller.path, caller.moduleName,
caller.operation);
......
......
......@@ -17,7 +17,8 @@ package org.oceandsl.tools.fxca.stages.calls;
import teetime.stage.basic.AbstractTransformation;
import org.oceandsl.analysis.code.stages.data.Table;
import org.oceandsl.analysis.code.stages.data.FileOperationEntry;
import org.oceandsl.analysis.generic.Table;
import org.oceandsl.tools.fxca.model.FortranProject;
/**
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment