Initial
This commit is contained in:
commit
4dbaba5e48
80 changed files with 4193 additions and 0 deletions
88
simpleWebApp/pom.xml
Normal file
88
simpleWebApp/pom.xml
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
<parent>
|
||||
<groupId>com.pymma-software.droolscourse</groupId>
|
||||
<artifactId>droolscourse</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
|
||||
<artifactId>simpleWebApp</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<name>Calculation Service WebApp</name>
|
||||
<url>http://www.springframework.org/spring-ws</url>
|
||||
<packaging>war</packaging>
|
||||
<build>
|
||||
<finalName>simpleWebApp</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.3.1</version>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.tomcat.maven</groupId>
|
||||
<artifactId>tomcat6-maven-plugin</artifactId>
|
||||
<version>2.1</version>
|
||||
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.drools</groupId>
|
||||
<artifactId>drools-compiler</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jdt.core.compiler</groupId>
|
||||
<artifactId>ecj</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jbpm</groupId>
|
||||
<artifactId>jbpm-bpmn2</artifactId>
|
||||
</dependency>
|
||||
<!-- Apache CXF dependencies -->
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-frontend-jaxws</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-transports-http</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring Dependencies -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Logging -->
|
||||
<dependency>
|
||||
<groupId>commons-logging</groupId>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Testing -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
92
simpleWebApp/simpleWebApp.iml
Normal file
92
simpleWebApp/simpleWebApp.iml
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="web" name="Web">
|
||||
<configuration>
|
||||
<descriptors>
|
||||
<deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/src/main/webapp/WEB-INF/web.xml" />
|
||||
</descriptors>
|
||||
<webroots>
|
||||
<root url="file://$MODULE_DIR$/src/main/webapp" relative="/" />
|
||||
</webroots>
|
||||
</configuration>
|
||||
</facet>
|
||||
<facet type="Spring" name="Spring">
|
||||
<configuration>
|
||||
<fileset id="fileset" name="Spring Application Context" removed="false">
|
||||
<file>file://$MODULE_DIR$/src/main/webapp/WEB-INF/spring-ws-servlet.xml</file>
|
||||
</fileset>
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_6" inherit-compiler-output="false">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/webapp" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Maven: org.drools:drools-compiler:5.6.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.drools:drools-core:5.6.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mvel:mvel2:2.1.8.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.drools:knowledge-api:5.6.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.6.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.drools:knowledge-internal-api:5.6.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.antlr:antlr-runtime:3.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.antlr:antlr:3.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.antlr:stringtemplate:3.2.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: antlr:antlr:2.7.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.eclipse.jdt.core.compiler:ecj:3.5.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.thoughtworks.xstream:xstream:1.4.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: xmlpull:xmlpull:1.1.3.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: xpp3:xpp3_min:1.1.4c" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jbpm:jbpm-bpmn2:5.5.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jbpm:jbpm-flow-builder:5.5.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jbpm:jbpm-flow:5.5.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.protobuf:protobuf-java:2.5.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-frontend-jaxws:2.2.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: xml-resolver:xml-resolver:1.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.geronimo.specs:geronimo-jaxws_2.1_spec:1.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.geronimo.specs:geronimo-activation_1.1_spec:1.0.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.geronimo.specs:geronimo-ws-metadata_2.0_spec:1.1.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: asm:asm:2.2.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.cxf:cxf-api:2.2.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.cxf:cxf-common-utilities:2.2.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-core:3.0.1.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-asm:3.0.1.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.1.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-beans:3.0.1.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-context:3.0.1.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: aopalliance:aopalliance:1.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.geronimo.specs:geronimo-annotation_1.0_spec:1.1.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: javax.xml.bind:jaxb-api:2.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.geronimo.specs:geronimo-stax-api_1.0_spec:1.0.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: wsdl4j:wsdl4j:1.6.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.ws.commons.schema:XmlSchema:1.4.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-lang:commons-lang:2.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.codehaus.woodstox:wstx-asl:3.2.9" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.neethi:neethi:2.0.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.cxf:cxf-common-schemas:2.2.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-core:2.2.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.sun.xml.bind:jaxb-impl:2.1.12" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.geronimo.specs:geronimo-javamail_1.4_spec:1.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-bindings-soap:2.2.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.cxf:cxf-tools-common:2.2.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: javax.xml.soap:saaj-api:1.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-databinding-jaxb:2.2.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-bindings-xml:2.2.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-frontend-simple:2.2.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-ws-addr:2.2.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.sun.xml.messaging.saaj:saaj-impl:1.3.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-transports-http:2.2.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-web:3.0.1.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-aop:3.0.1.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-expression:3.0.1.RELEASE" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.5" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package droolscours.loyalty;
|
||||
|
||||
import droolscours.loyalty.domains.Ticket;
|
||||
|
||||
import javax.jws.WebMethod;
|
||||
import javax.jws.WebService;
|
||||
|
||||
@WebService
|
||||
public interface IServiceCalculate {
|
||||
|
||||
@WebMethod(operationName = "calculate")
|
||||
public abstract Ticket calculate( Ticket ticket);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package droolscours.loyalty;
|
||||
|
||||
import droolscours.loyalty.domains.Ticket;
|
||||
import org.drools.runtime.StatefulKnowledgeSession;
|
||||
import util.KnowledgeSessionHelper;
|
||||
|
||||
import javax.jws.WebService;
|
||||
|
||||
@WebService(endpointInterface = "droolscours.loyalty.IServiceCalculate")
|
||||
public class ServiceCalculate implements IServiceCalculate{
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* droolscours.loyalty.IServiceCalculate#calculate(droolscours.loyalty.domains
|
||||
* .Ticket)
|
||||
*/
|
||||
private StatefulKnowledgeSession sessionStatefull = null;
|
||||
|
||||
|
||||
@Override
|
||||
public Ticket calculate( Ticket ticket) {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSession("File1.drl");
|
||||
sessionStatefull.insert(ticket);
|
||||
sessionStatefull.fireAllRules();
|
||||
System.out.println("Works");
|
||||
return ticket;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
package droolscours.loyalty.domains;
|
||||
|
||||
public class Card {
|
||||
private String number;
|
||||
private String name;
|
||||
|
||||
private Customer customer;
|
||||
|
||||
public void setNumber(String number) {
|
||||
this.number = number;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setCustomer(Customer customer) {
|
||||
this.customer = customer;
|
||||
}
|
||||
|
||||
public void setCartType(String cartType) {
|
||||
this.cartType = cartType;
|
||||
}
|
||||
|
||||
private String cartType;
|
||||
|
||||
public Card(String number, String cartName, String cartType,
|
||||
String customerID, String name, String surname, String maritalName,
|
||||
Gender gender) {
|
||||
this.number = number;
|
||||
this.name = cartName;
|
||||
this.cartType = cartType;
|
||||
this.customer = new Customer(customerID, name, surname, maritalName,
|
||||
gender, null);
|
||||
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getCartType() {
|
||||
return cartType;
|
||||
}
|
||||
|
||||
public String getNumber() {
|
||||
return number;
|
||||
}
|
||||
|
||||
public Customer getCustomer() {
|
||||
return customer;
|
||||
}
|
||||
|
||||
public Card() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
package droolscours.loyalty.domains;
|
||||
|
||||
public enum Currency {
|
||||
Euro, Dollar, Yen
|
||||
}
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
package droolscours.loyalty.domains;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class Customer {
|
||||
private String customerID;
|
||||
private String surName;
|
||||
private String name;
|
||||
private String maritalName;
|
||||
private Gender gender;
|
||||
private Date birthDate;
|
||||
|
||||
public String getCustomerID() {
|
||||
return customerID;
|
||||
}
|
||||
|
||||
public void setCustomerID(String customerID) {
|
||||
this.customerID = customerID;
|
||||
}
|
||||
|
||||
public String getSurName() {
|
||||
return surName;
|
||||
}
|
||||
|
||||
public void setSurName(String surName) {
|
||||
this.surName = surName;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getMaritalName() {
|
||||
return maritalName;
|
||||
}
|
||||
|
||||
public void setMaritalName(String maritalName) {
|
||||
this.maritalName = maritalName;
|
||||
}
|
||||
|
||||
public Gender getGender() {
|
||||
return gender;
|
||||
}
|
||||
|
||||
public void setGender(Gender gender) {
|
||||
this.gender = gender;
|
||||
}
|
||||
|
||||
public Date getBirthDate() {
|
||||
return birthDate;
|
||||
}
|
||||
|
||||
public void setBirthDate(Date birthDate) {
|
||||
this.birthDate = birthDate;
|
||||
}
|
||||
|
||||
public Customer(String customerID, String surName, String name,
|
||||
String maritalName, Gender gender, Date birthDate) {
|
||||
super();
|
||||
this.customerID = customerID;
|
||||
this.surName = surName;
|
||||
this.name = name;
|
||||
this.maritalName = maritalName;
|
||||
this.gender = gender;
|
||||
this.birthDate = birthDate;
|
||||
}
|
||||
|
||||
public Customer() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
package droolscours.loyalty.domains;
|
||||
|
||||
public enum Gender {
|
||||
Mr,Mrs,Miss
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package droolscours.loyalty.domains;
|
||||
|
||||
public class Ligneop {
|
||||
private String nomOP;
|
||||
private Float montantReduction;
|
||||
public String getNomOP() {
|
||||
return nomOP;
|
||||
}
|
||||
public void setNomOP(String nomOP) {
|
||||
this.nomOP = nomOP;
|
||||
}
|
||||
public Float getMontantReduction() {
|
||||
return montantReduction;
|
||||
}
|
||||
public void setMontantReduction(Float montantReduction) {
|
||||
this.montantReduction = montantReduction;
|
||||
}
|
||||
public Ligneop() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
package droolscours.loyalty.domains;
|
||||
|
||||
public class Price {
|
||||
|
||||
private Float price;
|
||||
private Currency currency;
|
||||
|
||||
public Float getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(Float price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public Currency getCurrency() {
|
||||
return currency;
|
||||
}
|
||||
|
||||
public void setCurrency(Currency currency) {
|
||||
this.currency = currency;
|
||||
}
|
||||
|
||||
public Price(Float price, Currency currency) {
|
||||
super();
|
||||
this.price = price;
|
||||
this.currency = currency;
|
||||
}
|
||||
|
||||
public Price() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
package droolscours.loyalty.domains;
|
||||
|
||||
public class Product {
|
||||
|
||||
private String Id;
|
||||
private String Name;
|
||||
private Price price;
|
||||
|
||||
public Price getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(Price price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
private Provider provider;
|
||||
|
||||
public String getId() {
|
||||
return Id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
Id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return Name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
Name = name;
|
||||
}
|
||||
|
||||
public Provider getProvider() {
|
||||
return provider;
|
||||
}
|
||||
|
||||
public void setProvider(Provider provider) {
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
public Product(String id, String name, Provider provider) {
|
||||
super();
|
||||
Id = id;
|
||||
Name = name;
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
public Product() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
package droolscours.loyalty.domains;
|
||||
|
||||
public class Provider {
|
||||
private String name;
|
||||
private String country;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getCountry() {
|
||||
return country;
|
||||
}
|
||||
|
||||
public void setCountry(String country) {
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
public Provider(String name, String country) {
|
||||
super();
|
||||
this.name = name;
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
public Provider() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
package droolscours.loyalty.domains;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class Ticket {
|
||||
|
||||
private String Id;
|
||||
private Date date;
|
||||
private Float amount;
|
||||
private Card loyaltyCard;
|
||||
private Customer customer;
|
||||
|
||||
public Customer getCustomer() {
|
||||
return customer;
|
||||
}
|
||||
|
||||
public void setCustomer(Customer customer) {
|
||||
this.customer = customer;
|
||||
}
|
||||
|
||||
public Card getLoyaltyCard() {
|
||||
return loyaltyCard;
|
||||
}
|
||||
|
||||
public void setLoyaltyCard(Card loyaltyCard) {
|
||||
this.loyaltyCard = loyaltyCard;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return Id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
Id = id;
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(Date date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
private List<TicketLine> ticketLines = new ArrayList<TicketLine>();
|
||||
|
||||
public long AddLine(Product product, Float price, long quantity) {
|
||||
TicketLine newLine = new TicketLine(this, product, quantity, price);
|
||||
ticketLines.add(newLine);
|
||||
this.amount = this.amount + newLine.getLineTotal();
|
||||
return newLine.getLineNumber();
|
||||
}
|
||||
|
||||
public void delLine(int lineNumber) {
|
||||
if (lineNumber <= this.ticketLines.size()) {
|
||||
TicketLine lineToDel = this.ticketLines.get(lineNumber);
|
||||
lineToDel.setValid(false);
|
||||
this.amount = this.amount-lineToDel.getLineTotal();
|
||||
}
|
||||
}
|
||||
|
||||
public Ticket() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public Float getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public void setAmount(Float amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public List<TicketLine> getTicketLines() {
|
||||
return ticketLines;
|
||||
}
|
||||
|
||||
public void setTicketLines(List<TicketLine> ticketLines) {
|
||||
this.ticketLines = ticketLines;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,121 @@
|
|||
package droolscours.loyalty.domains;
|
||||
|
||||
public class TicketLine {
|
||||
private static int numberLines = 0;
|
||||
private String ticketID;
|
||||
private Ticket ticket;
|
||||
private int lineNumber;
|
||||
private String productID;
|
||||
private Product product;
|
||||
private long quantity;
|
||||
private Float price = null;
|
||||
private Float lineTotal;;
|
||||
private Ligneop op;
|
||||
public Ligneop getOp() {
|
||||
return op;
|
||||
}
|
||||
|
||||
public String getProductID() {
|
||||
return productID;
|
||||
}
|
||||
|
||||
public void setProductID(String productID) {
|
||||
this.productID = productID;
|
||||
}
|
||||
|
||||
public String getTicketID() {
|
||||
return this.ticketID;
|
||||
}
|
||||
|
||||
public void setTicketID(String ticketID) {
|
||||
this.ticketID = ticketID;
|
||||
}
|
||||
|
||||
public void setOp(Ligneop op) {
|
||||
this.op = op;
|
||||
}
|
||||
private boolean valid;
|
||||
|
||||
public int getLineNumber() {
|
||||
return lineNumber;
|
||||
}
|
||||
|
||||
public Float getLineTotal() {
|
||||
return lineTotal;
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return valid;
|
||||
}
|
||||
|
||||
public void setValid(boolean valid) {
|
||||
this.valid = valid;
|
||||
}
|
||||
|
||||
public Ticket getTicket() {
|
||||
return ticket;
|
||||
}
|
||||
|
||||
public void setTicket(Ticket ticket) {
|
||||
this.ticket = ticket;
|
||||
}
|
||||
|
||||
public Product getProduct() {
|
||||
return product;
|
||||
}
|
||||
|
||||
public void setProduct(Product product) {
|
||||
this.product = product;
|
||||
}
|
||||
|
||||
public long getQuantity() {
|
||||
return quantity;
|
||||
}
|
||||
|
||||
public TicketLine(Ticket ticket, Product product, long quantity, Float price) {
|
||||
super();
|
||||
numberLines = numberLines + 1;
|
||||
this.lineNumber = numberLines;
|
||||
this.ticket = ticket;
|
||||
this.product = product;
|
||||
this.quantity = quantity;
|
||||
this.price = price;
|
||||
this.lineTotal = price * quantity;
|
||||
}
|
||||
|
||||
public void setQuantity(long quantity) {
|
||||
this.quantity = quantity;
|
||||
}
|
||||
|
||||
public Float getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(Float price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public TicketLine() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public static int getNumberLines() {
|
||||
return numberLines;
|
||||
}
|
||||
|
||||
public static void setNumberLines(int numberLines) {
|
||||
TicketLine.numberLines = numberLines;
|
||||
}
|
||||
|
||||
public void setLineNumber(int lineNumber) {
|
||||
this.lineNumber = lineNumber;
|
||||
}
|
||||
|
||||
public void setLineTotal(Float lineTotal) {
|
||||
this.lineTotal = lineTotal;
|
||||
}
|
||||
public void AddProductToTicketLine(Product p){
|
||||
this.product = p;
|
||||
}
|
||||
}
|
||||
20
simpleWebApp/src/main/java/util/DateHelper.java
Normal file
20
simpleWebApp/src/main/java/util/DateHelper.java
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
package util;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
public class DateHelper {
|
||||
public static String sFormat = "yyyy-MM-dd";
|
||||
|
||||
public static Date getDate(String sDate) throws Exception {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(sFormat);
|
||||
return sdf.parse(sDate);
|
||||
}
|
||||
|
||||
public static Date getDate(String sDate, String anotherFormat)
|
||||
throws Exception {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(anotherFormat);
|
||||
return sdf.parse(sDate);
|
||||
}
|
||||
}
|
||||
132
simpleWebApp/src/main/java/util/KnowledgeSessionHelper.java
Normal file
132
simpleWebApp/src/main/java/util/KnowledgeSessionHelper.java
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
package util;
|
||||
|
||||
import org.drools.KnowledgeBase;
|
||||
import org.drools.KnowledgeBaseFactory;
|
||||
import org.drools.builder.KnowledgeBuilder;
|
||||
import org.drools.builder.KnowledgeBuilderError;
|
||||
import org.drools.builder.KnowledgeBuilderErrors;
|
||||
import org.drools.builder.KnowledgeBuilderFactory;
|
||||
import org.drools.builder.ResourceType;
|
||||
import org.drools.event.rule.*;
|
||||
import org.drools.io.ResourceFactory;
|
||||
import org.drools.runtime.StatefulKnowledgeSession;
|
||||
import org.drools.runtime.StatelessKnowledgeSession;
|
||||
|
||||
public class KnowledgeSessionHelper {
|
||||
private static KnowledgeBase ruleBase = null;
|
||||
|
||||
private static KnowledgeBase createRuleBase(String drlFile) {
|
||||
|
||||
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory
|
||||
.newKnowledgeBuilder();
|
||||
kbuilder.add(ResourceFactory.newClassPathResource(drlFile),
|
||||
ResourceType.DRL);
|
||||
KnowledgeBuilderErrors errors = kbuilder.getErrors();
|
||||
if (errors.size() > 0) {
|
||||
for (KnowledgeBuilderError error : errors) {
|
||||
System.err.println(error);
|
||||
}
|
||||
throw new IllegalArgumentException(
|
||||
"Probleme a la lecture du fichier.");
|
||||
}
|
||||
ruleBase = KnowledgeBaseFactory.newKnowledgeBase();
|
||||
ruleBase.addKnowledgePackages(kbuilder.getKnowledgePackages());
|
||||
return ruleBase;
|
||||
}
|
||||
|
||||
public static StatelessKnowledgeSession getStatelessKnowledgeSession(
|
||||
String drlFile) {
|
||||
if (ruleBase == null) {
|
||||
ruleBase = createRuleBase(drlFile);
|
||||
}
|
||||
return ruleBase.newStatelessKnowledgeSession();
|
||||
}
|
||||
|
||||
public static StatefulKnowledgeSession getStatefulKnowledgeSession(
|
||||
String drlFile) {
|
||||
if (ruleBase == null) {
|
||||
ruleBase = createRuleBase(drlFile);
|
||||
}
|
||||
return ruleBase.newStatefulKnowledgeSession();
|
||||
}
|
||||
|
||||
public static StatefulKnowledgeSession getStatefulKnowledgeSessionWithCallback(
|
||||
String drlFile) {
|
||||
StatefulKnowledgeSession session = getStatefulKnowledgeSession(drlFile);
|
||||
session.addEventListener(new WorkingMemoryEventListener() {
|
||||
@Override
|
||||
public void objectUpdated(ObjectUpdatedEvent arg0) {
|
||||
System.out.println("Object mise à jour \n"
|
||||
+ "Nouvelles valeurs \n" + arg0.getObject().toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void objectRetracted(ObjectRetractedEvent arg0) {
|
||||
System.out.println("Object retiré \n"
|
||||
+ arg0.getOldObject().toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void objectInserted(ObjectInsertedEvent arg0) {
|
||||
System.out.println("Object inséré \n"
|
||||
+ arg0.getObject().toString());
|
||||
}
|
||||
});
|
||||
session.addEventListener(new DefaultAgendaEventListener() {
|
||||
@Override
|
||||
public void beforeActivationFired(BeforeActivationFiredEvent arg0) {
|
||||
System.out.println("La règle "
|
||||
+ arg0.getActivation().getRule().getName()
|
||||
+ " va être déclenchée");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void agendaGroupPushed(AgendaGroupPushedEvent arg0) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void agendaGroupPopped(AgendaGroupPoppedEvent arg0) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterActivationFired(AfterActivationFiredEvent arg0) {
|
||||
System.out.println("La règle "
|
||||
+ arg0.getActivation().getRule().getName()
|
||||
+ " a êté déclenchée");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void activationCreated(ActivationCreatedEvent arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void activationCancelled(ActivationCancelledEvent arg0) {
|
||||
}
|
||||
});
|
||||
return session;
|
||||
}
|
||||
|
||||
public static StatefulKnowledgeSession getStatefulKnowledgeSession(
|
||||
String drlFile, String rfFile) {
|
||||
KnowledgeBase ruleBase = null;
|
||||
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory
|
||||
.newKnowledgeBuilder();
|
||||
kbuilder.add(ResourceFactory.newClassPathResource(drlFile),
|
||||
ResourceType.DRL);
|
||||
kbuilder.add(ResourceFactory.newClassPathResource(rfFile),
|
||||
ResourceType.DRF);
|
||||
KnowledgeBuilderErrors errors = kbuilder.getErrors();
|
||||
if (errors.size() > 0) {
|
||||
for (KnowledgeBuilderError error : errors) {
|
||||
System.err.println(error);
|
||||
}
|
||||
throw new IllegalArgumentException(
|
||||
"Probleme a la lecture du fichier.");
|
||||
}
|
||||
ruleBase = KnowledgeBaseFactory.newKnowledgeBase();
|
||||
ruleBase.addKnowledgePackages(kbuilder.getKnowledgePackages());
|
||||
return ruleBase.newStatefulKnowledgeSession();
|
||||
}
|
||||
|
||||
}
|
||||
34
simpleWebApp/src/main/java/util/MyDate.java
Normal file
34
simpleWebApp/src/main/java/util/MyDate.java
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
package util;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class MyDate {
|
||||
|
||||
private String uneOp;
|
||||
private Date uneDate1;
|
||||
private Date uneDate2;
|
||||
|
||||
public String getUneOp() {
|
||||
return uneOp;
|
||||
}
|
||||
public void setUneOp(String uneOp) {
|
||||
this.uneOp = uneOp;
|
||||
}
|
||||
public Date getUneDate1() {
|
||||
return uneDate1;
|
||||
}
|
||||
public void setUneDate1(Date uneDate1) {
|
||||
this.uneDate1 = uneDate1;
|
||||
}
|
||||
public Date getUneDate2() {
|
||||
return uneDate2;
|
||||
}
|
||||
public void setUneDate2(Date uneDate2) {
|
||||
this.uneDate2 = uneDate2;
|
||||
}
|
||||
public MyDate() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
}
|
||||
10
simpleWebApp/src/main/java/util/OutputDisplay.java
Normal file
10
simpleWebApp/src/main/java/util/OutputDisplay.java
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
package util;
|
||||
|
||||
public class OutputDisplay {
|
||||
|
||||
public void showText(String someText) {
|
||||
long time = System.currentTimeMillis();
|
||||
System.out.println("time=" + time + "-" + someText);
|
||||
}
|
||||
|
||||
}
|
||||
34
simpleWebApp/src/main/resources/File1.drl
Normal file
34
simpleWebApp/src/main/resources/File1.drl
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
//#created on: 21 nov. 2010
|
||||
package droolscours.loyalty
|
||||
|
||||
|
||||
|
||||
import util.MyDate;
|
||||
import droolscours.loyalty.domains.Ticket;
|
||||
import droolscours.loyalty.domains.TicketLine;
|
||||
import droolscours.loyalty.domains.Ligneop;
|
||||
import droolscours.loyalty.domains.Product
|
||||
import util.DateHelper;
|
||||
dialect "MVEL"
|
||||
|
||||
rule "createdateOpPampers"
|
||||
when
|
||||
then
|
||||
MyDate t = new MyDate();
|
||||
t.setUneDate1(DateHelper.getDate("2010-12-01"));
|
||||
t.setUneDate1(DateHelper.getDate("2010-12-31"));
|
||||
t.setUneOp("pampers");
|
||||
insert(t);
|
||||
end
|
||||
rule "opPameprs"
|
||||
when
|
||||
MyDate(uneOp=="pampers",$d1:uneDate1,$d2:uneDate2)
|
||||
$t : Ticket(date >=$d1,date <=$d2)
|
||||
$l : TicketLine(ticketID==$t.Id)
|
||||
$p : Product(Id == $l.productID , name=="pampers")
|
||||
then
|
||||
$l.setOp(new Ligneop());
|
||||
$l.getOp().setMontantReduction(new Float($l.getLineTotal()*0.2));
|
||||
$l.getOp().setNomOP("opPameprs");
|
||||
end
|
||||
|
||||
15
simpleWebApp/src/main/resources/application-context.xml
Normal file
15
simpleWebApp/src/main/resources/application-context.xml
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
|
||||
|
||||
<import resource="classpath:META-INF/cxf/cxf.xml" />
|
||||
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
|
||||
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
|
||||
|
||||
<!-- Spring manage ServiceBean -->
|
||||
<bean id="calculateService" class="droolscours.loyalty.ServiceCalculate" />
|
||||
|
||||
<!-- JAX-WS Service Endpoint -->
|
||||
<jaxws:endpoint id="personService" implementor="#calculateService" address="/calculateService" />
|
||||
|
||||
</beans>
|
||||
28
simpleWebApp/src/main/webapp/WEB-INF/web.xml
Normal file
28
simpleWebApp/src/main/webapp/WEB-INF/web.xml
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
|
||||
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
|
||||
|
||||
<display-name>CXF Example Webservice</display-name>
|
||||
|
||||
<listener>
|
||||
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
|
||||
</listener>
|
||||
|
||||
<context-param>
|
||||
<param-name>contextConfigLocation</param-name>
|
||||
<param-value>classpath:application-context.xml</param-value>
|
||||
</context-param>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>CXFServlet</servlet-name>
|
||||
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
</servlet>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>CXFServlet</servlet-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
</web-app>
|
||||
Loading…
Add table
editor.link_modal.header
Reference in a new issue