use of com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface in project entando-core by entando.
the class UserFilterOptionBean method extractFormParameters.
protected void extractFormParameters(HttpServletRequest request) throws Throwable {
String[] formFieldNames = null;
try {
String frameIdSuffix = (null != this.getCurrentFrame()) ? "_frame" + this.getCurrentFrame().toString() : "";
if (!this.isAttributeFilter()) {
if (this.getKey().equals(KEY_FULLTEXT)) {
String fieldName = TYPE_METADATA + "_fulltext" + frameIdSuffix;
String[] fieldsSuffix = { "", "_option", "_attachSearch" };
formFieldNames = this.extractParams(fieldName, fieldsSuffix, frameIdSuffix, request);
} else if (this.getKey().equals(KEY_CATEGORY)) {
formFieldNames = new String[1];
formFieldNames[0] = TYPE_METADATA + "_category" + frameIdSuffix;
String value = request.getParameter(formFieldNames[0]);
this.addFormValue(formFieldNames[0], value, formFieldNames.length);
}
} else {
AttributeInterface attribute = this.getAttribute();
if (attribute instanceof ITextAttribute) {
String[] fieldsSuffix = { "_textFieldName" };
formFieldNames = this.extractAttributeParams(fieldsSuffix, frameIdSuffix, request);
} else if (attribute instanceof DateAttribute) {
String[] fieldsSuffix = { "_dateStartFieldName", "_dateEndFieldName" };
formFieldNames = this.extractAttributeParams(fieldsSuffix, frameIdSuffix, request);
this.checkRange(formFieldNames);
} else if (attribute instanceof BooleanAttribute) {
String[] fieldsSuffix = { "_booleanFieldName", "_booleanFieldName_ignore", "_booleanFieldName_control" };
formFieldNames = this.extractAttributeParams(fieldsSuffix, frameIdSuffix, request);
} else if (attribute instanceof NumberAttribute) {
String[] fieldsSuffix = { "_numberStartFieldName", "_numberEndFieldName" };
formFieldNames = this.extractAttributeParams(fieldsSuffix, frameIdSuffix, request);
this.checkRange(formFieldNames);
}
}
} catch (Throwable t) {
_logger.error("Error extracting form parameters", t);
throw new ApsSystemException("Error extracting form parameters", t);
}
this.setFormFieldNames(formFieldNames);
}
use of com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface in project entando-core by entando.
the class IndexerDAO method createDocument.
/**
* Crea un oggetto Document pronto per l'indicizzazione da un oggetto
* Content.
*
* @param entity Il dataobject dal quale ricavare il Document.
* @return L'oggetto Document ricavato dal dataobject.
* @throws ApsSystemException In caso di errore
*/
protected Document createDocument(IApsEntity entity) throws ApsSystemException {
Document document = new Document();
document.add(new StringField(DATAOBJECT_ID_FIELD_NAME, entity.getId(), Field.Store.YES));
document.add(new TextField(DATAOBJECT_TYPE_FIELD_NAME, entity.getTypeCode(), Field.Store.YES));
document.add(new StringField(DATAOBJECT_GROUP_FIELD_NAME, entity.getMainGroup(), Field.Store.YES));
Iterator<String> iterGroups = entity.getGroups().iterator();
while (iterGroups.hasNext()) {
String groupName = (String) iterGroups.next();
document.add(new StringField(DATAOBJECT_GROUP_FIELD_NAME, groupName, Field.Store.YES));
}
try {
EntityAttributeIterator attributesIter = new EntityAttributeIterator(entity);
while (attributesIter.hasNext()) {
AttributeInterface currentAttribute = (AttributeInterface) attributesIter.next();
List<Lang> langs = this.getLangManager().getLangs();
for (int i = 0; i < langs.size(); i++) {
Lang currentLang = (Lang) langs.get(i);
this.indexAttribute(document, currentAttribute, currentLang);
}
}
List<Category> categories = entity.getCategories();
if (null != categories && !categories.isEmpty()) {
for (int i = 0; i < categories.size(); i++) {
Category category = categories.get(i);
this.indexCategory(document, category);
}
}
} catch (Throwable t) {
_logger.error("Error creating document", t);
throw new ApsSystemException("Error creating document", t);
}
return document;
}
use of com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface in project entando-core by entando.
the class SearchEngineManager method verifyReloadingNeeded.
protected boolean verifyReloadingNeeded(IApsEntity oldEntityType, IApsEntity newEntityType) {
List<AttributeInterface> attributes = oldEntityType.getAttributeList();
for (int i = 0; i < attributes.size(); i++) {
AttributeInterface oldAttribute = attributes.get(i);
AttributeInterface newAttribute = (AttributeInterface) newEntityType.getAttribute(oldAttribute.getName());
boolean isOldAttributeIndexeable = (oldAttribute.getIndexingType() != null && oldAttribute.getIndexingType().equalsIgnoreCase(IndexableAttributeInterface.INDEXING_TYPE_TEXT));
boolean isNewAttributeIndexeable = (newAttribute != null && newAttribute.getIndexingType() != null && newAttribute.getIndexingType().equalsIgnoreCase(IndexableAttributeInterface.INDEXING_TYPE_TEXT));
if ((isOldAttributeIndexeable && !isNewAttributeIndexeable) || (!isOldAttributeIndexeable && isNewAttributeIndexeable)) {
return true;
}
}
return false;
}
use of com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface in project entando-core by entando.
the class TestApiContentInterface method testCreateNewContent.
protected void testCreateNewContent(MediaType mediaType, String contentId) throws Throwable {
String dateNow = DateConverter.getFormattedDate(new Date(), JacmsSystemConstants.CONTENT_METADATA_DATE_FORMAT);
EntitySearchFilter filter = new EntitySearchFilter(IContentManager.CONTENT_CREATION_DATE_FILTER_KEY, false, dateNow, null);
EntitySearchFilter[] filters = { filter };
List<String> ids = this._contentManager.searchId(filters);
assertTrue(ids.isEmpty());
JAXBContent jaxbContent = this.testGetContent(mediaType, "admin", contentId, "it");
ApiResource contentResource = this.getApiCatalogManager().getResource("jacms", "content");
ApiMethod postMethod = contentResource.getPostMethod();
Properties properties = super.createApiProperties("admin", "it", mediaType);
try {
jaxbContent.setId(null);
Object response = this.getResponseBuilder().createResponse(postMethod, jaxbContent, properties);
assertNotNull(response);
assertTrue(response instanceof StringApiResponse);
assertEquals(IResponseBuilder.SUCCESS, ((StringApiResponse) response).getResult());
ids = this._contentManager.searchId(filters);
assertEquals(1, ids.size());
String newContentId = ids.get(0);
Content newContent = this._contentManager.loadContent(newContentId, false);
Content masterContent = this._contentManager.loadContent(contentId, true);
List<AttributeInterface> attributes = masterContent.getAttributeList();
for (int i = 0; i < attributes.size(); i++) {
AttributeInterface attribute = attributes.get(i);
AttributeInterface newAttribute = (AttributeInterface) newContent.getAttribute(attribute.getName());
this.checkAttributes(attribute, newAttribute);
}
} catch (Exception e) {
throw e;
} finally {
ids = this._contentManager.searchId(filters);
if (!ids.isEmpty()) {
for (int i = 0; i < ids.size(); i++) {
String id = ids.get(i);
Content content = this._contentManager.loadContent(id, false);
this._contentManager.deleteContent(content);
}
}
}
}
use of com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface in project entando-core by entando.
the class JAXBUserProfile method valorizeTextAttribute.
private void valorizeTextAttribute(String attributeName, String value, IUserProfile profile) {
if (null == attributeName || value == null) {
return;
}
AttributeInterface attribute = (AttributeInterface) profile.getAttribute(attributeName);
if (null == attribute || !(attribute instanceof AbstractTextAttribute)) {
return;
}
AbstractTextAttribute textAttribute = (AbstractTextAttribute) attribute;
textAttribute.setText(value, null);
}
Aggregations