Skip to content

Commit

Permalink
Merge pull request #356 from OneBusAway/merge-camsys
Browse files Browse the repository at this point in the history
Merge camsys
  • Loading branch information
aaronbrethorst authored Jul 12, 2024
2 parents d2ec0af + b3813af commit 2df221f
Show file tree
Hide file tree
Showing 330 changed files with 257,397 additions and 983 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ jobs:
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn package -Ptravis -Dmaven.javadoc.skip=true -Dvalidate.silent=true -Dlog4j.configuration= -B -V -q
run: mvn -U clean install -Ptravis -Dhttps.protocols=TLSv1,TLSv1.1,TLSv1.2 -DskipTests=true -Dmaven.javadoc.skip=true -Dvalidate.silent=true -Dlog4j.configuration= -B -V -q
- name: Test with Maven
run: mvn test -Dlog4j.configuration=
8 changes: 4 additions & 4 deletions onebusaway-admin-webapp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.onebusaway</groupId>
<artifactId>onebusaway-application-modules</artifactId>
<version>2.2.1-SNAPSHOT</version>
<version>2.5.12-cs</version>
</parent>
<artifactId>onebusaway-admin-webapp</artifactId>
<packaging>war</packaging>
Expand Down Expand Up @@ -134,8 +134,8 @@
</dependency>
<!-- for amazon deployment -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
</dependency>
<dependency>
<groupId>org.tuckey</groupId>
Expand Down Expand Up @@ -369,7 +369,7 @@
<configuration>
<prefix>git</prefix>
<dateFormat>dd.MM.yyyy '@' HH:mm:ss z</dateFormat>
<verbose>true</verbose>
<verbose>false</verbose>
<skipPoms>false</skipPoms>
<generateGitPropertiesFile>false</generateGitPropertiesFile>
<generateGitPropertiesFilename>src/main/resources/git.properties</generateGitPropertiesFilename>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ public class RssServiceAlertsServiceImpl implements IntegratingServiceAlertsServ
private FeedMessage _feed = null;
private Locale _locale = null;

private int _refreshRate = 2; // minutes

@Autowired
public void setTransitDataService(TransitDataService tds) {
_transitDataService = tds;
Expand Down Expand Up @@ -98,7 +100,14 @@ public void setAlertSource(String source) {
public void setLocale(Locale locale) {
_locale = locale;
}


public void setRefreshRate(int rateInMinutes) {
this._refreshRate = rateInMinutes;
}
public int getRefreshRate() {
return _refreshRate;
}

public boolean isEnabled() {
return _serviceStatusUrlString != null && _serviceAdvisoryUrlString != null;
}
Expand All @@ -118,7 +127,7 @@ public void start() throws Exception {
// re-build internal route cache
_executor.scheduleAtFixedRate(new RefreshDataTask(), 0, 1, TimeUnit.HOURS);
// poll feed after cache is built above
_executor.scheduleAtFixedRate(new PollRssTask(), 1, 5, TimeUnit.MINUTES);
_executor.scheduleAtFixedRate(new PollRssTask(), 1, getRefreshRate(), TimeUnit.MINUTES);
}

@PreDestroy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,18 +239,18 @@ public String getStartDate() {
public void setStartDate(Date startDate) throws java.text.ParseException {
_startDate = startDate;

SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm");

Date time = null;
if (_startTime != null && !_startTime.isEmpty()) {
time = simpleDateFormat.parse(_startTime);
Calendar cal = Calendar.getInstance();
cal.setTime(time);
int hour = cal.get(Calendar.HOUR_OF_DAY);
int min = cal.get(Calendar.MINUTE);
setCombinedStartDate(((hour * 60) + min) * 60 * 1000);
}
else setCombinedStartDate(0);
try {
String[] timeparts = _startTime.split(":");
int hour = Integer.parseInt(timeparts[0]);
int min = Integer.parseInt(timeparts[1]);
setCombinedStartDate(hour, min);
} catch (Throwable t) {
_log.error("exception setting time {}", _startTime, t);
setCombinedStartDate(0, 0);
}
}
else setCombinedStartDate(0, 0);

}

Expand All @@ -267,21 +267,21 @@ public String getStartTime() {
public void setStartTime(String startTime) throws java.text.ParseException {
_startTime = startTime;

SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm");

Date time = null;
if (_startTime != null && !_startTime.isEmpty()) {
time = simpleDateFormat.parse(_startTime);
Calendar cal = Calendar.getInstance();
cal.setTime(time);
int hour = cal.get(Calendar.HOUR_OF_DAY);
int min = cal.get(Calendar.MINUTE);
setCombinedStartDate(((hour * 60) + min) * 60 * 1000);
try {
String[] timeparts = _startTime.split(":");
int hour = Integer.parseInt(timeparts[0]);
int min = Integer.parseInt(timeparts[1]);
setCombinedStartDate(hour, min);
} catch (Throwable t) {
_log.error("exception setting time {}", _startTime, t);
setCombinedStartDate(0, 0);
}
}
else setCombinedStartDate(0);
else setCombinedStartDate(0, 0);
}

private void setCombinedStartDate(long startTime) {
private void setCombinedStartDate(int hour, int min) {
List<TimeRangeBean> publicationWindows = _model.getPublicationWindows();
if (publicationWindows == null) {
publicationWindows = new ArrayList<TimeRangeBean>();
Expand All @@ -294,11 +294,11 @@ private void setCombinedStartDate(long startTime) {

TimeRangeBean timeRangeBean = publicationWindows.get(0);

if (startTime == 0 && _startDate != null) {//just have date
if (hour == 0 && min == 0 && _startDate != null) {//just have date
timeRangeBean.setFrom(_startDate.getTime());
}
else if(_startDate != null){//have both date and time
timeRangeBean.setFrom(_startDate.getTime() + startTime);
timeRangeBean.setFrom(addTime(_startDate, hour, min));
}
else{
timeRangeBean.setFrom(0);
Expand All @@ -309,7 +309,29 @@ else if(_startDate != null){//have both date and time
timeRangeBean.setFrom(timeRangeBean.getTo());
}
}


//// WMATA-609 support daylight savings time
private long addTime(Date startDate, int hour, int min) {
String prefix = new SimpleDateFormat("yyyy-MM-dd").format(startDate);
String dateStr = prefix + " " + lpad(hour) + ":" + lpad(min);
try {
Date parse = new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(dateStr);
return parse.getTime();
} catch (ParseException e) {
_log.error("unexpected date {}", dateStr, e);
return 0;
}
}

private String lpad(int t) {
String pad = "" + t;
if (pad.length() < 2)
pad = "0" + pad;
return pad;
}



public String getEndDate() {
List<TimeRangeBean> publicationWindows = _model.getPublicationWindows();
if(publicationWindows == null || publicationWindows.isEmpty() || publicationWindows.get(0).getTo() == 0){
Expand All @@ -323,18 +345,18 @@ public String getEndDate() {
public void setEndDate(Date endDate) throws java.text.ParseException {
_endDate = endDate;

SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm");

Date time = null;
if (_endTime != null && !_endTime.isEmpty()) {
time = simpleDateFormat.parse(_endTime);
Calendar cal = Calendar.getInstance();
cal.setTime(time);
int hour = cal.get(Calendar.HOUR_OF_DAY);
int min = cal.get(Calendar.MINUTE);
setCombinedEndDate(((hour * 60) + min) * 60 * 1000);
}
else setCombinedEndDate(0);
try {
String[] timeparts = _endTime.split(":");
int hour = Integer.parseInt(timeparts[0]);
int min = Integer.parseInt(timeparts[1]);
setCombinedEndDate(hour, min);
} catch (Throwable t) {
_log.error("exception setting time {}", _endTime, t);
setCombinedEndDate(0, 0);
}
}
else setCombinedEndDate(0, 0);

}

Expand All @@ -351,21 +373,21 @@ public String getEndTime() {
public void setEndTime(String endTime) throws java.text.ParseException {
_endTime = endTime;

SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm");

Date time = null;
if (_endTime != null && !_endTime.isEmpty()) {
time = simpleDateFormat.parse(_endTime);
Calendar cal = Calendar.getInstance();
cal.setTime(time);
int hour = cal.get(Calendar.HOUR_OF_DAY);
int min = cal.get(Calendar.MINUTE);
setCombinedEndDate(((hour * 60) + min) * 60 * 1000);
try {
String[] timeparts = _endTime.split(":");
int hour = Integer.parseInt(timeparts[0]);
int min = Integer.parseInt(timeparts[1]);
setCombinedEndDate(hour, min);
} catch (Throwable t) {
_log.error("exception setting time {}", _endTime, t);
setCombinedEndDate(0, 0);
}
}
else setCombinedEndDate(0);
else setCombinedEndDate(0, 0);
}

public void setCombinedEndDate(long endTime) {
public void setCombinedEndDate(int hour, int min) {
List<TimeRangeBean> publicationWindows = _model.getPublicationWindows();
if (publicationWindows == null) {
publicationWindows = new ArrayList<TimeRangeBean>();
Expand All @@ -378,11 +400,11 @@ public void setCombinedEndDate(long endTime) {

TimeRangeBean timeRangeBean = publicationWindows.get(0);

if (_endDate != null && endTime == 0) {
if (_endDate != null && hour == 0 && min == 0) {
timeRangeBean.setTo(_endDate.getTime());
}
else if(_endDate != null){
timeRangeBean.setTo(_endDate.getTime() + endTime);
timeRangeBean.setTo(addTime(_endDate, hour, min));
}
else{
timeRangeBean.setTo(0);
Expand Down
7 changes: 3 additions & 4 deletions onebusaway-admin-webapp/src/main/resources/data-sources.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@
-->
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">


<!-- Transit Data Service -->
Expand Down
20 changes: 10 additions & 10 deletions onebusaway-admin-webapp/src/main/resources/log4j2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

<!-- 0 or more appender elements -->
<Appenders>
<RollingFile name="ROLL" fileName="/opt/oba/logs/admin-webapp.log"
filePattern="/opt/oba/logs/admin-webapp.%d{yyyy-MM-dd}-%i.log.gz">
<RollingFile name="ROLL" fileName="/tmp/logs/admin-webapp.log"
filePattern="/tmp/logs/admin-webapp.%d{yyyy-MM-dd}-%i.log.gz">
<PatternLayout>
<Pattern>%d{ISO8601} %-5p [%F:%L] : %m%n</Pattern>
</PatternLayout>
Expand All @@ -39,14 +39,14 @@
</Appenders>

<Loggers>
<Logger name="org.hibernate.engine.internal.StatisticalLoggingSessionEventListener"
level="fatal"
additivity="false">
<AppenderRef ref="${log4j.appender}"/>
</Logger>
<Logger name="org.springframework.security.web.authentication.AnonymousAuthenticationFilter" level="debug" additivity="false">
<AppenderRef ref="${log4j.appender}"/>
</Logger>
<!-- <Logger name="org.hibernate.engine.internal.StatisticalLoggingSessionEventListener"-->
<!-- level="fatal"-->
<!-- additivity="false">-->
<!-- <AppenderRef ref="${log4j.appender}"/>-->
<!-- </Logger>-->
<!-- <Logger name="org.springframework.security.web.authentication.AnonymousAuthenticationFilter" level="debug" additivity="false">-->
<!-- <AppenderRef ref="${log4j.appender}"/>-->
<!-- </Logger>-->
<Root level="${log4j.priority}">
<AppenderRef ref="${log4j.appender}"/>
</Root>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.onebusaway.admin.service.assignments.impl;

import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onebusaway.admin.model.assignments.Assignment;
Expand Down Expand Up @@ -80,7 +81,11 @@ private Date laterPreviousServiceDate() {
}


@Test
@Test
public void emptyTest() {
return;
}
@Ignore
public void getAssignmentTest() {
Date currentServiceDate = currentServiceDate();
Date previousServiceDate = previousServiceDate();
Expand All @@ -103,7 +108,7 @@ public void getAssignmentTest() {

}

@Test
@Ignore
public void getAssignmentServiceDayChangeTest() {
Date currentServiceDate = currentServiceDate();
Date previousServiceDate = previousServiceDate();
Expand All @@ -128,7 +133,7 @@ public void getAssignmentServiceDayChangeTest() {

}

@Test
@Ignore
public void getAllTest() {

Date currentServiceDate = currentServiceDate();
Expand All @@ -155,7 +160,7 @@ public void getAllTest() {
assertEquals(0, assignmentList.size());
}

@Test
@Ignore
public void deleteTest() {

Date currentServiceDate = currentServiceDate();
Expand All @@ -179,7 +184,7 @@ public void deleteTest() {
assertNull(retrievedAssignment);
}

@Test
@Ignore
public void deleteAllTest() {

Date currentServiceDate = currentServiceDate();
Expand Down
Loading

0 comments on commit 2df221f

Please sign in to comment.