use of com.agiletec.aps.system.common.entity.model.AttributeTracer in project entando-core by entando.
the class TestValidateNumberAttribute method testValidate_MonoListElement.
public void testValidate_MonoListElement() throws Throwable {
try {
String contentOnSessionMarker = this.executeCreateNewContent();
Content content = this.getContentOnEdit(contentOnSessionMarker);
AttributeTracer tracer = this.getTracer();
MonoListAttribute monolist = (MonoListAttribute) content.getAttribute("MonoLNumb");
AttributeInterface attribute = monolist.addAttribute();
String formFieldPrefix = "Monolist:" + attribute.getType() + ":";
tracer.setListIndex(monolist.getAttributes().size() - 1);
tracer.setListLang(this.getLangManager().getDefaultLang());
tracer.setMonoListElement(true);
String formFieldName = tracer.getFormFieldName(attribute);
assertEquals(formFieldPrefix + "MonoLNumb_0", formFieldName);
this.initSaveContentAction(contentOnSessionMarker);
this.executeAction(Action.INPUT);
this.checkFieldErrors(1, formFieldName);
this.initSaveContentAction(contentOnSessionMarker);
this.addParameter(formFieldName, "wrongNumber");
this.executeAction(Action.INPUT);
this.checkFieldErrors(1, formFieldName);
this.initSaveContentAction(contentOnSessionMarker);
this.addParameter(formFieldName, "98");
this.executeAction(Action.INPUT);
this.checkFieldErrors(0, formFieldName);
AttributeInterface attribute2 = monolist.addAttribute();
tracer.setListIndex(monolist.getAttributes().size() - 1);
String formFieldName2 = tracer.getFormFieldName(attribute2);
assertEquals(formFieldPrefix + "MonoLNumb_1", formFieldName2);
this.initSaveContentAction(contentOnSessionMarker);
this.executeAction(Action.INPUT);
this.checkFieldErrors(1, formFieldName2);
this.initSaveContentAction(contentOnSessionMarker);
this.executeAction(Action.INPUT);
this.addParameter(formFieldName2, "71");
this.checkFieldErrors(1, formFieldName2);
} catch (Throwable t) {
this.deleteTestContent();
throw t;
}
}
use of com.agiletec.aps.system.common.entity.model.AttributeTracer in project entando-core by entando.
the class IndexerDAO method indexAttribute.
private void indexAttribute(Document document, AttributeInterface attribute, Lang lang) throws ApsSystemException {
attribute.setRenderingLang(lang.getCode());
if (attribute instanceof IndexableAttributeInterface) {
String valueToIndex = ((IndexableAttributeInterface) attribute).getIndexeableFieldValue();
String indexingType = attribute.getIndexingType();
String fieldName = lang.getCode();
if (attribute instanceof ResourceAttributeInterface) {
fieldName += IIndexerDAO.ATTACHMENT_FIELD_SUFFIX;
}
if (null != indexingType && IndexableAttributeInterface.INDEXING_TYPE_UNSTORED.equalsIgnoreCase(indexingType)) {
document.add(new TextField(fieldName, valueToIndex, Field.Store.NO));
}
if (null != indexingType && IndexableAttributeInterface.INDEXING_TYPE_TEXT.equalsIgnoreCase(indexingType)) {
document.add(new TextField(fieldName, valueToIndex, Field.Store.YES));
}
}
if (attribute.isSearchable()) {
List<Lang> langs = new ArrayList<Lang>();
langs.add(lang);
AttributeTracer tracer = new AttributeTracer();
tracer.setLang(lang);
String name = tracer.getFormFieldName(attribute);
List<AttributeSearchInfo> searchInfos = attribute.getSearchInfos(langs);
if (null != searchInfos) {
for (int i = 0; i < searchInfos.size(); i++) {
AttributeSearchInfo info = searchInfos.get(i);
Field field = null;
if (null != info.getDate()) {
field = new TextField(name, DateTools.timeToString(info.getDate().getTime(), DateTools.Resolution.MINUTE), Field.Store.YES);
} else if (null != info.getBigDecimal()) {
field = new IntField(name, info.getBigDecimal().intValue(), Field.Store.YES);
} else {
field = new TextField(name, info.getString(), Field.Store.YES);
}
document.add(field);
}
}
}
}
use of com.agiletec.aps.system.common.entity.model.AttributeTracer in project entando-core by entando.
the class UserFilterOptionBean method getIndexFieldName.
private String getIndexFieldName() {
AttributeTracer tracer = new AttributeTracer();
tracer.setLang(this.getCurrentLang());
return tracer.getFormFieldName(this.getAttribute());
}
use of com.agiletec.aps.system.common.entity.model.AttributeTracer in project entando-core by entando.
the class TestValidateResourceAttribute method testValidate_Single.
protected void testValidate_Single(String attributeName, String testResourceId) throws Throwable {
try {
String contentOnSessionMarker = this.executeCreateNewContent();
Content content = this.getContentOnEdit(contentOnSessionMarker);
AttributeTracer tracer = this.getTracer();
AttributeInterface resourceAttribute = (AttributeInterface) content.getAttribute(attributeName);
String formFieldName = tracer.getFormFieldName(resourceAttribute);
String resourceFieldName = resourceAttribute.getType() + ":" + attributeName;
this.initSaveContentAction(contentOnSessionMarker);
this.executeAction(Action.INPUT);
this.checkFieldErrors(0, resourceFieldName);
this.checkFieldErrors(0, formFieldName);
this.initSaveContentAction(contentOnSessionMarker);
this.addParameter(formFieldName, "resourceDescription");
this.executeAction(Action.INPUT);
this.checkFieldErrors(1, resourceFieldName);
content = this.getContentOnEdit(contentOnSessionMarker);
AbstractResourceAttribute attachAttribute = (AbstractResourceAttribute) content.getAttribute(attributeName);
ResourceInterface resource = this._resourceManager.loadResource(testResourceId);
attachAttribute.setResource(resource, this.getLangManager().getDefaultLang().getCode());
this.initSaveContentAction(contentOnSessionMarker);
this.executeAction(Action.INPUT);
this.checkFieldErrors(0, resourceFieldName);
} catch (Throwable t) {
this.deleteTestContent();
throw t;
}
}
use of com.agiletec.aps.system.common.entity.model.AttributeTracer in project entando-core by entando.
the class TestValidateTextAttribute method testValidate_MonoListElement_1.
public void testValidate_MonoListElement_1() throws Throwable {
try {
String contentOnSessionMarker = this.executeCreateNewContent();
Content content = this.getContentOnEdit(contentOnSessionMarker);
AttributeTracer tracer = this.getTracer();
MonoListAttribute monolistAttribute = (MonoListAttribute) content.getAttribute("MonoLText");
AttributeInterface textAttribute = monolistAttribute.addAttribute();
String formFieldPrefix = "Monolist:" + textAttribute.getType() + ":";
tracer.setListIndex(monolistAttribute.getAttributes().size() - 1);
tracer.setListLang(this.getLangManager().getDefaultLang());
tracer.setMonoListElement(true);
tracer.setParentAttribute(monolistAttribute);
String monolistElementName = tracer.getMonolistElementFieldName(textAttribute);
assertEquals(formFieldPrefix + "MonoLText_0", monolistElementName);
String formFieldName = tracer.getFormFieldName(textAttribute);
assertEquals(formFieldPrefix + "it_MonoLText_0", formFieldName);
this.initSaveContentAction(contentOnSessionMarker);
this.executeAction(Action.INPUT);
this.checkFieldErrors(1, monolistElementName);
this.initSaveContentAction(contentOnSessionMarker);
this.addParameter(formFieldName, "MonoLMonotElement0Value");
this.executeAction(Action.INPUT);
this.checkFieldErrors(0, formFieldName);
AttributeInterface attribute2 = monolistAttribute.addAttribute();
tracer.setListIndex(monolistAttribute.getAttributes().size() - 1);
String formFieldName2 = tracer.getFormFieldName(attribute2);
assertEquals(formFieldPrefix + "it_MonoLText_1", formFieldName2);
String monolistElementName2 = tracer.getMonolistElementFieldName(attribute2);
assertEquals(formFieldPrefix + "MonoLText_1", monolistElementName2);
this.initSaveContentAction(contentOnSessionMarker);
this.executeAction(Action.INPUT);
this.checkFieldErrors(1, monolistElementName2);
} catch (Throwable t) {
this.deleteTestContent();
throw t;
}
}
Aggregations