Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[incubator-kie-issues#1612] Fix BusinessCalendar behavior with inconsistent (full/partial) set of properties on calendar.properties #3788

Merged
merged 47 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
f47333c
incubator-kie-issues-1612
Abhitocode Nov 20, 2024
580313a
incubator-kie-issues-1612
Abhitocode Nov 20, 2024
2af0ea4
incubator-kie-issues-1612
Abhitocode Nov 21, 2024
bd4a633
Merge remote-tracking branch 'Abhitocode/incubator-kie-issues#1612' i…
Abhitocode Nov 21, 2024
8f9f231
Merge remote-tracking branch 'origin/main' into incubator-kie-issues#…
Nov 21, 2024
d3e3e1a
[incubator-kie-issues#1612] TODO setup
Nov 21, 2024
bd71ddc
Merge remote-tracking branch 'origin/main' into incubator-kie-issues#…
Nov 22, 2024
bb9f787
[incubator-kie-issues#1612] Separating different concerns in differen…
Nov 22, 2024
5b8fa04
incubator-kie-issues-1612
Abhitocode Nov 25, 2024
eeb406e
[incubator-kie-issues#1612] Example test
Nov 25, 2024
35bf3bb
incubator-kie-issues-1612
Abhitocode Nov 26, 2024
683290b
incubator-kie-issues-1612
Abhitocode Nov 27, 2024
f04993f
[incubator-kie-issues#1612] Extend test coverage. Minor refactoring r…
Nov 27, 2024
d6ac71e
incubator-kie-issues-1612
Abhitocode Nov 28, 2024
6f4a647
[incubator-kie-issues#1612] Comment on tests
Nov 28, 2024
352542d
[incubator-kie-issues#1612] Minor fixes
Nov 28, 2024
5735268
[incubator-kie-issues#1612] Extend test coverage. Minor refactoring r…
Nov 28, 2024
b8ef261
[incubator-kie-issues#1612] Minor refactoring
Nov 28, 2024
977b5cf
incubator-kie-issues-1612
Abhitocode Nov 29, 2024
6af2d9e
Merge remote-tracking branch 'origin/main' into incubator-kie-issues#…
Nov 29, 2024
7598827
[incubator-kie-issues#1612] Fixing tests. Including incubator-kie-iss…
Nov 29, 2024
cb32a67
[incubator-kie-issues#1612] WIP - implementing nightly hour
Nov 29, 2024
898f327
[incubator-kie-issues#1612] WIP - Simplify test - moving tested metho…
Nov 29, 2024
b01e8de
[incubator-kie-issues#1612] WIP - Cleanup
Nov 29, 2024
dfc594c
[incubator-kie-issues#1612] Working tests.
Nov 29, 2024
0f5c0b6
incubator-kie-issues-1612
Abhitocode Dec 2, 2024
73579b1
incubator-kie-issues-1612
Abhitocode Dec 2, 2024
7d8d1c9
incubator-kie-issues-1612
Abhitocode Dec 2, 2024
0ef21b2
Merge remote-tracking branch 'Abhitocode/incubator-kie-issues#1612' i…
Abhitocode Dec 2, 2024
dfbee16
[incubator-kie-issues#1612] Fixed logging
Dec 2, 2024
8e9a93b
[incubator-kie-issues#1612] Fixed minute/second reset on calendarRolling
Dec 2, 2024
ae9e082
[incubator-kie-issues#1612] Fixed assertiont JUnit5 -> assertj
Dec 2, 2024
a664e19
[incubator-kie-issues#1612] Fixed test
Dec 2, 2024
6136ad2
Merge remote-tracking branch 'origin/main' into Abhitocode_incubator-…
Dec 2, 2024
7ef7f11
incubator-kie-issues-1612
Abhitocode Dec 2, 2024
73269e8
Merge remote-tracking branch 'origin/main' into incubator-kie-issues#…
Dec 3, 2024
2850074
Merge remote-tracking branch 'origin/main' into incubator-kie-issues#…
Abhitocode Dec 3, 2024
b4f5138
Merge branch 'Abhitocode_incubator-kie-issues#1612' into incubator-ki…
Dec 3, 2024
815e450
incubator-kie-issues-1612
Abhitocode Dec 4, 2024
887f7f9
Merge remote-tracking branch 'Abhitocode/incubator-kie-issues#1612' i…
Dec 5, 2024
e8f52b3
[incubator-kie-issues#1612] Avoid minute/second reset on rolling hour…
Dec 5, 2024
670e4f8
[incubator-kie-issues#1612] Fix naming
Dec 5, 2024
dc0702b
[incubator-kie-issues#1612] Add minute / second test/fix
Dec 5, 2024
a861c0b
[incubator-kie-issues#1612] Extend test coverage
Dec 5, 2024
59fb324
updated logging
Abhitocode Dec 6, 2024
790b177
logger update
Abhitocode Dec 9, 2024
c0df20d
logger update
Abhitocode Dec 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,21 @@
public interface BusinessCalendar {

/**
* Calculates given time expression into duration in milliseconds based on calendar configuration.
*
* Returns the difference, in milliseconds, between the <b>business date</b> that matches the given
* <code>timeExpression</code>, and the current time.
* See {@link #calculateBusinessTimeAsDate} for <b>business date</b> calculation
*
* @param timeExpression time expression that is supported by business calendar implementation.
* @return duration expressed in milliseconds
*/
public long calculateBusinessTimeAsDuration(String timeExpression);
long calculateBusinessTimeAsDuration(String timeExpression);

/**
* Calculates given time expression into target date based on calendar configuration.
* Returns the first <code>Date</code> that matches the given <code>timeExpression</code> and falls
* into the business calendar working hours.
*
* @param timeExpression time expression that is supported by business calendar implementation.
* @return date when given time expression will match in the future
*/
public Date calculateBusinessTimeAsDate(String timeExpression);
Date calculateBusinessTimeAsDate(String timeExpression);
}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 org.jbpm.process.core.timer;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Objects;
import java.util.Properties;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static org.jbpm.process.core.constants.CalendarConstants.BUSINESS_CALENDAR_PATH;

public class CalendarBeanFactory {

private static final Logger logger = LoggerFactory.getLogger(CalendarBeanFactory.class);

public static CalendarBean createCalendarBean() {
logger.debug("createCalendarBean");
URL resource = Thread.currentThread().getContextClassLoader().getResource(BUSINESS_CALENDAR_PATH);
if (Objects.nonNull(resource)) {
logger.debug("URL resource: {}", resource);
Properties calendarConfiguration = new Properties();
try (InputStream is = resource.openStream()) {
calendarConfiguration.load(is);
return new CalendarBean(calendarConfiguration);
} catch (IOException e) {
String errorMessage = "Error while loading properties for business calendar";
logger.error(errorMessage, e);
throw new RuntimeException(errorMessage, e);
} catch (IllegalArgumentException e) {
String errorMessage = "Error while populating properties for business calendar";
logger.error(errorMessage, e);
throw e;
}
} else {
String errorMessage = String.format("Missing %s", BUSINESS_CALENDAR_PATH);
logger.error(errorMessage);
throw new RuntimeException(errorMessage);
}
}
}
Loading
Loading