Search in sources :

Example 76 with AttributeInterface

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

the class UserFilterOptionBean method extractFormParameters.

protected void extractFormParameters(HttpServletRequest request) throws Throwable {
    String[] formFieldNames = null;
    try {
        String frameIdSuffix = (null != this.getCurrentFrame()) ? "_frame" + this.getCurrentFrame().toString() : "";
        if (!this.isAttributeFilter()) {
            if (this.getKey().equals(KEY_FULLTEXT)) {
                String fieldName = TYPE_METADATA + "_fulltext" + frameIdSuffix;
                String[] fieldsSuffix = { "", "_option", "_attachSearch" };
                formFieldNames = this.extractParams(fieldName, fieldsSuffix, frameIdSuffix, request);
            } else if (this.getKey().equals(KEY_CATEGORY)) {
                formFieldNames = new String[1];
                formFieldNames[0] = TYPE_METADATA + "_category" + frameIdSuffix;
                String value = request.getParameter(formFieldNames[0]);
                this.addFormValue(formFieldNames[0], value, formFieldNames.length);
            }
        } else {
            AttributeInterface attribute = this.getAttribute();
            if (attribute instanceof ITextAttribute) {
                String[] fieldsSuffix = { "_textFieldName" };
                formFieldNames = this.extractAttributeParams(fieldsSuffix, frameIdSuffix, request);
            } else if (attribute instanceof DateAttribute) {
                String[] fieldsSuffix = { "_dateStartFieldName", "_dateEndFieldName" };
                formFieldNames = this.extractAttributeParams(fieldsSuffix, frameIdSuffix, request);
                this.checkRange(formFieldNames);
            } else if (attribute instanceof BooleanAttribute) {
                String[] fieldsSuffix = { "_booleanFieldName", "_booleanFieldName_ignore", "_booleanFieldName_control" };
                formFieldNames = this.extractAttributeParams(fieldsSuffix, frameIdSuffix, request);
            } else if (attribute instanceof NumberAttribute) {
                String[] fieldsSuffix = { "_numberStartFieldName", "_numberEndFieldName" };
                formFieldNames = this.extractAttributeParams(fieldsSuffix, frameIdSuffix, request);
                this.checkRange(formFieldNames);
            }
        }
    } catch (Throwable t) {
        _logger.error("Error extracting form parameters", t);
        throw new ApsSystemException("Error extracting form parameters", t);
    }
    this.setFormFieldNames(formFieldNames);
}
Also used : ITextAttribute(com.agiletec.aps.system.common.entity.model.attribute.ITextAttribute) BooleanAttribute(com.agiletec.aps.system.common.entity.model.attribute.BooleanAttribute) NumberAttribute(com.agiletec.aps.system.common.entity.model.attribute.NumberAttribute) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface) DateAttribute(com.agiletec.aps.system.common.entity.model.attribute.DateAttribute)

Example 77 with AttributeInterface

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

the class IndexerDAO method createDocument.

/**
 * Crea un oggetto Document pronto per l'indicizzazione da un oggetto
 * Content.
 *
 * @param entity Il dataobject dal quale ricavare il Document.
 * @return L'oggetto Document ricavato dal dataobject.
 * @throws ApsSystemException In caso di errore
 */
protected Document createDocument(IApsEntity entity) throws ApsSystemException {
    Document document = new Document();
    document.add(new StringField(DATAOBJECT_ID_FIELD_NAME, entity.getId(), Field.Store.YES));
    document.add(new TextField(DATAOBJECT_TYPE_FIELD_NAME, entity.getTypeCode(), Field.Store.YES));
    document.add(new StringField(DATAOBJECT_GROUP_FIELD_NAME, entity.getMainGroup(), Field.Store.YES));
    Iterator<String> iterGroups = entity.getGroups().iterator();
    while (iterGroups.hasNext()) {
        String groupName = (String) iterGroups.next();
        document.add(new StringField(DATAOBJECT_GROUP_FIELD_NAME, groupName, Field.Store.YES));
    }
    try {
        EntityAttributeIterator attributesIter = new EntityAttributeIterator(entity);
        while (attributesIter.hasNext()) {
            AttributeInterface currentAttribute = (AttributeInterface) attributesIter.next();
            List<Lang> langs = this.getLangManager().getLangs();
            for (int i = 0; i < langs.size(); i++) {
                Lang currentLang = (Lang) langs.get(i);
                this.indexAttribute(document, currentAttribute, currentLang);
            }
        }
        List<Category> categories = entity.getCategories();
        if (null != categories && !categories.isEmpty()) {
            for (int i = 0; i < categories.size(); i++) {
                Category category = categories.get(i);
                this.indexCategory(document, category);
            }
        }
    } catch (Throwable t) {
        _logger.error("Error creating document", t);
        throw new ApsSystemException("Error creating document", t);
    }
    return document;
}
Also used : Category(com.agiletec.aps.system.services.category.Category) Lang(com.agiletec.aps.system.services.lang.Lang) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) Document(org.apache.lucene.document.Document) StringField(org.apache.lucene.document.StringField) TextField(org.apache.lucene.document.TextField) IndexableAttributeInterface(com.agiletec.aps.system.common.searchengine.IndexableAttributeInterface) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface) EntityAttributeIterator(com.agiletec.aps.system.common.util.EntityAttributeIterator)

Example 78 with AttributeInterface

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

the class SearchEngineManager method verifyReloadingNeeded.

protected boolean verifyReloadingNeeded(IApsEntity oldEntityType, IApsEntity newEntityType) {
    List<AttributeInterface> attributes = oldEntityType.getAttributeList();
    for (int i = 0; i < attributes.size(); i++) {
        AttributeInterface oldAttribute = attributes.get(i);
        AttributeInterface newAttribute = (AttributeInterface) newEntityType.getAttribute(oldAttribute.getName());
        boolean isOldAttributeIndexeable = (oldAttribute.getIndexingType() != null && oldAttribute.getIndexingType().equalsIgnoreCase(IndexableAttributeInterface.INDEXING_TYPE_TEXT));
        boolean isNewAttributeIndexeable = (newAttribute != null && newAttribute.getIndexingType() != null && newAttribute.getIndexingType().equalsIgnoreCase(IndexableAttributeInterface.INDEXING_TYPE_TEXT));
        if ((isOldAttributeIndexeable && !isNewAttributeIndexeable) || (!isOldAttributeIndexeable && isNewAttributeIndexeable)) {
            return true;
        }
    }
    return false;
}
Also used : IndexableAttributeInterface(com.agiletec.aps.system.common.searchengine.IndexableAttributeInterface) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 79 with AttributeInterface

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

the class TestApiContentInterface method testCreateNewContent.

protected void testCreateNewContent(MediaType mediaType, String contentId) throws Throwable {
    String dateNow = DateConverter.getFormattedDate(new Date(), JacmsSystemConstants.CONTENT_METADATA_DATE_FORMAT);
    EntitySearchFilter filter = new EntitySearchFilter(IContentManager.CONTENT_CREATION_DATE_FILTER_KEY, false, dateNow, null);
    EntitySearchFilter[] filters = { filter };
    List<String> ids = this._contentManager.searchId(filters);
    assertTrue(ids.isEmpty());
    JAXBContent jaxbContent = this.testGetContent(mediaType, "admin", contentId, "it");
    ApiResource contentResource = this.getApiCatalogManager().getResource("jacms", "content");
    ApiMethod postMethod = contentResource.getPostMethod();
    Properties properties = super.createApiProperties("admin", "it", mediaType);
    try {
        jaxbContent.setId(null);
        Object response = this.getResponseBuilder().createResponse(postMethod, jaxbContent, properties);
        assertNotNull(response);
        assertTrue(response instanceof StringApiResponse);
        assertEquals(IResponseBuilder.SUCCESS, ((StringApiResponse) response).getResult());
        ids = this._contentManager.searchId(filters);
        assertEquals(1, ids.size());
        String newContentId = ids.get(0);
        Content newContent = this._contentManager.loadContent(newContentId, false);
        Content masterContent = this._contentManager.loadContent(contentId, true);
        List<AttributeInterface> attributes = masterContent.getAttributeList();
        for (int i = 0; i < attributes.size(); i++) {
            AttributeInterface attribute = attributes.get(i);
            AttributeInterface newAttribute = (AttributeInterface) newContent.getAttribute(attribute.getName());
            this.checkAttributes(attribute, newAttribute);
        }
    } catch (Exception e) {
        throw e;
    } finally {
        ids = this._contentManager.searchId(filters);
        if (!ids.isEmpty()) {
            for (int i = 0; i < ids.size(); i++) {
                String id = ids.get(i);
                Content content = this._contentManager.loadContent(id, false);
                this._contentManager.deleteContent(content);
            }
        }
    }
}
Also used : ApiResource(org.entando.entando.aps.system.services.api.model.ApiResource) ApiMethod(org.entando.entando.aps.system.services.api.model.ApiMethod) Properties(java.util.Properties) Date(java.util.Date) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) JAXBContent(org.entando.entando.plugins.jacms.aps.system.services.api.model.JAXBContent) JAXBContent(org.entando.entando.plugins.jacms.aps.system.services.api.model.JAXBContent) EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter) StringApiResponse(org.entando.entando.aps.system.services.api.model.StringApiResponse) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 80 with AttributeInterface

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

the class JAXBUserProfile method valorizeTextAttribute.

private void valorizeTextAttribute(String attributeName, String value, IUserProfile profile) {
    if (null == attributeName || value == null) {
        return;
    }
    AttributeInterface attribute = (AttributeInterface) profile.getAttribute(attributeName);
    if (null == attribute || !(attribute instanceof AbstractTextAttribute)) {
        return;
    }
    AbstractTextAttribute textAttribute = (AbstractTextAttribute) attribute;
    textAttribute.setText(value, null);
}
Also used : AbstractTextAttribute(com.agiletec.aps.system.common.entity.model.attribute.AbstractTextAttribute) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Aggregations

AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)147 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)55 AttributeTracer (com.agiletec.aps.system.common.entity.model.AttributeTracer)38 MonoListAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)37 CompositeAttribute (com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute)27 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)22 ArrayList (java.util.ArrayList)18 IApsEntity (com.agiletec.aps.system.common.entity.model.IApsEntity)17 ITextAttribute (com.agiletec.aps.system.common.entity.model.attribute.ITextAttribute)16 DateAttribute (com.agiletec.aps.system.common.entity.model.attribute.DateAttribute)14 NumberAttribute (com.agiletec.aps.system.common.entity.model.attribute.NumberAttribute)12 ListAttribute (com.agiletec.aps.system.common.entity.model.attribute.ListAttribute)11 BooleanAttribute (com.agiletec.aps.system.common.entity.model.attribute.BooleanAttribute)10 IndexableAttributeInterface (com.agiletec.aps.system.common.searchengine.IndexableAttributeInterface)10 HttpSession (javax.servlet.http.HttpSession)10 EntityAttributeIterator (com.agiletec.aps.system.common.util.EntityAttributeIterator)9 IEntityManager (com.agiletec.aps.system.common.entity.IEntityManager)7 MonoTextAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoTextAttribute)7 Lang (com.agiletec.aps.system.services.lang.Lang)7 Date (java.util.Date)7