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);
}
}
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;
}
}
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;
}
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;
}
}
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);
}
}
Aggregations