public class ZooDiscoverer
extends java.lang.Object
The path has to conform to a particular structure. Thus, the root path has to be composed by a set of folder (one per API), where each folder contains subfolders (one per JSON source).
For each JSON source, it is expected to find a "info.properties" file which the "name" and "shortname" properties describing the source. Furthermore, a set of JSON files have to be included in the JSON source. Each JSON file name must start with "json" string and it is expected both a .json * and a .properties file (with the same name), including the json text and the property "call" to invoke the service.
This is and example of such an organization:
- RootPath +-- API1 +-- source1 +-- info.properties +-- json1.json +-- json1.properties +-- json2.json +-- json2.properties +-- ... +-- sourcen +-- ... +-- API2 +-- ... +-- APIn +-- ...
We recommend you to have a look at the existing examples on this project to better understand how to configure the folder and the files.
Modifier and Type | Field and Description |
---|---|
private static java.util.logging.Logger |
LOGGER
The logger to keep track of all the execution traces
|
private java.io.File |
rootPath
The root from where the process will start
|
Constructor and Description |
---|
ZooDiscoverer(java.io.File rootPath)
Constructs a new
ZooDiscoverer element. |
Modifier and Type | Method and Description |
---|---|
void |
discover()
Launches the discovery process.
|
void |
discover(boolean overwrite)
Main method to start the discovery process.
|
private JsonSource |
discoverSource(java.io.File rootPath,
boolean overwrite)
Performs the discovery for a specific directory.
|
private org.eclipse.emf.ecore.EPackage |
loadEcore(java.io.File target)
Loads a metamodel (as
EPackage ) |
private void |
saveEcore(org.eclipse.emf.ecore.EPackage metamodel,
java.io.File target)
Saves a metamodel (as
EPackage ) into a file |
private static void |
saveModel(java.util.List<org.eclipse.emf.ecore.EObject> elements,
java.io.File target)
Save a list of model elements (as
EObject s) into a file |
private static final java.util.logging.Logger LOGGER
private java.io.File rootPath
public ZooDiscoverer(java.io.File rootPath)
ZooDiscoverer
element. Requires the starting directory pathrootPath
- The path from where the process will startpublic void discover() throws java.io.FileNotFoundException
This method relies on discoverSource(File, boolean)
with the second
parameter (overwriting) active.
java.io.FileNotFoundException
- Something went wrong when looking for a filepublic void discover(boolean overwrite) throws java.io.FileNotFoundException
Basically traverses the rootPath
folder and calls to
discoverSource(File, boolean)
to discover a JsonSource
element for each source (see class desc
overwrite
- The result has to overwrite (or not) previous executionsjava.io.FileNotFoundException
- Something went wrong when looking for a fileprivate JsonSource discoverSource(java.io.File rootPath, boolean overwrite) throws java.io.FileNotFoundException, java.io.IOException
The folder has to follow this pattern (example with two JSON sources):
+-- source1 +-- info.properties +-- json1.json +-- json1.properties +-- json2.json +-- json2.properties
The discovery process follow these steps:
As a result, a JsonSource
is built, which includes all the JSON sources plus the discovered metamodel (as a EPackage
)
rootPath
- The folder to analyzeoverwrite
- If the results have to overwrite previous onesJsonSource
with the JSON sources provided and the metamodeljava.io.FileNotFoundException
- A file required in the folder (check the doc to see the expected structure) was not foundjava.io.IOException
- Thrown when having problem while reading/writing filesprivate void saveEcore(org.eclipse.emf.ecore.EPackage metamodel, java.io.File target)
EPackage
) into a filemetamodel
- The metamodeltarget
- The file where the metamodel will be storedprivate org.eclipse.emf.ecore.EPackage loadEcore(java.io.File target)
EPackage
)target
- The path to the metamodelEPackage
)private static void saveModel(java.util.List<org.eclipse.emf.ecore.EObject> elements, java.io.File target)
EObject
s) into a fileelements
- List of model elements (as EObject
s)target
- The path for the file