bda-datastore/src/main/java/gr/ntua/ece/cslab/selis/bda/datastore/connectors/DatastorePostgresqlConnector.java
public String put(Message row) throws Exception {
        /*try {
            DatabaseMetaData dbm = connection.getMetaData();
            ResultSet rs = dbm.getTables(null, null, "Events", null);
            if (rs.next()) {
                // Table exists
                List<KeyValue> columns = describe("").getSchema().getColumnTypes();
                String values = "";
                String insertTableSQL = "INSERT INTO Events (";
                for (KeyValue element : row.getEntries()) {
                    insertTableSQL += element.getKey() + ",";
                    values += "?,";
                }
                insertTableSQL = insertTableSQL.substring(0, insertTableSQL.length() - 1) + ") VALUES (" + values.substring(0, values.length() - 1) + ");";

                PreparedStatement prepst = connection.prepareStatement(insertTableSQL);
                int i = 1;
                for (KeyValue field : row.getEntries()){
                    for (KeyValue value : columns) {
                        if (value.getKey().equals(field.getKey())) {
                            if (value.getValue().contains("integer"))
                                prepst.setInt(i, Integer.valueOf(field.getValue()));
                            else if (value.getValue().contains("timestamp"))
                                prepst.setTimestamp(i, Timestamp.valueOf(field.getValue()));
                            else if (value.getValue().contains("bytea"))
                                prepst.setBytes(i, field.getValue().getBytes());
                            else if (value.getValue().contains("boolean"))
                                prepst.setBoolean(i, Boolean.parseBoolean(field.getValue()));
                            else
                                prepst.setString(i, field.getValue());
                        }
                    }
                    i++;
                }
                prepst.executeUpdate();
            }
            else {
                // Table does not exist
                Statement st = connection.createStatement();
                String q="CREATE TABLE Events (";
                for (KeyValue fields : row.getEntries()){
                    q += fields.getKey()+" "+fields.getValue()+",";
                }
                // add one more column named 'message' that will contain the blob
                q=q.substring(0, q.length() - 1)+");";
                LOGGER.log(Level.INFO, q);
                st.executeUpdate(q);
                st.executeUpdate("ALTER TABLE Events OWNER TO "+ this.user+";");
            }
            connection.commit();
            rs.close();
        } catch (SQLException e) {
            e.printStackTrace();
            connection.rollback();
        }*/
        throw new java.lang.UnsupportedOperationException("Creating EventLog in Postgres is not supported.");
    }
// Used to initialize or append a message in the EventLog
Used to initialize or append a message in the EventLog
Used to initialize or append a message in the EventLog
public String put(Message row) throws Exception {
        /*try {
            DatabaseMetaData dbm = connection.getMetaData();
            ResultSet rs = dbm.getTables(null, null, "Events", null);
            if (rs.next()) {
                // Table exists
                List<KeyValue> columns = describe("").getSchema().getColumnTypes();
                String values = "";
                String insertTableSQL = "INSERT INTO Events (";
                for (KeyValue element : row.getEntries()) {
                    insertTableSQL += element.getKey() + ",";
                    values += "?,";
                }
                insertTableSQL = insertTableSQL.substring(0, insertTableSQL.length() - 1) + ") VALUES (" + values.substring(0, values.length() - 1) + ");";
                PreparedStatement prepst = connection.prepareStatement(insertTableSQL);
                int i = 1;
                for (KeyValue field : row.getEntries()){
                    for (KeyValue value : columns) {
                        if (value.getKey().equals(field.getKey())) {
                            if (value.getValue().contains("integer"))
                                prepst.setInt(i, Integer.valueOf(field.getValue()));
                            else if (value.getValue().contains("timestamp"))
                                prepst.setTimestamp(i, Timestamp.valueOf(field.getValue()));
                            else if (value.getValue().contains("bytea"))
                                prepst.setBytes(i, field.getValue().getBytes());
                            else if (value.getValue().contains("boolean"))
                                prepst.setBoolean(i, Boolean.parseBoolean(field.getValue()));
                            else
                                prepst.setString(i, field.getValue());
                        }
                    }
                    i++;
                }
                prepst.executeUpdate();
            }
            else {
                // Table does not exist
                Statement st = connection.createStatement();
                String q="CREATE TABLE Events (";
                for (KeyValue fields : row.getEntries()){
                    q += fields.getKey()+" "+fields.getValue()+",";
                }
                // add one more column named 'message' that will contain the blob
                q=q.substring(0, q.length() - 1)+");";
                LOGGER.log(Level.INFO, q);
                st.executeUpdate(q);
                st.executeUpdate("ALTER TABLE Events OWNER TO "+ this.user+";");
            }
            connection.commit();
            rs.close();
        } catch (SQLException e) {
            e.printStackTrace();
            connection.rollback();
        }*/
        throw new java.lang.UnsupportedOperationException("Creating EventLog in Postgres is not supported.");
    }
public String put ( Message row ) throws Exception { /*try {
            DatabaseMetaData dbm = connection.getMetaData();
            ResultSet rs = dbm.getTables(null, null, "Events", null);
            if (rs.next()) {
                // Table exists
                List<KeyValue> columns = describe("").getSchema().getColumnTypes();
                String values = "";
                String insertTableSQL = "INSERT INTO Events (";
                for (KeyValue element : row.getEntries()) {
                    insertTableSQL += element.getKey() + ",";
                    values += "?,";
                }
                insertTableSQL = insertTableSQL.substring(0, insertTableSQL.length() - 1) + ") VALUES (" + values.substring(0, values.length() - 1) + ");";

                PreparedStatement prepst = connection.prepareStatement(insertTableSQL);
                int i = 1;
                for (KeyValue field : row.getEntries()){
                    for (KeyValue value : columns) {
                        if (value.getKey().equals(field.getKey())) {
                            if (value.getValue().contains("integer"))
                                prepst.setInt(i, Integer.valueOf(field.getValue()));
                            else if (value.getValue().contains("timestamp"))
                                prepst.setTimestamp(i, Timestamp.valueOf(field.getValue()));
                            else if (value.getValue().contains("bytea"))
                                prepst.setBytes(i, field.getValue().getBytes());
                            else if (value.getValue().contains("boolean"))
                                prepst.setBoolean(i, Boolean.parseBoolean(field.getValue()));
                            else
                                prepst.setString(i, field.getValue());
                        }
                    }
                    i++;
                }
                prepst.executeUpdate();
            }
            else {
                // Table does not exist
                Statement st = connection.createStatement();
                String q="CREATE TABLE Events (";
                for (KeyValue fields : row.getEntries()){
                    q += fields.getKey()+" "+fields.getValue()+",";
                }
                // add one more column named 'message' that will contain the blob
                q=q.substring(0, q.length() - 1)+");";
                LOGGER.log(Level.INFO, q);
                st.executeUpdate(q);
                st.executeUpdate("ALTER TABLE Events OWNER TO "+ this.user+";");
            }
            connection.commit();
            rs.close();
        } catch (SQLException e) {
            e.printStackTrace();
            connection.rollback();
        }*/ throw new java . lang . UnsupportedOperationException ( "Creating EventLog in Postgres is not supported." ) ; }
Used to initialize or append a message in the EventLog
Used to initialize or append a message in the EventLog