Search in sources :

Example 31 with DataObject

use of org.entando.entando.aps.system.services.dataobject.model.DataObject in project entando-core by entando.

the class TestSearchEngineManager method testSearchContentsId_3.

public void testSearchContentsId_3() throws Throwable {
    try {
        DataObject content_1 = this.createDataObject_1();
        content_1.setMainGroup(Group.ADMINS_GROUP_NAME);
        this.dataObjectSearchEngineManager.deleteIndexedEntity(content_1.getId());
        this.dataObjectSearchEngineManager.addEntityToIndex(content_1);
        DataObject content_2 = this.createDataObject_2();
        this.dataObjectSearchEngineManager.deleteIndexedEntity(content_2.getId());
        this.dataObjectSearchEngineManager.addEntityToIndex(content_2);
        List<String> allowedGroup = new ArrayList<String>();
        allowedGroup.add(Group.FREE_GROUP_NAME);
        List<String> contentsId = this.dataObjectSearchEngineManager.searchEntityId("it", "San meravigliosa", allowedGroup);
        assertNotNull(contentsId);
        assertFalse(contentsId.contains(content_1.getId()));
        allowedGroup.add("secondaryGroup");
        contentsId = this.dataObjectSearchEngineManager.searchEntityId("it", "San meravigliosa", allowedGroup);
        assertNotNull(contentsId);
        assertTrue(contentsId.contains(content_1.getId()));
    } catch (Throwable t) {
        throw t;
    }
}
Also used : DataObject(org.entando.entando.aps.system.services.dataobject.model.DataObject) ArrayList(java.util.ArrayList)

Example 32 with DataObject

use of org.entando.entando.aps.system.services.dataobject.model.DataObject in project entando-core by entando.

the class DataObjectManager method createDataObject.

protected DataObject createDataObject(DataObjectRecordVO dataobjectVo, boolean onLine) throws ApsSystemException {
    DataObject dataobject = null;
    try {
        if (dataobjectVo != null) {
            String xmlData;
            if (onLine) {
                xmlData = dataobjectVo.getXmlOnLine();
            } else {
                xmlData = dataobjectVo.getXmlWork();
            }
            if (xmlData != null) {
                dataobject = (DataObject) this.createEntityFromXml(dataobjectVo.getTypeCode(), xmlData);
                dataobject.setId(dataobjectVo.getId());
                dataobject.setTypeCode(dataobjectVo.getTypeCode());
                dataobject.setDescription(dataobjectVo.getDescription());
                dataobject.setOnLine(dataobjectVo.isOnLine());
                dataobject.setMainGroup(dataobjectVo.getMainGroupCode());
                if (null == dataobject.getVersion()) {
                    dataobject.setVersion(dataobjectVo.getVersion());
                }
                if (null == dataobject.getFirstEditor()) {
                    dataobject.setFirstEditor(dataobjectVo.getFirstEditor());
                }
                if (null == dataobject.getLastEditor()) {
                    dataobject.setLastEditor(dataobjectVo.getLastEditor());
                }
                if (null == dataobject.getCreated()) {
                    dataobject.setCreated(dataobjectVo.getCreate());
                }
                if (null == dataobject.getLastModified()) {
                    dataobject.setLastModified(dataobjectVo.getModify());
                }
                if (null == dataobject.getStatus()) {
                    dataobject.setStatus(dataobjectVo.getStatus());
                }
            }
        }
    } catch (ApsSystemException e) {
        logger.error("Error while creating dataobject by vo", e);
        throw new ApsSystemException("Error while creating dataobject by vo", e);
    }
    return dataobject;
}
Also used : DataObject(org.entando.entando.aps.system.services.dataobject.model.DataObject) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException)

Example 33 with DataObject

use of org.entando.entando.aps.system.services.dataobject.model.DataObject in project entando-core by entando.

the class DataObjectManager method reloadEntityReferences.

@Override
public void reloadEntityReferences(String entityId) {
    try {
        DataObjectRecordVO dataobjectVo = this.loadDataObjectVO(entityId);
        DataObject dataobject = this.createDataObject(dataobjectVo, true);
        if (dataobject != null) {
            this.getDataObjectDAO().reloadDataObjectReferences(dataobject);
        }
        logger.debug("Reloaded dataobject references for dataobject {}", entityId);
    } catch (Throwable t) {
        logger.error("Error while reloading dataobject references for dataobject {}", entityId, t);
    }
}
Also used : DataObject(org.entando.entando.aps.system.services.dataobject.model.DataObject) DataObjectRecordVO(org.entando.entando.aps.system.services.dataobject.model.DataObjectRecordVO)

Example 34 with DataObject

use of org.entando.entando.aps.system.services.dataobject.model.DataObject in project entando-core by entando.

the class DataObjectManager method getTypeById.

/**
 * Return the dataobject type from the given ID code. The code is extracted
 * following the coding conventions: the first three characters are the type
 * of the code.
 *
 * @param dataId the dataobject ID whose dataobject type is extracted.
 * @return The dataobject type requested
 */
private DataObject getTypeById(String dataId) {
    String typeCode = dataId.substring(0, 3);
    DataObject type = (DataObject) super.getEntityTypes().get(typeCode);
    return type;
}
Also used : DataObject(org.entando.entando.aps.system.services.dataobject.model.DataObject)

Example 35 with DataObject

use of org.entando.entando.aps.system.services.dataobject.model.DataObject in project entando-core by entando.

the class DataObjectService method createEntityType.

@Override
protected DataObject createEntityType(IEntityManager entityManager, EntityTypeDtoRequest dto, BindingResult bindingResult) throws Throwable {
    DataObject dataObject = super.createEntityType(entityManager, dto, bindingResult);
    DataTypeDtoRequest dtr = (DataTypeDtoRequest) dto;
    if (this.checkModel(false, dataObject.getTypeCode(), dtr.getListModel(), bindingResult)) {
        dataObject.setListModel(dtr.getListModel());
    }
    if (this.checkModel(true, dataObject.getTypeCode(), dtr.getDefaultModel(), bindingResult)) {
        dataObject.setDefaultModel(dtr.getDefaultModel());
    }
    if (this.checkPage(dataObject.getTypeCode(), dtr.getViewPage(), bindingResult)) {
        dataObject.setViewPage(dtr.getViewPage());
    }
    return dataObject;
}
Also used : DataObject(org.entando.entando.aps.system.services.dataobject.model.DataObject) DataTypeDtoRequest(org.entando.entando.web.dataobject.model.DataTypeDtoRequest)

Aggregations

DataObject (org.entando.entando.aps.system.services.dataobject.model.DataObject)72 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)10 UserDetails (com.agiletec.aps.system.services.user.UserDetails)9 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)7 JAXBDataObject (org.entando.entando.aps.system.services.dataobject.api.model.JAXBDataObject)7 Test (org.junit.Test)7 TextAttribute (com.agiletec.aps.system.common.entity.model.attribute.TextAttribute)6 ArrayList (java.util.ArrayList)5 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)4 ITextAttribute (com.agiletec.aps.system.common.entity.model.attribute.ITextAttribute)4 MonoTextAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoTextAttribute)4 Category (com.agiletec.aps.system.services.category.Category)4 Date (java.util.Date)4 EntitySearchFilter (com.agiletec.aps.system.common.entity.model.EntitySearchFilter)3 FieldError (com.agiletec.aps.system.common.entity.model.FieldError)3 DateAttribute (com.agiletec.aps.system.common.entity.model.attribute.DateAttribute)3 MonoListAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)3 Group (com.agiletec.aps.system.services.group.Group)3 StringApiResponse (org.entando.entando.aps.system.services.api.model.StringApiResponse)3 IDataObjectManager (org.entando.entando.aps.system.services.dataobject.IDataObjectManager)3