diff --git a/src/main/config/es/fess_config.json b/src/main/config/es/fess_config.json index 044c50de9..dd87101d5 100644 --- a/src/main/config/es/fess_config.json +++ b/src/main/config/es/fess_config.json @@ -962,6 +962,32 @@ "index" : "not_analyzed" } } + }, + "thumbnail_queue" : { + "_all" : { + "enabled" : false + }, + "properties" : { + "createdBy" : { + "type" : "string", + "index" : "not_analyzed" + }, + "createdTime" : { + "type" : "long" + }, + "generator" : { + "type" : "string", + "index" : "not_analyzed" + }, + "path" : { + "type" : "string", + "index" : "not_analyzed" + }, + "url" : { + "type" : "string", + "index" : "not_analyzed" + } + } } }, "settings" : { diff --git a/src/main/java/org/codelibs/fess/app/web/thumbnail/ThumbnailAction.java b/src/main/java/org/codelibs/fess/app/web/thumbnail/ThumbnailAction.java index e957a6cb8..7e14ba532 100644 --- a/src/main/java/org/codelibs/fess/app/web/thumbnail/ThumbnailAction.java +++ b/src/main/java/org/codelibs/fess/app/web/thumbnail/ThumbnailAction.java @@ -71,7 +71,7 @@ public class ThumbnailAction extends FessSearchAction { final File thumbnailFile = thumbnailManager.getThumbnailFile(form.queryId, form.docId); if (thumbnailFile == null) { // 404 - thumbnailManager.generate(doc); + thumbnailManager.offer(doc); throw responseManager.new404("Thumbnail for " + form.docId + " is under generating."); } diff --git a/src/main/java/org/codelibs/fess/es/config/bsbhv/BsThumbnailQueueBhv.java b/src/main/java/org/codelibs/fess/es/config/bsbhv/BsThumbnailQueueBhv.java new file mode 100644 index 000000000..ff12bb127 --- /dev/null +++ b/src/main/java/org/codelibs/fess/es/config/bsbhv/BsThumbnailQueueBhv.java @@ -0,0 +1,257 @@ +/* + * Copyright 2012-2016 CodeLibs Project and the Others. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.codelibs.fess.es.config.bsbhv; + +import java.util.List; +import java.util.Map; + +import org.codelibs.fess.es.config.allcommon.EsAbstractBehavior; +import org.codelibs.fess.es.config.allcommon.EsAbstractEntity.RequestOptionCall; +import org.codelibs.fess.es.config.bsentity.dbmeta.ThumbnailQueueDbm; +import org.codelibs.fess.es.config.cbean.ThumbnailQueueCB; +import org.codelibs.fess.es.config.exentity.ThumbnailQueue; +import org.dbflute.Entity; +import org.dbflute.bhv.readable.CBCall; +import org.dbflute.bhv.readable.EntityRowHandler; +import org.dbflute.cbean.ConditionBean; +import org.dbflute.cbean.result.ListResultBean; +import org.dbflute.cbean.result.PagingResultBean; +import org.dbflute.exception.IllegalBehaviorStateException; +import org.dbflute.optional.OptionalEntity; +import org.dbflute.util.DfTypeUtil; +import org.elasticsearch.action.bulk.BulkRequestBuilder; +import org.elasticsearch.action.delete.DeleteRequestBuilder; +import org.elasticsearch.action.index.IndexRequestBuilder; + +/** + * @author ESFlute (using FreeGen) + */ +public abstract class BsThumbnailQueueBhv extends EsAbstractBehavior { + + // =================================================================================== + // Control Override + // ================ + @Override + public String asTableDbName() { + return asEsIndexType(); + } + + @Override + protected String asEsIndex() { + return ".fess_config"; + } + + @Override + public String asEsIndexType() { + return "thumbnail_queue"; + } + + @Override + public String asEsSearchType() { + return "thumbnail_queue"; + } + + @Override + public ThumbnailQueueDbm asDBMeta() { + return ThumbnailQueueDbm.getInstance(); + } + + @Override + protected RESULT createEntity(Map source, Class entityType) { + try { + final RESULT result = entityType.newInstance(); + result.setCreatedBy(DfTypeUtil.toString(source.get("createdBy"))); + result.setCreatedTime(DfTypeUtil.toLong(source.get("createdTime"))); + result.setGenerator(DfTypeUtil.toString(source.get("generator"))); + result.setPath(DfTypeUtil.toString(source.get("path"))); + result.setUrl(DfTypeUtil.toString(source.get("url"))); + return result; + } catch (InstantiationException | IllegalAccessException e) { + final String msg = "Cannot create a new instance: " + entityType.getName(); + throw new IllegalBehaviorStateException(msg, e); + } + } + + // =================================================================================== + // Select + // ====== + public int selectCount(CBCall cbLambda) { + return facadeSelectCount(createCB(cbLambda)); + } + + public OptionalEntity selectEntity(CBCall cbLambda) { + return facadeSelectEntity(createCB(cbLambda)); + } + + protected OptionalEntity facadeSelectEntity(ThumbnailQueueCB cb) { + return doSelectOptionalEntity(cb, typeOfSelectedEntity()); + } + + protected OptionalEntity doSelectOptionalEntity(ThumbnailQueueCB cb, Class tp) { + return createOptionalEntity(doSelectEntity(cb, tp), cb); + } + + @Override + public ThumbnailQueueCB newConditionBean() { + return new ThumbnailQueueCB(); + } + + @Override + protected Entity doReadEntity(ConditionBean cb) { + return facadeSelectEntity(downcast(cb)).orElse(null); + } + + public ThumbnailQueue selectEntityWithDeletedCheck(CBCall cbLambda) { + return facadeSelectEntityWithDeletedCheck(createCB(cbLambda)); + } + + public OptionalEntity selectByPK(String id) { + return facadeSelectByPK(id); + } + + protected OptionalEntity facadeSelectByPK(String id) { + return doSelectOptionalByPK(id, typeOfSelectedEntity()); + } + + protected ENTITY doSelectByPK(String id, Class tp) { + return doSelectEntity(xprepareCBAsPK(id), tp); + } + + protected ThumbnailQueueCB xprepareCBAsPK(String id) { + assertObjectNotNull("id", id); + return newConditionBean().acceptPK(id); + } + + protected OptionalEntity doSelectOptionalByPK(String id, Class tp) { + return createOptionalEntity(doSelectByPK(id, tp), id); + } + + @Override + protected Class typeOfSelectedEntity() { + return ThumbnailQueue.class; + } + + @Override + protected Class typeOfHandlingEntity() { + return ThumbnailQueue.class; + } + + @Override + protected Class typeOfHandlingConditionBean() { + return ThumbnailQueueCB.class; + } + + public ListResultBean selectList(CBCall cbLambda) { + return facadeSelectList(createCB(cbLambda)); + } + + public PagingResultBean selectPage(CBCall cbLambda) { + // #pending same? + return (PagingResultBean) facadeSelectList(createCB(cbLambda)); + } + + public void selectCursor(CBCall cbLambda, EntityRowHandler entityLambda) { + facadeSelectCursor(createCB(cbLambda), entityLambda); + } + + public void selectBulk(CBCall cbLambda, EntityRowHandler> entityLambda) { + delegateSelectBulk(createCB(cbLambda), entityLambda, typeOfSelectedEntity()); + } + + // =================================================================================== + // Update + // ====== + public void insert(ThumbnailQueue entity) { + doInsert(entity, null); + } + + public void insert(ThumbnailQueue entity, RequestOptionCall opLambda) { + entity.asDocMeta().indexOption(opLambda); + doInsert(entity, null); + } + + public void update(ThumbnailQueue entity) { + doUpdate(entity, null); + } + + public void update(ThumbnailQueue entity, RequestOptionCall opLambda) { + entity.asDocMeta().indexOption(opLambda); + doUpdate(entity, null); + } + + public void insertOrUpdate(ThumbnailQueue entity) { + doInsertOrUpdate(entity, null, null); + } + + public void insertOrUpdate(ThumbnailQueue entity, RequestOptionCall opLambda) { + entity.asDocMeta().indexOption(opLambda); + doInsertOrUpdate(entity, null, null); + } + + public void delete(ThumbnailQueue entity) { + doDelete(entity, null); + } + + public void delete(ThumbnailQueue entity, RequestOptionCall opLambda) { + entity.asDocMeta().deleteOption(opLambda); + doDelete(entity, null); + } + + public int queryDelete(CBCall cbLambda) { + return doQueryDelete(createCB(cbLambda), null); + } + + public int[] batchInsert(List list) { + return batchInsert(list, null, null); + } + + public int[] batchInsert(List list, RequestOptionCall call) { + return batchInsert(list, call, null); + } + + public int[] batchInsert(List list, RequestOptionCall call, + RequestOptionCall entityCall) { + return doBatchInsert(new BulkList<>(list, call, entityCall), null); + } + + public int[] batchUpdate(List list) { + return batchUpdate(list, null, null); + } + + public int[] batchUpdate(List list, RequestOptionCall call) { + return batchUpdate(list, call, null); + } + + public int[] batchUpdate(List list, RequestOptionCall call, + RequestOptionCall entityCall) { + return doBatchUpdate(new BulkList<>(list, call, entityCall), null); + } + + public int[] batchDelete(List list) { + return batchDelete(list, null, null); + } + + public int[] batchDelete(List list, RequestOptionCall call) { + return batchDelete(list, call, null); + } + + public int[] batchDelete(List list, RequestOptionCall call, + RequestOptionCall entityCall) { + return doBatchDelete(new BulkList<>(list, call, entityCall), null); + } + + // #pending create, modify, remove +} diff --git a/src/main/java/org/codelibs/fess/es/config/bsentity/BsThumbnailQueue.java b/src/main/java/org/codelibs/fess/es/config/bsentity/BsThumbnailQueue.java new file mode 100644 index 000000000..3eb581df7 --- /dev/null +++ b/src/main/java/org/codelibs/fess/es/config/bsentity/BsThumbnailQueue.java @@ -0,0 +1,164 @@ +/* + * Copyright 2012-2016 CodeLibs Project and the Others. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.codelibs.fess.es.config.bsentity; + +import java.time.LocalDateTime; +import java.util.HashMap; +import java.util.Map; + +import org.codelibs.fess.es.config.allcommon.EsAbstractEntity; +import org.codelibs.fess.es.config.bsentity.dbmeta.ThumbnailQueueDbm; + +/** + * ${table.comment} + * @author ESFlute (using FreeGen) + */ +public class BsThumbnailQueue extends EsAbstractEntity { + + // =================================================================================== + // Definition + // ========== + private static final long serialVersionUID = 1L; + protected static final Class suppressUnusedImportLocalDateTime = LocalDateTime.class; + + // =================================================================================== + // Attribute + // ========= + /** createdBy */ + protected String createdBy; + + /** createdTime */ + protected Long createdTime; + + /** generator */ + protected String generator; + + /** path */ + protected String path; + + /** url */ + protected String url; + + // [Referrers] *comment only + + // =================================================================================== + // DB Meta + // ======= + @Override + public ThumbnailQueueDbm asDBMeta() { + return ThumbnailQueueDbm.getInstance(); + } + + @Override + public String asTableDbName() { + return "thumbnail_queue"; + } + + // =================================================================================== + // Source + // ====== + @Override + public Map toSource() { + Map sourceMap = new HashMap<>(); + if (createdBy != null) { + sourceMap.put("createdBy", createdBy); + } + if (createdTime != null) { + sourceMap.put("createdTime", createdTime); + } + if (generator != null) { + sourceMap.put("generator", generator); + } + if (path != null) { + sourceMap.put("path", path); + } + if (url != null) { + sourceMap.put("url", url); + } + return sourceMap; + } + + // =================================================================================== + // Basic Override + // ============== + @Override + protected String doBuildColumnString(String dm) { + StringBuilder sb = new StringBuilder(); + sb.append(dm).append(createdBy); + sb.append(dm).append(createdTime); + sb.append(dm).append(generator); + sb.append(dm).append(path); + sb.append(dm).append(url); + if (sb.length() > dm.length()) { + sb.delete(0, dm.length()); + } + sb.insert(0, "{").append("}"); + return sb.toString(); + } + + // =================================================================================== + // Accessor + // ======== + public String getCreatedBy() { + checkSpecifiedProperty("createdBy"); + return convertEmptyToNull(createdBy); + } + + public void setCreatedBy(String value) { + registerModifiedProperty("createdBy"); + this.createdBy = value; + } + + public Long getCreatedTime() { + checkSpecifiedProperty("createdTime"); + return createdTime; + } + + public void setCreatedTime(Long value) { + registerModifiedProperty("createdTime"); + this.createdTime = value; + } + + public String getGenerator() { + checkSpecifiedProperty("generator"); + return convertEmptyToNull(generator); + } + + public void setGenerator(String value) { + registerModifiedProperty("generator"); + this.generator = value; + } + + public String getPath() { + checkSpecifiedProperty("path"); + return convertEmptyToNull(path); + } + + public void setPath(String value) { + registerModifiedProperty("path"); + this.path = value; + } + + public String getUrl() { + checkSpecifiedProperty("url"); + return convertEmptyToNull(url); + } + + public void setUrl(String value) { + registerModifiedProperty("url"); + this.url = value; + } +} diff --git a/src/main/java/org/codelibs/fess/es/config/bsentity/dbmeta/ThumbnailQueueDbm.java b/src/main/java/org/codelibs/fess/es/config/bsentity/dbmeta/ThumbnailQueueDbm.java new file mode 100644 index 000000000..35f9745bc --- /dev/null +++ b/src/main/java/org/codelibs/fess/es/config/bsentity/dbmeta/ThumbnailQueueDbm.java @@ -0,0 +1,239 @@ +/* + * Copyright 2012-2016 CodeLibs Project and the Others. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.codelibs.fess.es.config.bsentity.dbmeta; + +import java.time.LocalDateTime; +import java.util.List; +import java.util.Map; + +import org.codelibs.fess.es.config.exentity.ThumbnailQueue; +import org.dbflute.Entity; +import org.dbflute.dbmeta.AbstractDBMeta; +import org.dbflute.dbmeta.info.ColumnInfo; +import org.dbflute.dbmeta.info.UniqueInfo; +import org.dbflute.dbmeta.name.TableSqlName; +import org.dbflute.dbmeta.property.PropertyGateway; +import org.dbflute.dbway.DBDef; +import org.dbflute.util.DfTypeUtil; + +/** + * @author ESFlute (using FreeGen) + */ +public class ThumbnailQueueDbm extends AbstractDBMeta { + + protected static final Class suppressUnusedImportLocalDateTime = LocalDateTime.class; + + // =================================================================================== + // Singleton + // ========= + private static final ThumbnailQueueDbm _instance = new ThumbnailQueueDbm(); + + private ThumbnailQueueDbm() { + } + + public static ThumbnailQueueDbm getInstance() { + return _instance; + } + + // =================================================================================== + // Current DBDef + // ============= + @Override + public String getProjectName() { + return null; + } + + @Override + public String getProjectPrefix() { + return null; + } + + @Override + public String getGenerationGapBasePrefix() { + return null; + } + + @Override + public DBDef getCurrentDBDef() { + return null; + } + + // =================================================================================== + // Property Gateway + // ================ + // ----------------------------------------------------- + // Column Property + // --------------- + protected final Map _epgMap = newHashMap(); + { + setupEpg(_epgMap, et -> ((ThumbnailQueue) et).getCreatedBy(), + (et, vl) -> ((ThumbnailQueue) et).setCreatedBy(DfTypeUtil.toString(vl)), "createdBy"); + setupEpg(_epgMap, et -> ((ThumbnailQueue) et).getCreatedTime(), + (et, vl) -> ((ThumbnailQueue) et).setCreatedTime(DfTypeUtil.toLong(vl)), "createdTime"); + setupEpg(_epgMap, et -> ((ThumbnailQueue) et).getGenerator(), + (et, vl) -> ((ThumbnailQueue) et).setGenerator(DfTypeUtil.toString(vl)), "generator"); + setupEpg(_epgMap, et -> ((ThumbnailQueue) et).getPath(), (et, vl) -> ((ThumbnailQueue) et).setPath(DfTypeUtil.toString(vl)), "path"); + setupEpg(_epgMap, et -> ((ThumbnailQueue) et).getUrl(), (et, vl) -> ((ThumbnailQueue) et).setUrl(DfTypeUtil.toString(vl)), "url"); + } + + @Override + public PropertyGateway findPropertyGateway(final String prop) { + return doFindEpg(_epgMap, prop); + } + + // =================================================================================== + // Table Info + // ========== + protected final String _tableDbName = "thumbnail_queue"; + protected final String _tableDispName = "thumbnail_queue"; + protected final String _tablePropertyName = "ThumbnailQueue"; + + public String getTableDbName() { + return _tableDbName; + } + + @Override + public String getTableDispName() { + return _tableDispName; + } + + @Override + public String getTablePropertyName() { + return _tablePropertyName; + } + + @Override + public TableSqlName getTableSqlName() { + return null; + } + + // =================================================================================== + // Column Info + // =========== + protected final ColumnInfo _columnCreatedBy = cci("createdBy", "createdBy", null, null, String.class, "createdBy", null, false, false, + false, "String", 0, 0, null, false, null, null, null, null, null, false); + protected final ColumnInfo _columnCreatedTime = cci("createdTime", "createdTime", null, null, Long.class, "createdTime", null, false, + false, false, "Long", 0, 0, null, false, null, null, null, null, null, false); + protected final ColumnInfo _columnGenerator = cci("generator", "generator", null, null, String.class, "generator", null, false, false, + false, "String", 0, 0, null, false, null, null, null, null, null, false); + protected final ColumnInfo _columnPath = cci("path", "path", null, null, String.class, "path", null, false, false, false, "String", 0, + 0, null, false, null, null, null, null, null, false); + protected final ColumnInfo _columnUrl = cci("url", "url", null, null, String.class, "url", null, false, false, false, "String", 0, 0, + null, false, null, null, null, null, null, false); + + public ColumnInfo columnCreatedBy() { + return _columnCreatedBy; + } + + public ColumnInfo columnCreatedTime() { + return _columnCreatedTime; + } + + public ColumnInfo columnGenerator() { + return _columnGenerator; + } + + public ColumnInfo columnPath() { + return _columnPath; + } + + public ColumnInfo columnUrl() { + return _columnUrl; + } + + protected List ccil() { + List ls = newArrayList(); + ls.add(columnCreatedBy()); + ls.add(columnCreatedTime()); + ls.add(columnGenerator()); + ls.add(columnPath()); + ls.add(columnUrl()); + return ls; + } + + // =================================================================================== + // Unique Info + // =========== + @Override + public boolean hasPrimaryKey() { + return false; + } + + @Override + public boolean hasCompoundPrimaryKey() { + return false; + } + + @Override + protected UniqueInfo cpui() { + return null; + } + + // =================================================================================== + // Type Name + // ========= + @Override + public String getEntityTypeName() { + return "org.codelibs.fess.es.config.exentity.ThumbnailQueue"; + } + + @Override + public String getConditionBeanTypeName() { + return "org.codelibs.fess.es.config.cbean.ThumbnailQueueCB"; + } + + @Override + public String getBehaviorTypeName() { + return "org.codelibs.fess.es.config.exbhv.ThumbnailQueueBhv"; + } + + // =================================================================================== + // Object Type + // =========== + @Override + public Class getEntityType() { + return ThumbnailQueue.class; + } + + // =================================================================================== + // Object Instance + // =============== + @Override + public Entity newEntity() { + return new ThumbnailQueue(); + } + + // =================================================================================== + // Map Communication + // ================= + @Override + public void acceptPrimaryKeyMap(Entity entity, Map primaryKeyMap) { + } + + @Override + public void acceptAllColumnMap(Entity entity, Map allColumnMap) { + } + + @Override + public Map extractPrimaryKeyMap(Entity entity) { + return null; + } + + @Override + public Map extractAllColumnMap(Entity entity) { + return null; + } +} diff --git a/src/main/java/org/codelibs/fess/es/config/cbean/ThumbnailQueueCB.java b/src/main/java/org/codelibs/fess/es/config/cbean/ThumbnailQueueCB.java new file mode 100644 index 000000000..eb8a488d5 --- /dev/null +++ b/src/main/java/org/codelibs/fess/es/config/cbean/ThumbnailQueueCB.java @@ -0,0 +1,24 @@ +/* + * Copyright 2012-2016 CodeLibs Project and the Others. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.codelibs.fess.es.config.cbean; + +import org.codelibs.fess.es.config.cbean.bs.BsThumbnailQueueCB; + +/** + * @author ESFlute (using FreeGen) + */ +public class ThumbnailQueueCB extends BsThumbnailQueueCB { +} diff --git a/src/main/java/org/codelibs/fess/es/config/cbean/bs/BsThumbnailQueueCB.java b/src/main/java/org/codelibs/fess/es/config/cbean/bs/BsThumbnailQueueCB.java new file mode 100644 index 000000000..6eda159c9 --- /dev/null +++ b/src/main/java/org/codelibs/fess/es/config/cbean/bs/BsThumbnailQueueCB.java @@ -0,0 +1,170 @@ +/* + * Copyright 2012-2016 CodeLibs Project and the Others. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.codelibs.fess.es.config.cbean.bs; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.codelibs.fess.es.config.allcommon.EsAbstractConditionBean; +import org.codelibs.fess.es.config.bsentity.dbmeta.ThumbnailQueueDbm; +import org.codelibs.fess.es.config.cbean.ThumbnailQueueCB; +import org.codelibs.fess.es.config.cbean.cq.ThumbnailQueueCQ; +import org.codelibs.fess.es.config.cbean.cq.bs.BsThumbnailQueueCQ; +import org.dbflute.cbean.ConditionQuery; +import org.elasticsearch.action.search.SearchRequestBuilder; +import org.elasticsearch.index.query.QueryBuilder; + +/** + * @author ESFlute (using FreeGen) + */ +public class BsThumbnailQueueCB extends EsAbstractConditionBean { + + // =================================================================================== + // Attribute + // ========= + protected BsThumbnailQueueCQ _conditionQuery; + protected HpSpecification _specification; + + // =================================================================================== + // Control + // ======= + @Override + public ThumbnailQueueDbm asDBMeta() { + return ThumbnailQueueDbm.getInstance(); + } + + @Override + public String asTableDbName() { + return "thumbnail_queue"; + } + + @Override + public boolean hasSpecifiedColumn() { + return _specification != null; + } + + @Override + public ConditionQuery localCQ() { + return doGetConditionQuery(); + } + + // =================================================================================== + // Primary Key + // =========== + public ThumbnailQueueCB acceptPK(String id) { + assertObjectNotNull("id", id); + BsThumbnailQueueCB cb = this; + cb.query().docMeta().setId_Equal(id); + return (ThumbnailQueueCB) this; + } + + @Override + public void acceptPrimaryKeyMap(Map primaryKeyMap) { + acceptPK((String) primaryKeyMap.get("_id")); + } + + // =================================================================================== + // Build + // ===== + + @Override + public SearchRequestBuilder build(SearchRequestBuilder builder) { + if (_conditionQuery != null) { + QueryBuilder queryBuilder = _conditionQuery.getQuery(); + if (queryBuilder != null) { + builder.setQuery(queryBuilder); + } + _conditionQuery.getFieldSortBuilderList().forEach(sort -> { + builder.addSort(sort); + }); + } + + if (_specification != null) { + builder.setFetchSource(_specification.columnList.toArray(new String[_specification.columnList.size()]), null); + } + + return builder; + } + + // =================================================================================== + // Query + // ===== + public BsThumbnailQueueCQ query() { + assertQueryPurpose(); + return doGetConditionQuery(); + } + + protected BsThumbnailQueueCQ doGetConditionQuery() { + if (_conditionQuery == null) { + _conditionQuery = createLocalCQ(); + } + return _conditionQuery; + } + + protected BsThumbnailQueueCQ createLocalCQ() { + return new ThumbnailQueueCQ(); + } + + // =================================================================================== + // Specify + // ======= + public HpSpecification specify() { + assertSpecifyPurpose(); + if (_specification == null) { + _specification = new HpSpecification(); + } + return _specification; + } + + protected void assertQueryPurpose() { + } + + protected void assertSpecifyPurpose() { + } + + public static class HpSpecification { + private List columnList = new ArrayList<>(); + + private void doColumn(String name) { + columnList.add(name); + } + + public void columnId() { + doColumn("_id"); + } + + public void columnCreatedBy() { + doColumn("createdBy"); + } + + public void columnCreatedTime() { + doColumn("createdTime"); + } + + public void columnGenerator() { + doColumn("generator"); + } + + public void columnPath() { + doColumn("path"); + } + + public void columnUrl() { + doColumn("url"); + } + } +} diff --git a/src/main/java/org/codelibs/fess/es/config/cbean/cq/ThumbnailQueueCQ.java b/src/main/java/org/codelibs/fess/es/config/cbean/cq/ThumbnailQueueCQ.java new file mode 100644 index 000000000..2fc7c8368 --- /dev/null +++ b/src/main/java/org/codelibs/fess/es/config/cbean/cq/ThumbnailQueueCQ.java @@ -0,0 +1,24 @@ +/* + * Copyright 2012-2016 CodeLibs Project and the Others. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.codelibs.fess.es.config.cbean.cq; + +import org.codelibs.fess.es.config.cbean.cq.bs.BsThumbnailQueueCQ; + +/** + * @author ESFlute (using FreeGen) + */ +public class ThumbnailQueueCQ extends BsThumbnailQueueCQ { +} diff --git a/src/main/java/org/codelibs/fess/es/config/cbean/cq/bs/BsThumbnailQueueCQ.java b/src/main/java/org/codelibs/fess/es/config/cbean/cq/bs/BsThumbnailQueueCQ.java new file mode 100644 index 000000000..f038381b5 --- /dev/null +++ b/src/main/java/org/codelibs/fess/es/config/cbean/cq/bs/BsThumbnailQueueCQ.java @@ -0,0 +1,1167 @@ +/* + * Copyright 2012-2016 CodeLibs Project and the Others. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.codelibs.fess.es.config.cbean.cq.bs; + +import java.time.LocalDateTime; +import java.util.Collection; + +import org.codelibs.fess.es.config.allcommon.EsAbstractConditionQuery; +import org.codelibs.fess.es.config.cbean.cq.ThumbnailQueueCQ; +import org.dbflute.cbean.ckey.ConditionKey; +import org.elasticsearch.index.query.BoolQueryBuilder; +import org.elasticsearch.index.query.CommonTermsQueryBuilder; +import org.elasticsearch.index.query.ExistsQueryBuilder; +import org.elasticsearch.index.query.FuzzyQueryBuilder; +import org.elasticsearch.index.query.IdsQueryBuilder; +import org.elasticsearch.index.query.MatchQueryBuilder; +import org.elasticsearch.index.query.PrefixQueryBuilder; +import org.elasticsearch.index.query.RangeQueryBuilder; +import org.elasticsearch.index.query.RegexpQueryBuilder; +import org.elasticsearch.index.query.TermQueryBuilder; +import org.elasticsearch.index.query.TermsQueryBuilder; +import org.elasticsearch.index.query.WildcardQueryBuilder; + +/** + * @author ESFlute (using FreeGen) + */ +public abstract class BsThumbnailQueueCQ extends EsAbstractConditionQuery { + + protected static final Class suppressUnusedImportLocalDateTime = LocalDateTime.class; + + // =================================================================================== + // Name Override + // ============= + @Override + public String asTableDbName() { + return "thumbnail_queue"; + } + + @Override + public String xgetAliasName() { + return "thumbnail_queue"; + } + + // =================================================================================== + // Query Control + // ============= + public void filtered(FilteredCall filteredLambda) { + filtered(filteredLambda, null); + } + + public void filtered(FilteredCall filteredLambda, ConditionOptionCall opLambda) { + bool((must, should, mustNot, filter) -> { + filteredLambda.callback(must, filter); + }, opLambda); + } + + public void not(OperatorCall notLambda) { + not(notLambda, null); + } + + public void not(final OperatorCall notLambda, final ConditionOptionCall opLambda) { + bool((must, should, mustNot, filter) -> notLambda.callback(mustNot), opLambda); + } + + public void bool(BoolCall boolLambda) { + bool(boolLambda, null); + } + + public void bool(BoolCall boolLambda, ConditionOptionCall opLambda) { + ThumbnailQueueCQ mustQuery = new ThumbnailQueueCQ(); + ThumbnailQueueCQ shouldQuery = new ThumbnailQueueCQ(); + ThumbnailQueueCQ mustNotQuery = new ThumbnailQueueCQ(); + ThumbnailQueueCQ filterQuery = new ThumbnailQueueCQ(); + boolLambda.callback(mustQuery, shouldQuery, mustNotQuery, filterQuery); + if (mustQuery.hasQueries() || shouldQuery.hasQueries() || mustNotQuery.hasQueries() || filterQuery.hasQueries()) { + BoolQueryBuilder builder = + regBoolCQ(mustQuery.getQueryBuilderList(), shouldQuery.getQueryBuilderList(), mustNotQuery.getQueryBuilderList(), + filterQuery.getQueryBuilderList()); + if (opLambda != null) { + opLambda.callback(builder); + } + } + } + + // =================================================================================== + // Query Set + // ========= + public void setId_Equal(String id) { + setId_Term(id, null); + } + + public void setId_Equal(String id, ConditionOptionCall opLambda) { + setId_Term(id, opLambda); + } + + public void setId_Term(String id) { + setId_Term(id, null); + } + + public void setId_Term(String id, ConditionOptionCall opLambda) { + TermQueryBuilder builder = regTermQ("_id", id); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setId_NotEqual(String id) { + setId_NotTerm(id, null); + } + + public void setId_NotTerm(String id) { + setId_NotTerm(id, null); + } + + public void setId_NotEqual(String id, ConditionOptionCall opLambda) { + setId_NotTerm(id, opLambda); + } + + public void setId_NotTerm(String id, ConditionOptionCall opLambda) { + not(not -> not.setId_Term(id), opLambda); + } + + public void setId_Terms(Collection idList) { + setId_Terms(idList, null); + } + + public void setId_Terms(Collection idList, ConditionOptionCall opLambda) { + IdsQueryBuilder builder = regIdsQ(idList); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setId_InScope(Collection idList) { + setId_Terms(idList, null); + } + + public void setId_InScope(Collection idList, ConditionOptionCall opLambda) { + setId_Terms(idList, opLambda); + } + + public BsThumbnailQueueCQ addOrderBy_Id_Asc() { + regOBA("_id"); + return this; + } + + public BsThumbnailQueueCQ addOrderBy_Id_Desc() { + regOBD("_id"); + return this; + } + + public void setCreatedBy_Equal(String createdBy) { + setCreatedBy_Term(createdBy, null); + } + + public void setCreatedBy_Equal(String createdBy, ConditionOptionCall opLambda) { + setCreatedBy_Term(createdBy, opLambda); + } + + public void setCreatedBy_Term(String createdBy) { + setCreatedBy_Term(createdBy, null); + } + + public void setCreatedBy_Term(String createdBy, ConditionOptionCall opLambda) { + TermQueryBuilder builder = regTermQ("createdBy", createdBy); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedBy_NotEqual(String createdBy) { + setCreatedBy_NotTerm(createdBy, null); + } + + public void setCreatedBy_NotTerm(String createdBy) { + setCreatedBy_NotTerm(createdBy, null); + } + + public void setCreatedBy_NotEqual(String createdBy, ConditionOptionCall opLambda) { + setCreatedBy_NotTerm(createdBy, opLambda); + } + + public void setCreatedBy_NotTerm(String createdBy, ConditionOptionCall opLambda) { + not(not -> not.setCreatedBy_Term(createdBy), opLambda); + } + + public void setCreatedBy_Terms(Collection createdByList) { + setCreatedBy_Terms(createdByList, null); + } + + public void setCreatedBy_Terms(Collection createdByList, ConditionOptionCall opLambda) { + TermsQueryBuilder builder = regTermsQ("createdBy", createdByList); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedBy_InScope(Collection createdByList) { + setCreatedBy_Terms(createdByList, null); + } + + public void setCreatedBy_InScope(Collection createdByList, ConditionOptionCall opLambda) { + setCreatedBy_Terms(createdByList, opLambda); + } + + public void setCreatedBy_Match(String createdBy) { + setCreatedBy_Match(createdBy, null); + } + + public void setCreatedBy_Match(String createdBy, ConditionOptionCall opLambda) { + MatchQueryBuilder builder = regMatchQ("createdBy", createdBy); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedBy_MatchPhrase(String createdBy) { + setCreatedBy_MatchPhrase(createdBy, null); + } + + public void setCreatedBy_MatchPhrase(String createdBy, ConditionOptionCall opLambda) { + MatchQueryBuilder builder = regMatchPhraseQ("createdBy", createdBy); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedBy_MatchPhrasePrefix(String createdBy) { + setCreatedBy_MatchPhrasePrefix(createdBy, null); + } + + public void setCreatedBy_MatchPhrasePrefix(String createdBy, ConditionOptionCall opLambda) { + MatchQueryBuilder builder = regMatchPhrasePrefixQ("createdBy", createdBy); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedBy_Fuzzy(String createdBy) { + setCreatedBy_Fuzzy(createdBy, null); + } + + public void setCreatedBy_Fuzzy(String createdBy, ConditionOptionCall opLambda) { + FuzzyQueryBuilder builder = regFuzzyQ("createdBy", createdBy); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedBy_Prefix(String createdBy) { + setCreatedBy_Prefix(createdBy, null); + } + + public void setCreatedBy_Prefix(String createdBy, ConditionOptionCall opLambda) { + PrefixQueryBuilder builder = regPrefixQ("createdBy", createdBy); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedBy_Wildcard(String createdBy) { + setCreatedBy_Wildcard(createdBy, null); + } + + public void setCreatedBy_Wildcard(String createdBy, ConditionOptionCall opLambda) { + WildcardQueryBuilder builder = regWildcardQ("createdBy", createdBy); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedBy_Regexp(String createdBy) { + setCreatedBy_Regexp(createdBy, null); + } + + public void setCreatedBy_Regexp(String createdBy, ConditionOptionCall opLambda) { + RegexpQueryBuilder builder = regRegexpQ("createdBy", createdBy); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedBy_GreaterThan(String createdBy) { + setCreatedBy_GreaterThan(createdBy, null); + } + + public void setCreatedBy_GreaterThan(String createdBy, ConditionOptionCall opLambda) { + RangeQueryBuilder builder = regRangeQ("createdBy", ConditionKey.CK_GREATER_THAN, createdBy); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedBy_LessThan(String createdBy) { + setCreatedBy_LessThan(createdBy, null); + } + + public void setCreatedBy_LessThan(String createdBy, ConditionOptionCall opLambda) { + RangeQueryBuilder builder = regRangeQ("createdBy", ConditionKey.CK_LESS_THAN, createdBy); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedBy_GreaterEqual(String createdBy) { + setCreatedBy_GreaterEqual(createdBy, null); + } + + public void setCreatedBy_GreaterEqual(String createdBy, ConditionOptionCall opLambda) { + RangeQueryBuilder builder = regRangeQ("createdBy", ConditionKey.CK_GREATER_EQUAL, createdBy); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedBy_LessEqual(String createdBy) { + setCreatedBy_LessEqual(createdBy, null); + } + + public void setCreatedBy_LessEqual(String createdBy, ConditionOptionCall opLambda) { + RangeQueryBuilder builder = regRangeQ("createdBy", ConditionKey.CK_LESS_EQUAL, createdBy); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedBy_Exists() { + setCreatedBy_Exists(null); + } + + public void setCreatedBy_Exists(ConditionOptionCall opLambda) { + ExistsQueryBuilder builder = regExistsQ("createdBy"); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedBy_CommonTerms(String createdBy) { + setCreatedBy_CommonTerms(createdBy, null); + } + + public void setCreatedBy_CommonTerms(String createdBy, ConditionOptionCall opLambda) { + CommonTermsQueryBuilder builder = regCommonTermsQ("createdBy", createdBy); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public BsThumbnailQueueCQ addOrderBy_CreatedBy_Asc() { + regOBA("createdBy"); + return this; + } + + public BsThumbnailQueueCQ addOrderBy_CreatedBy_Desc() { + regOBD("createdBy"); + return this; + } + + public void setCreatedTime_Equal(Long createdTime) { + setCreatedTime_Term(createdTime, null); + } + + public void setCreatedTime_Equal(Long createdTime, ConditionOptionCall opLambda) { + setCreatedTime_Term(createdTime, opLambda); + } + + public void setCreatedTime_Term(Long createdTime) { + setCreatedTime_Term(createdTime, null); + } + + public void setCreatedTime_Term(Long createdTime, ConditionOptionCall opLambda) { + TermQueryBuilder builder = regTermQ("createdTime", createdTime); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedTime_NotEqual(Long createdTime) { + setCreatedTime_NotTerm(createdTime, null); + } + + public void setCreatedTime_NotTerm(Long createdTime) { + setCreatedTime_NotTerm(createdTime, null); + } + + public void setCreatedTime_NotEqual(Long createdTime, ConditionOptionCall opLambda) { + setCreatedTime_NotTerm(createdTime, opLambda); + } + + public void setCreatedTime_NotTerm(Long createdTime, ConditionOptionCall opLambda) { + not(not -> not.setCreatedTime_Term(createdTime), opLambda); + } + + public void setCreatedTime_Terms(Collection createdTimeList) { + setCreatedTime_Terms(createdTimeList, null); + } + + public void setCreatedTime_Terms(Collection createdTimeList, ConditionOptionCall opLambda) { + TermsQueryBuilder builder = regTermsQ("createdTime", createdTimeList); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedTime_InScope(Collection createdTimeList) { + setCreatedTime_Terms(createdTimeList, null); + } + + public void setCreatedTime_InScope(Collection createdTimeList, ConditionOptionCall opLambda) { + setCreatedTime_Terms(createdTimeList, opLambda); + } + + public void setCreatedTime_Match(Long createdTime) { + setCreatedTime_Match(createdTime, null); + } + + public void setCreatedTime_Match(Long createdTime, ConditionOptionCall opLambda) { + MatchQueryBuilder builder = regMatchQ("createdTime", createdTime); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedTime_MatchPhrase(Long createdTime) { + setCreatedTime_MatchPhrase(createdTime, null); + } + + public void setCreatedTime_MatchPhrase(Long createdTime, ConditionOptionCall opLambda) { + MatchQueryBuilder builder = regMatchPhraseQ("createdTime", createdTime); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedTime_MatchPhrasePrefix(Long createdTime) { + setCreatedTime_MatchPhrasePrefix(createdTime, null); + } + + public void setCreatedTime_MatchPhrasePrefix(Long createdTime, ConditionOptionCall opLambda) { + MatchQueryBuilder builder = regMatchPhrasePrefixQ("createdTime", createdTime); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedTime_Fuzzy(Long createdTime) { + setCreatedTime_Fuzzy(createdTime, null); + } + + public void setCreatedTime_Fuzzy(Long createdTime, ConditionOptionCall opLambda) { + FuzzyQueryBuilder builder = regFuzzyQ("createdTime", createdTime); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedTime_GreaterThan(Long createdTime) { + setCreatedTime_GreaterThan(createdTime, null); + } + + public void setCreatedTime_GreaterThan(Long createdTime, ConditionOptionCall opLambda) { + RangeQueryBuilder builder = regRangeQ("createdTime", ConditionKey.CK_GREATER_THAN, createdTime); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedTime_LessThan(Long createdTime) { + setCreatedTime_LessThan(createdTime, null); + } + + public void setCreatedTime_LessThan(Long createdTime, ConditionOptionCall opLambda) { + RangeQueryBuilder builder = regRangeQ("createdTime", ConditionKey.CK_LESS_THAN, createdTime); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedTime_GreaterEqual(Long createdTime) { + setCreatedTime_GreaterEqual(createdTime, null); + } + + public void setCreatedTime_GreaterEqual(Long createdTime, ConditionOptionCall opLambda) { + RangeQueryBuilder builder = regRangeQ("createdTime", ConditionKey.CK_GREATER_EQUAL, createdTime); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedTime_LessEqual(Long createdTime) { + setCreatedTime_LessEqual(createdTime, null); + } + + public void setCreatedTime_LessEqual(Long createdTime, ConditionOptionCall opLambda) { + RangeQueryBuilder builder = regRangeQ("createdTime", ConditionKey.CK_LESS_EQUAL, createdTime); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedTime_Exists() { + setCreatedTime_Exists(null); + } + + public void setCreatedTime_Exists(ConditionOptionCall opLambda) { + ExistsQueryBuilder builder = regExistsQ("createdTime"); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedTime_CommonTerms(Long createdTime) { + setCreatedTime_CommonTerms(createdTime, null); + } + + public void setCreatedTime_CommonTerms(Long createdTime, ConditionOptionCall opLambda) { + CommonTermsQueryBuilder builder = regCommonTermsQ("createdTime", createdTime); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public BsThumbnailQueueCQ addOrderBy_CreatedTime_Asc() { + regOBA("createdTime"); + return this; + } + + public BsThumbnailQueueCQ addOrderBy_CreatedTime_Desc() { + regOBD("createdTime"); + return this; + } + + public void setGenerator_Equal(String generator) { + setGenerator_Term(generator, null); + } + + public void setGenerator_Equal(String generator, ConditionOptionCall opLambda) { + setGenerator_Term(generator, opLambda); + } + + public void setGenerator_Term(String generator) { + setGenerator_Term(generator, null); + } + + public void setGenerator_Term(String generator, ConditionOptionCall opLambda) { + TermQueryBuilder builder = regTermQ("generator", generator); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setGenerator_NotEqual(String generator) { + setGenerator_NotTerm(generator, null); + } + + public void setGenerator_NotTerm(String generator) { + setGenerator_NotTerm(generator, null); + } + + public void setGenerator_NotEqual(String generator, ConditionOptionCall opLambda) { + setGenerator_NotTerm(generator, opLambda); + } + + public void setGenerator_NotTerm(String generator, ConditionOptionCall opLambda) { + not(not -> not.setGenerator_Term(generator), opLambda); + } + + public void setGenerator_Terms(Collection generatorList) { + setGenerator_Terms(generatorList, null); + } + + public void setGenerator_Terms(Collection generatorList, ConditionOptionCall opLambda) { + TermsQueryBuilder builder = regTermsQ("generator", generatorList); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setGenerator_InScope(Collection generatorList) { + setGenerator_Terms(generatorList, null); + } + + public void setGenerator_InScope(Collection generatorList, ConditionOptionCall opLambda) { + setGenerator_Terms(generatorList, opLambda); + } + + public void setGenerator_Match(String generator) { + setGenerator_Match(generator, null); + } + + public void setGenerator_Match(String generator, ConditionOptionCall opLambda) { + MatchQueryBuilder builder = regMatchQ("generator", generator); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setGenerator_MatchPhrase(String generator) { + setGenerator_MatchPhrase(generator, null); + } + + public void setGenerator_MatchPhrase(String generator, ConditionOptionCall opLambda) { + MatchQueryBuilder builder = regMatchPhraseQ("generator", generator); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setGenerator_MatchPhrasePrefix(String generator) { + setGenerator_MatchPhrasePrefix(generator, null); + } + + public void setGenerator_MatchPhrasePrefix(String generator, ConditionOptionCall opLambda) { + MatchQueryBuilder builder = regMatchPhrasePrefixQ("generator", generator); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setGenerator_Fuzzy(String generator) { + setGenerator_Fuzzy(generator, null); + } + + public void setGenerator_Fuzzy(String generator, ConditionOptionCall opLambda) { + FuzzyQueryBuilder builder = regFuzzyQ("generator", generator); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setGenerator_Prefix(String generator) { + setGenerator_Prefix(generator, null); + } + + public void setGenerator_Prefix(String generator, ConditionOptionCall opLambda) { + PrefixQueryBuilder builder = regPrefixQ("generator", generator); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setGenerator_Wildcard(String generator) { + setGenerator_Wildcard(generator, null); + } + + public void setGenerator_Wildcard(String generator, ConditionOptionCall opLambda) { + WildcardQueryBuilder builder = regWildcardQ("generator", generator); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setGenerator_Regexp(String generator) { + setGenerator_Regexp(generator, null); + } + + public void setGenerator_Regexp(String generator, ConditionOptionCall opLambda) { + RegexpQueryBuilder builder = regRegexpQ("generator", generator); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setGenerator_GreaterThan(String generator) { + setGenerator_GreaterThan(generator, null); + } + + public void setGenerator_GreaterThan(String generator, ConditionOptionCall opLambda) { + RangeQueryBuilder builder = regRangeQ("generator", ConditionKey.CK_GREATER_THAN, generator); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setGenerator_LessThan(String generator) { + setGenerator_LessThan(generator, null); + } + + public void setGenerator_LessThan(String generator, ConditionOptionCall opLambda) { + RangeQueryBuilder builder = regRangeQ("generator", ConditionKey.CK_LESS_THAN, generator); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setGenerator_GreaterEqual(String generator) { + setGenerator_GreaterEqual(generator, null); + } + + public void setGenerator_GreaterEqual(String generator, ConditionOptionCall opLambda) { + RangeQueryBuilder builder = regRangeQ("generator", ConditionKey.CK_GREATER_EQUAL, generator); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setGenerator_LessEqual(String generator) { + setGenerator_LessEqual(generator, null); + } + + public void setGenerator_LessEqual(String generator, ConditionOptionCall opLambda) { + RangeQueryBuilder builder = regRangeQ("generator", ConditionKey.CK_LESS_EQUAL, generator); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setGenerator_Exists() { + setGenerator_Exists(null); + } + + public void setGenerator_Exists(ConditionOptionCall opLambda) { + ExistsQueryBuilder builder = regExistsQ("generator"); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setGenerator_CommonTerms(String generator) { + setGenerator_CommonTerms(generator, null); + } + + public void setGenerator_CommonTerms(String generator, ConditionOptionCall opLambda) { + CommonTermsQueryBuilder builder = regCommonTermsQ("generator", generator); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public BsThumbnailQueueCQ addOrderBy_Generator_Asc() { + regOBA("generator"); + return this; + } + + public BsThumbnailQueueCQ addOrderBy_Generator_Desc() { + regOBD("generator"); + return this; + } + + public void setPath_Equal(String path) { + setPath_Term(path, null); + } + + public void setPath_Equal(String path, ConditionOptionCall opLambda) { + setPath_Term(path, opLambda); + } + + public void setPath_Term(String path) { + setPath_Term(path, null); + } + + public void setPath_Term(String path, ConditionOptionCall opLambda) { + TermQueryBuilder builder = regTermQ("path", path); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setPath_NotEqual(String path) { + setPath_NotTerm(path, null); + } + + public void setPath_NotTerm(String path) { + setPath_NotTerm(path, null); + } + + public void setPath_NotEqual(String path, ConditionOptionCall opLambda) { + setPath_NotTerm(path, opLambda); + } + + public void setPath_NotTerm(String path, ConditionOptionCall opLambda) { + not(not -> not.setPath_Term(path), opLambda); + } + + public void setPath_Terms(Collection pathList) { + setPath_Terms(pathList, null); + } + + public void setPath_Terms(Collection pathList, ConditionOptionCall opLambda) { + TermsQueryBuilder builder = regTermsQ("path", pathList); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setPath_InScope(Collection pathList) { + setPath_Terms(pathList, null); + } + + public void setPath_InScope(Collection pathList, ConditionOptionCall opLambda) { + setPath_Terms(pathList, opLambda); + } + + public void setPath_Match(String path) { + setPath_Match(path, null); + } + + public void setPath_Match(String path, ConditionOptionCall opLambda) { + MatchQueryBuilder builder = regMatchQ("path", path); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setPath_MatchPhrase(String path) { + setPath_MatchPhrase(path, null); + } + + public void setPath_MatchPhrase(String path, ConditionOptionCall opLambda) { + MatchQueryBuilder builder = regMatchPhraseQ("path", path); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setPath_MatchPhrasePrefix(String path) { + setPath_MatchPhrasePrefix(path, null); + } + + public void setPath_MatchPhrasePrefix(String path, ConditionOptionCall opLambda) { + MatchQueryBuilder builder = regMatchPhrasePrefixQ("path", path); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setPath_Fuzzy(String path) { + setPath_Fuzzy(path, null); + } + + public void setPath_Fuzzy(String path, ConditionOptionCall opLambda) { + FuzzyQueryBuilder builder = regFuzzyQ("path", path); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setPath_Prefix(String path) { + setPath_Prefix(path, null); + } + + public void setPath_Prefix(String path, ConditionOptionCall opLambda) { + PrefixQueryBuilder builder = regPrefixQ("path", path); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setPath_Wildcard(String path) { + setPath_Wildcard(path, null); + } + + public void setPath_Wildcard(String path, ConditionOptionCall opLambda) { + WildcardQueryBuilder builder = regWildcardQ("path", path); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setPath_Regexp(String path) { + setPath_Regexp(path, null); + } + + public void setPath_Regexp(String path, ConditionOptionCall opLambda) { + RegexpQueryBuilder builder = regRegexpQ("path", path); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setPath_GreaterThan(String path) { + setPath_GreaterThan(path, null); + } + + public void setPath_GreaterThan(String path, ConditionOptionCall opLambda) { + RangeQueryBuilder builder = regRangeQ("path", ConditionKey.CK_GREATER_THAN, path); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setPath_LessThan(String path) { + setPath_LessThan(path, null); + } + + public void setPath_LessThan(String path, ConditionOptionCall opLambda) { + RangeQueryBuilder builder = regRangeQ("path", ConditionKey.CK_LESS_THAN, path); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setPath_GreaterEqual(String path) { + setPath_GreaterEqual(path, null); + } + + public void setPath_GreaterEqual(String path, ConditionOptionCall opLambda) { + RangeQueryBuilder builder = regRangeQ("path", ConditionKey.CK_GREATER_EQUAL, path); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setPath_LessEqual(String path) { + setPath_LessEqual(path, null); + } + + public void setPath_LessEqual(String path, ConditionOptionCall opLambda) { + RangeQueryBuilder builder = regRangeQ("path", ConditionKey.CK_LESS_EQUAL, path); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setPath_Exists() { + setPath_Exists(null); + } + + public void setPath_Exists(ConditionOptionCall opLambda) { + ExistsQueryBuilder builder = regExistsQ("path"); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setPath_CommonTerms(String path) { + setPath_CommonTerms(path, null); + } + + public void setPath_CommonTerms(String path, ConditionOptionCall opLambda) { + CommonTermsQueryBuilder builder = regCommonTermsQ("path", path); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public BsThumbnailQueueCQ addOrderBy_Path_Asc() { + regOBA("path"); + return this; + } + + public BsThumbnailQueueCQ addOrderBy_Path_Desc() { + regOBD("path"); + return this; + } + + public void setUrl_Equal(String url) { + setUrl_Term(url, null); + } + + public void setUrl_Equal(String url, ConditionOptionCall opLambda) { + setUrl_Term(url, opLambda); + } + + public void setUrl_Term(String url) { + setUrl_Term(url, null); + } + + public void setUrl_Term(String url, ConditionOptionCall opLambda) { + TermQueryBuilder builder = regTermQ("url", url); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setUrl_NotEqual(String url) { + setUrl_NotTerm(url, null); + } + + public void setUrl_NotTerm(String url) { + setUrl_NotTerm(url, null); + } + + public void setUrl_NotEqual(String url, ConditionOptionCall opLambda) { + setUrl_NotTerm(url, opLambda); + } + + public void setUrl_NotTerm(String url, ConditionOptionCall opLambda) { + not(not -> not.setUrl_Term(url), opLambda); + } + + public void setUrl_Terms(Collection urlList) { + setUrl_Terms(urlList, null); + } + + public void setUrl_Terms(Collection urlList, ConditionOptionCall opLambda) { + TermsQueryBuilder builder = regTermsQ("url", urlList); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setUrl_InScope(Collection urlList) { + setUrl_Terms(urlList, null); + } + + public void setUrl_InScope(Collection urlList, ConditionOptionCall opLambda) { + setUrl_Terms(urlList, opLambda); + } + + public void setUrl_Match(String url) { + setUrl_Match(url, null); + } + + public void setUrl_Match(String url, ConditionOptionCall opLambda) { + MatchQueryBuilder builder = regMatchQ("url", url); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setUrl_MatchPhrase(String url) { + setUrl_MatchPhrase(url, null); + } + + public void setUrl_MatchPhrase(String url, ConditionOptionCall opLambda) { + MatchQueryBuilder builder = regMatchPhraseQ("url", url); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setUrl_MatchPhrasePrefix(String url) { + setUrl_MatchPhrasePrefix(url, null); + } + + public void setUrl_MatchPhrasePrefix(String url, ConditionOptionCall opLambda) { + MatchQueryBuilder builder = regMatchPhrasePrefixQ("url", url); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setUrl_Fuzzy(String url) { + setUrl_Fuzzy(url, null); + } + + public void setUrl_Fuzzy(String url, ConditionOptionCall opLambda) { + FuzzyQueryBuilder builder = regFuzzyQ("url", url); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setUrl_Prefix(String url) { + setUrl_Prefix(url, null); + } + + public void setUrl_Prefix(String url, ConditionOptionCall opLambda) { + PrefixQueryBuilder builder = regPrefixQ("url", url); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setUrl_Wildcard(String url) { + setUrl_Wildcard(url, null); + } + + public void setUrl_Wildcard(String url, ConditionOptionCall opLambda) { + WildcardQueryBuilder builder = regWildcardQ("url", url); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setUrl_Regexp(String url) { + setUrl_Regexp(url, null); + } + + public void setUrl_Regexp(String url, ConditionOptionCall opLambda) { + RegexpQueryBuilder builder = regRegexpQ("url", url); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setUrl_GreaterThan(String url) { + setUrl_GreaterThan(url, null); + } + + public void setUrl_GreaterThan(String url, ConditionOptionCall opLambda) { + RangeQueryBuilder builder = regRangeQ("url", ConditionKey.CK_GREATER_THAN, url); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setUrl_LessThan(String url) { + setUrl_LessThan(url, null); + } + + public void setUrl_LessThan(String url, ConditionOptionCall opLambda) { + RangeQueryBuilder builder = regRangeQ("url", ConditionKey.CK_LESS_THAN, url); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setUrl_GreaterEqual(String url) { + setUrl_GreaterEqual(url, null); + } + + public void setUrl_GreaterEqual(String url, ConditionOptionCall opLambda) { + RangeQueryBuilder builder = regRangeQ("url", ConditionKey.CK_GREATER_EQUAL, url); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setUrl_LessEqual(String url) { + setUrl_LessEqual(url, null); + } + + public void setUrl_LessEqual(String url, ConditionOptionCall opLambda) { + RangeQueryBuilder builder = regRangeQ("url", ConditionKey.CK_LESS_EQUAL, url); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setUrl_Exists() { + setUrl_Exists(null); + } + + public void setUrl_Exists(ConditionOptionCall opLambda) { + ExistsQueryBuilder builder = regExistsQ("url"); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setUrl_CommonTerms(String url) { + setUrl_CommonTerms(url, null); + } + + public void setUrl_CommonTerms(String url, ConditionOptionCall opLambda) { + CommonTermsQueryBuilder builder = regCommonTermsQ("url", url); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public BsThumbnailQueueCQ addOrderBy_Url_Asc() { + regOBA("url"); + return this; + } + + public BsThumbnailQueueCQ addOrderBy_Url_Desc() { + regOBD("url"); + return this; + } + +} diff --git a/src/main/java/org/codelibs/fess/es/config/exbhv/ThumbnailQueueBhv.java b/src/main/java/org/codelibs/fess/es/config/exbhv/ThumbnailQueueBhv.java new file mode 100644 index 000000000..7195f65db --- /dev/null +++ b/src/main/java/org/codelibs/fess/es/config/exbhv/ThumbnailQueueBhv.java @@ -0,0 +1,25 @@ +/* + * Copyright 2012-2016 CodeLibs Project and the Others. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.codelibs.fess.es.config.exbhv; + +import org.codelibs.fess.es.config.bsbhv.BsThumbnailQueueBhv; + +/** + * @author FreeGen + */ +public class ThumbnailQueueBhv extends BsThumbnailQueueBhv { + +} diff --git a/src/main/java/org/codelibs/fess/es/config/exentity/ThumbnailQueue.java b/src/main/java/org/codelibs/fess/es/config/exentity/ThumbnailQueue.java new file mode 100644 index 000000000..e96a50710 --- /dev/null +++ b/src/main/java/org/codelibs/fess/es/config/exentity/ThumbnailQueue.java @@ -0,0 +1,48 @@ +/* + * Copyright 2012-2016 CodeLibs Project and the Others. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.codelibs.fess.es.config.exentity; + +import org.codelibs.fess.es.config.bsentity.BsThumbnailQueue; + +/** + * @author ESFlute (using FreeGen) + */ +public class ThumbnailQueue extends BsThumbnailQueue { + + private static final long serialVersionUID = 1L; + + public String getId() { + return asDocMeta().id(); + } + + public void setId(final String id) { + asDocMeta().id(id); + } + + public Long getVersionNo() { + return asDocMeta().version(); + } + + public void setVersionNo(final Long version) { + asDocMeta().version(version); + } + + @Override + public String toString() { + return "ThumbnailQueue [createdBy=" + createdBy + ", createdTime=" + createdTime + ", generator=" + generator + ", path=" + path + + ", url=" + url + "]"; + } +} diff --git a/src/main/java/org/codelibs/fess/job/GenerateThumbnailJob.java b/src/main/java/org/codelibs/fess/job/GenerateThumbnailJob.java new file mode 100644 index 000000000..73df394b7 --- /dev/null +++ b/src/main/java/org/codelibs/fess/job/GenerateThumbnailJob.java @@ -0,0 +1,40 @@ +/* + * Copyright 2012-2016 CodeLibs Project and the Others. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.codelibs.fess.job; + +import org.codelibs.fess.util.ComponentUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class GenerateThumbnailJob { + private static final Logger logger = LoggerFactory.getLogger(GenerateThumbnailJob.class); + + public String execute() { + int totalCount = 0; + int count = 1; + try { + while (count != 0) { + count = ComponentUtil.getThumbnailManager().generate(); + totalCount += count; + } + return "Created " + totalCount + " thumbnail files."; + } catch (final Exception e) { + logger.error("Failed to purge user info.", e); + return e.getMessage(); + } + } + +} diff --git a/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java b/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java index ef016621e..142d3fc9c 100644 --- a/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java +++ b/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java @@ -637,6 +637,9 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction /** The key of the configuration. e.g. 1000 */ String PAGE_DICTIONARY_MAX_FETCH_SIZE = "page.dictionary.max.fetch.size"; + /** The key of the configuration. e.g. 100 */ + String PAGE_THUMBNAIL_QUEUE_MAX_FETCH_SIZE = "page.thumbnail.queue.max.fetch.size"; + /** The key of the configuration. e.g. 0 */ String PAGING_SEARCH_PAGE_START = "paging.search.page.start"; @@ -3084,6 +3087,21 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction */ Integer getPageDictionaryMaxFetchSizeAsInteger(); + /** + * Get the value for the key 'page.thumbnail.queue.max.fetch.size'.
+ * The value is, e.g. 100
+ * @return The value of found property. (NotNull: if not found, exception but basically no way) + */ + String getPageThumbnailQueueMaxFetchSize(); + + /** + * Get the value for the key 'page.thumbnail.queue.max.fetch.size' as {@link Integer}.
+ * The value is, e.g. 100
+ * @return The value of found property. (NotNull: if not found, exception but basically no way) + * @throws NumberFormatException When the property is not integer. + */ + Integer getPageThumbnailQueueMaxFetchSizeAsInteger(); + /** * Get the value for the key 'paging.search.page.start'.
* The value is, e.g. 0
@@ -5340,6 +5358,14 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction return getAsInteger(FessConfig.PAGE_DICTIONARY_MAX_FETCH_SIZE); } + public String getPageThumbnailQueueMaxFetchSize() { + return get(FessConfig.PAGE_THUMBNAIL_QUEUE_MAX_FETCH_SIZE); + } + + public Integer getPageThumbnailQueueMaxFetchSizeAsInteger() { + return getAsInteger(FessConfig.PAGE_THUMBNAIL_QUEUE_MAX_FETCH_SIZE); + } + public String getPagingSearchPageStart() { return get(FessConfig.PAGING_SEARCH_PAGE_START); } diff --git a/src/main/java/org/codelibs/fess/thumbnail/ThumbnailGenerator.java b/src/main/java/org/codelibs/fess/thumbnail/ThumbnailGenerator.java index 291dce709..bc48f53b7 100644 --- a/src/main/java/org/codelibs/fess/thumbnail/ThumbnailGenerator.java +++ b/src/main/java/org/codelibs/fess/thumbnail/ThumbnailGenerator.java @@ -20,6 +20,8 @@ import java.util.Map; public interface ThumbnailGenerator { + String getName(); + boolean generate(String url, File outputFile); boolean isTarget(Map docMap); diff --git a/src/main/java/org/codelibs/fess/thumbnail/ThumbnailManager.java b/src/main/java/org/codelibs/fess/thumbnail/ThumbnailManager.java index b7b2dec7a..3aaa19a57 100644 --- a/src/main/java/org/codelibs/fess/thumbnail/ThumbnailManager.java +++ b/src/main/java/org/codelibs/fess/thumbnail/ThumbnailManager.java @@ -28,6 +28,8 @@ import java.util.List; import java.util.Map; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; @@ -37,7 +39,10 @@ import javax.servlet.http.HttpSession; import org.codelibs.core.collection.LruHashMap; import org.codelibs.core.lang.StringUtil; +import org.codelibs.core.misc.Tuple3; import org.codelibs.fess.Constants; +import org.codelibs.fess.es.config.exbhv.ThumbnailQueueBhv; +import org.codelibs.fess.es.config.exentity.ThumbnailQueue; import org.codelibs.fess.exception.FessSystemException; import org.codelibs.fess.exception.JobProcessingException; import org.codelibs.fess.mylasta.direction.FessConfig; @@ -61,7 +66,7 @@ public class ThumbnailManager { private final List generatorList = new ArrayList<>(); - private BlockingQueue thumbnailTaskQueue; + private BlockingQueue> thumbnailTaskQueue; private volatile boolean generating; @@ -75,6 +80,10 @@ public class ThumbnailManager { protected int thumbnailTaskQueueSize = 10000; + protected int thumbnailTaskBulkSize = 100; + + protected long thumbnailTaskQueueTimeout = 60 * 1000L; + protected long noImageExpired = 24 * 60 * 60 * 1000L; // 24 hours @PostConstruct @@ -104,9 +113,20 @@ public class ThumbnailManager { thumbnailTaskQueue = new LinkedBlockingQueue<>(thumbnailTaskQueueSize); generating = true; thumbnailGeneratorThread = new Thread((Runnable) () -> { + final List> taskList = new ArrayList<>(); while (generating) { try { - thumbnailTaskQueue.take().generate(); + Tuple3 task = thumbnailTaskQueue.poll(thumbnailTaskQueueTimeout, TimeUnit.MILLISECONDS); + if (task == null) { + if (!taskList.isEmpty()) { + storeQueue(taskList); + } + } else { + taskList.add(task); + if (taskList.size() > thumbnailTaskBulkSize) { + storeQueue(taskList); + } + } } catch (final InterruptedException e) { logger.debug("Interupted task.", e); } catch (final Exception e) { @@ -137,24 +157,64 @@ public class ThumbnailManager { }); } - public void generate(final Map docMap) { + protected void storeQueue(final List> taskList) { + List list = taskList.stream().filter(entity -> entity != null).map(task -> { + ThumbnailQueue entity = new ThumbnailQueue(); + entity.setGenerator(task.getValue1()); + entity.setUrl(task.getValue2()); + entity.setPath(task.getValue3()); + return entity; + }).collect(Collectors.toList()); + taskList.clear(); + final ThumbnailQueueBhv thumbnailQueueBhv = ComponentUtil.getComponent(ThumbnailQueueBhv.class); + thumbnailQueueBhv.batchInsert(list); + } + + public int generate() { final FessConfig fessConfig = ComponentUtil.getFessConfig(); - for (final ThumbnailGenerator generator : generatorList) { - if (generator.isTarget(docMap)) { - final String url = DocumentUtil.getValue(docMap, fessConfig.getIndexFieldUrl(), String.class); - final String path = getImageFilename(docMap); - final File outputFile = new File(baseDir, path); + final List idList = new ArrayList<>(); + final ThumbnailQueueBhv thumbnailQueueBhv = ComponentUtil.getComponent(ThumbnailQueueBhv.class); + thumbnailQueueBhv.selectList(cb -> { + cb.query().addOrderBy_CreatedTime_Asc(); + cb.fetchFirst(fessConfig.getPageThumbnailQueueMaxFetchSizeAsInteger()); + }).forEach(entity -> { + idList.add(entity.getId()); + final String generatorName = entity.getGenerator(); + try { + final ThumbnailGenerator generator = ComponentUtil.getComponent(generatorName); + final File outputFile = new File(baseDir, entity.getPath()); final File noImageFile = new File(outputFile.getAbsolutePath() + NOIMAGE_FILE_SUFFIX); if (!noImageFile.isFile() || System.currentTimeMillis() - noImageFile.lastModified() > noImageExpired) { if (noImageFile.isFile() && !noImageFile.delete()) { logger.warn("Failed to delete " + noImageFile.getAbsolutePath()); } - if (!thumbnailTaskQueue.offer(new ThumbnailTask(url, outputFile, generator))) { - logger.warn("Failed to offer a thumbnail task: " + url + " -> " + path); + if (!generator.generate(entity.getUrl(), outputFile)) { + new File(outputFile.getAbsolutePath() + NOIMAGE_FILE_SUFFIX).setLastModified(System.currentTimeMillis()); } } else if (logger.isDebugEnabled()) { logger.debug("No image file exists: " + noImageFile.getAbsolutePath()); } + } catch (final Exception e) { + logger.warn("Failed to create thumbnail for " + entity, e); + } + }); + if (!idList.isEmpty()) { + thumbnailQueueBhv.queryDelete(cb -> { + cb.query().setId_InScope(idList); + }); + thumbnailQueueBhv.refresh(); + } + return idList.size(); + } + + public void offer(final Map docMap) { + final FessConfig fessConfig = ComponentUtil.getFessConfig(); + for (final ThumbnailGenerator generator : generatorList) { + if (generator.isTarget(docMap)) { + final String url = DocumentUtil.getValue(docMap, fessConfig.getIndexFieldUrl(), String.class); + final String path = getImageFilename(docMap); + Tuple3 task = new Tuple3(generator.getName(), url, path); + thumbnailTaskQueue.offer(task); break; } } @@ -283,66 +343,6 @@ public class ThumbnailManager { } - protected static class ThumbnailTask { - - String url; - - File outputFile; - - ThumbnailGenerator generator; - - protected ThumbnailTask(final String url, final File outputFile, final ThumbnailGenerator generator) { - this.url = url; - this.outputFile = outputFile; - this.generator = generator; - } - - public void generate() { - if (!generator.generate(url, outputFile)) { - new File(outputFile.getAbsolutePath() + NOIMAGE_FILE_SUFFIX).setLastModified(System.currentTimeMillis()); - } - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (outputFile == null ? 0 : outputFile.hashCode()); - result = prime * result + (url == null ? 0 : url.hashCode()); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final ThumbnailTask other = (ThumbnailTask) obj; - if (outputFile == null) { - if (other.outputFile != null) { - return false; - } - } else if (!outputFile.equals(other.outputFile)) { - return false; - } - if (url == null) { - if (other.url != null) { - return false; - } - } else if (!url.equals(other.url)) { - return false; - } - return true; - } - - } - public void setThumbnailPathCacheSize(final int thumbnailPathCacheSize) { this.thumbnailPathCacheSize = thumbnailPathCacheSize; } diff --git a/src/main/java/org/codelibs/fess/thumbnail/impl/BaseThumbnailGenerator.java b/src/main/java/org/codelibs/fess/thumbnail/impl/BaseThumbnailGenerator.java index ed9da7be0..2a660ee5e 100644 --- a/src/main/java/org/codelibs/fess/thumbnail/impl/BaseThumbnailGenerator.java +++ b/src/main/java/org/codelibs/fess/thumbnail/impl/BaseThumbnailGenerator.java @@ -41,6 +41,8 @@ public abstract class BaseThumbnailGenerator implements ThumbnailGenerator { protected Map filePathMap = new HashMap<>(); + protected String name; + public void addCondition(final String key, final String regex) { conditionMap.put(key, regex); } @@ -103,4 +105,12 @@ public abstract class BaseThumbnailGenerator implements ThumbnailGenerator { this.generatorList = generatorList; } + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + } \ No newline at end of file diff --git a/src/main/resources/esclient.xml b/src/main/resources/esclient.xml index 402c6bc91..e2f25c9eb 100644 --- a/src/main/resources/esclient.xml +++ b/src/main/resources/esclient.xml @@ -204,6 +204,9 @@ ".fess_config/web_config_to_role" + + ".fess_config/thumbnail_queue" + ".fess_user/user" diff --git a/src/main/resources/esflute_config.xml b/src/main/resources/esflute_config.xml index 975e2ac25..3dc7412f0 100644 --- a/src/main/resources/esflute_config.xml +++ b/src/main/resources/esflute_config.xml @@ -9,6 +9,7 @@ + @@ -16,6 +17,8 @@ + + @@ -29,9 +32,7 @@ - - - + diff --git a/src/main/resources/fess_config.properties b/src/main/resources/fess_config.properties index d7f49e063..1f465e316 100644 --- a/src/main/resources/fess_config.properties +++ b/src/main/resources/fess_config.properties @@ -341,6 +341,7 @@ page.search.field.log.max.fetch.size=100 page.elevate.word.max.fetch.size=1000 page.bad.word.max.fetch.size=1000 page.dictionary.max.fetch.size=1000 +page.thumbnail.queue.max.fetch.size=100 # search page paging.search.page.start=0 diff --git a/src/main/resources/fess_indices/.fess_config/alias/.fess_basic_config.json b/src/main/resources/fess_indices/.fess_config/alias/.fess_basic_config.json index 8b2571b0b..8770ab3a5 100644 --- a/src/main/resources/fess_indices/.fess_config/alias/.fess_basic_config.json +++ b/src/main/resources/fess_indices/.fess_config/alias/.fess_basic_config.json @@ -20,6 +20,11 @@ "type": { "value": "job_log" } + }, + { + "type": { + "value": "thumbnail_queue" + } } ] } diff --git a/src/main/resources/fess_indices/.fess_config/scheduled_job.bulk b/src/main/resources/fess_indices/.fess_config/scheduled_job.bulk index 96f2116c0..3d51200b4 100644 --- a/src/main/resources/fess_indices/.fess_config/scheduled_job.bulk +++ b/src/main/resources/fess_indices/.fess_config/scheduled_job.bulk @@ -8,7 +8,9 @@ {"name":"Log Purger","target":"all","cronExpression":"0 0 * * *","scriptType":"groovy","scriptData":"return container.getComponent(\"purgeLogJob\").execute();","jobLogging":false,"crawler":false,"available":true,"sortOrder":4,"createdBy":"system","createdTime":0,"updatedBy":"system","updatedTime":0} {"index":{"_index":".fess_config","_type":"scheduled_job","_id":"doc_purger"}} {"name":"Doc Purger","target":"all","cronExpression":"* * * * *","scriptType":"groovy","scriptData":"return container.getComponent(\"purgeDocJob\").execute();","jobLogging":false,"crawler":false,"available":true,"sortOrder":5,"createdBy":"system","createdTime":0,"updatedBy":"system","updatedTime":0} +{"index":{"_index":".fess_config","_type":"scheduled_job","_id":"thumbnail_generate"}} +{"name":"Thumbnail Generator","target":"all","cronExpression":"* * * * *","scriptType":"groovy","scriptData":"return container.getComponent(\"generateThumbnailJob\").execute();","jobLogging":false,"crawler":false,"available":true,"sortOrder":6,"createdBy":"system","createdTime":0,"updatedBy":"system","updatedTime":0} {"index":{"_index":".fess_config","_type":"scheduled_job","_id":"thumbnail_purger"}} -{"name":"Thumbnail Purger","target":"all","cronExpression":"0 0 * * *","scriptType":"groovy","scriptData":"return container.getComponent(\"purgeThumbnailJob\").expiry(30 * 24 * 60 * 60 * 1000).execute();","jobLogging":true,"crawler":false,"available":true,"sortOrder":6,"createdBy":"system","createdTime":0,"updatedBy":"system","updatedTime":0} +{"name":"Thumbnail Purger","target":"all","cronExpression":"0 0 * * *","scriptType":"groovy","scriptData":"return container.getComponent(\"purgeThumbnailJob\").expiry(30 * 24 * 60 * 60 * 1000).execute();","jobLogging":true,"crawler":false,"available":true,"sortOrder":7,"createdBy":"system","createdTime":0,"updatedBy":"system","updatedTime":0} {"index":{"_index":".fess_config","_type":"scheduled_job","_id":"ping_es"}} -{"name":"Ping Elasticsearch","target":"all","cronExpression":"* * * * *","scriptType":"groovy","scriptData":"return container.getComponent(\"pingEsJob\").execute();","jobLogging":false,"crawler":false,"available":true,"sortOrder":7,"createdBy":"system","createdTime":0,"updatedBy":"system","updatedTime":0} +{"name":"Ping Elasticsearch","target":"all","cronExpression":"* * * * *","scriptType":"groovy","scriptData":"return container.getComponent(\"pingEsJob\").execute();","jobLogging":false,"crawler":false,"available":true,"sortOrder":8,"createdBy":"system","createdTime":0,"updatedBy":"system","updatedTime":0} diff --git a/src/main/resources/fess_indices/.fess_config/thumbnail_queue.json b/src/main/resources/fess_indices/.fess_config/thumbnail_queue.json new file mode 100644 index 000000000..39534599e --- /dev/null +++ b/src/main/resources/fess_indices/.fess_config/thumbnail_queue.json @@ -0,0 +1,31 @@ +{ + "thumbnail_queue": { + "_source": { + "enabled": true + }, + "_all": { + "enabled": false + }, + "properties": { + "url": { + "type": "string", + "index": "not_analyzed" + }, + "path": { + "type": "string", + "index": "not_analyzed" + }, + "generator": { + "type": "string", + "index": "not_analyzed" + }, + "createdTime": { + "type": "long" + }, + "createdBy": { + "type": "string", + "index": "not_analyzed" + } + } + } +} diff --git a/src/main/resources/fess_job.xml b/src/main/resources/fess_job.xml index 44396194b..e73875d2a 100644 --- a/src/main/resources/fess_job.xml +++ b/src/main/resources/fess_job.xml @@ -16,6 +16,8 @@ + + diff --git a/src/main/resources/fess_thumbnail.xml b/src/main/resources/fess_thumbnail.xml index b331b824c..e30649d71 100644 --- a/src/main/resources/fess_thumbnail.xml +++ b/src/main/resources/fess_thumbnail.xml @@ -11,6 +11,7 @@ + "htmlThumbnailGenerator" ["${path}/phantomjs"] @@ -29,6 +30,7 @@ + "msofficeThumbnailGenerator" ["${path}/generate-thumbnail", "msoffice",