Search in sources :

Example 46 with DataObject

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

the class DataObjectModelManager method getDefaultUtilizer.

@Override
public SmallDataType getDefaultUtilizer(long modelId) {
    String modelIdString = String.valueOf(modelId);
    List<SmallDataType> smallDataTypes = this.getDataObjectManager().getSmallDataTypes();
    for (SmallDataType smallDataType : smallDataTypes) {
        DataObject prototype = this.getDataObjectManager().createDataObject(smallDataType.getCode());
        if ((null != prototype.getListModel() && prototype.getListModel().equals(modelIdString)) || (null != prototype.getDefaultModel() && prototype.getDefaultModel().equals(modelIdString))) {
            return smallDataType;
        }
    }
    return null;
}
Also used : DataObject(org.entando.entando.aps.system.services.dataobject.model.DataObject) SmallDataType(org.entando.entando.aps.system.services.dataobject.model.SmallDataType)

Example 47 with DataObject

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

the class IndexLoaderThread method reloadContentIndex.

private void reloadContentIndex(String id) {
    try {
        DataObject dataObject = this._dataObjectManager.loadDataObject(id, true, false);
        if (dataObject != null) {
            this._indexerDao.add(dataObject);
            _logger.debug("Indexed DataObject {}", dataObject.getId());
        }
    } catch (Throwable t) {
        _logger.error("Error reloading index: DataObject id {}", id, t);
    }
}
Also used : DataObject(org.entando.entando.aps.system.services.dataobject.model.DataObject)

Example 48 with DataObject

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

the class TestDataObjectManager method testCreateDataObjectWithDefaultModel.

public void testCreateDataObjectWithDefaultModel() {
    DataObject dataObject = _dataObjectManager.createDataObject("ART");
    String defaultModel = dataObject.getDefaultModel();
    assertEquals(defaultModel, "1");
}
Also used : DataObject(org.entando.entando.aps.system.services.dataobject.model.DataObject)

Example 49 with DataObject

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

the class TestValidateDataObject method createNewVoid.

private DataObject createNewVoid(String contentType, String insertedDescr, String status, String mainGroup, String lastEditor) {
    DataObject content = this._contentManager.createDataObject(contentType);
    content.setDescription(insertedDescr);
    content.setStatus(status);
    content.setMainGroup(mainGroup);
    content.setLastEditor(lastEditor);
    return content;
}
Also used : DataObject(org.entando.entando.aps.system.services.dataobject.model.DataObject)

Example 50 with DataObject

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

the class TestValidateDataObject method testValidate_1.

public void testValidate_1() throws Throwable {
    String insertedDescr = "XXX Prova Validazione XXX";
    try {
        DataObject content = this.createNewVoid("ART", insertedDescr, DataObject.STATUS_DRAFT, Group.FREE_GROUP_NAME, "admin");
        List<FieldError> errors = content.validate(this._groupManager);
        assertNotNull(errors);
        assertEquals(1, errors.size());
        FieldError error = errors.get(0);
        // Verifica obbligatorietĂ  attributo "Titolo"
        assertEquals("Text:it_Titolo", error.getFieldCode());
        assertEquals(FieldError.MANDATORY, error.getErrorCode());
        String monolistAttributeName = "Autori";
        MonoListAttribute monolist = (MonoListAttribute) content.getAttribute(monolistAttributeName);
        monolist.addAttribute();
        assertEquals(1, monolist.getAttributes().size());
        errors = content.validate(this._groupManager);
        assertEquals(2, errors.size());
        error = errors.get(0);
        // Verifica obbligatorietĂ  attributo "Titolo"
        assertEquals("Text:it_Titolo", error.getFieldCode());
        assertEquals(FieldError.MANDATORY, error.getErrorCode());
        error = errors.get(1);
        // Verifica non valido elemento 1 in attributo lista "Autori"
        assertEquals("Monolist:Monotext:Autori_0", error.getFieldCode());
        assertEquals(FieldError.INVALID, error.getErrorCode());
    } catch (Throwable t) {
        throw t;
    }
}
Also used : MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) DataObject(org.entando.entando.aps.system.services.dataobject.model.DataObject) FieldError(com.agiletec.aps.system.common.entity.model.FieldError)

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