Class CsvTorgDataSource
java.lang.Object
neqsim.process.mechanicaldesign.torg.CsvTorgDataSource
- All Implemented Interfaces:
TorgDataSource
CSV-based data source for loading Technical Requirements Documents (TORG).
This implementation supports two CSV file formats:
Format 1: Standards-focused (standards.csv)
PROJECT_ID,PROJECT_NAME,COMPANY,DESIGN_CATEGORY,STANDARD_CODE,VERSION,PRIORITY PROJ-001,Offshore Platform,Equinor,pressure vessel design code,ASME-VIII-Div1,2021,1 PROJ-001,Offshore Platform,Equinor,separator process design,API-12J,8th Ed,1 PROJ-001,Offshore Platform,Equinor,pipeline design codes,NORSOK-L-001,Rev 6,1
Format 2: Full TORG (torg_master.csv)
PROJECT_ID,PROJECT_NAME,COMPANY,REVISION,ISSUE_DATE,MIN_AMBIENT_TEMP,MAX_AMBIENT_TEMP,... PROJ-001,Offshore Platform,Equinor,2,-40,45,...
When using Format 1, the data source automatically combines rows with the same PROJECT_ID into a single TechnicalRequirementsDocument.
- Version:
- 1.0
- Author:
- esol
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Map<String, TechnicalRequirementsDocument> private static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final StringCSV column names for standards format.private static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate final Pathprivate booleanprivate static final org.apache.logging.log4j.Logger -
Constructor Summary
ConstructorsConstructorDescriptionCsvTorgDataSource(Path csvPath) Create a CsvTorgDataSource from a file path. -
Method Summary
Modifier and TypeMethodDescriptionstatic CsvTorgDataSourcefromResource(String resourcePath) Create a CsvTorgDataSource from a classpath resource.Get a list of available companies.Get a list of available project identifiers.private Stringprivate StringgetFieldOrDefault(String[] values, Map<String, Integer> headerIndex, String column, String defaultValue) protected BufferedReaderGet a BufferedReader for the CSV data.loadByCompanyAndProject(String companyIdentifier, String projectName) Load a TORG document by company and project name.loadByProjectId(String projectId) Load a TORG document by project identifier.private voidloadData()Load and parse the CSV file.private voidloadMasterFormat(BufferedReader reader, Map<String, Integer> headerIndex) Load master format where each row is a complete TORG (less common).private voidloadStandardsFormat(BufferedReader reader, Map<String, Integer> headerIndex) Load standards-focused CSV format where each row is a standard assignment.private String[]parseCSVLine(String line) private doubleparseDouble(String value, double defaultValue) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface TorgDataSource
hasProject, isWritable, store, update
-
Field Details
-
logger
private static final org.apache.logging.log4j.Logger logger -
COL_PROJECT_ID
-
COL_PROJECT_NAME
- See Also:
-
COL_COMPANY
- See Also:
-
COL_REVISION
- See Also:
-
COL_ISSUE_DATE
- See Also:
-
COL_DESIGN_CATEGORY
- See Also:
-
COL_STANDARD_CODE
- See Also:
-
COL_VERSION
- See Also:
-
COL_MIN_AMBIENT_TEMP
- See Also:
-
COL_MAX_AMBIENT_TEMP
- See Also:
-
COL_SEAWATER_TEMP
- See Also:
-
COL_SEISMIC_ZONE
- See Also:
-
COL_CORROSION_ALLOWANCE
- See Also:
-
COL_PRESSURE_SF
- See Also:
-
COL_PLATE_MATERIAL
- See Also:
-
COL_PIPE_MATERIAL
- See Also:
-
csvPath
-
cache
-
isLoaded
private boolean isLoaded
-
-
Constructor Details
-
CsvTorgDataSource
Create a CsvTorgDataSource from a file path.- Parameters:
csvPath- path to the CSV file
-
-
Method Details
-
fromResource
Create a CsvTorgDataSource from a classpath resource.- Parameters:
resourcePath- path relative to classpath (e.g., "designdata/torg/projects.csv")- Returns:
- new data source instance
-
getReader
Get a BufferedReader for the CSV data.- Returns:
- reader for CSV content
- Throws:
IOException- if the file cannot be read
-
loadData
private void loadData()Load and parse the CSV file. -
loadStandardsFormat
private void loadStandardsFormat(BufferedReader reader, Map<String, Integer> headerIndex) throws IOExceptionLoad standards-focused CSV format where each row is a standard assignment.- Throws:
IOException
-
loadMasterFormat
private void loadMasterFormat(BufferedReader reader, Map<String, Integer> headerIndex) throws IOExceptionLoad master format where each row is a complete TORG (less common).- Throws:
IOException
-
loadByProjectId
Description copied from interface:TorgDataSourceLoad a TORG document by project identifier.- Specified by:
loadByProjectIdin interfaceTorgDataSource- Parameters:
projectId- the project identifier- Returns:
- optional containing the TORG if found
-
loadByCompanyAndProject
public Optional<TechnicalRequirementsDocument> loadByCompanyAndProject(String companyIdentifier, String projectName) Description copied from interface:TorgDataSourceLoad a TORG document by company and project name.- Specified by:
loadByCompanyAndProjectin interfaceTorgDataSource- Parameters:
companyIdentifier- the company identifierprojectName- the project name- Returns:
- optional containing the TORG if found
-
getAvailableProjectIds
Description copied from interface:TorgDataSourceGet a list of available project identifiers.- Specified by:
getAvailableProjectIdsin interfaceTorgDataSource- Returns:
- list of project IDs available in this data source
-
getAvailableCompanies
Description copied from interface:TorgDataSourceGet a list of available companies.- Specified by:
getAvailableCompaniesin interfaceTorgDataSource- Returns:
- list of company identifiers
-
parseCSVLine
-
getField
-
getFieldOrDefault
-
parseDouble
-