working on stock refactoring
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -138,7 +138,7 @@ public class Constants {
|
||||
public static final String OFFSET = "offset";
|
||||
public static final String OPTIONAL = "optional";
|
||||
public static final String OWNER = "owner";
|
||||
public static final String OWNER_ID = "owner_id";
|
||||
public static final String OWNER_NUMBER = "owner_number";
|
||||
|
||||
public static final String PARENT_LOCATION_ID = "parent_location_id";
|
||||
public static final String PARENT_TASK_ID = "parent_task_id";
|
||||
|
||||
@@ -11,17 +11,17 @@ import java.util.*;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class Item implements Mappable {
|
||||
private long id, number; // id is the database key, number the owner-relative id
|
||||
private long id, ownerNumber; // id is the database key, number the owner-relative id
|
||||
private Owner owner;
|
||||
private String code, name;
|
||||
private Location location;
|
||||
private Collection<Property> properties;
|
||||
private Set<String> dirtyFields = new HashSet<>();
|
||||
|
||||
private Item(long id, Owner owner, long number, Location location, String code, String name) {
|
||||
private Item(long id, Owner owner, long ownerNumber, Location location, String code, String name) {
|
||||
this.id = id;
|
||||
this.owner = owner;
|
||||
this.number = number;
|
||||
this.ownerNumber = ownerNumber;
|
||||
this.location = location;
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
@@ -50,12 +50,12 @@ public class Item implements Mappable {
|
||||
|
||||
public static Item of(ResultSet rs) throws SQLException {
|
||||
var id = rs.getLong(ID);
|
||||
var owner = OwnerRef.of(rs);
|
||||
var ownerNumber = rs.getLong(OWNER_NUMBER);
|
||||
var location = Location.of(rs);
|
||||
var code = rs.getString(CODE);
|
||||
var name = rs.getString(NAME);
|
||||
var owner = OwnerRef.of(rs);
|
||||
var number = rs.getLong(NUMBER);
|
||||
var location = Location.of(rs);
|
||||
return new Item(id, owner, number, location, code, name);
|
||||
return new Item(id, owner, ownerNumber, location, code, name);
|
||||
}
|
||||
|
||||
public Owner owner(){
|
||||
|
||||
386
doc/stock.dia
386
doc/stock.dia
@@ -91,13 +91,13 @@
|
||||
<dia:layer name="Hintergrund" visible="true" connectable="true" active="true">
|
||||
<dia:object type="Flowchart - Box" version="0" id="O0">
|
||||
<dia:attribute name="obj_pos">
|
||||
<dia:point val="15.9,-2.66454e-15"/>
|
||||
<dia:point val="15.9,0"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="obj_bb">
|
||||
<dia:rectangle val="15.8,-0.1;23,2.1"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_corner">
|
||||
<dia:point val="15.9,-2.66454e-15"/>
|
||||
<dia:point val="15.9,0"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_width">
|
||||
<dia:real val="7"/>
|
||||
@@ -229,13 +229,13 @@
|
||||
</dia:object>
|
||||
<dia:object type="Flowchart - Box" version="0" id="O3">
|
||||
<dia:attribute name="obj_pos">
|
||||
<dia:point val="16.9,8"/>
|
||||
<dia:point val="17,6"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="obj_bb">
|
||||
<dia:rectangle val="16.85,7.95;22.95,10.05"/>
|
||||
<dia:rectangle val="16.95,5.95;23.05,8.05"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_corner">
|
||||
<dia:point val="16.9,8"/>
|
||||
<dia:point val="17,6"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_width">
|
||||
<dia:real val="6"/>
|
||||
@@ -261,7 +261,7 @@
|
||||
<dia:real val="0.80000000000000004"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="pos">
|
||||
<dia:point val="19.9,9.195"/>
|
||||
<dia:point val="20,7.195"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="color">
|
||||
<dia:color val="#000000ff"/>
|
||||
@@ -277,13 +277,13 @@
|
||||
<dia:point val="25.9,0"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="obj_bb">
|
||||
<dia:rectangle val="25.8,-0.1;32,2.1"/>
|
||||
<dia:rectangle val="25.8,-0.1;34.1,2.1"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_corner">
|
||||
<dia:point val="25.9,0"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_width">
|
||||
<dia:real val="6"/>
|
||||
<dia:real val="8.1000000000000014"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_height">
|
||||
<dia:real val="2.0000000029802321"/>
|
||||
@@ -309,7 +309,7 @@
|
||||
<dia:real val="0.80000000000000004"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="pos">
|
||||
<dia:point val="28.9,1.195"/>
|
||||
<dia:point val="29.95,1.195"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="color">
|
||||
<dia:color val="#000000ff"/>
|
||||
@@ -322,16 +322,16 @@
|
||||
</dia:object>
|
||||
<dia:object type="Flowchart - Box" version="0" id="O5">
|
||||
<dia:attribute name="obj_pos">
|
||||
<dia:point val="26.9,2"/>
|
||||
<dia:point val="27,2"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="obj_bb">
|
||||
<dia:rectangle val="26.85,1.95;31.95,4.05"/>
|
||||
<dia:rectangle val="26.95,1.95;34.05,4.05"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_corner">
|
||||
<dia:point val="26.9,2"/>
|
||||
<dia:point val="27,2"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_width">
|
||||
<dia:real val="5"/>
|
||||
<dia:real val="7"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_height">
|
||||
<dia:real val="2"/>
|
||||
@@ -354,7 +354,7 @@
|
||||
<dia:real val="0.80000000000000004"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="pos">
|
||||
<dia:point val="29.4,3.195"/>
|
||||
<dia:point val="30.5,3.195"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="color">
|
||||
<dia:color val="#000000ff"/>
|
||||
@@ -367,16 +367,16 @@
|
||||
</dia:object>
|
||||
<dia:object type="Flowchart - Box" version="0" id="O6">
|
||||
<dia:attribute name="obj_pos">
|
||||
<dia:point val="26.9,4"/>
|
||||
<dia:point val="27,4"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="obj_bb">
|
||||
<dia:rectangle val="26.85,3.95;31.95,6.05"/>
|
||||
<dia:rectangle val="26.95,3.95;34.05,6.05"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_corner">
|
||||
<dia:point val="26.9,4"/>
|
||||
<dia:point val="27,4"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_width">
|
||||
<dia:real val="5"/>
|
||||
<dia:real val="7"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_height">
|
||||
<dia:real val="2"/>
|
||||
@@ -390,7 +390,7 @@
|
||||
<dia:attribute name="text">
|
||||
<dia:composite type="text">
|
||||
<dia:attribute name="string">
|
||||
<dia:string>#LocationID#</dia:string>
|
||||
<dia:string>#ParentLocationID#</dia:string>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="font">
|
||||
<dia:font family="sans" style="0" name="Helvetica"/>
|
||||
@@ -399,7 +399,7 @@
|
||||
<dia:real val="0.80000000000000004"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="pos">
|
||||
<dia:point val="29.4,5.195"/>
|
||||
<dia:point val="30.5,5.195"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="color">
|
||||
<dia:color val="#000000ff"/>
|
||||
@@ -412,16 +412,16 @@
|
||||
</dia:object>
|
||||
<dia:object type="Flowchart - Box" version="0" id="O7">
|
||||
<dia:attribute name="obj_pos">
|
||||
<dia:point val="26.9,6"/>
|
||||
<dia:point val="27,6"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="obj_bb">
|
||||
<dia:rectangle val="26.85,5.95;31.95,8.05"/>
|
||||
<dia:rectangle val="26.95,5.95;34.05,8.05"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_corner">
|
||||
<dia:point val="26.9,6"/>
|
||||
<dia:point val="27,6"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_width">
|
||||
<dia:real val="5"/>
|
||||
<dia:real val="7"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_height">
|
||||
<dia:real val="2"/>
|
||||
@@ -444,7 +444,7 @@
|
||||
<dia:real val="0.80000000000000004"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="pos">
|
||||
<dia:point val="29.4,7.195"/>
|
||||
<dia:point val="30.5,7.195"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="color">
|
||||
<dia:color val="#000000ff"/>
|
||||
@@ -457,16 +457,16 @@
|
||||
</dia:object>
|
||||
<dia:object type="Flowchart - Box" version="0" id="O8">
|
||||
<dia:attribute name="obj_pos">
|
||||
<dia:point val="26.9,8"/>
|
||||
<dia:point val="27,8"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="obj_bb">
|
||||
<dia:rectangle val="26.85,7.95;31.95,10.05"/>
|
||||
<dia:rectangle val="26.95,7.95;34.05,10.05"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_corner">
|
||||
<dia:point val="26.9,8"/>
|
||||
<dia:point val="27,8"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_width">
|
||||
<dia:real val="5"/>
|
||||
<dia:real val="7"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_height">
|
||||
<dia:real val="2"/>
|
||||
@@ -489,7 +489,7 @@
|
||||
<dia:real val="0.80000000000000004"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="pos">
|
||||
<dia:point val="29.4,9.195"/>
|
||||
<dia:point val="30.5,9.195"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="color">
|
||||
<dia:color val="#000000ff"/>
|
||||
@@ -640,16 +640,16 @@
|
||||
</dia:object>
|
||||
<dia:object type="Standard - ZigZagLine" version="1" id="O12">
|
||||
<dia:attribute name="obj_pos">
|
||||
<dia:point val="22.9499,9"/>
|
||||
<dia:point val="23.0493,7"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="obj_bb">
|
||||
<dia:rectangle val="22.8999,2.6382;26.8998,9.05"/>
|
||||
<dia:rectangle val="22.9993,2.6382;27.0001,7.05"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="orth_points">
|
||||
<dia:point val="22.9499,9"/>
|
||||
<dia:point val="24.9,9"/>
|
||||
<dia:point val="23.0493,7"/>
|
||||
<dia:point val="24.9,7"/>
|
||||
<dia:point val="24.9,3"/>
|
||||
<dia:point val="26.8498,3"/>
|
||||
<dia:point val="26.9501,3"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="orth_orient">
|
||||
<dia:enum val="0"/>
|
||||
@@ -675,16 +675,16 @@
|
||||
</dia:object>
|
||||
<dia:object type="Standard - ZigZagLine" version="1" id="O13">
|
||||
<dia:attribute name="obj_pos">
|
||||
<dia:point val="31.9502,5"/>
|
||||
<dia:point val="34.0476,5"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="obj_bb">
|
||||
<dia:rectangle val="31.9002,2.6382;33.95,5.05"/>
|
||||
<dia:rectangle val="33.9976,2.6382;36.05,5.05"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="orth_points">
|
||||
<dia:point val="31.9502,5"/>
|
||||
<dia:point val="33.9,5"/>
|
||||
<dia:point val="33.9,3"/>
|
||||
<dia:point val="31.9502,3"/>
|
||||
<dia:point val="34.0476,5"/>
|
||||
<dia:point val="36,5"/>
|
||||
<dia:point val="36,3"/>
|
||||
<dia:point val="34.0476,3"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="orth_orient">
|
||||
<dia:enum val="0"/>
|
||||
@@ -1017,13 +1017,13 @@
|
||||
</dia:object>
|
||||
<dia:object type="Flowchart - Box" version="0" id="O21">
|
||||
<dia:attribute name="obj_pos">
|
||||
<dia:point val="16.9,10"/>
|
||||
<dia:point val="17,8"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="obj_bb">
|
||||
<dia:rectangle val="16.85,9.95;22.95,12.05"/>
|
||||
<dia:rectangle val="16.95,7.95;23.05,10.05"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_corner">
|
||||
<dia:point val="16.9,10"/>
|
||||
<dia:point val="17,8"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_width">
|
||||
<dia:real val="6"/>
|
||||
@@ -1049,7 +1049,7 @@
|
||||
<dia:real val="0.80000000000000004"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="pos">
|
||||
<dia:point val="19.9,11.195"/>
|
||||
<dia:point val="20,9.195"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="color">
|
||||
<dia:color val="#000000ff"/>
|
||||
@@ -1061,51 +1061,6 @@
|
||||
</dia:attribute>
|
||||
</dia:object>
|
||||
<dia:object type="Flowchart - Box" version="0" id="O22">
|
||||
<dia:attribute name="obj_pos">
|
||||
<dia:point val="16.9,6"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="obj_bb">
|
||||
<dia:rectangle val="16.85,5.95;22.95,8.05"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_corner">
|
||||
<dia:point val="16.9,6"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_width">
|
||||
<dia:real val="6"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_height">
|
||||
<dia:real val="2"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="show_background">
|
||||
<dia:boolean val="true"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="padding">
|
||||
<dia:real val="0"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="text">
|
||||
<dia:composite type="text">
|
||||
<dia:attribute name="string">
|
||||
<dia:string>#LocationRelation#</dia:string>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="font">
|
||||
<dia:font family="sans" style="0" name="Helvetica"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="height">
|
||||
<dia:real val="0.80000000000000004"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="pos">
|
||||
<dia:point val="19.9,7.195"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="color">
|
||||
<dia:color val="#000000ff"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="alignment">
|
||||
<dia:enum val="1"/>
|
||||
</dia:attribute>
|
||||
</dia:composite>
|
||||
</dia:attribute>
|
||||
</dia:object>
|
||||
<dia:object type="Flowchart - Box" version="0" id="O23">
|
||||
<dia:attribute name="obj_pos">
|
||||
<dia:point val="16,16"/>
|
||||
</dia:attribute>
|
||||
@@ -1153,7 +1108,7 @@
|
||||
</dia:composite>
|
||||
</dia:attribute>
|
||||
</dia:object>
|
||||
<dia:object type="Flowchart - Box" version="0" id="O24">
|
||||
<dia:object type="Flowchart - Box" version="0" id="O23">
|
||||
<dia:attribute name="obj_pos">
|
||||
<dia:point val="17,18"/>
|
||||
</dia:attribute>
|
||||
@@ -1198,15 +1153,15 @@
|
||||
</dia:composite>
|
||||
</dia:attribute>
|
||||
</dia:object>
|
||||
<dia:object type="Flowchart - Box" version="0" id="O25">
|
||||
<dia:object type="Flowchart - Box" version="0" id="O24">
|
||||
<dia:attribute name="obj_pos">
|
||||
<dia:point val="17,24"/>
|
||||
<dia:point val="17,26"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="obj_bb">
|
||||
<dia:rectangle val="16.95,23.95;23.05,26.05"/>
|
||||
<dia:rectangle val="16.95,25.95;23.05,28.05"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_corner">
|
||||
<dia:point val="17,24"/>
|
||||
<dia:point val="17,26"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_width">
|
||||
<dia:real val="6"/>
|
||||
@@ -1232,7 +1187,7 @@
|
||||
<dia:real val="0.80000000000000004"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="pos">
|
||||
<dia:point val="20,25.195"/>
|
||||
<dia:point val="20,27.195"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="color">
|
||||
<dia:color val="#000000ff"/>
|
||||
@@ -1243,15 +1198,15 @@
|
||||
</dia:composite>
|
||||
</dia:attribute>
|
||||
</dia:object>
|
||||
<dia:object type="Flowchart - Box" version="0" id="O26">
|
||||
<dia:object type="Flowchart - Box" version="0" id="O25">
|
||||
<dia:attribute name="obj_pos">
|
||||
<dia:point val="17,28"/>
|
||||
<dia:point val="17,24"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="obj_bb">
|
||||
<dia:rectangle val="16.95,27.95;23.05,30.05"/>
|
||||
<dia:rectangle val="16.95,23.95;23.05,26.05"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_corner">
|
||||
<dia:point val="17,28"/>
|
||||
<dia:point val="17,24"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_width">
|
||||
<dia:real val="6"/>
|
||||
@@ -1277,7 +1232,7 @@
|
||||
<dia:real val="0.80000000000000004"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="pos">
|
||||
<dia:point val="20,29.195"/>
|
||||
<dia:point val="20,25.195"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="color">
|
||||
<dia:color val="#000000ff"/>
|
||||
@@ -1288,18 +1243,18 @@
|
||||
</dia:composite>
|
||||
</dia:attribute>
|
||||
</dia:object>
|
||||
<dia:object type="Flowchart - Box" version="0" id="O27">
|
||||
<dia:object type="Flowchart - Box" version="0" id="O26">
|
||||
<dia:attribute name="obj_pos">
|
||||
<dia:point val="26,16"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="obj_bb">
|
||||
<dia:rectangle val="25.9,15.9;32.1,18.1"/>
|
||||
<dia:rectangle val="25.9,15.9;34.1,18.1"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_corner">
|
||||
<dia:point val="26,16"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_width">
|
||||
<dia:real val="6"/>
|
||||
<dia:real val="8"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_height">
|
||||
<dia:real val="2.0000000029802321"/>
|
||||
@@ -1325,7 +1280,7 @@
|
||||
<dia:real val="0.80000000000000004"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="pos">
|
||||
<dia:point val="29,17.195"/>
|
||||
<dia:point val="30,17.195"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="color">
|
||||
<dia:color val="#000000ff"/>
|
||||
@@ -1336,18 +1291,18 @@
|
||||
</dia:composite>
|
||||
</dia:attribute>
|
||||
</dia:object>
|
||||
<dia:object type="Flowchart - Box" version="0" id="O28">
|
||||
<dia:object type="Flowchart - Box" version="0" id="O27">
|
||||
<dia:attribute name="obj_pos">
|
||||
<dia:point val="27,18"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="obj_bb">
|
||||
<dia:rectangle val="26.95,17.95;32.05,20.05"/>
|
||||
<dia:rectangle val="26.95,17.95;34.05,20.05"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_corner">
|
||||
<dia:point val="27,18"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_width">
|
||||
<dia:real val="5"/>
|
||||
<dia:real val="7"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_height">
|
||||
<dia:real val="2"/>
|
||||
@@ -1370,7 +1325,7 @@
|
||||
<dia:real val="0.80000000000000004"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="pos">
|
||||
<dia:point val="29.5,19.195"/>
|
||||
<dia:point val="30.5,19.195"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="color">
|
||||
<dia:color val="#000000ff"/>
|
||||
@@ -1381,18 +1336,18 @@
|
||||
</dia:composite>
|
||||
</dia:attribute>
|
||||
</dia:object>
|
||||
<dia:object type="Flowchart - Box" version="0" id="O29">
|
||||
<dia:object type="Flowchart - Box" version="0" id="O28">
|
||||
<dia:attribute name="obj_pos">
|
||||
<dia:point val="27,22"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="obj_bb">
|
||||
<dia:rectangle val="26.95,21.95;32.05,24.05"/>
|
||||
<dia:rectangle val="26.95,21.95;34.05,24.05"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_corner">
|
||||
<dia:point val="27,22"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_width">
|
||||
<dia:real val="5"/>
|
||||
<dia:real val="7"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_height">
|
||||
<dia:real val="2"/>
|
||||
@@ -1406,7 +1361,7 @@
|
||||
<dia:attribute name="text">
|
||||
<dia:composite type="text">
|
||||
<dia:attribute name="string">
|
||||
<dia:string>#LocationID#</dia:string>
|
||||
<dia:string>#ParentLocationID#</dia:string>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="font">
|
||||
<dia:font family="sans" style="0" name="Helvetica"/>
|
||||
@@ -1415,7 +1370,7 @@
|
||||
<dia:real val="0.80000000000000004"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="pos">
|
||||
<dia:point val="29.5,23.195"/>
|
||||
<dia:point val="30.5,23.195"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="color">
|
||||
<dia:color val="#000000ff"/>
|
||||
@@ -1426,18 +1381,18 @@
|
||||
</dia:composite>
|
||||
</dia:attribute>
|
||||
</dia:object>
|
||||
<dia:object type="Flowchart - Box" version="0" id="O30">
|
||||
<dia:object type="Flowchart - Box" version="0" id="O29">
|
||||
<dia:attribute name="obj_pos">
|
||||
<dia:point val="27,24"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="obj_bb">
|
||||
<dia:rectangle val="26.95,23.95;32.05,26.05"/>
|
||||
<dia:rectangle val="26.95,23.95;34.05,26.05"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_corner">
|
||||
<dia:point val="27,24"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_width">
|
||||
<dia:real val="5"/>
|
||||
<dia:real val="7"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_height">
|
||||
<dia:real val="2"/>
|
||||
@@ -1460,7 +1415,7 @@
|
||||
<dia:real val="0.80000000000000004"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="pos">
|
||||
<dia:point val="29.5,25.195"/>
|
||||
<dia:point val="30.5,25.195"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="color">
|
||||
<dia:color val="#000000ff"/>
|
||||
@@ -1471,18 +1426,18 @@
|
||||
</dia:composite>
|
||||
</dia:attribute>
|
||||
</dia:object>
|
||||
<dia:object type="Flowchart - Box" version="0" id="O31">
|
||||
<dia:object type="Flowchart - Box" version="0" id="O30">
|
||||
<dia:attribute name="obj_pos">
|
||||
<dia:point val="27,26"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="obj_bb">
|
||||
<dia:rectangle val="26.95,25.95;32.05,28.05"/>
|
||||
<dia:rectangle val="26.95,25.95;34.05,28.05"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_corner">
|
||||
<dia:point val="27,26"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_width">
|
||||
<dia:real val="5"/>
|
||||
<dia:real val="7"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_height">
|
||||
<dia:real val="2"/>
|
||||
@@ -1505,7 +1460,7 @@
|
||||
<dia:real val="0.80000000000000004"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="pos">
|
||||
<dia:point val="29.5,27.195"/>
|
||||
<dia:point val="30.5,27.195"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="color">
|
||||
<dia:color val="#000000ff"/>
|
||||
@@ -1516,15 +1471,15 @@
|
||||
</dia:composite>
|
||||
</dia:attribute>
|
||||
</dia:object>
|
||||
<dia:object type="Flowchart - Box" version="0" id="O32">
|
||||
<dia:object type="Flowchart - Box" version="0" id="O31">
|
||||
<dia:attribute name="obj_pos">
|
||||
<dia:point val="8.88178e-16,16"/>
|
||||
<dia:point val="0,16"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="obj_bb">
|
||||
<dia:rectangle val="-0.1,15.9;5.1,18.1"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_corner">
|
||||
<dia:point val="8.88178e-16,16"/>
|
||||
<dia:point val="0,16"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_width">
|
||||
<dia:real val="5"/>
|
||||
@@ -1564,7 +1519,7 @@
|
||||
</dia:composite>
|
||||
</dia:attribute>
|
||||
</dia:object>
|
||||
<dia:object type="Flowchart - Box" version="0" id="O33">
|
||||
<dia:object type="Flowchart - Box" version="0" id="O32">
|
||||
<dia:attribute name="obj_pos">
|
||||
<dia:point val="1,18"/>
|
||||
</dia:attribute>
|
||||
@@ -1609,7 +1564,7 @@
|
||||
</dia:composite>
|
||||
</dia:attribute>
|
||||
</dia:object>
|
||||
<dia:object type="Flowchart - Box" version="0" id="O34">
|
||||
<dia:object type="Flowchart - Box" version="0" id="O33">
|
||||
<dia:attribute name="obj_pos">
|
||||
<dia:point val="1,20"/>
|
||||
</dia:attribute>
|
||||
@@ -1654,18 +1609,53 @@
|
||||
</dia:composite>
|
||||
</dia:attribute>
|
||||
</dia:object>
|
||||
<dia:object type="Standard - ZigZagLine" version="1" id="O34">
|
||||
<dia:attribute name="obj_pos">
|
||||
<dia:point val="23.0499,25"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="obj_bb">
|
||||
<dia:rectangle val="22.9999,18.6382;27.0024,25.05"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="orth_points">
|
||||
<dia:point val="23.0499,25"/>
|
||||
<dia:point val="25,25"/>
|
||||
<dia:point val="25,19"/>
|
||||
<dia:point val="26.9524,19"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="orth_orient">
|
||||
<dia:enum val="0"/>
|
||||
<dia:enum val="1"/>
|
||||
<dia:enum val="0"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="autorouting">
|
||||
<dia:boolean val="false"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="end_arrow">
|
||||
<dia:enum val="22"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="end_arrow_length">
|
||||
<dia:real val="0.5"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="end_arrow_width">
|
||||
<dia:real val="0.5"/>
|
||||
</dia:attribute>
|
||||
<dia:connections>
|
||||
<dia:connection handle="0" to="O25" connection="16"/>
|
||||
<dia:connection handle="1" to="O27" connection="16"/>
|
||||
</dia:connections>
|
||||
</dia:object>
|
||||
<dia:object type="Standard - ZigZagLine" version="1" id="O35">
|
||||
<dia:attribute name="obj_pos">
|
||||
<dia:point val="23.0499,29"/>
|
||||
<dia:point val="34.0476,23"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="obj_bb">
|
||||
<dia:rectangle val="22.9999,18.6382;26.9998,29.05"/>
|
||||
<dia:rectangle val="33.9976,18.6382;36.05,23.05"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="orth_points">
|
||||
<dia:point val="23.0499,29"/>
|
||||
<dia:point val="25,29"/>
|
||||
<dia:point val="25,19"/>
|
||||
<dia:point val="26.9498,19"/>
|
||||
<dia:point val="34.0476,23"/>
|
||||
<dia:point val="36,23"/>
|
||||
<dia:point val="36,19"/>
|
||||
<dia:point val="34.0476,19"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="orth_orient">
|
||||
<dia:enum val="0"/>
|
||||
@@ -1685,46 +1675,11 @@
|
||||
<dia:real val="0.5"/>
|
||||
</dia:attribute>
|
||||
<dia:connections>
|
||||
<dia:connection handle="0" to="O26" connection="16"/>
|
||||
<dia:connection handle="1" to="O28" connection="16"/>
|
||||
<dia:connection handle="0" to="O28" connection="16"/>
|
||||
<dia:connection handle="1" to="O27" connection="16"/>
|
||||
</dia:connections>
|
||||
</dia:object>
|
||||
<dia:object type="Standard - ZigZagLine" version="1" id="O36">
|
||||
<dia:attribute name="obj_pos">
|
||||
<dia:point val="32.0502,23"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="obj_bb">
|
||||
<dia:rectangle val="32.0002,18.6382;34.05,23.05"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="orth_points">
|
||||
<dia:point val="32.0502,23"/>
|
||||
<dia:point val="34,23"/>
|
||||
<dia:point val="34,19"/>
|
||||
<dia:point val="32.0502,19"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="orth_orient">
|
||||
<dia:enum val="0"/>
|
||||
<dia:enum val="1"/>
|
||||
<dia:enum val="0"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="autorouting">
|
||||
<dia:boolean val="false"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="end_arrow">
|
||||
<dia:enum val="22"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="end_arrow_length">
|
||||
<dia:real val="0.5"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="end_arrow_width">
|
||||
<dia:real val="0.5"/>
|
||||
</dia:attribute>
|
||||
<dia:connections>
|
||||
<dia:connection handle="0" to="O29" connection="16"/>
|
||||
<dia:connection handle="1" to="O28" connection="16"/>
|
||||
</dia:connections>
|
||||
</dia:object>
|
||||
<dia:object type="Flowchart - Box" version="0" id="O37">
|
||||
<dia:object type="Flowchart - Box" version="0" id="O36">
|
||||
<dia:attribute name="obj_pos">
|
||||
<dia:point val="8,16"/>
|
||||
</dia:attribute>
|
||||
@@ -1772,7 +1727,7 @@
|
||||
</dia:composite>
|
||||
</dia:attribute>
|
||||
</dia:object>
|
||||
<dia:object type="Flowchart - Box" version="0" id="O38">
|
||||
<dia:object type="Flowchart - Box" version="0" id="O37">
|
||||
<dia:attribute name="obj_pos">
|
||||
<dia:point val="9,18"/>
|
||||
</dia:attribute>
|
||||
@@ -1817,7 +1772,7 @@
|
||||
</dia:composite>
|
||||
</dia:attribute>
|
||||
</dia:object>
|
||||
<dia:object type="Flowchart - Box" version="0" id="O39">
|
||||
<dia:object type="Flowchart - Box" version="0" id="O38">
|
||||
<dia:attribute name="obj_pos">
|
||||
<dia:point val="9,20"/>
|
||||
</dia:attribute>
|
||||
@@ -1862,7 +1817,7 @@
|
||||
</dia:composite>
|
||||
</dia:attribute>
|
||||
</dia:object>
|
||||
<dia:object type="Flowchart - Box" version="0" id="O40">
|
||||
<dia:object type="Flowchart - Box" version="0" id="O39">
|
||||
<dia:attribute name="obj_pos">
|
||||
<dia:point val="9,22"/>
|
||||
</dia:attribute>
|
||||
@@ -1907,7 +1862,7 @@
|
||||
</dia:composite>
|
||||
</dia:attribute>
|
||||
</dia:object>
|
||||
<dia:object type="Standard - ZigZagLine" version="1" id="O41">
|
||||
<dia:object type="Standard - ZigZagLine" version="1" id="O40">
|
||||
<dia:attribute name="obj_pos">
|
||||
<dia:point val="8.95117,21"/>
|
||||
</dia:attribute>
|
||||
@@ -1938,11 +1893,11 @@
|
||||
<dia:real val="0.5"/>
|
||||
</dia:attribute>
|
||||
<dia:connections>
|
||||
<dia:connection handle="0" to="O39" connection="16"/>
|
||||
<dia:connection handle="1" to="O33" connection="16"/>
|
||||
<dia:connection handle="0" to="O38" connection="16"/>
|
||||
<dia:connection handle="1" to="O32" connection="16"/>
|
||||
</dia:connections>
|
||||
</dia:object>
|
||||
<dia:object type="Standard - ZigZagLine" version="1" id="O42">
|
||||
<dia:object type="Standard - ZigZagLine" version="1" id="O41">
|
||||
<dia:attribute name="obj_pos">
|
||||
<dia:point val="16.9498,19"/>
|
||||
</dia:attribute>
|
||||
@@ -1982,11 +1937,11 @@
|
||||
<dia:real val="0.5"/>
|
||||
</dia:attribute>
|
||||
<dia:connections>
|
||||
<dia:connection handle="0" to="O24" connection="16"/>
|
||||
<dia:connection handle="1" to="O38" connection="16"/>
|
||||
<dia:connection handle="0" to="O23" connection="16"/>
|
||||
<dia:connection handle="1" to="O37" connection="16"/>
|
||||
</dia:connections>
|
||||
</dia:object>
|
||||
<dia:object type="Flowchart - Box" version="0" id="O43">
|
||||
<dia:object type="Flowchart - Box" version="0" id="O42">
|
||||
<dia:attribute name="obj_pos">
|
||||
<dia:point val="1,22"/>
|
||||
</dia:attribute>
|
||||
@@ -2031,15 +1986,15 @@
|
||||
</dia:composite>
|
||||
</dia:attribute>
|
||||
</dia:object>
|
||||
<dia:object type="Flowchart - Box" version="0" id="O44">
|
||||
<dia:object type="Flowchart - Box" version="0" id="O43">
|
||||
<dia:attribute name="obj_pos">
|
||||
<dia:point val="17,30"/>
|
||||
<dia:point val="17,28"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="obj_bb">
|
||||
<dia:rectangle val="16.95,29.95;23.05,32.05"/>
|
||||
<dia:rectangle val="16.95,27.95;23.05,30.05"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_corner">
|
||||
<dia:point val="17,30"/>
|
||||
<dia:point val="17,28"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_width">
|
||||
<dia:real val="6"/>
|
||||
@@ -2056,7 +2011,7 @@
|
||||
<dia:attribute name="text">
|
||||
<dia:composite type="text">
|
||||
<dia:attribute name="string">
|
||||
<dia:string>#Physical#</dia:string>
|
||||
<dia:string>#Name#</dia:string>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="font">
|
||||
<dia:font family="sans" style="0" name="Helvetica"/>
|
||||
@@ -2065,7 +2020,7 @@
|
||||
<dia:real val="0.80000000000000004"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="pos">
|
||||
<dia:point val="20,31.195"/>
|
||||
<dia:point val="20,29.195"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="color">
|
||||
<dia:color val="#000000ff"/>
|
||||
@@ -2076,52 +2031,7 @@
|
||||
</dia:composite>
|
||||
</dia:attribute>
|
||||
</dia:object>
|
||||
<dia:object type="Flowchart - Box" version="0" id="O45">
|
||||
<dia:attribute name="obj_pos">
|
||||
<dia:point val="17,26"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="obj_bb">
|
||||
<dia:rectangle val="16.95,25.95;23.05,28.05"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_corner">
|
||||
<dia:point val="17,26"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_width">
|
||||
<dia:real val="6"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_height">
|
||||
<dia:real val="2"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="show_background">
|
||||
<dia:boolean val="true"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="padding">
|
||||
<dia:real val="0"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="text">
|
||||
<dia:composite type="text">
|
||||
<dia:attribute name="string">
|
||||
<dia:string>#LocationRelation#</dia:string>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="font">
|
||||
<dia:font family="sans" style="0" name="Helvetica"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="height">
|
||||
<dia:real val="0.80000000000000004"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="pos">
|
||||
<dia:point val="20,27.195"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="color">
|
||||
<dia:color val="#000000ff"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="alignment">
|
||||
<dia:enum val="1"/>
|
||||
</dia:attribute>
|
||||
</dia:composite>
|
||||
</dia:attribute>
|
||||
</dia:object>
|
||||
<dia:object type="Flowchart - Box" version="0" id="O46">
|
||||
<dia:object type="Flowchart - Box" version="0" id="O44">
|
||||
<dia:attribute name="obj_pos">
|
||||
<dia:point val="17,20"/>
|
||||
</dia:attribute>
|
||||
@@ -2166,7 +2076,7 @@
|
||||
</dia:composite>
|
||||
</dia:attribute>
|
||||
</dia:object>
|
||||
<dia:object type="Flowchart - Box" version="0" id="O47">
|
||||
<dia:object type="Flowchart - Box" version="0" id="O45">
|
||||
<dia:attribute name="obj_pos">
|
||||
<dia:point val="17,22"/>
|
||||
</dia:attribute>
|
||||
@@ -2211,18 +2121,18 @@
|
||||
</dia:composite>
|
||||
</dia:attribute>
|
||||
</dia:object>
|
||||
<dia:object type="Flowchart - Box" version="0" id="O48">
|
||||
<dia:object type="Flowchart - Box" version="0" id="O46">
|
||||
<dia:attribute name="obj_pos">
|
||||
<dia:point val="27,20"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="obj_bb">
|
||||
<dia:rectangle val="26.95,19.95;32.05,22.05"/>
|
||||
<dia:rectangle val="26.95,19.95;34.05,22.05"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_corner">
|
||||
<dia:point val="27,20"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_width">
|
||||
<dia:real val="5"/>
|
||||
<dia:real val="7"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="elem_height">
|
||||
<dia:real val="2"/>
|
||||
@@ -2245,7 +2155,7 @@
|
||||
<dia:real val="0.80000000000000004"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="pos">
|
||||
<dia:point val="29.5,21.195"/>
|
||||
<dia:point val="30.5,21.195"/>
|
||||
</dia:attribute>
|
||||
<dia:attribute name="color">
|
||||
<dia:color val="#000000ff"/>
|
||||
|
||||
@@ -29,19 +29,10 @@ public class SqliteDb extends BaseDb implements StockDb {
|
||||
return new LegacyLocation(rs.getString(ID), rs.getString(LOCATION_ID), rs.getString(NAME), rs.getString(DESCRIPTION));
|
||||
}
|
||||
|
||||
public long owner() {
|
||||
public String owner() {
|
||||
var parts = id.split(":");
|
||||
if (parts.length != 3) throw databaseException("Expected legacy location id to be of the form ss:dd:ss, encountered {0}!",id);
|
||||
try {
|
||||
var owner = Long.parseLong(parts[1]);
|
||||
switch (parts[0]){
|
||||
case "company": return -owner;
|
||||
case "user": return owner;
|
||||
case null, default: throw databaseException("Expected legacy location id to start with 'company:' or 'user:', encountered {0}!",id);
|
||||
}
|
||||
} catch (NumberFormatException nfe){
|
||||
throw databaseException("Expected legacy location id to be of the form ss:dd:ss, encountered {0}!",id);
|
||||
}
|
||||
return String.join(":", parts[0], parts[1]);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -96,9 +87,8 @@ public class SqliteDb extends BaseDb implements StockDb {
|
||||
{2} LONG NOT NULL,
|
||||
{3} VARCHAR(255),
|
||||
{4} VARCHAR(255) NOT NULL,
|
||||
{5} LONG NOT NULL,
|
||||
PRIMARY KEY({0}, {1}))""";
|
||||
sql = format(sql, ID, OWNER, OWNER_ID, CODE, NAME, LOCATION_ID);
|
||||
{5} LONG NOT NULL)""";
|
||||
sql = format(sql, ID, OWNER, OWNER_NUMBER, CODE, NAME, LOCATION_ID);
|
||||
db.prepareStatement(sql).execute();
|
||||
}
|
||||
|
||||
@@ -209,7 +199,7 @@ public class SqliteDb extends BaseDb implements StockDb {
|
||||
@Override
|
||||
public Collection<DbLocation> listCompanyLocations(Company company) {
|
||||
try {
|
||||
var rs = select(ALL).from(TABLE_LOCATIONS).where(OWNER,equal(-company.id())).where(PARENT_LOCATION_ID,isNull()).exec(db);
|
||||
var rs = select(ALL).from(TABLE_LOCATIONS).where(OWNER,equal(company.dbCode())).where(PARENT_LOCATION_ID,isNull()).exec(db);
|
||||
var list = new ArrayList<DbLocation>();
|
||||
while (rs.next()) list.add(DbLocation.of(rs));
|
||||
rs.close();
|
||||
@@ -224,13 +214,11 @@ public class SqliteDb extends BaseDb implements StockDb {
|
||||
try {
|
||||
var rs = select(ALL).from(TABLE_ITEMS).where(LOCATION_ID,equal(location.id())).exec(db);
|
||||
var list = new ArrayList<Item>();
|
||||
var ownerMap = new HashMap<Long,Mappable>();
|
||||
while (rs.next()) list.add(Item.of(rs));
|
||||
rs.close();
|
||||
|
||||
for (var item : list){
|
||||
var ownerId = item.owner();
|
||||
rs = select(ALL).from(TABLE_ITEM_PROPERTIES).leftJoin(PROPERTY_ID,TABLE_PROPERTIES,ID).where(OWNER,equal(ownerId)).where(ITEM_ID,equal(item.id())).exec(db);
|
||||
rs = select(ALL).from(TABLE_ITEM_PROPERTIES).leftJoin(PROPERTY_ID,TABLE_PROPERTIES,ID).where(ITEM_ID,equal(item.id())).exec(db);
|
||||
while (rs.next()) item.properties().add(Property.of(rs));
|
||||
rs.close();
|
||||
}
|
||||
@@ -282,7 +270,7 @@ public class SqliteDb extends BaseDb implements StockDb {
|
||||
@Override
|
||||
public Collection<DbLocation> listUserLocations(UmbrellaUser user) {
|
||||
try {
|
||||
var rs = select(ALL).from(TABLE_LOCATIONS).where(OWNER,equal(user.id())).where(PARENT_LOCATION_ID,isNull()).exec(db);
|
||||
var rs = select(ALL).from(TABLE_LOCATIONS).where(OWNER,equal(user.dbCode())).where(PARENT_LOCATION_ID,isNull()).exec(db);
|
||||
var list = new ArrayList<DbLocation>();
|
||||
while (rs.next()) list.add(DbLocation.of(rs));
|
||||
rs.close();
|
||||
@@ -335,32 +323,32 @@ public class SqliteDb extends BaseDb implements StockDb {
|
||||
return item;
|
||||
}
|
||||
|
||||
private void transformItems(Map<String, Long> oldLocationIdsToNew) throws SQLException {
|
||||
private HashMap<String, Long> transformItems(Map<String, Long> oldLocationIdsToNew) throws SQLException {
|
||||
var rs = select(ALL).from(TABLE_ITEMS).exec(db);
|
||||
var insert = insertInto("items_temp",OWNER, ID, CODE, NAME, LOCATION_ID);
|
||||
var insert = insertInto("items_temp",OWNER, OWNER_NUMBER, LOCATION_ID, CODE, NAME);
|
||||
var oldToNew = new HashMap<String,Long>(); // maps from old item ids to new ones
|
||||
while (rs.next()){
|
||||
var oldId = rs.getString(ID);
|
||||
var parts = oldId.split(":");
|
||||
var owner = 0L;
|
||||
var id = 0L;
|
||||
if (parts.length != 3) throw databaseException("Expected old item id to be of the form ss:dd:dd, encountered {0}!",oldId);
|
||||
var owner = String.join(":",parts[0], parts[1]);
|
||||
long ownerNumber;
|
||||
try {
|
||||
owner = Long.parseLong(parts[1]);
|
||||
id = Long.parseLong(parts[2]);
|
||||
} catch (NumberFormatException e){
|
||||
throw databaseException("Expected item id to be of format ss:dd:dd, but encountered \"{0}\"",oldId);
|
||||
ownerNumber = Long.parseLong(parts[2]);
|
||||
} catch (NumberFormatException e) {
|
||||
throw databaseException("Expected old item id to be of the form ss:dd:dd, encountered {0}!",oldId);
|
||||
}
|
||||
var ownerIsCompany = switch (parts[0]){
|
||||
case "company" -> true;
|
||||
case "user" -> false;
|
||||
case null, default -> throw databaseException("Expected item id to start with 'company:' or 'user:', encountered \"{0}\"",oldId);
|
||||
};
|
||||
|
||||
var oldLocationId = rs.getString(LOCATION_ID);
|
||||
var locationId = oldLocationIdsToNew.get(oldLocationId);
|
||||
if (locationId == null) throw databaseException("Item {0} of {1} {2} refers to location {3}, which is unknown!",id,parts[1],owner,oldLocationId);
|
||||
insert.values(ownerIsCompany?-owner:owner, id, rs.getString(CODE), rs.getString(NAME), locationId).execute(db).getGeneratedKeys();
|
||||
if (locationId == null) throw databaseException("Item {0} of {1} {2} refers to location {3}, which is unknown!",oldId,parts[0],parts[1],oldLocationId);
|
||||
var rs2 = insert.values(owner, ownerNumber, locationId, rs.getString(CODE), rs.getString(NAME)).execute(db).getGeneratedKeys();
|
||||
oldToNew.put(oldId,rs2.getLong(1));
|
||||
rs2.close();
|
||||
}
|
||||
rs.close();
|
||||
insert.execute(db);
|
||||
return oldToNew;
|
||||
}
|
||||
|
||||
private Map<String, Long> transformLocations() throws SQLException {
|
||||
@@ -370,7 +358,7 @@ public class SqliteDb extends BaseDb implements StockDb {
|
||||
while (rs.next()) locations.add(LegacyLocation.of(rs));
|
||||
rs.close();
|
||||
|
||||
var query = insertInto("locations_temp", PARENT_LOCATION_ID, OWNER, NAME, DESCRIPTION);
|
||||
var query = insertInto("locations_temp", OWNER, PARENT_LOCATION_ID, NAME, DESCRIPTION);
|
||||
while (!locations.isEmpty()){
|
||||
var legacyLocation = locations.removeFirst();
|
||||
var parentRef = nullIfEmpty(legacyLocation.parent());
|
||||
@@ -378,39 +366,30 @@ public class SqliteDb extends BaseDb implements StockDb {
|
||||
if (parentRef != null) {
|
||||
parentId = oldToNew.get(parentRef);
|
||||
if (parentId == null) { // parent not processed, re-add to end of queue
|
||||
LOG.log(WARNING,"Postpoining {0}, as {1} is not present…",legacyLocation.id,legacyLocation.parent);
|
||||
LOG.log(WARNING,"Postponing {0}, as {1} is not present…",legacyLocation.id,legacyLocation.parent);
|
||||
locations.add(legacyLocation);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
rs = query.values(parentId, legacyLocation.owner(), legacyLocation.name(), legacyLocation.description()).execute(db).getGeneratedKeys();
|
||||
var id = rs.getLong(1);
|
||||
oldToNew.put(legacyLocation.id(),id);
|
||||
var owner = legacyLocation.owner();
|
||||
|
||||
rs = query.values(owner, parentId, legacyLocation.name, legacyLocation.description).execute(db).getGeneratedKeys();
|
||||
oldToNew.put(legacyLocation.id(),rs.getLong(1));
|
||||
rs.close();
|
||||
}
|
||||
return oldToNew;
|
||||
}
|
||||
|
||||
private void transformProperties() throws SQLException {
|
||||
private void transformProperties(HashMap<String, Long> oldItemIdsToNew) throws SQLException {
|
||||
var rs = select(ALL).from(TABLE_ITEM_PROPERTIES).exec(db);
|
||||
var insert = insertInto("item_props_temp",OWNER, ITEM_ID, PROPERTY_ID, VALUE);
|
||||
var insert = insertInto("item_props_temp",ITEM_ID, PROPERTY_ID, VALUE);
|
||||
while (rs.next()){
|
||||
var oldItemId = rs.getString(ITEM_ID);
|
||||
var parts = oldItemId.split(":");
|
||||
var owner = 0L;
|
||||
var itemId = 0L;
|
||||
try {
|
||||
owner = Long.parseLong(parts[1]);
|
||||
itemId = Long.parseLong(parts[2]);
|
||||
} catch (NumberFormatException e){
|
||||
throw databaseException("Expected item id to be of format ss:dd:dd, but encountered \"{0}\"",oldItemId);
|
||||
var itemId = oldItemIdsToNew.get(oldItemId);
|
||||
if (itemId == null) {
|
||||
throw databaseException("Old item id ({0}) has no new counterpart!",oldItemId);
|
||||
}
|
||||
var ownerIsCompany = switch (parts[0]){
|
||||
case "company" -> true;
|
||||
case "user" -> false;
|
||||
case null, default -> throw databaseException("Expected item id to start with 'company:' or 'user:', encountered \"{0}\"",oldItemId);
|
||||
};
|
||||
insert.values(ownerIsCompany?-owner:owner, itemId, rs.getLong(PROPERTY_ID), rs.getString(VALUE));
|
||||
insert.values(itemId, rs.getLong(PROPERTY_ID), rs.getString(VALUE));
|
||||
}
|
||||
rs.close();
|
||||
insert.execute(db).close();
|
||||
@@ -423,8 +402,8 @@ public class SqliteDb extends BaseDb implements StockDb {
|
||||
createIntermediateItemsTable();
|
||||
createIntermediatePropsTable();
|
||||
var oldLocationIdsToNew = transformLocations();
|
||||
transformItems(oldLocationIdsToNew);
|
||||
transformProperties();
|
||||
var oldItemIdsToNew = transformItems(oldLocationIdsToNew);
|
||||
transformProperties(oldItemIdsToNew);
|
||||
replaceLocationsTable();
|
||||
replaceItemsTable();
|
||||
replaceItemPropsTable();
|
||||
|
||||
@@ -49,8 +49,8 @@ public class StockModule extends BaseHandler implements StockService {
|
||||
return switch (head) {
|
||||
case LOCATION -> {
|
||||
try {
|
||||
var id = Long.parseLong(path.pop());
|
||||
yield getLocation(user.get(), Location.of(id),ex);
|
||||
var location = Location.of(Long.parseLong(path.pop()));
|
||||
yield getItemsAtLocation(user.get(), location, ex);
|
||||
} catch (Exception e){
|
||||
yield super.doGet(path,ex);
|
||||
}
|
||||
@@ -100,7 +100,7 @@ public class StockModule extends BaseHandler implements StockService {
|
||||
|
||||
}
|
||||
|
||||
private boolean getLocation(UmbrellaUser user, Location location, HttpExchange ex) throws IOException {
|
||||
private boolean getItemsAtLocation(UmbrellaUser user, Location location, HttpExchange ex) throws IOException {
|
||||
return sendContent(ex, stockDb.listItemsAt(location).stream().map(Item::toMap).toList());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user