Cleanup backend and frontend (#67)
* remove 'flavor' associations from backend
* remove flavor from database slice
* remove 'flavor' from frontend
* removed 'flavor' implementation from frontend
* remove 'flavor' property from proptypes
diff --git a/backend/sql/get_graph_names/AGE.sql b/backend/sql/get_graph_names.sql
similarity index 100%
rename from backend/sql/get_graph_names/AGE.sql
rename to backend/sql/get_graph_names.sql
diff --git a/backend/sql/get_role/default.sql b/backend/sql/get_role.sql
similarity index 100%
rename from backend/sql/get_role/default.sql
rename to backend/sql/get_role.sql
diff --git a/backend/sql/graph_labels/AGE.sql b/backend/sql/graph_labels.sql
similarity index 100%
rename from backend/sql/graph_labels/AGE.sql
rename to backend/sql/graph_labels.sql
diff --git a/backend/sql/meta_data/AGE.sql b/backend/sql/meta_data.sql
similarity index 100%
rename from backend/sql/meta_data/AGE.sql
rename to backend/sql/meta_data.sql
diff --git a/backend/sql/meta_edges/AGE.sql b/backend/sql/meta_edges.sql
similarity index 100%
rename from backend/sql/meta_edges/AGE.sql
rename to backend/sql/meta_edges.sql
diff --git a/backend/sql/meta_nodes/AGE.sql b/backend/sql/meta_nodes.sql
similarity index 100%
rename from backend/sql/meta_nodes/AGE.sql
rename to backend/sql/meta_nodes.sql
diff --git a/backend/sql/property_keys/AGE.sql b/backend/sql/property_keys.sql
similarity index 100%
rename from backend/sql/property_keys/AGE.sql
rename to backend/sql/property_keys.sql
diff --git a/backend/src/models/GraphRepository.js b/backend/src/models/GraphRepository.js
index bd75b4c..27b02c3 100644
--- a/backend/src/models/GraphRepository.js
+++ b/backend/src/models/GraphRepository.js
@@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-import Flavors from '../config/Flavors';
import PgConfig from '../config/Pg'
import pg from 'pg';
@@ -26,11 +25,7 @@
class GraphRepository {
- constructor({host, port, database, graph, user, password, flavor, graphs=[]} = {}) {
- if (!flavor) {
- throw new Error('Flavor is required.');
- }
-
+ constructor({host, port, database, graph, user, password, graphs=[]} = {}) {
this._host = host;
this._port = port;
this._database = database;
@@ -38,7 +33,6 @@
this._graph = graph;
this._user = user;
this._password = password;
- this.flavor = flavor;
}
static async getConnection({
@@ -47,7 +41,6 @@
database,
user,
password,
- flavor
} = {},
closeConnection = true) {
const client = new pg.Client({
@@ -59,12 +52,7 @@
}
)
client.connect();
- if (flavor === Flavors.AGE) {
- await setAGETypes(client, types);
- } else {
- throw new Error(`Unknown flavor ${flavor}`)
- }
-
+ await setAGETypes(client, types);
if (closeConnection === true) {
await client.end();
}
@@ -90,7 +78,7 @@
}
async initGraphNames(){
- const { rows } = await this.execute(getQuery(this.flavor, 'get_graph_names'));
+ const { rows } = await this.execute(getQuery('get_graph_names'));
this._graphs = rows.map((item)=>item.name);
// set current graph to first name
this.setCurrentGraph(this._graphs[0]);
@@ -156,7 +144,6 @@
password: this._password,
graphs: this._graphs,
graph: this._graph,
- flavor: this.flavor,
};
}
diff --git a/backend/src/services/databaseService.js b/backend/src/services/databaseService.js
index e8160b5..3730554 100644
--- a/backend/src/services/databaseService.js
+++ b/backend/src/services/databaseService.js
@@ -72,7 +72,7 @@
let graphRepository = this._graphRepository;
let queryResult = {};
try {
- queryResult = await graphRepository.execute(getQuery(graphRepository.flavor, 'graph_labels'), [this.getConnectionInfo().graph]);
+ queryResult = await graphRepository.execute(getQuery('graph_labels'), [this.getConnectionInfo().graph]);
} catch (error) {
throw error;
}
@@ -85,9 +85,9 @@
let query = null;
if (labelKind === 'v') {
- query = util.format(getQuery(graphRepository.flavor, 'label_count_vertex'), `${this.getConnectionInfo().graph}.${labelName}`);
+ query = util.format(getQuery('label_count_vertex'), `${this.getConnectionInfo().graph}.${labelName}`);
} else if (labelKind === 'e') {
- query = util.format(getQuery(graphRepository.flavor, 'label_count_edge'), `${this.getConnectionInfo().graph}.${labelName}`);
+ query = util.format(getQuery('label_count_edge'), `${this.getConnectionInfo().graph}.${labelName}`);
}
let queryResult = await graphRepository.execute(query);
@@ -97,31 +97,19 @@
async readMetaData(graphName){
let gr = this._graphRepository;
- let queryResult = await gr.execute(util.format(getQuery(gr.flavor, 'meta_data'), graphName));
+ let queryResult = await gr.execute(util.format(getQuery('meta_data'), graphName));
return this.parseMeta(queryResult[1].rows);
}
- /*
- async getNodes() {
- let graphRepository = this._graphRepository;
- let queryResult = await graphRepository.execute(util.format(getQuery(graphRepository.flavor, 'meta_nodes'), graphRepository._graph, graphRepository._graph));
- return queryResult.rows;
- }
- async getEdges() {
- let graphRepository = this._graphRepository;
- let queryResult = await graphRepository.execute(util.format(getQuery(graphRepository.flavor, 'meta_edges'), graphRepository._graph, graphRepository._graph));
- return queryResult.rows;
- }
- */
async getPropertyKeys() {
let graphRepository = this._graphRepository;
- let queryResult = await graphRepository.execute(getQuery(graphRepository.flavor, 'property_keys'));
+ let queryResult = await graphRepository.execute(getQuery('property_keys'));
return queryResult.rows;
}
async getRole() {
let graphRepository = this._graphRepository;
- let queryResult = await graphRepository.execute(getQuery(graphRepository.flavor, 'get_role'), [this.getConnectionInfo().user]);
+ let queryResult = await graphRepository.execute(getQuery('get_role'), [this.getConnectionInfo().user]);
return queryResult.rows[0];
}
diff --git a/backend/src/tools/SQLFlavorManager.js b/backend/src/tools/SQLFlavorManager.js
index d238bf6..bf04d8a 100644
--- a/backend/src/tools/SQLFlavorManager.js
+++ b/backend/src/tools/SQLFlavorManager.js
@@ -18,19 +18,14 @@
*/
import * as path from "path";
import fs from 'fs'
-import Flavors from "../config/Flavors";
const sqlBasePath = path.join(__dirname, '../../sql');
// todo: util.format -> ejs
-function getQuery(flavor = Flavors.AGE, name) {
- const defaultSqlPath = path.join(sqlBasePath, `./${name}/default.sql`);
- let sqlPath = path.join(sqlBasePath, `./${name}/${flavor}.sql`);
- if (fs.existsSync(defaultSqlPath)) {
- sqlPath = defaultSqlPath;
- }
+function getQuery(name) {
+ const sqlPath = path.join(sqlBasePath, `${name}.sql`);
if (!fs.existsSync(sqlPath)) {
- throw new Error(`SQL is not exist, name = ${name}`);
+ throw new Error(`SQL does not exist, name = ${name}`);
}
return fs.readFileSync(sqlPath, 'utf8');
}
diff --git a/frontend/src/components/cypherresult/containers/CypherResultCytoscapeContainer.js b/frontend/src/components/cypherresult/containers/CypherResultCytoscapeContainer.js
index b2211d1..157e118 100644
--- a/frontend/src/components/cypherresult/containers/CypherResultCytoscapeContainer.js
+++ b/frontend/src/components/cypherresult/containers/CypherResultCytoscapeContainer.js
@@ -50,7 +50,6 @@
maxDataOfGraph: state.setting.maxDataOfGraph,
maxDataOfTable: state.setting.maxDataOfTable,
setChartLegend: ownProps.setChartLegend,
- flavor: state.database.flavor,
graph: state.database.graph,
};
};
diff --git a/frontend/src/components/cypherresult/presentations/CypherResultCytoscape.jsx b/frontend/src/components/cypherresult/presentations/CypherResultCytoscape.jsx
index ad63e52..7799276 100644
--- a/frontend/src/components/cypherresult/presentations/CypherResultCytoscape.jsx
+++ b/frontend/src/components/cypherresult/presentations/CypherResultCytoscape.jsx
@@ -379,7 +379,6 @@
cytoscapeLayout={cytoscapeLayout}
addLegendData={addLegendData}
maxDataOfGraph={maxDataOfGraph}
- flavor={props.flavor}
graph={props.graph}
/>
<CypherResultCytoscapeFooter
@@ -421,7 +420,6 @@
setLabels: PropTypes.func.isRequired,
refKey: PropTypes.string.isRequired,
setChartLegend: PropTypes.func.isRequired,
- flavor: PropTypes.string.isRequired,
graph: PropTypes.string.isRequired,
};
diff --git a/frontend/src/components/frame/presentations/ServerConnectFrame.jsx b/frontend/src/components/frame/presentations/ServerConnectFrame.jsx
index 08c8a83..c177b54 100644
--- a/frontend/src/components/frame/presentations/ServerConnectFrame.jsx
+++ b/frontend/src/components/frame/presentations/ServerConnectFrame.jsx
@@ -20,7 +20,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import {
- Button, Col, Form, Input, InputNumber, Row, Select,
+ Button, Col, Form, Input, InputNumber, Row,
} from 'antd';
import { useDispatch } from 'react-redux';
import Frame from '../Frame';
@@ -33,7 +33,6 @@
const FormInitialValue = {
database: '',
- flavor: null,
graph: '',
host: '',
password: '',
@@ -86,14 +85,6 @@
layout="vertical"
onFinish={connectToDatabase}
>
- <Form.Item name="flavor" label="Database Type" rules={[{ required: true }]}>
- <Select
- placeholder="Select a flavor of Database"
- allowClear
- >
- <Select.Option value="AGE">Apache AGE</Select.Option>
- </Select>
- </Form.Item>
<Form.Item name="host" label="Connect URL" rules={[{ required: true }]}>
<Input placeholder="192.168.0.1" />
</Form.Item>
diff --git a/frontend/src/components/sidebar/presentations/SidebarHome.jsx b/frontend/src/components/sidebar/presentations/SidebarHome.jsx
index 5acd6bf..e24025a 100644
--- a/frontend/src/components/sidebar/presentations/SidebarHome.jsx
+++ b/frontend/src/components/sidebar/presentations/SidebarHome.jsx
@@ -30,36 +30,31 @@
} from './SidebarComponents';
const genLabelQuery = (eleType, labelName, database) => {
- function age() {
- if (eleType === 'node') {
- if (labelName === '*') {
- return `SELECT * from cypher('${database.graph}', $$
- MATCH (V)
- RETURN V
-$$) as (V agtype);`;
- }
+ if (eleType === 'node') {
+ if (labelName === '*') {
return `SELECT * from cypher('${database.graph}', $$
- MATCH (V:${labelName})
- RETURN V
+ MATCH (V)
+ RETURN V
$$) as (V agtype);`;
}
- if (eleType === 'edge') {
- if (labelName === '*') {
- return `SELECT * from cypher('${database.graph}', $$
- MATCH (V)-[R]-(V2)
- RETURN V,R,V2
-$$) as (V agtype, R agtype, V2 agtype);`;
- }
+ return `SELECT * from cypher('${database.graph}', $$
+ MATCH (V:${labelName})
+ RETURN V
+$$) as (V agtype);`;
+ }
+ if (eleType === 'edge') {
+ if (labelName === '*') {
return `SELECT * from cypher('${database.graph}', $$
- MATCH (V)-[R:${labelName}]-(V2)
- RETURN V,R,V2
+ MATCH (V)-[R]-(V2)
+ RETURN V,R,V2
$$) as (V agtype, R agtype, V2 agtype);`;
}
- return '';
+ return `SELECT * from cypher('${database.graph}', $$
+ MATCH (V)-[R:${labelName}]-(V2)
+ RETURN V,R,V2
+$$) as (V agtype, R agtype, V2 agtype);`;
}
- if (database.flavor === 'AGE') {
- return age();
- }
+
return '';
};
@@ -128,7 +123,7 @@
);
NodeItems.propTypes = {
database: PropTypes.shape({
- flavor: PropTypes.string,
+ graph: PropTypes.string,
}).isRequired,
label: PropTypes.string.isRequired,
cnt: PropTypes.number.isRequired,
@@ -188,7 +183,7 @@
));
EdgeItems.propTypes = {
database: PropTypes.shape({
- flavor: PropTypes.string,
+ graph: PropTypes.string,
}).isRequired,
label: PropTypes.string.isRequired,
cnt: PropTypes.number.isRequired,
diff --git a/frontend/src/features/database/DatabaseSlice.js b/frontend/src/features/database/DatabaseSlice.js
index 7955100..053fd5c 100644
--- a/frontend/src/features/database/DatabaseSlice.js
+++ b/frontend/src/features/database/DatabaseSlice.js
@@ -91,7 +91,6 @@
password: action.payload.password,
database: action.payload.database,
graph: action.payload.graph,
- flavor: action.payload.flavor,
status: 'connected',
}),
[connectToDatabase.rejected]: () => ({
@@ -101,7 +100,6 @@
password: '',
database: '',
graph: '',
- flavor: '',
status: 'disconnected',
}),
[disconnectToDatabase.fulfilled]: () => ({
@@ -111,7 +109,6 @@
password: '',
database: '',
graph: '',
- flavor: '',
status: 'disconnected',
}),
[getConnectionStatus.fulfilled]: (state, action) => ({
@@ -121,7 +118,6 @@
password: action.payload.password,
database: action.payload.database,
graph: action.payload.graph,
- flavor: action.payload.flavor,
status: 'connected',
}),
[getConnectionStatus.rejected]: () => ({
@@ -131,7 +127,6 @@
password: '',
database: '',
graph: '',
- flavor: '',
status: 'disconnected',
}),
},