use of org.codelibs.fess.mylasta.direction.FessConfig in project fess by codelibs.
the class AdminSearchlistAction method validateCreateFields.
// ===================================================================================
// Validation
// =========
public static void validateCreateFields(final CreateForm form, final Consumer<VaMessenger<FessMessages>> throwError) {
final FessConfig fessConfig = ComponentUtil.getFessConfig();
if (!fessConfig.validateIndexRequiredFields(form.doc)) {
final List<String> invalidRequiredFields = fessConfig.invalidIndexRequiredFields(form.doc);
throwError.accept(messages -> {
messages.addErrorsCrudFailedToCreateInstance("doc." + invalidRequiredFields.get(0));
});
}
if (!fessConfig.validateIndexArrayFields(form.doc)) {
final List<String> invalidArrayFields = fessConfig.invalidIndexArrayFields(form.doc);
throwError.accept(messages -> {
messages.addErrorsCrudFailedToCreateInstance("doc." + invalidArrayFields.get(0));
});
}
if (!fessConfig.validateIndexDateFields(form.doc)) {
final List<String> invalidDateFields = fessConfig.invalidIndexDateFields(form.doc);
throwError.accept(messages -> {
messages.addErrorsCrudFailedToCreateInstance("doc." + invalidDateFields.get(0));
});
}
if (!fessConfig.validateIndexIntegerFields(form.doc)) {
final List<String> invalidIntegerFields = fessConfig.invalidIndexIntegerFields(form.doc);
throwError.accept(messages -> {
messages.addErrorsCrudFailedToCreateInstance("doc." + invalidIntegerFields.get(0));
});
}
if (!fessConfig.validateIndexLongFields(form.doc)) {
final List<String> invalidLongFields = fessConfig.invalidIndexLongFields(form.doc);
throwError.accept(messages -> {
messages.addErrorsCrudFailedToCreateInstance("doc." + invalidLongFields.get(0));
});
}
if (!fessConfig.validateIndexFloatFields(form.doc)) {
final List<String> invalidFloatFields = fessConfig.invalidIndexFloatFields(form.doc);
throwError.accept(messages -> {
messages.addErrorsCrudFailedToCreateInstance("doc." + invalidFloatFields.get(0));
});
}
if (!fessConfig.validateIndexDoubleFields(form.doc)) {
final List<String> invalidDoubleFields = fessConfig.invalidIndexDoubleFields(form.doc);
throwError.accept(messages -> {
messages.addErrorsCrudFailedToCreateInstance("doc." + invalidDoubleFields.get(0));
});
}
}
use of org.codelibs.fess.mylasta.direction.FessConfig in project fess by codelibs.
the class AdminSearchlistAction method validateUpdateFields.
public static void validateUpdateFields(final EditForm form, final Consumer<VaMessenger<FessMessages>> throwError) {
final FessConfig fessConfig = ComponentUtil.getFessConfig();
if (!fessConfig.validateIndexRequiredFields(form.doc)) {
final List<String> invalidRequiredFields = fessConfig.invalidIndexRequiredFields(form.doc);
throwError.accept(messages -> {
messages.addErrorsCrudCouldNotFindCrudTable("doc." + invalidRequiredFields.get(0), form.docId);
});
}
if (!fessConfig.validateIndexArrayFields(form.doc)) {
final List<String> invalidArrayFields = fessConfig.invalidIndexArrayFields(form.doc);
throwError.accept(messages -> {
messages.addErrorsCrudCouldNotFindCrudTable("doc." + invalidArrayFields.get(0), form.docId);
});
}
if (!fessConfig.validateIndexDateFields(form.doc)) {
final List<String> invalidDateFields = fessConfig.invalidIndexDateFields(form.doc);
throwError.accept(messages -> {
messages.addErrorsCrudCouldNotFindCrudTable("doc." + invalidDateFields.get(0), form.docId);
});
}
if (!fessConfig.validateIndexIntegerFields(form.doc)) {
final List<String> invalidIntegerFields = fessConfig.invalidIndexIntegerFields(form.doc);
throwError.accept(messages -> {
messages.addErrorsCrudCouldNotFindCrudTable("doc." + invalidIntegerFields.get(0), form.docId);
});
}
if (!fessConfig.validateIndexLongFields(form.doc)) {
final List<String> invalidLongFields = fessConfig.invalidIndexLongFields(form.doc);
throwError.accept(messages -> {
messages.addErrorsCrudCouldNotFindCrudTable("doc." + invalidLongFields.get(0), form.docId);
});
}
if (!fessConfig.validateIndexFloatFields(form.doc)) {
final List<String> invalidFloatFields = fessConfig.invalidIndexFloatFields(form.doc);
throwError.accept(messages -> {
messages.addErrorsCrudCouldNotFindCrudTable("doc." + invalidFloatFields.get(0), form.docId);
});
}
if (!fessConfig.validateIndexDoubleFields(form.doc)) {
final List<String> invalidDoubleFields = fessConfig.invalidIndexDoubleFields(form.doc);
throwError.accept(messages -> {
messages.addErrorsCrudCouldNotFindCrudTable("doc." + invalidDoubleFields.get(0), form.docId);
});
}
}
use of org.codelibs.fess.mylasta.direction.FessConfig in project fess by codelibs.
the class FessCrawlerThread method getChildUrlSet.
protected Set<RequestData> getChildUrlSet(final FessEsClient fessEsClient, final String id) {
final FessConfig fessConfig = ComponentUtil.getFessConfig();
final IndexingHelper indexingHelper = ComponentUtil.getIndexingHelper();
final List<Map<String, Object>> docList = indexingHelper.getChildDocumentList(fessEsClient, id, new String[] { fessConfig.getIndexFieldUrl() });
if (docList.isEmpty()) {
return null;
}
if (logger.isDebugEnabled()) {
logger.debug("Found documents: " + docList);
}
final Set<RequestData> urlSet = new HashSet<>(docList.size());
for (final Map<String, Object> doc : docList) {
final String url = DocumentUtil.getValue(doc, fessConfig.getIndexFieldUrl(), String.class);
if (StringUtil.isNotBlank(url)) {
urlSet.add(RequestDataBuilder.newRequestData().get().url(url).build());
}
}
return urlSet;
}
use of org.codelibs.fess.mylasta.direction.FessConfig in project fess by codelibs.
the class FessEsClient method getDocumentList.
public List<Map<String, Object>> getDocumentList(final String index, final String type, final SearchCondition<SearchRequestBuilder> condition) {
return getDocumentList(index, type, condition, (response, hit) -> {
final FessConfig fessConfig = ComponentUtil.getFessConfig();
final Map<String, Object> source = hit.getSource();
if (source != null) {
final Map<String, Object> docMap = new HashMap<>(source);
docMap.put(fessConfig.getIndexFieldId(), hit.getId());
return docMap;
}
final Map<String, SearchHitField> fields = hit.getFields();
if (fields != null) {
final Map<String, Object> docMap = fields.entrySet().stream().collect(Collectors.toMap(e -> e.getKey(), e -> (Object) e.getValue().getValues()));
docMap.put(fessConfig.getIndexFieldId(), hit.getId());
return docMap;
}
return null;
});
}
use of org.codelibs.fess.mylasta.direction.FessConfig in project fess by codelibs.
the class FessEsClient method getDocument.
public OptionalEntity<Map<String, Object>> getDocument(final String index, final String type, final SearchCondition<SearchRequestBuilder> condition) {
return getDocument(index, type, condition, (response, hit) -> {
final FessConfig fessConfig = ComponentUtil.getFessConfig();
final Map<String, Object> source = hit.getSource();
if (source != null) {
final Map<String, Object> docMap = new HashMap<>(source);
docMap.put(fessConfig.getIndexFieldId(), hit.getId());
docMap.put(fessConfig.getIndexFieldVersion(), hit.getVersion());
return docMap;
}
final Map<String, SearchHitField> fields = hit.getFields();
if (fields != null) {
final Map<String, Object> docMap = fields.entrySet().stream().collect(Collectors.toMap(e -> e.getKey(), e -> (Object) e.getValue().getValues()));
docMap.put(fessConfig.getIndexFieldId(), hit.getId());
docMap.put(fessConfig.getIndexFieldVersion(), hit.getVersion());
return docMap;
}
return null;
});
}
Aggregations