.withPageSize(pageSize) .select(Query.fields(ElementView.FIELDS_IDX_EXT_ID) .where(Condition.eq(ElementView.FIELD_EXTID, rootExtId))), pageSize);
try { Relation rel = browserFacade.relation(ContributorView.CONTRIBUTOR_VIEW_NAME, requiredTags) .withPageSize(pageSize); if (aggregationType.ordinal() > rel.getInfo().getViews().length) throw new SystemException(Modules.BROWSER, "No such aggreagation type: " clauses.add(filteredCondition(entry.getKey(), entry.getValue(), rel.getInfo())); f = rel.aggregate( rel.getAggregatingView(aggregationType.getAggregationName()) .getUuid(), query.where(new ComplexClause( ComplexClause.Operator.AND, clauses)), false);
@Override protected void saveEntry(short position, String licenceId) throws ServiceException { try { Relation relation = getDirectoryRelation(); relation.addOrUpdate( Condition.eq("position", position), new Serializable[]{position, licenceId}); } catch (BrowseException e) { throw new ServiceException(e); } }
public static void markAsReady(Relation relation) { Set<String> tags = new HashSet<String>(); tags = new HashSet<String>(); for (String tag : relation.getInfo().getTags()) tags.add(tag); tags.add(TAG_READY); relation.updateTags(tags.toArray(new String[tags.size()])); } }
.withPageSize(pageSize); clauses.add(filteredCondition(entry.getKey(), entry.getValue(), rel.getInfo())); contrViewFetcher = rel.select(query.where(new ComplexClause( ComplexClause.Operator.AND, clauses))); contrViewFetcher = rel.select(query);
@Override protected void finishProcess(final ProcessContext context) { try { browserFacade.relation(ElementPublisherView.ELEMENT_PUBLISHER_VIEW_NAME).setAggregatingEnabled(true, true); browserFacade.relation(ElementPublisherView.ELEMENT_PUBLISHER_VIEW_NAME).getInfo().getViews(); if (views != null) { for (final AggregatingView view : views) { if (view.getMaterializationStrategy() != AggregatingView.MaterializationStrategy.NONE) { browserFacade.relation(ElementPublisherView.ELEMENT_PUBLISHER_VIEW_NAME).aggregate(view.getUuid(), Query.fields("*"), false);
@Override public void removeReference(String sourceId, int position) throws AnalysisException { log.debug("Relation manager: Removing a reference: " + sourceId + ", " + position); Relation refsRelation = getRefsRelation(); Relation dirtyRelation = getDirtyRelation(); try { waitForSource(sourceId); } catch (InterruptedException ex) { throw new AnalysisException(ex); } try { refsRelation.delete(getRefsSourcePosCondition(sourceId, position)); dirtyRelation.addOrUpdate(getDirtySourceCondition(sourceId), new Serializable[]{sourceId}); } catch (NoSuchFieldInRelationException ex) { notifyForSource(sourceId); throw new AnalysisException(ex); } catch (NoSuchRelationException ex) { notifyForSource(sourceId); throw new AnalysisException(ex); } notifyForSource(sourceId); }
@Override protected Chunk doProcessChunk(Chunk data, Map<String, Serializable> context, IProcessListener processListener, ProcessingStats stats) throws Exception { final Batch batch = browserFacade.relation(ElementPublisherView.ELEMENT_PUBLISHER_VIEW_NAME).batch(); for (final CatalogElement catalogElement : data.getItems()) { try { batch.delete(Condition.eq(ElementPublisherView.FIELD_PUBLISHED_ELEMENT_EXTID, catalogElement.getExtId())); if (!catalogElement.isDeleted() && catalogElement.getElement() != null && hasRelatedPublisher(catalogElement)) { final List<Serializable[]> tuples = ElementPublisherView.asTuples(catalogElement, contributorInfoBuilder, bwmetaSource); for (final Serializable[] tuple : tuples) { batch.add(tuple); } } } catch (final Exception e) { if (context.containsKey(Constants.PARAM_DISABLE_AGGREGATIONS_DURING_REBUILD)) { browserFacade.relation(ElementPublisherView.ELEMENT_PUBLISHER_VIEW_NAME).setAggregatingEnabled(false, false); } if (processListener != null) { processListener.notifyEvent("elementPublisherViewGenerator.process", new String[]{catalogElement.getExtId()}, EventResultCode.ERROR, StackTraceUtil.getStackTrace(e)); } log.error("Exception processing element " + catalogElement.getExtId()); throw e; } } batch.run(); return data; }
@Override protected Chunk doProcessChunk(final Chunk data, final Map<String, Serializable> context, final IProcessListener processListener, final ProcessingStats stats) throws Exception { final Batch batch = browserFacade.relation(SubscriberView.VIEW_NAME).batch(); for (final CatalogElement ce : data.getItems()) { try { batch.delete(Condition.eq(SubscriberView.FIELD_ELEMENT_ID, ce.getExtId())); if (!ce.isDeleted() && ce.getElement() != null) { final Serializable[][] tuples=SubscriberView.asTuples(ce); for (final Serializable[] tuple : tuples) { batch.add(tuple); } } } catch (final Exception e) { if (processListener != null) { processListener.notifyEvent("subscriberViewGenerator.process", new String[]{ce.getExtId()}, EventResultCode.ERROR, StackTraceUtil.getStackTrace(e)); } log.error("Exception processing element " + ce.getExtId()); throw e; } } batch.run(); return data; }
@Override protected void finishProcess(final ProcessContext context) { try { browserFacade.relation(ContributorView.CONTRIBUTOR_VIEW_NAME).setAggregatingEnabled(true, true); browserFacade.relation(ContributorView.CONTRIBUTOR_VIEW_NAME).getInfo().getViews(); if (views != null) { for (final AggregatingView view : views) { if (view.getMaterializationStrategy() != MaterializationStrategy.NONE) { browserFacade.relation(ContributorView.CONTRIBUTOR_VIEW_NAME).aggregate(view.getUuid(), Query.fields("*"), false);
@Override protected Chunk doProcessChunk(final Chunk data, final Map<String, Serializable> context, final IProcessListener processListener, final ProcessingStats stats) throws Exception { final Batch batch = browserFacade.relation(ContributorView.CONTRIBUTOR_VIEW_NAME).batch(); for (final CatalogElement ce : data.getItems()) { try { batch.delete(Condition.eq(ContributorView.FIELD_ELEMENT_ID, ce.getExtId())); if (!ce.isDeleted() && ce.getElement() != null) { final Serializable[][] tuples=ContributorView.asTuples(ce.getElement(), contributorInfoBuilder); for (final Serializable[] tuple : tuples) { batch.add(tuple); } } } catch (final Exception e) { if (context.containsKey(Constants.PARAM_DISABLE_AGGREGATIONS_DURING_REBUILD)) { browserFacade.relation(ContributorView.CONTRIBUTOR_VIEW_NAME).setAggregatingEnabled(false, false); } if (processListener != null) { processListener.notifyEvent("contributorViewGenerator.process", new String[]{ce.getExtId()}, EventResultCode.ERROR, StackTraceUtil.getStackTrace(e)); } log.error("Exception processing element " + ce.getExtId()); throw e; } } batch.run(); return data; }
throws Exception { final Batch elementViewBath = browserFacade.relation(ElementView.ELEMENT_VIEW_NAME).batch(); final Batch journalViewBatch = browserFacade.relation(JournalView.JOURNAL_VIEW_NAME).batch(); final Batch publisherViewBatch = browserFacade.relation(PublisherView.PUBLISHER_VIEW_NAME).batch(); final Batch bookPublisherViewBatch = browserFacade.relation(BookPublisherView.PUBLISHER_VIEW_NAME).batch(); final Batch institutionEntityViewBatch = browserFacade.relation(InstitutionEntityView.VIEW_NAME).batch();
@Override public Map<Integer, String> getFromReferences(String sourceId) throws AnalysisException { try { Map<Integer, String> references = new HashMap<Integer, String>(); Relation refsRelation = getRefsRelation().withPageSize(PAGE_SIZE); Selection selection = Query.fields(REFS_RELATION_POSITION_FIELD, REFS_RELATION_TARGET_FIELD) .where(getRefsSourceCondition(sourceId)); FetcherIterator fetcherIterator = new FetcherIterator(refsRelation.select(selection), PAGE_SIZE); while (fetcherIterator.hasNext()) { Serializable[] record = fetcherIterator.next(); references.put(Integer.valueOf(record[0].toString()), record[1].toString()); } return references; } catch (BrowseException ex) { throw new AnalysisException(ex); } }
String aggregation = browseScheme.getAggregation(); Relation rel = browserFacade.relation(browseScheme.getRelationName(), requiredTags) .withPageSize(pageSize); for (Map.Entry<String, String> entry : filterBy.entrySet()) { if (!entry.getKey().equals("language")) { clauses.add(filteredCondition(entry.getKey(), entry.getValue(), rel.getInfo())); clauses.add(filteredCondition(key, browseScheme.getClauses().get(key), rel.getInfo())); f = rel.select(query.where(new ComplexClause( ComplexClause.Operator.AND, clauses))); f = rel.select(query); f = rel.aggregate(rel.getAggregatingView(aggregation).getUuid(), query.where(new ComplexClause(ComplexClause.Operator.AND, clauses)), false);
@Override protected void finishProcess(final ProcessContext context) { try { browserFacade.relation(SubscriberView.VIEW_NAME).setAggregatingEnabled(true, true); browserFacade.relation(SubscriberView.VIEW_NAME).getInfo().getViews(); if (views != null) { for (final AggregatingView view : views) { if (view.getMaterializationStrategy() != MaterializationStrategy.NONE) { browserFacade.relation(SubscriberView.VIEW_NAME).aggregate(view.getUuid(), Query.fields("*"), false);
@Override public void setReference(String sourceId, int position, String targetId) throws AnalysisException { log.debug("Relation manager: Setting a reference: " + sourceId + ", " + position+ ", " + targetId); Relation refsRelation = getRefsRelation(); Relation dirtyRelation = getDirtyRelation(); try { waitForSource(sourceId); } catch (InterruptedException ex) { throw new AnalysisException(ex); } try { refsRelation.addOrUpdate(getRefsSourcePosCondition(sourceId, position), new Serializable[]{sourceId, position, targetId}); dirtyRelation.addOrUpdate(getDirtySourceCondition(sourceId), new Serializable[]{sourceId}); } catch (NoSuchFieldInRelationException ex) { notifyForSource(sourceId); throw new AnalysisException(ex); } catch (NoSuchRelationException ex) { notifyForSource(sourceId); throw new AnalysisException(ex); } notifyForSource(sourceId); }
browserFacade.relation(CategoryView.CATEGORY_VIEW_NAME).batch();
@Override public Map<String, Integer> getToReferences(String targetId) throws AnalysisException { try { Map<String, Integer> references = new HashMap<String, Integer>(); Relation refsRelation = getRefsRelation().withPageSize(PAGE_SIZE); FetcherIterator fetcherIterator = new FetcherIterator(refsRelation.select( Query.fields(REFS_RELATION_SOURCE_FIELD, REFS_RELATION_POSITION_FIELD) .where(getRefsTargetCondition(targetId))), PAGE_SIZE); while (fetcherIterator.hasNext()) { Serializable[] record = fetcherIterator.next(); references.put(record[0].toString(), Integer.valueOf(record[1].toString())); } return references; } catch (BrowseException ex) { throw new AnalysisException(ex); } }
@Override protected void finishProcess(final ProcessContext context) { try { browserFacade.relation(ElementView.ELEMENT_VIEW_NAME).setAggregatingEnabled(true, true); browserFacade.relation(ElementView.ELEMENT_VIEW_NAME).getInfo().getViews(); if (views != null) { for (final AggregatingView view : views) { if (view.getMaterializationStrategy() != MaterializationStrategy.NONE) { browserFacade.relation(ElementView.ELEMENT_VIEW_NAME).aggregate(view.getUuid(), Query.fields("*"), false);
@Override protected Chunk doProcessChunk(final Chunk data, final Map<String, Serializable> context, final IProcessListener processListener, final ProcessingStats stats) throws Exception { final Batch batch = browserFacade.relation(TypeView.TYPE_VIEW_NAME).batch(); for (final CatalogElement ce : data.getItems()) { try { if (ce.isDeleted()) { batch.delete(Condition.eq(TypeView.FIELD_EXTID, ce.getId().getId())); } else if (ce.getElement() == null && ce.getNonElement() != null) { String extId = null; extId = ce.getNonElement().getExtId(); final Serializable[] tuple = TypeView.asTuple(ce.getNonElement()); batch.addOrUpdate(Condition.eq(TypeView.FIELD_EXTID, extId), tuple); } else if (ce.isDeleted()) { batch.delete(Condition.eq(TypeView.FIELD_EXTID, ce.getExtId())); } } catch (final Exception e) { log.error("Exception processing element " + ce.getExtId()); if (processListener != null) { processListener.notifyEvent("typeViewGenerator.process", new String[]{ce.getExtId()}, EventResultCode.ERROR, StackTraceUtil.getStackTrace(e)); } throw e; } } batch.run(); return data; }