-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
120 lines (106 loc) · 4.03 KB
/
example.py
File metadata and controls
120 lines (106 loc) · 4.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
from collections import *
from erdBuilder import ERDBuilder
if __name__ == "__main__":
port = Entity('Port', [
Attribute('Port_ID', is_primary=True),
Attribute('Port_name'),
Attribute('Port_country'),
Attribute('Port_handling_time'),
Attribute('Port_capacity')
])
vessel = Entity('Vessel', [
Attribute('ID', is_primary=True),
Attribute('Name'),
Attribute('fleetSize'),
Attribute('Owner'),
Attribute('Capacity'),
Attribute('policyID'),
Attribute('vesselType'),
Attribute('fuelCapacity')
])
cargo = Entity('Cargo', [
Attribute('Id', is_primary=True),
Attribute('Weight'),
Attribute('Type'),
Attribute('Hazardous'),
Attribute('Description'),
Attribute('Origin'),
Attribute('policyID'),
Attribute('regulationID'),
Attribute('Destination')
])
fuel_consumption = Entity('FuelConsumption', [
Attribute('Id', is_primary=True),
Attribute('VesselID'),
Attribute('Date'),
Attribute('Volume'),
Attribute('carbonEmission'),
Attribute('fuelType'),
Attribute('fuelAmount'),
Attribute('fuelUsed')
])
shipping_route = Entity('ShippingRoute', [
Attribute('Id', is_primary=True),
Attribute('startPortID'),
Attribute('destPortID'),
Attribute('Distance'),
Attribute('Duration')
])
trade_agreement = Entity('TradeAgreement', [
Attribute('Id', is_primary=True),
Attribute('Countries'),
Attribute('expiryDate'),
Attribute('agreementStartDate'),
Attribute('TOC/rules'),
Attribute('authorityID')
])
crew_member = Entity('CrewMember', [
Attribute('Id', is_primary=True),
Attribute('Name'),
Attribute('Nationality'),
Attribute('Role'),
Attribute('shipID')
])
warehouse = Entity('Warehouse', [
Attribute('Id', is_primary=True),
Attribute('Capacity'),
Attribute('OccupancyStatus'),
Attribute('PortID'),
Attribute('CompanyID')
])
insurance_policy = Entity('InsurancePolicy', [
Attribute('Id', is_primary=True),
Attribute('providerName'),
Attribute('Number'),
Attribute('coverageAmount'),
Attribute('expiresAt'),
Attribute('coverageDetails')
])
schedule = Entity('Schedule', [
Attribute('Id', is_primary=True),
Attribute('Status'),
Attribute('PortID'),
Attribute('VesselID'),
Attribute('Date'),
Attribute('ArrivalTime'),
Attribute('DepartureTime')
])
#set Relationships
vessel_port = Relationship(vessel, port, Cardinality.MANY_TO_MANY, 'docks_at')
vessel_cargo = Relationship(vessel, cargo, Cardinality.ONE_TO_MANY, 'transports')
vessel_route = Relationship(vessel, shipping_route, Cardinality.ONE_TO_ONE, 'follows')
vessel_fuel = Relationship(vessel, fuel_consumption, Cardinality.ONE_TO_MANY, 'consumes')
vessel_trade_agreement = Relationship(vessel, trade_agreement, Cardinality.MANY_TO_MANY, 'operates_under')
crew_vessel = Relationship(crew_member, vessel, Cardinality.MANY_TO_ONE, 'assigned_to')
warehouse_port = Relationship(warehouse, port, Cardinality.ONE_TO_ONE, 'located_at')
insurance_vessel = Relationship(insurance_policy, vessel, Cardinality.ONE_TO_ONE, 'covers')
schedule_vessel = Relationship(schedule, vessel, Cardinality.ONE_TO_ONE, 'scheduled_for')
# Entity List and Relationship List
entities = [port, vessel, cargo, fuel_consumption, shipping_route, trade_agreement,
crew_member, warehouse, insurance_policy, schedule]
relationships = [vessel_port, vessel_cargo, vessel_route, vessel_fuel, vessel_trade_agreement,
crew_vessel, warehouse_port, insurance_vessel, schedule_vessel]
erdBuilder = ERDBuilder(entities=entities, relationships=relationships)
erdBuilder.build()
erdBuilder.saveSVG('file')
erdBuilder.savePNG('file')