use of com.agiletec.aps.system.services.category.Category 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.services.category.Category in project entando-core by entando.
the class TestSearchEngineManager method testSearchContentsId_5.
public void testSearchContentsId_5() throws Throwable {
try {
Thread thread = this.dataObjectSearchEngineManager.startReloadDataObjectsReferences();
thread.join();
SearchEngineManager sem = (SearchEngineManager) this.dataObjectSearchEngineManager;
Category general_cat2 = this._categoryManager.getCategory("general_cat2");
List<ITreeNode> categories = new ArrayList<ITreeNode>();
categories.add(general_cat2);
List<String> allowedGroup = new ArrayList<String>();
allowedGroup.add(Group.FREE_GROUP_NAME);
List<String> contentsId = sem.searchEntityId(null, categories, allowedGroup);
assertNotNull(contentsId);
assertTrue(contentsId.isEmpty());
allowedGroup.add(Group.ADMINS_GROUP_NAME);
contentsId = sem.searchEntityId(null, categories, allowedGroup);
String[] expected1 = { "ART111", "ART120" };
this.verify(contentsId, expected1);
Category general_cat1 = this._categoryManager.getCategory("general_cat1");
categories.add(general_cat1);
contentsId = sem.searchEntityId(null, categories, allowedGroup);
assertNotNull(contentsId);
String[] expected2 = { "ART111" };
this.verify(contentsId, expected2);
} catch (Throwable t) {
throw t;
}
}
use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.
the class TestSearchEngineManager method createDataObject_2.
private DataObject createDataObject_2() {
DataObject content = new DataObject();
content.setId("101");
content.setMainGroup(Group.FREE_GROUP_NAME);
content.addGroup("thirdGroup");
content.setTypeCode("ART");
TextAttribute text = new TextAttribute();
text.setName("Articolo");
text.setType("Text");
text.setIndexingType(IndexableAttributeInterface.INDEXING_TYPE_TEXT);
text.setText("Il turismo ha incrementato più del 20 per cento nel 2011-2013, quando la Croazia ha aderito all'Unione europea. Consegienda di questo aumento è una serie di modernizzazione di alloggi di recente costruzione, tra cui circa tre dozzine di ostelli.", "it");
text.setText("Tourism had shot up more than 20 percent from 2011 to 2013, when Croatia joined the European Union. Accompanying that rise is a raft of modernized and recently built lodgings, including some three dozen hostels.", "en");
content.addAttribute(text);
Category category1 = this._categoryManager.getCategory("resCat1");
Category category2 = this._categoryManager.getCategory("general_cat2");
content.addCategory(category1);
content.addCategory(category2);
return content;
}
use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.
the class TestSearchEngineManager method createDataObject_3.
private DataObject createDataObject_3() {
DataObject content = new DataObject();
content.setId("103");
content.setMainGroup(Group.FREE_GROUP_NAME);
content.setTypeCode("ART");
TextAttribute text = new TextAttribute();
text.setName("Articolo");
text.setType("Text");
text.setIndexingType(IndexableAttributeInterface.INDEXING_TYPE_TEXT);
text.setText("La vita è una cosa meravigliosa", "it");
text.setText("Life is a wonderful thing", "en");
content.addAttribute(text);
Category category = this._categoryManager.getCategory("general_cat1");
content.addCategory(category);
return content;
}
use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.
the class ResourceManagerIntegrationTest method testUpdateResource.
public void testUpdateResource() throws Throwable {
String oldDescr = null;
List<Category> oldCategories = null;
try {
ResourceInterface resource = this._resourceManager.loadResource("44");
assertTrue(resource instanceof ImageResource);
assertEquals(resource.getDescription(), "logo");
assertEquals(resource.getCategories().size(), 1);
assertTrue(resource.isMultiInstance());
oldCategories = resource.getCategories();
oldDescr = resource.getDescription();
String newDescr = "New Description";
resource.setDescription(newDescr);
resource.setCategories(new ArrayList<Category>());
this._resourceManager.updateResource(resource);
resource = this._resourceManager.loadResource("44");
assertEquals(resource.getDescription(), newDescr);
assertEquals(resource.getCategories().size(), 0);
} catch (Throwable t) {
throw t;
} finally {
if (oldCategories != null && oldDescr != null) {
ResourceInterface resource = this._resourceManager.loadResource("44");
resource.setCategories(oldCategories);
resource.setDescription(oldDescr);
this._resourceManager.updateResource(resource);
}
}
}
Aggregations