Search in sources :

Example 1 with BoostDocumentRule

use of org.codelibs.fess.es.config.exentity.BoostDocumentRule in project fess by codelibs.

the class ApiAdminBoostdocAction method settings.

// ===================================================================================
// Search Execute
// ==============
// GET /api/admin/boostdoc
// POST /api/admin/boostdoc
@Execute
public JsonResponse<ApiResult> settings(final SearchBody body) {
    validateApi(body, messages -> {
    });
    final BoostDocPager pager = copyBeanToNewBean(body, BoostDocPager.class);
    final List<BoostDocumentRule> list = boostDocumentRuleService.getBoostDocumentRuleList(pager);
    return asJson(new ApiConfigsResponse<EditBody>().settings(list.stream().map(this::createEditBody).collect(Collectors.toList())).total(pager.getAllRecordCount()).status(Status.OK).result());
}
Also used : BoostDocumentRule(org.codelibs.fess.es.config.exentity.BoostDocumentRule) AdminBoostdocAction.getBoostDocumentRule(org.codelibs.fess.app.web.admin.boostdoc.AdminBoostdocAction.getBoostDocumentRule) BoostDocPager(org.codelibs.fess.app.pager.BoostDocPager) Execute(org.lastaflute.web.Execute)

Example 2 with BoostDocumentRule

use of org.codelibs.fess.es.config.exentity.BoostDocumentRule in project fess by codelibs.

the class ApiAdminBoostdocAction method put$setting.

// PUT /api/admin/boostdoc/setting
@Execute
public JsonResponse<ApiResult> put$setting(final CreateBody body) {
    validateApi(body, messages -> {
    });
    body.crudMode = CrudMode.CREATE;
    final BoostDocumentRule boostDoc = getBoostDocumentRule(body).map(entity -> {
        try {
            boostDocumentRuleService.store(entity);
        } catch (final Exception e) {
            throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL, buildThrowableMessage(e)));
        }
        return entity;
    }).orElseGet(() -> {
        throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToCreateInstance(GLOBAL));
        return null;
    });
    return asJson(new ApiUpdateResponse().id(boostDoc.getId()).created(true).status(Status.OK).result());
}
Also used : FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) Resource(javax.annotation.Resource) BoostDocumentRule(org.codelibs.fess.es.config.exentity.BoostDocumentRule) ApiConfigResponse(org.codelibs.fess.app.web.api.ApiResult.ApiConfigResponse) JsonResponse(org.lastaflute.web.response.JsonResponse) AdminBoostdocAction.getBoostDocumentRule(org.codelibs.fess.app.web.admin.boostdoc.AdminBoostdocAction.getBoostDocumentRule) Collectors(java.util.stream.Collectors) ApiResult(org.codelibs.fess.app.web.api.ApiResult) ApiUpdateResponse(org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse) Status(org.codelibs.fess.app.web.api.ApiResult.Status) List(java.util.List) CrudMode(org.codelibs.fess.app.web.CrudMode) BoostDocumentRuleService(org.codelibs.fess.app.service.BoostDocumentRuleService) Execute(org.lastaflute.web.Execute) ApiResponse(org.codelibs.fess.app.web.api.ApiResult.ApiResponse) CopyOptions(org.codelibs.core.beans.util.CopyOptions) BoostDocPager(org.codelibs.fess.app.pager.BoostDocPager) ApiConfigsResponse(org.codelibs.fess.app.web.api.ApiResult.ApiConfigsResponse) BoostDocumentRule(org.codelibs.fess.es.config.exentity.BoostDocumentRule) AdminBoostdocAction.getBoostDocumentRule(org.codelibs.fess.app.web.admin.boostdoc.AdminBoostdocAction.getBoostDocumentRule) ApiUpdateResponse(org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse) Execute(org.lastaflute.web.Execute)

Example 3 with BoostDocumentRule

use of org.codelibs.fess.es.config.exentity.BoostDocumentRule in project fess by codelibs.

the class ApiAdminBoostdocAction method post$setting.

// POST /api/admin/boostdoc/setting
@Execute
public JsonResponse<ApiResult> post$setting(final EditBody body) {
    validateApi(body, messages -> {
    });
    body.crudMode = CrudMode.EDIT;
    final BoostDocumentRule boostDoc = getBoostDocumentRule(body).map(entity -> {
        try {
            boostDocumentRuleService.store(entity);
        } catch (final Exception e) {
            throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToUpdateCrudTable(GLOBAL, buildThrowableMessage(e)));
        }
        return entity;
    }).orElseGet(() -> {
        throwValidationErrorApi(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, body.id));
        return null;
    });
    return asJson(new ApiUpdateResponse().id(boostDoc.getId()).created(false).status(Status.OK).result());
}
Also used : FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) Resource(javax.annotation.Resource) BoostDocumentRule(org.codelibs.fess.es.config.exentity.BoostDocumentRule) ApiConfigResponse(org.codelibs.fess.app.web.api.ApiResult.ApiConfigResponse) JsonResponse(org.lastaflute.web.response.JsonResponse) AdminBoostdocAction.getBoostDocumentRule(org.codelibs.fess.app.web.admin.boostdoc.AdminBoostdocAction.getBoostDocumentRule) Collectors(java.util.stream.Collectors) ApiResult(org.codelibs.fess.app.web.api.ApiResult) ApiUpdateResponse(org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse) Status(org.codelibs.fess.app.web.api.ApiResult.Status) List(java.util.List) CrudMode(org.codelibs.fess.app.web.CrudMode) BoostDocumentRuleService(org.codelibs.fess.app.service.BoostDocumentRuleService) Execute(org.lastaflute.web.Execute) ApiResponse(org.codelibs.fess.app.web.api.ApiResult.ApiResponse) CopyOptions(org.codelibs.core.beans.util.CopyOptions) BoostDocPager(org.codelibs.fess.app.pager.BoostDocPager) ApiConfigsResponse(org.codelibs.fess.app.web.api.ApiResult.ApiConfigsResponse) BoostDocumentRule(org.codelibs.fess.es.config.exentity.BoostDocumentRule) AdminBoostdocAction.getBoostDocumentRule(org.codelibs.fess.app.web.admin.boostdoc.AdminBoostdocAction.getBoostDocumentRule) ApiUpdateResponse(org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse) Execute(org.lastaflute.web.Execute)

Aggregations

BoostDocPager (org.codelibs.fess.app.pager.BoostDocPager)3 AdminBoostdocAction.getBoostDocumentRule (org.codelibs.fess.app.web.admin.boostdoc.AdminBoostdocAction.getBoostDocumentRule)3 BoostDocumentRule (org.codelibs.fess.es.config.exentity.BoostDocumentRule)3 Execute (org.lastaflute.web.Execute)3 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 Resource (javax.annotation.Resource)2 CopyOptions (org.codelibs.core.beans.util.CopyOptions)2 BoostDocumentRuleService (org.codelibs.fess.app.service.BoostDocumentRuleService)2 CrudMode (org.codelibs.fess.app.web.CrudMode)2 ApiResult (org.codelibs.fess.app.web.api.ApiResult)2 ApiConfigResponse (org.codelibs.fess.app.web.api.ApiResult.ApiConfigResponse)2 ApiConfigsResponse (org.codelibs.fess.app.web.api.ApiResult.ApiConfigsResponse)2 ApiResponse (org.codelibs.fess.app.web.api.ApiResult.ApiResponse)2 ApiUpdateResponse (org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse)2 Status (org.codelibs.fess.app.web.api.ApiResult.Status)2 FessApiAdminAction (org.codelibs.fess.app.web.api.admin.FessApiAdminAction)2 JsonResponse (org.lastaflute.web.response.JsonResponse)2