-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for migrating historic case instances
- Loading branch information
1 parent
cd6ca22
commit bc5c13e
Showing
23 changed files
with
1,691 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
...i/src/main/java/org/flowable/cmmn/api/migration/HistoricCaseInstanceMigrationBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
/* 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 org.flowable.cmmn.api.migration; | ||
|
||
import org.flowable.batch.api.Batch; | ||
|
||
public interface HistoricCaseInstanceMigrationBuilder { | ||
|
||
/** | ||
* Creates a HistoricCaseInstanceMigrationBuilder using the values of a HistoricCaseInstanceMigrationDocument | ||
* | ||
* @param historicCaseInstanceMigrationDocument Migration document with pre-filled case information | ||
* @return Returns the builder | ||
* @see HistoricCaseInstanceMigrationDocument | ||
*/ | ||
HistoricCaseInstanceMigrationBuilder fromHistoricCaseInstanceMigrationDocument(HistoricCaseInstanceMigrationDocument caseInstanceMigrationDocument); | ||
|
||
/** | ||
* Specifies the case definition to migrate to, using the case definition id | ||
* | ||
* @param caseDefinitionId ID of the case definition to migrate to | ||
* @return Returns the builder | ||
* @see org.flowable.cmmn.api.repository.CaseDefinition | ||
*/ | ||
HistoricCaseInstanceMigrationBuilder migrateToCaseDefinition(String caseDefinitionId); | ||
|
||
/** | ||
* Specifies the case definition to migrate to, identified by its key and version | ||
* | ||
* @param caseDefinitionKey Key of the case definition to migrate to | ||
* @param caseDefinitionVersion Version of the case to migrate to | ||
* @return Returns the builder | ||
* @see org.flowable.cmmn.api.repository.CaseDefinition | ||
*/ | ||
HistoricCaseInstanceMigrationBuilder migrateToCaseDefinition(String caseDefinitionKey, int caseDefinitionVersion); | ||
|
||
/** | ||
* Specifies the case definition to migrate to, identified by its key and version and tenantId | ||
* | ||
* @param caseDefinitionKey Key of the case definition to migrate to | ||
* @param caseDefinitionVersion Version of the case to migrate to | ||
* @param caseDefinitionTenantId Tenant id of the case definition, must be part of the same tenant | ||
* @return Returns the builder | ||
* @see org.flowable.cmmn.api.repository.CaseDefinition | ||
*/ | ||
HistoricCaseInstanceMigrationBuilder migrateToCaseDefinition(String caseDefinitionKey, int caseDefinitionVersion, String caseDefinitionTenantId); | ||
|
||
/** | ||
* Specifies the tenantId of the case definition to migrate to | ||
* | ||
* @param caseDefinitionTenantId Tenant id of the case definition, must be part of the same tenant | ||
* @return Returns the builder | ||
*/ | ||
HistoricCaseInstanceMigrationBuilder withMigrateToCaseDefinitionTenantId(String caseDefinitionTenantId); | ||
|
||
/** | ||
* Builds a HistoricCaseInstanceMigrationDocument | ||
* | ||
* @return Returns the builder | ||
* @see HistoricCaseInstanceMigrationDocument | ||
*/ | ||
HistoricCaseInstanceMigrationDocument getHistoricCaseInstanceMigrationDocument(); | ||
|
||
/** | ||
* Starts the case instance migration for a case identified with the submitted caseInstanceId | ||
* | ||
* @param caseInstanceId | ||
*/ | ||
void migrate(String caseInstanceId); | ||
|
||
/** | ||
* Asynchronously starts the case instance migration for each case instances of a given case definition identified by the case definition id. | ||
* | ||
* @param caseDefinitionId | ||
*/ | ||
void migrateHistoricCaseInstances(String caseDefinitionId); | ||
|
||
/** | ||
* Starts the case instance migration for all case instances of a given case definition identified by the case definition id. | ||
* | ||
* @param caseDefinitionId | ||
*/ | ||
Batch batchMigrateHistoricCaseInstances(String caseDefinitionId); | ||
|
||
/** | ||
* Starts the case instance migration for all case instances of a given case definition identified by the case definition key and version (optional tenantId). | ||
* | ||
* @param caseDefinitionKey | ||
* @param caseDefinitionVersion | ||
* @param caseDefinitionTenantId | ||
*/ | ||
void migrateHistoricCaseInstances(String caseDefinitionKey, int caseDefinitionVersion, String caseDefinitionTenantId); | ||
|
||
/** | ||
* Asynchronously starts the case instance migration for each case instances of a given case definition identified by the case definition key and version (optional tenantId). | ||
* | ||
* @param caseDefinitionKey | ||
* @param caseDefinitionVersion | ||
* @param caseDefinitionTenantId | ||
* @return an id of the created batch entity | ||
*/ | ||
Batch batchMigrateHistoricCaseInstances(String caseDefinitionKey, int caseDefinitionVersion, String caseDefinitionTenantId); | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
.../src/main/java/org/flowable/cmmn/api/migration/HistoricCaseInstanceMigrationDocument.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* 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 org.flowable.cmmn.api.migration; | ||
|
||
public interface HistoricCaseInstanceMigrationDocument { | ||
|
||
String getMigrateToCaseDefinitionId(); | ||
|
||
String getMigrateToCaseDefinitionKey(); | ||
|
||
Integer getMigrateToCaseDefinitionVersion(); | ||
|
||
String getMigrateToCaseDefinitionTenantId(); | ||
|
||
String asJsonString(); | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
...in/java/org/flowable/cmmn/api/migration/HistoricCaseInstanceMigrationDocumentBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* 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 org.flowable.cmmn.api.migration; | ||
|
||
public interface HistoricCaseInstanceMigrationDocumentBuilder { | ||
|
||
HistoricCaseInstanceMigrationDocumentBuilder setCaseDefinitionToMigrateTo(String caseDefinitionId); | ||
|
||
HistoricCaseInstanceMigrationDocumentBuilder setCaseDefinitionToMigrateTo(String caseDefinitionKey, Integer caseDefinitionVersion); | ||
|
||
HistoricCaseInstanceMigrationDocumentBuilder setTenantId(String caseDefinitionTenantId); | ||
|
||
HistoricCaseInstanceMigrationDocument build(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
...rc/main/java/org/flowable/cmmn/engine/impl/cmd/HistoricCaseInstanceMigrationBatchCmd.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* 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 org.flowable.cmmn.engine.impl.cmd; | ||
|
||
import org.flowable.batch.api.Batch; | ||
import org.flowable.cmmn.api.migration.HistoricCaseInstanceMigrationDocument; | ||
import org.flowable.cmmn.engine.CmmnEngineConfiguration; | ||
import org.flowable.cmmn.engine.impl.migration.CaseInstanceMigrationManager; | ||
import org.flowable.common.engine.api.FlowableException; | ||
import org.flowable.common.engine.impl.interceptor.Command; | ||
import org.flowable.common.engine.impl.interceptor.CommandContext; | ||
|
||
public class HistoricCaseInstanceMigrationBatchCmd implements Command<Batch> { | ||
|
||
protected CmmnEngineConfiguration cmmnEngineConfiguration; | ||
|
||
protected String caseDefinitionId; | ||
protected String caseDefinitionKey; | ||
protected int caseDefinitionVersion; | ||
protected String caseDefinitionTenantId; | ||
protected HistoricCaseInstanceMigrationDocument historicCaseInstanceMigrationDocument; | ||
|
||
public HistoricCaseInstanceMigrationBatchCmd(HistoricCaseInstanceMigrationDocument historicCaseInstanceMigrationDocument, String caseDefinitionId, | ||
CmmnEngineConfiguration cmmnEngineConfiguration) { | ||
|
||
if (caseDefinitionId == null) { | ||
throw new FlowableException("Must specify a case definition id to migrate"); | ||
} | ||
if (historicCaseInstanceMigrationDocument == null) { | ||
throw new FlowableException("Must specify a historic case instance migration document to migrate"); | ||
} | ||
this.caseDefinitionId = caseDefinitionId; | ||
this.historicCaseInstanceMigrationDocument = historicCaseInstanceMigrationDocument; | ||
this.cmmnEngineConfiguration = cmmnEngineConfiguration; | ||
} | ||
|
||
public HistoricCaseInstanceMigrationBatchCmd(String caseDefinitionKey, int caseDefinitionVersion, String caseDefinitionTenantId, | ||
HistoricCaseInstanceMigrationDocument historicCaseInstanceMigrationDocument, CmmnEngineConfiguration cmmnEngineConfiguration) { | ||
|
||
if (caseDefinitionKey == null) { | ||
throw new FlowableException("Must specify a case definition id to migrate"); | ||
} | ||
if (caseDefinitionTenantId == null) { | ||
throw new FlowableException("Must specify a case definition tenant id to migrate"); | ||
} | ||
if (historicCaseInstanceMigrationDocument == null) { | ||
throw new FlowableException("Must specify a historic case instance migration document to migrate"); | ||
} | ||
this.caseDefinitionKey = caseDefinitionKey; | ||
this.caseDefinitionVersion = caseDefinitionVersion; | ||
this.caseDefinitionTenantId = caseDefinitionTenantId; | ||
this.historicCaseInstanceMigrationDocument = historicCaseInstanceMigrationDocument; | ||
this.cmmnEngineConfiguration = cmmnEngineConfiguration; | ||
} | ||
|
||
@Override | ||
public Batch execute(CommandContext commandContext) { | ||
CaseInstanceMigrationManager migrationManager = cmmnEngineConfiguration.getCaseInstanceMigrationManager(); | ||
|
||
if (caseDefinitionId != null) { | ||
return migrationManager.batchMigrateHistoricCaseInstancesOfCaseDefinition(caseDefinitionId, historicCaseInstanceMigrationDocument, commandContext); | ||
} else if (caseDefinitionKey != null && caseDefinitionVersion >= 0) { | ||
return migrationManager.batchMigrateHistoricCaseInstancesOfCaseDefinition(caseDefinitionKey, caseDefinitionVersion, caseDefinitionTenantId, | ||
historicCaseInstanceMigrationDocument, commandContext); | ||
} else { | ||
throw new FlowableException("Cannot migrate historic case instances, not enough information"); | ||
} | ||
} | ||
} |
Oops, something went wrong.