/* (non-Javadoc) * @see net.sf.iquiver.service.BaseService#doStart() */ protected void doStart() { String indexDirectory = IQuiver.getConfiguration().getString("lucene.index.path"); Criteria crit = new Criteria(); try { List sources = ContentSourcePeer.doSelectAll(); for (Iterator iter = sources.iterator(); iter.hasNext(); ) { ContentSource source = (ContentSource) iter.next(); crit.clear(); crit.add(ContentPeer.CONTENT_TO_DELETE, true); crit.add(ContentPeer.CONTENT_SOURCE_ID, source.getContentSourceId()); List docs = ContentPeer.doSelect(crit); if (docs != null) { for (Iterator it = docs.iterator(); it.hasNext(); ) { Content content = (Content) it.next(); content.setRemoved(true); } IndexScheduler scheduler = IndexScheduler.getInstance( indexDirectory + File.separator + String.valueOf(source.getContentSourceId())); scheduler.scheduleForIndexing(docs); } ContentPeer.doDelete(crit); } } catch (TorqueException e) { logger.error("Error occured while deleting all marked contents from database!", e); } }
private com.relteq.sirius.jaxb.Table restoreTable(Tables db_table) throws TorqueException { com.relteq.sirius.jaxb.Table table = factory.createTable(); table.setName(db_table.getName()); Criteria crit = new Criteria(); crit.addAscendingOrderByColumn(TabularDataKeysPeer.COLUMN_NUMBER); @SuppressWarnings("unchecked") List<TabularDataKeys> db_tdk_l = db_table.getTabularDataKeyss(crit); com.relteq.sirius.jaxb.ColumnNames colnames = factory.createColumnNames(); for (TabularDataKeys db_tdk : db_tdk_l) colnames.getColumnName().add(restoreColumnName(db_tdk)); table.setColumnNames(colnames); crit.clear(); crit.addJoin(TabularDataPeer.TABLE_ID, TabularDataKeysPeer.TABLE_ID); crit.addJoin(TabularDataPeer.COLUMN_NAME, TabularDataKeysPeer.COLUMN_NAME); crit.addAscendingOrderByColumn(TabularDataPeer.ROW_NUMBER); crit.addAscendingOrderByColumn(TabularDataKeysPeer.COLUMN_NUMBER); @SuppressWarnings("unchecked") List<TabularData> db_td_l = db_table.getTabularDatas(crit); com.relteq.sirius.jaxb.Row row = null; Integer rownum = null; java.util.Iterator<com.relteq.sirius.jaxb.ColumnName> citer = null; for (TabularData db_td : db_td_l) { if (null != rownum && !rownum.equals(db_td.getRowNumber())) { table.getRow().add(row); row = null; } if (null == row) { row = factory.createRow(); citer = colnames.getColumnName().iterator(); } while (citer.hasNext()) { com.relteq.sirius.jaxb.ColumnName colname = citer.next(); if (colname.getValue().equals(db_td.getColumnName())) { row.getColumn().add(db_td.getValue()); break; } else { row.getColumn().add(null); logger.warn( "Column " + colname.getValue() + " skipped (table=" + db_td.getId() + ", row=" + db_td.getRowNumber() + ")"); } } } if (null != row) table.getRow().add(row); return table; }