Package com.impetus.kundera.query

Examples of com.impetus.kundera.query.KunderaQuery


        ObjectMapper mapper = new ObjectMapper();

        try {
            paramsMap = mapper.readValue(parameterString, new TypeReference<HashMap<String, String>>() {
            });
            KunderaQuery kq = ((QueryImpl) q).getKunderaQuery();
            Set<Parameter<?>> parameters = kq.getParameters();
            for (String paramName : paramsMap.keySet()) {
                String value = paramsMap.get(paramName);

                if (paramName.equalsIgnoreCase("firstResult")) {
                    q.setFirstResult(Integer.parseInt(value));
View Full Code Here


        while (st.hasMoreTokens()) {
            String element = st.nextToken();
            paramsMap.put(element.substring(0, element.indexOf("=")),
                element.substring(element.indexOf("=") + 1, element.length()));
        }
        KunderaQuery kq = ((QueryImpl) q).getKunderaQuery();
        Set<Parameter<?>> parameters = kq.getParameters();
        for (String paramName : paramsMap.keySet()) {
            String value = paramsMap.get(paramName);
            if (paramName.equalsIgnoreCase("firstResult")) {
                q.setFirstResult(Integer.parseInt(value));
            } else if (paramName.equalsIgnoreCase("maxResult")) {
View Full Code Here

    /**
     * @param queryString
     * @param q
     */
    public static void setQueryParameters(String queryString, HashMap<String, String> paramsMap, Query q) {
        KunderaQuery kq = ((QueryImpl) q).getKunderaQuery();
        Set<Parameter<?>> parameters = kq.getParameters();
        for (String paramName : paramsMap.keySet()) {
            String value = paramsMap.get(paramName);

            if (StringUtils.isNumeric(paramName)) {
                for (Parameter param : parameters) {
View Full Code Here

        List<String> nameList = new ArrayList<String>();
        nameList.add("kk");
        nameList.add("dk");
        nameList.add("sk");

        KunderaQuery kunderaQuery = getQueryObject(queryString, emf);
        kunderaQuery.setParameter("nameList", nameList);

        cqlQuery = parseAndCreateCqlQuery(kunderaQuery, emf, em, pu, PersonCassandra.class, Integer.MAX_VALUE);

        Assert.assertNotNull(cqlQuery);

        Assert.assertEquals("SELECT * FROM \"PERSONCASSANDRA\" WHERE \"personId\" IN ('kk', 'dk', 'sk' ) ", cqlQuery);

        // In Query set Paramater with and clause.
        queryString = "Select p from PersonCassandra p WHERE p.personId in :nameList and p.age = 10";

        kunderaQuery = getQueryObject(queryString, emf);
        kunderaQuery.setParameter("nameList", nameList);

        cqlQuery = parseAndCreateCqlQuery(kunderaQuery, emf, em, pu, PersonCassandra.class, Integer.MAX_VALUE);

        Assert.assertNotNull(cqlQuery);

        Assert.assertEquals(
                "SELECT * FROM \"PERSONCASSANDRA\" WHERE \"personId\" IN ('kk', 'dk', 'sk' )  AND \"AGE\" = 10  ALLOW FILTERING",
                cqlQuery);

        // In Query set Paramater with gt clause.
        queryString = "Select p from PersonCassandra p WHERE p.personId in :nameList and p.age > 10";

        kunderaQuery = getQueryObject(queryString, emf);
        kunderaQuery.setParameter("nameList", nameList);

        cqlQuery = parseAndCreateCqlQuery(kunderaQuery, emf, em, pu, PersonCassandra.class, 5);

        Assert.assertNotNull(cqlQuery);

        Assert.assertEquals(
                "SELECT * FROM \"PERSONCASSANDRA\" WHERE \"personId\" IN ('kk', 'dk', 'sk' )  AND \"AGE\" > 10 LIMIT 5  ALLOW FILTERING",
                cqlQuery);

        // In Query over non pk field set Paramater with gt clause.
        queryString = "Select p from PersonCassandra p WHERE p.age in :ageList and p.personName = 'vivek'";

        List<Integer> ageList = new ArrayList<Integer>();
        ageList.add(10);
        ageList.add(20);
        ageList.add(30);

        kunderaQuery = getQueryObject(queryString, emf);
        kunderaQuery.setParameter("ageList", ageList);

        cqlQuery = parseAndCreateCqlQuery(kunderaQuery, emf, em, pu, PersonCassandra.class, 100);

        Assert.assertNotNull(cqlQuery);

View Full Code Here

        List<String> userIdList = new ArrayList<String>();
        userIdList.add("kk");
        userIdList.add("dk");
        userIdList.add("sk");

        KunderaQuery kunderaQuery = getQueryObject(queryString, emf);
        kunderaQuery.setParameter("userIdList", userIdList);

        cqlQuery = parseAndCreateCqlQuery(kunderaQuery, emf, em, pu, CassandraPrimeUser.class, Integer.MAX_VALUE);

        Assert.assertNotNull(cqlQuery);

        Assert.assertEquals(
                "SELECT * FROM \"CompositeUser\" WHERE \"userId\" IN ('kk', 'dk', 'sk' )   ORDER BY \"tweetId\" ASC   ALLOW FILTERING",
                cqlQuery);

        // In Query set Paramater with and clause.
        queryString = "Select u from CassandraPrimeUser u WHERE u.key.userId IN :userIdList and p.name = 'kuldeep' ORDER BY u.key.tweetId ASC";

        kunderaQuery = getQueryObject(queryString, emf);
        kunderaQuery.setParameter("userIdList", userIdList);

        cqlQuery = parseAndCreateCqlQuery(kunderaQuery, emf, em, pu, CassandraPrimeUser.class, 100);

        Assert.assertNotNull(cqlQuery);

        Assert.assertEquals(
                "SELECT * FROM \"CompositeUser\" WHERE \"userId\" IN ('kk', 'dk', 'sk' )  AND \"name\" = 'kuldeep'  ORDER BY \"tweetId\" ASC  LIMIT 100  ALLOW FILTERING",
                cqlQuery);

        // In Query set Paramater with gt clause.
        queryString = "Select u from CassandraPrimeUser u WHERE u.key IN :keyList";

        List<CassandraCompoundKey> personIdList = new ArrayList<CassandraCompoundKey>();
        UUID timeLineId1 = UUID.randomUUID();
        personIdList.add(new CassandraCompoundKey("kk", 1, timeLineId1));
        personIdList.add(new CassandraCompoundKey("vm", 2, timeLineId1));
        personIdList.add(new CassandraCompoundKey("vs", 3, timeLineId1));

        kunderaQuery = getQueryObject(queryString, emf);
        kunderaQuery.setParameter("keyList", personIdList);

        cqlQuery = parseAndCreateCqlQuery(kunderaQuery, emf, em, pu, CassandraPrimeUser.class, 100);

        Assert.assertNotNull(cqlQuery);
        Assert.assertTrue(cqlQuery.contains("SELECT * FROM \"CompositeUser\" WHERE "));
        Assert.assertTrue(cqlQuery.contains("\"timeLineId\" IN (" + timeLineId1 + ", " + timeLineId1 + ", "
                + timeLineId1 + " )"));
        Assert.assertTrue(cqlQuery.contains("\"userId\" IN ('kk', 'vm', 'vs' )"));
        Assert.assertTrue(cqlQuery.contains("\"tweetId\" IN (1, 2, 3 )"));
        Assert.assertTrue(cqlQuery.contains(" LIMIT 100"));
        Assert.assertTrue(cqlQuery.contains(" AND "));
        Assert.assertTrue(cqlQuery.indexOf(" AND ") > 0);

        // In Query over non pk field set Paramater with gt clause.
        queryString = "Select u from CassandraPrimeUser u WHERE u.key IN :keyList and u.name = 'vivek'";

        kunderaQuery = getQueryObject(queryString, emf);
        kunderaQuery.setParameter("keyList", personIdList);

        cqlQuery = parseAndCreateCqlQuery(kunderaQuery, emf, em, pu, CassandraPrimeUser.class, 100);

        Assert.assertNotNull(cqlQuery);
        Assert.assertTrue(cqlQuery.contains("SELECT * FROM \"CompositeUser\" WHERE "));
View Full Code Here

        List<String> id = new ArrayList<String>();
        id.add("1");
        id.add("2");
        id.add("3");

        KunderaQuery kunderaQuery = getQueryObject(queryString, emf);
        kunderaQuery.setParameter("idList", id);

        cqlQuery = parseAndCreateUpdateQuery(kunderaQuery, emf, em, pu, PersonCassandra.class, Integer.MAX_VALUE);

        Assert.assertNotNull(cqlQuery);

        Assert.assertEquals(
                "UPDATE \"PERSONCASSANDRA\" SET \"PERSON_NAME\"='Kuldeep' WHERE \"personId\" IN ('1', '2', '3' ) ", cqlQuery);

        // In Query set Paramater with and clause.
        queryString = "Update PersonCassandra p SET p.personName = 'Kuldeep' WHERE p.personId in :nameList and p.age = 10";

        kunderaQuery = getQueryObject(queryString, emf);
        kunderaQuery.setParameter("nameList", id);

        cqlQuery = parseAndCreateUpdateQuery(kunderaQuery, emf, em, pu, PersonCassandra.class, Integer.MAX_VALUE);

        Assert.assertNotNull(cqlQuery);

        Assert.assertEquals(
                "UPDATE \"PERSONCASSANDRA\" SET \"PERSON_NAME\"='Kuldeep' WHERE \"personId\" IN ('1', '2', '3' )  AND \"AGE\" = 10",
                cqlQuery);

        // In Query.
        queryString = "Delete from PersonCassandra p WHERE p.personId = '1'";

        cqlQuery = parseAndCreateDeleteQuery(getQueryObject(queryString, emf), emf, em, pu, PersonCassandra.class, 400);

        Assert.assertNotNull(cqlQuery);

        Assert.assertEquals("DELETE FROM \"PERSONCASSANDRA\" WHERE \"personId\" = '1'", cqlQuery);

        // In Query.
        queryString = "Delete from PersonCassandra p WHERE p.personId IN ('1', '2', '3')";

        cqlQuery = parseAndCreateDeleteQuery(getQueryObject(queryString, emf), emf, em, pu, PersonCassandra.class, 400);

        Assert.assertNotNull(cqlQuery);

        Assert.assertEquals("DELETE FROM \"PERSONCASSANDRA\" WHERE \"personId\" IN ('1', '2', '3')", cqlQuery);

        // In Query set Paramater.
        queryString = "Delete from PersonCassandra p WHERE p.personId IN :idList";

        kunderaQuery = getQueryObject(queryString, emf);
        kunderaQuery.setParameter("idList", id);

        cqlQuery = parseAndCreateDeleteQuery(kunderaQuery, emf, em, pu, PersonCassandra.class, Integer.MAX_VALUE);

        Assert.assertNotNull(cqlQuery);

        Assert.assertEquals("DELETE FROM \"PERSONCASSANDRA\" WHERE \"personId\" IN ('1', '2', '3' ) ", cqlQuery);

        // In Query over non pk field set Paramater with gt clause.
        queryString = "Delete from PersonCassandra p WHERE p.personId in :idList and p.age = 25";

        kunderaQuery = getQueryObject(queryString, emf);
        kunderaQuery.setParameter("idList", id);

        cqlQuery = parseAndCreateDeleteQuery(kunderaQuery, emf, em, pu, PersonCassandra.class, 100);

        Assert.assertNotNull(cqlQuery);
View Full Code Here

        List<String> id = new ArrayList<String>();
        id.add("1");
        id.add("2");
        id.add("3");

        KunderaQuery kunderaQuery = getQueryObject(queryString, emf);
        kunderaQuery.setParameter("idList", id);

        cqlQuery = parseAndCreateUpdateQuery(kunderaQuery, emf, em, pu, PersonCassandra.class, Integer.MAX_VALUE, 1000);

        Assert.assertNotNull(cqlQuery);

        Assert.assertEquals(
                "UPDATE \"PERSONCASSANDRA\"  USING TTL 1000 SET \"PERSON_NAME\"='Kuldeep' WHERE \"personId\" IN ('1', '2', '3' ) ", cqlQuery);

        // In Query set Paramater with and clause.
        queryString = "Update PersonCassandra p SET p.personName = 'Kuldeep' WHERE p.personId in :nameList and p.age = 10";

        kunderaQuery = getQueryObject(queryString, emf);
        kunderaQuery.setParameter("nameList", id);

        cqlQuery = parseAndCreateUpdateQuery(kunderaQuery, emf, em, pu, PersonCassandra.class, Integer.MAX_VALUE);

        Assert.assertNotNull(cqlQuery);
View Full Code Here

        List<String> userIdList = new ArrayList<String>();
        userIdList.add("kk");
        userIdList.add("dk");
        userIdList.add("sk");

        KunderaQuery kunderaQuery = getQueryObject(queryString, emf);
        kunderaQuery.setParameter("userIdList", userIdList);

        cqlQuery = parseAndCreateUpdateQuery(kunderaQuery, emf, em, pu, CassandraPrimeUser.class, Integer.MAX_VALUE);

        Assert.assertNotNull(cqlQuery);

        Assert.assertEquals("UPDATE \"CompositeUser\" SET \"name\"='Kuldeep' WHERE \"userId\" IN ('kk', 'dk', 'sk' ) ",
                cqlQuery);

        // Simple Query.
        queryString = "Delete from CassandraPrimeUser u WHERE u.name = 'kk'";

        cqlQuery = parseAndCreateDeleteQuery(getQueryObject(queryString, emf), emf, em, pu, CassandraPrimeUser.class,
                100);

        Assert.assertNotNull(cqlQuery);

        Assert.assertEquals("DELETE FROM \"CompositeUser\" WHERE \"name\" = 'kk'", cqlQuery);

        // In Query.
        queryString = "Delete from CassandraPrimeUser u WHERE u.key.userId IN ('kk', 'dk', 'sk' )";

        cqlQuery = parseAndCreateDeleteQuery(getQueryObject(queryString, emf), emf, em, pu, CassandraPrimeUser.class,
                400);

        Assert.assertNotNull(cqlQuery);

        Assert.assertEquals("DELETE FROM \"CompositeUser\" WHERE \"userId\" IN ('kk', 'dk', 'sk')", cqlQuery);

        // In Query set Paramater with and clause.
        queryString = "Delete from CassandraPrimeUser u WHERE u.key.userId IN :userIdList";

        kunderaQuery = getQueryObject(queryString, emf);
        kunderaQuery.setParameter("userIdList", userIdList);

        cqlQuery = parseAndCreateDeleteQuery(kunderaQuery, emf, em, pu, CassandraPrimeUser.class, 100);

        Assert.assertNotNull(cqlQuery);
View Full Code Here

          log.warn(e.getMessage());
        }
        getpostParsingInit.setAccessible(true);

        KunderaMetadata kunderaMetadata = ((EntityManagerFactoryImpl) emf).getKunderaMetadataInstance();
        KunderaQuery kunderaQuery = new KunderaQuery(queryString, kunderaMetadata);
        KunderaQueryParser queryParser = new KunderaQueryParser(kunderaQuery);
        queryParser.parse();
        try
        {
            getpostParsingInit.invoke(kunderaQuery);
View Full Code Here

    }
    getpostParsingInit.setAccessible(true);

    KunderaMetadata kunderaMetadata = ((EntityManagerFactoryImpl) emf)
        .getKunderaMetadataInstance();
    KunderaQuery kunderaQuery = new KunderaQuery(queryString,
        kunderaMetadata);
    KunderaQueryParser queryParser = new KunderaQueryParser(kunderaQuery);
    queryParser.parse();
    try {
      getpostParsingInit.invoke(kunderaQuery);
View Full Code Here

TOP

Related Classes of com.impetus.kundera.query.KunderaQuery

Copyright © 2018 www.massapicom. 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.