use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.
the class ContentManagerTest method testGetXML.
@Test
public void testGetXML() throws Throwable {
String typeCode = "ART";
// @formatter:off
when(entityTypeFactory.extractEntityType(typeCode, Content.class, contentManager.getConfigItemName(), this.entityTypeDom, contentManager.getName(), this.entityDom)).thenReturn(this.createFakeEntity(typeCode, "contentview", "1"));
// @formatter:on
Content content = contentManager.createContentType(typeCode);
ContentDOM contentDOM = new ContentDOM();
contentDOM.setRootElementName("content");
content.setEntityDOM(contentDOM);
content.setId("ART1");
content.setTypeCode("Articolo");
content.setTypeDescription("Articolo");
content.setDescription("descrizione");
content.setStatus(Content.STATUS_DRAFT);
content.setMainGroup("free");
Category cat13 = new Category();
cat13.setCode("13");
content.addCategory(cat13);
Category cat19 = new Category();
cat19.setCode("19");
content.addCategory(cat19);
String xml = content.getXML();
assertNotNull(xml);
assertTrue(xml.indexOf("<content id=\"ART1\" typecode=\"Articolo\" typedescr=\"Articolo\">") != -1);
assertTrue(xml.indexOf("<descr>descrizione</descr>") != -1);
assertTrue(xml.indexOf("<status>" + Content.STATUS_DRAFT + "</status>") != -1);
assertTrue(xml.indexOf("<category id=\"13\" />") != -1);
assertTrue(xml.indexOf("<category id=\"19\" />") != -1);
}
use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.
the class TestContentManager method testGetXML.
public void testGetXML() throws Throwable {
Content content = this._contentManager.createContentType("ART");
content.setId("ART1");
content.setTypeCode("Articolo");
content.setTypeDescription("Articolo");
content.setDescription("descrizione");
content.setStatus(Content.STATUS_DRAFT);
content.setMainGroup("free");
Category cat13 = new Category();
cat13.setCode("13");
content.addCategory(cat13);
Category cat19 = new Category();
cat19.setCode("19");
content.addCategory(cat19);
String xml = content.getXML();
assertNotNull(xml);
assertTrue(xml.indexOf("<content id=\"ART1\" typecode=\"Articolo\" typedescr=\"Articolo\">") != -1);
assertTrue(xml.indexOf("<descr>descrizione</descr>") != -1);
assertTrue(xml.indexOf("<status>" + Content.STATUS_DRAFT + "</status>") != -1);
assertTrue(xml.indexOf("<category id=\"13\" />") != -1);
assertTrue(xml.indexOf("<category id=\"19\" />") != -1);
}
use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.
the class ContentCategoryBulkAction method initBulkCommand.
private BaseContentPropertyBulkCommand<Category> initBulkCommand(List<Category> categories) {
String commandBeanName = ApsAdminSystemConstants.DELETE == this.getStrutsAction() ? RemoveCategoryBulkCommand.BEAN_NAME : JoinCategoryBulkCommand.BEAN_NAME;
WebApplicationContext applicationContext = ApsWebApplicationUtils.getWebApplicationContext(this.getRequest());
BaseContentPropertyBulkCommand<Category> command = (BaseContentPropertyBulkCommand<Category>) applicationContext.getBean(commandBeanName);
ContentPropertyBulkCommandContext<Category> context = new ContentPropertyBulkCommandContext<Category>(this.getSelectedIds(), categories, this.getCurrentUser(), new DefaultBulkCommandTracer<String>());
command.init(context);
return command;
}
use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.
the class ResourceDAO method getCategoryCodes.
/**
* Restituisce la lista di codici di categorie associate ad una risorsa. La
* risorsa viene sempre referenziata con la categoria "root" della tipologia
* relativa (che corrisponde al codice della tipologia).
*
* @param resource La risorsa da inserire o da modificare.
* @return Il set di codici di categorie.
*/
private Set<String> getCategoryCodes(ResourceInterface resource) {
Set<String> codes = new HashSet<String>();
Iterator<Category> categoryIter = resource.getCategories().iterator();
while (categoryIter.hasNext()) {
Category category = (Category) categoryIter.next();
this.addCategoryCode(resource, category, codes);
}
return codes;
}
use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.
the class TestResourceAction method testDelete.
/*
* NOTE: we create a fake resource using the manager rather than the most obvious 'save' action.
*
*/
public void testDelete() throws Throwable {
ResourceInterface resource = this._resourceManager.createResourceType("Image");
String resourceId = null;
String result = null;
ResourceAction action = null;
assertNotNull(resource);
try {
this.setUserOnSession("admin");
resource.setMainGroup(Group.FREE_GROUP_NAME);
resource.setDescr("Levò la bocca dal fero pasto quel peccator");
resource.setCategories(new ArrayList<Category>());
this._resourceManager.addResource(resource);
resourceId = resource.getId();
ResourceInterface verify = this._resourceManager.loadResource(resourceId);
assertNotNull(verify);
// test with invalid ID
this.initAction("/do/jacms/Resource", "delete");
result = this.executeAction();
assertEquals(Action.INPUT, result);
action = (ResourceAction) this.getAction();
assertEquals(1, action.getActionErrors().size());
// test with a valid ID
this.initAction("/do/jacms/Resource", "delete");
this.addParameter("resourceId", resourceId);
result = this.executeAction();
assertEquals(Action.SUCCESS, result);
verify = this._resourceManager.loadResource(resourceId);
assertNull(verify);
} catch (Throwable t) {
throw t;
} finally {
this._resourceManager.deleteResource(resource);
}
}
Aggregations