Skip to content

Commit

Permalink
Merge pull request #1176 from US-CBP/Release1.1.3
Browse files Browse the repository at this point in the history
Release1.1.3
  • Loading branch information
originalname51 authored Jun 5, 2019
2 parents 7631bcc + c2e85bd commit 9dc414d
Show file tree
Hide file tree
Showing 70 changed files with 131 additions and 7,893 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class GraphRule extends BaseEntityAudit {
@Column(name = "title")
private String title;

@Column(name = "cipherQuery")
@Column(name = "cipherQuery", length = 10000)
private String cipherQuery;

@OneToMany(mappedBy = "graphRule")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,21 @@ public Pair<Long, List<Flight>> findByCriteria(FlightsRequestDto dto) {
}
if ("desc".equalsIgnoreCase(sort.getDir())) {
for (Expression<?> e : orderByItem) {
if ("fuzzyHitCount".equalsIgnoreCase(sort.getColumn()) || "graphHitCount".equalsIgnoreCase(sort.getColumn())
|| "ruleHitCount".equalsIgnoreCase(sort.getColumn()) || "listHitCount".equalsIgnoreCase(sort.getColumn())) {
orderList.add(cb.desc(cb.coalesce(e, 0)));
} else {
orderList.add(cb.desc(e));
}
}
} else {
for (Expression<?> e : orderByItem) {
orderList.add(cb.asc(e));
if ("fuzzyHitCount".equalsIgnoreCase(sort.getColumn()) || "graphHitCount".equalsIgnoreCase(sort.getColumn())
|| "ruleHitCount".equalsIgnoreCase(sort.getColumn()) || "listHitCount".equalsIgnoreCase(sort.getColumn())) {
orderList.add(cb.asc(cb.coalesce(e, 0)));
} else {
orderList.add(cb.asc(e));
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ public List<UdrRule> findByDeletedAndEnabled(
@Param("deleted") YesNoEnum deleted,
@Param("enabled") YesNoEnum enabled);

@Query("SELECT udr FROM Rule r, UdrRule udr WHERE r.id =:ruleId AND udr.id = r.parent")
public UdrRule findUdrRuleByRuleId (
@Param("ruleId") Long ruleId);

default UdrRule findOne(Long id)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
package gov.gtas.services;

import gov.gtas.model.lookup.AppConfiguration;
import java.util.Date;


public interface AppConfigurationService
{

public AppConfiguration findByOption(String option);

public AppConfiguration save(AppConfiguration appConfig);
public AppConfiguration save(AppConfiguration appConfig);

public Date offSetTimeZone(Date date);

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
import javax.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.Calendar;
import java.util.Date;

/**
*
* @author gbays
Expand All @@ -29,6 +32,17 @@ public AppConfiguration findByOption(String option)
return appConfig;

}

public Date offSetTimeZone(Date date) {
if (date == null) {
return null;
}
int hour_offset = Integer.parseInt(appConfigurationRepository.findByOption(AppConfigurationRepository.HOURLY_ADJ).getValue());
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.HOUR_OF_DAY, hour_offset);
return calendar.getTime();
}

@Override
public AppConfiguration save(AppConfiguration appConfig)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ public class CaseDispositionServiceImpl implements CaseDispositionService {
private PassengerResolverService passengerResolverService;
@Resource
private AppConfigurationRepository appConfigurationRepository;
@Autowired
private AppConfigurationService appConfigurationService;

public CaseDispositionServiceImpl() {
}
Expand Down Expand Up @@ -475,7 +477,7 @@ private Long getHighPriorityRuleCatId(Long ruleId) {

private Long getRuleCatId(Long ruleId) {
try {
return ruleCatService.fetchRuleCatIdFromRuleId(ruleId);
return ruleCatService.fetchRuleCatIdFromNonUdrRuleId(ruleId);
} catch (Exception ex) {
logger.error("error in get rule cat id", ex);
}
Expand Down Expand Up @@ -802,7 +804,7 @@ private CaseVo calculateCountDownDisplayString(CaseVo caseVo) {
if (Boolean.parseBoolean(appConfigurationRepository.findByOption(AppConfigurationRepository.UTC_SERVER).getValue())) {
caseVo.setCurrentTime(new Date());
} else {
caseVo.setCurrentTime(offSetTimeZone(new Date()));
caseVo.setCurrentTime(appConfigurationService.offSetTimeZone(new Date()));
}
Long currentTimeMillis = caseVo.getCurrentTime().getTime();
Long countDownMillis = etdEtaDateTime.getTime() - currentTimeMillis;
Expand All @@ -823,20 +825,14 @@ private CaseVo calculateCountDownDisplayString(CaseVo caseVo) {
return caseVo;
}

private Date offSetTimeZone(Date caseDate) {
int hour_offset = Integer.parseInt(appConfigurationRepository.findByOption(AppConfigurationRepository.HOURLY_ADJ).getValue());
Calendar calendar = Calendar.getInstance();
calendar.setTime(caseDate);
calendar.add(Calendar.HOUR_OF_DAY, hour_offset);
return calendar.getTime();
}


@Override
public Date getCurrentServerTime() {
if (Boolean.parseBoolean(appConfigurationRepository.findByOption(AppConfigurationRepository.UTC_SERVER).getValue())) {
return new Date();
} else {
return offSetTimeZone(new Date());
return appConfigurationService.offSetTimeZone(new Date());
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.function.Predicate;
import java.util.stream.Collectors;

import javax.annotation.Resource;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

Expand Down Expand Up @@ -74,6 +75,7 @@ public List<FlightVo> convertFlightToFlightVo(List<Flight> flights) {
List<CodeShareVo> codeshareList = new ArrayList<>();
BeanUtils.copyProperties(f, vo);
BeanUtils.copyProperties(f.getMutableFlightDetails(), vo);

Integer fuzzyHits = 0;

if (f.getFlightHitsFuzzy() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ public class PassengerServiceImpl implements PassengerService {
@Autowired
FlightPaxRepository flightPaxRepository;

@Autowired
AppConfigurationService appConfigurationService;

@Override
@Transactional
public Passenger create(Passenger passenger) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@ public interface RuleCatService {
Long fetchRuleCatPriorityIdFromRuleId(Long ruleId) throws Exception;

Long fetchRuleCatIdFromRuleId(Long ruleId) throws Exception;

Long fetchRuleCatIdFromNonUdrRuleId(Long ruleId) throws Exception;

}
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,29 @@ public Long fetchRuleCatIdFromRuleId(Long ruleId) {
}

}

@Override
@Cacheable("ruleCategoryCache")
public Long fetchRuleCatIdFromNonUdrRuleId(Long ruleId) {

UdrRule _tempRule = udrRuleRepository.findUdrRuleByRuleId(ruleId);

RuleCat _tempRuleCat = null;
if(_tempRule!=null){
Set<RuleCat> _tempRuleCatSet = _tempRule.getMetaData().getRuleCategories();

_tempRuleCat = _tempRuleCatSet.stream()
.findFirst()
.orElse(null);
if(_tempRuleCat==null)return 1L; // bracket orphans to 'General' rule category
else return _tempRuleCat.getCatId();

}else {
// bracket orphans to 'General' rule category
return 1L;
}

}


}
Original file line number Diff line number Diff line change
Expand Up @@ -335,11 +335,16 @@ public int findMatchesBasedOnTimeThreshold(List<MessageStatus> messageStatuses)
PassengerWLTimestamp passengerWLTimestamp;
if (passenger.getPassengerWLTimestamp() == null) {
passengerWLTimestamp = new PassengerWLTimestamp(passenger.getId(), new Date());
passengerWLTimestamp.setHitCount(fuzzyHitCounts);
} else {
passengerWLTimestamp = passenger.getPassengerWLTimestamp();
passengerWLTimestamp.setWatchlistCheckTimestamp(new Date());
if (passengerWLTimestamp.getHitCount() != null) {
passengerWLTimestamp.setHitCount(passengerWLTimestamp.getHitCount() + fuzzyHitCounts);
} else {
passengerWLTimestamp.setHitCount(fuzzyHitCounts);
}
}
passengerWLTimestamp.setHitCount(fuzzyHitCounts);
if (fuzzyHitCounts > 0) {
totalMatchCount++;
}
Expand All @@ -361,7 +366,7 @@ public int findMatchesBasedOnTimeThreshold(List<MessageStatus> messageStatuses)
endTime = System.nanoTime();
int paxTotal = passengers == null ? 0 : passengers.size();
logger.debug("Passenger hit count and total run: " + totalMatchCount + " " + paxTotal);
logger.debug("Execution time for performFuzzyMatching() for loop = " + (endTime - startTime) / 1000000
logger.info("Execution time for performFuzzyMatching() for loop = " + (endTime - startTime) / 1000000
+ "ms");
return totalMatchCount;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,19 +236,16 @@ public List<UdrRule> findValidUdrOnDate(Date targetDate) {
}

@Override
@Cacheable(value = "knowledgebase")
public KnowledgeBase findUdrKnowledgeBase() {
return this.findUdrKnowledgeBase(RuleConstants.UDR_KNOWLEDGE_BASE_NAME);
}

@Override
@Cacheable(value = "knowledgebase")
public KnowledgeBase findUdrKnowledgeBase(String kbName) {
return udrRuleRepository.getKnowledgeBaseByName(kbName);
}

@Override
@CacheEvict(value = "knowledgebase", allEntries = true)
public KnowledgeBase saveKnowledgeBase(KnowledgeBase kb) {
kb.setCreationDt(new Date());
if (kb.getId() == null) {
Expand All @@ -260,7 +257,6 @@ public KnowledgeBase saveKnowledgeBase(KnowledgeBase kb) {
}

@Override
@CacheEvict(value = "knowledgebase", allEntries = true)
public KnowledgeBase deleteKnowledgeBase(String kbName) {
KnowledgeBase kb = findUdrKnowledgeBase(kbName);
if (kb != null) {
Expand Down
Loading

0 comments on commit 9dc414d

Please sign in to comment.