mirror of
https://github.com/sismics/docs.git
synced 2025-12-15 02:36:24 +00:00
#79: POST /theme/color to change the main color
This commit is contained in:
@@ -10,4 +10,8 @@ public enum ConfigType {
|
||||
* Lucene directory storage type.
|
||||
*/
|
||||
LUCENE_DIRECTORY_STORAGE,
|
||||
/**
|
||||
* Theme configuration.
|
||||
*/
|
||||
THEME
|
||||
}
|
||||
|
||||
@@ -33,4 +33,23 @@ public class ConfigDao {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a configuration parameter.
|
||||
*
|
||||
* @param id Configuration parameter ID
|
||||
* @param value Configuration parameter value
|
||||
*/
|
||||
public void update(ConfigType id, String value) {
|
||||
EntityManager em = ThreadLocalContext.get().getEntityManager();
|
||||
Config config = getById(id);
|
||||
if (config == null) {
|
||||
config = new Config();
|
||||
config.setId(id);
|
||||
config.setValue(value);
|
||||
em.persist(config);
|
||||
} else {
|
||||
config.setValue(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,9 +21,7 @@ public class ContributorDao {
|
||||
* Creates a new contributor.
|
||||
*
|
||||
* @param contributor Contributor
|
||||
* @param userId User ID
|
||||
* @return New ID
|
||||
* @throws Exception
|
||||
*/
|
||||
public String create(Contributor contributor) {
|
||||
// Create the UUID
|
||||
@@ -72,7 +70,7 @@ public class ContributorDao {
|
||||
int i = 0;
|
||||
ContributorDto contributorDto = new ContributorDto();
|
||||
contributorDto.setUsername((String) o[i++]);
|
||||
contributorDto.setEmail((String) o[i++]);
|
||||
contributorDto.setEmail((String) o[i]);
|
||||
contributorDtoList.add(contributorDto);
|
||||
}
|
||||
return contributorDtoList;
|
||||
|
||||
@@ -25,7 +25,6 @@ public class FileDao {
|
||||
* @param file File
|
||||
* @param userId User ID
|
||||
* @return New ID
|
||||
* @throws Exception
|
||||
*/
|
||||
public String create(File file, String userId) {
|
||||
// Create the UUID
|
||||
@@ -169,7 +168,7 @@ public class FileDao {
|
||||
/**
|
||||
* Get files by document ID or all orphan files of an user.
|
||||
*
|
||||
* @parma userId User ID
|
||||
* @param userId User ID
|
||||
* @param documentId Document ID
|
||||
* @return List of files
|
||||
*/
|
||||
|
||||
@@ -108,7 +108,7 @@ public class TagDao {
|
||||
sb.append(" where dt.DOT_IDDOCUMENT_C = :documentId and t.TAG_DELETEDATE_D is null ");
|
||||
sb.append(" and t.TAG_IDUSER_C = :userId and dt.DOT_DELETEDATE_D is null ");
|
||||
sb.append(" order by t.TAG_NAME_C ");
|
||||
|
||||
|
||||
// Perform the query
|
||||
Query q = em.createNativeQuery(sb.toString());
|
||||
q.setParameter("documentId", documentId);
|
||||
@@ -116,14 +116,14 @@ public class TagDao {
|
||||
List<Object[]> l = q.getResultList();
|
||||
|
||||
// Assemble results
|
||||
List<TagDto> tagDtoList = new ArrayList<TagDto>();
|
||||
List<TagDto> tagDtoList = new ArrayList<>();
|
||||
for (Object[] o : l) {
|
||||
int i = 0;
|
||||
TagDto tagDto = new TagDto();
|
||||
tagDto.setId((String) o[i++]);
|
||||
tagDto.setName((String) o[i++]);
|
||||
tagDto.setColor((String) o[i++]);
|
||||
tagDto.setParentId((String) o[i++]);
|
||||
tagDto.setParentId((String) o[i]);
|
||||
tagDtoList.add(tagDto);
|
||||
}
|
||||
return tagDtoList;
|
||||
@@ -132,7 +132,7 @@ public class TagDao {
|
||||
/**
|
||||
* Returns stats on tags.
|
||||
*
|
||||
* @param documentId Document ID
|
||||
* @param userId User ID
|
||||
* @return Stats by tag
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -145,14 +145,14 @@ public class TagDao {
|
||||
sb.append(" where t.TAG_IDUSER_C = :userId and t.TAG_DELETEDATE_D is null ");
|
||||
sb.append(" group by t.TAG_ID_C ");
|
||||
sb.append(" order by t.TAG_NAME_C ");
|
||||
|
||||
|
||||
// Perform the query
|
||||
Query q = em.createNativeQuery(sb.toString());
|
||||
q.setParameter("userId", userId);
|
||||
List<Object[]> l = q.getResultList();
|
||||
|
||||
// Assemble results
|
||||
List<TagStatDto> tagStatDtoList = new ArrayList<TagStatDto>();
|
||||
List<TagStatDto> tagStatDtoList = new ArrayList<>();
|
||||
for (Object[] o : l) {
|
||||
int i = 0;
|
||||
TagStatDto tagDto = new TagStatDto();
|
||||
@@ -160,7 +160,7 @@ public class TagDao {
|
||||
tagDto.setName((String) o[i++]);
|
||||
tagDto.setColor((String) o[i++]);
|
||||
tagDto.setParentId((String) o[i++]);
|
||||
tagDto.setCount(((Number) o[i++]).intValue());
|
||||
tagDto.setCount(((Number) o[i]).intValue());
|
||||
tagStatDtoList.add(tagDto);
|
||||
}
|
||||
return tagStatDtoList;
|
||||
@@ -172,7 +172,6 @@ public class TagDao {
|
||||
* @param tag Tag
|
||||
* @param userId User ID
|
||||
* @return New ID
|
||||
* @throws Exception
|
||||
*/
|
||||
public String create(Tag tag, String userId) {
|
||||
// Create the UUID
|
||||
|
||||
@@ -11,7 +11,7 @@ public class ThreadLocalContext {
|
||||
/**
|
||||
* ThreadLocal to store the context.
|
||||
*/
|
||||
public static final ThreadLocal<ThreadLocalContext> threadLocalContext = new ThreadLocal<ThreadLocalContext>();
|
||||
private static final ThreadLocal<ThreadLocalContext> threadLocalContext = new ThreadLocal<>();
|
||||
|
||||
/**
|
||||
* Entity manager.
|
||||
@@ -46,15 +46,6 @@ public class ThreadLocalContext {
|
||||
threadLocalContext.set(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true only if the entity manager is defined.
|
||||
*
|
||||
* @return Condition
|
||||
*/
|
||||
public boolean isInTransactionalContext() {
|
||||
return entityManager != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter of entityManager.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user