User: jon@sartography.com added process model file playground/jon/load-world-for-typeahead/load_world.bpmn
This commit is contained in:
parent
a7cd682871
commit
9725a6eb88
|
@ -0,0 +1,200 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:spiffworkflow="http://spiffworkflow.org/bpmn/schema/1.0/core" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_96f6665" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.0.0-dev">
|
||||
<bpmn:dataStore id="typeahead" name="TypeaheadDataStore" />
|
||||
<bpmn:process id="load_world" name="Load World" isExecutable="true">
|
||||
<bpmn:startEvent id="StartEvent_1">
|
||||
<bpmn:outgoing>Flow_0tn4ed3</bpmn:outgoing>
|
||||
</bpmn:startEvent>
|
||||
<bpmn:sequenceFlow id="Flow_0tn4ed3" sourceRef="StartEvent_1" targetRef="Activity_09mu4sd" />
|
||||
<bpmn:endEvent id="Event_0jxoz7s">
|
||||
<bpmn:incoming>Flow_0lz96a1</bpmn:incoming>
|
||||
</bpmn:endEvent>
|
||||
<bpmn:sequenceFlow id="Flow_0lz96a1" sourceRef="Activity_0o51srq" targetRef="Event_0jxoz7s" />
|
||||
<bpmn:scriptTask id="Activity_0o51srq" name="Parse cities response">
|
||||
<bpmn:extensionElements>
|
||||
<spiffworkflow:unitTests>
|
||||
<spiffworkflow:unitTest id="test_top3">
|
||||
<spiffworkflow:inputJson>{
|
||||
"typeahead": {},
|
||||
"cities_result": [
|
||||
{
|
||||
"id": 52,
|
||||
"name": "Ashkāsham",
|
||||
"state_id": 3901,
|
||||
"state_code": "BDS",
|
||||
"state_name": "Badakhshan",
|
||||
"country_id": 1,
|
||||
"country_code": "AF",
|
||||
"country_name": "Afghanistan",
|
||||
"latitude": "36.68333000",
|
||||
"longitude": "71.53333000",
|
||||
"wikiDataId": "Q4805192"
|
||||
},
|
||||
{
|
||||
"id": 68,
|
||||
"name": "Fayzabad",
|
||||
"state_id": 3901,
|
||||
"state_code": "BDS",
|
||||
"state_name": "Badakhshan",
|
||||
"country_id": 1,
|
||||
"country_code": "AF",
|
||||
"country_name": "Afghanistan",
|
||||
"latitude": "37.11664000",
|
||||
"longitude": "70.58002000",
|
||||
"wikiDataId": "Q156558"
|
||||
},
|
||||
{
|
||||
"id": 78,
|
||||
"name": "Jurm",
|
||||
"state_id": 3901,
|
||||
"state_code": "BDS",
|
||||
"state_name": "Badakhshan",
|
||||
"country_id": 1,
|
||||
"country_code": "AF",
|
||||
"country_name": "Afghanistan",
|
||||
"latitude": "36.86477000",
|
||||
"longitude": "70.83421000",
|
||||
"wikiDataId": "Q10308323"
|
||||
}
|
||||
]
|
||||
}</spiffworkflow:inputJson>
|
||||
<spiffworkflow:expectedOutputJson>{
|
||||
"typeahead": {
|
||||
"cities": [
|
||||
{
|
||||
"search_term": "Ashkāsham",
|
||||
"result": {
|
||||
"name": "Ashkāsham",
|
||||
"country": "Afghanistan",
|
||||
"state": "Badakhshan"
|
||||
}
|
||||
},
|
||||
{
|
||||
"search_term": "Fayzabad",
|
||||
"result": {
|
||||
"name": "Fayzabad",
|
||||
"country": "Afghanistan",
|
||||
"state": "Badakhshan"
|
||||
}
|
||||
},
|
||||
{
|
||||
"search_term": "Jurm",
|
||||
"result": {
|
||||
"name": "Jurm",
|
||||
"country": "Afghanistan",
|
||||
"state": "Badakhshan"
|
||||
}
|
||||
}
|
||||
],
|
||||
"countries": [
|
||||
{
|
||||
"result": {
|
||||
"name": "Afghanistan"
|
||||
},
|
||||
"search_term": "Afghanistan"
|
||||
}
|
||||
],
|
||||
"states": [
|
||||
{
|
||||
"result": {
|
||||
"country": "Afghanistan",
|
||||
"name": "Badakhshan"
|
||||
},
|
||||
"search_term": "Badakhshan"
|
||||
}
|
||||
]
|
||||
}
|
||||
}</spiffworkflow:expectedOutputJson>
|
||||
</spiffworkflow:unitTest>
|
||||
</spiffworkflow:unitTests>
|
||||
</bpmn:extensionElements>
|
||||
<bpmn:incoming>Flow_0w7oyed</bpmn:incoming>
|
||||
<bpmn:outgoing>Flow_0lz96a1</bpmn:outgoing>
|
||||
<bpmn:dataOutputAssociation id="DataOutputAssociation_0tjuw5b">
|
||||
<bpmn:targetRef>DataStoreReference_1oronwq</bpmn:targetRef>
|
||||
</bpmn:dataOutputAssociation>
|
||||
<bpmn:script>def parse_cities_result():
|
||||
cities = []
|
||||
countries = []
|
||||
states = []
|
||||
states_by_country = {}
|
||||
|
||||
for result in cities_result:
|
||||
name = result["name"]
|
||||
state = result["state_name"]
|
||||
country = result["country_name"]
|
||||
cities.append({"search_term": name, "result": {"name": name, "state": state, "country": country}})
|
||||
if country not in states_by_country:
|
||||
states_by_country[country] = set()
|
||||
states_by_country[country].add(state)
|
||||
|
||||
for country in states_by_country.keys():
|
||||
countries.append({"search_term": country, "result":{"name": country}})
|
||||
for state in states_by_country[country]:
|
||||
states.append({"search_term": state, "result": {"name": state, "country": country}})
|
||||
|
||||
return { "cities": cities, "countries": countries, "states": states }
|
||||
|
||||
typeahead = parse_cities_result()
|
||||
|
||||
del(cities_result)</bpmn:script>
|
||||
</bpmn:scriptTask>
|
||||
<bpmn:sequenceFlow id="Flow_0w7oyed" sourceRef="Activity_09mu4sd" targetRef="Activity_0o51srq" />
|
||||
<bpmn:serviceTask id="Activity_09mu4sd" name="Fetch cities.json">
|
||||
<bpmn:extensionElements>
|
||||
<spiffworkflow:serviceTaskOperator id="http/GetRequest" resultVariable="cities_result">
|
||||
<spiffworkflow:parameters>
|
||||
<spiffworkflow:parameter id="basic_auth_password" type="str" />
|
||||
<spiffworkflow:parameter id="basic_auth_username" type="str" />
|
||||
<spiffworkflow:parameter id="headers" type="any" />
|
||||
<spiffworkflow:parameter id="params" type="any" />
|
||||
<spiffworkflow:parameter id="url" type="str" value=""https://raw.githubusercontent.com/dr5hn/countries-states-cities-database/master/cities.json"" />
|
||||
</spiffworkflow:parameters>
|
||||
</spiffworkflow:serviceTaskOperator>
|
||||
</bpmn:extensionElements>
|
||||
<bpmn:incoming>Flow_0tn4ed3</bpmn:incoming>
|
||||
<bpmn:outgoing>Flow_0w7oyed</bpmn:outgoing>
|
||||
</bpmn:serviceTask>
|
||||
<bpmn:dataStoreReference id="DataStoreReference_1oronwq" name="Update Typeahead Data Store" dataStoreRef="typeahead" />
|
||||
</bpmn:process>
|
||||
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="load_world">
|
||||
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
|
||||
<dc:Bounds x="179" y="159" width="36" height="36" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Event_0jxoz7s_di" bpmnElement="Event_0jxoz7s">
|
||||
<dc:Bounds x="542" y="159" width="36" height="36" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Activity_1fwfxsn_di" bpmnElement="Activity_0o51srq">
|
||||
<dc:Bounds x="390" y="137" width="100" height="80" />
|
||||
<bpmndi:BPMNLabel />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Activity_1hntoll_di" bpmnElement="Activity_09mu4sd">
|
||||
<dc:Bounds x="250" y="137" width="100" height="80" />
|
||||
<bpmndi:BPMNLabel />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="DataStoreReference_1oronwq_di" bpmnElement="DataStoreReference_1oronwq">
|
||||
<dc:Bounds x="415" y="305" width="50" height="50" />
|
||||
<bpmndi:BPMNLabel>
|
||||
<dc:Bounds x="413" y="362" width="55" height="14" />
|
||||
</bpmndi:BPMNLabel>
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNEdge id="Flow_0tn4ed3_di" bpmnElement="Flow_0tn4ed3">
|
||||
<di:waypoint x="215" y="177" />
|
||||
<di:waypoint x="250" y="177" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNEdge id="Flow_0lz96a1_di" bpmnElement="Flow_0lz96a1">
|
||||
<di:waypoint x="490" y="177" />
|
||||
<di:waypoint x="542" y="177" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNEdge id="Flow_0w7oyed_di" bpmnElement="Flow_0w7oyed">
|
||||
<di:waypoint x="350" y="177" />
|
||||
<di:waypoint x="390" y="177" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNEdge id="DataOutputAssociation_0tjuw5b_di" bpmnElement="DataOutputAssociation_0tjuw5b">
|
||||
<di:waypoint x="441" y="217" />
|
||||
<di:waypoint x="444" y="305" />
|
||||
</bpmndi:BPMNEdge>
|
||||
</bpmndi:BPMNPlane>
|
||||
</bpmndi:BPMNDiagram>
|
||||
</bpmn:definitions>
|
|
@ -4,6 +4,6 @@
|
|||
"exception_notification_addresses": [],
|
||||
"fault_or_suspend_on_exception": "fault",
|
||||
"metadata_extraction_paths": null,
|
||||
"primary_file_name": null,
|
||||
"primary_process_id": null
|
||||
"primary_file_name": "load_world.bpmn",
|
||||
"primary_process_id": "load_world"
|
||||
}
|
Loading…
Reference in New Issue