working on migration of items to stock db
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -8,7 +8,7 @@ import java.util.Collection;
|
||||
public interface StockService {
|
||||
/**
|
||||
* Das war mal die methode um zu checken, ob einer Firma noch Items zugewiesen sind.
|
||||
* Diese Methode muss neu definiert werden, sobald der Stock-Service neu implementiert ist.
|
||||
* TODO: Diese Methode muss neu definiert werden, sobald der Stock-Service neu implementiert ist.
|
||||
* @param company_id
|
||||
* @return
|
||||
*/
|
||||
|
||||
@@ -13,19 +13,20 @@ import org.json.JSONObject;
|
||||
public class Item implements Mappable {
|
||||
private long id, ownerNumber; // id is the database key, number the owner-relative id
|
||||
private Owner owner;
|
||||
private String code, name;
|
||||
private String code, description, name;
|
||||
private Location location;
|
||||
private Collection<Property> properties;
|
||||
private Set<String> dirtyFields = new HashSet<>();
|
||||
|
||||
public Item(long id, Owner owner, long ownerNumber, Location location, String code, String name) {
|
||||
this.id = id;
|
||||
this.owner = owner;
|
||||
public Item(long id, Owner owner, long ownerNumber, Location location, String code, String name, String description) {
|
||||
this.id = id;
|
||||
this.owner = owner;
|
||||
this.ownerNumber = ownerNumber;
|
||||
this.location = location;
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
this.properties = new HashSet<>();
|
||||
this.location = location;
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.properties = new HashSet<>();
|
||||
}
|
||||
|
||||
public Item clear() {
|
||||
@@ -37,6 +38,10 @@ public class Item implements Mappable {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String description(){
|
||||
return description;
|
||||
}
|
||||
|
||||
public boolean isDirty(){
|
||||
return !dirtyFields.isEmpty();
|
||||
}
|
||||
@@ -65,13 +70,14 @@ public class Item implements Mappable {
|
||||
}
|
||||
|
||||
public static Item of(ResultSet rs) throws SQLException {
|
||||
var id = rs.getLong(ID);
|
||||
var owner = OwnerRef.of(rs);
|
||||
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);
|
||||
return new Item(id, owner, ownerNumber, location, code, name);
|
||||
var location = Location.of(rs);
|
||||
var code = rs.getString(CODE);
|
||||
var name = rs.getString(NAME);
|
||||
var description = rs.getString(DESCRIPTION);
|
||||
return new Item(id, owner, ownerNumber, location, code, name, description);
|
||||
}
|
||||
|
||||
public Owner owner(){
|
||||
@@ -92,6 +98,9 @@ public class Item implements Mappable {
|
||||
case NAME:
|
||||
name = json.getString(field);
|
||||
break;
|
||||
case DESCRIPTION:
|
||||
description = json.getString(field);
|
||||
break;
|
||||
default:
|
||||
known = false;
|
||||
}
|
||||
@@ -112,6 +121,7 @@ public class Item implements Mappable {
|
||||
map.put(LOCATION,location.toMap());
|
||||
map.put(CODE,code);
|
||||
map.put(NAME,name);
|
||||
map.put(DESCRIPTION,description);
|
||||
map.put(OWNER_NUMBER,ownerNumber);
|
||||
if (properties != null) map.put(PROPERTIES,properties.stream().map(Property::toMap).toList());
|
||||
return map;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
package de.srsoftware.umbrella.core.model;
|
||||
|
||||
import static de.srsoftware.umbrella.core.Constants.*;
|
||||
import static java.text.MessageFormat.format;
|
||||
|
||||
import de.srsoftware.tools.Mappable;
|
||||
import java.sql.ResultSet;
|
||||
@@ -22,6 +23,14 @@ public class Property implements Mappable {
|
||||
this.unit = unit;
|
||||
}
|
||||
|
||||
public long id(){
|
||||
return id;
|
||||
}
|
||||
|
||||
public String name(){
|
||||
return name;
|
||||
}
|
||||
|
||||
public static Property of(ResultSet rs) throws SQLException {
|
||||
var id = rs.getLong(ID);
|
||||
var name = rs.getString(NAME);
|
||||
@@ -45,6 +54,19 @@ public class Property implements Mappable {
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return format("{0} ({1} = {2}{3})",getClass().getSimpleName(),name,value,unit==null?"":" "+unit);
|
||||
}
|
||||
|
||||
public String unit(){
|
||||
return unit;
|
||||
}
|
||||
|
||||
public Object value(){
|
||||
return value;
|
||||
}
|
||||
|
||||
public Property value(Object newVal){
|
||||
value = newVal;
|
||||
return this;
|
||||
|
||||
Reference in New Issue
Block a user