Merge branch 'release/release-1.3.1'
This commit is contained in:
commit
dcb1c1539a
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>org.sadtech.autoresponder</groupId>
|
<groupId>org.sadtech.autoresponder</groupId>
|
||||||
<artifactId>autoresponder</artifactId>
|
<artifactId>autoresponder</artifactId>
|
||||||
<version>1.3.0-RELEASE</version>
|
<version>1.3.1-RELEASE</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
@ -8,10 +8,7 @@ import org.sadtech.autoresponder.service.PersonService;
|
|||||||
import org.sadtech.autoresponder.service.UnitService;
|
import org.sadtech.autoresponder.service.UnitService;
|
||||||
import org.sadtech.autoresponder.submodule.parser.Parser;
|
import org.sadtech.autoresponder.submodule.parser.Parser;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@ -22,6 +19,14 @@ public class Autoresponder {
|
|||||||
private UnitService unitService;
|
private UnitService unitService;
|
||||||
private PersonService personService;
|
private PersonService personService;
|
||||||
|
|
||||||
|
public PersonService getPersonService() {
|
||||||
|
return personService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPersonService(PersonService personService) {
|
||||||
|
this.personService = personService;
|
||||||
|
}
|
||||||
|
|
||||||
public Autoresponder(UnitService unitService, PersonService personService) {
|
public Autoresponder(UnitService unitService, PersonService personService) {
|
||||||
this.unitService = unitService;
|
this.unitService = unitService;
|
||||||
this.personService = personService;
|
this.personService = personService;
|
||||||
@ -56,7 +61,7 @@ public class Autoresponder {
|
|||||||
return person;
|
return person;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Unit nextUnit(List<Unit> nextUnits, String message) {
|
private Unit nextUnit(Set<Unit> nextUnits, String message) {
|
||||||
if (nextUnits.size() > 0) {
|
if (nextUnits.size() > 0) {
|
||||||
UnitPriorityComparator unitPriorityComparator = new UnitPriorityComparator();
|
UnitPriorityComparator unitPriorityComparator = new UnitPriorityComparator();
|
||||||
Optional<Unit> patternUnits = nextUnits.stream().filter(nextUnit -> nextUnit.getPattern() != null).filter(nextUnit -> patternReg(nextUnit, message)).max(unitPriorityComparator);
|
Optional<Unit> patternUnits = nextUnits.stream().filter(nextUnit -> nextUnit.getPattern() != null).filter(nextUnit -> patternReg(nextUnit, message)).max(unitPriorityComparator);
|
||||||
@ -91,6 +96,7 @@ public class Autoresponder {
|
|||||||
if (unit.getKeyWords() != null) {
|
if (unit.getKeyWords() != null) {
|
||||||
Set<String> temp = new HashSet<>(unit.getKeyWords());
|
Set<String> temp = new HashSet<>(unit.getKeyWords());
|
||||||
temp.retainAll(words);
|
temp.retainAll(words);
|
||||||
|
log.info("Юнит: " + unit.getClass().getSimpleName());
|
||||||
log.info("Ключевые слова юнита: " + unit.getKeyWords() + " (" + unit.getKeyWords().size() + ")");
|
log.info("Ключевые слова юнита: " + unit.getKeyWords() + " (" + unit.getKeyWords().size() + ")");
|
||||||
log.info("Ключевые слова от пользователя: " + words);
|
log.info("Ключевые слова от пользователя: " + words);
|
||||||
log.info("Пересечение: " + temp + " (" + temp.size() + ")");
|
log.info("Пересечение: " + temp + " (" + temp.size() + ")");
|
||||||
|
@ -6,10 +6,12 @@ public class Person {
|
|||||||
|
|
||||||
private Integer id;
|
private Integer id;
|
||||||
private Unit unit;
|
private Unit unit;
|
||||||
|
private Boolean replyStatus;
|
||||||
|
|
||||||
public Person(Integer id, Unit unit) {
|
public Person(Integer id, Unit unit) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.unit = unit;
|
this.unit = unit;
|
||||||
|
replyStatus = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Person(Integer id) {
|
public Person(Integer id) {
|
||||||
@ -32,6 +34,14 @@ public class Person {
|
|||||||
this.unit = unit;
|
this.unit = unit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean getReplyStatus() {
|
||||||
|
return replyStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReplyStatus(Boolean replyStatus) {
|
||||||
|
this.replyStatus = replyStatus;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
|
@ -9,14 +9,14 @@ public abstract class Unit {
|
|||||||
private Pattern pattern;
|
private Pattern pattern;
|
||||||
private Integer matchThreshold;
|
private Integer matchThreshold;
|
||||||
private Integer priority;
|
private Integer priority;
|
||||||
private List<Unit> nextUnits;
|
private Set<Unit> nextUnits;
|
||||||
|
|
||||||
public Unit() {
|
public Unit() {
|
||||||
priority = 10;
|
priority = 10;
|
||||||
matchThreshold = 10;
|
matchThreshold = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Unit(Set<String> keyWords, Pattern pattern, Integer matchThreshold, Integer priority, List<Unit> nextUnits) {
|
public Unit(Set<String> keyWords, Pattern pattern, Integer matchThreshold, Integer priority, Set<Unit> nextUnits) {
|
||||||
this.keyWords = keyWords;
|
this.keyWords = keyWords;
|
||||||
this.pattern = pattern;
|
this.pattern = pattern;
|
||||||
this.matchThreshold = matchThreshold;
|
this.matchThreshold = matchThreshold;
|
||||||
@ -33,7 +33,7 @@ public abstract class Unit {
|
|||||||
|
|
||||||
public void setNextUnit(Unit unit) {
|
public void setNextUnit(Unit unit) {
|
||||||
if (nextUnits == null) {
|
if (nextUnits == null) {
|
||||||
nextUnits = new ArrayList<>();
|
nextUnits = new HashSet<>();
|
||||||
}
|
}
|
||||||
nextUnits.add(unit);
|
nextUnits.add(unit);
|
||||||
}
|
}
|
||||||
@ -62,11 +62,11 @@ public abstract class Unit {
|
|||||||
this.priority = priority;
|
this.priority = priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Unit> getNextUnits() {
|
public Set<Unit> getNextUnits() {
|
||||||
return nextUnits;
|
return nextUnits;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNextUnits(List<Unit> nextUnits) {
|
public void setNextUnits(Set<Unit> nextUnits) {
|
||||||
this.nextUnits = nextUnits;
|
this.nextUnits = nextUnits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package org.sadtech.autoresponder.repository;
|
|||||||
import org.sadtech.autoresponder.entity.Unit;
|
import org.sadtech.autoresponder.entity.Unit;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public interface UnitRepository {
|
public interface UnitRepository {
|
||||||
|
|
||||||
@ -10,6 +11,6 @@ public interface UnitRepository {
|
|||||||
|
|
||||||
void addUnits(List<Unit> units);
|
void addUnits(List<Unit> units);
|
||||||
|
|
||||||
List<Unit> menuUnits();
|
Set<Unit> menuUnits();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
package org.sadtech.autoresponder.service;
|
package org.sadtech.autoresponder.service;
|
||||||
|
|
||||||
import org.sadtech.autoresponder.entity.Unit;
|
import org.sadtech.autoresponder.entity.Unit;
|
||||||
import org.sadtech.autoresponder.repository.UnitRepository;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.Set;
|
||||||
|
|
||||||
public interface UnitService {
|
public interface UnitService {
|
||||||
|
|
||||||
List<Unit> menuUnit();
|
Set<Unit> menuUnit();
|
||||||
|
|
||||||
void addUnit(Unit unit);
|
void addUnit(Unit unit);
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package org.sadtech.autoresponder.service.impl;
|
|||||||
|
|
||||||
import org.sadtech.autoresponder.entity.Person;
|
import org.sadtech.autoresponder.entity.Person;
|
||||||
import org.sadtech.autoresponder.repository.PersonRepository;
|
import org.sadtech.autoresponder.repository.PersonRepository;
|
||||||
|
import org.sadtech.autoresponder.repository.impl.PersonRepositoryMap;
|
||||||
import org.sadtech.autoresponder.service.PersonService;
|
import org.sadtech.autoresponder.service.PersonService;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
@ -12,6 +13,10 @@ public class PersonServiceImpl implements PersonService {
|
|||||||
|
|
||||||
private PersonRepository personRepository;
|
private PersonRepository personRepository;
|
||||||
|
|
||||||
|
public PersonServiceImpl() {
|
||||||
|
this.personRepository = new PersonRepositoryMap();
|
||||||
|
}
|
||||||
|
|
||||||
public PersonServiceImpl(PersonRepository personRepository) {
|
public PersonServiceImpl(PersonRepository personRepository) {
|
||||||
this.personRepository = personRepository;
|
this.personRepository = personRepository;
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,7 @@ import org.sadtech.autoresponder.entity.Unit;
|
|||||||
import org.sadtech.autoresponder.repository.UnitRepository;
|
import org.sadtech.autoresponder.repository.UnitRepository;
|
||||||
import org.sadtech.autoresponder.service.UnitService;
|
import org.sadtech.autoresponder.service.UnitService;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.Set;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class UnitServiceImpl implements UnitService {
|
public class UnitServiceImpl implements UnitService {
|
||||||
|
|
||||||
@ -19,7 +18,7 @@ public class UnitServiceImpl implements UnitService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Unit> menuUnit() {
|
public Set<Unit> menuUnit() {
|
||||||
return unitRepository.menuUnits();
|
return unitRepository.menuUnits();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user