Class StandardBasedCsvDataSource

java.lang.Object
neqsim.process.mechanicaldesign.data.StandardBasedCsvDataSource
All Implemented Interfaces:
MechanicalDesignDataSource

public class StandardBasedCsvDataSource extends Object implements 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
  • Field Details

    • logger

      private static final org.apache.logging.log4j.Logger logger
    • csvPath

      private final Path csvPath
    • resourcePath

      private final String resourcePath
    • isResource

      private final boolean isResource
    • cachedData

    • isStandardFormat

      private boolean isStandardFormat
  • Constructor Details

    • StandardBasedCsvDataSource

      public StandardBasedCsvDataSource(Path csvPath)
      Create a data source from a file path.
      Parameters:
      csvPath - path to the CSV file
    • StandardBasedCsvDataSource

      public StandardBasedCsvDataSource(String resourcePath)
      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: MechanicalDesignDataSource
      Retrieve design limit data for a given equipment type and company identifier.
      Specified by:
      getDesignLimits in interface MechanicalDesignDataSource
      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: MechanicalDesignDataSource
      Retrieve 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:
      getDesignLimitsByStandard in interface MechanicalDesignDataSource
      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 default
      equipmentTypeName - canonical equipment type identifier
      Returns:
      optional design limit data if available
    • getAvailableStandards

      public List<String> getAvailableStandards(String equipmentTypeName)
      Description copied from interface: MechanicalDesignDataSource
      Get a list of available standards in this data source.
      Specified by:
      getAvailableStandards in interface MechanicalDesignDataSource
      Parameters:
      equipmentTypeName - the equipment type to filter by (null for all)
      Returns:
      list of standard codes available
    • getAvailableVersions

      public List<String> getAvailableVersions(String standardCode)
      Description copied from interface: MechanicalDesignDataSource
      Get a list of available versions for a given standard.
      Specified by:
      getAvailableVersions in interface MechanicalDesignDataSource
      Parameters:
      standardCode - the standard code to query
      Returns:
      list of available versions
    • getSpecificationValues

      public Map<String,double[]> getSpecificationValues(String standardCode, String version, String equipmentTypeName)
      Get all specification values for a given standard, version, and equipment type.

      Returns a map from specification name to a two-element double array where index 0 is MINVALUE and index 1 is MAXVALUE. This allows access to arbitrary specification names beyond the fixed fields in DesignLimitData.

      Parameters:
      standardCode - the standard code (e.g., "NORSOK-D-010")
      version - the standard version (e.g., "Rev 5"), or null for any version
      equipmentTypeName - the equipment type (e.g., "SubseaWell")
      Returns:
      map of specification name to [minValue, maxValue] arrays
    • findByCompany

      private Optional<DesignLimitData> findByCompany(String equipmentTypeName, String companyIdentifier)
    • 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

      private BufferedReader openReader() throws IOException
      Throws:
      IOException
    • parseCsvLine

      private String[] parseCsvLine(String line)
    • parseRow

    • getString

      private String getString(String[] tokens, int index)
    • getDouble

      private double getDouble(String[] tokens, int index)
    • normalize

      private String normalize(String value)