Class CsvGraphicSource
- All Implemented Interfaces:
DataSource
,GraphicSource
GraphicSource
interface to read NodeGraphicInput
and LineGraphicInput
entities from .csv files- Since:
- 08.04.20
-
Field Summary
Fields inherited from class edu.ie3.datamodel.io.source.csv.CsvDataSource
connector, csvSep, FIELDS_TO_VALUES_MAP, log, NODE, NODE_A, NODE_B, OPERATOR, TYPE
-
Constructor Summary
ConstructorDescriptionCsvGraphicSource
(String csvSep, String folderPath, FileNamingStrategy fileNamingStrategy, TypeSource typeSource, RawGridSource rawGridSource) -
Method Summary
Modifier and TypeMethodDescriptionShould return either a consistent instance ofGraphicElements
wrapped inOptional
or an emptyOptional
.Returns a set ofLineGraphicInput
instances.getLineGraphicInput
(Set<LineInput> lines) Returns a set ofLineGraphicInput
instances.Returns a set ofNodeGraphicInput
instances.getNodeGraphicInput
(Set<NodeInput> nodes) Returns a set ofNodeGraphicInput
instances.Methods inherited from class edu.ie3.datamodel.io.source.csv.CsvDataSource
assetInputEntityDataStream, assetInputEntityDataStream, buildStreamWithFieldsToAttributesMap, buildStreamWithFieldsToAttributesMap, csvRowFieldValueMapping, distinctRowsWithLog, findFirstEntityByUuid, getAssetType, isPresentCollectIfNot, logSkippingWarning, nodeAssetEntityStream, nodeAssetInputEntityDataStream, parseCsvRow, printInvalidElementInformation, saveMapGet, simpleEntityDataStream
-
Constructor Details
-
CsvGraphicSource
public CsvGraphicSource(String csvSep, String folderPath, FileNamingStrategy fileNamingStrategy, TypeSource typeSource, RawGridSource rawGridSource)
-
-
Method Details
-
getGraphicElements
Should return either a consistent instance ofGraphicElements
wrapped inOptional
or an emptyOptional
. The decision to useOptional
instead of returning theGraphicElements
instance directly is motivated by the fact, that aGraphicElements
is a container instance that depends on several other entities. Without being complete, it is useless for further processing. Hence, whenever at least one entityGraphicElements
depends on cannot be provided,Optional.empty()
should be returned and extensive logging should provide enough information to debug the error and fix the persistent data that has been failed to processed.Furthermore, it is expected, that the specific implementation of this method ensures not only the completeness of the resulting
GraphicElements
instance, but also its validity e.g. in the sense that not duplicate UUIDs exist within all entities contained in the returning instance.- Specified by:
getGraphicElements
in interfaceGraphicSource
- Returns:
- either a valid, complete
GraphicElements
optional orOptional.empty()
-
getNodeGraphicInput
Returns a set ofNodeGraphicInput
instances. This set has to be unique in the sense of object uniqueness but also in the sense ofUUID
uniqueness of the providedNodeGraphicInput
which has to be checked manually, asNodeGraphicInput.equals(Object)
is NOT restricted on the uuid ofNodeGraphicInput
.- Specified by:
getNodeGraphicInput
in interfaceGraphicSource
- Returns:
- a set of object and uuid unique
NodeGraphicInput
entities
-
getNodeGraphicInput
Returns a set ofNodeGraphicInput
instances. This set has to be unique in the sense of object uniqueness but also in the sense ofUUID
uniqueness of the providedNodeGraphicInput
which has to be checked manually, asNodeGraphicInput.equals(Object)
is NOT restricted on the uuid ofNodeGraphicInput
.In contrast to
GraphicSource.getNodeGraphicInput()
this interface provides the ability to pass in an already existing set ofNodeInput
entities, theNodeGraphicInput
instances depend on. Doing so, already loaded nodes can be recycled to improve performance and prevent unnecessary loading operations.If something fails during the creation process it's up to the concrete implementation of an empty set or a set with all entities that has been able to be build is returned.
If the set of
NodeInput
entities is not exhaustive for all availableNodeGraphicInput
entities or if an error during the building process occurs, all entities that has been able to be built are returned and the not-built ones are ignored (= filtered out).- Specified by:
getNodeGraphicInput
in interfaceGraphicSource
- Parameters:
nodes
- a set of object and uuid unique nodes that should be used for the returning instances- Returns:
- a set of object and uuid unique
NodeGraphicInput
entities
-
getLineGraphicInput
Returns a set ofLineGraphicInput
instances. This set has to be unique in the sense of object uniqueness but also in the sense ofUUID
uniqueness of the providedLineGraphicInput
which has to be checked manually, asLineGraphicInput.equals(Object)
is NOT restricted on the uuid ofLineGraphicInput
.- Specified by:
getLineGraphicInput
in interfaceGraphicSource
- Returns:
- a set of object and uuid unique
LineGraphicInput
entities
-
getLineGraphicInput
Returns a set ofLineGraphicInput
instances. This set has to be unique in the sense of object uniqueness but also in the sense ofUUID
uniqueness of the providedLineGraphicInput
which has to be checked manually, asLineGraphicInput.equals(Object)
is NOT restricted on the uuid ofLineGraphicInput
.In contrast to
GraphicSource.getLineGraphicInput()
this interface provides the ability to pass in an already existing set ofLineInput
entities, theLineGraphicInput
instances depend on. Doing so, already loaded nodes can be recycled to improve performance and prevent unnecessary loading operations.If something fails during the creation process it's up to the concrete implementation of an empty set or a set with all entities that has been able to be build is returned.
If the set of
LineInput
entities is not exhaustive for all availableLineGraphicInput
entities or if an error during the building process occurs, all entities that has been able to be built are returned and the not-built ones are ignored (= filtered out).- Specified by:
getLineGraphicInput
in interfaceGraphicSource
- Parameters:
lines
- a set of object and uuid unique lines that should be used for the returning instances- Returns:
- a set of object and uuid unique
LineGraphicInput
entities
-