View Javadoc
1   /*
2    * Copyright 2012-2025 CodeLibs Project and the Others.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13   * either express or implied. See the License for the specific language
14   * governing permissions and limitations under the License.
15   */
16  package org.codelibs.fess.opensearch.config.exentity;
17  
18  import java.util.Locale;
19  
20  import org.codelibs.fess.opensearch.config.bsentity.BsCrawlingInfoParam;
21  import org.codelibs.fess.opensearch.config.exbhv.CrawlingInfoBhv;
22  import org.codelibs.fess.util.ComponentUtil;
23  import org.dbflute.optional.OptionalEntity;
24  
25  /**
26   * @author ESFlute (using FreeGen)
27   */
28  public class CrawlingInfoParam extends BsCrawlingInfoParam {
29  
30      private static final long serialVersionUID = 1L;
31  
32      private OptionalEntity<CrawlingInfo> crawlingInfo;
33  
34      public String getId() {
35          return asDocMeta().id();
36      }
37  
38      public void setId(final String id) {
39          asDocMeta().id(id);
40      }
41  
42      public Long getVersionNo() {
43          return asDocMeta().version();
44      }
45  
46      public void setVersionNo(final Long version) {
47          asDocMeta().version(version);
48      }
49  
50      public OptionalEntity<CrawlingInfo> getCrawlingInfo() {
51          if (crawlingInfo != null) {
52              final CrawlingInfoBhv crawlingInfoBhv = ComponentUtil.getComponent(CrawlingInfoBhv.class);
53              crawlingInfo = crawlingInfoBhv.selectEntity(cb -> {
54                  cb.query().docMeta().setId_Equal(getCrawlingInfoId());
55              });
56          }
57          return crawlingInfo;
58      }
59  
60      public String getKeyMsg() {
61          final Locale locale = ComponentUtil.getRequestManager().getUserLocale();
62          final String message = ComponentUtil.getMessageManager().getMessage(locale, "labels.crawling_info_" + getKey());
63          if (message == null || message.startsWith("???")) {
64              return getKey();
65          }
66          return message;
67      }
68  
69      @Override
70      public String toString() {
71          return "CrawlingInfoParam [crawlingInfo=" + crawlingInfo + ", crawlingInfoId=" + crawlingInfoId + ", createdTime=" + createdTime
72                  + ", key=" + key + ", value=" + value + ", docMeta=" + docMeta + "]";
73      }
74  
75  }