Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PostgreSQL support #18

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ rulette-core/lib/datasource.properties
/rulette-core copy/target/
/rulette-engine/target/
/rulette-engine copy/target/
/rulette-examples/target/
/rulette-examples/target/
/rulette-postgres-provider/target/
2 changes: 2 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@
<tag>HEAD</tag>
</scm>
<properties>
<rulette.version>1.2.8-SNAPSHOT</rulette.version>
<powermock.version>1.6.2</powermock.version>
</properties>

<modules>
<module>rulette-core</module>
<module>rulette-engine</module>
<module>rulette-mysql-provider</module>
<module>rulette-postgres-provider</module>
<module>rulette-examples</module>
</modules>

Expand Down
2 changes: 1 addition & 1 deletion rulette-engine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<dependency>
<groupId>com.github.kislayverma.rulette</groupId>
<artifactId>rulette-core</artifactId>
<version>1.2.8-SNAPSHOT</version>
<version>${rulette.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down
10 changes: 8 additions & 2 deletions rulette-examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,19 @@
<dependency>
<groupId>com.github.kislayverma.rulette</groupId>
<artifactId>rulette-engine</artifactId>
<version>1.2.8-SNAPSHOT</version>
<version>${rulette.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.github.kislayverma.rulette</groupId>
<artifactId>rulette-mysql-provider</artifactId>
<version>1.2.8-SNAPSHOT</version>
<version>${rulette.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.github.kislayverma.rulette</groupId>
<artifactId>rulette-postgres-provider</artifactId>
<version>${rulette.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.github.kislayverma.rulette.example.postgres;

import com.github.kislayverma.rulette.RuleSystem;
import com.github.kislayverma.rulette.core.data.IDataProvider;
import com.github.kislayverma.rulette.core.rule.Rule;
import java.io.File;
import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import com.github.kislayverma.rulette.mysql.MysqlDataProvider;

/**
* NOT FOR ACTUAL USE!!!
* This class shows how to initialize a Rulette engine from PostgreSQL store and its use.
*
* @author Kislay Verma
*
*/
public class SimplePostgresUse implements Serializable {

public static void main(String[] args) throws Exception {
File f = new File("/Users/kislay.verma/Applications/apache-tomcat-7.0.53/conf/rulette-datasource.properties");
IDataProvider dataProvider = new MysqlDataProvider(f.getPath());
RuleSystem rs = new RuleSystem("govt_vat_rule_system", dataProvider);

Map<String, String> inputMap = new HashMap<>();
inputMap.put("article_id", "7");
inputMap.put("source_state_code", "HAR");
inputMap.put("destination_state_code", "GUJ");
inputMap.put("courier_code", "IP");
inputMap.put("mrp_threshold", "5");
inputMap.put("gender", "Women");
inputMap.put("is_active", "1");
inputMap.put("valid_date_range", "20130820");

// Rule rule = null;
long stime = new Date().getTime();
for (int i = 0; i < 1; i++) {
Rule rule = rs.getRule(inputMap);
// System.out.println((rule == null) ? "none" : rule.toString());
// System.out.println("\n---------------------------\n");
// List<Rule> rules = rs.getAllApplicableRules(inputMap);
// System.out.println((rules == null) ? "none" : rules.toString());
}

long etime = new Date().getTime();
System.out.println("Time taken to get rule : " + (etime - stime) + " ms.");
}
}
2 changes: 1 addition & 1 deletion rulette-mysql-provider/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<dependency>
<groupId>com.github.kislayverma.rulette</groupId>
<artifactId>rulette-core</artifactId>
<version>1.2.8-SNAPSHOT</version>
<version>${rulette.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down
223 changes: 223 additions & 0 deletions rulette-postgres-provider/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.github.kislayverma</groupId>
<artifactId>rulette</artifactId>
<version>1.2.8-SNAPSHOT</version>
</parent>

<groupId>com.github.kislayverma.rulette</groupId>
<artifactId>rulette-postgres-provider</artifactId>
<name>rulette-postgres-provider</name>
<description>PostgreSQL integration for Rulette</description>

<dependencies>
<dependency>
<groupId>com.github.kislayverma.rulette</groupId>
<artifactId>rulette-core</artifactId>
<version>${rulette.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.4.1209</version>
</dependency>
<dependency>
<groupId>c3p0</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.1.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.21</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.19</version>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<version>3.3.1</version>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-easymock</artifactId>
<version>${powermock.version}</version>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>${powermock.version}</version>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<version>${powermock.version}</version>
</dependency>
</dependencies>

<build>
<sourceDirectory>src/main/java/</sourceDirectory>
<resources>
<resource>
<directory>lib</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.7</version>
<configuration>
<check>
<totalLineRate>0</totalLineRate>
</check>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<inherited>true</inherited>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.5</version>
<executions>
<execution>
<goals>
<goal>pmd</goal>
</goals>
</execution>
</executions>
<configuration>
<linkXref>true</linkXref>
<sourceEncoding>utf-8</sourceEncoding>
<minimumTokens>100</minimumTokens>
<targetJdk>1.7</targetJdk>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.3</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.7</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<autoVersionSubmodules>true</autoVersionSubmodules>
<useReleaseProfile>false</useReleaseProfile>
<releaseProfiles>release</releaseProfiles>
<goals>deploy</goals>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.5</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.9</version>
<configuration>
<dependencyLocationsEnabled>false</dependencyLocationsEnabled>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.3</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.7</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.6</version>
<configuration>
<linkXref>true</linkXref>
<sourceEncoding>utf-8</sourceEncoding>
<minimumTokens>100</minimumTokens>
<targetJdk>1.7</targetJdk>
</configuration>
</plugin>
</plugins>
</reporting>
</project>
Binary file added rulette-postgres-provider/src/main/.DS_Store
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.