Search in sources :

Example 1 with DataObjectRenderizationInfo

use of org.entando.entando.aps.system.services.dataobjectdispenser.DataObjectRenderizationInfo in project entando-core by entando.

the class DataObjectViewerHelper method getRenderizationInfo.

@Override
public DataObjectRenderizationInfo getRenderizationInfo(String dataobjectId, String modelId, boolean publishExtraTitle, RequestContext reqCtx) throws ApsSystemException {
    DataObjectRenderizationInfo renderizationInfo = null;
    try {
        Lang currentLang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
        String langCode = currentLang.getCode();
        Widget widget = (Widget) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_WIDGET);
        ApsProperties widgetConfig = widget.getConfig();
        dataobjectId = this.extractDataId(dataobjectId, widgetConfig, reqCtx);
        modelId = this.extractModelId(dataobjectId, modelId, widgetConfig, reqCtx);
        if (dataobjectId != null && modelId != null) {
            long longModelId = new Long(modelId).longValue();
            this.setStylesheet(longModelId, reqCtx);
            renderizationInfo = this.getDataObjectDispenser().getRenderizationInfo(dataobjectId, longModelId, langCode, reqCtx, true);
            if (null == renderizationInfo) {
                _logger.info("Null Renderization informations: dataobject={}", dataobjectId);
                return null;
            }
            this.manageAttributeValues(renderizationInfo, publishExtraTitle, reqCtx);
        } else {
            _logger.warn("Parametri visualizzazione dataobject incompleti: dataobject={} modello={}", dataobjectId, modelId);
        }
    } catch (Throwable t) {
        _logger.error("Error extracting renderization info", t);
        throw new ApsSystemException("Error extracting renderization info", t);
    }
    return renderizationInfo;
}
Also used : DataObjectRenderizationInfo(org.entando.entando.aps.system.services.dataobjectdispenser.DataObjectRenderizationInfo) Widget(com.agiletec.aps.system.services.page.Widget) Lang(com.agiletec.aps.system.services.lang.Lang) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 2 with DataObjectRenderizationInfo

use of org.entando.entando.aps.system.services.dataobjectdispenser.DataObjectRenderizationInfo in project entando-core by entando.

the class TestDataObjectDispenser method testGetRenderedContent_2.

public void testGetRenderedContent_2() throws Throwable {
    RequestContext reqCtx = this.getRequestContext();
    this.setUserOnSession("admin");
    DataObjectRenderizationInfo outputInfo = this._dataObjectDispenser.getRenderizationInfo("ART120", 2, "it", reqCtx);
    assertEquals(this.replaceNewLine(_attendedItART120_cached.trim()), this.replaceNewLine(outputInfo.getRenderedDataobject().trim()));
    outputInfo = this._dataObjectDispenser.getRenderizationInfo("ART120", 2, "en", reqCtx);
    assertEquals(this.replaceNewLine(_attendedEnART120_cached.trim()), this.replaceNewLine(outputInfo.getRenderedDataobject().trim()));
    outputInfo = this._dataObjectDispenser.getRenderizationInfo("ART121", 2, "it", reqCtx);
    assertEquals(this.replaceNewLine(_attendedItART121_cached.trim()), this.replaceNewLine(outputInfo.getRenderedDataobject().trim()));
    outputInfo = this._dataObjectDispenser.getRenderizationInfo("ART121", 2, "en", reqCtx);
    assertEquals(this.replaceNewLine(_attendedEnART121_cached.trim()), this.replaceNewLine(outputInfo.getRenderedDataobject().trim()));
    outputInfo = this._dataObjectDispenser.getRenderizationInfo("ART122", 2, "en", reqCtx);
    assertEquals(this.replaceNewLine(_attendedEnART122_cached.trim()), this.replaceNewLine(outputInfo.getRenderedDataobject().trim()));
}
Also used : DataObjectRenderizationInfo(org.entando.entando.aps.system.services.dataobjectdispenser.DataObjectRenderizationInfo) RequestContext(com.agiletec.aps.system.RequestContext)

Example 3 with DataObjectRenderizationInfo

use of org.entando.entando.aps.system.services.dataobjectdispenser.DataObjectRenderizationInfo in project entando-core by entando.

the class TestDataObjectDispenser method testGetRenderedContent_3.

public void testGetRenderedContent_3() throws Throwable {
    DataObject dataobject = this._dataObjectManager.loadDataObject("ART120", true);
    dataobject.setId(null);
    try {
        RequestContext reqCtx = this.getRequestContext();
        this.setUserOnSession("admin");
        this._dataObjectManager.insertDataObject(dataobject);
        DataObjectRenderizationInfo outputInfo = this._dataObjectDispenser.getRenderizationInfo(dataobject.getId(), 2, "it", reqCtx);
        assertNotNull(outputInfo);
        // assertNotNull(this._cacheInfoManager.getFromCache(JacmsSystemConstants.CONTENT_CACHE_PREFIX+dataobject.getId()));
        // assertNotNull(this._cacheInfoManager.getFromCache(JacmsSystemConstants.CONTENT_AUTH_INFO_CACHE_PREFIX+dataobject.getId()));
        this._dataObjectManager.insertDataObject(dataobject);
        this.waitNotifyingThread();
    // assertNull(this._cacheInfoManager.getFromCache(JacmsSystemConstants.CONTENT_CACHE_PREFIX+dataobject.getId()));
    // assertNull(this._cacheInfoManager.getFromCache(JacmsSystemConstants.CONTENT_AUTH_INFO_CACHE_PREFIX+dataobject.getId()));
    } catch (Throwable t) {
        throw t;
    } finally {
        if (null != dataobject.getId()) {
            this._dataObjectManager.deleteDataObject(dataobject);
        }
    }
}
Also used : DataObjectRenderizationInfo(org.entando.entando.aps.system.services.dataobjectdispenser.DataObjectRenderizationInfo) DataObject(org.entando.entando.aps.system.services.dataobject.model.DataObject) RequestContext(com.agiletec.aps.system.RequestContext)

Example 4 with DataObjectRenderizationInfo

use of org.entando.entando.aps.system.services.dataobjectdispenser.DataObjectRenderizationInfo in project entando-core by entando.

the class ApiDataObjectInterface method getRenderedDataObject.

protected String getRenderedDataObject(String id, int modelId, String langCode) {
    String renderedData = null;
    DataObjectRenderizationInfo renderizationInfo = this.getDataObjectDispenser().getRenderizationInfo(id, modelId, langCode, null, true);
    if (null != renderizationInfo) {
        renderedData = renderizationInfo.getRenderedDataobject();
    }
    return renderedData;
}
Also used : DataObjectRenderizationInfo(org.entando.entando.aps.system.services.dataobjectdispenser.DataObjectRenderizationInfo)

Example 5 with DataObjectRenderizationInfo

use of org.entando.entando.aps.system.services.dataobjectdispenser.DataObjectRenderizationInfo in project entando-core by entando.

the class DataObjectViewerHelper method getRenderedDataObject.

/**
 * Restituisce il dataObject da visualizzare nel widget.
 *
 * @param dataobjectId L'identificativo del dataObject ricavato dal tag.
 * @param modelId Il modello del dataObject ricavato dal tag.
 * @param publishExtraTitle
 * @param reqCtx Il contesto della richiesta.
 * @return Il dataObject da visualizzare nella widget.
 * @throws ApsSystemException In caso di errore.
 */
@Override
public String getRenderedDataObject(String dataobjectId, String modelId, boolean publishExtraTitle, RequestContext reqCtx) throws ApsSystemException {
    String renderedDataObject = null;
    DataObjectRenderizationInfo renderInfo = this.getRenderizationInfo(dataobjectId, modelId, publishExtraTitle, reqCtx);
    if (null != renderInfo) {
        renderedDataObject = renderInfo.getRenderedDataobject();
    }
    if (null == renderedDataObject) {
        renderedDataObject = "";
    }
    return renderedDataObject;
}
Also used : DataObjectRenderizationInfo(org.entando.entando.aps.system.services.dataobjectdispenser.DataObjectRenderizationInfo)

Aggregations

DataObjectRenderizationInfo (org.entando.entando.aps.system.services.dataobjectdispenser.DataObjectRenderizationInfo)8 RequestContext (com.agiletec.aps.system.RequestContext)5 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)1 Lang (com.agiletec.aps.system.services.lang.Lang)1 Widget (com.agiletec.aps.system.services.page.Widget)1 ApsProperties (com.agiletec.aps.util.ApsProperties)1 DataObject (org.entando.entando.aps.system.services.dataobject.model.DataObject)1 DataObjectModel (org.entando.entando.aps.system.services.dataobjectmodel.DataObjectModel)1