Skip to content

Commit

Permalink
Merge pull request #22 from DataFlowAnalysis/split-dfd-converter
Browse files Browse the repository at this point in the history
Split DFD and Web Converter
  • Loading branch information
uuqjz authored Oct 31, 2024
2 parents 85a9144 + 2abbb32 commit b03c858
Show file tree
Hide file tree
Showing 8 changed files with 401 additions and 361 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
package org.dataflowanalysis.converter;

import com.fasterxml.jackson.databind.ObjectMapper;

import tools.mdsd.library.standalone.initialization.StandaloneInitializationException;
import tools.mdsd.library.standalone.initialization.StandaloneInitializerBuilder;

import java.io.File;
import java.io.IOException;
import java.util.Map;
import org.apache.log4j.Logger;
import org.dataflowanalysis.analysis.dfd.resource.DFDURIResourceProvider;
import org.dataflowanalysis.analysis.utils.ResourceUtils;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
Expand All @@ -21,6 +27,27 @@ public abstract class Converter {
public Converter() {
objectMapper = new ObjectMapper();
}

/**
* Loads a data flow diagram and data dictionary from specified input files and returns them as a combined object.
* @param inputDataFlowDiagram The path of the input data flow diagram file.
* @param inputDataDictionary The path of the input data dictionary file.
* @return DataFlowDiagramAndDictionary object representing the loaded data flow diagram and dictionary.
*/
public DataFlowDiagramAndDictionary loadDFD(String project, String inputDataFlowDiagram, String inputDataDictionary, Class<?> activator)
throws StandaloneInitializationException {
StandaloneInitializerBuilder.builder()
.registerProjectURI(activator, project)
.build()
.init();

URI dfdURI = ResourceUtils.createRelativePluginURI(inputDataFlowDiagram, project);
URI ddURI = ResourceUtils.createRelativePluginURI(inputDataDictionary, project);

var provider = new DFDURIResourceProvider(dfdURI, ddURI);
provider.loadRequiredResources();
return new DataFlowDiagramAndDictionary(provider.getDataFlowDiagram(), provider.getDataDictionary());
}

/**
* Stores a DataFlowDiagramAndDictionary object into a specified output file.
Expand Down
Loading

0 comments on commit b03c858

Please sign in to comment.