Search in sources :

Example 16 with IllegalBehaviorStateException

use of org.dbflute.exception.IllegalBehaviorStateException in project fess by codelibs.

the class BsWebConfigToRoleBhv method createEntity.

@Override
protected <RESULT extends WebConfigToRole> RESULT createEntity(Map<String, Object> source, Class<? extends RESULT> entityType) {
    try {
        final RESULT result = entityType.newInstance();
        result.setRoleTypeId(DfTypeUtil.toString(source.get("roleTypeId")));
        result.setWebConfigId(DfTypeUtil.toString(source.get("webConfigId")));
        return updateEntity(source, result);
    } catch (InstantiationException | IllegalAccessException e) {
        final String msg = "Cannot create a new instance: " + entityType.getName();
        throw new IllegalBehaviorStateException(msg, e);
    }
}
Also used : IllegalBehaviorStateException(org.dbflute.exception.IllegalBehaviorStateException)

Example 17 with IllegalBehaviorStateException

use of org.dbflute.exception.IllegalBehaviorStateException in project fess by codelibs.

the class EsAbstractBehavior method delegateQueryDelete.

@Override
protected int delegateQueryDelete(final ConditionBean cb, final DeleteOption<? extends ConditionBean> option) {
    SearchResponse response = null;
    int count = 0;
    while (true) {
        if (response == null) {
            final SearchRequestBuilder builder = client.prepareSearch(asEsIndex()).setTypes(asEsIndexType()).setScroll(scrollForDelete).setSize(sizeForDelete);
            final EsAbstractConditionBean esCb = (EsAbstractConditionBean) cb;
            if (esCb.getPreference() != null) {
                esCb.setPreference(esCb.getPreference());
            }
            esCb.request().build(builder);
            response = esCb.build(builder).execute().actionGet(scrollSearchTimeout);
        } else {
            final String scrollId = response.getScrollId();
            response = client.prepareSearchScroll(scrollId).setScroll(scrollForDelete).execute().actionGet(scrollSearchTimeout);
        }
        final SearchHits searchHits = response.getHits();
        final SearchHit[] hits = searchHits.getHits();
        if (hits.length == 0) {
            break;
        }
        final BulkRequestBuilder bulkRequest = client.prepareBulk();
        for (final SearchHit hit : hits) {
            bulkRequest.add(client.prepareDelete(asEsIndex(), asEsIndexType(), hit.getId()));
        }
        count += hits.length;
        final BulkResponse bulkResponse = bulkRequest.execute().actionGet(bulkTimeout);
        if (bulkResponse.hasFailures()) {
            throw new IllegalBehaviorStateException(bulkResponse.buildFailureMessage());
        }
    }
    return count;
}
Also used : SearchRequestBuilder(org.elasticsearch.action.search.SearchRequestBuilder) SearchHit(org.elasticsearch.search.SearchHit) IllegalBehaviorStateException(org.dbflute.exception.IllegalBehaviorStateException) BulkResponse(org.elasticsearch.action.bulk.BulkResponse) SearchHits(org.elasticsearch.search.SearchHits) BulkRequestBuilder(org.elasticsearch.action.bulk.BulkRequestBuilder) SearchResponse(org.elasticsearch.action.search.SearchResponse)

Example 18 with IllegalBehaviorStateException

use of org.dbflute.exception.IllegalBehaviorStateException in project fess by codelibs.

the class BsSearchLogBhv method createEntity.

@Override
protected <RESULT extends SearchLog> RESULT createEntity(Map<String, Object> source, Class<? extends RESULT> entityType) {
    try {
        final RESULT result = entityType.newInstance();
        result.setAccessType(DfTypeUtil.toString(source.get("accessType")));
        result.setUser(DfTypeUtil.toString(source.get("user")));
        result.setRoles(toStringArray(source.get("roles")));
        result.setQueryId(DfTypeUtil.toString(source.get("queryId")));
        result.setClientIp(DfTypeUtil.toString(source.get("clientIp")));
        result.setHitCount(DfTypeUtil.toLong(source.get("hitCount")));
        result.setQueryOffset(DfTypeUtil.toInteger(source.get("queryOffset")));
        result.setQueryPageSize(DfTypeUtil.toInteger(source.get("queryPageSize")));
        result.setReferer(DfTypeUtil.toString(source.get("referer")));
        result.setRequestedAt(toLocalDateTime(source.get("requestedAt")));
        result.setResponseTime(DfTypeUtil.toLong(source.get("responseTime")));
        result.setQueryTime(DfTypeUtil.toLong(source.get("queryTime")));
        result.setSearchWord(DfTypeUtil.toString(source.get("searchWord")));
        result.setUserAgent(DfTypeUtil.toString(source.get("userAgent")));
        result.setUserInfoId(DfTypeUtil.toString(source.get("userInfoId")));
        result.setUserSessionId(DfTypeUtil.toString(source.get("userSessionId")));
        result.setLanguages(DfTypeUtil.toString(source.get("languages")));
        return updateEntity(source, result);
    } catch (InstantiationException | IllegalAccessException e) {
        final String msg = "Cannot create a new instance: " + entityType.getName();
        throw new IllegalBehaviorStateException(msg, e);
    }
}
Also used : IllegalBehaviorStateException(org.dbflute.exception.IllegalBehaviorStateException)

Example 19 with IllegalBehaviorStateException

use of org.dbflute.exception.IllegalBehaviorStateException in project fess by codelibs.

the class BsClickLogBhv method createEntity.

@Override
protected <RESULT extends ClickLog> RESULT createEntity(Map<String, Object> source, Class<? extends RESULT> entityType) {
    try {
        final RESULT result = entityType.newInstance();
        result.setQueryRequestedAt(toLocalDateTime(source.get("queryRequestedAt")));
        result.setRequestedAt(toLocalDateTime(source.get("requestedAt")));
        result.setQueryId(DfTypeUtil.toString(source.get("queryId")));
        result.setDocId(DfTypeUtil.toString(source.get("docId")));
        result.setUserSessionId(DfTypeUtil.toString(source.get("userSessionId")));
        result.setUrl(DfTypeUtil.toString(source.get("url")));
        result.setOrder(DfTypeUtil.toInteger(source.get("order")));
        return updateEntity(source, result);
    } catch (InstantiationException | IllegalAccessException e) {
        final String msg = "Cannot create a new instance: " + entityType.getName();
        throw new IllegalBehaviorStateException(msg, e);
    }
}
Also used : IllegalBehaviorStateException(org.dbflute.exception.IllegalBehaviorStateException)

Example 20 with IllegalBehaviorStateException

use of org.dbflute.exception.IllegalBehaviorStateException in project fess by codelibs.

the class BsSearchFieldLogBhv method createEntity.

@Override
protected <RESULT extends SearchFieldLog> RESULT createEntity(Map<String, Object> source, Class<? extends RESULT> entityType) {
    try {
        final RESULT result = entityType.newInstance();
        result.setName(DfTypeUtil.toString(source.get("name")));
        result.setSearchLogId(DfTypeUtil.toString(source.get("searchLogId")));
        result.setValue(DfTypeUtil.toString(source.get("value")));
        return updateEntity(source, result);
    } catch (InstantiationException | IllegalAccessException e) {
        final String msg = "Cannot create a new instance: " + entityType.getName();
        throw new IllegalBehaviorStateException(msg, e);
    }
}
Also used : IllegalBehaviorStateException(org.dbflute.exception.IllegalBehaviorStateException)

Aggregations

IllegalBehaviorStateException (org.dbflute.exception.IllegalBehaviorStateException)44 BulkRequestBuilder (org.elasticsearch.action.bulk.BulkRequestBuilder)4 BulkResponse (org.elasticsearch.action.bulk.BulkResponse)4 SearchResponse (org.elasticsearch.action.search.SearchResponse)4 SearchHit (org.elasticsearch.search.SearchHit)4 SearchHits (org.elasticsearch.search.SearchHits)4 Map (java.util.Map)3 Collectors (java.util.stream.Collectors)3 Pair (org.codelibs.core.misc.Pair)3 DfTypeUtil (org.dbflute.util.DfTypeUtil)3 SearchRequestBuilder (org.elasticsearch.action.search.SearchRequestBuilder)3 BsGroupBhv (org.codelibs.fess.es.user.bsbhv.BsGroupBhv)1 BsRoleBhv (org.codelibs.fess.es.user.bsbhv.BsRoleBhv)1 BsUserBhv (org.codelibs.fess.es.user.bsbhv.BsUserBhv)1 Group (org.codelibs.fess.es.user.exentity.Group)1 Role (org.codelibs.fess.es.user.exentity.Role)1 User (org.codelibs.fess.es.user.exentity.User)1 FessConfig (org.codelibs.fess.mylasta.direction.FessConfig)1 MultiSearchResponse (org.elasticsearch.action.search.MultiSearchResponse)1