working on document view/edit

This commit is contained in:
2025-07-10 15:42:37 +02:00
parent 0bfbe47d96
commit 90c27382a1
22 changed files with 281 additions and 34 deletions

View File

@@ -6,6 +6,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
public class Constants {
private Constants(){}
public static final String ADDRESS = "address";
public static final String ATTACHMENTS = "attachments";
public static final String AUTHORIZATION = "Authorization";

View File

@@ -7,8 +7,13 @@ import de.srsoftware.umbrella.core.model.UmbrellaUser;
import java.util.Collection;
public interface CompanyService {
public Collection<UmbrellaUser> getMembers(long companyId) throws UmbrellaException;
public UserService userService();
Company get(long companyId) throws UmbrellaException;
Collection<UmbrellaUser> getMembers(long companyId) throws UmbrellaException;
Collection<Company> listCompaniesOf(UmbrellaUser user) throws UmbrellaException;
boolean membership(long companyId, long userId) throws UmbrellaException;
UserService userService();
}

View File

@@ -0,0 +1,11 @@
/* © SRSoftware 2025 */
package de.srsoftware.umbrella.core.api;
import de.srsoftware.umbrella.core.exceptions.UmbrellaException;
import de.srsoftware.umbrella.core.model.Contact;
import de.srsoftware.umbrella.core.model.UmbrellaUser;
import java.util.Collection;
public interface ContactService {
Collection<Contact> listContactsOf(UmbrellaUser user) throws UmbrellaException;
}

View File

@@ -25,6 +25,10 @@ public class UmbrellaException extends Exception{
return this;
}
public static UmbrellaException databaseException(String message, Object fills) {
return new UmbrellaException(HTTP_SERVER_ERROR,message,fills);
}
public static UmbrellaException invalidFieldException(String field,String expected){
return new UmbrellaException(HTTP_UNPROCESSABLE, ERROR_INVALID_FIELD, field, expected);
}

View File

@@ -1,15 +1,19 @@
/* © SRSoftware 2025 */
package de.srsoftware.umbrella.core.model;
import static de.srsoftware.tools.Optionals.emptyIfNull;
import static de.srsoftware.umbrella.core.Constants.*;
import static java.util.Map.entry;
import de.srsoftware.tools.Mappable;
import de.srsoftware.umbrella.core.exceptions.UmbrellaException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Map;
import org.json.JSONException;
import org.json.JSONObject;
public record Company(long id, String name, String address, String court, String taxId, String phone, String decimalSeparator, String thousandsSeparator, long lastCustomerNumber, int decimals, String customerNumberPrefix, String currency, String email, String bankAccount) {
public record Company(long id, String name, String address, String court, String taxId, String phone, String decimalSeparator, String thousandsSeparator, long lastCustomerNumber, int decimals, String customerNumberPrefix, String currency, String email, String bankAccount) implements Mappable {
public static Company of(JSONObject json) throws UmbrellaException {
try {
@@ -54,4 +58,29 @@ public record Company(long id, String name, String address, String court, String
throw new UmbrellaException(500,"Failed to convert ResultSet to Company!").causedBy(e);
}
}
@Override
public String toString() {
return name;
}
@Override
public Map<String, Object> toMap() {
return Map.ofEntries(
entry(ID,id),
entry(NAME,name),
entry(ADDRESS,emptyIfNull(address)),
entry(FIELD_COURT,emptyIfNull(court)),
entry(FIELD_TAX_NUMBER,emptyIfNull(taxId)),
entry(FIELD_PHONE,emptyIfNull(phone)),
entry(DECIMAL_SEPARATOR,emptyIfNull(decimalSeparator)),
entry(THOUSANDS_SEPARATOR,emptyIfNull(thousandsSeparator)),
entry(LAST_CUSTOMER_NUMBER,lastCustomerNumber),
entry(DECIMALS,decimals),
entry(CUSTOMER_NUMBER_PREFIX,emptyIfNull(customerNumberPrefix)),
entry(FIELD_CURRENCY,emptyIfNull(currency)),
entry(EMAIL,emptyIfNull(email)),
entry(FIELD_BANK_ACCOUNT,emptyIfNull(bankAccount))
);
}
}

View File

@@ -0,0 +1,21 @@
/* © SRSoftware 2025 */
package de.srsoftware.umbrella.core.model;
import static de.srsoftware.umbrella.core.Constants.DATA;
import static de.srsoftware.umbrella.core.Constants.ID;
import de.srsoftware.tools.Mappable;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Map;
public record Contact(long id, String vcard) implements Mappable {
public static Contact of(ResultSet rs) throws SQLException {
return new Contact(rs.getLong(ID),rs.getString(DATA));
}
@Override
public Map<String, Object> toMap() {
return Map.of();
}
}