working on location tree
This commit is contained in:
@@ -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";
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user