Ajouter examples

This commit is contained in:
Nicolas Héron 2018-08-31 17:05:24 +02:00
commit 25975a0767
527 changed files with 201926 additions and 5 deletions

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<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/java" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: joda-time:joda-time:1.6.2" level="project" />
</component>
</module>

View file

@ -0,0 +1,41 @@
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
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.pymmasoftware.jbpm</groupId>
<artifactId>drools-framework-examples</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>drools-framework-loyalty-model</artifactId>
<name>demopojo</name>
<description>demopojo</description>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>1.6.2</version>
</dependency>
</dependencies>
</project>

View file

@ -0,0 +1,73 @@
/*
* Copyright 2014 Pymma Software
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package loyalty.domains;
public class Card {
private String number;
private String name;
private Customer customer;
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 Card() {
super();
// TODO Auto-generated constructor stub
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCartType() {
return cartType;
}
public void setCartType(String cartType) {
this.cartType = cartType;
}
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
}
public Customer getCustomer() {
return customer;
}
public void setCustomer(Customer customer) {
this.customer = customer;
}
}

View file

@ -0,0 +1,20 @@
/*
* Copyright 2014 Pymma Software
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package loyalty.domains;
public enum Currency {
Euro, Dollar, Yen
}

View file

@ -0,0 +1,94 @@
/*
* Copyright 2014 Pymma Software
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package loyalty.domains;
import javax.xml.bind.annotation.XmlElement;
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 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
}
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;
}
@XmlElement(type = Date.class)
public Date getBirthDate() {
return birthDate;
}
public void setBirthDate(Date birthDate) {
this.birthDate = birthDate;
}
}

View file

@ -0,0 +1,20 @@
/*
* Copyright 2014 Pymma Software
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package loyalty.domains;
public enum Gender {
Mr, Mrs, Miss
}

View file

@ -0,0 +1,43 @@
/*
* Copyright 2014 Pymma Software
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package loyalty.domains;
public class Ligneop {
private String nomOP;
private Float montantReduction;
public Ligneop() {
super();
// TODO Auto-generated constructor stub
}
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;
}
}

View file

@ -0,0 +1,50 @@
/*
* Copyright 2014 Pymma Software
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package loyalty.domains;
public class Price {
private Float price;
private Currency currency;
public Price(Float price, Currency currency) {
super();
this.price = price;
this.currency = currency;
}
public Price() {
super();
// TODO Auto-generated constructor stub
}
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;
}
}

View file

@ -0,0 +1,69 @@
/*
* Copyright 2014 Pymma Software
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package loyalty.domains;
public class Product {
private String Id;
private String Name;
private Price price;
private 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
}
public Price getPrice() {
return price;
}
public void setPrice(Price price) {
this.price = price;
}
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;
}
}

View file

@ -0,0 +1,49 @@
/*
* Copyright 2014 Pymma Software
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package loyalty.domains;
public class Provider {
private String name;
private String country;
public Provider(String name, String country) {
super();
this.name = name;
this.country = country;
}
public Provider() {
super();
// TODO Auto-generated constructor stub
}
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;
}
}

View file

@ -0,0 +1,99 @@
/*
* Copyright 2014 Pymma Software
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package loyalty.domains;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class Ticket {
private String Id;
private Date dateTicket;
private Float amount;
private Card loyaltyCard;
private Customer customer;
private List<TicketLine> ticketLines = new ArrayList<TicketLine>();
public Ticket() {
super();
// TODO Auto-generated constructor stub
}
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 getDateTicket() {
return dateTicket;
}
public void setDateTicket(Date date) {
this.dateTicket = date;
}
public long AddLine(Product product, Float price, long quantity) {
TicketLine newLine = new TicketLine(null, 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 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;
}
}

View file

@ -0,0 +1,138 @@
/*
* Copyright 2014 Pymma Software
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package 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;
private boolean valid;
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 TicketLine() {
super();
// TODO Auto-generated constructor stub
}
public static int getNumberLines() {
return numberLines;
}
public static void setNumberLines(int numberLines) {
TicketLine.numberLines = numberLines;
}
public Ligneop getOp() {
return op;
}
public void setOp(Ligneop op) {
this.op = 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 int getLineNumber() {
return lineNumber;
}
public void setLineNumber(int lineNumber) {
this.lineNumber = lineNumber;
}
public Float getLineTotal() {
return lineTotal;
}
public void setLineTotal(Float lineTotal) {
this.lineTotal = 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 void setQuantity(long quantity) {
this.quantity = quantity;
}
public Float getPrice() {
return price;
}
public void setPrice(Float price) {
this.price = price;
}
public void AddProductToTicketLine(Product p) {
this.product = p;
}
}