Search in sources :

Example 1 with AttributeSearchInfo

use of com.agiletec.aps.system.common.entity.model.AttributeSearchInfo in project entando-core by entando.

the class DateAttribute method getSearchInfos.

@Override
public List<AttributeSearchInfo> getSearchInfos(List<Lang> systemLangs) {
    if (this.getDate() != null) {
        List<AttributeSearchInfo> infos = new ArrayList<>();
        AttributeSearchInfo info = new AttributeSearchInfo(null, this.getDate(), null, null);
        infos.add(info);
        return infos;
    }
    return null;
}
Also used : ArrayList(java.util.ArrayList) AttributeSearchInfo(com.agiletec.aps.system.common.entity.model.AttributeSearchInfo)

Example 2 with AttributeSearchInfo

use of com.agiletec.aps.system.common.entity.model.AttributeSearchInfo in project entando-core by entando.

the class MonoTextAttribute method getSearchInfos.

@Override
public List<AttributeSearchInfo> getSearchInfos(List<Lang> systemLangs) {
    if (this.getText() != null) {
        List<AttributeSearchInfo> infos = new ArrayList<>();
        String text = this.getText();
        if (text != null && text.length() >= 255) {
            text = text.substring(0, 254);
        }
        AttributeSearchInfo info = new AttributeSearchInfo(text, null, null, null);
        infos.add(info);
        return infos;
    }
    return null;
}
Also used : ArrayList(java.util.ArrayList) AttributeSearchInfo(com.agiletec.aps.system.common.entity.model.AttributeSearchInfo)

Example 3 with AttributeSearchInfo

use of com.agiletec.aps.system.common.entity.model.AttributeSearchInfo in project entando-core by entando.

the class NumberAttribute method getSearchInfos.

@Override
public List<AttributeSearchInfo> getSearchInfos(List<Lang> systemLangs) {
    if (this.getValue() != null) {
        List<AttributeSearchInfo> infos = new ArrayList<>();
        AttributeSearchInfo info = new AttributeSearchInfo(null, null, this.getValue(), null);
        infos.add(info);
        return infos;
    }
    return null;
}
Also used : ArrayList(java.util.ArrayList) AttributeSearchInfo(com.agiletec.aps.system.common.entity.model.AttributeSearchInfo)

Example 4 with AttributeSearchInfo

use of com.agiletec.aps.system.common.entity.model.AttributeSearchInfo in project entando-core by entando.

the class AbstractEntityDAO method addEntitySearchRecord.

protected void addEntitySearchRecord(String id, IApsEntity entity, PreparedStatement stat) throws Throwable {
    EntityAttributeIterator attributeIter = new EntityAttributeIterator(entity);
    while (attributeIter.hasNext()) {
        AttributeInterface currAttribute = (AttributeInterface) attributeIter.next();
        List<AttributeSearchInfo> infos = currAttribute.getSearchInfos(this.getLangManager().getLangs());
        if (currAttribute.isSearchable() && null != infos) {
            for (int i = 0; i < infos.size(); i++) {
                AttributeSearchInfo searchInfo = infos.get(i);
                stat.setString(1, id);
                stat.setString(2, currAttribute.getName());
                stat.setString(3, searchInfo.getString());
                if (searchInfo.getDate() != null) {
                    stat.setTimestamp(4, new java.sql.Timestamp(searchInfo.getDate().getTime()));
                } else {
                    stat.setDate(4, null);
                }
                stat.setBigDecimal(5, searchInfo.getBigDecimal());
                stat.setString(6, searchInfo.getLangCode());
                stat.addBatch();
                stat.clearParameters();
            }
        }
    }
    stat.executeBatch();
}
Also used : AttributeSearchInfo(com.agiletec.aps.system.common.entity.model.AttributeSearchInfo) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface) EntityAttributeIterator(com.agiletec.aps.system.common.util.EntityAttributeIterator)

Example 5 with AttributeSearchInfo

use of com.agiletec.aps.system.common.entity.model.AttributeSearchInfo in project entando-core by entando.

the class IndexerDAO method indexAttribute.

private void indexAttribute(Document document, AttributeInterface attribute, Lang lang) throws ApsSystemException {
    attribute.setRenderingLang(lang.getCode());
    if (attribute instanceof IndexableAttributeInterface) {
        String valueToIndex = ((IndexableAttributeInterface) attribute).getIndexeableFieldValue();
        String indexingType = attribute.getIndexingType();
        String fieldName = lang.getCode();
        if (null != indexingType && IndexableAttributeInterface.INDEXING_TYPE_UNSTORED.equalsIgnoreCase(indexingType)) {
            document.add(new TextField(fieldName, valueToIndex, Field.Store.NO));
        }
        if (null != indexingType && IndexableAttributeInterface.INDEXING_TYPE_TEXT.equalsIgnoreCase(indexingType)) {
            document.add(new TextField(fieldName, valueToIndex, Field.Store.YES));
        }
    }
    if (attribute.isSearchable()) {
        List<Lang> langs = new ArrayList<Lang>();
        langs.add(lang);
        AttributeTracer tracer = new AttributeTracer();
        tracer.setLang(lang);
        String name = tracer.getFormFieldName(attribute);
        List<AttributeSearchInfo> searchInfos = attribute.getSearchInfos(langs);
        if (null != searchInfos) {
            for (int i = 0; i < searchInfos.size(); i++) {
                AttributeSearchInfo info = searchInfos.get(i);
                Field field = null;
                if (null != info.getDate()) {
                    field = new TextField(name, DateTools.timeToString(info.getDate().getTime(), DateTools.Resolution.MINUTE), Field.Store.YES);
                } else if (null != info.getBigDecimal()) {
                    field = new IntField(name, info.getBigDecimal().intValue(), Field.Store.YES);
                } else {
                    field = new TextField(name, info.getString(), Field.Store.YES);
                }
                document.add(field);
            }
        }
    }
}
Also used : StringField(org.apache.lucene.document.StringField) Field(org.apache.lucene.document.Field) TextField(org.apache.lucene.document.TextField) IntField(org.apache.lucene.document.IntField) AttributeTracer(com.agiletec.aps.system.common.entity.model.AttributeTracer) ArrayList(java.util.ArrayList) TextField(org.apache.lucene.document.TextField) Lang(com.agiletec.aps.system.services.lang.Lang) IntField(org.apache.lucene.document.IntField) AttributeSearchInfo(com.agiletec.aps.system.common.entity.model.AttributeSearchInfo) IndexableAttributeInterface(com.agiletec.aps.system.common.searchengine.IndexableAttributeInterface)

Aggregations

AttributeSearchInfo (com.agiletec.aps.system.common.entity.model.AttributeSearchInfo)8 ArrayList (java.util.ArrayList)6 Lang (com.agiletec.aps.system.services.lang.Lang)3 AttributeTracer (com.agiletec.aps.system.common.entity.model.AttributeTracer)2 IndexableAttributeInterface (com.agiletec.aps.system.common.searchengine.IndexableAttributeInterface)2 Field (org.apache.lucene.document.Field)2 IntField (org.apache.lucene.document.IntField)2 StringField (org.apache.lucene.document.StringField)2 TextField (org.apache.lucene.document.TextField)2 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)1 EntityAttributeIterator (com.agiletec.aps.system.common.util.EntityAttributeIterator)1 ResourceAttributeInterface (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.ResourceAttributeInterface)1