Search in sources :

Example 1 with IManager

use of com.agiletec.aps.system.common.IManager in project entando-core by entando.

the class TestWidgetTypeAction method testFailureTrashType_2.

public void testFailureTrashType_2() throws Throwable {
    String widgetTypeCode = "test_widgetType_trash2";
    assertNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
    try {
        WidgetType type = this.createNewLogicWidgetType(widgetTypeCode);
        type.setLocked(true);
        this._widgetTypeManager.addWidgetType(type);
        assertNotNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
        String result = this.executeTrash(widgetTypeCode, "admin");
        assertEquals("inputWidgetTypes", result);
        ActionSupport action = this.getAction();
        assertEquals(1, action.getActionErrors().size());
        assertNotNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
    } catch (Throwable t) {
        throw t;
    } finally {
        if (null != this._widgetTypeManager.getWidgetType(widgetTypeCode)) {
            this._mockWidgetTypeDAO.deleteWidgetType(widgetTypeCode);
        }
        ((IManager) this._widgetTypeManager).refresh();
        assertNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
    }
}
Also used : IManager(com.agiletec.aps.system.common.IManager) ActionSupport(com.opensymphony.xwork2.ActionSupport) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType)

Example 2 with IManager

use of com.agiletec.aps.system.common.IManager in project entando-core by entando.

the class ExtraAttributeDisablingCodesWrapper method executeLoading.

public void executeLoading(Map<String, String> collectionToFill, IEntityManager entityManager) throws ApsSystemException {
    String managerName = ((IManager) entityManager).getName();
    if (!managerName.equals(super.getEntityManagerNameDest())) {
        return;
    }
    try {
        String xml = super.extractXml();
        AttributeDisablingCodesDOM dom = new AttributeDisablingCodesDOM();
        Map<String, String> codeMap = dom.extractDisablingCodes(xml, this.getDefsFilePath());
        List<String> codes = new ArrayList<>(codeMap.keySet());
        for (int i = 0; i < codes.size(); i++) {
            String code = codes.get(i);
            if (collectionToFill.containsKey(code)) {
                _logger.warn("You can't override existing disabling code : {} - {}", code, collectionToFill.get(code));
            } else {
                collectionToFill.put(code, codeMap.get(code));
                _logger.info("Added new disabling code : {} - {}", code, collectionToFill.get(code));
            }
        }
    } catch (Throwable t) {
        // ApsSystemUtils.logThrowable(t, this, "executeLoading", "Error loading extra attribute disabling codes");
        _logger.error("Error loading extra attribute disabling codes", t);
    }
}
Also used : AttributeDisablingCodesDOM(com.agiletec.aps.system.common.entity.parse.AttributeDisablingCodesDOM) IManager(com.agiletec.aps.system.common.IManager) ArrayList(java.util.ArrayList)

Example 3 with IManager

use of com.agiletec.aps.system.common.IManager in project entando-core by entando.

the class TestWidgetTypeManager method testFailureDeleteWidgetType_2.

public void testFailureDeleteWidgetType_2() throws Throwable {
    String widgetTypeCode = "test_widgetType";
    assertNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
    try {
        WidgetType type = this.createNewWidgetType(widgetTypeCode);
        type.setLocked(true);
        this._widgetTypeManager.addWidgetType(type);
        assertNotNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
        try {
            this._widgetTypeManager.deleteWidgetType(widgetTypeCode);
            fail();
        } catch (Throwable t) {
            assertNotNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
        }
    } catch (Throwable t) {
        throw t;
    } finally {
        if (null != this._widgetTypeManager.getWidgetType(widgetTypeCode)) {
            this._mockWidgetTypeDAO.deleteWidgetType(widgetTypeCode);
        }
        ((IManager) this._widgetTypeManager).refresh();
        assertNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
    }
}
Also used : IManager(com.agiletec.aps.system.common.IManager) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType)

Example 4 with IManager

use of com.agiletec.aps.system.common.IManager in project entando-core by entando.

the class TestWidgetTypeAction method testTrashType.

public void testTrashType() throws Throwable {
    String pageCode = "pagina_1";
    int frame = 1;
    String widgetTypeCode = "test_widgetType_trash3";
    try {
        assertNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
        WidgetType type = this.createNewWidgetType(widgetTypeCode);
        this._widgetTypeManager.addWidgetType(type);
        assertNotNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
        IPage pagina_1 = this._pageManager.getDraftPage(pageCode);
        assertNull(pagina_1.getWidgets()[frame]);
        String result = this.executeJoinWidget(pageCode, frame, widgetTypeCode, "admin");
        assertEquals(Action.SUCCESS, result);
        pagina_1 = this._pageManager.getDraftPage(pageCode);
        assertNotNull(pagina_1.getWidgets()[frame]);
        result = this.executeTrash(widgetTypeCode, "admin");
        assertEquals("inputWidgetTypes", result);
        ActionSupport action = this.getAction();
        assertEquals(1, action.getActionErrors().size());
        result = this.executeDeleteWidgetFromPage(pageCode, frame, "admin");
        assertEquals(Action.SUCCESS, result);
        result = this.executeTrash(widgetTypeCode, "admin");
        assertEquals(Action.SUCCESS, result);
        result = this.executeDelete(widgetTypeCode, "admin");
        assertEquals(Action.SUCCESS, result);
        assertNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
    } catch (Throwable t) {
        throw t;
    } finally {
        IPage pagina_1 = this._pageManager.getDraftPage(pageCode);
        pagina_1.getWidgets()[frame] = null;
        this._pageManager.updatePage(pagina_1);
        if (null != this._widgetTypeManager.getWidgetType(widgetTypeCode)) {
            this._mockWidgetTypeDAO.deleteWidgetType(widgetTypeCode);
        }
        ((IManager) this._widgetTypeManager).refresh();
        assertNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
    }
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) IManager(com.agiletec.aps.system.common.IManager) ActionSupport(com.opensymphony.xwork2.ActionSupport) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType)

Example 5 with IManager

use of com.agiletec.aps.system.common.IManager in project entando-core by entando.

the class ExtraAttributeRolesWrapper method executeLoading.

public void executeLoading(Map<String, AttributeRole> collectionToFill, IEntityManager entityManager) throws ApsSystemException {
    String managerName = ((IManager) entityManager).getName();
    if (!managerName.equals(super.getEntityManagerNameDest())) {
        return;
    }
    AttributeRoleDOM dom = new AttributeRoleDOM();
    try {
        String xml = super.extractXml();
        Map<String, AttributeRole> attributeRoles = dom.extractRoles(xml, this.getDefsFilePath());
        List<AttributeRole> roles = new ArrayList<>(attributeRoles.values());
        for (int i = 0; i < roles.size(); i++) {
            AttributeRole role = roles.get(i);
            if (collectionToFill.containsKey(role.getName())) {
                _logger.warn("You can't override existing attribute role : {} - {}", role.getName(), role.getDescription());
            } else {
                collectionToFill.put(role.getName(), role);
                _logger.info("Added new attribute role : {} - {}", role.getName(), role.getDescription());
            }
        }
    } catch (Throwable t) {
        // ApsSystemUtils.logThrowable(t, this, "executeLoading", "Error loading extra attribute Roles");
        _logger.error("Error loading extra attribute Roles", t);
    }
}
Also used : IManager(com.agiletec.aps.system.common.IManager) ArrayList(java.util.ArrayList) AttributeRoleDOM(com.agiletec.aps.system.common.entity.parse.AttributeRoleDOM) AttributeRole(com.agiletec.aps.system.common.entity.model.attribute.AttributeRole)

Aggregations

IManager (com.agiletec.aps.system.common.IManager)5 WidgetType (org.entando.entando.aps.system.services.widgettype.WidgetType)3 ActionSupport (com.opensymphony.xwork2.ActionSupport)2 ArrayList (java.util.ArrayList)2 AttributeRole (com.agiletec.aps.system.common.entity.model.attribute.AttributeRole)1 AttributeDisablingCodesDOM (com.agiletec.aps.system.common.entity.parse.AttributeDisablingCodesDOM)1 AttributeRoleDOM (com.agiletec.aps.system.common.entity.parse.AttributeRoleDOM)1 IPage (com.agiletec.aps.system.services.page.IPage)1