Search in sources :

Example 1 with ApsEntityRecord

use of com.agiletec.aps.system.common.entity.model.ApsEntityRecord in project entando-core by entando.

the class TestContentEntityManager method testSearchRecords.

public void testSearchRecords() throws Throwable {
    List<ApsEntityRecord> contents = this._contentManager.searchRecords(null);
    assertNotNull(contents);
    assertEquals(25, contents.size());
    EntitySearchFilter typeFilter = new EntitySearchFilter(IContentManager.ENTITY_TYPE_CODE_FILTER_KEY, false, "ART", false);
    EntitySearchFilter[] filters1 = { typeFilter };
    contents = this._contentManager.searchRecords(filters1);
    assertEquals(11, contents.size());
    EntitySearchFilter creationOrderFilter = new EntitySearchFilter(IContentManager.CONTENT_CREATION_DATE_FILTER_KEY, false);
    creationOrderFilter.setOrder(EntitySearchFilter.DESC_ORDER);
    EntitySearchFilter[] filters2 = { typeFilter, creationOrderFilter };
    String[] order2 = { "ART122", "ART121", "ART120", "ART112", "ART111", "ART104", "ART102", "ART187", "ART180", "ART179", "ART1" };
    contents = this._contentManager.searchRecords(filters2);
    assertEquals(order2.length, contents.size());
    this.verifyOrder(contents, order2);
    EntitySearchFilter descrFilter = new EntitySearchFilter(IContentManager.CONTENT_DESCR_FILTER_KEY, false, "descriz", true);
    EntitySearchFilter[] filters3 = { typeFilter, creationOrderFilter, descrFilter };
    String[] order3 = { "ART187", "ART180", "ART179" };
    contents = this._contentManager.searchRecords(filters3);
    assertEquals(order3.length, contents.size());
    this.verifyOrder(contents, order3);
    EntitySearchFilter statusFilter = new EntitySearchFilter(IContentManager.CONTENT_STATUS_FILTER_KEY, false, "AF", true);
    EntitySearchFilter[] filters4 = { typeFilter, creationOrderFilter, descrFilter, statusFilter };
    String[] order4 = { "ART187", "ART179" };
    contents = this._contentManager.searchRecords(filters4);
    assertEquals(order4.length, contents.size());
    this.verifyOrder(contents, order4);
    EntitySearchFilter onLineFilter = new EntitySearchFilter(IContentManager.CONTENT_ONLINE_FILTER_KEY, false);
    EntitySearchFilter[] filters5 = { typeFilter, creationOrderFilter, descrFilter, statusFilter, onLineFilter };
    String[] order5 = { "ART187" };
    contents = this._contentManager.searchRecords(filters5);
    assertEquals(order5.length, contents.size());
    this.verifyOrder(contents, order5);
    onLineFilter.setNullOption(true);
    EntitySearchFilter[] filters6 = { typeFilter, creationOrderFilter, descrFilter, statusFilter, onLineFilter };
    String[] order6 = { "ART179" };
    contents = this._contentManager.searchRecords(filters6);
    assertEquals(order6.length, contents.size());
    this.verifyOrder(contents, order6);
}
Also used : ApsEntityRecord(com.agiletec.aps.system.common.entity.model.ApsEntityRecord) EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter)

Example 2 with ApsEntityRecord

use of com.agiletec.aps.system.common.entity.model.ApsEntityRecord in project entando-core by entando.

the class AbstractEntityDAO method loadEntityRecord.

@Override
public ApsEntityRecord loadEntityRecord(String id) {
    Connection conn = null;
    PreparedStatement stat = null;
    ResultSet res = null;
    ApsEntityRecord entityRecord = null;
    try {
        conn = this.getConnection();
        stat = conn.prepareStatement(this.getLoadEntityRecordQuery());
        stat.setString(1, id);
        res = stat.executeQuery();
        if (res.next()) {
            entityRecord = this.createEntityRecord(res);
        }
    } catch (Throwable t) {
        _logger.error("Error loading entity record '{}'", id, t);
        throw new RuntimeException("Error loading entity record", t);
    } finally {
        closeDaoResources(res, stat, conn);
    }
    return entityRecord;
}
Also used : ApsEntityRecord(com.agiletec.aps.system.common.entity.model.ApsEntityRecord) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement)

Example 3 with ApsEntityRecord

use of com.agiletec.aps.system.common.entity.model.ApsEntityRecord in project entando-core by entando.

the class TestDataObjectEntityManager method testSearchRecords.

public void testSearchRecords() throws Throwable {
    List<ApsEntityRecord> dataObjects = this._dataObjectManager.searchRecords(null);
    assertNotNull(dataObjects);
    assertEquals(25, dataObjects.size());
    EntitySearchFilter typeFilter = new EntitySearchFilter(IDataObjectManager.ENTITY_TYPE_CODE_FILTER_KEY, false, "ART", false);
    EntitySearchFilter[] filters1 = { typeFilter };
    dataObjects = this._dataObjectManager.searchRecords(filters1);
    assertEquals(11, dataObjects.size());
    EntitySearchFilter creationOrderFilter = new EntitySearchFilter(IDataObjectManager.DATA_OBJECT_CREATION_DATE_FILTER_KEY, false);
    creationOrderFilter.setOrder(EntitySearchFilter.DESC_ORDER);
    EntitySearchFilter[] filters2 = { typeFilter, creationOrderFilter };
    String[] order2 = { "ART122", "ART121", "ART120", "ART112", "ART111", "ART104", "ART102", "ART187", "ART180", "ART179", "ART1" };
    dataObjects = this._dataObjectManager.searchRecords(filters2);
    assertEquals(order2.length, dataObjects.size());
    this.verifyOrder(dataObjects, order2);
    EntitySearchFilter descrFilter = new EntitySearchFilter(IDataObjectManager.DATA_OBJECT_DESCR_FILTER_KEY, false, "descriz", true);
    EntitySearchFilter[] filters3 = { typeFilter, creationOrderFilter, descrFilter };
    String[] order3 = { "ART187", "ART180", "ART179" };
    dataObjects = this._dataObjectManager.searchRecords(filters3);
    assertEquals(order3.length, dataObjects.size());
    this.verifyOrder(dataObjects, order3);
    EntitySearchFilter statusFilter = new EntitySearchFilter(IDataObjectManager.DATA_OBJECT_STATUS_FILTER_KEY, false, "AF", true);
    EntitySearchFilter[] filters4 = { typeFilter, creationOrderFilter, descrFilter, statusFilter };
    String[] order4 = { "ART187", "ART179" };
    dataObjects = this._dataObjectManager.searchRecords(filters4);
    assertEquals(order4.length, dataObjects.size());
    this.verifyOrder(dataObjects, order4);
    EntitySearchFilter onLineFilter = new EntitySearchFilter(IDataObjectManager.DATA_OBJECT_ONLINE_FILTER_KEY, false);
    EntitySearchFilter[] filters5 = { typeFilter, creationOrderFilter, descrFilter, statusFilter, onLineFilter };
    String[] order5 = { "ART187" };
    dataObjects = this._dataObjectManager.searchRecords(filters5);
    assertEquals(order5.length, dataObjects.size());
    this.verifyOrder(dataObjects, order5);
    onLineFilter.setNullOption(true);
    EntitySearchFilter[] filters6 = { typeFilter, creationOrderFilter, descrFilter, statusFilter, onLineFilter };
    String[] order6 = { "ART179" };
    dataObjects = this._dataObjectManager.searchRecords(filters6);
    assertEquals(order6.length, dataObjects.size());
    this.verifyOrder(dataObjects, order6);
}
Also used : ApsEntityRecord(com.agiletec.aps.system.common.entity.model.ApsEntityRecord) EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter)

Example 4 with ApsEntityRecord

use of com.agiletec.aps.system.common.entity.model.ApsEntityRecord in project entando-core by entando.

the class UserProfileManagerIntegrationTest method testSearchProfileRecords.

public void testSearchProfileRecords() throws Throwable {
    List<ApsEntityRecord> records = this._profileManager.searchRecords(null);
    assertNotNull(records);
    assertEquals(4, records.size());
    EntitySearchFilter usernameFilter1 = new EntitySearchFilter(IUserProfileManager.ENTITY_ID_FILTER_KEY, false);
    usernameFilter1.setOrder(EntitySearchFilter.Order.ASC);
    EntitySearchFilter[] filters1 = { usernameFilter1 };
    records = this._profileManager.searchRecords(filters1);
    assertNotNull(records);
    String[] expected1 = { "editorCoach", "editorCustomers", "mainEditor", "pageManagerCoach" };
    assertEquals(expected1.length, records.size());
    this.verifyRecordOrder(records, expected1);
    EntitySearchFilter usernameFilter2 = new EntitySearchFilter(IUserProfileManager.ENTITY_ID_FILTER_KEY, false, "oa", true);
    usernameFilter2.setOrder(EntitySearchFilter.Order.ASC);
    EntitySearchFilter[] filters2 = { usernameFilter2 };
    records = this._profileManager.searchRecords(filters2);
    assertNotNull(records);
    String[] expected2 = { "editorCoach", "pageManagerCoach" };
    assertEquals(expected2.length, records.size());
    this.verifyRecordOrder(records, expected2);
}
Also used : ApsEntityRecord(com.agiletec.aps.system.common.entity.model.ApsEntityRecord) EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter)

Example 5 with ApsEntityRecord

use of com.agiletec.aps.system.common.entity.model.ApsEntityRecord in project entando-core by entando.

the class UserProfileManagerIntegrationTest method verifyRecordOrder.

private void verifyRecordOrder(List<ApsEntityRecord> records, String[] order) {
    for (int i = 0; i < records.size(); i++) {
        ApsEntityRecord record = records.get(i);
        assertEquals(order[i], record.getId());
    }
}
Also used : ApsEntityRecord(com.agiletec.aps.system.common.entity.model.ApsEntityRecord)

Aggregations

ApsEntityRecord (com.agiletec.aps.system.common.entity.model.ApsEntityRecord)6 EntitySearchFilter (com.agiletec.aps.system.common.entity.model.EntitySearchFilter)3 Connection (java.sql.Connection)2 PreparedStatement (java.sql.PreparedStatement)2 ResultSet (java.sql.ResultSet)2 ArrayList (java.util.ArrayList)1