Class StandardBasedCsvDataSource
java.lang.Object
neqsim.process.mechanicaldesign.data.StandardBasedCsvDataSource
- All Implemented Interfaces:
MechanicalDesignDataSource
Loads mechanical design limits from CSV files with support for international standards.
This data source supports two CSV formats:
Standard Format (with STANDARD_CODE column):
STANDARD_CODE,STANDARD_VERSION,EQUIPMENTTYPE,SPECIFICATION,MINVALUE,MAXVALUE,UNIT,DESCRIPTION NORSOK-L-001,Rev 6,Pipeline,DesignPressureMargin,1.1,1.1,-,Design pressure safety factor ASME-VIII-Div1,2021,Separator,MaxPressure,0,150,barg,Maximum design pressure
Company Format (legacy compatibility):
EQUIPMENTTYPE,COMPANY,MAXPRESSURE,MINPRESSURE,MAXTEMPERATURE,MINTEMPERATURE,CORROSIONALLOWANCE,JOINTEFFICIENCY Pipeline,StatoilTR,100,0,150,-50,3.0,0.85
The data source automatically detects the format based on column headers.
- Version:
- 1.0
- Author:
- esol
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final classColumn index mapper.private static final classInternal data structure for parsed rows. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionStandardBasedCsvDataSource(String resourcePath) Create a data source from a classpath resource.StandardBasedCsvDataSource(Path csvPath) Create a data source from a file path. -
Method Summary
Modifier and TypeMethodDescriptionprivate booleanprivate voidprivate Optional<DesignLimitData> findByCompany(String equipmentTypeName, String companyIdentifier) getAvailableStandards(String equipmentTypeName) Get a list of available standards in this data source.getAvailableVersions(String standardCode) Get a list of available versions for a given standard.getDesignLimits(String equipmentTypeName, String companyIdentifier) Retrieve design limit data for a given equipment type and company identifier.getDesignLimitsByStandard(String standardCode, String version, String equipmentTypeName) Retrieve design limit data for a given equipment type based on an international standard.private doubleprivate Stringprivate voidloadData()private Stringprivate BufferedReaderprivate String[]parseCsvLine(String line) parseRow(String[] tokens, StandardBasedCsvDataSource.ColumnIndex index) private doubleselectValue(double minValue, double maxValue) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface MechanicalDesignDataSource
hasStandard
-
Field Details
-
logger
private static final org.apache.logging.log4j.Logger logger -
csvPath
-
resourcePath
-
isResource
private final boolean isResource -
cachedData
-
isStandardFormat
private boolean isStandardFormat
-
-
Constructor Details
-
StandardBasedCsvDataSource
Create a data source from a file path.- Parameters:
csvPath- path to the CSV file
-
StandardBasedCsvDataSource
Create a data source from a classpath resource.- Parameters:
resourcePath- the classpath resource path (e.g., "designdata/standards/norsok.csv")
-
-
Method Details
-
getDesignLimits
public Optional<DesignLimitData> getDesignLimits(String equipmentTypeName, String companyIdentifier) Description copied from interface:MechanicalDesignDataSourceRetrieve design limit data for a given equipment type and company identifier.- Specified by:
getDesignLimitsin interfaceMechanicalDesignDataSource- Parameters:
equipmentTypeName- canonical equipment type identifier (e.g. "Pipeline").companyIdentifier- company specific design code identifier.- Returns:
- optional design limit data if available.
-
getDesignLimitsByStandard
public Optional<DesignLimitData> getDesignLimitsByStandard(String standardCode, String version, String equipmentTypeName) Description copied from interface:MechanicalDesignDataSourceRetrieve design limit data for a given equipment type based on an international standard.This method allows looking up design limits by standard code (e.g., "NORSOK-L-001") rather than company identifier.
- Specified by:
getDesignLimitsByStandardin interfaceMechanicalDesignDataSource- Parameters:
standardCode- the international standard code (e.g., "NORSOK-L-001", "ASME-VIII-Div1")version- the standard version (e.g., "Rev 6", "2021"), null for defaultequipmentTypeName- canonical equipment type identifier- Returns:
- optional design limit data if available
-
getAvailableStandards
Description copied from interface:MechanicalDesignDataSourceGet a list of available standards in this data source.- Specified by:
getAvailableStandardsin interfaceMechanicalDesignDataSource- Parameters:
equipmentTypeName- the equipment type to filter by (null for all)- Returns:
- list of standard codes available
-
getAvailableVersions
Description copied from interface:MechanicalDesignDataSourceGet a list of available versions for a given standard.- Specified by:
getAvailableVersionsin interfaceMechanicalDesignDataSource- Parameters:
standardCode- the standard code to query- Returns:
- list of available versions
-
findByCompany
-
applySpecification
private boolean applySpecification(DesignLimitData.Builder builder, StandardBasedCsvDataSource.StandardDataRow row) -
selectValue
private double selectValue(double minValue, double maxValue) -
ensureLoaded
private void ensureLoaded() -
loadData
private void loadData() -
openReader
- Throws:
IOException
-
parseCsvLine
-
parseRow
private StandardBasedCsvDataSource.StandardDataRow parseRow(String[] tokens, StandardBasedCsvDataSource.ColumnIndex index) -
getString
-
getDouble
-
normalize
-