[WIP] #592 Edit
This commit is contained in:
parent
20fabe3e78
commit
3a933ac663
4 changed files with 49 additions and 2 deletions
|
@ -279,7 +279,11 @@ public class AdminSearchlistAction extends FessAdminAction {
|
|||
verifyToken(() -> asEditHtml());
|
||||
getDoc(form).ifPresent(entity -> {
|
||||
try {
|
||||
// TODO save
|
||||
for (Map.Entry<String, Object> entry : form.doc.entrySet()) {
|
||||
entity.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
// TODO store does not work
|
||||
fessEsClient.store(fessConfig.getIndexDocumentUpdateIndex(), fessConfig.getIndexDocumentType(), entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
|
||||
} catch (final Exception e) {
|
||||
logger.error("Failed to update " + entity, e);
|
||||
|
@ -304,7 +308,28 @@ public class AdminSearchlistAction extends FessAdminAction {
|
|||
}
|
||||
|
||||
protected OptionalEntity<Map<String, Object>> getDoc(final CreateForm form) {
|
||||
// TODO
|
||||
switch (form.crudMode) {
|
||||
case CrudMode.CREATE:
|
||||
// TODO
|
||||
return OptionalEntity.empty();
|
||||
case CrudMode.EDIT:
|
||||
if (form instanceof EditForm) {
|
||||
final String docId = ((EditForm) form).id;
|
||||
if (processHelper.isProcessRunning()) {
|
||||
break;
|
||||
}
|
||||
try {
|
||||
final QueryBuilder query = QueryBuilders.termQuery(fessConfig.getIndexFieldDocId(), docId);
|
||||
return fessEsClient.getDocumentByQuery(fessConfig.getIndexDocumentUpdateIndex(), fessConfig.getIndexDocumentType(),
|
||||
query);
|
||||
} catch (final Exception e) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return OptionalEntity.empty();
|
||||
}
|
||||
|
||||
|
|
|
@ -674,6 +674,17 @@ public class FessEsClient implements Client {
|
|||
});
|
||||
}
|
||||
|
||||
public OptionalEntity<Map<String, Object>> getDocumentByQuery(final String index, final String type, final QueryBuilder queryBuilder) {
|
||||
|
||||
final FessConfig fessConfig = ComponentUtil.getFessConfig();
|
||||
SearchResponse response =
|
||||
client.prepareSearch(index).setTypes(type).setSize(sizeForDelete).setQuery(queryBuilder)
|
||||
.setPreference(Constants.SEARCH_PREFERENCE_PRIMARY).execute()
|
||||
.actionGet(fessConfig.getIndexScrollSearchTimeoutTimeout());
|
||||
return OptionalEntity.of(response.getHits().getAt(0).getSource());
|
||||
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> getDocumentList(final String index, final String type,
|
||||
final SearchCondition<SearchRequestBuilder> condition) {
|
||||
return getDocumentList(
|
||||
|
|
|
@ -94,6 +94,16 @@
|
|||
<i class="fa fa-trash"></i>
|
||||
<la:message key="labels.search_list_button_delete" />
|
||||
</button>
|
||||
<la:form action="/admin/searchlist/edit" styleClass="form-inline">
|
||||
<input type="hidden" name="id" value="${doc.doc_id}" />
|
||||
<input type="hidden" name="crudMode" value="4" /> <!-- FIXME -->
|
||||
<input type="hidden" name="versionNo" value="1" /> <!-- FIXME -->
|
||||
<button type="submit" class="btn btn-warning" name="update"
|
||||
value="<la:message key="labels.crud_button_update" />">
|
||||
<i class="fa fa-pencil"></i>
|
||||
<la:message key="labels.crud_button_update" />
|
||||
</button>
|
||||
</la:form>
|
||||
</li>
|
||||
</c:forEach>
|
||||
</ol>
|
||||
|
|
|
@ -56,6 +56,7 @@
|
|||
</div>
|
||||
<!-- /.box-body -->
|
||||
<div class="box-footer">
|
||||
<input type="hidden" name="versionNo" value="1" /> <!-- FIXME -->
|
||||
<jsp:include page="/WEB-INF/view/common/admin/crud/buttons.jsp"></jsp:include>
|
||||
</div>
|
||||
<!-- /.box-footer -->
|
||||
|
|
Loading…
Add table
Reference in a new issue