Search in sources :

Example 11 with IApsEntity

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

the class UserProfileAction method edit.

@Override
public String edit() {
    String username = this.getUsername();
    try {
        String checkUsernameResult = this.checkUsername(username, false);
        if (null != checkUsernameResult)
            return checkUsernameResult;
        IUserProfile userProfile = (IUserProfile) this.getUserProfileManager().getProfile(username);
        if (null == userProfile) {
            List<IApsEntity> userProfileTypes = new ArrayList<IApsEntity>();
            userProfileTypes.addAll(this.getUserProfileManager().getEntityPrototypes().values());
            if (userProfileTypes.isEmpty()) {
                throw new RuntimeException("Unexpected error - no one user profile types");
            } else if (userProfileTypes.size() == 1) {
                userProfile = (IUserProfile) userProfileTypes.get(0);
                userProfile.setId(username);
            } else {
                return "chooseType";
            }
        }
        this.getRequest().getSession().setAttribute(USERPROFILE_ON_SESSION, userProfile);
    } catch (Throwable t) {
        _logger.error("error in edit", t);
        return FAILURE;
    }
    return SUCCESS;
}
Also used : IUserProfile(org.entando.entando.aps.system.services.userprofile.model.IUserProfile) ArrayList(java.util.ArrayList) IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity)

Example 12 with IApsEntity

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

the class EntityTypeDOM method doParsing.

protected IApsEntity doParsing(Element element, Class entityClass, IApsEntityDOM entityDom) throws ApsSystemException {
    IApsEntity entity = null;
    try {
        entity = this.createEntityType(element, entityClass);
        entity.setEntityDOM(entityDom);
        this.fillEntityType(entity, element);
        entity.setDefaultLang(this.getLangManager().getDefaultLang().getCode());
        _logger.debug("Entity Type '{}' defined", entity.getTypeCode());
    } catch (Throwable t) {
        _logger.error("Error extracting entity type", t);
        throw new ApsSystemException("Configuration error of the Entity Type detected", t);
    }
    return entity;
}
Also used : IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException)

Example 13 with IApsEntity

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

the class TestJacmsEntityTypeConfigAction method testMoveAttribute.

public void testMoveAttribute() throws Throwable {
    String result = this.executeEditEntityPrototype("ART", JacmsSystemConstants.CONTENT_MANAGER);
    assertEquals(Action.SUCCESS, result);
    IApsEntity contentType = (IApsEntity) this.getRequest().getSession().getAttribute(IEntityTypeConfigAction.ENTITY_TYPE_ON_EDIT_SESSION_PARAM);
    assertNotNull(contentType);
    List<AttributeInterface> attributes = contentType.getAttributeList();
    assertEquals(7, attributes.size());
    assertEquals("VediAnche", attributes.get(2).getName());
    assertEquals("CorpoTesto", attributes.get(3).getName());
    this.initAction("/do/jacms/Entity", "moveAttribute");
    this.addParameter("attributeIndex", "2");
    this.addParameter("movement", ApsAdminSystemConstants.MOVEMENT_DOWN_CODE);
    result = this.executeAction();
    assertEquals(Action.SUCCESS, result);
    contentType = (IApsEntity) this.getRequest().getSession().getAttribute(IEntityTypeConfigAction.ENTITY_TYPE_ON_EDIT_SESSION_PARAM);
    assertNotNull(contentType);
    attributes = contentType.getAttributeList();
    assertEquals(7, attributes.size());
    assertEquals("VediAnche", attributes.get(3).getName());
    assertEquals("CorpoTesto", attributes.get(2).getName());
}
Also used : IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 14 with IApsEntity

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

the class TestJacmsEntityTypeConfigAction method testRemoveAttribute.

public void testRemoveAttribute() throws Throwable {
    String result = this.executeEditEntityPrototype("ART", JacmsSystemConstants.CONTENT_MANAGER);
    assertEquals(Action.SUCCESS, result);
    IApsEntity contentType = (IApsEntity) this.getRequest().getSession().getAttribute(IEntityTypeConfigAction.ENTITY_TYPE_ON_EDIT_SESSION_PARAM);
    assertNotNull(contentType);
    List<AttributeInterface> attributes = contentType.getAttributeList();
    assertEquals(7, attributes.size());
    assertEquals("VediAnche", attributes.get(2).getName());
    assertEquals("CorpoTesto", attributes.get(3).getName());
    this.initAction("/do/jacms/Entity", "removeAttribute");
    this.addParameter("attributeIndex", "2");
    result = this.executeAction();
    assertEquals(Action.SUCCESS, result);
    contentType = (IApsEntity) this.getRequest().getSession().getAttribute(IEntityTypeConfigAction.ENTITY_TYPE_ON_EDIT_SESSION_PARAM);
    assertNotNull(contentType);
    attributes = contentType.getAttributeList();
    assertEquals(6, attributes.size());
    assertEquals("CorpoTesto", attributes.get(2).getName());
}
Also used : IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 15 with IApsEntity

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

the class TestJacmsEntityTypeConfigAction method testEditEntityPrototype.

public void testEditEntityPrototype() throws Throwable {
    String result = this.executeEditEntityPrototype("ART", JacmsSystemConstants.CONTENT_MANAGER);
    assertEquals(Action.SUCCESS, result);
    IApsEntity contentType = (IApsEntity) this.getRequest().getSession().getAttribute(IEntityTypeConfigAction.ENTITY_TYPE_ON_EDIT_SESSION_PARAM);
    assertNotNull(contentType);
    List<AttributeInterface> attributes = contentType.getAttributeList();
    assertEquals(7, attributes.size());
}
Also used : IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

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