/** Performs count of the specific query results. */ protected int countQuery(Condition query, String relation) throws BrowseException { return browser.relation(relation).count(query); }
protected Relation getDirectoryRelation() throws ServiceException { try { return browserFacade.relation(RELATION_NAME); } catch (NoSuchRelationException e) { try { return browserFacade.create(relationInfo); } catch (BrowseException e2) { throw new ServiceException(e2); } } }
private synchronized Relation getDirtyRelation() { try { return browserFacade.relation(DIRTY_RELATION_NAME); } catch (NoSuchRelationException ex) { Field sourceField = new Field(DIRTY_RELATION_SOURCE_FIELD, Field.Type.STRING, false, true); try { return browserFacade.create(new RelationInfo(DIRTY_RELATION_NAME, sourceField)); } catch (InvalidNameException ex1) { throw new IllegalArgumentException(ex1); } } }
@Override protected void initProcess(final ProcessContext context) { try { if (context.containsKey(Constants.PARAM_DISABLE_AGGREGATIONS_DURING_REBUILD)) { browserFacade.relation(ContributorView.CONTRIBUTOR_VIEW_NAME).setAggregatingEnabled(false, false); } } catch (final Exception e) { if (context != null) { context.getListener().notifyEvent("contributorViewGenerator.start", new String[]{}, EventResultCode.ERROR, StackTraceUtil.getStackTrace(e)); } log.error("Exception starting processing", e); } }
browserFacade.relation(ElementView.ELEMENT_VIEW_NAME) .withPageSize(pageSize) .select(Query.fields(ElementView.FIELDS_IDX_EXT_ID)
@Override protected void initProcess(final ProcessContext context) { try { if (context.containsKey(Constants.PARAM_DISABLE_AGGREGATIONS_DURING_REBUILD)) { browserFacade.relation(ElementPublisherView.ELEMENT_PUBLISHER_VIEW_NAME).setAggregatingEnabled(false, false); } } catch (final Exception e) { if (context != null) { context.getListener().notifyEvent("contributorViewGenerator.start", new String[]{}, EventResultCode.ERROR, StackTraceUtil.getStackTrace(e)); } log.error("Exception starting processing", e); } }
private synchronized Relation getRefsRelation() { try { return browserFacade.relation(REFS_RELATION_NAME); } catch (NoSuchRelationException ex) { Field sourceField = new Field(REFS_RELATION_SOURCE_FIELD, Field.Type.STRING, false, true); Field positionField = new Field(REFS_RELATION_POSITION_FIELD, Field.Type.INTEGER, false, false); Field targetField = new Field(REFS_RELATION_TARGET_FIELD, Field.Type.STRING, false, true); try { return browserFacade.create( new RelationInfo(REFS_RELATION_NAME, sourceField, positionField, targetField)); } catch (InvalidNameException ex1) { throw new IllegalArgumentException(ex1); } } }
@Override protected void initProcess(final ProcessContext context) { try { if (context.containsKey(Constants.PARAM_DISABLE_AGGREGATIONS_DURING_REBUILD)) { browserFacade.relation(ElementView.ELEMENT_VIEW_NAME).setAggregatingEnabled(false, false); } } catch (final Exception e) { if (context.getListener() != null) { context.getListener().notifyEvent("elementViewGenerator.start", new String[]{}, EventResultCode.ERROR, StackTraceUtil.getStackTrace(e)); } log.error("Exception starting processing", e); } }
@Override protected T doProcess(T data, Map<String, Serializable> context, IProcessListener listener, ProcessingStats stats) throws Exception { //initializer.drop(); if (context.containsKey(Constants.PARAM_FORCE_RECREATE)) { initializer.forceInit(); } else { initializer.prepare(); } if (context.containsKey(Constants.PARAM_MARK_VIEWS_AS_READY)) { for (ICommand<RelationInfo> command : initializer.getCommands()) { String relationName = command.getCommand().getBaseName(); Relation relation = browserFacade.relation(relationName); ViewConstants.markAsReady(relation); } } return data; }
@Override protected void finishProcess(final ProcessContext context) { try { if (context.containsKey(Constants.PARAM_MARK_VIEWS_AS_READY)) { ViewConstants.markAsReady(browserFacade.relation(TypeView.TYPE_VIEW_NAME)); } } catch (final Exception e) { if (context.getListener() != null) { context.getListener().notifyEvent("typeViewGenerator.finish", new String[0], EventResultCode.ERROR, StackTraceUtil.getStackTrace(e)); } log.error("Exception finishing processing", e); } }
@Override protected void initProcess(final ProcessContext context) { try { if (context.containsKey(Constants.PARAM_DISABLE_AGGREGATIONS_DURING_REBUILD)) { browserFacade.relation(SubscriberView.VIEW_NAME).setAggregatingEnabled(false, false); } } catch (final Exception e) { if (context.getListener() != null) { context.getListener().notifyEvent("subscriberViewGenerator.start", new String[0], EventResultCode.ERROR, StackTraceUtil.getStackTrace(e)); } log.error("Exception starting processing", e); } }
@Override protected void finishProcess(final ProcessContext context) { try { if (context.containsKey(Constants.PARAM_MARK_VIEWS_AS_READY)) { ViewConstants.markAsReady(browserFacade.relation( CategoryView.CATEGORY_VIEW_NAME)); } } catch (final Exception e) { if (context.getListener() != null) { context.getListener().notifyEvent("institutionView.finish", new String[0], EventResultCode.ERROR, StackTraceUtil.getStackTrace( e)); } log.error("Exception finishing processing", e); } }
protected void notifyChildrenOfDeleted(String id, Set<String> parentsToInvalidate) throws YaddaException, BrowseException { Selection selection = Query.fields(ElementView.FIELD_PARENT_EXTID) .where(Condition.eq(ElementView.FIELD_EXTID, id)); FetcherIterator fi = new FetcherIterator( browserFacade.relation(ElementView.ELEMENT_VIEW_NAME) .withPageSize(BROWSE_PAGE_SIZE) .select(selection), BROWSE_PAGE_SIZE); while (fi.hasNext()) { Serializable[] row = fi.next(); parentsToInvalidate.add(row[0].toString()); } }
protected PagingResponse<T> processSelection(Selection sel, String relation, int pageSize, Object[] extraData) throws BrowseException, ServiceException { int ps = pageSize > 0 ? pageSize : BUFFER_PAGE_SIZE; Fetcher fetcher = browser.relation(relation, new String[] {ViewConstants.TAG_READY}) .withPageSize(ps) .select(sel); List<T> li = decodeResultPage(fetcher, ps, extraData); Token t = new Token(fetcher.getCookie(), encodeExtraData(extraData), 0, ps); t.setHasNextPage(li.size() >= ps); PagingResponse<T> res = new PagingResponse<T>(li, t); return res; }
protected Map<String, Set<ElementTreeNode>> getChildrenFromRelation( ElementTreeNode parent) throws BrowseException { Map<String, Set<ElementTreeNode>> result = new HashMap<String, Set<ElementTreeNode>>(); Relation relation = browserFacade.relation(ElementView.ELEMENT_VIEW_NAME) .withPageSize(BROWSE_PAGE_SIZE); Selection selection = Query.fields(ElementView.FIELD_PARENT_EXTID, ElementView.FIELD_EXTID, ElementView.FIELD_LEVEL_EXTID, ElementView.FIELD_TEXT, ElementView.FIELD_HIERARCHY) .where(Condition.eq(ElementView.FIELD_PARENT_EXTID, parent.getElementExtId())); FetcherIterator fi = new FetcherIterator(relation.select(selection), BROWSE_PAGE_SIZE); while (fi.hasNext()) { Serializable[] row = fi.next(); String hierarchyId = (String) row[4]; if (result.get(hierarchyId) == null) { result.put(hierarchyId, new HashSet<ElementTreeNode>()); } ElementTreeNode child = new ElementTreeNode(row[1].toString()); child.setParentExtId(parent.getElementExtId()); child.setParentLevelExtId(parent.getElementLevelExtId()); child.setParentText(parent.getElementText()); child.setElementLevelExtId(row[2].toString()); child.setElementText(row[3].toString()); result.get(hierarchyId).add(child); } return result; }
@Override public Fetcher browseSubscribedItems(String libraryId, Map<String, String> filters) { try { Relation rel = browserFacade.relation(SubscriberView.VIEW_NAME, requiredTags) .withPageSize(1024); Selection query = Query.fields(SubscriberView.FIELD_TOP_ELEMENT_ID, SubscriberView.FIELD_TOP_ELEMENT_NAME, SubscriberView.FIELD_ELEMENT_ID, SubscriberView.FIELD_ELEMENT_NAME); Fetcher f = rel.select(query .where(Condition.eq(SubscriberView.FIELD_CONTRIBUTOR_ID, libraryId)) .upBy(SubscriberView.FIELD_TOP_ELEMENT_NAME_SORTKEY) .upBy(SubscriberView.FIELD_TOP_ELEMENT_ID) .upBy(SubscriberView.FIELD_ELEMENT_NAME_SORTKEY)); return f; } catch (NoSuchRelationException e) { log.error("Error getting subscriptions!", e); throw new SystemException(Modules.BROWSER, "Error getting subscriptions!", e); } catch (NoSuchFieldInRelationException e) { log.error("Error getting subscriptions!", e); throw new SystemException(Modules.BROWSER, "Error getting subscriptions!", e); } }
@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(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; }
@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 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; }