INSM-TUM-Teaching / SimuBridge-OLCA

Team work from Anoa group
MIT License
0 stars 0 forks source link

API request for UI of getting cost drivers from oLCA #25

Closed alexey192 closed 9 months ago

alexey192 commented 9 months ago

Currently we are getting an error from API. { "jsonrpc": "2.0", "error": { "code": 500, "message": "Error while loading all ProductSystem" }, "id": 1 }

From OpenLCA log: ERROR org.openlca.core.database.ProductSystemDao Error while loading ProductSystem with id 6816475 Exception: Internal Exception: java.sql.SQLException: The conglomerate (2,000) requested does not exist. Error Code: 30000 Call: SELECT id, resulting_amount_value, base_uncertainty, cost_formula, cost_value, f_default_provider, description, dq_entry, resulting_amount_formula, internal_id, avoided_product, is_input, distribution_type, parameter1_value, parameter2_value, parameter3_value, f_currency, f_flow, f_flow_property_factor, f_location, f_unit FROM tbl_exchanges WHERE (id = ?) bind => [1 parameter bound] Query: ReadObjectQuery(name="referenceExchange" referenceClass=Exchange )

alexey192 commented 9 months ago

const handleButtonClick = () => { // Make an API call using fetch let resp = fetch(apiUrl, { method: "POST", body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "data/get/all", params: { "@type": "ProductSystem" } }) .then((response) => { if (!response.ok) { throw new Error(HTTP error! Status: ${response.status}); } return response.json(); }) .then((data) => { console.log('API Response:', data); // Handle the response as needed }) .catch((error) => { console.error('API Error:', error); // Handle errors as needed }) }); }

fyndalf commented 9 months ago

So, I've been looking into the openLCA database, and it seems that the problem does indeed come from a corrupted database. Have you tried running your code on a different machine? Does it lead to the same error? Otherwise, ProductSystem 6816475 corresponds to the Product System Shipment_A_Lorry. What happens when you make a copy and delete the original?

alexey192 commented 9 months ago

I cannot reproduce on another teammate laptop. Trying to reinstall my local DB

alexey192 commented 9 months ago

Cleaning oLCA and re-importing dataset helped, thanks @fyndalf