Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
69a9462bb9 | ||
|
|
350bc65bea | ||
|
|
f0c9e2f843 | ||
|
|
4d2f813f79 | ||
|
|
5038e3f531 | ||
|
|
3c4959e635 | ||
|
|
86f76b23c7 | ||
|
|
fc628686d2 | ||
|
|
7fe74e900a | ||
|
|
12b291c9ab | ||
|
|
d6d12fdeaa | ||
|
|
052653f28a | ||
|
|
ca39ddeb66 | ||
|
|
541a8b300d | ||
|
|
42246a20f5 |
|
After Width: | Height: | Size: 7.4 KiB |
@@ -0,0 +1,86 @@
|
||||
<mxfile host="app.diagrams.net" modified="2023-05-11T22:07:43.655Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36" etag="aBW4jSGyPDGQoomiV2hG" version="21.2.9" type="device">
|
||||
<diagram name="Page-1" id="l5vY4O9IbvtC4RH7jgLU">
|
||||
<mxGraphModel dx="2261" dy="796" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
|
||||
<root>
|
||||
<mxCell id="0" />
|
||||
<mxCell id="1" parent="0" />
|
||||
<mxCell id="dh-SCe4R4OtTttROAreb-6" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;entryPerimeter=0;" parent="1" source="dh-SCe4R4OtTttROAreb-1" target="dh-SCe4R4OtTttROAreb-2" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="dh-SCe4R4OtTttROAreb-8" value="Provides id for <br>deposit" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" parent="dh-SCe4R4OtTttROAreb-6" vertex="1" connectable="0">
|
||||
<mxGeometry x="-0.1493" y="4" relative="1" as="geometry">
|
||||
<mxPoint x="3" y="24" as="offset" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="dh-SCe4R4OtTttROAreb-1" value="" style="shape=cylinder3;whiteSpace=wrap;html=1;boundedLbl=1;backgroundOutline=1;size=15;" parent="1" vertex="1">
|
||||
<mxGeometry x="-173" y="40" width="160" height="180" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="dh-SCe4R4OtTttROAreb-2" value="" style="shape=cylinder3;whiteSpace=wrap;html=1;boundedLbl=1;backgroundOutline=1;size=15;" parent="1" vertex="1">
|
||||
<mxGeometry x="107" y="40" width="160" height="180" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="dh-SCe4R4OtTttROAreb-7" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="dh-SCe4R4OtTttROAreb-3" target="dh-SCe4R4OtTttROAreb-2" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="dh-SCe4R4OtTttROAreb-9" value="Provides id for<br style="border-color: var(--border-color);">product" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" parent="dh-SCe4R4OtTttROAreb-7" vertex="1" connectable="0">
|
||||
<mxGeometry x="0.2059" y="1" relative="1" as="geometry">
|
||||
<mxPoint x="12" y="19" as="offset" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="dh-SCe4R4OtTttROAreb-3" value="" style="shape=cylinder3;whiteSpace=wrap;html=1;boundedLbl=1;backgroundOutline=1;size=15;" parent="1" vertex="1">
|
||||
<mxGeometry x="387" y="40" width="160" height="180" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="dh-SCe4R4OtTttROAreb-4" value="<font style="font-size: 15px;">Deposit</font>" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" parent="1" vertex="1">
|
||||
<mxGeometry x="-128" y="230" width="70" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="dh-SCe4R4OtTttROAreb-5" value="<font style="font-size: 15px;">Product</font>" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" parent="1" vertex="1">
|
||||
<mxGeometry x="427" y="230" width="80" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="dh-SCe4R4OtTttROAreb-10" value="<font style="font-size: 15px;">Prod_In_Depo</font>" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" parent="1" vertex="1">
|
||||
<mxGeometry x="127" y="230" width="120" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="dh-SCe4R4OtTttROAreb-11" value="- ID: Integer<br>- Name: String" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" parent="1" vertex="1">
|
||||
<mxGeometry x="417" y="120" width="100" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="dh-SCe4R4OtTttROAreb-12" value="<font style="font-size: 20px;">Fields</font>" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" parent="1" vertex="1">
|
||||
<mxGeometry x="427" y="80" width="80" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="dh-SCe4R4OtTttROAreb-13" value="<font style="font-size: 20px;">Fields</font>" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" parent="1" vertex="1">
|
||||
<mxGeometry x="-133" y="80" width="80" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="dh-SCe4R4OtTttROAreb-14" value="- ID: Integer<br>- Name: String<br>- Lat_Coord: String<br>- Long_Coord: String" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" parent="1" vertex="1">
|
||||
<mxGeometry x="-158" y="120" width="130" height="70" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="dh-SCe4R4OtTttROAreb-15" value="<font style="font-size: 20px;">Fields</font>" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" parent="1" vertex="1">
|
||||
<mxGeometry x="147" y="80" width="80" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="dh-SCe4R4OtTttROAreb-16" value="-ID_Product: Integer<br>-ID_Deposit: Integer" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" parent="1" vertex="1">
|
||||
<mxGeometry x="122" y="120" width="130" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="OZQAEx3QhlDbhOcGXMMP-1" value="" style="shape=cylinder3;whiteSpace=wrap;html=1;boundedLbl=1;backgroundOutline=1;size=15;" vertex="1" parent="1">
|
||||
<mxGeometry x="-453" y="40" width="160" height="180" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="OZQAEx3QhlDbhOcGXMMP-2" value="<font style="font-size: 15px;">Orders</font>" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
|
||||
<mxGeometry x="-408" y="230" width="70" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="OZQAEx3QhlDbhOcGXMMP-3" value="<font style="font-size: 20px;">Fields</font>" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
|
||||
<mxGeometry x="-413" y="80" width="80" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="OZQAEx3QhlDbhOcGXMMP-4" value="- ID: Integer<br>- File_Name: String" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
|
||||
<mxGeometry x="-438" y="120" width="130" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="OZQAEx3QhlDbhOcGXMMP-5" value="" style="shape=cylinder3;whiteSpace=wrap;html=1;boundedLbl=1;backgroundOutline=1;size=15;" vertex="1" parent="1">
|
||||
<mxGeometry x="667" y="40" width="160" height="180" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="OZQAEx3QhlDbhOcGXMMP-6" value="<font style="font-size: 15px;">Routes</font>" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
|
||||
<mxGeometry x="712" y="230" width="70" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="OZQAEx3QhlDbhOcGXMMP-7" value="<font style="font-size: 20px;">Fields</font>" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
|
||||
<mxGeometry x="707" y="80" width="80" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="OZQAEx3QhlDbhOcGXMMP-8" value="- ID: Integer<br>- File_Name: String" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
|
||||
<mxGeometry x="682" y="120" width="130" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
||||
|
After Width: | Height: | Size: 25 KiB |
@@ -0,0 +1,94 @@
|
||||
<mxfile host="app.diagrams.net" modified="2023-05-10T22:21:30.619Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36" etag="tVxgBoU-VddJc27ReIE6" version="21.2.9" type="device">
|
||||
<diagram name="Page-1" id="8nhaB22vOXxsg6rP0QTx">
|
||||
<mxGraphModel dx="1195" dy="589" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
|
||||
<root>
|
||||
<mxCell id="0" />
|
||||
<mxCell id="1" parent="0" />
|
||||
<mxCell id="iqbZGlfnLgNiDH94HB-4-7" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=-0.022;entryY=0.499;entryDx=0;entryDy=0;entryPerimeter=0;" edge="1" parent="1" source="iqbZGlfnLgNiDH94HB-4-1" target="iqbZGlfnLgNiDH94HB-4-2">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="iqbZGlfnLgNiDH94HB-4-16" value="Selects files<br>to process" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" vertex="1" connectable="0" parent="iqbZGlfnLgNiDH94HB-4-7">
|
||||
<mxGeometry x="-0.2741" y="2" relative="1" as="geometry">
|
||||
<mxPoint x="6" y="22" as="offset" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="iqbZGlfnLgNiDH94HB-4-1" value="Admin" style="shape=umlActor;verticalLabelPosition=bottom;verticalAlign=top;html=1;outlineConnect=0;" vertex="1" parent="1">
|
||||
<mxGeometry x="40" y="90" width="40" height="80" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="iqbZGlfnLgNiDH94HB-4-20" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=-0.096;entryY=0.633;entryDx=0;entryDy=0;entryPerimeter=0;" edge="1" parent="1" source="iqbZGlfnLgNiDH94HB-4-2" target="iqbZGlfnLgNiDH94HB-4-18">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<Array as="points">
|
||||
<mxPoint x="280" y="130" />
|
||||
<mxPoint x="280" y="141" />
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="iqbZGlfnLgNiDH94HB-4-21" value="Generates" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" vertex="1" connectable="0" parent="iqbZGlfnLgNiDH94HB-4-20">
|
||||
<mxGeometry x="-0.2162" y="-1" relative="1" as="geometry">
|
||||
<mxPoint x="4" y="19" as="offset" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="iqbZGlfnLgNiDH94HB-4-2" value="App" style="shape=cube;whiteSpace=wrap;html=1;boundedLbl=1;backgroundOutline=1;darkOpacity=0.05;darkOpacity2=0.1;" vertex="1" parent="1">
|
||||
<mxGeometry x="160" y="100" width="80" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="iqbZGlfnLgNiDH94HB-4-14" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.55;exitY=0.95;exitDx=0;exitDy=0;exitPerimeter=0;" edge="1" parent="1" source="iqbZGlfnLgNiDH94HB-4-3" target="iqbZGlfnLgNiDH94HB-4-6">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<Array as="points">
|
||||
<mxPoint x="550" y="211" />
|
||||
<mxPoint x="550" y="230" />
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="iqbZGlfnLgNiDH94HB-4-15" value="Saves results in folder" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" vertex="1" connectable="0" parent="iqbZGlfnLgNiDH94HB-4-14">
|
||||
<mxGeometry x="-0.3353" y="1" relative="1" as="geometry">
|
||||
<mxPoint x="25" y="11" as="offset" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="iqbZGlfnLgNiDH94HB-4-27" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.875;exitY=0.5;exitDx=0;exitDy=0;exitPerimeter=0;entryX=-0.05;entryY=0.628;entryDx=0;entryDy=0;entryPerimeter=0;" edge="1" parent="1" source="iqbZGlfnLgNiDH94HB-4-3" target="iqbZGlfnLgNiDH94HB-4-25">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="iqbZGlfnLgNiDH94HB-4-29" value="Uses" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" vertex="1" connectable="0" parent="iqbZGlfnLgNiDH94HB-4-27">
|
||||
<mxGeometry x="-0.3438" y="1" relative="1" as="geometry">
|
||||
<mxPoint x="16" y="-14" as="offset" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="iqbZGlfnLgNiDH94HB-4-3" value="Server" style="ellipse;shape=cloud;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="410" y="30" width="257" height="190" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="iqbZGlfnLgNiDH94HB-4-4" value="Database" style="shape=cylinder3;whiteSpace=wrap;html=1;boundedLbl=1;backgroundOutline=1;size=15;" vertex="1" parent="1">
|
||||
<mxGeometry x="720" y="10" width="60" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="iqbZGlfnLgNiDH94HB-4-6" value="Routes folder" style="sketch=0;outlineConnect=0;fontColor=#232F3E;gradientColor=none;fillColor=#232F3D;strokeColor=none;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=center;html=1;fontSize=12;fontStyle=0;aspect=fixed;pointerEvents=1;shape=mxgraph.aws4.folder;" vertex="1" parent="1">
|
||||
<mxGeometry x="674.96" y="210" width="45.04" height="41" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="iqbZGlfnLgNiDH94HB-4-12" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.625;entryY=0.2;entryDx=0;entryDy=0;entryPerimeter=0;" edge="1" parent="1" source="iqbZGlfnLgNiDH94HB-4-4" target="iqbZGlfnLgNiDH94HB-4-3">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<Array as="points">
|
||||
<mxPoint x="560" y="40" />
|
||||
<mxPoint x="560" y="58" />
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="iqbZGlfnLgNiDH94HB-4-13" value="Extract DB info for algorithm" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" vertex="1" connectable="0" parent="iqbZGlfnLgNiDH94HB-4-12">
|
||||
<mxGeometry x="0.2696" y="2" relative="1" as="geometry">
|
||||
<mxPoint x="36" y="-12" as="offset" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="iqbZGlfnLgNiDH94HB-4-22" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.16;entryY=0.55;entryDx=0;entryDy=0;entryPerimeter=0;" edge="1" parent="1" source="iqbZGlfnLgNiDH94HB-4-18" target="iqbZGlfnLgNiDH94HB-4-3">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="iqbZGlfnLgNiDH94HB-4-23" value="Send to server" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" vertex="1" connectable="0" parent="iqbZGlfnLgNiDH94HB-4-22">
|
||||
<mxGeometry x="0.0278" y="1" relative="1" as="geometry">
|
||||
<mxPoint x="-10" y="17" as="offset" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="iqbZGlfnLgNiDH94HB-4-18" value="JSON" style="shape=note;whiteSpace=wrap;html=1;backgroundOutline=1;darkOpacity=0.05;" vertex="1" parent="1">
|
||||
<mxGeometry x="310" y="90" width="40" height="80" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="iqbZGlfnLgNiDH94HB-4-25" value="Alg script" style="shape=note;whiteSpace=wrap;html=1;backgroundOutline=1;darkOpacity=0.05;" vertex="1" parent="1">
|
||||
<mxGeometry x="740" y="100" width="60" height="70" as="geometry" />
|
||||
</mxCell>
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
||||
|
After Width: | Height: | Size: 26 KiB |
@@ -0,0 +1,122 @@
|
||||
body {
|
||||
display: grid;
|
||||
grid-template-columns: 20% 60% 20%;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.margin{
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
background-image: linear-gradient(
|
||||
rgb(8, 255, 156),
|
||||
rgb(255, 5, 5),
|
||||
rgb(255, 234, 5),
|
||||
rgb(226, 5, 255)
|
||||
);
|
||||
}
|
||||
|
||||
.main-content{
|
||||
border-left: solid black 2px;
|
||||
border-right: solid black 2px;
|
||||
padding: 3rem;
|
||||
}
|
||||
|
||||
p,
|
||||
ul {
|
||||
font-family: 'Roboto';
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.main-title {
|
||||
text-align: center;
|
||||
font-size: 4rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.authors {
|
||||
text-align: center;
|
||||
font-size: 2rem;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.paragraph {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin-bottom: 2rem;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.header {
|
||||
font-size: 1.7rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.text {
|
||||
text-align: justify;
|
||||
text-justify: inter-word;
|
||||
font-size: 1.1rem;
|
||||
margin-bottom: 0.7rem;
|
||||
}
|
||||
|
||||
.list {
|
||||
margin-left: 2rem;
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
|
||||
.sub-title {
|
||||
font-size: 1.4rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.database_img{
|
||||
display: block;
|
||||
width: 100%;
|
||||
|
||||
margin-top: 2rem;
|
||||
margin-bottom: 2rem;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.routes_img{
|
||||
display: block;
|
||||
width: 80%;
|
||||
|
||||
margin-bottom: 2rem;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.wrap_img {
|
||||
float: right;
|
||||
margin-left: 2rem;
|
||||
margin-bottom: 2rem;
|
||||
width: 70%;
|
||||
}
|
||||
|
||||
.json_paragraph{
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
margin-left: 3rem;
|
||||
margin-right: 3rem;
|
||||
}
|
||||
|
||||
.img_json{
|
||||
margin-left: 5rem;
|
||||
margin-bottom: 2rem;
|
||||
width: 30%;
|
||||
}
|
||||
|
||||
.img_json2{
|
||||
margin-left: 5rem;
|
||||
margin-bottom: 2rem;
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.sub-paragraph{
|
||||
margin-left: 3rem;
|
||||
margin-right: 3rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
@@ -0,0 +1,209 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>Delivery Planner</title>
|
||||
<link rel="stylesheet" href="index.css">
|
||||
<link href='https://fonts.googleapis.com/css?family=Roboto' rel='stylesheet'>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="margin"></div>
|
||||
|
||||
<div class="main-content">
|
||||
<p class="main-title">DeliveryPlanner</p>
|
||||
<div class="authors">
|
||||
<p>Proiect realizat de: </p>
|
||||
<p>Cerbu Andrei - Mihnea </h3>
|
||||
<p>Robert - Giorgio Ciubotaru</h3>
|
||||
</div>
|
||||
|
||||
<div class="paragraph">
|
||||
<p class="header">Cerinta:</p>
|
||||
<p class="text">
|
||||
Sa se realizeze un server de procesare a comenzilor online plasate de clienti.
|
||||
Acest server va analiza o comanda si va stabili cu ajutorul algoritmului
|
||||
‘Multi-Depot-Vehicle-Routing’ traseul cel mai scurt pentru un camion de a
|
||||
colecta produsele de la un depozit/mai multe depozite si a le livra la client.
|
||||
|
||||
</p>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p class="header">Tehnologii:</p>
|
||||
<ul class="list">
|
||||
<li>Server java;</li>
|
||||
<li>Baza de date mySql;</li>
|
||||
<li>Interfata server pentru client/admin realizata cu JavaFX;</li>
|
||||
<li>Fisiere JSON pentru comunicarea pe retea.</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p class="header">Clasificarea utlizatorilor</p>
|
||||
<p class="text">
|
||||
Un utilizator va putea accesa resursele din server numai prin intermediul unei aplicatii.
|
||||
Exista doua tipuri de aplicatii cu diferite functionalitati, aceste tipuri fiind descrise
|
||||
in detaliu in sectiunea 'Interfata'.
|
||||
</p>
|
||||
<p class="text">
|
||||
Utilizatorul 'User' este cel care se foloseste de aplicatie pentru a plasa comenzi catre server.
|
||||
Acestuia i se ofera pe interfata intreaga gama de produse disponibila, acesta urmand sa faca o
|
||||
selectie si sa o trimita la server.
|
||||
</p>
|
||||
<p class="text">
|
||||
Utilizatorul 'Admin' are acces la toate informatiile stocate pe server, incluzand produsele,
|
||||
depozitele, toate comenzile facute de utilizatori 'User' cat si rutele pentru a onora comenzile.
|
||||
Acesta are capacitatea de a insera, modifica, extragere si stergere de informatii din server.
|
||||
</p>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p class="header">Descriere interactiuni</p>
|
||||
<div class="sub-paragraph">
|
||||
<p class="sub-title">a. Plasare comanda</p>
|
||||
|
||||
<img class="wrap_img" src="place_order.png">
|
||||
<p class="text">
|
||||
Utilizatorul se va conecta la server folosind o aplicatie creata pentru a accesa
|
||||
produsele disponibile si pentru a plasa o comanda. Dupa ce utilizatorul a selectat
|
||||
produsele, incluzand cantitatea, dorite, aplicatia va prelua informatiile respective
|
||||
si le va converti intr-un fisier JSON. Acest fisier va fi trimis in retea catre server,
|
||||
care acesta va stoca fisierul in folder-ul denumit 'Orders'.
|
||||
</p>
|
||||
</div>
|
||||
<div class="sub-paragraph">
|
||||
<p class="sub-title">b. Modificare baza de date</p>
|
||||
<p class="text">
|
||||
Aceasta sectiune descrie cazul in care un admin trebuie sa altereze
|
||||
informatii din baza de date. In primul rand trebuie sa prezentam
|
||||
structura bazei de date.
|
||||
</p>
|
||||
<img class="database_img" src="database.png">
|
||||
<p class="text">
|
||||
Baza de date este formata din 5 tabele: 'Deposit', 'Product', 'Prod_In Depo', 'Orders' si 'Routes'.
|
||||
Fiecare tabel va stoca informatii referitoare la un produs, un depozit si produsele dintr-un anumit
|
||||
depozit. Tabelului 'Prod_In_Depo' ne ajuta sa asignam la un ID_Deposit mai multe ID_Product astfel
|
||||
incat
|
||||
firma sa poata tine evidenta produselor care se afla intr-un depozit.
|
||||
</p>
|
||||
<p class="text">
|
||||
Utlizatorul 'Admin' poate insera, modifica sau sterge valori din aceste trei tabele folosindu-se
|
||||
de a doua versiune de aplicatie, dedicata utilizatorilor din cadrul firmei, care contine functiile
|
||||
necesare pentru a efectua operatiile enuntate.
|
||||
</p>
|
||||
</div>
|
||||
<div class="sub-paragraph">
|
||||
<p class="sub-title">c. Generare rute pentru livrarea produselor</p>
|
||||
|
||||
<img class="routes_img" src="generate_route.png">
|
||||
<p class="text">
|
||||
Pe server este implementat algoritmul pentru determinarea celei mai scurte rute pentru a colecta
|
||||
toate produsele necesare pentru livrare. Acest algoritm va rula numai cand un utilizator 'Admin'
|
||||
va selecta un fisier/un set comenzi pentru livrare. Astfel, garantam faptul ca drumul cel mai
|
||||
scurt va fi calculat cu cele mai actuale informatii din baza de date.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p class="header">4. Intelegerea algoritmului</p>
|
||||
<p class="text">
|
||||
Dupa cum s-a exemplificat si mai sus (vezi 3. Generare rute pentru livrearea produselor), pentru
|
||||
determinarea rutelor este folosit un algoritm. Acesta se bazeaza pe problema din teoria grafurilor
|
||||
numita ‘Multi-Depot-Vehicle-Routing’, care determina traseul unui camion astfel incat sa colecteze
|
||||
produsele pentru onorarea unei comenzi utilizand drumul cel mai scurt.
|
||||
</p>
|
||||
<p class="text">
|
||||
Algoritmul va identifica prima oara depozitele in care se afla produsele dintr-o comanda primita ca
|
||||
input. Dupa va ordona in ordine crescatoare (in functie de distanta fata de client) toate depozitele.
|
||||
Dupa va itera prin fiecare depozit si va tine minte ce produse se afla in primul depozit, apoi al doilea
|
||||
pana cand toate produsele au fost localizate. Dupa aceea va lua depozitele in sens invers si va crea un
|
||||
JSON cu depozitele respective si produsele care trebuiesc luate de la un anumit depozit si il va salva
|
||||
in folder-ul dedicat traseelor.
|
||||
</p>
|
||||
<p class="text">
|
||||
Aceasta varianta de algoritm garanteaza faptul ca, in cazul in care chiar daca un depozit contine toate
|
||||
produsele pentru a onora comanda, va putea gasi un drum mai scurt, chiar daca asta ar insemna sa
|
||||
viziteze
|
||||
un numar mai mare de depozite. Deoarece ordonam depozitele in ordine crescatoare in functie de distanta
|
||||
fata de destinatie, dupa ce vizitam un depozit 'i' nu mai poate exista un alt depozit 'j' care sa fie in
|
||||
acelasi timp mai aproape de destinatie fata de 'i' si sa aiba o parte / toate produsele necesare
|
||||
onorarii
|
||||
comenzii.
|
||||
</p>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p class="header">5. Descrierea structurii fisierelor JSON</p>
|
||||
<div class="json_paragraph">
|
||||
<div>
|
||||
<p class="sub-title">a. Order JSON</p>
|
||||
<p class="text">
|
||||
Acest fisier JSON va fi creat in aplicatia utilizata de utilizatorul 'User'. Dupa ce
|
||||
utilizatorul
|
||||
a selectat produsele dorite si a solicitat ca comanda sa fie trimisa, aplicatia va crea un
|
||||
fisier
|
||||
JSON cu structura urmatoare: va exista un singur camp, un array denumit 'products', unde vor fi
|
||||
stocate toate id-urile produselor selectate.
|
||||
</p>
|
||||
</div>
|
||||
<img class="img_json" src="products-json.png">
|
||||
</div>
|
||||
|
||||
<div class="json_paragraph">
|
||||
<div>
|
||||
<p class="sub-title">b. Route JSON</p>
|
||||
<p class="text">
|
||||
Dupa ce algoritmul a fost rulat folosind un JSON de tipul 'Order', va salva in folder-ul dedicat
|
||||
rutelor un JSON cu structura afisata in partea dreapta; JSON ul va contine mai multe obiecte de
|
||||
tipul 'deposit_i' care vor oferii informatii precum:
|
||||
</p>
|
||||
<ul class="list">
|
||||
<li>'name': numele depozitului;</li>
|
||||
<li>'lat_coord': coordonata reala pe glob pe latitudine;</li>
|
||||
<li>'long_coord': coordonata reala pe glob pe longitudine;</li>
|
||||
<li>'products': un array pentru stocarea id-urilor produselor care trebuiesc preluate din
|
||||
depozit.</li>
|
||||
</ul>
|
||||
</div>
|
||||
<img class="img_json" src="route-json.png">
|
||||
|
||||
</div>
|
||||
|
||||
<div class="json_paragraph">
|
||||
<div>
|
||||
<p class="sub-title">c. Items JSON</p>
|
||||
<p class="text">
|
||||
In esenta, fiecare obiect va avea asignat un id (pentru identificarea in baza
|
||||
|
||||
de date) si un nume. In adaos vor exista inca doua campuri pentru 'Deposit',
|
||||
dar celelalte obiecte vor seta acele field uri NULL. Atunci cand user-ul
|
||||
'Admin' va dori sa execute o operatie asupra bazei de date, in back-end
|
||||
se va preciza numele tabelei unde sa fie trimis JSON-ul. Nu va conta ce fel
|
||||
de obiect trebuie sa inseram in baza de date deoarece toate produsele vor
|
||||
respecta aceeasi structura.
|
||||
</p>
|
||||
</div>
|
||||
<img class="img_json" src="baseItemStructure.png">
|
||||
</div>
|
||||
|
||||
<div class="json_paragraph">
|
||||
<div>
|
||||
<p class="text">
|
||||
In esenta, fiecare obiect va avea asignat un id (pentru identificarea in baza
|
||||
de date) si un nume. In adaos vor exista inca doua campuri pentru 'Deposit',
|
||||
dar celelalte obiecte vor seta acele field uri NULL. Atunci cand user-ul
|
||||
'Admin' va dori sa execute o operatie asupra bazei de date, in back-end
|
||||
se va preciza numele tabelei unde sa fie trimis JSON-ul. Nu va conta ce fel
|
||||
de obiect trebuie sa inseram in baza de date deoarece toate produsele vor
|
||||
respecta aceeasi structura.
|
||||
</p>
|
||||
</div>
|
||||
<img class="img_json" src="listOfItems.png">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="margin"></div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
After Width: | Height: | Size: 5.5 KiB |
@@ -0,0 +1,59 @@
|
||||
<mxfile host="app.diagrams.net" modified="2023-05-10T19:56:47.677Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36" etag="2jhWfXdu0t6ZuXVvJqVj" version="21.2.9" type="device">
|
||||
<diagram id="C5RBs43oDa-KdzZeNtuy" name="Page-1">
|
||||
<mxGraphModel dx="1185" dy="642" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
|
||||
<root>
|
||||
<mxCell id="WIyWlLk6GJQsqaUBKTNV-0" />
|
||||
<mxCell id="WIyWlLk6GJQsqaUBKTNV-1" parent="WIyWlLk6GJQsqaUBKTNV-0" />
|
||||
<mxCell id="zt2KT-08LXESvZvVNvZk-11" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0;entryY=0;entryDx=0;entryDy=30;entryPerimeter=0;" edge="1" parent="WIyWlLk6GJQsqaUBKTNV-1" source="zt2KT-08LXESvZvVNvZk-0" target="zt2KT-08LXESvZvVNvZk-5">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="zt2KT-08LXESvZvVNvZk-12" value="Places order through" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" vertex="1" connectable="0" parent="zt2KT-08LXESvZvVNvZk-11">
|
||||
<mxGeometry x="0.76" y="-1" relative="1" as="geometry">
|
||||
<mxPoint x="-46" y="9" as="offset" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="zt2KT-08LXESvZvVNvZk-0" value="User" style="shape=umlActor;verticalLabelPosition=bottom;verticalAlign=top;html=1;outlineConnect=0;" vertex="1" parent="WIyWlLk6GJQsqaUBKTNV-1">
|
||||
<mxGeometry x="100" y="70" width="30" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="zt2KT-08LXESvZvVNvZk-13" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.013;entryY=0.562;entryDx=0;entryDy=0;entryPerimeter=0;" edge="1" parent="WIyWlLk6GJQsqaUBKTNV-1" source="zt2KT-08LXESvZvVNvZk-5" target="zt2KT-08LXESvZvVNvZk-10">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="zt2KT-08LXESvZvVNvZk-14" value="Creates" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" vertex="1" connectable="0" parent="zt2KT-08LXESvZvVNvZk-13">
|
||||
<mxGeometry x="0.2384" y="-1" relative="1" as="geometry">
|
||||
<mxPoint x="-7" y="10" as="offset" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="zt2KT-08LXESvZvVNvZk-5" value="Application" style="shape=cube;whiteSpace=wrap;html=1;boundedLbl=1;backgroundOutline=1;darkOpacity=0.05;darkOpacity2=0.1;" vertex="1" parent="WIyWlLk6GJQsqaUBKTNV-1">
|
||||
<mxGeometry x="240" y="70" width="90" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="zt2KT-08LXESvZvVNvZk-18" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.083;entryY=0.5;entryDx=0;entryDy=0;entryPerimeter=0;" edge="1" parent="WIyWlLk6GJQsqaUBKTNV-1" source="zt2KT-08LXESvZvVNvZk-10" target="zt2KT-08LXESvZvVNvZk-16">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="zt2KT-08LXESvZvVNvZk-19" value="Sends to" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" vertex="1" connectable="0" parent="zt2KT-08LXESvZvVNvZk-18">
|
||||
<mxGeometry x="0.2293" y="1" relative="1" as="geometry">
|
||||
<mxPoint x="-13" y="16" as="offset" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="zt2KT-08LXESvZvVNvZk-10" value="JSON" style="shape=note;whiteSpace=wrap;html=1;backgroundOutline=1;darkOpacity=0.05;" vertex="1" parent="WIyWlLk6GJQsqaUBKTNV-1">
|
||||
<mxGeometry x="380" y="60" width="50" height="70" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="zt2KT-08LXESvZvVNvZk-22" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="WIyWlLk6GJQsqaUBKTNV-1" source="zt2KT-08LXESvZvVNvZk-16" target="zt2KT-08LXESvZvVNvZk-26">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="648.02" y="95.32499999999993" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="zt2KT-08LXESvZvVNvZk-23" value="Stores in" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" vertex="1" connectable="0" parent="zt2KT-08LXESvZvVNvZk-22">
|
||||
<mxGeometry x="-0.257" relative="1" as="geometry">
|
||||
<mxPoint y="15" as="offset" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="zt2KT-08LXESvZvVNvZk-16" value="Server" style="ellipse;shape=cloud;whiteSpace=wrap;html=1;" vertex="1" parent="WIyWlLk6GJQsqaUBKTNV-1">
|
||||
<mxGeometry x="480" y="55" width="120" height="80" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="zt2KT-08LXESvZvVNvZk-26" value="Orders folder" style="sketch=0;outlineConnect=0;fontColor=#232F3E;gradientColor=none;fillColor=#232F3D;strokeColor=none;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=center;html=1;fontSize=12;fontStyle=0;aspect=fixed;pointerEvents=1;shape=mxgraph.aws4.folder;" vertex="1" parent="WIyWlLk6GJQsqaUBKTNV-1">
|
||||
<mxGeometry x="660" y="68.75" width="57.68" height="52.5" as="geometry" />
|
||||
</mxCell>
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
||||
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 5.3 KiB |
|
After Width: | Height: | Size: 12 KiB |
@@ -1 +1,3 @@
|
||||
# Delivery_Planner
|
||||
|
||||
Acest repo contine proiectul 'Delivery Planner' realizat de studentii Cerbu Andrei - Mihnea si Ciubotaru Robert - Giorgio.
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
[
|
||||
{
|
||||
"id_product": 48,
|
||||
"quantity": 3,
|
||||
"name": "JAVA"
|
||||
},
|
||||
{
|
||||
"id_product": 49,
|
||||
"quantity": 2,
|
||||
"name": "SQL"
|
||||
},
|
||||
{
|
||||
"id_product": 51,
|
||||
"quantity": 1,
|
||||
"name": "C++"
|
||||
},
|
||||
{
|
||||
"id_product": 46,
|
||||
"quantity": 1,
|
||||
"name": "PHP"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,5 @@
|
||||
[{
|
||||
"id_product": 48,
|
||||
"quantity": 1,
|
||||
"name": "JAVA"
|
||||
}]
|
||||
@@ -0,0 +1,12 @@
|
||||
[
|
||||
{
|
||||
"id_product": 49,
|
||||
"quantity": 3,
|
||||
"name": "SQL"
|
||||
},
|
||||
{
|
||||
"id_product": 46,
|
||||
"quantity": 2,
|
||||
"name": "PHP"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,4 @@
|
||||
[{
|
||||
"id_product": 1,
|
||||
"quantity": 2
|
||||
}]
|
||||
@@ -0,0 +1,28 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.andreicerbu.deliveryplanner</groupId>
|
||||
<artifactId>Server_Delivery_Planner</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<properties>
|
||||
<maven.compiler.source>20</maven.compiler.source>
|
||||
<maven.compiler.target>20</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
<version>20230227</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
<version>8.0.33</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"id_route": 89,
|
||||
"destination": {
|
||||
"lat_coord": 763.51,
|
||||
"name": "Robert",
|
||||
"id_user": 17,
|
||||
"long_coord": 323.417
|
||||
},
|
||||
"deposits": [
|
||||
{
|
||||
"lat_coord": 40,
|
||||
"distance": 774.57404,
|
||||
"name": "deposit4",
|
||||
"id_deposit": 4,
|
||||
"long_coord": 600,
|
||||
"products": [
|
||||
{
|
||||
"id_product": 46,
|
||||
"quantity": 1,
|
||||
"name": "PHP"
|
||||
},
|
||||
{
|
||||
"id_product": 48,
|
||||
"quantity": 3,
|
||||
"name": "JAVA"
|
||||
},
|
||||
{
|
||||
"id_product": 51,
|
||||
"quantity": 1,
|
||||
"name": "C++"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"lat_coord": 501,
|
||||
"distance": 484.8045,
|
||||
"name": "deposit2",
|
||||
"id_deposit": 5,
|
||||
"long_coord": 731,
|
||||
"products": [{
|
||||
"id_product": 49,
|
||||
"quantity": 2,
|
||||
"name": "SQL"
|
||||
}]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"id_route": 88,
|
||||
"destination": {
|
||||
"lat_coord": 763.51,
|
||||
"name": "Robert",
|
||||
"id_user": 17,
|
||||
"long_coord": 323.417
|
||||
},
|
||||
"deposits": [{
|
||||
"lat_coord": 40,
|
||||
"distance": 774.57404,
|
||||
"name": "deposit4",
|
||||
"id_deposit": 4,
|
||||
"long_coord": 600,
|
||||
"products": [
|
||||
{
|
||||
"id_product": 46,
|
||||
"quantity": 2,
|
||||
"name": "PHP"
|
||||
},
|
||||
{
|
||||
"id_product": 49,
|
||||
"quantity": 3,
|
||||
"name": "SQL"
|
||||
}
|
||||
]
|
||||
}]
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"destination": {
|
||||
"lat_coord": 422.917,
|
||||
"id_user": 1,
|
||||
"long_coord": 151.684
|
||||
},
|
||||
"deposits": [
|
||||
{
|
||||
"lat_coord": 3,
|
||||
"name": "deposit3",
|
||||
"long_coord": 3,
|
||||
"products": []
|
||||
},
|
||||
{
|
||||
"lat_coord": 2,
|
||||
"name": "deposit2",
|
||||
"long_coord": 2,
|
||||
"products": [{
|
||||
"quantity": 2,
|
||||
"name": "apple"
|
||||
}]
|
||||
}
|
||||
],
|
||||
"products": [{
|
||||
"id_product": 1,
|
||||
"quantity": 2
|
||||
}]
|
||||
}
|
||||
@@ -0,0 +1,190 @@
|
||||
package com.andreicerbu;
|
||||
|
||||
import com.andreicerbu.exceptions.*;
|
||||
import com.andreicerbu.items.database.TableDeposit;
|
||||
import com.andreicerbu.json.JsonFields;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
|
||||
import static com.andreicerbu.json.JsonFields.listOfDeposits;
|
||||
|
||||
public class Algorithm {
|
||||
JSONObject order = null;
|
||||
Integer id_user = null;
|
||||
String name = null;
|
||||
Float lat_coord = null;
|
||||
Float long_coord = null;
|
||||
|
||||
JSONObject routeJson = null;
|
||||
JSONObject destination = null;
|
||||
JSONArray deposits = null;
|
||||
|
||||
List<TableDeposit> listOfDeposits = new ArrayList<>();
|
||||
Map<Integer, String> mapProductIdToName = new HashMap<>();
|
||||
|
||||
public Algorithm(JSONObject order) throws SQLException, ProductUnavailableAnymoreException {
|
||||
this.order = new JSONObject(order.toString());
|
||||
this.id_user = this.order.getInt(JsonFields.id_user);
|
||||
this.order.remove(JsonFields.id_user);
|
||||
|
||||
run();
|
||||
}
|
||||
|
||||
private void getUserInformation(Connection conn) throws SQLException{
|
||||
PreparedStatement pstmt = conn.prepareStatement("SELECT * FROM users WHERE id = ?");
|
||||
pstmt.setInt(1, id_user);
|
||||
|
||||
ResultSet resultSet = pstmt.executeQuery();
|
||||
resultSet.next();
|
||||
|
||||
name = resultSet.getString("username");
|
||||
lat_coord = resultSet.getFloat(JsonFields.lat_coord);
|
||||
long_coord = resultSet.getFloat(JsonFields.long_coord);
|
||||
|
||||
destination = new JSONObject();
|
||||
destination.put(JsonFields.id_user, id_user);
|
||||
destination.put(JsonFields.name, name);
|
||||
destination.put(JsonFields.lat_coord, lat_coord);
|
||||
destination.put(JsonFields.long_coord, long_coord);
|
||||
}
|
||||
|
||||
private void getDeposits(Connection conn) throws SQLException{
|
||||
PreparedStatement pstmt = conn.prepareStatement("SELECT * FROM deposits");
|
||||
ResultSet resultSet = pstmt.executeQuery();
|
||||
|
||||
while(resultSet.next()){
|
||||
listOfDeposits.add(new TableDeposit(
|
||||
resultSet.getInt("id"), resultSet.getString("name"),
|
||||
resultSet.getFloat("lat_coord"), resultSet.getFloat("long_coord")
|
||||
));
|
||||
}
|
||||
|
||||
listOfDeposits.sort(new Comparator<TableDeposit>() {
|
||||
@Override
|
||||
public int compare(TableDeposit d1, TableDeposit d2) {
|
||||
return (int) (findDistanceBetweenCoord(d2.getLat_coord(), d2.getLong_coord(), lat_coord, long_coord) -
|
||||
findDistanceBetweenCoord(d1.getLat_coord(), d1.getLong_coord(), lat_coord, long_coord));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private float findDistanceBetweenCoord(Float x1, Float y1, Float x2, Float y2){
|
||||
return (float) Math.sqrt(
|
||||
Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2)
|
||||
);
|
||||
}
|
||||
|
||||
private void getProductNames(Connection conn) throws SQLException {
|
||||
JSONArray products = new JSONArray(order.get(JsonFields.listOfProducts).toString());
|
||||
Statement stmt = conn.createStatement();
|
||||
ResultSet resultSet = stmt.executeQuery("SELECT id, name FROM products");
|
||||
|
||||
while (resultSet.next()) {
|
||||
int id_product = resultSet.getInt("id");
|
||||
String name = resultSet.getString("name");
|
||||
|
||||
for (int index = 0; index < products.length(); index++) {
|
||||
JSONObject item = products.getJSONObject(index);
|
||||
|
||||
if(id_product == item.getInt(JsonFields.id_product)){
|
||||
mapProductIdToName.put(id_product, name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void createRoute(Connection conn) throws SQLException, ProductUnavailableAnymoreException {
|
||||
deposits = new JSONArray();
|
||||
JSONArray products = new JSONArray(order.get(JsonFields.listOfProducts).toString());
|
||||
|
||||
PreparedStatement pstmt;
|
||||
for(TableDeposit deposit : listOfDeposits){//we take each deposit
|
||||
JSONObject depositJSON = new JSONObject(createDepositJSONForRoute(deposit).toString());
|
||||
JSONArray listOfProductsJSON = depositJSON.getJSONArray(JsonFields.listOfProducts);
|
||||
|
||||
pstmt = conn.prepareStatement("SELECT * FROM prod_in_depo WHERE id_deposit = ?");
|
||||
pstmt.setInt(1, deposit.getId_deposit());
|
||||
ResultSet resultSet = pstmt.executeQuery();//we take all the products that exists in a deposit
|
||||
|
||||
while(resultSet.next()){
|
||||
int id_product = resultSet.getInt("id_product");
|
||||
int quantity = resultSet.getInt("quantity");
|
||||
String name = mapProductIdToName.get(id_product);
|
||||
|
||||
for(int index = 0; index < products.length(); index++){//iterate through our order
|
||||
JSONObject item = products.getJSONObject(index);
|
||||
JSONObject itemForList = new JSONObject();
|
||||
|
||||
if(item.getInt(JsonFields.id_product) == id_product){
|
||||
itemForList.put(JsonFields.id_product, id_product);
|
||||
itemForList.put(JsonFields.name, name);
|
||||
int newQuantity = item.getInt(JsonFields.quantity) - quantity;
|
||||
|
||||
if(newQuantity > 0){
|
||||
item.put(JsonFields.quantity, newQuantity);
|
||||
itemForList.put(JsonFields.quantity, quantity);
|
||||
}else{
|
||||
itemForList.put(JsonFields.quantity, item.getInt(JsonFields.quantity));
|
||||
products.remove(index);
|
||||
}
|
||||
|
||||
listOfProductsJSON.put(itemForList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!depositJSON.getJSONArray(JsonFields.listOfProducts).isEmpty()) {
|
||||
deposits.put(depositJSON);
|
||||
}
|
||||
|
||||
if(products.isEmpty()){
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(!products.isEmpty()){
|
||||
throw new ProductUnavailableAnymoreException("One of the chosen products is not available anymore");
|
||||
}
|
||||
}
|
||||
|
||||
private JSONObject createDepositJSONForRoute(TableDeposit deposit){
|
||||
JSONObject depositJSON = new JSONObject();
|
||||
|
||||
depositJSON.put(JsonFields.id_deposit, deposit.getId_deposit());
|
||||
depositJSON.put(JsonFields.name, deposit.getName());
|
||||
depositJSON.put(JsonFields.lat_coord, deposit.getLat_coord());
|
||||
depositJSON.put(JsonFields.long_coord, deposit.getLong_coord());
|
||||
depositJSON.put(JsonFields.listOfProducts, new JSONArray());
|
||||
depositJSON.put(JsonFields.distance, findDistanceBetweenCoord(lat_coord, long_coord, deposit.getLat_coord(), deposit.getLong_coord()));
|
||||
|
||||
return depositJSON;
|
||||
}
|
||||
|
||||
|
||||
private void createJsonRoute(){
|
||||
routeJson = new JSONObject();
|
||||
|
||||
routeJson.put(JsonFields.destination, destination);
|
||||
routeJson.put(JsonFields.listOfDeposits, deposits);
|
||||
routeJson.put(JsonFields.listOfProducts, order.getJSONArray(JsonFields.listOfProducts));
|
||||
}
|
||||
|
||||
private synchronized void run() throws SQLException, ProductUnavailableAnymoreException{
|
||||
Connection conn = Database.getConnection();
|
||||
|
||||
getUserInformation(conn);
|
||||
getDeposits(conn);
|
||||
getProductNames(conn);
|
||||
|
||||
createRoute(conn);
|
||||
createJsonRoute();
|
||||
}
|
||||
|
||||
public JSONObject getRouteJson() {
|
||||
return routeJson;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.andreicerbu;
|
||||
|
||||
import com.andreicerbu.json.JsonFields;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class ClientThread extends Thread{
|
||||
private final Socket socket;
|
||||
private boolean isRunning = true;
|
||||
private static final int TIME_OUT = 3000;
|
||||
|
||||
public ClientThread(Socket socket)throws IOException {
|
||||
this.socket = socket;
|
||||
socket.setSoTimeout(TIME_OUT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(){
|
||||
try {
|
||||
BufferedReader in = new BufferedReader(
|
||||
new InputStreamReader(socket.getInputStream()));
|
||||
PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
|
||||
|
||||
SocketInput socketInput = new SocketInput();
|
||||
|
||||
while (isRunning) {
|
||||
try {
|
||||
if(!socket.isConnected()){
|
||||
throw new SocketTimeoutException();
|
||||
}
|
||||
String input = in.readLine();
|
||||
socketInput = new SocketInput(input);
|
||||
|
||||
Connection conn = Database.getConnection();
|
||||
socketInput.processInputJson(conn);
|
||||
|
||||
out.println(socketInput.getJsonResponse().toString());
|
||||
} catch (SocketTimeoutException ignored) {
|
||||
} catch (SQLException e) {
|
||||
socketInput.processOutputJson(JsonFields.responseError, "Internal server error.\nPlease try again later");
|
||||
out.println(socketInput.getJsonResponse().toString());
|
||||
} catch (IOException e){
|
||||
System.out.println("Closing Thread");
|
||||
System.out.flush();
|
||||
isRunning = false;
|
||||
}
|
||||
}
|
||||
|
||||
in.close();
|
||||
out.close();
|
||||
socket.close();
|
||||
}catch(IOException ignored){
|
||||
}
|
||||
}
|
||||
|
||||
public void endThread(){
|
||||
isRunning = false;
|
||||
}
|
||||
|
||||
public boolean isThreadNotAlive(){
|
||||
return !this.isAlive();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,650 @@
|
||||
package com.andreicerbu;
|
||||
|
||||
import com.andreicerbu.exceptions.*;
|
||||
import com.andreicerbu.items.AdminJson;
|
||||
import com.andreicerbu.items.BaseItem;
|
||||
import com.andreicerbu.json.JsonFields;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.sql.*;
|
||||
import java.util.Random;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Database {
|
||||
private static final String URL =
|
||||
"jdbc:mysql://localhost:3306/java";
|
||||
private static final String USER = "root";
|
||||
private static final String PASSWORD = "";
|
||||
|
||||
private static Connection conn;
|
||||
|
||||
public static Connection getConnection() throws SQLException{
|
||||
conn = DriverManager.getConnection(URL, USER, PASSWORD);
|
||||
conn.setAutoCommit(false);
|
||||
return conn;
|
||||
}
|
||||
|
||||
|
||||
public static synchronized void placeOrder(Connection conn, JSONObject json, Integer id_user) throws SQLException, IOException {
|
||||
JSONArray listOfProducts = new JSONArray(json.getJSONArray(JsonFields.listOfProducts));
|
||||
json.remove(JsonFields.listOfProducts);
|
||||
|
||||
for(int index = 0; index < listOfProducts.length(); index++){
|
||||
JSONObject item = listOfProducts.getJSONObject(index);
|
||||
PreparedStatement pstmt = conn.prepareStatement("SELECT * FROM products WHERE id = ?");
|
||||
pstmt.setInt(1, item.getInt(JsonFields.id_product));
|
||||
ResultSet resultSet = pstmt.executeQuery();
|
||||
resultSet.next();
|
||||
|
||||
item.put(JsonFields.name, resultSet.getString("name"));
|
||||
}
|
||||
|
||||
String pathToOrders = "D:\\Server Delivery Planner\\orders\\";
|
||||
String pathToRoutes = "D:\\Server Delivery Planner\\routes\\";
|
||||
String pathToOrderDatabase = "D:\\\\Server Delivery Planner\\\\orders\\\\";
|
||||
String pathToRouteDatabase = "D:\\\\Server Delivery Planner\\\\routes\\\\";
|
||||
|
||||
|
||||
String nameOfFile;
|
||||
while(true){
|
||||
nameOfFile = randomStringGenerator();
|
||||
|
||||
Statement pstmt = conn.createStatement();
|
||||
ResultSet resultSet = pstmt.executeQuery("SELECT * FROM orders WHERE path_to_file = '" + pathToOrderDatabase + nameOfFile + "'");
|
||||
if(!resultSet.next()){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
String orderFileName = pathToOrders + nameOfFile + "_order.txt";
|
||||
String routeFileName = pathToRoutes + nameOfFile + "_route.txt";
|
||||
|
||||
PreparedStatement pstmt = conn.prepareStatement("INSERT INTO orders (path_to_file) VALUES (?)");
|
||||
pstmt.setString(1,pathToOrderDatabase + nameOfFile + "_order.txt" );
|
||||
pstmt.executeUpdate();
|
||||
|
||||
pstmt = conn.prepareStatement("INSERT INTO routes (path_to_file) VALUES (?)");
|
||||
pstmt.setString(1, pathToRouteDatabase + nameOfFile + "_route.txt");
|
||||
pstmt.executeUpdate();
|
||||
|
||||
conn.commit();
|
||||
|
||||
int idOrder;
|
||||
pstmt = conn.prepareStatement("SELECT id FROM orders WHERE path_to_file = ?");
|
||||
pstmt.setString(1,pathToOrderDatabase + nameOfFile + "_order.txt" );
|
||||
ResultSet resultSet = pstmt.executeQuery();
|
||||
resultSet.next();
|
||||
idOrder = resultSet.getInt("id");
|
||||
|
||||
pstmt = conn.prepareStatement("SELECT id FROM routes WHERE path_to_file = ?");
|
||||
pstmt.setString(1,pathToRouteDatabase + nameOfFile + "_route.txt" );
|
||||
resultSet = pstmt.executeQuery();
|
||||
resultSet.next();
|
||||
json.put(JsonFields.id_route, resultSet.getInt("id"));
|
||||
|
||||
File order = new File(orderFileName);
|
||||
File route = new File(routeFileName);
|
||||
|
||||
FileWriter writerOrder = new FileWriter(order);
|
||||
FileWriter writerRoute = new FileWriter(route);
|
||||
|
||||
writerOrder.write(listOfProducts.toString(4));
|
||||
writerRoute.write(json.toString(4));
|
||||
|
||||
writerOrder.close();
|
||||
writerRoute.close();
|
||||
|
||||
JSONArray array = new JSONArray(listOfProducts.toString());
|
||||
for(int index = 0; index < array.length(); index++){
|
||||
JSONObject item = array.getJSONObject(index);
|
||||
|
||||
pstmt = conn.prepareStatement("SELECT * FROM prod_in_depo");
|
||||
ResultSet products = pstmt.executeQuery();
|
||||
while(products.next()){
|
||||
int id_product = products.getInt(JsonFields.id_product);
|
||||
int quantity = products.getInt(JsonFields.quantity);
|
||||
int id_deposit = products.getInt(JsonFields.id_deposit);
|
||||
|
||||
if(item.getInt(JsonFields.id_product) == id_product && item.has(JsonFields.quantity)){
|
||||
if(quantity - item.getInt(JsonFields.quantity) > 0) {
|
||||
int newQuantity = quantity - item.getInt(JsonFields.quantity);
|
||||
item.put(JsonFields.quantity, newQuantity);
|
||||
pstmt = conn.prepareStatement(
|
||||
"UPDATE prod_in_depo SET quantity = ? WHERE id_product = ? AND id_deposit = ?");
|
||||
pstmt.setInt(1, item.getInt(JsonFields.quantity));
|
||||
pstmt.setInt(2, id_product);
|
||||
pstmt.setInt(3, id_deposit);
|
||||
|
||||
item.remove(JsonFields.quantity);
|
||||
|
||||
pstmt.executeUpdate();
|
||||
conn.commit();
|
||||
|
||||
|
||||
}else{
|
||||
int newQuantity = item.getInt(JsonFields.quantity) - quantity;
|
||||
item.put(JsonFields.quantity, newQuantity);
|
||||
pstmt = conn.prepareStatement("DELETE FROM prod_in_depo WHERE id_product = ? AND id_deposit = ?");
|
||||
pstmt.setInt(1, id_product);
|
||||
pstmt.setInt(2, id_deposit);
|
||||
|
||||
if(newQuantity == 0){
|
||||
item.remove(JsonFields.quantity);
|
||||
}else {
|
||||
item.put(JsonFields.quantity, newQuantity);
|
||||
}
|
||||
|
||||
pstmt.executeUpdate();
|
||||
conn.commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pstmt = conn.prepareStatement("INSERT INTO user_orders (id_user, id_order) VALUES (?, ?) ");
|
||||
pstmt.setInt(1, id_user);
|
||||
pstmt.setInt(2, idOrder);
|
||||
|
||||
pstmt.executeUpdate();
|
||||
conn.commit();
|
||||
}
|
||||
|
||||
private static String randomStringGenerator(){
|
||||
int leftLimit = 97; // letter 'a'
|
||||
int rightLimit = 122; // letter 'z'
|
||||
int targetStringLength = 10;
|
||||
Random random = new Random();
|
||||
|
||||
return random.ints(leftLimit, rightLimit + 1)
|
||||
.limit(targetStringLength)
|
||||
.collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append)
|
||||
.toString();
|
||||
}
|
||||
|
||||
public static JSONObject getUserOrders(Connection conn, Integer idUser) throws SQLException, IOException {
|
||||
JSONObject json = new JSONObject();
|
||||
JSONArray array = new JSONArray();
|
||||
PreparedStatement getUserOrders = conn.prepareStatement("SELECT id_order WHERE id_user = ?");
|
||||
getUserOrders.setInt(1, idUser);
|
||||
|
||||
ResultSet userOrders = getUserOrders.executeQuery();
|
||||
while(userOrders.next()){
|
||||
int id_order = userOrders.getInt("id_order");
|
||||
PreparedStatement getOrders = conn.prepareStatement("SELECT path_to_file FROM orders WHERE id = ?");
|
||||
getOrders.setInt(1, id_order);
|
||||
|
||||
ResultSet order = getOrders.executeQuery();
|
||||
if(!order.next()){
|
||||
continue;
|
||||
}
|
||||
|
||||
String path = order.getString("path_to_file");
|
||||
array.put(getDataFromFile(path));
|
||||
}
|
||||
|
||||
json.put(JsonFields.response, JsonFields.responseSuccess);
|
||||
json.put(JsonFields.responseMessage, array);
|
||||
|
||||
return json;
|
||||
}
|
||||
|
||||
private static String getDataFromFile(String path) throws IOException{
|
||||
Scanner myReader = new Scanner(new File(path));
|
||||
StringBuilder data = new StringBuilder();
|
||||
|
||||
while(myReader.hasNextLine()){
|
||||
data.append(myReader.nextLine());
|
||||
}
|
||||
|
||||
return data.toString();
|
||||
}
|
||||
|
||||
public static void registerUser(Connection conn, BaseItem user) throws SQLException, InvalidCredentialsException {
|
||||
PreparedStatement pstmt = conn.prepareStatement("SELECT * FROM users where email = ?");
|
||||
pstmt.setString(1, user.getEmail());
|
||||
ResultSet resultSet = pstmt.executeQuery();
|
||||
|
||||
if(resultSet.isBeforeFirst()){
|
||||
throw new InvalidCredentialsException("User already exists");
|
||||
}
|
||||
|
||||
pstmt = conn.prepareStatement(
|
||||
"INSERT INTO users (username, email, password, lat_coord, long_coord) VALUES (?, ?, ?, ?, ?)");
|
||||
pstmt.setString(1, user.getName());
|
||||
pstmt.setString(2, user.getEmail());
|
||||
pstmt.setString(3, user.getPassword());
|
||||
pstmt.setFloat(4, user.getLat_coord());
|
||||
pstmt.setFloat(5, user.getLong_coord());
|
||||
|
||||
pstmt.executeUpdate();
|
||||
conn.commit();
|
||||
}
|
||||
|
||||
public static Integer loginUser(Connection conn, BaseItem user) throws SQLException, InvalidCredentialsException {
|
||||
Statement stmt = conn.createStatement();
|
||||
ResultSet resultSet = stmt.executeQuery("SELECT id, password FROM users WHERE email = '" + user.getEmail() + "'");
|
||||
|
||||
if(!resultSet.isBeforeFirst()){
|
||||
throw new InvalidCredentialsException("Incorrect credentials");
|
||||
}
|
||||
|
||||
resultSet.next();
|
||||
Integer id = resultSet.getInt("id");
|
||||
String password = resultSet.getString("password");
|
||||
|
||||
if(!user.getPassword().equals(password)){
|
||||
throw new InvalidCredentialsException("Incorrect credentials");
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
public static void alterTable(Connection conn, AdminJson adminJson) throws SQLException, ProcessDoneException,
|
||||
FieldToUpdateNotExistingException, FieldAlreadyExistsException {
|
||||
|
||||
switch (adminJson.getTable()){
|
||||
case JsonFields.tableRoutes -> alterTableRoutes(conn, adminJson);
|
||||
case JsonFields.tableDeposits -> alterTableDeposits(conn, adminJson);
|
||||
case JsonFields.tableProducts -> alterTableProducts(conn, adminJson);
|
||||
case JsonFields.tableProdInDepo -> alterTableProdInDepo(conn, adminJson);
|
||||
case JsonFields.tableUsers -> alterTableUsers(conn, adminJson);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static void alterTableRoutes(Connection conn, AdminJson adminJson) throws SQLException, ProcessDoneException {
|
||||
try {
|
||||
PreparedStatement pstmt = conn.prepareStatement("SELECT * FROM routes WHERE id = ?");
|
||||
pstmt.setInt(1, adminJson.getListOfValues().get(0).getId_route());
|
||||
ResultSet resultSet = pstmt.executeQuery();
|
||||
|
||||
if(!resultSet.isBeforeFirst()){
|
||||
throw new SQLException();
|
||||
}
|
||||
|
||||
String nameOfFile = getNameOfFileRoute(conn, adminJson.getListOfValues().get(0).getId_route());
|
||||
|
||||
pstmt = conn.prepareStatement("DELETE FROM routes WHERE id = ?");
|
||||
pstmt.setInt(1, adminJson.getListOfValues().get(0).getId_route());
|
||||
pstmt.executeUpdate();
|
||||
|
||||
File routeFile = new File("D:\\Server Delivery Planner\\routes\\" + nameOfFile + "_route.txt");
|
||||
|
||||
System.gc();
|
||||
routeFile.delete();
|
||||
|
||||
conn.commit();
|
||||
throw new ProcessDoneException("Route successfully deleted");
|
||||
} catch (SQLException ignored){
|
||||
throw new SQLException("Route was already deleted");
|
||||
}
|
||||
}
|
||||
|
||||
private static void alterTableDeposits(Connection conn, AdminJson adminJson) throws SQLException, ProcessDoneException{
|
||||
switch (adminJson.getCommand()){
|
||||
case JsonFields.commandInsert -> {
|
||||
try {
|
||||
PreparedStatement pstmt = conn.prepareStatement("SELECT * FROM deposits WHERE name = ?");
|
||||
pstmt.setString(1, adminJson.getListOfValues().get(0).getName());
|
||||
ResultSet resultSet = pstmt.executeQuery();
|
||||
|
||||
if(resultSet.isBeforeFirst()){
|
||||
throw new SQLException();
|
||||
}
|
||||
|
||||
pstmt = conn.prepareStatement("INSERT INTO deposits (name, lat_coord, long_coord) VALUES (?, ?, ?)");
|
||||
pstmt.setString(1, adminJson.getListOfValues().get(0).getName());
|
||||
pstmt.setFloat(2, adminJson.getListOfValues().get(0).getLat_coord());
|
||||
pstmt.setFloat(3, adminJson.getListOfValues().get(0).getLong_coord());
|
||||
|
||||
pstmt.executeUpdate();
|
||||
conn.commit();
|
||||
|
||||
throw new ProcessDoneException("Deposit " + adminJson.getListOfValues().get(0).getName() + " successfully inserted");
|
||||
} catch (SQLException ignored){
|
||||
throw new SQLException("Deposit " + adminJson.getListOfValues().get(0).getName() + " was already inserted");
|
||||
}
|
||||
}
|
||||
|
||||
case JsonFields.commandUpdate -> {
|
||||
try {
|
||||
PreparedStatement pstmt = conn.prepareStatement("SELECT * FROM deposits WHERE lat_coord = ? AND long_coord = ? AND id <> ? ");
|
||||
pstmt.setString(1, adminJson.getListOfValues().get(0).getName());
|
||||
pstmt.setFloat(2, adminJson.getListOfValues().get(0).getLat_coord());
|
||||
pstmt.setFloat(3, adminJson.getListOfValues().get(0).getLong_coord());
|
||||
pstmt.setInt(4, adminJson.getListOfValues().get(0).getId_deposit());
|
||||
ResultSet resultSet = pstmt.executeQuery();
|
||||
|
||||
if(resultSet.isBeforeFirst()){
|
||||
throw new SQLException();
|
||||
}
|
||||
|
||||
pstmt = conn.prepareStatement("UPDATE deposits SET name = ?, lat_coord = ?, long_coord = ? WHERE id = ?");
|
||||
pstmt.setString(1, adminJson.getListOfValues().get(0).getName());
|
||||
pstmt.setFloat(2, adminJson.getListOfValues().get(0).getLat_coord());
|
||||
pstmt.setFloat(3, adminJson.getListOfValues().get(0).getLong_coord());
|
||||
pstmt.setInt(4, adminJson.getListOfValues().get(0).getId_deposit());
|
||||
|
||||
pstmt.executeUpdate();
|
||||
conn.commit();
|
||||
|
||||
throw new ProcessDoneException("Deposit successfully updated");
|
||||
} catch (SQLException ignored){
|
||||
throw new SQLException("Deposit was not updated");
|
||||
}
|
||||
}
|
||||
|
||||
case JsonFields.commandDelete -> {
|
||||
try {
|
||||
PreparedStatement pstmt = conn.prepareStatement("SELECT * FROM deposits WHERE id = ?");
|
||||
pstmt.setInt(1, adminJson.getListOfValues().get(0).getId_deposit());
|
||||
ResultSet resultSet = pstmt.executeQuery();
|
||||
|
||||
if(!resultSet.isBeforeFirst()){
|
||||
throw new SQLException();
|
||||
}
|
||||
|
||||
int idDeposit = adminJson.getListOfValues().get(0).getId_deposit();
|
||||
pstmt = conn.prepareStatement("DELETE FROM prod_in_depo WHERE id_deposit = ?");
|
||||
pstmt.setInt(1, idDeposit);
|
||||
pstmt.executeUpdate();
|
||||
|
||||
pstmt = conn.prepareStatement("DELETE FROM deposits WHERE id = ?");
|
||||
pstmt.setInt(1, idDeposit);
|
||||
pstmt.executeUpdate();
|
||||
|
||||
conn.commit();
|
||||
|
||||
throw new ProcessDoneException("Deposit " + adminJson.getListOfValues().get(0).getName() + " successfully deleted");
|
||||
} catch (SQLException ignored){
|
||||
throw new SQLException("Deposit " + adminJson.getListOfValues().get(0).getName() + " was already deleted");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void alterTableProducts(Connection conn, AdminJson adminJson) throws SQLException, ProcessDoneException,
|
||||
FieldToUpdateNotExistingException, FieldAlreadyExistsException{
|
||||
switch (adminJson.getCommand()){
|
||||
case JsonFields.commandInsert -> {
|
||||
try {
|
||||
PreparedStatement pstmt = conn.prepareStatement("SELECT * FROM products WHERE name = ?");
|
||||
pstmt.setString(1, adminJson.getListOfValues().get(0).getName());
|
||||
ResultSet resultSet = pstmt.executeQuery();
|
||||
|
||||
if(resultSet.isBeforeFirst()){
|
||||
throw new SQLException();
|
||||
}
|
||||
|
||||
pstmt = conn.prepareStatement("INSERT INTO products (name) VALUES (?)");
|
||||
pstmt.setString(1, adminJson.getListOfValues().get(0).getName());
|
||||
|
||||
pstmt.executeUpdate();
|
||||
conn.commit();
|
||||
|
||||
throw new ProcessDoneException("Product " + adminJson.getListOfValues().get(0).getName() + " successfully inserted");
|
||||
} catch (SQLException ignored){
|
||||
throw new SQLException("Product " + adminJson.getListOfValues().get(0).getName() + " was already inserted");
|
||||
}
|
||||
}
|
||||
|
||||
case JsonFields.commandUpdate -> {
|
||||
String oldName = null;
|
||||
try {
|
||||
PreparedStatement pstmt = conn.prepareStatement("SELECT * FROM products WHERE id = ?");
|
||||
pstmt.setInt(1, adminJson.getListOfValues().get(0).getId_product());
|
||||
ResultSet resultSet = pstmt.executeQuery();
|
||||
|
||||
if(!resultSet.isBeforeFirst()){
|
||||
throw new FieldToUpdateNotExistingException("Product not existing anymore");
|
||||
}
|
||||
|
||||
resultSet.next();
|
||||
oldName = resultSet.getString("name");
|
||||
|
||||
pstmt = conn.prepareStatement("SELECT id FROM products WHERE name = ?");
|
||||
pstmt.setString(1, adminJson.getListOfValues().get(0).getName());
|
||||
resultSet = pstmt.executeQuery();
|
||||
|
||||
if(resultSet.isBeforeFirst()){
|
||||
throw new FieldAlreadyExistsException("New label can't be added because it already exists");
|
||||
}
|
||||
|
||||
pstmt = conn.prepareStatement("UPDATE products SET name = ? WHERE id = ?");
|
||||
pstmt.setString(1, adminJson.getListOfValues().get(0).getName());
|
||||
pstmt.setInt(2, adminJson.getListOfValues().get(0).getId_product());
|
||||
|
||||
pstmt.executeUpdate();
|
||||
conn.commit();
|
||||
|
||||
throw new ProcessDoneException("Product " + oldName + " successfully updated to " + adminJson.getListOfValues().get(0).getName());
|
||||
} catch (SQLException ignored){
|
||||
throw new SQLException( "Product " + oldName + " was not updated to " + adminJson.getListOfValues().get(0).getName());
|
||||
}
|
||||
}
|
||||
|
||||
case JsonFields.commandDelete -> {
|
||||
try {
|
||||
PreparedStatement pstmt = conn.prepareStatement("SELECT * FROM products WHERE id = ?");
|
||||
pstmt.setInt(1, adminJson.getListOfValues().get(0).getId_product());
|
||||
ResultSet resultSet = pstmt.executeQuery();
|
||||
|
||||
if(!resultSet.isBeforeFirst()){
|
||||
throw new SQLException();
|
||||
}
|
||||
|
||||
pstmt = conn.prepareStatement("DELETE FROM prod_in_depo WHERE id_product = ?");
|
||||
pstmt.setInt(1, adminJson.getListOfValues().get(0).getId_product());
|
||||
pstmt.executeUpdate();
|
||||
|
||||
pstmt = conn.prepareStatement("DELETE FROM products WHERE id = ?");
|
||||
pstmt.setInt(1, adminJson.getListOfValues().get(0).getId_product());
|
||||
pstmt.executeUpdate();
|
||||
|
||||
conn.commit();
|
||||
|
||||
throw new ProcessDoneException("Product " + adminJson.getListOfValues().get(0).getName() + " successfully deleted");
|
||||
}catch (SQLException ignored){
|
||||
throw new SQLException("Product " + adminJson.getListOfValues().get(0).getName() + " was already deleted");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void alterTableProdInDepo(Connection conn, AdminJson adminJson) throws SQLException, ProcessDoneException, FieldToUpdateNotExistingException {
|
||||
switch (adminJson.getCommand()) {
|
||||
case JsonFields.commandInsert -> {
|
||||
try {
|
||||
String name = adminJson.getListOfValues().get(0).getName();
|
||||
PreparedStatement pstmt = conn.prepareStatement("SELECT * FROM products WHERE name = ?");
|
||||
pstmt.setString(1, name);
|
||||
ResultSet resultSet = pstmt.executeQuery();
|
||||
|
||||
if(!resultSet.isBeforeFirst()){
|
||||
throw new FieldToUpdateNotExistingException("Product not existing anymore");
|
||||
}
|
||||
|
||||
resultSet.next();
|
||||
int idProduct = resultSet.getInt("id");
|
||||
|
||||
pstmt = conn.prepareStatement("SELECT * FROM prod_in_depo WHERE id_product = ? AND id_deposit = ?");
|
||||
pstmt.setInt(1, idProduct);
|
||||
pstmt.setInt(2, adminJson.getListOfValues().get(0).getId_deposit());
|
||||
resultSet = pstmt.executeQuery();
|
||||
|
||||
if(resultSet.isBeforeFirst()){
|
||||
throw new SQLException();
|
||||
}
|
||||
|
||||
pstmt = conn.prepareStatement("INSERT INTO prod_in_depo (id_product, id_deposit, quantity) VALUES (?, ?, ?)");
|
||||
pstmt.setInt(1, idProduct);
|
||||
pstmt.setInt(2, adminJson.getListOfValues().get(0).getId_deposit());
|
||||
pstmt.setInt(3, adminJson.getListOfValues().get(0).getQuantity());
|
||||
|
||||
pstmt.executeUpdate();
|
||||
conn.commit();
|
||||
|
||||
throw new ProcessDoneException("Product " + adminJson.getListOfValues().get(0).getName() + " successfully inserted in deposit");
|
||||
} catch (SQLException ignored){
|
||||
throw new SQLException("Product " + adminJson.getListOfValues().get(0).getName() + " was already inserted in deposit");
|
||||
}
|
||||
}
|
||||
|
||||
case JsonFields.commandUpdate -> {
|
||||
try {
|
||||
PreparedStatement pstmt = conn.prepareStatement("SELECT * FROM prod_in_depo WHERE id_product = ? AND id_deposit = ?");
|
||||
pstmt.setInt(1, adminJson.getListOfValues().get(0).getId_product());
|
||||
pstmt.setInt(2, adminJson.getListOfValues().get(0).getId_deposit());
|
||||
ResultSet resultSet = pstmt.executeQuery();
|
||||
|
||||
if(!resultSet.isBeforeFirst()){
|
||||
throw new SQLException();
|
||||
}
|
||||
|
||||
pstmt = conn.prepareStatement("UPDATE prod_in_depo SET quantity = ? WHERE id_product = ? AND id_deposit = ?");
|
||||
|
||||
pstmt.setInt(1, adminJson.getListOfValues().get(0).getQuantity());
|
||||
pstmt.setInt(2, adminJson.getListOfValues().get(0).getId_product());
|
||||
pstmt.setInt(3, adminJson.getListOfValues().get(0).getId_deposit());
|
||||
|
||||
pstmt.executeUpdate();
|
||||
conn.commit();
|
||||
|
||||
throw new ProcessDoneException("Product " + adminJson.getListOfValues().get(0).getName() + " successfully updated");
|
||||
} catch (SQLException ignored){
|
||||
throw new SQLException("Product " + adminJson.getListOfValues().get(0).getName() + " was not updated");
|
||||
}
|
||||
}
|
||||
|
||||
case JsonFields.commandDelete -> {
|
||||
try {
|
||||
PreparedStatement pstmt = conn.prepareStatement("SELECT * FROM prod_in_depo WHERE id_product = ? AND id_deposit = ?");
|
||||
pstmt.setInt(1, adminJson.getListOfValues().get(0).getId_product());
|
||||
pstmt.setInt(2, adminJson.getListOfValues().get(0).getId_deposit());
|
||||
ResultSet resultSet = pstmt.executeQuery();
|
||||
|
||||
if(!resultSet.isBeforeFirst()){
|
||||
throw new SQLException();
|
||||
}
|
||||
|
||||
pstmt = conn.prepareStatement("DELETE FROM prod_in_depo WHERE id_product = ? AND id_deposit = ?");
|
||||
pstmt.setInt(1, adminJson.getListOfValues().get(0).getId_product());
|
||||
pstmt.setInt(2, adminJson.getListOfValues().get(0).getId_deposit());
|
||||
|
||||
pstmt.executeUpdate();
|
||||
conn.commit();
|
||||
|
||||
throw new ProcessDoneException("Product " + adminJson.getListOfValues().get(0).getName() + " successfully deleted from deposit");
|
||||
} catch (SQLException ignored) {
|
||||
throw new SQLException("Product " + adminJson.getListOfValues().get(0).getName() + " was already deleted from deposit");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static void alterTableUsers(Connection conn, AdminJson adminJson) throws SQLException, ProcessDoneException{
|
||||
try {
|
||||
PreparedStatement pstmt = conn.prepareStatement("SELECT * FROM users WHERE id = ?");//check for user existence
|
||||
pstmt.setInt(1, adminJson.getListOfValues().get(0).getId_user());
|
||||
ResultSet resultSet = pstmt.executeQuery();
|
||||
|
||||
if(!resultSet.isBeforeFirst()){
|
||||
throw new SQLException();
|
||||
}
|
||||
|
||||
pstmt = conn.prepareStatement("SELECT id_order FROM user_orders WHERE id_user = ?");//get all orders made by user
|
||||
pstmt.setInt(1, adminJson.getListOfValues().get(0).getId_user());
|
||||
resultSet = pstmt.executeQuery();
|
||||
|
||||
while(resultSet.next()){
|
||||
int id_order = resultSet.getInt("id_order");
|
||||
String nameOfOrder = getNameOfFile(conn, id_order);
|
||||
|
||||
String pathToFileRouteDatabase = "D:\\\\Server Delivery Planner\\\\routes\\\\" + nameOfOrder + "_route.txt";
|
||||
String pathToFileOrderDatabase = "D:\\\\Server Delivery Planner\\\\orders\\\\" + nameOfOrder + "_order.txt";
|
||||
String pathToFileOrder = "D:\\Server Delivery Planner\\orders\\" + nameOfOrder + "_order.txt";
|
||||
String pathToFileRoute = "D:\\Server Delivery Planner\\routes\\" + nameOfOrder + "_route.txt";
|
||||
|
||||
File orderFile = new File(pathToFileOrder);
|
||||
File routeFile = new File(pathToFileRoute);
|
||||
|
||||
System.gc();
|
||||
orderFile.delete();
|
||||
|
||||
System.gc();
|
||||
routeFile.delete();
|
||||
|
||||
pstmt = conn.prepareStatement("DELETE FROM user_orders WHERE id_order = ?");
|
||||
pstmt.setInt(1, id_order);
|
||||
pstmt.executeUpdate();
|
||||
|
||||
pstmt = conn.prepareStatement("DELETE FROM orders WHERE path_to_file = ?");
|
||||
pstmt.setString(1, pathToFileOrderDatabase);
|
||||
pstmt.executeUpdate();
|
||||
|
||||
pstmt = conn.prepareStatement("DELETE FROM routes WHERE path_to_file = ?");
|
||||
pstmt.setString(1, pathToFileRouteDatabase);
|
||||
pstmt.executeUpdate();
|
||||
|
||||
conn.commit();
|
||||
}
|
||||
|
||||
pstmt = conn.prepareStatement("DELETE FROM users WHERE id = ?");
|
||||
pstmt.setInt(1, adminJson.getListOfValues().get(0).getId_user());
|
||||
pstmt.executeUpdate();
|
||||
|
||||
conn.commit();
|
||||
|
||||
throw new ProcessDoneException("User " + adminJson.getListOfValues().get(0).getName() + " successfully deleted");
|
||||
} catch (SQLException ignored){
|
||||
throw new SQLException("User " + adminJson.getListOfValues().get(0).getName() + " was already deleted");
|
||||
}
|
||||
}
|
||||
|
||||
private static String getNameOfFile(Connection conn, int id_order)throws SQLException{
|
||||
PreparedStatement pstmt = conn.prepareStatement("SELECT path_to_file FROM orders WHERE id = ?");
|
||||
pstmt.setInt(1, id_order);
|
||||
ResultSet resultSet1 = pstmt.executeQuery();
|
||||
resultSet1.next();
|
||||
|
||||
String resultStringToProcess = resultSet1.getString("path_to_file");
|
||||
int left, right = resultStringToProcess.indexOf('_');
|
||||
left = right;
|
||||
|
||||
while(resultStringToProcess.charAt(left) != '\\'){
|
||||
left--;
|
||||
}
|
||||
left++;
|
||||
|
||||
return resultStringToProcess.substring(left, right);
|
||||
}
|
||||
|
||||
private static String getNameOfFileRoute(Connection conn, int id_route)throws SQLException{
|
||||
PreparedStatement pstmt = conn.prepareStatement("SELECT path_to_file FROM routes WHERE id = ?");
|
||||
pstmt.setInt(1, id_route);
|
||||
ResultSet resultSet1 = pstmt.executeQuery();
|
||||
resultSet1.next();
|
||||
|
||||
String resultStringToProcess = resultSet1.getString("path_to_file");
|
||||
int left, right = resultStringToProcess.indexOf('_');
|
||||
left = right;
|
||||
|
||||
while(resultStringToProcess.charAt(left) != '\\'){
|
||||
left--;
|
||||
}
|
||||
left++;
|
||||
|
||||
return resultStringToProcess.substring(left, right);
|
||||
}
|
||||
|
||||
|
||||
public static void closeConnection(Connection conn) throws SQLException{
|
||||
conn.close();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.andreicerbu;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class InitializeDatabase {
|
||||
private static final String URL =
|
||||
"jdbc:mysql://localhost:3306/java";
|
||||
private static final String USER = "root";
|
||||
private static final String PASSWORD = "";
|
||||
private static Connection conn;
|
||||
|
||||
private final static String createProduct =
|
||||
"CREATE TABLE products( id INT AUTO_INCREMENT, name VARCHAR(256) NOT NULL, PRIMARY KEY(id) , UNIQUE(name))";
|
||||
private final static String createDeposit =
|
||||
"CREATE TABLE deposits( id INT AUTO_INCREMENT, name VARCHAR(256) NOT NULL, lat_coord FLOAT NOT NULL, long_coord FLOAT NOT NULL, PRIMARY KEY(id), UNIQUE (lat_coord), UNIQUE (long_coord) )";
|
||||
private final static String createProdInDepo =
|
||||
"CREATE TABLE prod_in_depo( id INT AUTO_INCREMENT, id_product INT NOT NULL, id_deposit INT NOT NULL, quantity INT NOT NULL, PRIMARY KEY(id), FOREIGN KEY (id_product) REFERENCES products(id), FOREIGN KEY (id_deposit) REFERENCES deposits(id), UNIQUE (id_product, id_deposit) )";
|
||||
private final static String createOrders =
|
||||
"CREATE TABLE orders( id INT AUTO_INCREMENT, path_to_file VARCHAR(512) NOT NULL, PRIMARY KEY(id), UNIQUE (path_to_file) )";
|
||||
private final static String createRoutes =
|
||||
"CREATE TABLE routes( id INT AUTO_INCREMENT, path_to_file VARCHAR(512) NOT NULL, PRIMARY KEY(id), UNIQUE (path_to_file) )";
|
||||
private final static String createUsers =
|
||||
"CREATE TABLE users( id INT AUTO_INCREMENT, username VARCHAR(256) NOT NULL, email VARCHAR(256) NOT NULL, password VARCHAR(256) NOT NULL, lat_coord FLOAT NOT NULL, long_coord FLOAT NOT NULL, PRIMARY KEY(id), UNIQUE(email) );";
|
||||
private final static String createUserOrders =
|
||||
"CREATE TABLE user_orders( id INT AUTO_INCREMENT, id_user INT NOT NULL, id_order INT NOT NULL, PRIMARY KEY (id), FOREIGN KEY (id_user) REFERENCES users(id), FOREIGN KEY (id_order) REFERENCES orders (id), UNIQUE (id_order) )";
|
||||
|
||||
private final static String dropProduct = "DROP TABLE products";
|
||||
private final static String dropDeposit = "DROP TABLE deposits";
|
||||
private final static String dropProdInDepo = "DROP TABLE prod_in_depo";
|
||||
private final static String dropOrders = "DROP TABLE orders";
|
||||
private final static String dropRoutes = "DROP TABLE routes";
|
||||
private final static String dropUsers = "DROP TABLE users";
|
||||
private final static String dropUserOrders = "DROP TABLE user_orders";
|
||||
|
||||
private final static List<String> dropTablesQueries = new ArrayList<>(Arrays.asList(dropProdInDepo, dropUserOrders, dropDeposit, dropProduct, dropRoutes, dropUsers, dropOrders));
|
||||
private final static List<String> createTablesQueries = new ArrayList<>(Arrays.asList(createDeposit, createOrders, createRoutes, createProduct, createProdInDepo, createUsers, createUserOrders));
|
||||
|
||||
public static void main(String[] args){
|
||||
createTables();
|
||||
//dropTables();
|
||||
}
|
||||
|
||||
private static void createTables(){
|
||||
try {
|
||||
conn = DriverManager.getConnection(URL, USER, PASSWORD);
|
||||
conn.setAutoCommit(false);
|
||||
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
for(String query : createTablesQueries){
|
||||
try {
|
||||
stmt.executeUpdate(query);
|
||||
System.out.println("Table created successfully");
|
||||
}
|
||||
catch (SQLException tableExists){
|
||||
System.out.println(tableExists.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
conn.commit();
|
||||
}catch (SQLException e){
|
||||
try {
|
||||
System.err.println(e);
|
||||
conn.rollback();
|
||||
}catch(SQLException rollback){
|
||||
System.err.println(rollback);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void dropTables(){
|
||||
try {
|
||||
conn = DriverManager.getConnection(URL, USER, PASSWORD);
|
||||
conn.setAutoCommit(false);
|
||||
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
for(String query : dropTablesQueries){
|
||||
try {
|
||||
stmt.executeUpdate(query);
|
||||
System.out.println("Dropped table");
|
||||
} catch (SQLException tableNotExisting) {
|
||||
System.out.println(tableNotExisting.getMessage());
|
||||
}
|
||||
}
|
||||
conn.commit();
|
||||
}catch (SQLException e){
|
||||
try {
|
||||
conn.rollback();
|
||||
}catch(SQLException ee){
|
||||
System.err.println(ee);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.andreicerbu;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args){
|
||||
try {
|
||||
Server server = new Server();
|
||||
server.run();
|
||||
}catch (IOException e){
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.andreicerbu;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Server {
|
||||
private static final int PORT = 8672;
|
||||
private static final int TIME_OUT = 10000;
|
||||
ServerSocket serverSocket = null;
|
||||
List<ClientThread> clients;
|
||||
|
||||
public Server()throws IOException {
|
||||
serverSocket = new ServerSocket(PORT);
|
||||
serverSocket.setSoTimeout(TIME_OUT);
|
||||
clients = new ArrayList<>();
|
||||
|
||||
InetAddress localaddr = InetAddress.getLocalHost();
|
||||
System.out.println("Local IP Address : " + localaddr);
|
||||
System.out.println("Local hostname : " + localaddr.getHostName());
|
||||
}
|
||||
|
||||
private void acceptConnection() throws IOException{
|
||||
Socket clientSocket = serverSocket.accept();
|
||||
System.out.println("Client Connected!");
|
||||
clients.add(new ClientThread(clientSocket));
|
||||
clients.get(clients.size() - 1).start();
|
||||
}
|
||||
|
||||
public void run(){
|
||||
while(true) {
|
||||
try {
|
||||
acceptConnection();
|
||||
}catch (SocketTimeoutException ignored){
|
||||
clients.removeIf(ClientThread::isThreadNotAlive);
|
||||
System.out.println("Waiting for client!");
|
||||
} catch (IOException e) {
|
||||
System.err.println(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
package com.andreicerbu;
|
||||
|
||||
import com.andreicerbu.exceptions.*;
|
||||
import com.andreicerbu.items.*;
|
||||
|
||||
import com.andreicerbu.json.JsonFields;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class SocketInput {
|
||||
private String input;
|
||||
private JSONObject jsonInput = null;
|
||||
private JSONObject jsonOutput = null;
|
||||
|
||||
private static final String registrationDone = "Registration done succesfully";
|
||||
private static final String orderDone = "Order placed successfully";
|
||||
|
||||
|
||||
private static final String genericError = "Internal server error. Please try again";
|
||||
|
||||
public SocketInput(){}
|
||||
|
||||
public SocketInput(String input){
|
||||
this.input = input;
|
||||
jsonInput = new JSONObject(input);
|
||||
}
|
||||
|
||||
public void processInputJson(Connection conn) throws IOException{
|
||||
jsonOutput = new JSONObject();
|
||||
AdminJson adminJson = new AdminJson();
|
||||
|
||||
switch(jsonInput.getString(JsonFields.command)) {
|
||||
case JsonFields.commandPlaceOrder -> {
|
||||
try {
|
||||
Algorithm algorithm = new Algorithm(jsonInput);
|
||||
Database.placeOrder(Database.getConnection(), algorithm.getRouteJson(), jsonInput.getInt(JsonFields.id_user));
|
||||
processOutputJson(JsonFields.responseSuccess, orderDone);
|
||||
} catch (ProductUnavailableAnymoreException e){
|
||||
processOutputJson(JsonFields.responseError, e.getMessage());
|
||||
} catch (SQLException ignored){
|
||||
processOutputJson(JsonFields.responseError, genericError);
|
||||
}
|
||||
}
|
||||
|
||||
case JsonFields.commandGetDatabase -> {
|
||||
try {
|
||||
DatabaseJson databaseJson = new DatabaseJson();
|
||||
databaseJson.createJSON();
|
||||
jsonOutput = databaseJson.getJSON();
|
||||
} catch (SQLException e){
|
||||
System.err.println(e);
|
||||
System.err.flush();
|
||||
processOutputJson(JsonFields.responseError, genericError);
|
||||
}
|
||||
}
|
||||
|
||||
case JsonFields.commandGetUserDatabase -> {
|
||||
try {
|
||||
adminJson.deserializeJSON(jsonInput);
|
||||
DatabaseClientJson databaseClientJson = new DatabaseClientJson(adminJson.getListOfValues().get(0).getId_user());
|
||||
databaseClientJson.createJSON();
|
||||
jsonOutput = databaseClientJson.getJSON();
|
||||
} catch (SQLException ignored){
|
||||
processOutputJson(JsonFields.responseError, genericError);
|
||||
}
|
||||
}
|
||||
|
||||
case JsonFields.commandGetOrders -> {
|
||||
try {
|
||||
jsonOutput = Database.getUserOrders(conn, adminJson.getListOfValues().get(0).getId_user());
|
||||
} catch (SQLException ignored){
|
||||
processOutputJson(JsonFields.responseError, genericError);
|
||||
}
|
||||
}
|
||||
|
||||
case JsonFields.commandRegister -> {
|
||||
try {
|
||||
adminJson.deserializeJSON(jsonInput);
|
||||
Database.registerUser(conn, adminJson.getListOfValues().get(0));
|
||||
processOutputJson(JsonFields.responseSuccess, registrationDone);
|
||||
} catch (InvalidCredentialsException e) {
|
||||
processOutputJson(JsonFields.responseError, e.getMessage());
|
||||
} catch (SQLException ignored){
|
||||
processOutputJson(JsonFields.responseError, genericError);
|
||||
}
|
||||
}
|
||||
|
||||
case JsonFields.commandLogin -> {
|
||||
try{
|
||||
adminJson.deserializeJSON(jsonInput);
|
||||
Integer userId = Database.loginUser(conn, adminJson.getListOfValues().get(0));
|
||||
processOutputJson(JsonFields.responseSuccess, String.valueOf(userId));
|
||||
} catch (InvalidCredentialsException e){
|
||||
processOutputJson(JsonFields.responseError, e.getMessage());
|
||||
} catch (SQLException ignored){
|
||||
processOutputJson(JsonFields.responseError, genericError);
|
||||
}
|
||||
}
|
||||
|
||||
default -> {
|
||||
try {
|
||||
adminJson.deserializeJSON(jsonInput);
|
||||
Database.alterTable(conn, adminJson);
|
||||
}catch(SQLException | FieldToUpdateNotExistingException | FieldAlreadyExistsException e){
|
||||
processOutputJson(JsonFields.responseError, e.getMessage());
|
||||
} catch(ProcessDoneException e){
|
||||
processOutputJson(JsonFields.responseSuccess, e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void processOutputJson(String response, String message){
|
||||
jsonOutput = new JSONObject();
|
||||
switch (response){
|
||||
case JsonFields.responseSuccess -> {
|
||||
jsonOutput.put(JsonFields.response, JsonFields.responseSuccess);
|
||||
jsonOutput.put(JsonFields.responseMessage, message);
|
||||
}
|
||||
|
||||
case JsonFields.responseError -> {
|
||||
jsonOutput.put(JsonFields.response, JsonFields.responseError);
|
||||
jsonOutput.put(JsonFields.responseMessage, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public JSONObject getJsonResponse(){
|
||||
return jsonOutput;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.andreicerbu.exceptions;
|
||||
|
||||
public class FieldAlreadyExistsException extends Exception{
|
||||
public FieldAlreadyExistsException(String message){
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.andreicerbu.exceptions;
|
||||
|
||||
public class FieldToUpdateNotExistingException extends Exception{
|
||||
public FieldToUpdateNotExistingException(String message){
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.andreicerbu.exceptions;
|
||||
|
||||
public class InvalidCredentialsException extends Exception{
|
||||
public InvalidCredentialsException(String message){
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.andreicerbu.exceptions;
|
||||
|
||||
public class NotExistingUserException extends Exception{
|
||||
public NotExistingUserException(){
|
||||
super("Incorrect credentials");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.andreicerbu.exceptions;
|
||||
|
||||
public class ProcessDoneException extends Exception{
|
||||
public ProcessDoneException(String message){
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.andreicerbu.exceptions;
|
||||
|
||||
public class ProductUnavailableAnymoreException extends Exception{
|
||||
public ProductUnavailableAnymoreException(String message){
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.andreicerbu.interfaces;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
public interface JSONMethods {
|
||||
void createJSON() throws SQLException;
|
||||
JSONObject getJSON();
|
||||
void deserializeJSON(JSONObject json);
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.andreicerbu.items;
|
||||
|
||||
import com.andreicerbu.interfaces.JSONMethods;
|
||||
import com.andreicerbu.json.JsonFields;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AdminJson extends BaseItem implements JSONMethods {
|
||||
private List<BaseItem> listOfValues = new ArrayList<>();
|
||||
private JSONArray listOfValuesJSON = new JSONArray();
|
||||
|
||||
public AdminJson(){}
|
||||
|
||||
|
||||
@Override
|
||||
public void createJSON() {
|
||||
json.put(JsonFields.table, table == null ? JSONObject.NULL : table);
|
||||
json.put(JsonFields.command, command == null ? JSONObject.NULL : command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getJSON() {
|
||||
json.put(JsonFields.listOfValues,listOfValuesJSON);
|
||||
return json;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserializeJSON(JSONObject json) {
|
||||
table = json.get(JsonFields.table) == JSONObject.NULL ? null : json.getString(JsonFields.table);
|
||||
command = json.getString(JsonFields.command) == JSONObject.NULL ? null : json.getString(JsonFields.command);
|
||||
|
||||
JSONArray listOfValuesJSON = json.getJSONArray(JsonFields.listOfValues);
|
||||
|
||||
for (int index = 0; index < listOfValuesJSON.length(); index++) {
|
||||
JSONObject value = listOfValuesJSON.getJSONObject(index);
|
||||
BaseItem item = deserializeBaseItemJSON(table, value);
|
||||
this.listOfValues.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
public List<BaseItem> getListOfValues() {
|
||||
return listOfValues;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
package com.andreicerbu.items;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import static com.andreicerbu.json.JsonFields.*;
|
||||
import com.andreicerbu.json.JsonFields;
|
||||
import com.andreicerbu.items.database.*;
|
||||
|
||||
public abstract class BaseItem {
|
||||
protected JSONObject json = new JSONObject();
|
||||
|
||||
protected Integer id_user_orders = null;
|
||||
protected Integer id_user = null;
|
||||
protected Integer id_order = null;
|
||||
protected Integer id_deposit = null;
|
||||
protected Integer id_prod_in_depo = null;
|
||||
protected Integer id_product = null;
|
||||
protected Integer id_route = null;
|
||||
|
||||
protected Integer quantity = null;
|
||||
protected String name = null;
|
||||
protected String email = null;
|
||||
protected String password = null;
|
||||
protected Float lat_coord = null;
|
||||
protected Float long_coord = null;
|
||||
|
||||
protected String command = null;
|
||||
protected String table = null;
|
||||
protected String jsonType = null;
|
||||
|
||||
|
||||
|
||||
protected BaseItem deserializeBaseItemJSON(String table, JSONObject json){
|
||||
BaseItem item;
|
||||
|
||||
switch(table){
|
||||
case tableOrders -> item = new TableOrder(
|
||||
json.get(JsonFields.id_order) == JSONObject.NULL ? null : json.getInt(JsonFields.id_order),
|
||||
json.get(JsonFields.name) == JSONObject.NULL ? null : json.getString(JsonFields.name)
|
||||
);
|
||||
case tableDeposits -> item = new TableDeposit(
|
||||
json.get(JsonFields.id_deposit) == JSONObject.NULL ? null : json.getInt(JsonFields.id_deposit),
|
||||
json.get(JsonFields.name) == JSONObject.NULL ? null : json.getString(JsonFields.name),
|
||||
json.get(JsonFields.lat_coord) == JSONObject.NULL ? null : json.getFloat(JsonFields.lat_coord),
|
||||
json.get(JsonFields.long_coord) == JSONObject.NULL ? null : json.getFloat(JsonFields.long_coord)
|
||||
);
|
||||
case tableProdInDepo -> item = new TableProdInDepo(
|
||||
json.get(JsonFields.id_prod_in_depo) == JSONObject.NULL ? null : json.getInt(JsonFields.id_prod_in_depo),
|
||||
json.get(JsonFields.id_product) == JSONObject.NULL ? null : json.getInt(JsonFields.id_product),
|
||||
json.get(JsonFields.id_deposit) == JSONObject.NULL ? null : json.getInt(JsonFields.id_deposit),
|
||||
json.get(JsonFields.name) == JSONObject.NULL ? null : json.getString(JsonFields.name),
|
||||
json.get(JsonFields.quantity) == JSONObject.NULL ? null : json.getInt(JsonFields.quantity)
|
||||
|
||||
);
|
||||
case tableProducts -> item = new TableProduct(
|
||||
json.get(JsonFields.id_product) == JSONObject.NULL ? null : json.getInt(JsonFields.id_product),
|
||||
json.get(JsonFields.name) == JSONObject.NULL ? null : json.getString(JsonFields.name)
|
||||
);
|
||||
case tableRoutes -> item = new TableRoute(
|
||||
json.get(JsonFields.id_route) == JSONObject.NULL ? null : json.getInt(JsonFields.id_route),
|
||||
json.get(JsonFields.name) == JSONObject.NULL ? null : json.getString(JsonFields.name),
|
||||
json.get(JsonFields.id_order) == JSONObject.NULL ? null : json.getInt(JsonFields.id_order)
|
||||
);
|
||||
|
||||
case tableUsers -> item = new TableUser(
|
||||
json.get(JsonFields.id_user) == JSONObject.NULL ? null : json.getInt(JsonFields.id_user),
|
||||
json.get(JsonFields.name) == JSONObject.NULL ? null : json.getString(JsonFields.name),
|
||||
json.get(JsonFields.email) == JSONObject.NULL ? null : json.getString(JsonFields.email),
|
||||
json.get(JsonFields.password) == JSONObject.NULL ? null : json.getString(JsonFields.password),
|
||||
json.get(JsonFields.lat_coord) == JSONObject.NULL ? null : json.getFloat(JsonFields.lat_coord),
|
||||
json.get(JsonFields.long_coord) == JSONObject.NULL ? null : json.getFloat(JsonFields.long_coord)
|
||||
);
|
||||
|
||||
case tableUserOrders -> item = new TableUserOrder (
|
||||
json.get(JsonFields.id_user_orders) == JSONObject.NULL ? null : json.getInt(JsonFields.id_user_orders),
|
||||
json.get(JsonFields.id_user) == JSONObject.NULL ? null : json.getInt(JsonFields.id_user),
|
||||
json.get(JsonFields.id_order) == JSONObject.NULL ? null : json.getInt(JsonFields.id_order)
|
||||
);
|
||||
|
||||
default -> item = null;
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
public Integer getId_user() {
|
||||
return id_user;
|
||||
}
|
||||
|
||||
public Integer getId_user_orders() {
|
||||
return id_user_orders;
|
||||
}
|
||||
|
||||
public Integer getId_prod_in_depo() {
|
||||
return id_prod_in_depo;
|
||||
}
|
||||
|
||||
public Integer getId_route() {
|
||||
return id_route;
|
||||
}
|
||||
|
||||
public Integer getId_product() {
|
||||
return id_product;
|
||||
}
|
||||
|
||||
public Integer getId_deposit() {
|
||||
return id_deposit;
|
||||
}
|
||||
|
||||
public Integer getId_order() {
|
||||
return id_order;
|
||||
}
|
||||
|
||||
public Integer getQuantity() {
|
||||
return quantity;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public Float getLat_coord() {
|
||||
return lat_coord;
|
||||
}
|
||||
|
||||
public Float getLong_coord() {
|
||||
return long_coord;
|
||||
}
|
||||
|
||||
public String getCommand() {
|
||||
return command;
|
||||
}
|
||||
|
||||
public String getTable() {
|
||||
return table;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
package com.andreicerbu.items;
|
||||
|
||||
import com.andreicerbu.Database;
|
||||
import com.andreicerbu.interfaces.JSONMethods;
|
||||
import com.andreicerbu.items.database.*;
|
||||
import com.andreicerbu.json.JsonFields;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.sql.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class DatabaseClientJson implements JSONMethods {
|
||||
JSONObject json = new JSONObject();
|
||||
Integer idUser;
|
||||
|
||||
JSONArray listTableOrderJson;
|
||||
JSONArray listTableProductJson;
|
||||
JSONArray listTableProdInDepoJson;
|
||||
JSONArray listTableUserJson;
|
||||
|
||||
public DatabaseClientJson(Integer idUser){
|
||||
this.idUser = idUser;
|
||||
}
|
||||
|
||||
public void readDatabase() throws SQLException {
|
||||
Connection conn = Database.getConnection();
|
||||
|
||||
listTableOrderJson = new JSONArray();
|
||||
listTableProductJson = new JSONArray();
|
||||
listTableUserJson = new JSONArray();
|
||||
listTableProdInDepoJson = new JSONArray();
|
||||
|
||||
populateListTableOrderJson(conn, idUser);
|
||||
populateListTableProductJson(conn);
|
||||
populateListTableUserJson(conn, idUser);
|
||||
populateListTableProdInDepoJson(conn);
|
||||
|
||||
Database.closeConnection(conn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createJSON() throws SQLException {
|
||||
readDatabase();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getJSON() {
|
||||
return json;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserializeJSON(JSONObject json) {
|
||||
|
||||
}
|
||||
|
||||
private void populateListTableOrderJson(Connection conn, Integer idUser) throws SQLException{
|
||||
PreparedStatement pstmt = conn.prepareStatement("SELECT id_order FROM user_orders WHERE id_user = ?");
|
||||
pstmt.setInt(1, idUser);
|
||||
|
||||
ResultSet resultSet = pstmt.executeQuery();
|
||||
while(resultSet.next()){
|
||||
int id_order = resultSet.getInt("id_order");
|
||||
|
||||
Statement stmt = conn.createStatement();
|
||||
ResultSet resultSetPath = stmt.executeQuery("SELECT path_to_file FROM orders WHERE id = " + id_order);
|
||||
resultSetPath.next();
|
||||
|
||||
String path_to_file = resultSetPath.getString("path_to_file");
|
||||
StringBuilder content = new StringBuilder();
|
||||
|
||||
try {
|
||||
File myObj = new File(path_to_file);
|
||||
Scanner myReader = new Scanner(myObj);
|
||||
while (myReader.hasNextLine()) {
|
||||
content.append(myReader.nextLine());
|
||||
}
|
||||
}catch (IOException ignored){}
|
||||
|
||||
JSONArray order = new JSONArray(content.toString());
|
||||
listTableOrderJson.put(order);
|
||||
}
|
||||
|
||||
json.put(JsonFields.tableOrders, listTableOrderJson);
|
||||
}
|
||||
|
||||
private void populateListTableProdInDepoJson(Connection conn) throws SQLException{
|
||||
Statement stmt = conn.createStatement();
|
||||
ResultSet resultSet = stmt.executeQuery("SELECT * FROM prod_in_depo");
|
||||
while(resultSet.next()){
|
||||
JSONObject object = new JSONObject();
|
||||
object.put(JsonFields.id_prod_in_depo, resultSet.getInt("id"));
|
||||
object.put(JsonFields.id_product, resultSet.getInt("id_product"));
|
||||
object.put(JsonFields.id_deposit, resultSet.getInt("id_deposit"));
|
||||
object.put(JsonFields.quantity, resultSet.getInt("quantity"));
|
||||
|
||||
listTableProdInDepoJson.put(object);
|
||||
}
|
||||
|
||||
json.put(JsonFields.tableProdInDepo, listTableProdInDepoJson);
|
||||
}
|
||||
|
||||
private void populateListTableProductJson(Connection conn) throws SQLException{
|
||||
Statement stmt = conn.createStatement();
|
||||
ResultSet resultSet = stmt.executeQuery("SELECT * FROM products");
|
||||
while(resultSet.next()){
|
||||
JSONObject object = new JSONObject();
|
||||
object.put(JsonFields.id_product, resultSet.getInt("id"));
|
||||
object.put(JsonFields.name, resultSet.getString("name"));
|
||||
|
||||
listTableProductJson.put(object);
|
||||
}
|
||||
|
||||
json.put(JsonFields.tableProducts, listTableProductJson);
|
||||
}
|
||||
|
||||
private void populateListTableUserJson(Connection conn, Integer idUser) throws SQLException{
|
||||
PreparedStatement pstmt = conn.prepareStatement("SELECT * FROM users WHERE id = ?");
|
||||
pstmt.setInt(1, idUser);
|
||||
|
||||
ResultSet resultSet = pstmt.executeQuery();
|
||||
while(resultSet.next()){
|
||||
JSONObject object = new JSONObject();
|
||||
object.put(JsonFields.id_user, resultSet.getInt("id"));
|
||||
object.put(JsonFields.name, resultSet.getString("username"));
|
||||
object.put(JsonFields.email, resultSet.getString("email"));
|
||||
object.put(JsonFields.password, resultSet.getString("password"));
|
||||
object.put(JsonFields.lat_coord, resultSet.getString("lat_coord"));
|
||||
object.put(JsonFields.long_coord, resultSet.getString("long_coord"));
|
||||
|
||||
listTableUserJson.put(object);
|
||||
}
|
||||
|
||||
json.put(JsonFields.tableUsers, listTableUserJson);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,218 @@
|
||||
package com.andreicerbu.items;
|
||||
|
||||
import com.andreicerbu.Database;
|
||||
import com.andreicerbu.interfaces.JSONMethods;
|
||||
import com.andreicerbu.items.database.*;
|
||||
import com.andreicerbu.json.JsonFields;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.sql.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class DatabaseJson implements JSONMethods {
|
||||
JSONObject json = new JSONObject();
|
||||
|
||||
JSONArray listTableDepositJson;
|
||||
JSONArray listTableOrderJson;
|
||||
JSONArray listTableProdInDepoJson;
|
||||
JSONArray listTableProductJson;
|
||||
JSONArray listTableRouteJson;
|
||||
JSONArray listTableUserJson;
|
||||
JSONArray listTableUserOrderJson;
|
||||
|
||||
public DatabaseJson() {
|
||||
}
|
||||
|
||||
public void readDatabase() throws SQLException {
|
||||
Connection conn = Database.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
listTableDepositJson = new JSONArray();
|
||||
listTableOrderJson = new JSONArray();
|
||||
listTableProdInDepoJson = new JSONArray();
|
||||
listTableProductJson = new JSONArray();
|
||||
listTableRouteJson = new JSONArray();
|
||||
listTableUserJson = new JSONArray();
|
||||
listTableUserOrderJson = new JSONArray();
|
||||
|
||||
populateListTableDepositJson(stmt);
|
||||
populateListTableOrderJson(stmt);
|
||||
populateListTableProdInDepoJson(stmt);
|
||||
populateListTableProductJson(stmt);
|
||||
populateListTableRouteJson(stmt);
|
||||
populateListTableUserJson(stmt);
|
||||
populateListTableUserOrderJson(stmt);
|
||||
|
||||
Database.closeConnection(conn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createJSON() throws SQLException {
|
||||
readDatabase();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getJSON() {
|
||||
return json;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserializeJSON(JSONObject json) {
|
||||
|
||||
}
|
||||
|
||||
private void populateListTableDepositJson(Statement stmt) throws SQLException {
|
||||
ResultSet resultSet = stmt.executeQuery("SELECT * FROM deposits");
|
||||
while (resultSet.next()) {
|
||||
JSONObject object = new JSONObject();
|
||||
object.put(JsonFields.id_deposit, resultSet.getInt("id"));
|
||||
object.put(JsonFields.name, resultSet.getString("name"));
|
||||
object.put(JsonFields.lat_coord, resultSet.getString("lat_coord"));
|
||||
object.put(JsonFields.long_coord, resultSet.getString("long_coord"));
|
||||
|
||||
listTableDepositJson.put(object);
|
||||
}
|
||||
|
||||
json.put(JsonFields.tableDeposits, listTableDepositJson);
|
||||
}
|
||||
|
||||
private void populateListTableOrderJson(Statement stmt) throws SQLException {
|
||||
ResultSet resultSet = stmt.executeQuery("SELECT * FROM orders");
|
||||
|
||||
while (resultSet.next()) {
|
||||
JSONObject item = new JSONObject();
|
||||
int id_order = resultSet.getInt("id");
|
||||
String fileName = getNameOfFileRoute(Database.getConnection(), id_order, "orders");
|
||||
String path_to_file = "D:\\Server Delivery Planner\\orders\\" + fileName + "_order.txt";
|
||||
|
||||
StringBuilder content = new StringBuilder();
|
||||
|
||||
try {
|
||||
File myObj = new File(path_to_file);
|
||||
Scanner myReader = new Scanner(myObj);
|
||||
while (myReader.hasNextLine()) {
|
||||
content.append(myReader.nextLine());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
System.out.println(e.getMessage());
|
||||
System.out.flush();
|
||||
}
|
||||
|
||||
item.put(JsonFields.id_order, id_order);
|
||||
item.put(JsonFields.order, new JSONArray(content.toString()));
|
||||
listTableOrderJson.put(item);
|
||||
}
|
||||
|
||||
resultSet.close();
|
||||
json.put(JsonFields.tableOrders, listTableOrderJson);
|
||||
}
|
||||
|
||||
private void populateListTableProdInDepoJson(Statement stmt) throws SQLException {
|
||||
ResultSet resultSet = stmt.executeQuery("SELECT * FROM prod_in_depo");
|
||||
while (resultSet.next()) {
|
||||
JSONObject object = new JSONObject();
|
||||
object.put(JsonFields.id_prod_in_depo, resultSet.getInt("id"));
|
||||
object.put(JsonFields.id_product, resultSet.getInt("id_product"));
|
||||
object.put(JsonFields.id_deposit, resultSet.getInt("id_deposit"));
|
||||
object.put(JsonFields.quantity, resultSet.getInt("quantity"));
|
||||
|
||||
listTableProdInDepoJson.put(object);
|
||||
}
|
||||
|
||||
json.put(JsonFields.tableProdInDepo, listTableProdInDepoJson);
|
||||
}
|
||||
|
||||
private void populateListTableProductJson(Statement stmt) throws SQLException {
|
||||
ResultSet resultSet = stmt.executeQuery("SELECT * FROM products");
|
||||
while (resultSet.next()) {
|
||||
JSONObject object = new JSONObject();
|
||||
object.put(JsonFields.id_product, resultSet.getInt("id"));
|
||||
object.put(JsonFields.name, resultSet.getString("name"));
|
||||
|
||||
listTableProductJson.put(object);
|
||||
}
|
||||
|
||||
json.put(JsonFields.tableProducts, listTableProductJson);
|
||||
}
|
||||
|
||||
private void populateListTableRouteJson(Statement stmt) throws SQLException {
|
||||
ResultSet resultSet = stmt.executeQuery("SELECT id FROM routes");
|
||||
while (resultSet.next()) {
|
||||
JSONObject item = new JSONObject();
|
||||
int id_route = resultSet.getInt("id");
|
||||
String fileName = getNameOfFileRoute(Database.getConnection(), id_route, "routes");
|
||||
String path_to_file = "D:\\Server Delivery Planner\\routes\\" + fileName + "_route.txt";
|
||||
StringBuilder content = new StringBuilder();
|
||||
|
||||
try {
|
||||
File myObj = new File(path_to_file);
|
||||
Scanner myReader = new Scanner(myObj);
|
||||
while (myReader.hasNextLine()) {
|
||||
content.append(myReader.nextLine());
|
||||
}
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
|
||||
item.put(JsonFields.id_route, id_route);
|
||||
item.put(JsonFields.route, new JSONObject(content.toString()));
|
||||
listTableRouteJson.put(item);
|
||||
}
|
||||
|
||||
json.put(JsonFields.tableRoutes, listTableRouteJson);
|
||||
}
|
||||
|
||||
private void populateListTableUserJson(Statement stmt) throws SQLException {
|
||||
ResultSet resultSet = stmt.executeQuery("SELECT * FROM users");
|
||||
while (resultSet.next()) {
|
||||
JSONObject object = new JSONObject();
|
||||
object.put(JsonFields.id_user, resultSet.getInt("id"));
|
||||
object.put(JsonFields.name, resultSet.getString("username"));
|
||||
object.put(JsonFields.email, resultSet.getString("email"));
|
||||
object.put(JsonFields.password, resultSet.getString("password"));
|
||||
object.put(JsonFields.lat_coord, resultSet.getString("lat_coord"));
|
||||
object.put(JsonFields.long_coord, resultSet.getString("long_coord"));
|
||||
|
||||
listTableUserJson.put(object);
|
||||
}
|
||||
|
||||
json.put(JsonFields.tableUsers, listTableUserJson);
|
||||
}
|
||||
|
||||
private void populateListTableUserOrderJson(Statement stmt) throws SQLException {
|
||||
ResultSet resultSet = stmt.executeQuery("SELECT * FROM user_orders");
|
||||
while (resultSet.next()) {
|
||||
JSONObject object = new JSONObject();
|
||||
|
||||
object.put(JsonFields.id_user_orders, resultSet.getInt("id"));
|
||||
object.put(JsonFields.id_user, resultSet.getInt("id_user"));
|
||||
object.put(JsonFields.id_order, resultSet.getInt("id_order"));
|
||||
|
||||
listTableUserOrderJson.put(object);
|
||||
}
|
||||
|
||||
json.put(JsonFields.tableUserOrders, listTableUserOrderJson);
|
||||
}
|
||||
|
||||
private static String getNameOfFileRoute(Connection conn, int id, String tableName) throws SQLException {
|
||||
PreparedStatement pstmt = conn.prepareStatement("SELECT path_to_file FROM " + tableName + " WHERE id = ?");
|
||||
pstmt.setInt(1, id);
|
||||
ResultSet resultSet1 = pstmt.executeQuery();
|
||||
resultSet1.next();
|
||||
|
||||
String resultStringToProcess = resultSet1.getString("path_to_file");
|
||||
int left, right = resultStringToProcess.indexOf('_');
|
||||
left = right;
|
||||
|
||||
while (resultStringToProcess.charAt(left) != '\\') {
|
||||
left--;
|
||||
}
|
||||
left++;
|
||||
|
||||
return resultStringToProcess.substring(left, right);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.andreicerbu.items;
|
||||
|
||||
import com.andreicerbu.interfaces.JSONMethods;
|
||||
import com.andreicerbu.json.JsonFields;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Order extends BaseItem implements JSONMethods {
|
||||
List<ProductForOrder> listOfProducts = new ArrayList<>();
|
||||
JSONArray listOfProductsJSON = new JSONArray();
|
||||
|
||||
public Order(){}
|
||||
|
||||
public Order(Integer id_user){
|
||||
this.id_user = id_user;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void createJSON() {}
|
||||
|
||||
@Override
|
||||
public JSONObject getJSON() {
|
||||
json.put(JsonFields.id_user, id_user);
|
||||
json.put(JsonFields.listOfProducts, listOfProductsJSON);
|
||||
return json;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserializeJSON(JSONObject json) {
|
||||
id_user = json.getInt(JsonFields.id_user);
|
||||
|
||||
JSONArray listOfProducts = json.getJSONArray(JsonFields.listOfProducts);
|
||||
for(int index = 0; index < listOfProducts.length(); index++){
|
||||
JSONObject product = listOfProducts.getJSONObject(index);
|
||||
|
||||
this.listOfProducts.add(new ProductForOrder(product.getInt(JsonFields.id_product), product.getInt(JsonFields.quantity)));
|
||||
}
|
||||
}
|
||||
|
||||
public List<ProductForOrder> getListOfProducts() {
|
||||
return listOfProducts;
|
||||
}
|
||||
|
||||
public void addProductToOrder(ProductForOrder product){
|
||||
listOfProductsJSON.put(product.getJSON());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.andreicerbu.items;
|
||||
|
||||
import com.andreicerbu.interfaces.JSONMethods;
|
||||
import com.andreicerbu.json.JsonFields;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class ProductForOrder extends BaseItem implements JSONMethods {
|
||||
public ProductForOrder(Integer id_product, Integer quantity){
|
||||
this.id_product = id_product;
|
||||
this.quantity = quantity;
|
||||
|
||||
createJSON();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void createJSON() {
|
||||
json.put(JsonFields.id_product, id_product);
|
||||
json.put(JsonFields.quantity, quantity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getJSON() {
|
||||
return json;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserializeJSON(JSONObject json){
|
||||
this.id_product = json.getInt(JsonFields.id_product);
|
||||
this.quantity = json.getInt(JsonFields.quantity);
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
return id_product + " " + quantity;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.andreicerbu.items.database;
|
||||
|
||||
import com.andreicerbu.items.BaseItem;
|
||||
|
||||
public class TableDeposit extends BaseItem {
|
||||
public TableDeposit(Integer id_deposit, String name, Float lat_coord, Float long_coord){
|
||||
this.id_deposit = id_deposit;
|
||||
this.name = name;
|
||||
this.lat_coord = lat_coord;
|
||||
this.long_coord = long_coord;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.andreicerbu.items.database;
|
||||
|
||||
import com.andreicerbu.items.BaseItem;
|
||||
|
||||
public class TableOrder extends BaseItem {
|
||||
public TableOrder(Integer id_order, String file_name){
|
||||
this.id_order = id_order;
|
||||
this.name = file_name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.andreicerbu.items.database;
|
||||
|
||||
import com.andreicerbu.items.BaseItem;
|
||||
|
||||
public class TableProdInDepo extends BaseItem {
|
||||
public TableProdInDepo(Integer id_prod_in_depo, Integer id_product, Integer id_deposit, String prod_in_depo_name, Integer quantity){
|
||||
this.id_prod_in_depo = id_prod_in_depo;
|
||||
this.id_product = id_product;
|
||||
this.id_deposit = id_deposit;
|
||||
this.name = prod_in_depo_name;
|
||||
this.quantity = quantity;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.andreicerbu.items.database;
|
||||
|
||||
import com.andreicerbu.items.BaseItem;
|
||||
|
||||
public class TableProduct extends BaseItem {
|
||||
public TableProduct(Integer id_product, String name){
|
||||
this.id_product = id_product;
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.andreicerbu.items.database;
|
||||
|
||||
import com.andreicerbu.items.BaseItem;
|
||||
|
||||
public class TableRoute extends BaseItem {
|
||||
public TableRoute(Integer id_route, String name, Integer id_order){
|
||||
this.id_route = id_route;
|
||||
this.name = name;
|
||||
this.id_order = id_order;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.andreicerbu.items.database;
|
||||
|
||||
import com.andreicerbu.items.BaseItem;
|
||||
|
||||
public class TableUser extends BaseItem {
|
||||
public TableUser(Integer id_user, String username, String email, String password,
|
||||
Float lat_coord, Float long_coord){
|
||||
this.id_user = id_user;
|
||||
this.name = username;
|
||||
this.email = email;
|
||||
this.password = password;
|
||||
this.lat_coord = lat_coord;
|
||||
this.long_coord = long_coord;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.andreicerbu.items.database;
|
||||
|
||||
import com.andreicerbu.items.BaseItem;
|
||||
|
||||
public class TableUserOrder extends BaseItem {
|
||||
public TableUserOrder(Integer id_user_orders, Integer id_user, Integer id_order){
|
||||
this.id_user_orders = id_user_orders;
|
||||
this.id_user = id_user;
|
||||
this.id_order = id_order;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.andreicerbu.json;
|
||||
|
||||
public class JsonFields {
|
||||
public static final String response = "response";
|
||||
public static final String responseSuccess = "success";
|
||||
public static final String responseError = "error";
|
||||
public static final String responseMessage = "message";
|
||||
|
||||
public static final String id_user = "id_user";
|
||||
public static final String id_order = "id_order";
|
||||
public static final String id_deposit = "id_deposit";
|
||||
public static final String id_prod_in_depo = "id_prod_in_depo";
|
||||
public static final String id_product = "id_product";
|
||||
public static final String id_user_orders = "id_user_orders";
|
||||
public static final String id_route = "id_route";
|
||||
|
||||
public static final String quantity = "quantity";
|
||||
public static final String name = "name";
|
||||
public static final String oldName = "oldName";
|
||||
public static final String email = "email";
|
||||
public static final String password = "password";
|
||||
public static final String lat_coord = "lat_coord";
|
||||
public static final String long_coord = "long_coord";
|
||||
public static final String order = "order";
|
||||
public static final String route = "route";
|
||||
public static final String distance = "distance";
|
||||
|
||||
public static final String listOfProducts = "products";
|
||||
public static final String listOfDeposits = "deposits";
|
||||
public static final String listOfValues = "values";
|
||||
|
||||
public static final String destination = "destination";
|
||||
public static final String table = "table";
|
||||
public static final String tableOrders = "orders";
|
||||
public static final String tableDeposits = "deposits";
|
||||
public static final String tableProdInDepo = "prod_in_depo";
|
||||
public static final String tableProducts = "products";
|
||||
public static final String tableRoutes = "routes";
|
||||
public static final String tableUsers = "users";
|
||||
public static final String tableUserOrders = "user_orders";
|
||||
|
||||
public static final String command = "command";
|
||||
public static final String commandGetDatabase = "getDatabase";
|
||||
public static final String commandGetUserDatabase = "userDatabase";
|
||||
public static final String commandInsert = "insert";
|
||||
public static final String commandUpdate = "update";
|
||||
public static final String commandDelete = "delete";
|
||||
public static final String commandRegister = "register";
|
||||
public static final String commandLogin = "login";
|
||||
public static final String commandGetOrders = "getOrders";
|
||||
public static final String commandPlaceOrder = "placeOrder";
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.andreicerbu;
|
||||
|
||||
public class test {
|
||||
public static void main (String[] args){
|
||||
float x1 = 258, y1 = 326; // user
|
||||
|
||||
float x2 = 200, y2 = 320;
|
||||
float x3 = 250, y3 = 280;
|
||||
float x4 = 230, y4 = 310;
|
||||
|
||||
System.out.println(calculateDistance(x1, y1, x2, y2));
|
||||
System.out.println(calculateDistance(x1, y1, x3, y3));
|
||||
System.out.println(calculateDistance(x1, y1, x4, y4));
|
||||
}
|
||||
|
||||
public static float calculateDistance(float x1, float y1, float x2, float y2){
|
||||
return (float) Math.sqrt(
|
||||
Math.pow(x2-x1, 2) + Math.pow(y2-y1, 2)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<archetype>
|
||||
<id>Server_Delivery_Planner</id>
|
||||
<sources>
|
||||
<source>src/main/java/App.java</source>
|
||||
</sources>
|
||||
<testSources>
|
||||
<source>src/test/java/AppTest.java</source>
|
||||
</testSources>
|
||||
</archetype>
|
||||
@@ -0,0 +1,15 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>$com.andreicerbu.deliveryplanner</groupId>
|
||||
<artifactId>$Server_Delivery_Planner</artifactId>
|
||||
<version>$1.0-SNAPSHOT</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,13 @@
|
||||
package $com.andreicerbu.deliveryplanner;
|
||||
|
||||
/**
|
||||
* Hello world!
|
||||
*
|
||||
*/
|
||||
public class App
|
||||
{
|
||||
public static void main( String[] args )
|
||||
{
|
||||
System.out.println( "Hello World!" );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package $com.andreicerbu.deliveryplanner;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
/**
|
||||
* Unit test for simple App.
|
||||
*/
|
||||
public class AppTest
|
||||
extends TestCase
|
||||
{
|
||||
/**
|
||||
* Create the test case
|
||||
*
|
||||
* @param testName name of the test case
|
||||
*/
|
||||
public AppTest( String testName )
|
||||
{
|
||||
super( testName );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the suite of tests being tested
|
||||
*/
|
||||
public static Test suite()
|
||||
{
|
||||
return new TestSuite( AppTest.class );
|
||||
}
|
||||
|
||||
/**
|
||||
* Rigourous Test :-)
|
||||
*/
|
||||
public void testApp()
|
||||
{
|
||||
assertTrue( true );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<archetype>
|
||||
<id>Server_Delivery_Planner</id>
|
||||
<sources>
|
||||
<source>src/main/java/App.java</source>
|
||||
</sources>
|
||||
<testSources>
|
||||
<source>src/test/java/AppTest.java</source>
|
||||
</testSources>
|
||||
</archetype>
|
||||
@@ -0,0 +1,15 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>$com.andreicerbu.deliveryplanner</groupId>
|
||||
<artifactId>$Server_Delivery_Planner</artifactId>
|
||||
<version>$1.0-SNAPSHOT</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,13 @@
|
||||
package $com.andreicerbu.deliveryplanner;
|
||||
|
||||
/**
|
||||
* Hello world!
|
||||
*
|
||||
*/
|
||||
public class App
|
||||
{
|
||||
public static void main( String[] args )
|
||||
{
|
||||
System.out.println( "Hello World!" );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package $com.andreicerbu.deliveryplanner;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
/**
|
||||
* Unit test for simple App.
|
||||
*/
|
||||
public class AppTest
|
||||
extends TestCase
|
||||
{
|
||||
/**
|
||||
* Create the test case
|
||||
*
|
||||
* @param testName name of the test case
|
||||
*/
|
||||
public AppTest( String testName )
|
||||
{
|
||||
super( testName );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the suite of tests being tested
|
||||
*/
|
||||
public static Test suite()
|
||||
{
|
||||
return new TestSuite( AppTest.class );
|
||||
}
|
||||
|
||||
/**
|
||||
* Rigourous Test :-)
|
||||
*/
|
||||
public void testApp()
|
||||
{
|
||||
assertTrue( true );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
com\andreicerbu\Algorithm.class
|
||||
com\andreicerbu\exceptions\NotExistingUserException.class
|
||||
com\andreicerbu\items\database\TableDeposit.class
|
||||
com\andreicerbu\items\Order.class
|
||||
com\andreicerbu\items\AdminJson.class
|
||||
com\andreicerbu\exceptions\FieldToUpdateNotExistingException.class
|
||||
com\andreicerbu\Algorithm$1.class
|
||||
com\andreicerbu\items\DatabaseJson.class
|
||||
com\andreicerbu\exceptions\ProcessDoneException.class
|
||||
com\andreicerbu\items\database\TableOrder.class
|
||||
com\andreicerbu\ClientThread.class
|
||||
com\andreicerbu\Database.class
|
||||
com\andreicerbu\interfaces\JSONMethods.class
|
||||
com\andreicerbu\test.class
|
||||
com\andreicerbu\json\JsonFields.class
|
||||
com\andreicerbu\exceptions\ProductUnavailableAnymoreException.class
|
||||
com\andreicerbu\SocketInput.class
|
||||
com\andreicerbu\items\ProductForOrder.class
|
||||
com\andreicerbu\Server.class
|
||||
com\andreicerbu\items\database\TableUserOrder.class
|
||||
com\andreicerbu\items\BaseItem.class
|
||||
com\andreicerbu\exceptions\FieldAlreadyExistsException.class
|
||||
com\andreicerbu\items\database\TableProduct.class
|
||||
com\andreicerbu\InitializeDatabase.class
|
||||
com\andreicerbu\items\database\TableProdInDepo.class
|
||||
com\andreicerbu\exceptions\InvalidCredentialsException.class
|
||||
com\andreicerbu\items\database\TableUser.class
|
||||
com\andreicerbu\items\database\TableRoute.class
|
||||
com\andreicerbu\items\DatabaseClientJson.class
|
||||
com\andreicerbu\Main.class
|
||||
@@ -0,0 +1,29 @@
|
||||
D:\Server Delivery Planner\src\main\java\com\andreicerbu\ClientThread.java
|
||||
D:\Server Delivery Planner\src\main\java\com\andreicerbu\interfaces\JSONMethods.java
|
||||
D:\Server Delivery Planner\src\main\java\com\andreicerbu\items\database\TableProdInDepo.java
|
||||
D:\Server Delivery Planner\src\main\java\com\andreicerbu\items\database\TableUserOrder.java
|
||||
D:\Server Delivery Planner\src\main\java\com\andreicerbu\Algorithm.java
|
||||
D:\Server Delivery Planner\src\main\java\com\andreicerbu\items\DatabaseJson.java
|
||||
D:\Server Delivery Planner\src\main\java\com\andreicerbu\items\database\TableOrder.java
|
||||
D:\Server Delivery Planner\src\main\java\com\andreicerbu\items\ProductForOrder.java
|
||||
D:\Server Delivery Planner\src\main\java\com\andreicerbu\SocketInput.java
|
||||
D:\Server Delivery Planner\src\main\java\com\andreicerbu\Main.java
|
||||
D:\Server Delivery Planner\src\main\java\com\andreicerbu\Server.java
|
||||
D:\Server Delivery Planner\src\main\java\com\andreicerbu\items\AdminJson.java
|
||||
D:\Server Delivery Planner\src\main\java\com\andreicerbu\exceptions\ProductUnavailableAnymoreException.java
|
||||
D:\Server Delivery Planner\src\main\java\com\andreicerbu\items\database\TableProduct.java
|
||||
D:\Server Delivery Planner\src\main\java\com\andreicerbu\exceptions\FieldAlreadyExistsException.java
|
||||
D:\Server Delivery Planner\src\main\java\com\andreicerbu\items\DatabaseClientJson.java
|
||||
D:\Server Delivery Planner\src\main\java\com\andreicerbu\items\Order.java
|
||||
D:\Server Delivery Planner\src\main\java\com\andreicerbu\items\BaseItem.java
|
||||
D:\Server Delivery Planner\src\main\java\com\andreicerbu\Database.java
|
||||
D:\Server Delivery Planner\src\main\java\com\andreicerbu\test.java
|
||||
D:\Server Delivery Planner\src\main\java\com\andreicerbu\items\database\TableRoute.java
|
||||
D:\Server Delivery Planner\src\main\java\com\andreicerbu\json\JsonFields.java
|
||||
D:\Server Delivery Planner\src\main\java\com\andreicerbu\exceptions\FieldToUpdateNotExistingException.java
|
||||
D:\Server Delivery Planner\src\main\java\com\andreicerbu\items\database\TableUser.java
|
||||
D:\Server Delivery Planner\src\main\java\com\andreicerbu\exceptions\InvalidCredentialsException.java
|
||||
D:\Server Delivery Planner\src\main\java\com\andreicerbu\exceptions\ProcessDoneException.java
|
||||
D:\Server Delivery Planner\src\main\java\com\andreicerbu\items\database\TableDeposit.java
|
||||
D:\Server Delivery Planner\src\main\java\com\andreicerbu\exceptions\NotExistingUserException.java
|
||||
D:\Server Delivery Planner\src\main\java\com\andreicerbu\InitializeDatabase.java
|
||||