@Override public int count() { if(it instanceof CountingIterator<?>) { return ((CountingIterator<?>)it).count(); } else return -1; } }
public void matchMetadata() throws MetadataIndexException { try { final CountingIterator<CatalogObjectMeta> ci = catalogFacade.iterateObjects(null, null, null, new String[] { MetadataIndexConstants.C_IMPORTED }, false); while (ci.hasNext()) { final CatalogObjectMeta meta = ci.next(); final String extId = meta.getId().getId(); matchMetadata(meta, extId); } } catch (final CatalogException e) { throw new MetadataIndexException(e); } }
@Override protected void processContentFile(String addr, InputStream is, Set<String> tags, boolean closeStream) throws Exception { String ext = contentPathToExtension(addr); String mime = MimeTypeHelper.getTypeForExtension(ext); if (mime == null) { mime = MimeTypeHelper.MIME_UNKNOWN; } String uri = contentPathToArchiveUri(addr); // Object already exists and we don't want to overwrite it if ((overwriteMode == OverwriteMode.NEVER) && (archiveFacade2.queryObjects(uri, false).hasNext())) { return; } archiveTransaction.storeData(uri, mime, is, tags.toArray(new String[tags.size()]), closeStream); archiveObjectsInTransaction++; flushIfNecessary(); }
public void importMetadata() throws MetadataIndexException { try { final CountingIterator<CatalogObjectMeta> ci = catalogFacade.iterateObjects(null, null, null, null, false); while (ci.hasNext()) { final CatalogObjectMeta meta = ci.next(); final String extId = meta.getId().getId(); importMetadata(meta, extId); } } catch (final CatalogException e) { throw new MetadataIndexException(e); } }
private void retrieveNext() { while (metaIterator.hasNext()) { CatalogObjectMeta meta = metaIterator.next(); if (meta.getStatus().isDeleted()) continue; try { CatalogObjectPart<String> bwmetaPart = catalogFacade.getPart(meta.getId(), CatalogParamConstants.TYPE_BWMETA1, null); nextObject = bwmetaPart.getData(); } catch (CatalogException e) { throw new RuntimeException("CatalogException while retrieving next bwmeta from catalog", e); } return; } nextObject = null; }
@Override public int count() { int res = -1; if(it instanceof CountingIterator<?>) { res = ((CountingIterator<?>)it).count(); } return res; } }
public void cleanMetadata() throws MetadataIndexException { try { final CountingIterator<CatalogObjectMeta> ci = catalogFacade.iterateObjects(null, null, null, null, false); while (ci.hasNext()) { final CatalogObjectMeta meta = ci.next(); final String extId = meta.getId().getId(); cleanMetadata(meta, extId); } } catch (final CatalogException e) { throw new MetadataIndexException(e); } }
public int count() { int count = 0; for (Object iterator : iteratorChain) { if (iterator instanceof CountingIterator) { CountingIterator ci = (CountingIterator)iterator; int localCount = ci.count(); if (localCount >= 0) count+= localCount; } } return count; }
@Override public int getEstimatedSize() throws UnsupportedOperationException { if (it instanceof CountingIterator<?>) { return ((CountingIterator<CatalogObjectMeta>) it).count(); } else { throw new UnsupportedOperationException("getting estimated size is unsupported"); } }
@Override public void matchInternal(final Date from, final Date until, String[] tags) throws MetadataIndexException { try { if (tags == null) { tags = new String[] {}; } final CountingIterator<CatalogObjectMeta> ci = catalogFacade.iterateObjects( new String[] { MetadataIndexConstants.T_REFMETA }, from, until, tags, false); while (ci.hasNext()) { final CatalogObjectMeta meta = ci.next(); final String extId = meta.getId().getId(); matchMetadata(meta, extId); } } catch (final CatalogException e) { throw new MetadataIndexException(e); } }
@SuppressWarnings("unchecked") public FlatElementIterator(ICatalogFacade<String> catalogFacade, String[] tags) throws CatalogException{ super(catalogFacade); CountingIterator<CatalogObjectMeta> metas = catalogFacade.iterateObjects(new String[]{CatalogParamConstants.TYPE_BWMETA1}, new Date(0), new Date(), tags, false); count = metas.count(); //TODO what about counting deleted ones ? iterator = new FilterIterator(metas, new Predicate() { @Override public boolean evaluate(Object o) { CatalogObjectMeta item = (CatalogObjectMeta)o; return !item.getStatus().isDeleted(); } }); }
public void init() { try { //fetch all CountingIterator<CatalogObjectMeta> i = catalog.iterateObjects(new String[]{partType}, null, null, null, false); while (i.hasNext()) { String id = i.next().getId().getId(); NamedObject no = loadObject(idMapper.getName(id), idMapper.getType(id)); addRelations(no); } } catch (CatalogException ex) { log.error( "Failed to read/process some objects during initialization.", ex); } }
totalCatalogElements = ((CountingIterator) elementIterator).count(); } else { totalCatalogElements = -1;
private boolean checkNextElement(){ if (next!=null) return true; if (lastCheck) { while (iterator.hasNext() && next==null) { catToS.logTick(); CatalogObjectMeta meta = iterator.next(); try { CatalogObject<String> object = catalogFacade.getObject(meta.getId()); CatalogObjectPart<String> part = object.getPart(catToS.getPartType()); if (part != null) { next = part.getData(); } } catch (CatalogException e) { log.warn("Cannot process " + meta.getId()); } } } lastCheck=(next!=null); return(next!=null); }
monitor.noteTaskStart(TASK_NAME); if(it instanceof CountingIterator<?>) monitor.setTotal(TASK_NAME,((CountingIterator<?>)it).count());
monitor.noteTaskStart(TASK_NAME); if(it instanceof CountingIterator<?>) monitor.setTotal(TASK_NAME,((CountingIterator<?>)it).count());