Search in sources :

Example 1 with SynonymItem

use of org.codelibs.fess.dict.synonym.SynonymItem in project fess by codelibs.

the class ApiAdminDictSynonymAction method post$setting.

// POST /api/admin/dict/synonym/setting/{dictId}
@Execute
public JsonResponse<ApiResult> post$setting(final String dictId, final EditBody body) {
    body.dictId = dictId;
    validateApi(body, messages -> {
    });
    body.crudMode = CrudMode.EDIT;
    final SynonymItem entity = createSynonymItem(this, body, () -> {
        throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToUpdateCrudTable(GLOBAL, String.valueOf(body.id)));
        return null;
    }).orElseGet(() -> {
        throwValidationErrorApi(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, String.valueOf(body.id)));
        return null;
    });
    synonymService.store(body.dictId, entity);
    return asJson(new ApiResult.ApiUpdateResponse().id(String.valueOf(entity.getId())).created(false).status(ApiResult.Status.OK).result());
}
Also used : FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) Resource(javax.annotation.Resource) SynonymItem(org.codelibs.fess.dict.synonym.SynonymItem) IOException(java.io.IOException) JsonResponse(org.lastaflute.web.response.JsonResponse) SynonymFile(org.codelibs.fess.dict.synonym.SynonymFile) AdminDictSynonymAction.createSynonymItem(org.codelibs.fess.app.web.admin.dict.synonym.AdminDictSynonymAction.createSynonymItem) Collectors(java.util.stream.Collectors) ApiResult(org.codelibs.fess.app.web.api.ApiResult) File(java.io.File) UploadForm(org.codelibs.fess.app.web.admin.dict.synonym.UploadForm) SynonymPager(org.codelibs.fess.app.pager.SynonymPager) StreamResponse(org.lastaflute.web.response.StreamResponse) CrudMode(org.codelibs.fess.app.web.CrudMode) Execute(org.lastaflute.web.Execute) SynonymService(org.codelibs.fess.app.service.SynonymService) InputStream(java.io.InputStream) ApiResult(org.codelibs.fess.app.web.api.ApiResult) SynonymItem(org.codelibs.fess.dict.synonym.SynonymItem) AdminDictSynonymAction.createSynonymItem(org.codelibs.fess.app.web.admin.dict.synonym.AdminDictSynonymAction.createSynonymItem) Execute(org.lastaflute.web.Execute)

Example 2 with SynonymItem

use of org.codelibs.fess.dict.synonym.SynonymItem in project fess by codelibs.

the class ApiAdminDictSynonymAction method put$setting.

// PUT /api/admin/dict/synonym/setting/{dictId}
@Execute
public JsonResponse<ApiResult> put$setting(final String dictId, final CreateBody body) {
    body.dictId = dictId;
    validateApi(body, messages -> {
    });
    body.crudMode = CrudMode.CREATE;
    final SynonymItem entity = createSynonymItem(this, body, () -> {
        throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToCreateInstance(GLOBAL));
        return null;
    }).orElseGet(() -> {
        throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToCreateInstance(GLOBAL));
        return null;
    });
    synonymService.store(body.dictId, entity);
    return asJson(new ApiResult.ApiUpdateResponse().id(String.valueOf(entity.getId())).created(true).status(ApiResult.Status.OK).result());
}
Also used : FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) Resource(javax.annotation.Resource) SynonymItem(org.codelibs.fess.dict.synonym.SynonymItem) IOException(java.io.IOException) JsonResponse(org.lastaflute.web.response.JsonResponse) SynonymFile(org.codelibs.fess.dict.synonym.SynonymFile) AdminDictSynonymAction.createSynonymItem(org.codelibs.fess.app.web.admin.dict.synonym.AdminDictSynonymAction.createSynonymItem) Collectors(java.util.stream.Collectors) ApiResult(org.codelibs.fess.app.web.api.ApiResult) File(java.io.File) UploadForm(org.codelibs.fess.app.web.admin.dict.synonym.UploadForm) SynonymPager(org.codelibs.fess.app.pager.SynonymPager) StreamResponse(org.lastaflute.web.response.StreamResponse) CrudMode(org.codelibs.fess.app.web.CrudMode) Execute(org.lastaflute.web.Execute) SynonymService(org.codelibs.fess.app.service.SynonymService) InputStream(java.io.InputStream) ApiResult(org.codelibs.fess.app.web.api.ApiResult) SynonymItem(org.codelibs.fess.dict.synonym.SynonymItem) AdminDictSynonymAction.createSynonymItem(org.codelibs.fess.app.web.admin.dict.synonym.AdminDictSynonymAction.createSynonymItem) Execute(org.lastaflute.web.Execute)

Aggregations

File (java.io.File)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 Collectors (java.util.stream.Collectors)2 Resource (javax.annotation.Resource)2 SynonymPager (org.codelibs.fess.app.pager.SynonymPager)2 SynonymService (org.codelibs.fess.app.service.SynonymService)2 CrudMode (org.codelibs.fess.app.web.CrudMode)2 AdminDictSynonymAction.createSynonymItem (org.codelibs.fess.app.web.admin.dict.synonym.AdminDictSynonymAction.createSynonymItem)2 UploadForm (org.codelibs.fess.app.web.admin.dict.synonym.UploadForm)2 ApiResult (org.codelibs.fess.app.web.api.ApiResult)2 FessApiAdminAction (org.codelibs.fess.app.web.api.admin.FessApiAdminAction)2 SynonymFile (org.codelibs.fess.dict.synonym.SynonymFile)2 SynonymItem (org.codelibs.fess.dict.synonym.SynonymItem)2 Execute (org.lastaflute.web.Execute)2 JsonResponse (org.lastaflute.web.response.JsonResponse)2 StreamResponse (org.lastaflute.web.response.StreamResponse)2