refactored item module → stock, added legacy database creation methods
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -10,11 +10,11 @@ public class ModuleRegistry {
|
||||
private ContactService contactService;
|
||||
private DocumentService documentService;
|
||||
private FileService fileService;
|
||||
private ItemService itemService;
|
||||
private MarkdownService markdownService;
|
||||
private NoteService noteService;
|
||||
private PostBox postBox;
|
||||
private ProjectService projectService;
|
||||
private StockService stockService;
|
||||
private TagService tagService;
|
||||
private TaskService taskService;
|
||||
private TimeService timeService;
|
||||
@@ -33,7 +33,7 @@ public class ModuleRegistry {
|
||||
case ContactService cs: singleton.contactService = cs; break;
|
||||
case DocumentService ds: singleton.documentService = ds; break;
|
||||
case FileService fs: singleton.fileService = fs; break;
|
||||
case ItemService is: singleton.itemService = is; break;
|
||||
case StockService is: singleton.stockService = is; break;
|
||||
case MarkdownService ms: singleton.markdownService = ms; break;
|
||||
case NoteService ns: singleton.noteService = ns; break;
|
||||
case PostBox pb: singleton.postBox = pb; break;
|
||||
@@ -65,8 +65,8 @@ public class ModuleRegistry {
|
||||
return singleton.documentService;
|
||||
}
|
||||
|
||||
public static ItemService itemService(){
|
||||
return singleton.itemService;
|
||||
public static StockService itemService(){
|
||||
return singleton.stockService;
|
||||
}
|
||||
|
||||
public static FileService fileService(){
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
/* © SRSoftware 2025 */
|
||||
package de.srsoftware.umbrella.core.api;
|
||||
|
||||
import de.srsoftware.umbrella.core.exceptions.UmbrellaException;
|
||||
import de.srsoftware.umbrella.core.model.Item;
|
||||
import java.util.Collection;
|
||||
|
||||
public interface ItemService {
|
||||
Collection<Item> list(long companyId) throws UmbrellaException;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
/* © SRSoftware 2025 */
|
||||
package de.srsoftware.umbrella.core.api;
|
||||
|
||||
|
||||
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.
|
||||
* @param company_id
|
||||
* @return
|
||||
*/
|
||||
Collection<Object> redefineMe(long company_id);
|
||||
}
|
||||
@@ -1,38 +1,12 @@
|
||||
/* © SRSoftware 2025 */
|
||||
package de.srsoftware.umbrella.core.model;
|
||||
|
||||
import static de.srsoftware.umbrella.core.Constants.*;
|
||||
import static de.srsoftware.umbrella.core.Constants.CODE;
|
||||
import static de.srsoftware.umbrella.core.Util.mapMarkdown;
|
||||
import java.util.Collection;
|
||||
|
||||
import de.srsoftware.tools.Mappable;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map;
|
||||
|
||||
public record Item(long id, long companyId, String code, String name, String description, String unit, long unitPrice, long tax) implements Mappable {
|
||||
public static Item of(ResultSet rs) throws SQLException {
|
||||
var id = rs.getLong(ID);
|
||||
var companyId = rs.getLong(COMPANY_ID);
|
||||
var code = rs.getString(CODE);
|
||||
var name = rs.getString(NAME);
|
||||
var desc = rs.getString(DESCRIPTION);
|
||||
var unit = rs.getString(UNIT);
|
||||
var unitPrice = rs.getLong(UNIT_PRICE);
|
||||
var tax = rs.getInt(TAX);
|
||||
|
||||
return new Item(id,companyId,code,name,desc,unit,unitPrice,tax);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap() {
|
||||
return Map.of(
|
||||
ID,id,
|
||||
COMPANY_ID,companyId,
|
||||
CODE,code,NAME,name,
|
||||
DESCRIPTION,mapMarkdown(description),
|
||||
UNIT,unit,
|
||||
UNIT_PRICE,unitPrice,
|
||||
TAX,tax);
|
||||
}
|
||||
public class Item {
|
||||
private long id;
|
||||
private String code;
|
||||
private boolean physical;
|
||||
private Location location;
|
||||
private Collection<Property> properties;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
/* © SRSoftware 2025 */
|
||||
package de.srsoftware.umbrella.core.model;
|
||||
|
||||
public class Location {
|
||||
private long id;
|
||||
private long parentLocationId;
|
||||
private String name;
|
||||
private String description;
|
||||
private String relation; // when added to an item, this field describes the type of the relation
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
/* © SRSoftware 2025 */
|
||||
package de.srsoftware.umbrella.core.model;
|
||||
|
||||
public class Property {
|
||||
long id;
|
||||
String name;
|
||||
Object value;
|
||||
String unit;
|
||||
String quantity;
|
||||
}
|
||||
Reference in New Issue
Block a user