public class JsonComposer
extends java.lang.Object
Although some of the calculations done here could be applied in a more-general process
of composing any ecore model, the current implementation is coupled to the data/structure
of the ecore models discovered by the JsonAdvancedDiscoverer
.
In the context of the JSON discoverer, the JsonComposer
is used to
discover the metamodel out of a set of JSON-based APIs
Modifier and Type | Field and Description |
---|---|
private static double |
ATTRIBUTE_MATCHING_THRESHOLD
Threshold to consider when two attributes.
|
private static double |
CLASS_MATCHING_THRESHOLD
Threshold to consider when two metamodel classes are similar.
|
private static java.util.logging.Logger |
LOGGER
Used to log all the activity
|
private java.util.List<JsonSourceSet> |
sourceSets
The set of
JsonSourceSet s to use in the discovery process |
Constructor and Description |
---|
JsonComposer(java.util.List<JsonSourceSet> sourceSets)
Constructs a new
JsonComposer with a list of JsonSourceSet s |
Modifier and Type | Method and Description |
---|---|
org.eclipse.emf.ecore.EPackage |
compose()
Compose the sourceSet's received in the constructor and returns the composed metamodel.
|
org.eclipse.emf.ecore.EPackage |
compose(java.io.File resultPath)
Compose the sourceSet's received in the constructor and returns the composed metamodel.
|
private boolean |
isSimilar(org.eclipse.emf.ecore.EClass sourceEClass,
org.eclipse.emf.ecore.EClass targetEClass)
Compares if two metamodel classes (as
EClass elements) are similar. |
private boolean |
nameIsSimilar(java.util.List<java.lang.String> sourceNames,
java.util.List<java.lang.String> targetNames)
Compares two list of
String and returns true when two similar String s
are found. |
private java.util.List<JsonSourceSet> sourceSets
JsonSourceSet
s to use in the discovery processprivate static final java.util.logging.Logger LOGGER
private static final double ATTRIBUTE_MATCHING_THRESHOLD
To calculate the ratio, the number of matching attributes in the two metamodel classes are compared. Thus, two metamodel classes with matching attributes will give a ratio of 1
private static final double CLASS_MATCHING_THRESHOLD
To calculate the ratio, the number of matching attributes/refereces in the two metamodel classes are compared. Thus, two metamodel classes with matching attributes/references will give a ratio of 1
public JsonComposer(java.util.List<JsonSourceSet> sourceSets)
JsonComposer
with a list of JsonSourceSet
ssourceSets
- A list of JsonSourceSet
spublic org.eclipse.emf.ecore.EPackage compose(java.io.File resultPath) throws java.io.FileNotFoundException
resultPath
- The path where the resulting metamodel will be storedjava.io.FileNotFoundException
- There is no file to read frompublic org.eclipse.emf.ecore.EPackage compose()
private boolean isSimilar(org.eclipse.emf.ecore.EClass sourceEClass, org.eclipse.emf.ecore.EClass targetEClass)
EClass
elements) are similar.
The comparison takes into consideration the names of attributes/refrences and counts
the ones that are similar. The ratio of similar vs. different is calculated and if it higher
that ATTRIBUTE_MATCHING_THRESHOLD
, the two classes are considered similar
sourceEClass
- The source EClass
targetEClass
- The target EClass
private boolean nameIsSimilar(java.util.List<java.lang.String> sourceNames, java.util.List<java.lang.String> targetNames)
String
and returns true when two similar String
s
are found.sourceNames
- Source list of String
targetNames
- Target list of String
String
s (one in each list) are found.