Skip to content

Commit f61a7be

Browse files
committed
updates
1 parent 265975d commit f61a7be

File tree

3 files changed

+86
-93
lines changed

3 files changed

+86
-93
lines changed

Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ sha3 = "0.10.6"
4343
syn = "2.0.15"
4444
tungstenite = { version = "0.21.0", features = ["rustls"] }
4545
url = "2.4.1"
46-
rusqlite = { version = "0.31.0", features = ["bundled", "blob", "functions"] }
4746
zip = "0.6.6"
4847

4948
[workspace.package]

rust-orchestration/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,3 @@ tungstenite.workspace = true
2222
url.workspace = true
2323
derive_builder.workspace = true
2424
base64.workspace = true
25-
rusqlite.workspace = true

rust-orchestration/src/identification.rs

+86-91
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
use std::{
2-
net::TcpStream,
3-
sync::Arc,
4-
};
1+
use std::{net::TcpStream, sync::Arc};
52

63
use idesyde_core::{
7-
merge_identification_results, DecisionModel, DesignModel,
8-
IdentificationResult, IdentificationRuleLike, Module, OpaqueDecisionModel, OpaqueDesignModel,
4+
merge_identification_results, DecisionModel, DesignModel, IdentificationResult,
5+
IdentificationRuleLike, Module, OpaqueDecisionModel, OpaqueDesignModel,
96
};
107

118
use log::debug;
12-
use rusqlite::params;
139
use tungstenite::WebSocket;
1410

1511
use rayon::prelude::*;
@@ -131,7 +127,6 @@ impl Iterator for ExternalServerIdentifiticationIterator {
131127
}
132128
}
133129

134-
135130
impl Drop for ExternalServerIdentifiticationIterator {
136131
fn drop(&mut self) {
137132
if self.websocket.can_write() {
@@ -202,91 +197,91 @@ pub fn identification_procedure(
202197
(identified, messages)
203198
}
204199

205-
pub fn get_sqlite_for_identification(url: &str) -> Result<rusqlite::Connection, rusqlite::Error> {
206-
let conn = rusqlite::Connection::open(url)?;
207-
conn.execute(
208-
"CREATE TABLE IF NOT EXISTS decision_models (
209-
id INTEGER PRIMARY KEY,
210-
category TEXT NOT NULL,
211-
body_cbor BLOB,
212-
body_msgpack BLOB,
213-
body_json JSON NOT NULL,
214-
UNIQUE (category, body_json)
215-
)",
216-
[],
217-
)?;
218-
conn.execute(
219-
"CREATE TABLE IF NOT EXISTS design_models (
220-
id INTEGER PRIMARY KEY,
221-
category TEXT NOT NULL,
222-
format TEXT NOT NULL,
223-
body TEXT NOT NULL,
224-
UNIQUE (format, category, body)
225-
)",
226-
[],
227-
)?;
228-
conn.execute(
229-
"CREATE TABLE IF NOT EXISTS part (
230-
decision_model_id INTEGER NOT NULL,
231-
element_name TEXT NOT NULL,
232-
FOREIGN KEY (decision_model_id) REFERENCES decision_models (id),
233-
UNIQUE (decision_model_id, element_name)
234-
)",
235-
[],
236-
)?;
237-
conn.execute(
238-
"CREATE TABLE IF NOT EXISTS elems (
239-
design_model_id INTEGER NOT NULL,
240-
element_name TEXT NOT NULL,
241-
FOREIGN KEY (design_model_id) REFERENCES decision_models (id),
242-
UNIQUE (design_model_id, element_name)
243-
)",
244-
[],
245-
)?;
246-
Ok(conn)
247-
}
200+
// pub fn get_sqlite_for_identification(url: &str) -> Result<rusqlite::Connection, rusqlite::Error> {
201+
// let conn = rusqlite::Connection::open(url)?;
202+
// conn.execute(
203+
// "CREATE TABLE IF NOT EXISTS decision_models (
204+
// id INTEGER PRIMARY KEY,
205+
// category TEXT NOT NULL,
206+
// body_cbor BLOB,
207+
// body_msgpack BLOB,
208+
// body_json JSON NOT NULL,
209+
// UNIQUE (category, body_json)
210+
// )",
211+
// [],
212+
// )?;
213+
// conn.execute(
214+
// "CREATE TABLE IF NOT EXISTS design_models (
215+
// id INTEGER PRIMARY KEY,
216+
// category TEXT NOT NULL,
217+
// format TEXT NOT NULL,
218+
// body TEXT NOT NULL,
219+
// UNIQUE (format, category, body)
220+
// )",
221+
// [],
222+
// )?;
223+
// conn.execute(
224+
// "CREATE TABLE IF NOT EXISTS part (
225+
// decision_model_id INTEGER NOT NULL,
226+
// element_name TEXT NOT NULL,
227+
// FOREIGN KEY (decision_model_id) REFERENCES decision_models (id),
228+
// UNIQUE (decision_model_id, element_name)
229+
// )",
230+
// [],
231+
// )?;
232+
// conn.execute(
233+
// "CREATE TABLE IF NOT EXISTS elems (
234+
// design_model_id INTEGER NOT NULL,
235+
// element_name TEXT NOT NULL,
236+
// FOREIGN KEY (design_model_id) REFERENCES decision_models (id),
237+
// UNIQUE (design_model_id, element_name)
238+
// )",
239+
// [],
240+
// )?;
241+
// Ok(conn)
242+
// }
248243

249-
pub fn save_decision_model_sqlite<T: DecisionModel + ?Sized>(
250-
url: &str,
251-
decision_model: &T,
252-
) -> Result<usize, rusqlite::Error> {
253-
let conn = get_sqlite_for_identification(url)?;
254-
let id = conn.execute(
255-
"INSERT INTO decision_models (category, body_cbor, body_msgpack, body_json) VALUES (?1, ?2, ?3, ?4)", params![
256-
decision_model.category(),
257-
decision_model.body_as_cbor(),
258-
decision_model.body_as_msgpack(),
259-
decision_model.body_as_json()
260-
]
261-
)?;
262-
let mut stmt =
263-
conn.prepare("INSERT INTO part (decision_model_id, element_name) VALUES (?1, ?2)")?;
264-
for elem in decision_model.part() {
265-
stmt.execute(params![id, elem])?;
266-
}
267-
Ok(id)
268-
}
244+
// pub fn save_decision_model_sqlite<T: DecisionModel + ?Sized>(
245+
// url: &str,
246+
// decision_model: &T,
247+
// ) -> Result<usize, rusqlite::Error> {
248+
// let conn = get_sqlite_for_identification(url)?;
249+
// let id = conn.execute(
250+
// "INSERT INTO decision_models (category, body_cbor, body_msgpack, body_json) VALUES (?1, ?2, ?3, ?4)", params![
251+
// decision_model.category(),
252+
// decision_model.body_as_cbor(),
253+
// decision_model.body_as_msgpack(),
254+
// decision_model.body_as_json()
255+
// ]
256+
// )?;
257+
// let mut stmt =
258+
// conn.prepare("INSERT INTO part (decision_model_id, element_name) VALUES (?1, ?2)")?;
259+
// for elem in decision_model.part() {
260+
// stmt.execute(params![id, elem])?;
261+
// }
262+
// Ok(id)
263+
// }
269264

270-
pub fn save_design_model_sqlite<T: DesignModel + ?Sized>(
271-
url: &str,
272-
design_model: &T,
273-
) -> Result<usize, rusqlite::Error> {
274-
let conn = get_sqlite_for_identification(url)?;
275-
let id = conn.execute(
276-
"INSERT INTO design_models (category, format, body) VALUES (?1, ?2, ?3)",
277-
params![
278-
design_model.category(),
279-
design_model.format(),
280-
design_model.body_as_string()
281-
],
282-
)?;
283-
let mut stmt =
284-
conn.prepare("INSERT INTO elems (design_model_id, element_name) VALUES (?1, ?2)")?;
285-
for elem in design_model.elements() {
286-
stmt.execute(params![id, elem])?;
287-
}
288-
Ok(id)
289-
}
265+
// pub fn save_design_model_sqlite<T: DesignModel + ?Sized>(
266+
// url: &str,
267+
// design_model: &T,
268+
// ) -> Result<usize, rusqlite::Error> {
269+
// let conn = get_sqlite_for_identification(url)?;
270+
// let id = conn.execute(
271+
// "INSERT INTO design_models (category, format, body) VALUES (?1, ?2, ?3)",
272+
// params![
273+
// design_model.category(),
274+
// design_model.format(),
275+
// design_model.body_as_string()
276+
// ],
277+
// )?;
278+
// let mut stmt =
279+
// conn.prepare("INSERT INTO elems (design_model_id, element_name) VALUES (?1, ?2)")?;
280+
// for elem in design_model.elements() {
281+
// stmt.execute(params![id, elem])?;
282+
// }
283+
// Ok(id)
284+
// }
290285

291286
// #[derive(Debug, PartialEq, Eq, Hash)]
292287
// pub struct ExternalIdentificationModule {

0 commit comments

Comments
 (0)