Search in sources :

Example 46 with IApsEntity

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

the class TestEntityManagersAction method testInitEditEntityType.

public void testInitEditEntityType() throws Throwable {
    String[] defNames = this.getApplicationContext().getBeanNamesForType(ApsEntityManager.class);
    if (null == defNames || defNames.length == 0)
        return;
    String entityManagerName = defNames[0];
    IEntityManager entityManager = (IEntityManager) this.getApplicationContext().getBean(entityManagerName);
    Map<String, IApsEntity> entityPrototypes = entityManager.getEntityPrototypes();
    if (null == entityPrototypes || entityPrototypes.size() == 0)
        return;
    IApsEntity realEntityPrototype = new ArrayList<IApsEntity>(entityPrototypes.values()).get(0);
    String result = this.executeInitEditEntityType("supervisorCoach", entityManagerName, realEntityPrototype.getTypeCode());
    assertEquals("userNotAllowed", result);
    result = this.executeInitEditEntityType("admin", null, realEntityPrototype.getTypeCode());
    assertEquals(Action.INPUT, result);
    assertEquals(1, this.getAction().getFieldErrors().size());
    assertEquals(1, this.getAction().getFieldErrors().get("entityManagerName").size());
    if (null == entityPrototypes.get("XXX")) {
        result = this.executeInitEditEntityType("admin", entityManagerName, "XXX");
        assertEquals("wrongEntityType", result);
        assertEquals(1, this.getAction().getFieldErrors().size());
        assertEquals(1, this.getAction().getFieldErrors().get("entityTypeCode").size());
    }
    result = this.executeInitEditEntityType("admin", entityManagerName, null);
    assertEquals("wrongEntityType", result);
    assertEquals(1, this.getAction().getFieldErrors().size());
    assertEquals(1, this.getAction().getFieldErrors().get("entityTypeCode").size());
    result = this.executeInitEditEntityType("admin", entityManagerName, realEntityPrototype.getTypeCode());
    assertEquals(Action.SUCCESS, result);
}
Also used : IEntityManager(com.agiletec.aps.system.common.entity.IEntityManager) IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity)

Example 47 with IApsEntity

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

the class TestEntityManagersAction method executeEditAttribute.

private String executeEditAttribute(String username, String attributeName, String entityTypeCode, String entityManagerName) throws Throwable {
    this.setUserOnSession(username);
    this.initAction("/do/Entity/Attribute", "editAttribute");
    this.addParameter("attributeName", attributeName);
    IEntityManager entityManager = (IEntityManager) this.getApplicationContext().getBean(entityManagerName);
    IApsEntity entityType = entityManager.getEntityPrototype(entityTypeCode);
    this.getRequest().getSession().setAttribute(IEntityTypeConfigAction.ENTITY_TYPE_ON_EDIT_SESSION_PARAM, entityType);
    return this.executeAction();
}
Also used : IEntityManager(com.agiletec.aps.system.common.entity.IEntityManager) IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity)

Example 48 with IApsEntity

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

the class TestJacmsEntityManagersAction method addEntityTypeForTest.

private void addEntityTypeForTest(String typeCode, String typeDescr) throws Throwable {
    assertNull(this._contentManager.getEntityPrototype(typeCode));
    IApsEntity prototype = this._contentManager.getEntityPrototype("ART");
    prototype.setTypeCode(typeCode);
    prototype.setTypeDescr(typeDescr);
    ((IEntityTypesConfigurer) this._contentManager).addEntityPrototype(prototype);
}
Also used : IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity) IEntityTypesConfigurer(com.agiletec.aps.system.common.entity.IEntityTypesConfigurer)

Example 49 with IApsEntity

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

the class TestJacmsEntityManagersAction method testGetEntityPrototypes.

public void testGetEntityPrototypes() throws Throwable {
    String result = this.executeViewModels(JacmsSystemConstants.CONTENT_MANAGER);
    assertEquals(Action.SUCCESS, result);
    IEntityTypesAction action = (IEntityTypesAction) this.getAction();
    List<IApsEntity> entityPrototypes = action.getEntityPrototypes();
    assertNotNull(entityPrototypes);
    assertEquals(4, entityPrototypes.size());
    IApsEntity firstType = entityPrototypes.get(0);
    assertEquals("ART", firstType.getTypeCode());
    assertEquals("Articolo rassegna stampa", firstType.getTypeDescr());
    IApsEntity lastType = entityPrototypes.get(3);
    assertEquals("RAH", lastType.getTypeCode());
    assertEquals("Tipo_Semplice", lastType.getTypeDescr());
}
Also used : IEntityTypesAction(com.agiletec.apsadmin.system.entity.type.IEntityTypesAction) IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity)

Example 50 with IApsEntity

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

the class TestJacmsEntityTypeConfigAction method testSaveEntityType.

public void testSaveEntityType() throws Throwable {
    String typeCode = "TST";
    assertNull(this._contentManager.getEntityPrototype(typeCode));
    try {
        IApsEntity prototype = this._contentManager.getEntityPrototype("ART");
        prototype.setTypeCode(typeCode);
        prototype.setTypeDescr("Entity type Description");
        this.getRequest().getSession().setAttribute(IEntityTypeConfigAction.ENTITY_TYPE_MANAGER_SESSION_PARAM, JacmsSystemConstants.CONTENT_MANAGER);
        this.getRequest().getSession().setAttribute(IEntityTypeConfigAction.ENTITY_TYPE_OPERATION_ID_SESSION_PARAM, new Integer(ApsAdminSystemConstants.ADD));
        this.getRequest().getSession().setAttribute(IEntityTypeConfigAction.ENTITY_TYPE_ON_EDIT_SESSION_PARAM, prototype);
        String result = this.executeSaveEntityType(prototype.getTypeCode(), prototype.getTypeDescr());
        assertEquals(Action.SUCCESS, result);
        assertNotNull(this._contentManager.getEntityPrototype(typeCode));
        assertNull(this.getRequest().getSession().getAttribute(IEntityTypeConfigAction.ENTITY_TYPE_ON_EDIT_SESSION_PARAM));
        result = this.executeEditEntityPrototype(typeCode, JacmsSystemConstants.CONTENT_MANAGER);
        assertEquals(Action.SUCCESS, result);
        assertNotNull(this.getRequest().getSession().getAttribute(IEntityTypeConfigAction.ENTITY_TYPE_ON_EDIT_SESSION_PARAM));
    } catch (Throwable t) {
        throw t;
    } finally {
        if (null != this._contentManager.getEntityPrototype(typeCode)) {
            ((IEntityTypesConfigurer) this._contentManager).removeEntityPrototype(typeCode);
        }
    }
}
Also used : IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity) IEntityTypesConfigurer(com.agiletec.aps.system.common.entity.IEntityTypesConfigurer)

Aggregations

IApsEntity (com.agiletec.aps.system.common.entity.model.IApsEntity)70 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)24 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)16 IEntityManager (com.agiletec.aps.system.common.entity.IEntityManager)12 IEntityTypesConfigurer (com.agiletec.aps.system.common.entity.IEntityTypesConfigurer)11 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)11 ArrayList (java.util.ArrayList)9 StringApiResponse (org.entando.entando.aps.system.services.api.model.StringApiResponse)6 EntitySearchFilter (com.agiletec.aps.system.common.entity.model.EntitySearchFilter)5 MonoListAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)4 Lang (com.agiletec.aps.system.services.lang.Lang)4 List (java.util.List)4 BeanComparator (org.apache.commons.beanutils.BeanComparator)4 ListAttribute (com.agiletec.aps.system.common.entity.model.attribute.ListAttribute)3 ListAttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.ListAttributeInterface)3 ApiError (org.entando.entando.aps.system.services.api.model.ApiError)3 IUserProfile (org.entando.entando.aps.system.services.userprofile.model.IUserProfile)3 Widget (com.agiletec.aps.system.services.page.Widget)2 ApsProperties (com.agiletec.aps.util.ApsProperties)2 EntityAttributeConfigAction (com.agiletec.apsadmin.system.entity.type.EntityAttributeConfigAction)2