Class JSONResourceAdapter
java.lang.Object
net.simplace.sim.io.FWSimIOAdapter
net.simplace.sim.io.resources.FWSimInputAdapter
net.simplace.sim.io.resources.FWSimResourceAdapter<com.fasterxml.jackson.databind.JsonNode>
net.simplace.sim.io.resources.adapter.JSONResourceAdapter
- All Implemented Interfaces:
FWSimFieldContainer
public class JSONResourceAdapter
extends FWSimResourceAdapter<com.fasterxml.jackson.databind.JsonNode>
Resource adapter for JSON data (
JSONInterface, e.g. from a web service). The data is read on every call of
getData(FWSimVarMap); the unique id of the cache is derived from the adapter name and the content, so
transformers detect changed source data.- Author:
- Andreas Enders
-
Nested Class Summary
Nested classes/interfaces inherited from class FWSimIOAdapter
FWSimIOAdapter.FREQUENCE -
Field Summary
Fields inherited from class FWSimResourceAdapter
iLinesToReadFields inherited from class FWSimInputAdapter
iJexlScript, iShouldCacheToDBFields inherited from class FWSimIOAdapter
iArrayMode, iFieldcount, iFrequence, iHeaderVariables, iInterface, iJexlRule, iKeyMap, iName, iOrderNumber, iProcessTime, iResourceElement, iSession, iSourceKey -
Constructor Summary
ConstructorsConstructorDescriptionJSONResourceAdapter(String aURL, String aPath, String aVarName, String aComponentName, int aOrderNumber, FWSimSession aFwSimSession, FWSimIOAdapter.FREQUENCE aFrequence, Map<String, String> aKeyMap) Creates the adapter from the graph panel with its own JSON interface.JSONResourceAdapter(FWSimResourceAdapter<?> aAdapter, JSONInterface aInterface) Copy constructor used when the interface is replaced; the key variables are taken over.JSONResourceAdapter(org.jdom2.Element aResourceElement, String aURL, String aPath, String aVarName, String aComponentName, int aOrderNumber, FWSimSession aFwSimSession, FWSimIOAdapter.FREQUENCE aFrequence, Map<String, String> aKeyMap) Creates the adapter from aresourceelement with its own JSON interface.JSONResourceAdapter(org.jdom2.Element aResourceElement, FWSimSession aSession, int aOrderNumber) Creates the adapter from aresourceelement of the solution. -
Method Summary
Modifier and TypeMethodDescriptiongetData(FWSimVarMap aVarMap) Gets the JSON data from the interface and reads it into a new cache.getData(FWSimVarMap aVarMap, JSONDataContainer aJsonArray) Reads JSON data into a new cache.Methods inherited from class FWSimResourceAdapter
createAdapterFromObservable, createResourceAdapter, getLinesToRead, setLinesToRead, toXML, updateAdapterMethods inherited from class FWSimInputAdapter
getContentType, getInputVariables, getJexlScript, getOutputVariables, getVarMap, isTransformer, setFrequenceAndRule, shouldCacheToDB, toHTMLTablestringMethods inherited from class FWSimIOAdapter
addProcessTime, addVariable, checkCondition, createFormFields, createVariables, finalize, getCreateFormXML, getEditFormXML, getFieldMap, getFrequence, getHeaderVariables, getHeaderXML, getInterface, getJexlRule, getKeyMap, getName, getOrderNumber, getVariable, isArrayMode, isConditionCheck, removeVariable, setInterface, setOrderNumber, toString, writeHeaderList
-
Constructor Details
-
JSONResourceAdapter
public JSONResourceAdapter(org.jdom2.Element aResourceElement, FWSimSession aSession, int aOrderNumber) Creates the adapter from aresourceelement of the solution.- Parameters:
aResourceElement- theresourceelementaSession- the sessionaOrderNumber- order number of the adapter
-
JSONResourceAdapter
public JSONResourceAdapter(org.jdom2.Element aResourceElement, String aURL, String aPath, String aVarName, String aComponentName, int aOrderNumber, FWSimSession aFwSimSession, FWSimIOAdapter.FREQUENCE aFrequence, Map<String, String> aKeyMap) throws ExceptionCreates the adapter from aresourceelement with its own JSON interface.- Parameters:
aResourceElement- theresourceelementaURL- URL of the JSON dataaPath- path to the data within the JSON documentaVarName- name of the variable in the JSON documentaComponentName- name of the interfaceaOrderNumber- order number of the adapteraFwSimSession- the sessionaFrequence- not used (taken from the element)aKeyMap- not used (taken from the element)- Throws:
Exception- if the interface cannot be created
-
JSONResourceAdapter
public JSONResourceAdapter(String aURL, String aPath, String aVarName, String aComponentName, int aOrderNumber, FWSimSession aFwSimSession, FWSimIOAdapter.FREQUENCE aFrequence, Map<String, String> aKeyMap) throws ExceptionCreates the adapter from the graph panel with its own JSON interface.- Parameters:
aURL- URL of the JSON dataaPath- path to the data within the JSON documentaVarName- name of the variable in the JSON documentaComponentName- name of the adapter and the interfaceaOrderNumber- order number of the adapteraFwSimSession- the sessionaFrequence- frequency the data is read withaKeyMap- key variables; if empty, the user is asked to select them- Throws:
Exception- if the interface cannot be created
-
JSONResourceAdapter
Copy constructor used when the interface is replaced; the key variables are taken over.- Parameters:
aAdapter- the adapter to copyaInterface- the new interface
-
-
Method Details
-
getData
Gets the JSON data from the interface and reads it into a new cache.- Specified by:
getDatain classFWSimInputAdapter- Parameters:
aVarMap- variable map of the simulation (e.g. for the key values of the rule)- Returns:
- the cache containing the data read
- Throws:
MissingSimResourceException- if the data cannot be read- See Also:
-
getData
public FWSimResourceCache getData(FWSimVarMap aVarMap, JSONDataContainer aJsonArray) throws MissingSimResourceException Reads JSON data into a new cache.- Parameters:
aVarMap- variable map of the simulationaJsonArray- the JSON data- Returns:
- the new cache
- Throws:
MissingSimResourceException- if the data cannot be read
-