added links to documents to time track list
This commit is contained in:
@@ -430,6 +430,10 @@ public class DocumentApi extends BaseHandler implements DocumentService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Long, Map<Long, String>> docsReferencedByTimes(Set<Long> timeIds) throws UmbrellaException {
|
||||
return db.docReferencedByTimes(timeIds);
|
||||
}
|
||||
|
||||
private boolean patchDocument(long docId, UmbrellaUser user, HttpExchange ex) throws UmbrellaException, IOException {
|
||||
var doc = getDocument(docId,user).a;
|
||||
|
||||
@@ -10,6 +10,7 @@ import de.srsoftware.umbrella.documents.model.*;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public interface DocumentDb {
|
||||
Long dropPosition(long documentId, long pos) throws UmbrellaException;
|
||||
@@ -27,9 +28,13 @@ public interface DocumentDb {
|
||||
|
||||
CompanySettings getCompanySettings(long companyId, Type docType) throws UmbrellaException;
|
||||
|
||||
Collection<Template> getCompanyTemplates(long l) throws UmbrellaException;
|
||||
|
||||
Type getType(int typeId) throws UmbrellaException;
|
||||
|
||||
Map<Long, Document> listDocs(long companyId) throws UmbrellaException;
|
||||
public Map<Long, Map<Long, String>> docReferencedByTimes(Set<Long> timeIds) throws UmbrellaException;
|
||||
|
||||
Map<Long, Document> listDocs(long companyId) throws UmbrellaException;
|
||||
|
||||
HashMap<Integer, Type> listTypes() throws UmbrellaException;
|
||||
|
||||
@@ -55,6 +60,4 @@ public interface DocumentDb {
|
||||
void step(CompanySettings settings);
|
||||
|
||||
Pair<Integer> switchPositions(long docId, Pair<Integer> longPair) throws UmbrellaException;
|
||||
|
||||
Collection<Template> getCompanyTemplates(long l) throws UmbrellaException;
|
||||
}
|
||||
|
||||
@@ -25,10 +25,7 @@ import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.time.Instant;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
public class SqliteDb implements DocumentDb{
|
||||
private static final System.Logger LOG = System.getLogger(SqliteDb.class.getSimpleName());
|
||||
@@ -319,6 +316,24 @@ CREATE TABLE IF NOT EXISTS {0} ( {1} VARCHAR(255) PRIMARY KEY, {2} VARCHAR(255)
|
||||
var version = createTables();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Long, Map<Long, String>> docReferencedByTimes(Set<Long> timeIds) throws UmbrellaException {
|
||||
try {
|
||||
var map = new HashMap<Long, Map<Long, String>>(); // Map ( timeId → Map ( docId → name ))
|
||||
var rs = select(FIELD_TIME_ID,FIELD_DOCUMENT_ID,NUMBER).from(TABLE_POSITIONS).leftJoin(FIELD_DOCUMENT_ID,TABLE_DOCUMENTS,ID).where(FIELD_TIME_ID,in(timeIds.toArray())).exec(db);
|
||||
while (rs.next()) {
|
||||
var timeId = rs.getLong(FIELD_TIME_ID);
|
||||
var docId = rs.getLong(FIELD_DOCUMENT_ID);
|
||||
var number = rs.getString(NUMBER);
|
||||
map.computeIfAbsent(timeId,k -> new HashMap<>()).put(docId,number);
|
||||
}
|
||||
rs.close();
|
||||
return map;
|
||||
} catch (SQLException e) {
|
||||
throw databaseException("Failed to list Documents for list of times");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Long, Document> listDocs(long companyId) throws UmbrellaException {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user