Detect duplicate process ids when uploading/creating a new file (#1581)
Co-authored-by: jasquat <jasquat@users.noreply.github.com>
This commit is contained in:
parent
191f46b95b
commit
5bf3ea0db2
|
@ -307,11 +307,7 @@ class SpecFileService(FileSystemService):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def update_process_cache(ref: Reference) -> None:
|
def update_process_cache(ref: Reference) -> None:
|
||||||
process_id_lookup = (
|
process_id_lookup = ReferenceCacheModel.basic_query().filter_by(identifier=ref.identifier, type=ref.type).first()
|
||||||
ReferenceCacheModel.basic_query()
|
|
||||||
.filter_by(identifier=ref.identifier, relative_location=ref.relative_location, type=ref.type)
|
|
||||||
.first()
|
|
||||||
)
|
|
||||||
if process_id_lookup is None:
|
if process_id_lookup is None:
|
||||||
process_id_lookup = ReferenceCacheModel.from_spec_reference(ref, use_current_cache_generation=True)
|
process_id_lookup = ReferenceCacheModel.from_spec_reference(ref, use_current_cache_generation=True)
|
||||||
db.session.add(process_id_lookup)
|
db.session.add(process_id_lookup)
|
||||||
|
|
|
@ -151,9 +151,9 @@ class TestProcessModelService(BaseTest):
|
||||||
assert process_model.primary_process_id == primary_process_id
|
assert process_model.primary_process_id == primary_process_id
|
||||||
|
|
||||||
process_model = load_test_spec(
|
process_model = load_test_spec(
|
||||||
"test_group/hello_world_2",
|
"test_group/sample",
|
||||||
bpmn_file_name="hello_world.bpmn",
|
bpmn_file_name="sample.bpmn",
|
||||||
process_model_source_directory="hello_world",
|
process_model_source_directory="sample",
|
||||||
)
|
)
|
||||||
|
|
||||||
# this model should not show up in results because it has no primary_file_name
|
# this model should not show up in results because it has no primary_file_name
|
||||||
|
|
|
@ -97,7 +97,7 @@ describe('process-models', () => {
|
||||||
cy.getBySel('process-model-add-file').click();
|
cy.getBySel('process-model-add-file').click();
|
||||||
cy.getBySel('process-model-add-file').contains('New DMN File').click();
|
cy.getBySel('process-model-add-file').contains('New DMN File').click();
|
||||||
cy.contains(/^Process Model File$/);
|
cy.contains(/^Process Model File$/);
|
||||||
cy.get('g[data-element-id=decision_1]').click();
|
cy.get('g[data-element-id^=decision_]').click();
|
||||||
cy.contains('General').click();
|
cy.contains('General').click();
|
||||||
cy.get('#bio-properties-panel-id').clear();
|
cy.get('#bio-properties-panel-id').clear();
|
||||||
cy.get('#bio-properties-panel-id').type(decisionAcceptanceTestId);
|
cy.get('#bio-properties-panel-id').type(decisionAcceptanceTestId);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<definitions xmlns="https://www.omg.org/spec/DMN/20191111/MODEL/" xmlns:dmndi="https://www.omg.org/spec/DMN/20191111/DMNDI/" xmlns:dc="http://www.omg.org/spec/DMN/20180521/DC/" id="Definitions_76910d7" name="DRD" namespace="http://camunda.org/schema/1.0/dmn">
|
<definitions xmlns="https://www.omg.org/spec/DMN/20191111/MODEL/" xmlns:dmndi="https://www.omg.org/spec/DMN/20191111/DMNDI/" xmlns:dc="http://www.omg.org/spec/DMN/20180521/DC/" id="Definitions_76910d7" name="DRD" namespace="http://camunda.org/schema/1.0/dmn">
|
||||||
<decision id="decision_1" name="Decision 1">
|
<decision id="{{DECISION_ID}}" name="Decision">
|
||||||
<decisionTable id="decisionTable_1">
|
<decisionTable id="decisionTable_1">
|
||||||
<input id="input_1">
|
<input id="input_1">
|
||||||
<inputExpression id="inputExpression_1" typeRef="string">
|
<inputExpression id="inputExpression_1" typeRef="string">
|
||||||
|
@ -12,7 +12,7 @@
|
||||||
</decision>
|
</decision>
|
||||||
<dmndi:DMNDI>
|
<dmndi:DMNDI>
|
||||||
<dmndi:DMNDiagram id="DMNDiagram_1cykosu">
|
<dmndi:DMNDiagram id="DMNDiagram_1cykosu">
|
||||||
<dmndi:DMNShape id="DMNShape_1dhfq2s" dmnElementRef="decision_1">
|
<dmndi:DMNShape id="DMNShape_1dhfq2s" dmnElementRef="{{DECISION_ID}}">
|
||||||
<dc:Bounds height="80" width="180" x="157" y="151" />
|
<dc:Bounds height="80" width="180" x="157" y="151" />
|
||||||
</dmndi:DMNShape>
|
</dmndi:DMNShape>
|
||||||
</dmndi:DMNDiagram>
|
</dmndi:DMNDiagram>
|
||||||
|
|
|
@ -544,14 +544,22 @@ export default function ReactDiagramEditor({
|
||||||
alreadyImportedXmlRef.current = true;
|
alreadyImportedXmlRef.current = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetchDiagramFromURL(urlToUse: any) {
|
function dmnTextHandler(text: str) {
|
||||||
|
const decisionId = `decision_${makeid(7)}`;
|
||||||
|
const newText = text.replaceAll('{{DECISION_ID}}', decisionId);
|
||||||
|
setDiagramXMLString(newText);
|
||||||
|
}
|
||||||
|
|
||||||
|
function bpmnTextHandler(text: str) {
|
||||||
|
const processId = `Process_${makeid(7)}`;
|
||||||
|
const newText = text.replaceAll('{{PROCESS_ID}}', processId);
|
||||||
|
setDiagramXMLString(newText);
|
||||||
|
}
|
||||||
|
|
||||||
|
function fetchDiagramFromURL(urlToUse: any, textHandler?: (text: str) => void) {
|
||||||
fetch(urlToUse)
|
fetch(urlToUse)
|
||||||
.then((response) => response.text())
|
.then((response) => response.text())
|
||||||
.then((text) => {
|
.then(textHandler ?? bpmnTextHandler)
|
||||||
const processId = `Process_${makeid(7)}`;
|
|
||||||
const newText = text.replace('{{PROCESS_ID}}', processId);
|
|
||||||
setDiagramXMLString(newText);
|
|
||||||
})
|
|
||||||
.catch((err) => handleError(err));
|
.catch((err) => handleError(err));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -587,10 +595,12 @@ export default function ReactDiagramEditor({
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
let newDiagramFileName = 'new_bpmn_diagram.bpmn';
|
let newDiagramFileName = 'new_bpmn_diagram.bpmn';
|
||||||
|
let textHandler = null;
|
||||||
if (diagramType === 'dmn') {
|
if (diagramType === 'dmn') {
|
||||||
newDiagramFileName = 'new_dmn_diagram.dmn';
|
newDiagramFileName = 'new_dmn_diagram.dmn';
|
||||||
|
textHandler = dmnTextHandler;
|
||||||
}
|
}
|
||||||
fetchDiagramFromURL(`/${newDiagramFileName}`);
|
fetchDiagramFromURL(`/${newDiagramFileName}`, textHandler);
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue