Search in sources :

Example 16 with DataObject

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

the class TestDataObjectDAO method init.

private void init() throws Exception {
    this._dataObjectDao = new DataObjectDAO();
    try {
        this._dataObjectManager = (IDataObjectManager) this.getService("DataObjectManager");
        DataObject mockDataObject = this.getMockDataObject();
        DataSource dataSource = (DataSource) this.getApplicationContext().getBean("servDataSource");
        this._dataObjectDao.setDataSource(dataSource);
        ILangManager langManager = (ILangManager) this.getService(SystemConstants.LANGUAGE_MANAGER);
        this._dataObjectDao.setLangManager(langManager);
        this._dataObjectDao.addEntity(mockDataObject);
    } catch (Throwable e) {
        throw new Exception(e);
    }
}
Also used : DataObject(org.entando.entando.aps.system.services.dataobject.model.DataObject) ILangManager(com.agiletec.aps.system.services.lang.ILangManager) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) DataSource(javax.sql.DataSource)

Example 17 with DataObject

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

the class TestDataObjectDAO method testDeleteAddDataObject.

public void testDeleteAddDataObject() throws Throwable {
    try {
        DataObject mockDataObject = this.getMockDataObject();
        this.deleteDataObject(mockDataObject);
        this.addDataObject(mockDataObject);
    } catch (Throwable e) {
        throw e;
    }
}
Also used : DataObject(org.entando.entando.aps.system.services.dataobject.model.DataObject)

Example 18 with DataObject

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

the class TestDataObjectDAO method getMockDataObject.

private DataObject getMockDataObject() {
    DataObject dataObject = this._dataObjectManager.createDataObject("ART");
    dataObject.setId("temp");
    dataObject.setMainGroup(Group.FREE_GROUP_NAME);
    dataObject.addGroup("firstGroup");
    dataObject.addGroup("secondGroup");
    dataObject.addGroup("thirdGroup");
    AttributeInterface attribute = new MonoTextAttribute();
    attribute.setName("temp");
    attribute.setDefaultLangCode("it");
    attribute.setRenderingLang("it");
    attribute.setSearchable(true);
    attribute.setType("Monotext");
    dataObject.addAttribute(attribute);
    dataObject.setDefaultLang("it");
    dataObject.setDefaultModel("dataObject_viewer");
    dataObject.setDescription("temp");
    dataObject.setListModel("Monolist");
    dataObject.setRenderingLang("it");
    dataObject.setStatus("Bozza");
    dataObject.setTypeCode("ART");
    dataObject.setTypeDescription("Articolo rassegna stampa");
    return dataObject;
}
Also used : DataObject(org.entando.entando.aps.system.services.dataobject.model.DataObject) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface) MonoTextAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoTextAttribute)

Example 19 with DataObject

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

the class TestDataObjectDAO method testUpdateDataObject.

public void testUpdateDataObject() throws Throwable {
    try {
        DataObject mockDataObject = this.getMockDataObject();
        mockDataObject.setDescription("New Description");
        mockDataObject.setStatus(DataObject.STATUS_READY);
        this.updateDataObject(mockDataObject);
    } catch (Throwable t) {
        throw t;
    }
}
Also used : DataObject(org.entando.entando.aps.system.services.dataobject.model.DataObject)

Example 20 with DataObject

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

the class TestDataObjectManager method testLoadDataObjectsByAttribute_3.

public void testLoadDataObjectsByAttribute_3() throws Throwable {
    List<String> groups = new ArrayList<String>();
    String[] masterDataObjectIds = { "EVN193", "EVN191", "EVN192", "EVN194", "EVN23", "EVN24" };
    String[] newDataObjectIds = null;
    try {
        newDataObjectIds = this.addDraftDataObjectsForTest(masterDataObjectIds, false);
        for (int i = 0; i < newDataObjectIds.length; i++) {
            DataObject dataObject = this._dataObjectManager.loadDataObject(newDataObjectIds[i], false);
            TextAttribute titleAttribute = (TextAttribute) dataObject.getAttribute("Titolo");
            if (i % 2 == 1 && i < 4) {
                titleAttribute.setText(null, "en");
            }
            titleAttribute.setText(null, "it");
            this._dataObjectManager.saveDataObject(dataObject);
        }
        groups.add(Group.ADMINS_GROUP_NAME);
        EntitySearchFilter filter0 = new EntitySearchFilter(IDataObjectManager.DATA_OBJECT_CREATION_DATE_FILTER_KEY, false);
        filter0.setOrder(EntitySearchFilter.ASC_ORDER);
        EntitySearchFilter filter1 = new EntitySearchFilter(IDataObjectManager.ENTITY_TYPE_CODE_FILTER_KEY, false, "EVN", false);
        EntitySearchFilter filter2 = new EntitySearchFilter(IDataObjectManager.ENTITY_ID_FILTER_KEY, false);
        filter2.setOrder(EntitySearchFilter.ASC_ORDER);
        EntitySearchFilter[] filters = { filter0, filter1, filter2 };
        String[] expectedDataObjectsId = { "EVN191", "EVN192", "EVN193", "EVN194", "EVN103", "EVN20", "EVN23", "EVN24", "EVN25", "EVN41", "EVN21", newDataObjectIds[0], newDataObjectIds[1], newDataObjectIds[2], newDataObjectIds[3], newDataObjectIds[4], newDataObjectIds[5] };
        List<String> dataObjects = this._dataObjectManager.loadDataObjectsId(null, filters, groups);
        assertEquals(expectedDataObjectsId.length, dataObjects.size());
        for (int i = 0; i < expectedDataObjectsId.length; i++) {
            assertEquals(expectedDataObjectsId[i], dataObjects.get(i));
        }
        EntitySearchFilter filter3 = new EntitySearchFilter("Titolo", true);
        filter3.setLangCode("en");
        filter3.setOrder(EntitySearchFilter.ASC_ORDER);
        EntitySearchFilter[] filters1 = { filter0, filter1, filter2, filter3 };
        String[] expectedDataObjectsId1 = { "EVN191", "EVN192", "EVN193", "EVN194", "EVN103", "EVN20", "EVN23", "EVN24", "EVN25", "EVN41", "EVN21", newDataObjectIds[0], newDataObjectIds[2] };
        dataObjects = this._dataObjectManager.loadDataObjectsId(null, filters1, groups);
        assertEquals(expectedDataObjectsId1.length, dataObjects.size());
        for (int i = 0; i < expectedDataObjectsId1.length; i++) {
            assertEquals(expectedDataObjectsId1[i], dataObjects.get(i));
        }
        filter3.setNullOption(true);
        filter3.setLangCode("it");
        EntitySearchFilter[] filters2 = { filter0, filter1, filter2, filter3 };
        String[] expectedDataObjectsId2 = { newDataObjectIds[0], newDataObjectIds[1], newDataObjectIds[2], newDataObjectIds[3], newDataObjectIds[4], newDataObjectIds[5] };
        dataObjects = this._dataObjectManager.loadDataObjectsId(null, filters2, groups);
        assertEquals(expectedDataObjectsId2.length, dataObjects.size());
        for (int i = 0; i < expectedDataObjectsId2.length; i++) {
            assertEquals(expectedDataObjectsId2[i], dataObjects.get(i));
        }
        filter3.setNullOption(true);
        filter3.setLangCode("en");
        EntitySearchFilter[] filters3 = { filter0, filter1, filter2, filter3 };
        String[] expectedDataObjectsId3 = { newDataObjectIds[1], newDataObjectIds[3], newDataObjectIds[4], newDataObjectIds[5] };
        dataObjects = this._dataObjectManager.loadDataObjectsId(null, filters3, groups);
        assertEquals(expectedDataObjectsId3.length, dataObjects.size());
        for (int i = 0; i < expectedDataObjectsId3.length; i++) {
            assertEquals(expectedDataObjectsId3[i], dataObjects.get(i));
        }
        filter2.setNullOption(true);
        EntitySearchFilter[] filters4 = { filter0, filter1, filter2 };
        dataObjects = this._dataObjectManager.loadDataObjectsId(null, filters4, groups);
        assertEquals(0, dataObjects.size());
    } catch (Throwable t) {
        throw t;
    } finally {
        this.deleteDataObjects(newDataObjectIds);
    }
}
Also used : DataObject(org.entando.entando.aps.system.services.dataobject.model.DataObject) TextAttribute(com.agiletec.aps.system.common.entity.model.attribute.TextAttribute) MonoTextAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoTextAttribute) ArrayList(java.util.ArrayList) EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter)

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