protected List<String> getChildrenIds(CatalogElement e) throws Exception { List<String> childrenIds = new LinkedList<String>(); if (e.getChildren() != null && !e.getChildren().isEmpty()) { for (ElementTreeNode child : e.getChildren()) { childrenIds.add(child.getElementExtId()); } } // Fetcher f = browserFacade.relation(ElementView.ELEMENT_VIEW_NAME).select( // Query.fields(ElementView.FIELD_PARENT_EXTID). // where(Condition.eq(ElementView.FIELD_EXTID, e.getExtId()))); // // int PAGE_SIZE = 5; // // for (f.fetchFirst(PAGE_SIZE); f.getPage().size() > 0; f.fetchNext(PAGE_SIZE)) { // for (Serializable[] row : f.getPage().getData()) { // childrenIds.add(row[0].toString()); // } // } return childrenIds; }
(Map<String, CollectionConfigurationElement>)context.get(Constants.PARAM_PROCESS_LICENSE_CONFIG); if (element.getCollections() != null && (!processOnlyUnlicensed || element.getLicenses() == null || element.getLicenses().isEmpty())) { element, batchHolder, null, context); for (final String currentCollection : element.getCollections()) { } else { log.error("exception occured when processing element: " + element.getExtId() + " with module " + relatedModule + " for collection " +currentCollection, e); + currentCollection + "; element extId: " + element.getExtId(); if (breakOnFailure) { throw new LicenseProcessorException(failureMessage); if (element.getCollections().size()>1) { removeDuplicatedBatchEntries(licenceContext); if (element.getCollections() == null) { log.warn("no collection defined for element " + element.getExtId());
/** * Updates auxilary licenses in {@link CatalogElement} object * according to the {@link TagOperation} object. * @param ce * @param tagOp * @param licenseTagPrefix */ public static void updateAuxilaryContentLicenses(CatalogElement ce, TagOperation tagOp, String licenseTagPrefix) throws YaddaException { if (ce!=null && tagOp!=null) { if (tagOp.getTagsToRemove()!=null && ce.getContentLicenses()!=null) { for (String removeTag : tagOp.getTagsToRemove()) { if (removeTag.startsWith(licenseTagPrefix)) { ce.getContentLicenses().remove(removeTag.substring( licenseTagPrefix.length())); } } } if (tagOp.getTagsToAdd()!=null) { for (String addTag : tagOp.getTagsToAdd()) { if (addTag.startsWith(licenseTagPrefix)) { ce.getContentLicenses().add(addTag.substring( licenseTagPrefix.length())); } } } } }
private void fillPublishingProcessRelatedFields(SElement sElement, CatalogElement catalogElement) { sElement.setState(catalogElement.getState()); sElement.setLastEditor(catalogElement.getEditedBy()); sElement.setRejectedEditor(catalogElement.getReturnedTo()); }
@Override protected Chunk doProcessChunk(Chunk data, Map<String, Serializable> context, IProcessListener processListener, ProcessingStats stats) throws Exception { List<Element> elementList = new ArrayList<Element>(); List<Ancestors> ancestorsList = new ArrayList<Ancestors>(); for (CatalogElement item : data.getItems()) { if (item == null || item.getElement() == null) continue; Ancestors ancestors = new Ancestors(); for (Entry<String, List<Ancestor>> hierarchyData : item.getRelations().entrySet()) ancestors.setAncestorsOfHierarchy(hierarchyData.getKey(), hierarchyData.getValue()); elementList.add(item.getElement()); ancestorsList.add(ancestors); } if (! elementList.isEmpty()) metadataImporter.importDesklightMetadata(elementList, ancestorsList); return data; }
throw new YaddaException("Element not found"); if (e.getElementTimestamp().after(finishDate)) { skipped++; updateStats(); if (e.hasFreshMeta(cutoffDate, relatedObjects)) { skipped++; updateStats(); if (e.getElement() == null && e.getNonElement() == null && !e.isDeleted()) { log.info("Element with id " + e.getExtId() + " doesn't contain BWMETA1. Skipped"); return; if (e.hasSignificantChanges() || force) { childRelatedObjects.put(e.getExtId(), e.getElementTimestamp()); if (e.getElement() != null || e.isDeleted()) { MetaStatus ms = e.isDeleted() ? new MetaStatus(e.getExtId(), e.getElementTimestamp()) : new MetaStatus(e.getElement(), e.getElementTimestamp()); ms.setTimestampsOfRelatedObjects(new HashMap<String, Date>(relatedObjects)); feedTarget(new WriteStatusRequest(e.getId(), ms));
CatalogElement ce = CatalogElement.newDeletedElement(cmo.getId()); ce.setElementTimestamp(cmo.getTimestamp()); ce.setCreationTimestamp(cmo.getCreationTimestamp()); return ce; CatalogElement ce=new CatalogElement(serializers, cmo.getId(), parts, licenses, collections, contentLicenses); ce.setElementTimestamp(timestamp); ce.setExistingMetaTimestamp(statusTimestamp); ce.setCreationTimestamp(cmo.getCreationTimestamp()); ce.setState(state); ce.setEditedBy(editedBy); ce.setReturnedTo(returnedTo);
final List<String> indexes = indexResolver.resolveIndexes(ce.getCollections(), ce.isDeleted(), ce.getExtId()); log.warn("Object with id" + ce.getExtId() + " doesn't belong to any collection - won't be indexed"); if (!ce.isDeleted() && ce.getElement() != null) { final SElement sel = elementConverter.convert(ce, !context .containsKey(pl.edu.icm.yadda.process.harvester.Constants.PARAM_DISABLE_INDEX_FULLTEXT)); if (ce.getElementTimestamp() != null) { doc.addField(IndexFields.F_INTERNAL_MODIFICATION_TIMESTAMP, Long.toString(ce.getElementTimestamp().getTime())); if (ce.getCreationTimestamp() != null) { doc.addField(IndexFields.F_INTERNAL_CREATION_TIMESTAMP, Long.toString(ce.getCreationTimestamp().getTime())); if (ce.isDeleted()) { if (!objectsToDelete.containsKey(index)) { objectsToDelete.put(index, new LinkedList<String>()); objectsToDelete.get(index).add(ce.getExtId()); if (log.isDebugEnabled()) { log.debug("Document is deleted (CatalogObject extid: " + ce.getExtId()); } else if (ce.getElement() != null) { if (!objectsToAdd.containsKey(index)) { objectsToAdd.put(index, new LinkedList<IndexDocument>());
@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; }
/** * Converts CatalogElement to SimilarityDocument. Note that this method does * not categorize elements and so categorization should occur before this * convertion. * * @see CatalogElementToCDocumentConverter */ public SimilarityDocument convert(CatalogElement ce) throws YaddaException { Element el = ce.getElement(); if (el == null) { return null; } SimilarityDocument doc = new SimilarityDocument(); doc.setId(ce.getExtId()); doc.setName(StringUtils.defaultString(el.getDescription())); doc.setText(getText(el, ce.getLanguage())); doc.setAuthors(getAuthors(el)); doc.setCategory(ce.getCategory()); doc.setLanguage(ce.getLanguage()); if (ce.getLicenses() != null) { doc.setLicenses(new ArrayList<String>(ce.getLicenses())); } prepareValues(ce, doc); return doc; }
if (ce.getElement() != null) { final Ancestors ancestors = calculateAncestors(ce.getElement(), ce.getElementTimestamp(), ce.hasChildren(), cutoffDate, ancestorsToWrite); ce.setRelations(hierarchyId, ancestors.getAncestorsOfHierarchy(hierarchyId)); log.error("Exception processing element " + ce.getExtId()); if (processListener != null) { processListener.notifyEvent("ancestorGenerator.process", new String[] { ce.getExtId() }, EventResultCode.ERROR, StackTraceUtil.getStackTrace(e));
if (ce.isDeleted()) { notifyChildrenOfDeleted(ce.getExtId(), parentsToInvalidate); } else if (ce.getElement() != null) { for (List<Ancestor> entry : ce.getRelations().values()) { if (entry.size() > 1) { Ancestor parent = entry.get(1); log.error("Exception processing element " + ce.getExtId()); if (processListener != null) { processListener.notifyEvent("childrenGenerator.process", new String[]{ce.getExtId()}, EventResultCode.ERROR, StackTraceUtil.getStackTrace(e));
doc = converter.convert(ce); if (doc == null) { throw new YaddaException("Catalog element " + ce.getExtId() + " could not be converted to CDocument"); log.debug("Element ["+ce.getCategory()+"] is not basic level element and is ignored"); if (isBasicLevelElement(ce)) { if (cr.isOk()) { ce.setCategory(cr.getCategoryName()); ce.setLanguage(cr.getLanguage()); } else { log.warn( "Catalog element {} could not be categorized ({})", ce.getExtId(), cr.getStatus());
protected void fillElement(final SElement sElement, final CatalogElement ce, final boolean indexFulltext) throws YaddaException { final Element el = ce.getElement(); sElement.setExtId(el.getExtId()); final Collection<String> licenses = ce.getLicenses(); if (Utils.emptyCollection(licenses)) { log.debug("No licenses for element '" + el.getExtId() + "'"); final Collection<String> collections = ce.getCollections(); if (Utils.emptyCollection(collections)) { log.debug("No collections for element '" + el.getExtId() + "'"); final List<AttributedDate> dates = ce.getElement().getDates(); for (final AttributedDate date : dates) { if (YConstants.DT_PUBLISHED.equals(date.getAttribute())) { if (ce.getRelations() != null) { for (final List<Ancestor> ancestorLists : ce.getRelations().values()) { for (final Ancestor ancestor : ancestorLists) {
public CDocument convert(CatalogElement ce) throws YaddaException { Element el = ce.getElement(); if (el==null) { return null; } CDocument doc = new CDocument(); doc.setId(ce.getExtId()); doc.setText(getText(el)); // we ignore language only if it is not valid iso 639-1 language code if (!el.getLanguages().isEmpty()) { String lang = StringUtils.defaultString(LanguageUtils.canonicalLang(el.getLanguages().get(0))); if (LanguagesIso639_1.isValid(lang)) { doc.setLanguage(lang); } } return doc; }
@Override protected Chunk doProcessChunk(final Chunk data, final Map<String, Serializable> context, final IProcessListener processListener, final ProcessingStats stats) throws Exception { final ComplexEditorStorageBatchHolder batchHolder = new ComplexEditorStorageBatchHolder(); for (final CatalogElement e : data.getItems()) { try { if (e.getElement() != null || e.getNonElement()!=null) { processElement(e, context, batchHolder); } } catch (final Exception ex) { if (processListener != null) { processListener.notifyEvent("licenceResolver.process", new String[]{e.getExtId()}, EventResultCode.ERROR, StackTraceUtil.getStackTrace(ex)); } log.error("Exception processing licenses for element" + e.getExtId(), ex); throw ex; } } data.getCustomEditorOperations().addAll(batchHolder.getEditorBatchToRead()); data.getCustomStorageOperations().addAll(batchHolder.getStorageBatchToRead()); return data; }
Set<String> uris = new HashSet<String>(); try { if (ctx.getElement().getElement()!=null) { for (Content content : ctx.getElement().getElement().getContents()) { for (ContentFile location : content.getLocations()) { uris.add(location.getAddress()); ctx.getElement().getExtId()); } else { try { ctx.getElement().getContentLicenses(), CatalogParamConstants.TAG_CONTENT_LICENSE_PREFIX, dataType.getLicensesToBeRemoved(),
/** * Retrieves publication date from ancestors or null when not found. * @param ce * @return */ protected Date getPublicationDateFromAncestors(CatalogElement ce) { if (ce!=null && ce.getAncestors()!=null) { List<Ancestor> anc = ce.getAncestors().getAncestorsOfHierarchy(ID_HIERARACHY_JOURNAL); if (anc!=null) { for (Ancestor currentAnc : anc) { if (currentAnc.getPublishedDate()!=null) { try { return currentAnc.getPublishedDate().getDate(); } catch (ParseException e) { log.error("unable to retrieve publication date from ancestor " + currentAnc.getExtid() + " of level " + currentAnc.getLevelExtid() + " of element " + ce.getExtId(), e); } } } } } // fallback return null; }
private void fillContent(final CatalogElement ce, final SElement sElement) throws YaddaException { // content files if (ce.getElement().getContents() != null && !ce.getElement().getContents().isEmpty()) { for (final Content content : ce.getElement().getContents()) { for (final ContentFile location : content.getLocations()) { final String fileAddress = location.getAddress(); if (ArchiveObjectPath.isValid(fileAddress)) { sElement.hasContent(true); } else { sElement.setRemoteContent(true); } } } // content licenses if (!Utils.emptyCollection(ce.getContentLicenses())) { for (final String license : ce.getContentLicenses()) { sElement.addContentLicense(license); } } } fillRemoteContent(ce, sElement); }