Examples of CouchDbClient


Examples of com.impetus.client.couchdb.CouchDBClient

        joinTableData.addJoinTableRecord(joinKey, inverseJoinKeys);

        EntityManager em = emf.createEntityManager();
        Map<String, Client> clients = (Map<String, Client>) em.getDelegate();
        CouchDBClient client = (CouchDBClient) clients.get(_PU);
        client.persistJoinTable(joinTableData);

        List<String> columns = client.getColumnsById(schemaName, tableName, joinColumn, inverseJoinColumn, joinKey,
                String.class);

        Assert.assertNotNull(columns);
        Assert.assertEquals(true, !columns.isEmpty());
        Assert.assertEquals(2, columns.size());
        Assert.assertEquals(true, columns.contains(inverseJoinKey1.toString()));
        Assert.assertEquals(true, columns.contains(inverseJoinKey2.toString()));

        client.deleteByColumn(schemaName, tableName, inverseJoinColumn, inverseJoinKey1);
        client.deleteByColumn(schemaName, tableName, inverseJoinColumn, inverseJoinKey2);

        columns = client.getColumnsById(schemaName, tableName, joinColumn, inverseJoinColumn, joinKey, String.class);

        Assert.assertTrue(columns.isEmpty());
    }
View Full Code Here

Examples of com.impetus.client.couchdb.CouchDBClient

    public void testCRUD()
    {
        logger.info("On testInsert");
        EntityManager em = emf.createEntityManager();
        Map<String, Client> clients = (Map<String, Client>) em.getDelegate();
        CouchDBClient client = (CouchDBClient) clients.get(_PU);
        onInsert(client);
        onUpdate(client);
        onDelete(client);
        em.close();
    }
View Full Code Here

Examples of com.impetus.client.couchdb.CouchDBClient

        Map<String, String> batchProperty = new HashMap<String, String>(1);
        batchProperty.put(PersistenceProperties.KUNDERA_BATCH_SIZE, "5");
        EntityManagerFactory emf = Persistence.createEntityManagerFactory(_PU, batchProperty);
        EntityManager em = emf.createEntityManager();
        Map<String, Client> clients = (Map<String, Client>) em.getDelegate();
        CouchDBClient client = (CouchDBClient) clients.get(_PU);
        Assert.assertEquals(5, ((Batcher) client).getBatchSize());

        final String originalName = "vivek";

        for (int i = 0; i < 9; i++)
        {
            PersonCouchDB object = new PersonCouchDB();
            object.setAge(32);
            object.setPersonId(ROW_KEY + i);
            object.setPersonName(originalName);
            em.persist(object);

            if (i >= 5)
            {
                PersonCouchDB result = (PersonCouchDB) client.find(PersonCouchDB.class, ROW_KEY + i);
                Assert.assertNull(result);
            }
            else if (i > 0 && i % 4 == 0)
            {
                PersonCouchDB result = (PersonCouchDB) client.find(PersonCouchDB.class, ROW_KEY + i);
                Assert.assertNotNull(result);
                Assert.assertEquals(result.getPersonId(), object.getPersonId());
                Assert.assertEquals(result.getAge(), object.getAge());
                Assert.assertEquals(result.getPersonName(), object.getPersonName());
            }
View Full Code Here

Examples of org.geotools.data.couchdb.client.CouchDBClient

        return props;
    }

    @Override
    protected void connect() throws Exception {
        client = new CouchDBClient(getTestHost());
        client.getDatabaseNames(); // should fail unless configured correctly
    }
View Full Code Here

Examples of org.geotools.data.couchdb.client.CouchDBClient

    protected String TEST_DB_NAME = "gttestdb";
    protected Logger logger;

    @Before
    public void setUp() throws Exception {
        client = new CouchDBClient("http://127.0.0.1:5984/");
    }
View Full Code Here

Examples of org.geotools.data.couchdb.client.CouchDBClient

            Logger.getLogger(CouchDBDataStore.class.getName()).log(Level.WARNING, "Error closing client", ex);
        }
    }
   
    public void init() throws Exception {
        client = new CouchDBClient(couchURL);
        dbConn = client.openDBConnection(dbName);
    }
View Full Code Here

Examples of org.lightcouch.CouchDbClient

                                                      @PluginAttr("port") final String port,
                                                      @PluginAttr("username") final String username,
                                                      @PluginAttr("password") final String password,
                                                      @PluginAttr("factoryClassName") final String factoryClassName,
                                                      @PluginAttr("factoryMethodName") final String factoryMethodName) {
        CouchDbClient client;
        String description;
        if (factoryClassName != null && factoryClassName.length() > 0 &&
                factoryMethodName != null && factoryMethodName.length() > 0) {
            try {
                final Class<?> factoryClass = Class.forName(factoryClassName);
                final Method method = factoryClass.getMethod(factoryMethodName);
                final Object object = method.invoke(null);

                if (object instanceof CouchDbClient) {
                    client = (CouchDbClient) object;
                    description = "uri=" + client.getDBUri();
                } else if (object instanceof CouchDbProperties) {
                    final CouchDbProperties properties = (CouchDbProperties) object;
                    client = new CouchDbClient(properties);
                    description = "uri=" + client.getDBUri() + ", username=" + properties.getUsername()
                            + ", passwordHash=" + NameUtil.md5(password + CouchDBProvider.class.getName())
                            + ", maxConnections=" + properties.getMaxConnections() + ", connectionTimeout="
                            + properties.getConnectionTimeout() + ", socketTimeout=" + properties.getSocketTimeout();
                } else if (object == null) {
                    LOGGER.error("The factory method [{}.{}()] returned null.", factoryClassName, factoryMethodName);
                    return null;
                } else {
                    LOGGER.error("The factory method [{}.{}()] returned an unsupported type [{}].", factoryClassName,
                            factoryMethodName, object.getClass().getName());
                    return null;
                }
            } catch (final ClassNotFoundException e) {
                LOGGER.error("The factory class [{}] could not be loaded.", factoryClassName, e);
                return null;
            } catch (final NoSuchMethodException e) {
                LOGGER.error("The factory class [{}] does not have a no-arg method named [{}].", factoryClassName,
                        factoryMethodName, e);
                return null;
            } catch (final Exception e) {
                LOGGER.error("The factory method [{}.{}()] could not be invoked.", factoryClassName, factoryMethodName,
                        e);
                return null;
            }
        } else if (databaseName != null && databaseName.length() > 0) {
            if (protocol != null && protocol.length() > 0) {
                protocol = protocol.toLowerCase();
                if (!protocol.equals("http") && !protocol.equals("https")) {
                    LOGGER.error("Only protocols [http] and [https] are supported, [{}] specified.", protocol);
                    return null;
                }
            } else {
                protocol = "http";
                LOGGER.warn("No protocol specified, using default port [http].");
            }

            int portInt = protocol.equals("https") ? HTTPS : HTTP;
            if (port != null && port.length() > 0) {
                try {
                    portInt = Integer.parseInt(port);
                } catch (final NumberFormatException ignore) {
                    // we don't care
                }
            } else {
                LOGGER.warn("No port specified, using default port [{}] for protocol [{}].", portInt, protocol);
            }

            if (server == null || server.length() == 0) {
                server = "localhost";
                LOGGER.warn("No server specified, using default server localhost.");
            }

            if (username == null || username.length() == 0 || password == null || password.length() == 0) {
                LOGGER.error("You must provide a username and password for the CouchDB provider.");
                return null;
            }

            client = new CouchDbClient(databaseName, false, protocol, server, portInt, username, password);
            description = "uri=" + client.getDBUri() + ", username=" + username + ", passwordHash="
                    + NameUtil.md5(password + CouchDBProvider.class.getName());
        } else {
            LOGGER.error("No factory method was provided so the database name is required.");
            return null;
        }
View Full Code Here

Examples of org.lightcouch.CouchDbClient

            @PluginAttribute("port") final String port,
            @PluginAttribute("username") final String username,
            @PluginAttribute(value = "password", sensitive = true) final String password,
            @PluginAttribute("factoryClassName") final String factoryClassName,
            @PluginAttribute("factoryMethodName") final String factoryMethodName) {
        CouchDbClient client;
        String description;
        if (factoryClassName != null && factoryClassName.length() > 0 &&
                factoryMethodName != null && factoryMethodName.length() > 0) {
            try {
                final Class<?> factoryClass = Loader.loadClass(factoryClassName);
                final Method method = factoryClass.getMethod(factoryMethodName);
                final Object object = method.invoke(null);

                if (object instanceof CouchDbClient) {
                    client = (CouchDbClient) object;
                    description = "uri=" + client.getDBUri();
                } else if (object instanceof CouchDbProperties) {
                    final CouchDbProperties properties = (CouchDbProperties) object;
                    client = new CouchDbClient(properties);
                    description = "uri=" + client.getDBUri() + ", username=" + properties.getUsername()
                            + ", passwordHash=" + NameUtil.md5(password + CouchDBProvider.class.getName())
                            + ", maxConnections=" + properties.getMaxConnections() + ", connectionTimeout="
                            + properties.getConnectionTimeout() + ", socketTimeout=" + properties.getSocketTimeout();
                } else if (object == null) {
                    LOGGER.error("The factory method [{}.{}()] returned null.", factoryClassName, factoryMethodName);
                    return null;
                } else {
                    LOGGER.error("The factory method [{}.{}()] returned an unsupported type [{}].", factoryClassName,
                            factoryMethodName, object.getClass().getName());
                    return null;
                }
            } catch (final ClassNotFoundException e) {
                LOGGER.error("The factory class [{}] could not be loaded.", factoryClassName, e);
                return null;
            } catch (final NoSuchMethodException e) {
                LOGGER.error("The factory class [{}] does not have a no-arg method named [{}].", factoryClassName,
                        factoryMethodName, e);
                return null;
            } catch (final Exception e) {
                LOGGER.error("The factory method [{}.{}()] could not be invoked.", factoryClassName, factoryMethodName,
                        e);
                return null;
            }
        } else if (databaseName != null && databaseName.length() > 0) {
            if (protocol != null && protocol.length() > 0) {
                protocol = protocol.toLowerCase();
                if (!protocol.equals("http") && !protocol.equals("https")) {
                    LOGGER.error("Only protocols [http] and [https] are supported, [{}] specified.", protocol);
                    return null;
                }
            } else {
                protocol = "http";
                LOGGER.warn("No protocol specified, using default port [http].");
            }

            final int portInt = AbstractAppender.parseInt(port, protocol.equals("https") ? HTTPS : HTTP);

            if (Strings.isEmpty(server)) {
                server = "localhost";
                LOGGER.warn("No server specified, using default server localhost.");
            }

            if (Strings.isEmpty(username) || Strings.isEmpty(password)) {
                LOGGER.error("You must provide a username and password for the CouchDB provider.");
                return null;
            }

            client = new CouchDbClient(databaseName, false, protocol, server, portInt, username, password);
            description = "uri=" + client.getDBUri() + ", username=" + username + ", passwordHash="
                    + NameUtil.md5(password + CouchDBProvider.class.getName());
        } else {
            LOGGER.error("No factory method was provided so the database name is required.");
            return null;
        }
View Full Code Here

Examples of org.lightcouch.CouchDbClient

            @PluginAttribute("port") final String port,
            @PluginAttribute("username") final String username,
            @PluginAttribute("password") final String password,
            @PluginAttribute("factoryClassName") final String factoryClassName,
            @PluginAttribute("factoryMethodName") final String factoryMethodName) {
        CouchDbClient client;
        String description;
        if (factoryClassName != null && factoryClassName.length() > 0 &&
                factoryMethodName != null && factoryMethodName.length() > 0) {
            try {
                final Class<?> factoryClass = Class.forName(factoryClassName);
                final Method method = factoryClass.getMethod(factoryMethodName);
                final Object object = method.invoke(null);

                if (object instanceof CouchDbClient) {
                    client = (CouchDbClient) object;
                    description = "uri=" + client.getDBUri();
                } else if (object instanceof CouchDbProperties) {
                    final CouchDbProperties properties = (CouchDbProperties) object;
                    client = new CouchDbClient(properties);
                    description = "uri=" + client.getDBUri() + ", username=" + properties.getUsername()
                            + ", passwordHash=" + NameUtil.md5(password + CouchDBProvider.class.getName())
                            + ", maxConnections=" + properties.getMaxConnections() + ", connectionTimeout="
                            + properties.getConnectionTimeout() + ", socketTimeout=" + properties.getSocketTimeout();
                } else if (object == null) {
                    LOGGER.error("The factory method [{}.{}()] returned null.", factoryClassName, factoryMethodName);
                    return null;
                } else {
                    LOGGER.error("The factory method [{}.{}()] returned an unsupported type [{}].", factoryClassName,
                            factoryMethodName, object.getClass().getName());
                    return null;
                }
            } catch (final ClassNotFoundException e) {
                LOGGER.error("The factory class [{}] could not be loaded.", factoryClassName, e);
                return null;
            } catch (final NoSuchMethodException e) {
                LOGGER.error("The factory class [{}] does not have a no-arg method named [{}].", factoryClassName,
                        factoryMethodName, e);
                return null;
            } catch (final Exception e) {
                LOGGER.error("The factory method [{}.{}()] could not be invoked.", factoryClassName, factoryMethodName,
                        e);
                return null;
            }
        } else if (databaseName != null && databaseName.length() > 0) {
            if (protocol != null && protocol.length() > 0) {
                protocol = protocol.toLowerCase();
                if (!protocol.equals("http") && !protocol.equals("https")) {
                    LOGGER.error("Only protocols [http] and [https] are supported, [{}] specified.", protocol);
                    return null;
                }
            } else {
                protocol = "http";
                LOGGER.warn("No protocol specified, using default port [http].");
            }

            final int portInt = AbstractAppender.parseInt(port, protocol.equals("https") ? HTTPS : HTTP);

            if (Strings.isEmpty(server)) {
                server = "localhost";
                LOGGER.warn("No server specified, using default server localhost.");
            }

            if (Strings.isEmpty(username) || Strings.isEmpty(password)) {
                LOGGER.error("You must provide a username and password for the CouchDB provider.");
                return null;
            }

            client = new CouchDbClient(databaseName, false, protocol, server, portInt, username, password);
            description = "uri=" + client.getDBUri() + ", username=" + username + ", passwordHash="
                    + NameUtil.md5(password + CouchDBProvider.class.getName());
        } else {
            LOGGER.error("No factory method was provided so the database name is required.");
            return null;
        }
View Full Code Here

Examples of org.lightcouch.CouchDbClient

    private CouchDbClient client;

    @Before
    public void before() {
        client = new CouchDbClient("camelcouchdb", true, "http", "localhost", 5984, null, null);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.