working on location tree

This commit is contained in:
2025-10-13 16:14:31 +02:00
parent b361731cab
commit 2cd022451a
10 changed files with 205 additions and 72 deletions

View File

@@ -133,7 +133,9 @@ 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 PARENT_LOCATION_ID = "parent_location_id";
public static final String PARENT_TASK_ID = "parent_task_id";
public static final String PASS = "pass";
public static final String PASSWORD = "password";

View File

@@ -1,13 +1,16 @@
/* © SRSoftware 2025 */
package de.srsoftware.umbrella.core.model;
import java.sql.ResultSet;
import java.sql.SQLException;
import de.srsoftware.tools.Mappable;
import static de.srsoftware.umbrella.core.Constants.*;
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.databaseException;
public class Location {
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
public class Location implements Mappable {
private long owner;
private boolean ownerIsCompany = false;
private long id;
@@ -37,8 +40,12 @@ public class Location {
return name;
}
public static Location of(ResultSet rs){
return null;
public static Location of(ResultSet rs) throws SQLException {
var owner = rs.getLong(OWNER);
var id = rs.getLong(ID);
var isCompany = owner < 0;
if (isCompany) owner = -owner;
return new Location(owner,isCompany,id, rs.getLong(PARENT_LOCATION_ID), rs.getString(NAME),rs.getString(DESCRIPTION));
}
@@ -50,4 +57,13 @@ public class Location {
public Long parent(){
return parentLocationId;
}
@Override
public Map<String, Object> toMap() {
return Map.of(
ownerIsCompany ? COMPANY : USER,owner,
ID,id,
NAME,name,
DESCRIPTION,description);
}
}