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

feat: support Activiti IdGenerator Based on CosId. #464

Merged
merged 2 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 19 additions & 0 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,25 @@ jobs:
- name: Test CosId-Axon
run: ./gradlew cosid-axon:clean cosid-axon:check

cosid-activiti-test:
name: CosId Activiti Test
needs: [ cosid-core-test ]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
server-id: github
settings-path: ${{ github.workspace }}

- name: Test CosId-Activiti
run: ./gradlew cosid-activiti:clean cosid-activiti:check

cosid-flowable-test:
name: CosId Flowable Test
needs: [ cosid-core-test ]
Expand Down
6 changes: 6 additions & 0 deletions cosid-activiti/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies {
implementation(libs.activitiEngine)
api(project(":cosid-core"))
testImplementation(project(":cosid-test"))

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].
* 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 me.ahoo.cosid.activiti;

import me.ahoo.cosid.provider.IdGeneratorProvider;
import me.ahoo.cosid.provider.LazyIdGenerator;

/**
* Activiti IdGenerator Based on CosId.
*/
public class ActivitiIdGenerator implements org.activiti.engine.impl.cfg.IdGenerator {
/**
* The key of the system property that can be used to set the id generator name.
*/
public static final String ID_KEY = "cosid.activiti";
private static final String ID_NAME;
private static final LazyIdGenerator ID_GENERATOR;

static {
ID_NAME = System.getProperty(ID_KEY, IdGeneratorProvider.SHARE);
ID_GENERATOR = new LazyIdGenerator(ID_NAME);
}

public String getNextId() {
return ID_GENERATOR.generateAsString();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].
* 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 me.ahoo.cosid.activiti;

import static me.ahoo.cosid.activiti.ActivitiIdGenerator.ID_KEY;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;

import me.ahoo.cosid.provider.DefaultIdGeneratorProvider;
import me.ahoo.cosid.test.MockIdGenerator;

import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.SetSystemProperty;

class ActivitiIdGeneratorTest {

@SetSystemProperty(key = ID_KEY, value = "activiti")
@Test
void getNextId() {
DefaultIdGeneratorProvider.INSTANCE.set("activiti", MockIdGenerator.usePrefix("activiti_"));
String id = new ActivitiIdGenerator().getNextId();
assertThat(id, startsWith("activiti_"));
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# limitations under the License.
#
group=me.ahoo.cosid
version=2.5.5
version=2.5.6
description=Universal, flexible, high-performance distributed ID generator.
website=https://github.com/Ahoo-Wang/CosId
issues=https://github.com/Ahoo-Wang/CosId/issues
Expand Down
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ mybatisSpringBoot = "3.0.2"
junitPioneer = "2.1.0"
axon = "4.9.0"
flowable = "6.8.0"
activiti = "6.0.0"
springDoc = "2.2.0"
hamcrest = "2.2"
mockk = "1.13.8"
Expand All @@ -33,6 +34,7 @@ springDocStarterWebfluxUi = { module = "org.springdoc:springdoc-openapi-starter-
flowableEngineCommon = { module = "org.flowable:flowable-engine-common", version.ref = "flowable" }
flowableSpring = { module = "org.flowable:flowable-spring", version.ref = "flowable" }
flowableSpringBootAutoconfigure = { module = "org.flowable:flowable-spring-boot-autoconfigure", version.ref = "flowable" }
activitiEngine = { module = "org.activiti:activiti-engine", version.ref = "activiti" }
junitPioneer = { module = "org.junit-pioneer:junit-pioneer", version.ref = "junitPioneer" }
hamcrest = { module = "org.hamcrest:hamcrest", version.ref = "hamcrest" }
mockk = { module = "io.mockk:mockk", version.ref = "mockk" }
Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ include(":cosid-proxy")
include(":cosid-proxy-server")
include(":cosid-axon")
include(":cosid-flowable")
include(":cosid-activiti")
include(":cosid-mongo")
include(":cosid-spring-data-jdbc")
include(":code-coverage-report")
Expand Down
Loading