Initial
This commit is contained in:
commit
4dbaba5e48
80 changed files with 4193 additions and 0 deletions
|
|
@ -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