Class CsvRawGridSource
- All Implemented Interfaces:
DataSource,RawGridSource
RawGridElements
as well as the RawGridElements container from .csv files.
This source is not buffered which means each call on a getter method always tries to read all data is necessary to return the requested objects in a hierarchical cascading way.
If performance is an issue, it is recommended to read the data cascading starting with reading nodes and then using the getters with arguments to avoid reading the same data multiple times.
The resulting sets are always unique on object and UUID base (with distinct UUIDs).
- Since:
- 03.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
ConstructorsConstructorDescriptionCsvRawGridSource(String csvSep, String gridFolderPath, FileNamingStrategy fileNamingStrategy, TypeSource typeSource) -
Method Summary
Modifier and TypeMethodDescriptionReturns a unique set ofTransformer2WInputinstances.get2WTransformers(Set<NodeInput> nodes, Set<Transformer2WTypeInput> transformer2WTypes, Set<OperatorInput> operators) Returns a set ofTransformer2WInputinstances.Returns a unique set ofTransformer3WInputinstances.get3WTransformers(Set<NodeInput> nodes, Set<Transformer3WTypeInput> transformer3WTypeInputs, Set<OperatorInput> operators) Returns a set ofTransformer3WInputinstances.Should return either a consistent instance ofRawGridElementswrapped inOptionalor an emptyOptional.getLines()Returns a unique set ofLineInputinstances.getLines(Set<NodeInput> nodes, Set<LineTypeInput> lineTypeInputs, Set<OperatorInput> operators) Returns a set ofLineInputinstances.Returns a unique set ofMeasurementUnitInputinstances.getMeasurementUnits(Set<NodeInput> nodes, Set<OperatorInput> operators) Returns a set ofMeasurementUnitInputinstances.getNodes()Returns a unique set ofNodeInputinstances.getNodes(Set<OperatorInput> operators) Returns a set ofNodeInputinstances.Returns a unique set ofSwitchInputinstances.getSwitches(Set<NodeInput> nodes, Set<OperatorInput> operators) Returns a set ofSwitchInputinstances.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
-
CsvRawGridSource
public CsvRawGridSource(String csvSep, String gridFolderPath, FileNamingStrategy fileNamingStrategy, TypeSource typeSource)
-
-
Method Details
-
getGridData
Should return either a consistent instance ofRawGridElementswrapped inOptionalor an emptyOptional. The decision to useOptionalinstead of returning theRawGridElementsinstance directly is motivated by the fact, that aRawGridElementsis a container instance that depends on several other entities. Without being complete, it is useless for further processing.Hence, whenever at least one entity
RawGridElementsdepends 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
RawGridElementsinstance, but also its validity e.g. in the sense that not duplicate UUIDs exist within all entities contained in the returning instance.- Specified by:
getGridDatain interfaceRawGridSource- Returns:
- either a valid, complete
RawGridElementsoptional orOptional.empty()
-
getNodes
Returns a unique set ofNodeInputinstances.This set has to be unique in the sense of object uniqueness but also in the sense of
UUIDuniqueness of the providedNodeInputwhich has to be checked manually, asNodeInput.equals(Object)is NOT restricted on the uuid ofNodeInput.- Specified by:
getNodesin interfaceRawGridSource- Returns:
- a set of object and uuid unique
NodeInputentities
-
getNodes
Returns a set ofNodeInputinstances. This set has to be unique in the sense of object uniqueness but also in the sense ofUUIDuniqueness of the providedNodeInputwhich has to be checked manually, asNodeInput.equals(Object)is NOT restricted on the uuid ofNodeInput.In contrast to
RawGridSource.getNodes()this interface provides the ability to pass in an already existing set ofOperatorInputentities, theNodeInputinstances 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 with
OperatorInputis not exhaustive, the corresponding operator is set toOperatorInput.NO_OPERATOR_ASSIGNED- Specified by:
getNodesin interfaceRawGridSource- Parameters:
operators- a set of object and uuid uniqueOperatorInputthat should be used for the returning instances- Returns:
- a set of object and uuid unique
NodeInputentities
-
getLines
Returns a unique set ofLineInputinstances.This set has to be unique in the sense of object uniqueness but also in the sense of
UUIDuniqueness of the providedLineInputwhich has to be checked manually, asLineInput.equals(Object)is NOT restricted on the uuid ofLineInput.- Specified by:
getLinesin interfaceRawGridSource- Returns:
- a set of object and uuid unique
LineInputentities
-
getLines
public Set<LineInput> getLines(Set<NodeInput> nodes, Set<LineTypeInput> lineTypeInputs, Set<OperatorInput> operators) Returns a set ofLineInputinstances. This set has to be unique in the sense of object uniqueness but also in the sense ofUUIDuniqueness of the providedLineInputwhich has to be checked manually, asLineInput.equals(Object)is NOT restricted on the uuid ofLineInput.In contrast to
RawGridSource.getNodes()this interface provides the ability to pass in an already existing set ofNodeInput,LineTypeInputandOperatorInputentities, theLineInputinstances depend on. Doing so, already loaded nodes, line types and operators 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 one of the sets of
NodeInputorLineTypeInputentities is not exhaustive for all availableLineInputentities (e.g. aNodeInputorLineTypeInputentity is missing) or if an error during the building process occurs, the entity that misses something will be skipped (which can be seen as a filtering functionality) but all entities that are able to be built will be returned anyway and the elements that couldn't have been built are logged.If the set with
OperatorInputis not exhaustive, the corresponding operator is set toOperatorInput.NO_OPERATOR_ASSIGNED- Specified by:
getLinesin interfaceRawGridSource- Parameters:
nodes- a set of object and uuid uniqueNodeInputentitieslineTypeInputs- a set of object and uuid uniqueLineTypeInputentitiesoperators- a set of object and uuid uniqueOperatorInputthat should be used for the returning instances- Returns:
- a set of object and uuid unique
LineInputentities
-
get2WTransformers
Returns a unique set ofTransformer2WInputinstances.This set has to be unique in the sense of object uniqueness but also in the sense of
UUIDuniqueness of the providedTransformer2WInputwhich has to be checked manually, asTransformer2WInput.equals(Object)is NOT restricted on the uuid ofTransformer2WInput.- Specified by:
get2WTransformersin interfaceRawGridSource- Returns:
- a set of object and uuid unique
Transformer2WInputentities
-
get2WTransformers
public Set<Transformer2WInput> get2WTransformers(Set<NodeInput> nodes, Set<Transformer2WTypeInput> transformer2WTypes, Set<OperatorInput> operators) Returns a set ofTransformer2WInputinstances. This set has to be unique in the sense of object uniqueness but also in the sense ofUUIDuniqueness of the providedTransformer2WInputwhich has to be checked manually, asTransformer2WInput.equals(Object)is NOT restricted on the uuid ofTransformer2WInput.In contrast to
RawGridSource.getNodes()this interface provides the ability to pass in an already existing set ofNodeInput,Transformer2WTypeInputandOperatorInputentities, theTransformer2WInputinstances depend on. Doing so, already loaded nodes, line types and operators 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 one of the sets of
NodeInputorTransformer2WTypeInputentities is not exhaustive for all availableTransformer2WInputentities (e.g. aNodeInputorTransformer2WTypeInputentity is missing) or if an error during the building process occurs, the entity that misses something will be skipped (which can be seen as a filtering functionality) but all entities that are able to be built will be returned anyway and the elements that couldn't have been built are logged.If the set with
OperatorInputis not exhaustive, the corresponding operator is set toOperatorInput.NO_OPERATOR_ASSIGNED- Specified by:
get2WTransformersin interfaceRawGridSource- Parameters:
nodes- a set of object and uuid uniqueNodeInputentitiestransformer2WTypes- a set of object and uuid uniqueTransformer2WTypeInputentitiesoperators- a set of object and uuid uniqueOperatorInputthat should be used for the returning instances- Returns:
- a set of object and uuid unique
Transformer2WInputentities
-
get3WTransformers
Returns a unique set ofTransformer3WInputinstances.This set has to be unique in the sense of object uniqueness but also in the sense of
UUIDuniqueness of the providedTransformer3WInputwhich has to be checked manually, asTransformer3WInput.equals(Object)is NOT restricted on the uuid ofTransformer3WInput.- Specified by:
get3WTransformersin interfaceRawGridSource- Returns:
- a set of object and uuid unique
Transformer3WInputentities
-
get3WTransformers
public Set<Transformer3WInput> get3WTransformers(Set<NodeInput> nodes, Set<Transformer3WTypeInput> transformer3WTypeInputs, Set<OperatorInput> operators) Returns a set ofTransformer3WInputinstances. This set has to be unique in the sense of object uniqueness but also in the sense ofUUIDuniqueness of the providedTransformer3WInputwhich has to be checked manually, asTransformer3WInput.equals(Object)is NOT restricted on the uuid ofTransformer3WInput.In contrast to
RawGridSource.getNodes()this interface provides the ability to pass in an already existing set ofNodeInput,Transformer3WTypeInputandOperatorInputentities, theTransformer3WInputinstances depend on. Doing so, already loaded nodes, line types and operators 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 one of the sets of
NodeInputorTransformer3WTypeInputentities is not exhaustive for all availableTransformer3WInputentities (e.g. aNodeInputorTransformer3WTypeInputentity is missing) or if an error during the building process occurs, the entity that misses something will be skipped (which can be seen as a filtering functionality) but all entities that are able to be built will be returned anyway and the elements that couldn't have been built are logged.If the set with
OperatorInputis not exhaustive, the corresponding operator is set toOperatorInput.NO_OPERATOR_ASSIGNED- Specified by:
get3WTransformersin interfaceRawGridSource- Parameters:
nodes- a set of object and uuid uniqueNodeInputentitiestransformer3WTypeInputs- a set of object and uuid uniqueTransformer3WTypeInputentitiesoperators- a set of object and uuid uniqueOperatorInputthat should be used for the returning instances- Returns:
- a set of object and uuid unique
Transformer3WInputentities
-
getSwitches
Returns a unique set ofSwitchInputinstances.This set has to be unique in the sense of object uniqueness but also in the sense of
UUIDuniqueness of the providedSwitchInputwhich has to be checked manually, asSwitchInput.equals(Object)is NOT restricted on the uuid ofSwitchInput.- Specified by:
getSwitchesin interfaceRawGridSource- Returns:
- a set of object and uuid unique
SwitchInputentities
-
getSwitches
Returns a set ofSwitchInputinstances. This set has to be unique in the sense of object uniqueness but also in the sense ofUUIDuniqueness of the providedSwitchInputwhich has to be checked manually, asSwitchInput.equals(Object)is NOT restricted on the uuid ofSwitchInput.In contrast to
RawGridSource.getNodes()this interface provides the ability to pass in an already existing set ofNodeInputandOperatorInputentities, theSwitchInputinstances depend on. Doing so, already loaded nodes, line types and operators 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 one of the sets of
NodeInputentities is not exhaustive for all availableSwitchInputentities (e.g. aNodeInputentity is missing) or if an error during the building process occurs, the entity that misses something will be skipped (which can be seen as a filtering functionality) but all entities that are able to be built will be returned anyway and the elements that couldn't have been built are logged.If the set with
OperatorInputis not exhaustive, the corresponding operator is set toOperatorInput.NO_OPERATOR_ASSIGNED- Specified by:
getSwitchesin interfaceRawGridSource- Parameters:
nodes- a set of object and uuid uniqueNodeInputentitiesoperators- a set of object and uuid uniqueOperatorInputthat should be used for the returning instances- Returns:
- a set of object and uuid unique
SwitchInputentities
-
getMeasurementUnits
Returns a unique set ofMeasurementUnitInputinstances.This set has to be unique in the sense of object uniqueness but also in the sense of
UUIDuniqueness of the providedMeasurementUnitInputwhich has to be checked manually, asMeasurementUnitInput.equals(Object)is NOT restricted on the uuid ofMeasurementUnitInput.- Specified by:
getMeasurementUnitsin interfaceRawGridSource- Returns:
- a set of object and uuid unique
MeasurementUnitInputentities
-
getMeasurementUnits
public Set<MeasurementUnitInput> getMeasurementUnits(Set<NodeInput> nodes, Set<OperatorInput> operators) Returns a set ofMeasurementUnitInputinstances. This set has to be unique in the sense of object uniqueness but also in the sense ofUUIDuniqueness of the providedMeasurementUnitInputwhich has to be checked manually, asMeasurementUnitInput.equals(Object)is NOT restricted on the uuid ofMeasurementUnitInput.In contrast to
RawGridSource.getNodes()this interface provides the ability to pass in an already existing set ofNodeInputandOperatorInputentities, theMeasurementUnitInputinstances depend on. Doing so, already loaded nodes, line types and operators 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 one of the sets of
NodeInputentities is not exhaustive for all availableMeasurementUnitInputentities (e.g. aNodeInputentity is missing) or if an error during the building process occurs, the entity that misses something will be skipped (which can be seen as a filtering functionality) but all entities that are able to be built will be returned anyway and the elements that couldn't have been built are logged.If the set with
OperatorInputis not exhaustive, the corresponding operator is set toOperatorInput.NO_OPERATOR_ASSIGNED- Specified by:
getMeasurementUnitsin interfaceRawGridSource- Parameters:
nodes- a set of object and uuid uniqueNodeInputentitiesoperators- a set of object and uuid uniqueOperatorInputthat should be used for the returning instances- Returns:
- a set of object and uuid unique
MeasurementUnitInputentities
-