use of com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.LinkAttribute in project entando-core by entando.
the class LinkAttributeActionHelper method joinLink.
protected void joinLink(AttributeInterface attribute, String[] destinations, int destType, HttpServletRequest request) {
HttpSession session = request.getSession();
if (attribute instanceof CompositeAttribute) {
String includedAttributeName = (String) session.getAttribute(INCLUDED_ELEMENT_NAME_SESSION_PARAM);
AttributeInterface includedAttribute = ((CompositeAttribute) attribute).getAttribute(includedAttributeName);
updateLink(includedAttribute, destinations, destType);
} else if (attribute instanceof MonoListAttribute) {
Integer elementIndex = (Integer) session.getAttribute(LIST_ELEMENT_INDEX_SESSION_PARAM);
AttributeInterface attributeElement = ((MonoListAttribute) attribute).getAttribute(elementIndex.intValue());
joinLink(attributeElement, destinations, destType, request);
} else if (attribute instanceof LinkAttribute) {
updateLink(attribute, destinations, destType);
}
}
use of com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.LinkAttribute in project entando-core by entando.
the class TestApiContentInterface method checkAttributes.
private void checkAttributes(AttributeInterface oldAttribute, AttributeInterface newAttribute) {
if (null == newAttribute) {
fail();
}
assertEquals(oldAttribute.getName(), newAttribute.getName());
assertEquals(oldAttribute.getType(), newAttribute.getType());
if (!oldAttribute.isSimple()) {
if (oldAttribute instanceof AbstractListAttribute) {
List<AttributeInterface> oldListAttributes = ((AbstractComplexAttribute) oldAttribute).getAttributes();
List<AttributeInterface> newListAttributes = ((AbstractComplexAttribute) newAttribute).getAttributes();
assertEquals(oldListAttributes.size(), newListAttributes.size());
for (int i = 0; i < oldListAttributes.size(); i++) {
AttributeInterface oldElement = oldListAttributes.get(i);
AttributeInterface newElement = newListAttributes.get(i);
this.checkAttributes(oldElement, newElement);
}
} else if (oldAttribute instanceof CompositeAttribute) {
Map<String, AttributeInterface> oldAttributeMap = ((CompositeAttribute) oldAttribute).getAttributeMap();
Map<String, AttributeInterface> newAttributeMap = ((CompositeAttribute) newAttribute).getAttributeMap();
assertEquals(oldAttributeMap.size(), newAttributeMap.size());
Iterator<String> iterator = oldAttributeMap.keySet().iterator();
while (iterator.hasNext()) {
String key = iterator.next();
AttributeInterface oldElement = oldAttributeMap.get(key);
AttributeInterface newElement = newAttributeMap.get(key);
this.checkAttributes(oldElement, newElement);
}
}
} else {
if (oldAttribute instanceof AbstractResourceAttribute || oldAttribute instanceof LinkAttribute) {
return;
}
assertEquals(oldAttribute.getValue(), newAttribute.getValue());
}
}
use of com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.LinkAttribute in project entando-core by entando.
the class TestContentManager method testLoadContent.
public void testLoadContent() throws Throwable {
Content content = this._contentManager.loadContent("ART111", false);
assertEquals(Content.STATUS_PUBLIC, content.getStatus());
assertEquals("coach", content.getMainGroup());
assertEquals(2, content.getGroups().size());
assertTrue(content.getGroups().contains("customers"));
assertTrue(content.getGroups().contains("helpdesk"));
Map<String, AttributeInterface> attributes = content.getAttributeMap();
assertEquals(7, attributes.size());
TextAttribute title = (TextAttribute) attributes.get("Titolo");
assertEquals("Titolo Contenuto 3 Coach", title.getTextForLang("it"));
assertNull(title.getTextForLang("en"));
MonoListAttribute authors = (MonoListAttribute) attributes.get("Autori");
assertEquals(4, authors.getAttributes().size());
LinkAttribute link = (LinkAttribute) attributes.get("VediAnche");
assertNull(link.getSymbolicLink());
HypertextAttribute hypertext = (HypertextAttribute) attributes.get("CorpoTesto");
assertEquals("<p>Corpo Testo Contenuto 3 Coach</p>", hypertext.getTextForLang("it").trim());
assertNull(hypertext.getTextForLang("en"));
ResourceAttributeInterface image = (ResourceAttributeInterface) attributes.get("Foto");
assertNull(image.getResource());
DateAttribute date = (DateAttribute) attributes.get("Data");
assertEquals("13/12/2006", DateConverter.getFormattedDate(date.getDate(), "dd/MM/yyyy"));
}
use of com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.LinkAttribute in project entando-core by entando.
the class TestValidateContent method testValidate_2.
public void testValidate_2() throws Throwable {
try {
Content content = this._contentManager.loadContent("EVN191", true);
content.setId(null);
// Valorizzo il gruppo proprietario
content.setMainGroup(Group.FREE_GROUP_NAME);
content.getGroups().add("customers");
MonoListAttribute linksCorrelati = (MonoListAttribute) content.getAttribute("LinkCorrelati");
LinkAttribute linkAttribute = (LinkAttribute) linksCorrelati.addAttribute();
List<FieldError> errors = content.validate(this._groupManager);
assertNotNull(errors);
assertEquals(1, errors.size());
FieldError error = errors.get(0);
// Verifica obbligatorietĂ attributo "Titolo"
assertEquals("Monolist:Link:LinkCorrelati_0", error.getFieldCode());
assertEquals(FieldError.INVALID, error.getErrorCode());
// AGGIUNGO LINK SU PAGINA COACH
linkAttribute.setText("Descrizione link", "it");
SymbolicLink symbolicLink = new SymbolicLink();
// Contenuto di coach
symbolicLink.setDestinationToContent("EVN103");
linkAttribute.setSymbolicLink(symbolicLink);
errors = content.validate(this._groupManager);
assertNotNull(errors);
assertEquals(1, errors.size());
error = errors.get(0);
assertEquals("Monolist:Link:LinkCorrelati_0", error.getFieldCode());
assertEquals(ICmsAttributeErrorCodes.INVALID_CONTENT_GROUPS, error.getErrorCode());
} catch (Throwable t) {
throw t;
}
}
use of com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.LinkAttribute in project entando-core by entando.
the class TestContentAction method testValidate_2.
public void testValidate_2() throws Throwable {
String insertedDescr = "XXX Prova Validazione XXX";
try {
Content contentForTest = this.getContentManager().loadContent("EVN191", true);
String contentOnSessionMarker = AbstractContentAction.buildContentOnSessionMarker(contentForTest, ApsAdminSystemConstants.EDIT);
contentForTest.setId(null);
contentForTest.setDescription(insertedDescr);
// Valorizzo il gruppo proprietario
contentForTest.setMainGroup("coach");
contentForTest.getGroups().add("customers");
// AGGIUNGO LINK SU PAGINA COACH
MonoListAttribute linksCorrelati = (MonoListAttribute) contentForTest.getAttribute("LinkCorrelati");
LinkAttribute linkAttribute = (LinkAttribute) linksCorrelati.addAttribute();
linkAttribute.setText("Descrizione link", "it");
SymbolicLink symbolicLink = new SymbolicLink();
// Contenuto di coach
symbolicLink.setDestinationToContent("EVN103");
linkAttribute.setSymbolicLink(symbolicLink);
this.getRequest().getSession().setAttribute(ContentActionConstants.SESSION_PARAM_NAME_CURRENT_CONTENT_PREXIX + contentOnSessionMarker, contentForTest);
this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
this.setUserOnSession("admin");
String result = this.executeAction();
assertEquals(Action.INPUT, result);
ActionSupport action = this.getAction();
assertEquals(1, action.getFieldErrors().size());
assertEquals(1, action.getFieldErrors().get("Monolist:Link:LinkCorrelati_0").size());
} catch (Throwable t) {
throw t;
} finally {
this.removeTestContent(insertedDescr);
}
}
Aggregations