+ /**
+ * Load a tech type table from a CSV file and write it in the active model.
+ *
+ * @param componentType The component type that the tech type table is associated with
+ * @param filePath A path to a CSV file
+ * @throws DatabaseException
+ * @throws IOException
+ */
+ public static void loadTechTypeTable(Resource componentType, String filePath) throws DatabaseException, IOException {
+ String data;
+ try {
+ data = Files.lines(Paths.get(filePath), Charset.defaultCharset()).collect(Collectors.joining("\n"));
+ } catch (IOException e) {
+ LOGGER.error("Failed to read contents of file '{}' as {}", filePath, Charset.defaultCharset(), e);
+ return;
+ }
+
+ Simantics.getSession().syncRequest(new WriteRequest() {
+ @Override
+ public void perform(WriteGraph graph) throws DatabaseException {
+ graph.syncRequest(new WriteTechTypeTable(componentType, data));
+ }
+ });
+ }
+