Class FWSimResourceAdapter<T>
java.lang.Object
net.simplace.sim.io.FWSimIOAdapter
net.simplace.sim.io.resources.FWSimInputAdapter
net.simplace.sim.io.resources.FWSimResourceAdapter<T>
- Type Parameters:
T- type of the data provided by theFWSimInterface
- All Implemented Interfaces:
FWSimFieldContainer
- Direct Known Subclasses:
CSVResourceAdapter, DatabaseResourceAdapter, JSONResourceAdapter, NetCDFResourceAdapter, XMLResourceAdapter
Resource adapters read data from an interface (
FWSimInterface) into a FWSimResourceCache. They are
specific to the media type of the interface (CSV, database, DBF/SHP, NetCDF, XML, JSON); the matching adapter is
created by createResourceAdapter(FWSimSession, Element, int).- Author:
- Andreas Enders
-
Nested Class Summary
Nested classes/interfaces inherited from class FWSimIOAdapter
FWSimIOAdapter.FREQUENCE -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Integer[]lines of the resource to read, ornullfor allFields 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
ConstructorsModifierConstructorDescriptionFWSimResourceAdapter(FWSimResourceAdapter<?> aAdapter, FWSimInterface<?> aInterface) Copy constructor used when the interface of an adapter is replaced.FWSimResourceAdapter(org.jdom2.Element aResourceElement, String aName, int aOrderNumber, FWSimInterface<?> aInterface, FWSimIOAdapter.FREQUENCE aFrequence, FWSimSession aFwSimSession) Creates the adapter from the graph panel.protectedFWSimResourceAdapter(org.jdom2.Element aResourceElement, FWSimSession aCurrentSession, int aOrderNumber) Creates the adapter from aresourceelement of the solution. -
Method Summary
Modifier and TypeMethodDescriptionstatic FWSimFieldContainercreateAdapterFromObservable(FWObservable aObservable, FWSimSession aFwSimSession, int aOrderNumber) Creates a resource adapter from the data of the GUI form (fieldsName,Datatype,Frequenceand, depending on the type,Driver,URL,User,Pass,StatementorFile,Content).static FWSimResourceAdaptercreateResourceAdapter(FWSimSession aSession, org.jdom2.Element aResourceElement, int aOrderNumber) Factory method: creates the resource adapter matching the type of the interface named in the attributeinterface(SHP and DBF share one adapter).Integer[]voidsetLinesToRead(Integer[] aLinesToRead) org.jdom2.ElementtoXML()Creates theresourceelement with id, interface, frequency, rule, dbcache and header.static FWSimResourceAdapterupdateAdapter(FWSimResourceAdapter<?> aOldAdapter, FWSimInterface<?> aInterface) Factory method: creates a copy of an adapter for a new interface, with the adapter class matching the interface type.Methods inherited from class FWSimInputAdapter
getContentType, getData, 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
-
Field Details
-
iLinesToRead
lines of the resource to read, ornullfor all
-
-
Constructor Details
-
FWSimResourceAdapter
protected FWSimResourceAdapter(org.jdom2.Element aResourceElement, FWSimSession aCurrentSession, int aOrderNumber) Creates the adapter from aresourceelement of the solution.- Parameters:
aResourceElement- theresourceelementaCurrentSession- the sessionaOrderNumber- order number of the adapter
-
FWSimResourceAdapter
public FWSimResourceAdapter(org.jdom2.Element aResourceElement, String aName, int aOrderNumber, FWSimInterface<?> aInterface, FWSimIOAdapter.FREQUENCE aFrequence, FWSimSession aFwSimSession) Creates the adapter from the graph panel.- Parameters:
aResourceElement- theresourceelementaName- name (id) of the adapteraOrderNumber- order number of the adapteraInterface- interface to read fromaFrequence- frequency the data is read withaFwSimSession- the session
-
FWSimResourceAdapter
Copy constructor used when the interface of an adapter is replaced.- Parameters:
aAdapter- the adapter to copyaInterface- the new interface
-
-
Method Details
-
createResourceAdapter
public static FWSimResourceAdapter createResourceAdapter(FWSimSession aSession, org.jdom2.Element aResourceElement, int aOrderNumber) throws MissingSimResourceException, DuplicateSimFieldException Factory method: creates the resource adapter matching the type of the interface named in the attributeinterface(SHP and DBF share one adapter).- Parameters:
aSession- the sessionaResourceElement- theresourceelementaOrderNumber- order number of the adapter- Returns:
- the created adapter
- Throws:
MissingSimResourceException- if no interface is given, the interface does not exist or its type is not supportedDuplicateSimFieldException- if a resource with the same id already exists
-
getLinesToRead
- Returns:
- the lines of the resource to read, or
nullfor all
-
setLinesToRead
- Parameters:
aLinesToRead- the lines of the resource to read, ornullfor all
-
updateAdapter
public static FWSimResourceAdapter updateAdapter(FWSimResourceAdapter<?> aOldAdapter, FWSimInterface<?> aInterface) Factory method: creates a copy of an adapter for a new interface, with the adapter class matching the interface type.- Parameters:
aOldAdapter- the adapter to copyaInterface- the new interface- Returns:
- the new adapter, or
nullif the interface type is not supported (e.g. MEMORY, CUSTOM)
-
toXML
public org.jdom2.Element toXML()Creates theresourceelement with id, interface, frequency, rule, dbcache and header.- Returns:
- an XML element with all settings of this container
- See Also:
-
createAdapterFromObservable
public static FWSimFieldContainer createAdapterFromObservable(FWObservable aObservable, FWSimSession aFwSimSession, int aOrderNumber) throws MissingSimResourceException Creates a resource adapter from the data of the GUI form (fieldsName,Datatype,Frequenceand, depending on the type,Driver,URL,User,Pass,StatementorFile,Content). Supported types are DATABASE, CSV (the divider is chosen in a preview dialog) and XML.- Parameters:
aObservable- the form dataaFwSimSession- the sessionaOrderNumber- order number of the adapter- Returns:
- the created adapter, or
nullif creating it failed (the error is logged) - Throws:
MissingSimResourceException- if the type is not supported
-