Search in sources :

Example 1 with CharMappingItem

use of org.codelibs.fess.dict.mapping.CharMappingItem in project fess by codelibs.

the class ApiAdminDictMappingAction method put$setting.

// PUT /api/admin/dict/mapping/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 CharMappingItem entity = createCharMappingItem(this, body, () -> {
        throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToCreateInstance(GLOBAL));
        return null;
    }).orElseGet(() -> {
        throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToCreateInstance(GLOBAL));
        return null;
    });
    charMappingService.store(body.dictId, entity);
    return asJson(new ApiResult.ApiUpdateResponse().id(String.valueOf(entity.getId())).created(true).status(ApiResult.Status.OK).result());
}
Also used : CharMappingItem(org.codelibs.fess.dict.mapping.CharMappingItem) AdminDictMappingAction.createCharMappingItem(org.codelibs.fess.app.web.admin.dict.mapping.AdminDictMappingAction.createCharMappingItem) UploadForm(org.codelibs.fess.app.web.admin.dict.mapping.UploadForm) FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) Resource(javax.annotation.Resource) IOException(java.io.IOException) CharMappingPager(org.codelibs.fess.app.pager.CharMappingPager) JsonResponse(org.lastaflute.web.response.JsonResponse) Collectors(java.util.stream.Collectors) ApiResult(org.codelibs.fess.app.web.api.ApiResult) CharMappingItem(org.codelibs.fess.dict.mapping.CharMappingItem) File(java.io.File) CharMappingFile(org.codelibs.fess.dict.mapping.CharMappingFile) StreamResponse(org.lastaflute.web.response.StreamResponse) CrudMode(org.codelibs.fess.app.web.CrudMode) CharMappingService(org.codelibs.fess.app.service.CharMappingService) AdminDictMappingAction.createCharMappingItem(org.codelibs.fess.app.web.admin.dict.mapping.AdminDictMappingAction.createCharMappingItem) Execute(org.lastaflute.web.Execute) InputStream(java.io.InputStream) ApiResult(org.codelibs.fess.app.web.api.ApiResult) Execute(org.lastaflute.web.Execute)

Example 2 with CharMappingItem

use of org.codelibs.fess.dict.mapping.CharMappingItem in project fess by codelibs.

the class ApiAdminDictMappingAction method post$setting.

// POST /api/admin/dict/mapping/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 CharMappingItem entity = createCharMappingItem(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;
    });
    charMappingService.store(body.dictId, entity);
    return asJson(new ApiResult.ApiUpdateResponse().id(String.valueOf(entity.getId())).created(false).status(ApiResult.Status.OK).result());
}
Also used : CharMappingItem(org.codelibs.fess.dict.mapping.CharMappingItem) AdminDictMappingAction.createCharMappingItem(org.codelibs.fess.app.web.admin.dict.mapping.AdminDictMappingAction.createCharMappingItem) UploadForm(org.codelibs.fess.app.web.admin.dict.mapping.UploadForm) FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) Resource(javax.annotation.Resource) IOException(java.io.IOException) CharMappingPager(org.codelibs.fess.app.pager.CharMappingPager) JsonResponse(org.lastaflute.web.response.JsonResponse) Collectors(java.util.stream.Collectors) ApiResult(org.codelibs.fess.app.web.api.ApiResult) CharMappingItem(org.codelibs.fess.dict.mapping.CharMappingItem) File(java.io.File) CharMappingFile(org.codelibs.fess.dict.mapping.CharMappingFile) StreamResponse(org.lastaflute.web.response.StreamResponse) CrudMode(org.codelibs.fess.app.web.CrudMode) CharMappingService(org.codelibs.fess.app.service.CharMappingService) AdminDictMappingAction.createCharMappingItem(org.codelibs.fess.app.web.admin.dict.mapping.AdminDictMappingAction.createCharMappingItem) Execute(org.lastaflute.web.Execute) InputStream(java.io.InputStream) ApiResult(org.codelibs.fess.app.web.api.ApiResult) 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 CharMappingPager (org.codelibs.fess.app.pager.CharMappingPager)2 CharMappingService (org.codelibs.fess.app.service.CharMappingService)2 CrudMode (org.codelibs.fess.app.web.CrudMode)2 AdminDictMappingAction.createCharMappingItem (org.codelibs.fess.app.web.admin.dict.mapping.AdminDictMappingAction.createCharMappingItem)2 UploadForm (org.codelibs.fess.app.web.admin.dict.mapping.UploadForm)2 ApiResult (org.codelibs.fess.app.web.api.ApiResult)2 FessApiAdminAction (org.codelibs.fess.app.web.api.admin.FessApiAdminAction)2 CharMappingFile (org.codelibs.fess.dict.mapping.CharMappingFile)2 CharMappingItem (org.codelibs.fess.dict.mapping.CharMappingItem)2 Execute (org.lastaflute.web.Execute)2 JsonResponse (org.lastaflute.web.response.JsonResponse)2 StreamResponse (org.lastaflute.web.response.StreamResponse)2