Skip to content

Commit 1c0cfd1

Browse files
author
Jens Kürten
committed
feat: part field calculation event
1 parent 27e8120 commit 1c0cfd1

File tree

4 files changed

+97
-0
lines changed

4 files changed

+97
-0
lines changed

csfunctions/events/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from .engineering_change_release import EngineeringChangeRelease, EngineeringChangeReleaseData
1111
from .engineering_change_release_check import EngineeringChangeReleaseCheck, EngineeringChangeReleaseCheckData
1212
from .field_value_calculation import FieldValueCalculationData, FieldValueCalculationEvent
13+
from .part_field_calculation import PartFieldCalculationData, PartFieldCalculationEvent
1314
from .part_release import PartReleaseData, PartReleaseEvent
1415
from .part_release_check import PartReleaseCheckData, PartReleaseCheckEvent
1516
from .workflow_task_trigger import WorkflowTaskTriggerEvent, WorkflowTaskTriggerEventData
@@ -21,6 +22,7 @@
2122
DocumentFieldCalculationEvent,
2223
PartReleaseEvent,
2324
PartReleaseCheckEvent,
25+
PartFieldCalculationEvent,
2426
FieldValueCalculationEvent,
2527
DummyEvent,
2628
EngineeringChangeRelease,
@@ -35,6 +37,7 @@
3537
DocumentFieldCalculationData,
3638
PartReleaseData,
3739
PartReleaseCheckData,
40+
PartFieldCalculationData,
3841
FieldValueCalculationData,
3942
DummyEventData,
4043
EngineeringChangeReleaseData,
@@ -48,6 +51,7 @@
4851
"DocumentFieldCalculationEvent",
4952
"PartReleaseEvent",
5053
"PartReleaseCheckEvent",
54+
"PartFieldCalculationEvent",
5155
"FieldValueCalculationEvent",
5256
"DummyEvent",
5357
"EngineeringChangeRelease",
@@ -65,4 +69,5 @@
6569
"WorkflowTaskTriggerEventData",
6670
"DocumentReleaseDialogData",
6771
"PartReleaseDialogData",
72+
"PartFieldCalculationData",
6873
]

csfunctions/events/base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class EventNames(str, Enum):
1010
DOCUMENT_FIELD_CALCULATION = "document_field_calculation"
1111
PART_RELEASE = "part_release"
1212
PART_RELEASE_CHECK = "part_release_check"
13+
PART_FIELD_CALCULATION = "part_field_calculation"
1314
ENGINEERING_CHANGE_RELEASE = "engineering_change_release"
1415
ENGINEERING_CHANGE_RELEASE_CHECK = "engineering_change_release_check"
1516
FIELD_VALUE_CALCULATION = "field_value_calculation"
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from typing import Literal
2+
3+
from pydantic import BaseModel, Field
4+
5+
from csfunctions.objects import Document, Part
6+
7+
from .base import BaseEvent, EventNames
8+
9+
10+
class PartFieldCalculationData(BaseModel):
11+
part: Part = Field(..., description="Current state of the part")
12+
action: Literal["create", "modify", "copy", "index"] = Field(..., description="Action being performed")
13+
14+
linked_documents: list[Document] = Field(..., description="List of documents that are referenced by the parts.")
15+
linked_parts: list[Part] = Field(..., description="Related parts (e.g. source part)")
16+
17+
18+
class PartFieldCalculationEvent(BaseEvent):
19+
name: Literal[EventNames.PART_FIELD_CALCULATION] = EventNames.PART_FIELD_CALCULATION
20+
data: PartFieldCalculationData

json_schemas/request.json

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2490,6 +2490,73 @@
24902490
"title": "Part",
24912491
"type": "object"
24922492
},
2493+
"PartFieldCalculationData": {
2494+
"properties": {
2495+
"part": {
2496+
"$ref": "#/$defs/Part",
2497+
"description": "Current state of the part"
2498+
},
2499+
"action": {
2500+
"description": "Action being performed",
2501+
"enum": [
2502+
"create",
2503+
"modify",
2504+
"copy",
2505+
"index"
2506+
],
2507+
"title": "Action",
2508+
"type": "string"
2509+
},
2510+
"linked_documents": {
2511+
"description": "List of documents that are referenced by the parts.",
2512+
"items": {
2513+
"$ref": "#/$defs/Document"
2514+
},
2515+
"title": "Linked Documents",
2516+
"type": "array"
2517+
},
2518+
"linked_parts": {
2519+
"description": "Related parts (e.g. source part)",
2520+
"items": {
2521+
"$ref": "#/$defs/Part"
2522+
},
2523+
"title": "Linked Parts",
2524+
"type": "array"
2525+
}
2526+
},
2527+
"required": [
2528+
"part",
2529+
"action",
2530+
"linked_documents",
2531+
"linked_parts"
2532+
],
2533+
"title": "PartFieldCalculationData",
2534+
"type": "object"
2535+
},
2536+
"PartFieldCalculationEvent": {
2537+
"properties": {
2538+
"name": {
2539+
"const": "part_field_calculation",
2540+
"default": "part_field_calculation",
2541+
"title": "Name",
2542+
"type": "string"
2543+
},
2544+
"event_id": {
2545+
"description": "unique identifier",
2546+
"title": "Event Id",
2547+
"type": "string"
2548+
},
2549+
"data": {
2550+
"$ref": "#/$defs/PartFieldCalculationData"
2551+
}
2552+
},
2553+
"required": [
2554+
"event_id",
2555+
"data"
2556+
],
2557+
"title": "PartFieldCalculationEvent",
2558+
"type": "object"
2559+
},
24932560
"PartReleaseCheckData": {
24942561
"properties": {
24952562
"parts": {
@@ -2823,6 +2890,7 @@
28232890
"engineering_change_release": "#/$defs/EngineeringChangeRelease",
28242891
"engineering_change_release_check": "#/$defs/EngineeringChangeReleaseCheck",
28252892
"field_value_calculation": "#/$defs/FieldValueCalculationEvent",
2893+
"part_field_calculation": "#/$defs/PartFieldCalculationEvent",
28262894
"part_release": "#/$defs/PartReleaseEvent",
28272895
"part_release_check": "#/$defs/PartReleaseCheckEvent",
28282896
"workflow_task_trigger": "#/$defs/WorkflowTaskTriggerEvent"
@@ -2845,6 +2913,9 @@
28452913
{
28462914
"$ref": "#/$defs/PartReleaseCheckEvent"
28472915
},
2916+
{
2917+
"$ref": "#/$defs/PartFieldCalculationEvent"
2918+
},
28482919
{
28492920
"$ref": "#/$defs/FieldValueCalculationEvent"
28502921
},

0 commit comments

Comments
 (0)